Fiery containers

- Fix #2812
This commit is contained in:
PepperCode1 2022-03-23 18:15:59 -07:00
parent a31d713958
commit bf1b6382ee
3 changed files with 17 additions and 15 deletions

View file

@ -162,13 +162,11 @@ public class BlazeBurnerBlock extends Block implements ITE<BlazeBurnerTileEntity
return InteractionResultHolder.fail(ItemStack.EMPTY); return InteractionResultHolder.fail(ItemStack.EMPTY);
if (!doNotConsume) { if (!doNotConsume) {
ItemStack container = stack.getContainerItem(); ItemStack container = stack.hasContainerItem() ? stack.getContainerItem() : ItemStack.EMPTY;
if (!world.isClientSide && !simulate) { if (!world.isClientSide) {
stack.shrink(1); stack.shrink(1);
} }
if (!container.isEmpty()) { return InteractionResultHolder.success(container);
return InteractionResultHolder.success(container);
}
} }
return InteractionResultHolder.success(ItemStack.EMPTY); return InteractionResultHolder.success(ItemStack.EMPTY);
} }

View file

@ -42,7 +42,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils; import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.InteractionResult; import net.minecraft.world.Containers;
import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -332,15 +332,15 @@ public abstract class ArmInteractionPoint {
@Override @Override
protected ItemStack insert(Level world, ItemStack stack, boolean simulate) { protected ItemStack insert(Level world, ItemStack stack, boolean simulate) {
ItemStack input = stack.copy(); ItemStack input = stack.copy();
if (!BlazeBurnerBlock.tryInsert(state, world, pos, input, false, false, true)
.getObject()
.isEmpty()) {
return stack;
}
InteractionResultHolder<ItemStack> res = BlazeBurnerBlock.tryInsert(state, world, pos, input, false, false, simulate); InteractionResultHolder<ItemStack> res = BlazeBurnerBlock.tryInsert(state, world, pos, input, false, false, simulate);
return res.getResult() == InteractionResult.SUCCESS ItemStack remainder = res.getObject();
? ItemHandlerHelper.copyStackWithSize(stack, stack.getCount() - 1) if (input.isEmpty()) {
: stack; return remainder;
} else {
if (!simulate)
Containers.dropItemStack(world, pos.getX(), pos.getY(), pos.getZ(), remainder);
return input;
}
} }
@Override @Override

View file

@ -313,7 +313,11 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE
protected int getDistributableAmount(ArmInteractionPoint armInteractionPoint, int i) { protected int getDistributableAmount(ArmInteractionPoint armInteractionPoint, int i) {
ItemStack stack = armInteractionPoint.extract(level, i, true); ItemStack stack = armInteractionPoint.extract(level, i, true);
ItemStack remainder = simulateInsertion(stack); ItemStack remainder = simulateInsertion(stack);
return stack.getCount() - remainder.getCount(); if (stack.sameItem(remainder)) {
return stack.getCount() - remainder.getCount();
} else {
return stack.getCount();
}
} }
protected void depositItem() { protected void depositItem() {