Merge remote-tracking branch 'concealed/mc1.20.1/feature-dev' into mc1.20.1/feature-dev

This commit is contained in:
IThundxr 2025-02-15 11:53:33 -05:00
commit b28427fe2d
Failed to generate hash of commit
8 changed files with 58 additions and 9 deletions

View file

@ -684,6 +684,9 @@ public abstract class Contraption {
toLocalPos(NbtUtils.readBlockPos(nbt.getCompound("Controller"))) : toLocalPos(NbtUtils.readBlockPos(nbt.getCompound("Controller"))) :
localPos; localPos;
nbt.put("Controller", NbtUtils.writeBlockPos(controllerPos)); 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) { if (multiBlockBE.isController() && multiBlockBE.getHeight() <= 1 && multiBlockBE.getWidth() <= 1) {
nbt.put("LastKnownPos", NbtUtils.writeBlockPos(BlockPos.ZERO.below(Integer.MAX_VALUE - 1))); nbt.put("LastKnownPos", NbtUtils.writeBlockPos(BlockPos.ZERO.below(Integer.MAX_VALUE - 1)));

View file

@ -199,6 +199,12 @@ public class WaterWheelBlockEntity extends GeneratingKineticBlockEntity {
redraw(); redraw();
} }
@Override
public void writeSafe(CompoundTag tag) {
super.writeSafe(tag);
tag.put("Material", NbtUtils.writeBlockState(material));
}
@Override @Override
public void write(CompoundTag compound, boolean clientPacket) { public void write(CompoundTag compound, boolean clientPacket) {
super.write(compound, clientPacket); super.write(compound, clientPacket);

View file

@ -25,10 +25,14 @@ public class AddressEditBox extends EditBox {
private DestinationSuggestions destinationSuggestions; private DestinationSuggestions destinationSuggestions;
private Consumer<String> mainResponder; private Consumer<String> mainResponder;
private String prevValue = "=)"; private String prevValue = "=)";
public AddressEditBox(Screen screen, Font pFont, int pX, int pY, int pWidth, int pHeight, boolean anchorToBottom) { 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()); 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.setAllowSuggestions(true);
destinationSuggestions.updateCommandInfo(); destinationSuggestions.updateCommandInfo();
mainResponder = t -> { mainResponder = t -> {

View file

@ -38,7 +38,7 @@ public class AddressEditBoxHelper {
NEARBY_CLIPBOARDS.put(blockPos, new WeakReference<>(blockEntity)); 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(); Minecraft mc = Minecraft.getInstance();
Player player = mc.player; Player player = mc.player;
List<IntAttached<String>> options = new ArrayList<>(); List<IntAttached<String>> options = new ArrayList<>();
@ -49,6 +49,11 @@ public class AddressEditBoxHelper {
if (player == null) if (player == null)
return destinationSuggestions; return destinationSuggestions;
if (localAddress != null) {
options.add(IntAttached.with(-1, localAddress));
alreadyAdded.add(localAddress);
}
for (int i = 0; i < Inventory.INVENTORY_SIZE; i++) for (int i = 0; i < Inventory.INVENTORY_SIZE; i++)
appendAddresses(options, alreadyAdded, player.getInventory() appendAddresses(options, alreadyAdded, player.getInventory()

View file

@ -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.factoryBoard.FactoryPanelBlock.PanelSlot;
import com.simibubi.create.content.logistics.filter.FilterItem; import com.simibubi.create.content.logistics.filter.FilterItem;
import com.simibubi.create.content.logistics.filter.FilterItemStack; 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.InventorySummary;
import com.simibubi.create.content.logistics.packager.PackagerBlockEntity; import com.simibubi.create.content.logistics.packager.PackagerBlockEntity;
import com.simibubi.create.content.logistics.packager.PackagingRequest; import com.simibubi.create.content.logistics.packager.PackagingRequest;
@ -778,6 +779,7 @@ public class FactoryPanelBehaviour extends FilteringBehaviour implements MenuPro
CompoundTag panelTag = new CompoundTag(); CompoundTag panelTag = new CompoundTag();
super.write(panelTag, clientPacket); super.write(panelTag, clientPacket);
panelTag.putInt("Timer", timer);
panelTag.putInt("LastLevel", lastReportedLevelInStorage); panelTag.putInt("LastLevel", lastReportedLevelInStorage);
panelTag.putInt("LastPromised", lastReportedPromises); panelTag.putInt("LastPromised", lastReportedPromises);
panelTag.putInt("LastUnloadedLinks", lastReportedUnloadedLinks); panelTag.putInt("LastUnloadedLinks", lastReportedUnloadedLinks);
@ -813,6 +815,7 @@ public class FactoryPanelBehaviour extends FilteringBehaviour implements MenuPro
filter = FilterItemStack.of(panelTag.getCompound("Filter")); filter = FilterItemStack.of(panelTag.getCompound("Filter"));
count = panelTag.getInt("FilterAmount"); count = panelTag.getInt("FilterAmount");
upTo = panelTag.getBoolean("UpTo"); upTo = panelTag.getBoolean("UpTo");
timer = panelTag.getInt("Timer");
lastReportedLevelInStorage = panelTag.getInt("LastLevel"); lastReportedLevelInStorage = panelTag.getInt("LastLevel");
lastReportedPromises = panelTag.getInt("LastPromised"); lastReportedPromises = panelTag.getInt("LastPromised");
lastReportedUnloadedLinks = panelTag.getInt("LastUnloadedLinks"); lastReportedUnloadedLinks = panelTag.getInt("LastUnloadedLinks");
@ -1055,4 +1058,14 @@ public class FactoryPanelBehaviour extends FilteringBehaviour implements MenuPro
.getName(); .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;
}
} }

View file

@ -154,8 +154,8 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
int y = guiTop; int y = guiTop;
if (addressBox == null) { if (addressBox == null) {
addressBox = String frogAddress = behaviour.getFrogAddress();
new AddressEditBox(this, new NoShadowFontWrapper(font), x + 36, y + windowHeight - 51, 108, 10, false); addressBox = new AddressEditBox(this, new NoShadowFontWrapper(font), x + 36, y + windowHeight - 51, 108, 10, false, frogAddress);
addressBox.setValue(behaviour.recipeAddress); addressBox.setValue(behaviour.recipeAddress);
addressBox.setTextColor(0x555555); addressBox.setTextColor(0x555555);
} }

View file

@ -260,7 +260,7 @@ public class PackagerBlockEntity extends SmartBlockEntity {
BlockState blockState = getBlockState(); BlockState blockState = getBlockState();
if (!blockState.hasProperty(PackagerBlock.LINKED)) if (!blockState.hasProperty(PackagerBlock.LINKED))
return; return;
boolean shouldBeLinked = shouldBeLinked(); boolean shouldBeLinked = getLinkPos() != null;
boolean isLinked = blockState.getValue(PackagerBlock.LINKED); boolean isLinked = blockState.getValue(PackagerBlock.LINKED);
if (shouldBeLinked == isLinked) if (shouldBeLinked == isLinked)
return; return;
@ -272,16 +272,16 @@ public class PackagerBlockEntity extends SmartBlockEntity {
.orElse(false); .orElse(false);
} }
private boolean shouldBeLinked() { private BlockPos getLinkPos() {
for (Direction d : Iterate.directions) { for (Direction d : Iterate.directions) {
BlockState adjacentState = level.getBlockState(worldPosition.relative(d)); BlockState adjacentState = level.getBlockState(worldPosition.relative(d));
if (!AllBlocks.STOCK_LINK.has(adjacentState)) if (!AllBlocks.STOCK_LINK.has(adjacentState))
continue; continue;
if (PackagerLinkBlock.getConnectedDirection(adjacentState) != d) if (PackagerLinkBlock.getConnectedDirection(adjacentState) != d)
continue; continue;
return true; return worldPosition.relative(d);
} }
return false; return null;
} }
public void flashLink() { public void flashLink() {
@ -545,6 +545,11 @@ public class PackagerBlockEntity extends SmartBlockEntity {
if (!requestQueue && !signBasedAddress.isBlank()) if (!requestQueue && !signBasedAddress.isBlank())
PackageItem.addAddress(createdBox, signBasedAddress); 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) { if (!heldBox.isEmpty() || animationTicks != 0) {
queuedExitingPackages.add(createdBox); queuedExitingPackages.add(createdBox);
return; return;

View file

@ -32,6 +32,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
public class LogisticallyLinkedBehaviour extends BlockEntityBehaviour { public class LogisticallyLinkedBehaviour extends BlockEntityBehaviour {
@ -185,6 +186,18 @@ public class LogisticallyLinkedBehaviour extends BlockEntityBehaviour {
return plbe.fetchSummaryFromPackager(ignoredHandler); return plbe.fetchSummaryFromPackager(ignoredHandler);
return InventorySummary.EMPTY; 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()));
}
}
// //