diff --git a/resources/changelog/1.19.2-1.2.39.txt b/resources/changelog/1.19.2-1.2.39.txt new file mode 100644 index 0000000000..15c6124479 --- /dev/null +++ b/resources/changelog/1.19.2-1.2.39.txt @@ -0,0 +1,6 @@ +As always, don't forget to backup your world before updating! +Requires CyclopsCore version 1.17.0 or higher. + +Fixes: +* Fix crash when copy_tank_data loot function is applied to wrong block, Closes #1056 + diff --git a/src/main/java/org/cyclops/evilcraft/loot/functions/LootFunctionCopyTankData.java b/src/main/java/org/cyclops/evilcraft/loot/functions/LootFunctionCopyTankData.java index 324bbd912d..fa8bb560b0 100644 --- a/src/main/java/org/cyclops/evilcraft/loot/functions/LootFunctionCopyTankData.java +++ b/src/main/java/org/cyclops/evilcraft/loot/functions/LootFunctionCopyTankData.java @@ -31,17 +31,18 @@ protected LootFunctionCopyTankData(LootItemCondition[] conditionsIn) { @Override public ItemStack run(ItemStack itemStack, LootContext lootContext) { - BlockEntityTankInventory tile = (BlockEntityTankInventory) lootContext.getParamOrNull(LootContextParams.BLOCK_ENTITY); - SingleUseTank fluidHandlerTile = tile.getTank(); - itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) - .ifPresent(fluidHandlerItem -> { - if (fluidHandlerItem instanceof IFluidHandlerMutable) { - ((IFluidHandlerMutable) fluidHandlerItem).setFluidInTank(0, fluidHandlerTile.getFluidInTank(0)); - } - if (fluidHandlerItem instanceof IFluidHandlerItemCapacity) { - ((IFluidHandlerItemCapacity) fluidHandlerItem).setCapacity(fluidHandlerTile.getTankCapacity(0)); - } - }); + if (lootContext.getParamOrNull(LootContextParams.BLOCK_ENTITY) instanceof BlockEntityTankInventory tile) { + SingleUseTank fluidHandlerTile = tile.getTank(); + itemStack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM) + .ifPresent(fluidHandlerItem -> { + if (fluidHandlerItem instanceof IFluidHandlerMutable) { + ((IFluidHandlerMutable) fluidHandlerItem).setFluidInTank(0, fluidHandlerTile.getFluidInTank(0)); + } + if (fluidHandlerItem instanceof IFluidHandlerItemCapacity) { + ((IFluidHandlerItemCapacity) fluidHandlerItem).setCapacity(fluidHandlerTile.getTankCapacity(0)); + } + }); + } return itemStack; }