From 01a95326785a64f18e0f4be966142954671dcc11 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:46:17 +0100 Subject: [PATCH 1/3] Water whe doing - Fixed factory gauge sending incomplete orders when activating in the same tick as a competing gauge - Water wheels now maintain their texture material when pasted in a schematic --- .../kinetics/waterwheel/WaterWheelBlockEntity.java | 6 ++++++ .../factoryBoard/FactoryPanelBehaviour.java | 2 ++ .../logistics/packager/PackagerBlockEntity.java | 13 +++++++++---- .../packagerLink/LogisticallyLinkedBehaviour.java | 13 +++++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelBlockEntity.java index 36a60adeda..8eba206796 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelBlockEntity.java @@ -199,6 +199,12 @@ public class WaterWheelBlockEntity extends GeneratingKineticBlockEntity { redraw(); } + @Override + public void writeSafe(CompoundTag tag) { + super.writeSafe(tag); + tag.put("Material", NbtUtils.writeBlockState(material)); + } + @Override public void write(CompoundTag compound, boolean clientPacket) { super.write(compound, clientPacket); diff --git a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBehaviour.java index 88a6d32bbe..8d7a87e65b 100644 --- a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBehaviour.java @@ -778,6 +778,7 @@ public class FactoryPanelBehaviour extends FilteringBehaviour implements MenuPro CompoundTag panelTag = new CompoundTag(); super.write(panelTag, clientPacket); + panelTag.putInt("Timer", timer); panelTag.putInt("LastLevel", lastReportedLevelInStorage); panelTag.putInt("LastPromised", lastReportedPromises); panelTag.putInt("LastUnloadedLinks", lastReportedUnloadedLinks); @@ -813,6 +814,7 @@ public class FactoryPanelBehaviour extends FilteringBehaviour implements MenuPro filter = FilterItemStack.of(panelTag.getCompound("Filter")); count = panelTag.getInt("FilterAmount"); upTo = panelTag.getBoolean("UpTo"); + timer = panelTag.getInt("Timer"); lastReportedLevelInStorage = panelTag.getInt("LastLevel"); lastReportedPromises = panelTag.getInt("LastPromised"); lastReportedUnloadedLinks = panelTag.getInt("LastUnloadedLinks"); diff --git a/src/main/java/com/simibubi/create/content/logistics/packager/PackagerBlockEntity.java b/src/main/java/com/simibubi/create/content/logistics/packager/PackagerBlockEntity.java index 0765e89607..6d77e6be26 100644 --- a/src/main/java/com/simibubi/create/content/logistics/packager/PackagerBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/packager/PackagerBlockEntity.java @@ -260,7 +260,7 @@ public class PackagerBlockEntity extends SmartBlockEntity { BlockState blockState = getBlockState(); if (!blockState.hasProperty(PackagerBlock.LINKED)) return; - boolean shouldBeLinked = shouldBeLinked(); + boolean shouldBeLinked = getLinkPos() != null; boolean isLinked = blockState.getValue(PackagerBlock.LINKED); if (shouldBeLinked == isLinked) return; @@ -272,16 +272,16 @@ public class PackagerBlockEntity extends SmartBlockEntity { .orElse(false); } - private boolean shouldBeLinked() { + private BlockPos getLinkPos() { for (Direction d : Iterate.directions) { BlockState adjacentState = level.getBlockState(worldPosition.relative(d)); if (!AllBlocks.STOCK_LINK.has(adjacentState)) continue; if (PackagerLinkBlock.getConnectedDirection(adjacentState) != d) continue; - return true; + return worldPosition.relative(d); } - return false; + return null; } public void flashLink() { @@ -545,6 +545,11 @@ public class PackagerBlockEntity extends SmartBlockEntity { if (!requestQueue && !signBasedAddress.isBlank()) PackageItem.addAddress(createdBox, signBasedAddress); + BlockPos linkPos = getLinkPos(); + if (extractedPackageItem.isEmpty() && linkPos != null + && level.getBlockEntity(linkPos) instanceof PackagerLinkBlockEntity plbe) + plbe.behaviour.deductFromAccurateSummary(extractedItems); + if (!heldBox.isEmpty() || animationTicks != 0) { queuedExitingPackages.add(createdBox); return; diff --git a/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBehaviour.java index 942f1921e0..a4d3152417 100644 --- a/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBehaviour.java @@ -32,6 +32,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.ItemStackHandler; public class LogisticallyLinkedBehaviour extends BlockEntityBehaviour { @@ -185,6 +186,18 @@ public class LogisticallyLinkedBehaviour extends BlockEntityBehaviour { return plbe.fetchSummaryFromPackager(ignoredHandler); return InventorySummary.EMPTY; } + + public void deductFromAccurateSummary(ItemStackHandler packageContents) { + InventorySummary summary = LogisticsManager.ACCURATE_SUMMARIES.getIfPresent(freqId); + if (summary == null) + return; + for (int i = 0; i < packageContents.getSlots(); i++) { + ItemStack orderedStack = packageContents.getStackInSlot(i); + if (orderedStack.isEmpty()) + continue; + summary.add(orderedStack, -Math.min(summary.getCountOf(orderedStack), orderedStack.getCount())); + } + } // From adb3de04618473ad2a48055e3dbf2acce465aae2 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Fri, 14 Feb 2025 17:11:52 +0100 Subject: [PATCH 2/3] Update Contraption.java - Fixed vault rendering on contraptions --- .../com/simibubi/create/content/contraptions/Contraption.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/contraptions/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java index 0572798966..3a2a497861 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/Contraption.java @@ -684,6 +684,9 @@ public abstract class Contraption { toLocalPos(NbtUtils.readBlockPos(nbt.getCompound("Controller"))) : localPos; nbt.put("Controller", NbtUtils.writeBlockPos(controllerPos)); + + if (updateTags.containsKey(localPos)) + updateTags.get(localPos).put("Controller", NbtUtils.writeBlockPos(controllerPos)); if (multiBlockBE.isController() && multiBlockBE.getHeight() <= 1 && multiBlockBE.getWidth() <= 1) { nbt.put("LastKnownPos", NbtUtils.writeBlockPos(BlockPos.ZERO.below(Integer.MAX_VALUE - 1))); From 3d47f58daaa78e430c7de39aee0cad0799c0036d Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Fri, 14 Feb 2025 17:42:55 +0100 Subject: [PATCH 3/3] Autocompletely - Restocker gauge UI now suggests the address of the frog port on top of its packager --- .../create/content/logistics/AddressEditBox.java | 8 ++++++-- .../content/logistics/AddressEditBoxHelper.java | 7 ++++++- .../logistics/factoryBoard/FactoryPanelBehaviour.java | 11 +++++++++++ .../logistics/factoryBoard/FactoryPanelScreen.java | 4 ++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/AddressEditBox.java b/src/main/java/com/simibubi/create/content/logistics/AddressEditBox.java index 1f096fbd71..d978c8917c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/AddressEditBox.java +++ b/src/main/java/com/simibubi/create/content/logistics/AddressEditBox.java @@ -25,10 +25,14 @@ public class AddressEditBox extends EditBox { private DestinationSuggestions destinationSuggestions; private Consumer mainResponder; private String prevValue = "=)"; - + public AddressEditBox(Screen screen, Font pFont, int pX, int pY, int pWidth, int pHeight, boolean anchorToBottom) { + this(screen, pFont, pX, pY, pWidth, pHeight, anchorToBottom, null); + } + + public AddressEditBox(Screen screen, Font pFont, int pX, int pY, int pWidth, int pHeight, boolean anchorToBottom, String localAddress) { super(pFont, pX, pY, pWidth, pHeight, Component.empty()); - destinationSuggestions = AddressEditBoxHelper.createSuggestions(screen, this, anchorToBottom); + destinationSuggestions = AddressEditBoxHelper.createSuggestions(screen, this, anchorToBottom, localAddress); destinationSuggestions.setAllowSuggestions(true); destinationSuggestions.updateCommandInfo(); mainResponder = t -> { diff --git a/src/main/java/com/simibubi/create/content/logistics/AddressEditBoxHelper.java b/src/main/java/com/simibubi/create/content/logistics/AddressEditBoxHelper.java index 8cf84038fe..47f159f980 100644 --- a/src/main/java/com/simibubi/create/content/logistics/AddressEditBoxHelper.java +++ b/src/main/java/com/simibubi/create/content/logistics/AddressEditBoxHelper.java @@ -38,7 +38,7 @@ public class AddressEditBoxHelper { NEARBY_CLIPBOARDS.put(blockPos, new WeakReference<>(blockEntity)); } - public static DestinationSuggestions createSuggestions(Screen screen, EditBox pInput, boolean anchorToBottom) { + public static DestinationSuggestions createSuggestions(Screen screen, EditBox pInput, boolean anchorToBottom, String localAddress) { Minecraft mc = Minecraft.getInstance(); Player player = mc.player; List> options = new ArrayList<>(); @@ -49,6 +49,11 @@ public class AddressEditBoxHelper { if (player == null) return destinationSuggestions; + + if (localAddress != null) { + options.add(IntAttached.with(-1, localAddress)); + alreadyAdded.add(localAddress); + } for (int i = 0; i < Inventory.INVENTORY_SIZE; i++) appendAddresses(options, alreadyAdded, player.getInventory() diff --git a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBehaviour.java index 8d7a87e65b..ce280b1c74 100644 --- a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBehaviour.java @@ -26,6 +26,7 @@ import com.simibubi.create.content.logistics.BigItemStack; import com.simibubi.create.content.logistics.factoryBoard.FactoryPanelBlock.PanelSlot; import com.simibubi.create.content.logistics.filter.FilterItem; import com.simibubi.create.content.logistics.filter.FilterItemStack; +import com.simibubi.create.content.logistics.packagePort.frogport.FrogportBlockEntity; import com.simibubi.create.content.logistics.packager.InventorySummary; import com.simibubi.create.content.logistics.packager.PackagerBlockEntity; import com.simibubi.create.content.logistics.packager.PackagingRequest; @@ -1057,4 +1058,14 @@ public class FactoryPanelBehaviour extends FilteringBehaviour implements MenuPro .getName(); } + public String getFrogAddress() { + PackagerBlockEntity packager = panelBE().getRestockedPackager(); + if (packager == null) + return null; + if (packager.getLevel().getBlockEntity(packager.getBlockPos().above()) instanceof FrogportBlockEntity fpbe) + if (fpbe.addressFilter != null && !fpbe.addressFilter.isBlank()) + return fpbe.addressFilter + ""; + return null; + } + } diff --git a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelScreen.java b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelScreen.java index ae323c23ee..eb39a2148c 100644 --- a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelScreen.java @@ -154,8 +154,8 @@ public class FactoryPanelScreen extends AbstractSimiScreen { int y = guiTop; if (addressBox == null) { - addressBox = - new AddressEditBox(this, new NoShadowFontWrapper(font), x + 36, y + windowHeight - 51, 108, 10, false); + String frogAddress = behaviour.getFrogAddress(); + addressBox = new AddressEditBox(this, new NoShadowFontWrapper(font), x + 36, y + windowHeight - 51, 108, 10, false, frogAddress); addressBox.setValue(behaviour.recipeAddress); addressBox.setTextColor(0x555555); }