Baiting the hotfix

- Fixed basin inventory pretending to accept full stacks when empty #3104
- Fixed basin spout outputs getting voided when targeting another basin #6451 #6474
- Fixed basin spout outputs not working when targeting a basin with a recipe filter
This commit is contained in:
simibubi 2024-07-16 17:43:48 +02:00
parent f29d26705c
commit 661e5c5aef
4 changed files with 48 additions and 17 deletions

View file

@ -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 {

View file

@ -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<FluidStack> 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<SmartFluidTankBehaviour> getTanks() {

View file

@ -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);

View file

@ -149,13 +149,22 @@ public class BasinRecipe extends ProcessingRecipe<SmartInventory> {
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);
}
}
}