diff --git a/src/main/java/com/simibubi/create/content/contraptions/behaviour/FenceGateMovingInteraction.java b/src/main/java/com/simibubi/create/content/contraptions/behaviour/FenceGateMovingInteraction.java index 95510d99a..340dc0b56 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/behaviour/FenceGateMovingInteraction.java +++ b/src/main/java/com/simibubi/create/content/contraptions/behaviour/FenceGateMovingInteraction.java @@ -7,7 +7,6 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.FenceGateBlock; -import net.minecraft.world.level.block.TrapDoorBlock; import net.minecraft.world.level.block.state.BlockState; public class FenceGateMovingInteraction extends SimpleBlockMovingInteraction { diff --git a/src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java b/src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java index 9d82d5ce4..ee4292c77 100644 --- a/src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java @@ -380,6 +380,9 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf inserter = BlockEntityBehaviour.get(level, be.getBlockPos(), InvManipulationBehaviour.TYPE); } + if (be instanceof BasinBlockEntity) + filter = null; // Do not test spout outputs against the recipe filter + IItemHandler targetInv = be == null ? null : be.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite()) .orElse(inserter == null ? null : inserter.getInventory()); @@ -402,16 +405,21 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf if (targetInv == null) break; - if (!ItemHandlerHelper.insertItemStacked(targetInv, itemStack, true) - .isEmpty()) + + ItemStack remainder = ItemHandlerHelper.insertItemStacked(targetInv, itemStack, true); + if (remainder.getCount() == itemStack.getCount()) continue; if (filter != null && !filter.test(itemStack)) continue; - update = true; - ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), false); - iterator.remove(); visualizedOutputItems.add(IntAttached.withZero(itemStack)); + update = true; + + remainder = ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), false); + if (remainder.isEmpty()) + iterator.remove(); + else + itemStack.setCount(remainder.getCount()); } for (Iterator iterator = spoutputFluidBuffer.iterator(); iterator.hasNext();) { @@ -547,9 +555,9 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf if (simulate) return true; - for (ItemStack itemStack : outputItems) { - spoutputBuffer.add(itemStack.copy()); - } + for (ItemStack itemStack : outputItems) + if (!itemStack.isEmpty()) + spoutputBuffer.add(itemStack.copy()); if (!externalTankNotPresent) for (FluidStack fluidStack : outputFluids) spoutputFluidBuffer.add(fluidStack.copy()); @@ -604,7 +612,9 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf public static HeatLevel getHeatLevelOf(BlockState state) { if (state.hasProperty(BlazeBurnerBlock.HEAT_LEVEL)) return state.getValue(BlazeBurnerBlock.HEAT_LEVEL); - return AllTags.AllBlockTags.PASSIVE_BOILER_HEATERS.matches(state) && BlockHelper.isNotUnheated(state) ? HeatLevel.SMOULDERING : HeatLevel.NONE; + return AllTags.AllBlockTags.PASSIVE_BOILER_HEATERS.matches(state) && BlockHelper.isNotUnheated(state) + ? HeatLevel.SMOULDERING + : HeatLevel.NONE; } public Couple getTanks() { diff --git a/src/main/java/com/simibubi/create/content/processing/basin/BasinInventory.java b/src/main/java/com/simibubi/create/content/processing/basin/BasinInventory.java index 0c88d4d0d..63121355d 100644 --- a/src/main/java/com/simibubi/create/content/processing/basin/BasinInventory.java +++ b/src/main/java/com/simibubi/create/content/processing/basin/BasinInventory.java @@ -13,16 +13,29 @@ public class BasinInventory extends SmartInventory { super(slots, be, 16, true); this.blockEntity = be; } - + @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - // Only insert if no other slot already has a stack of this item - for (int i = 0; i < getSlots(); i++) + int firstFreeSlot = -1; + + for (int i = 0; i < getSlots(); i++) { + // Only insert if no other slot already has a stack of this item if (i != slot && ItemHandlerHelper.canItemStacksStack(stack, inv.getStackInSlot(i))) return stack; + if (inv.getStackInSlot(i) + .isEmpty() && firstFreeSlot == -1) + firstFreeSlot = i; + } + + // Only insert if this is the first empty slot, prevents overfilling in the + // simulation pass + if (inv.getStackInSlot(slot) + .isEmpty() && firstFreeSlot != slot) + return stack; + return super.insertItem(slot, stack, simulate); } - + @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { ItemStack extractItem = super.extractItem(slot, amount, simulate); diff --git a/src/main/java/com/simibubi/create/content/processing/basin/BasinRecipe.java b/src/main/java/com/simibubi/create/content/processing/basin/BasinRecipe.java index 9a86e0066..0db6e6eec 100644 --- a/src/main/java/com/simibubi/create/content/processing/basin/BasinRecipe.java +++ b/src/main/java/com/simibubi/create/content/processing/basin/BasinRecipe.java @@ -149,13 +149,22 @@ public class BasinRecipe extends ProcessingRecipe { if (simulate) { if (recipe instanceof BasinRecipe basinRecipe) { recipeOutputItems.addAll(basinRecipe.rollResults()); - recipeOutputFluids.addAll(basinRecipe.getFluidResults()); - recipeOutputItems.addAll(basinRecipe.getRemainingItems(basin.getInputInventory())); + + for (FluidStack fluidStack : basinRecipe.getFluidResults()) + if (!fluidStack.isEmpty()) + recipeOutputFluids.add(fluidStack); + for (ItemStack stack : basinRecipe.getRemainingItems(basin.getInputInventory())) + if (!stack.isEmpty()) + recipeOutputItems.add(stack); + } else { recipeOutputItems.add(recipe.getResultItem()); if (recipe instanceof CraftingRecipe craftingRecipe) { - recipeOutputItems.addAll(craftingRecipe.getRemainingItems(new DummyCraftingContainer(availableItems, extractedItemsFromSlot))); + for (ItemStack stack : craftingRecipe + .getRemainingItems(new DummyCraftingContainer(availableItems, extractedItemsFromSlot))) + if (!stack.isEmpty()) + recipeOutputItems.add(stack); } } }