From cb257b105b89d03c6cb2a13846bd16e1f5eac7d6 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Tue, 9 Aug 2022 01:06:19 +0300 Subject: [PATCH] Fluid Cells to play more nicely in creative. --- src/main/java/techreborn/items/DynamicCellItem.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/techreborn/items/DynamicCellItem.java b/src/main/java/techreborn/items/DynamicCellItem.java index 1f183cdd2..36400a329 100644 --- a/src/main/java/techreborn/items/DynamicCellItem.java +++ b/src/main/java/techreborn/items/DynamicCellItem.java @@ -81,6 +81,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo { } // Thanks vanilla :) + @SuppressWarnings("deprecation") private void playEmptyingSound(@Nullable PlayerEntity playerEntity, WorldAccess world, BlockPos blockPos, Fluid fluid) { SoundEvent soundEvent = fluid.isIn(FluidTags.LAVA) ? SoundEvents.ITEM_BUCKET_EMPTY_LAVA : SoundEvents.ITEM_BUCKET_EMPTY; world.playSound(playerEntity, blockPos, soundEvent, SoundCategory.BLOCKS, 1.0F, 1.0F); @@ -121,6 +122,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo { if (!blockState.isAir() && !canPlace && (!(blockState.getBlock() instanceof FluidFillable) || !((FluidFillable) blockState.getBlock()).canFillWithFluid(world, pos, blockState, fluid))) { return hitResult != null && this.placeFluid(player, world, hitResult.getBlockPos().offset(hitResult.getSide()), null, filledCell); } else { + //noinspection deprecation if (world.getDimension().ultrawarm() && fluid.isIn(FluidTags.WATER)) { int i = pos.getX(); int j = pos.getY(); @@ -207,7 +209,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo { world.emitGameEvent(player, GameEvent.FLUID_PICKUP, hitPos); // Replace bucket item with cell item itemStack = getCellWithFluid(drainFluid, 1); - ItemStack resultStack = ItemUsage.exchangeStack(stack, player, itemStack); + ItemStack resultStack = ItemUsage.exchangeStack(stack, player, itemStack, false); return TypedActionResult.success(resultStack, world.isClient()); } } else { @@ -215,6 +217,10 @@ public class DynamicCellItem extends Item implements ItemFluidInfo { if (placeState.canBucketPlace(containedFluid)) { placeFluid(player, world, placePos, hitResult, stack); + if (player.getAbilities().creativeMode) { + return TypedActionResult.success(stack); + } + if (stack.getCount() == 1) { stack = getEmpty(); } else { @@ -252,10 +258,12 @@ public class DynamicCellItem extends Item implements ItemFluidInfo { return Fluids.EMPTY; } + @SuppressWarnings("UnstableApiUsage") public void registerFluidApi() { FluidStorage.ITEM.registerForItems((stack, ctx) -> new CellStorage(ctx), this); } + @SuppressWarnings("UnstableApiUsage") public class CellStorage extends SingleVariantItemStorage { public CellStorage(ContainerItemContext context) { super(context);