diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 1d0b58346b..98e49fff43 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -558,7 +558,7 @@ public class AllBlocks { public static final BlockEntry WATER_WHEEL_STRUCTURAL = REGISTRATE.block("water_wheel_structure", WaterWheelStructuralBlock::new) - .initialProperties(SharedProperties::wooden) + //.initialProperties(SharedProperties::wooden) fabric: make structual blocks non flammable .blockstate((c, p) -> p.getVariantBuilder(c.get()) .forAllStatesExcept(BlockStateGen.mapToAir(p), WaterWheelStructuralBlock.FACING)) .properties(p -> p.noOcclusion().color(MaterialColor.DIRT)) diff --git a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelStructuralBlock.java b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelStructuralBlock.java index b15214802e..e3fe1fbe9e 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelStructuralBlock.java +++ b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelStructuralBlock.java @@ -205,8 +205,9 @@ public BlockPos getInformationSource(Level level, BlockPos pos, BlockState state return stillValid(level, pos, state, false) ? getMaster(level, pos, state) : pos; } - @Override - public boolean isFlammable(BlockState state, BlockGetter level, BlockPos pos, Direction direction) { - return false; - } + // fabric: handled in AllBlocks by not giving it the wood material +// @Override +// public boolean isFlammable(BlockState state, BlockGetter level, BlockPos pos, Direction direction) { +// return false; +// } } 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 1348115586..198d450cfa 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 @@ -455,8 +455,8 @@ private void tryClearingSpoutputOverflow() { if (targetInv == null) break; - ItemStack remainder = ItemHandlerHelper.insertItemStacked(targetInv, itemStack, true); - if (remainder.getCount() == itemStack.getCount()) + long inserted = TransferUtil.insertItem(targetInv, itemStack); + if (inserted == 0) continue; if (filter != null && !filter.test(itemStack)) continue; @@ -464,11 +464,11 @@ private void tryClearingSpoutputOverflow() { visualizedOutputItems.add(LongAttached.withZero(itemStack)); update = true; - remainder = ItemHandlerHelper.insertItemStacked(targetInv, itemStack.copy(), false); - if (remainder.isEmpty()) + inserted = TransferUtil.insertItem(targetInv, itemStack.copy()); + if (inserted == itemStack.getCount()) iterator.remove(); else - itemStack.setCount(remainder.getCount()); + itemStack.setCount((int) inserted); } for (Iterator iterator = spoutputFluidBuffer.iterator(); iterator.hasNext();) { 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 09dd322e2e..40c62b353a 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 @@ -3,9 +3,9 @@ import com.simibubi.create.foundation.item.SmartInventory; import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant; +import net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions; +import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction; import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.items.ItemHandlerHelper; public class BasinInventory extends SmartInventory { @@ -18,44 +18,34 @@ public BasinInventory(int slots, BasinBlockEntity be) { @Override public long insert(ItemVariant resource, long maxAmount, TransactionContext transaction) { + StoragePreconditions.notBlankNotNegative(resource, maxAmount); + if (!insertionAllowed) + return 0; // 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; + try (Transaction test = transaction.openNested()) { + long contained = this.extract(resource, Long.MAX_VALUE, test); + if (contained != 0) { + // already have this item. can we stack? + long maxStackSize = Math.min(stackSize, resource.getItem().getMaxStackSize()); + long space = Math.max(0, maxStackSize - contained); + if (space <= 0) { + // nope. + return 0; + } else { + // yes! + maxAmount = Math.min(space, maxAmount); + } + } + } return super.insert(resource, maxAmount, transaction); } @Override - public ItemStack extractItem(int slot, int amount, boolean simulate) { - ItemStack extractItem = super.extractItem(slot, amount, simulate); - if (!simulate && !extractItem.isEmpty()) + public long extract(ItemVariant resource, long maxAmount, TransactionContext transaction) { + long extractedAmount = super.extract(resource, maxAmount, transaction); + if (extractedAmount != 0) blockEntity.notifyChangeOfContents(); - return extractItem; + return extractedAmount; } - // old code: - // @Override - // public long insert(ItemVariant resource, long maxAmount, TransactionContext transaction) { - // StoragePreconditions.notBlankNotNegative(resource, maxAmount); - // if (!insertionAllowed) - // return 0; - // // Only insert if no other slot already has a stack of this item - // try (Transaction test = transaction.openNested()) { - // long contained = this.extract(resource, Long.MAX_VALUE, test); - // if (contained != 0) { - // // already have this item. can we stack? - // long maxStackSize = Math.min(stackSize, resource.getItem().getMaxStackSize()); - // long space = Math.max(0, maxStackSize - contained); - // if (space <= 0) { - // // nope. - // return 0; - // } else { - // // yes! - // maxAmount = Math.min(space, maxAmount); - // } - // } - // } - // return super.insert(resource, maxAmount, transaction); - // } - }