mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Autocompletely
- Restocker gauge UI now suggests the address of the frog port on top of its packager
This commit is contained in:
parent
adb3de0461
commit
3d47f58daa
4 changed files with 25 additions and 5 deletions
|
@ -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 -> {
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -1057,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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue