mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Merge remote-tracking branch 'concealed/mc1.20.1/feature-dev' into mc1.20.1/feature-dev
This commit is contained in:
commit
b28427fe2d
8 changed files with 58 additions and 9 deletions
|
@ -685,6 +685,9 @@ public abstract class Contraption {
|
|||
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)));
|
||||
return;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -27,8 +27,12 @@ public class AddressEditBox extends EditBox {
|
|||
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 -> {
|
||||
|
|
|
@ -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<IntAttached<String>> options = new ArrayList<>();
|
||||
|
@ -50,6 +50,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()
|
||||
.getItem(i));
|
||||
|
|
|
@ -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;
|
||||
|
@ -778,6 +779,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 +815,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");
|
||||
|
@ -1055,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
@ -186,6 +187,18 @@ public class LogisticallyLinkedBehaviour extends BlockEntityBehaviour {
|
|||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public boolean mayInteract(Player player) {
|
||||
|
|
Loading…
Add table
Reference in a new issue