From 983fe9b068f84fb3bd8f475a245dd2992485e763 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 5 Sep 2024 16:52:51 +0200 Subject: [PATCH 1/2] Fix crash when copy_tank_data loot function is applied to wrong block Closes #1056 --- .../functions/LootFunctionCopyTankData.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) 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 662231f0ce..7904eec4f9 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(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) - .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(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY) + .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; } From d902f16213acbb5b244c6b1cb44f19817ceaed35 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 5 Sep 2024 16:53:45 +0200 Subject: [PATCH 2/2] Bump mod version --- gradle.properties | 2 +- resources/changelog/1.19.2-1.2.39.txt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 resources/changelog/1.19.2-1.2.39.txt diff --git a/gradle.properties b/gradle.properties index caff7297ce..2acd0204ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -mod_version=1.2.38 +mod_version=1.2.39 minecraft_version=1.19.2 forge_version=43.0.8 cyclopscore_version=1.17.0-237 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 +