use pattern variables

This commit is contained in:
dfsek
2021-11-27 08:34:03 -07:00
parent 2d316fa042
commit 2307897b31
16 changed files with 33 additions and 58 deletions

View File

@@ -40,12 +40,11 @@ public class BufferedLootApplication implements BufferedItem {
public void paste(Vector3 origin, World world) {
try {
BlockEntity data = world.getBlockState(origin);
if(!(data instanceof Container)) {
if(!(data instanceof Container container)) {
LOGGER.error("Failed to place loot at {}; block {} is not a container", origin, data);
return;
}
Container container = (Container) data;
LootPopulateEvent event = new LootPopulateEvent(container, table, world.getConfig().getPack(), structure);
platform.getEventManager().callEvent(event);
if(event.isCancelled()) return;

View File

@@ -33,8 +33,7 @@ public class Block implements Item<Block.ReturnInfo<?>> {
Map<String, Variable<?>> scope = new HashMap<>(variableMap);
for(Item<?> item : items) {
Object result = item.apply(implementationArguments, scope);
if(result instanceof ReturnInfo) {
ReturnInfo<?> level = (ReturnInfo<?>) result;
if(result instanceof ReturnInfo<?> level) {
if(!level.getLevel().equals(ReturnLevel.NONE)) return level;
}
}