From 4c26627b733376639c1068a5f7800a818b0e5d7b Mon Sep 17 00:00:00 2001 From: tterrag Date: Sun, 13 Dec 2020 15:04:55 -0500 Subject: [PATCH] Fix blaze burner consuming buckets, arm no longer inserts lava buckets --- .../processing/burner/BlazeBurnerBlock.java | 30 ++++++++++++++----- .../mechanicalArm/ArmInteractionPoint.java | 10 +++++-- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java index b6ae0d8c6..4f91a76bb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerBlock.java @@ -27,6 +27,7 @@ import net.minecraft.state.EnumProperty; import net.minecraft.state.IProperty; import net.minecraft.state.StateContainer.Builder; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.util.IItemProvider; @@ -123,29 +124,42 @@ public class BlazeBurnerBlock extends Block implements ITE res = tryInsert(state, world, pos, dontConsume ? heldItem.copy() : heldItem, forceOverflow, false); + ItemStack leftover = res.getResult(); + if (!world.isRemote && !dontConsume && !leftover.isEmpty()) { + if (heldItem.isEmpty()) { + player.setHeldItem(hand, leftover); + } else if (!player.inventory.addItemStackToInventory(leftover)) { + player.dropItem(leftover, false); + } + } + + return res.getType() == ActionResultType.SUCCESS ? res.getType() : ActionResultType.PASS; } - public static boolean tryInsert(BlockState state, World world, BlockPos pos, ItemStack stack, boolean forceOverflow, + public static ActionResult tryInsert(BlockState state, World world, BlockPos pos, ItemStack stack, boolean forceOverflow, boolean simulate) { if (!state.hasTileEntity()) - return false; + return ActionResult.fail(ItemStack.EMPTY); TileEntity te = world.getTileEntity(pos); if (!(te instanceof BlazeBurnerTileEntity)) - return false; + return ActionResult.fail(ItemStack.EMPTY); BlazeBurnerTileEntity burnerTE = (BlazeBurnerTileEntity) te; if (!burnerTE.tryUpdateFuel(stack, forceOverflow, simulate)) - return false; + return ActionResult.fail(ItemStack.EMPTY); + + ItemStack container = stack.getContainerItem(); if (!simulate && !world.isRemote) { world.playSound(null, pos, SoundEvents.ENTITY_BLAZE_SHOOT, SoundCategory.BLOCKS, .125f + world.rand.nextFloat() * .125f, .75f - world.rand.nextFloat() * .25f); stack.shrink(1); } - return true; + if (!container.isEmpty()) { + return ActionResult.success(container); + } + return ActionResult.success(ItemStack.EMPTY); } @Override diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java index 039e0e37a..99a83a092 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java @@ -36,6 +36,8 @@ import net.minecraft.nbt.NBTUtil; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.JukeboxTileEntity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResult; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -277,8 +279,12 @@ public abstract class ArmInteractionPoint { @Override ItemStack insert(World world, ItemStack stack, boolean simulate) { - boolean success = BlazeBurnerBlock.tryInsert(state, world, pos, stack.copy(), false, simulate); - return success ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1) : stack; + ItemStack input = stack.copy(); + if (!BlazeBurnerBlock.tryInsert(state, world, pos, input, false, true).getResult().isEmpty()) { + return stack; + } + ActionResult res = BlazeBurnerBlock.tryInsert(state, world, pos, input, false, simulate); + return res.getType() == ActionResultType.SUCCESS ? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1) : stack; } @Override