mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
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:
parent
f29d26705c
commit
661e5c5aef
4 changed files with 48 additions and 17 deletions
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
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() {
|
||||
|
|
|
@ -16,10 +16,23 @@ public class BasinInventory extends SmartInventory {
|
|||
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||
int firstFreeSlot = -1;
|
||||
|
||||
for (int i = 0; i < getSlots(); i++) {
|
||||
// Only insert if no other slot already has a stack of this item
|
||||
for (int i = 0; i < getSlots(); i++)
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue