mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 14:54:42 +01:00
It looks like you're writing an address. Would you like help?
- Get help with writing the address - Just type the address without help - Don't show this tip again
This commit is contained in:
parent
087e42408e
commit
9d13cd9853
13 changed files with 352 additions and 50 deletions
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.logistics.AddressEditBoxHelper;
|
||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
|
||||
|
@ -39,6 +40,13 @@ public class ClipboardBlockEntity extends SmartBlockEntity {
|
|||
notifyUpdate();
|
||||
updateWrittenState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lazyTick() {
|
||||
super.lazyTick();
|
||||
if (level.isClientSide())
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::advertiseToAddressHelper);
|
||||
}
|
||||
|
||||
public void updateWrittenState() {
|
||||
BlockState blockState = getBlockState();
|
||||
|
@ -87,5 +95,10 @@ public class ClipboardBlockEntity extends SmartBlockEntity {
|
|||
return;
|
||||
cs.reopenWith(dataContainer);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void advertiseToAddressHelper() {
|
||||
AddressEditBoxHelper.advertiseClipboard(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -280,19 +281,32 @@ public class ClipboardScreen extends AbstractSimiScreen {
|
|||
int y = guiTop - 8;
|
||||
|
||||
AllGuiTextures.CLIPBOARD.render(graphics, x, y);
|
||||
graphics.drawString(font, Components.translatable("book.pageIndicator", currentPage + 1, getNumPages()), x + 150, y + 9,
|
||||
0x43ffffff, false);
|
||||
graphics.drawString(font, Components.translatable("book.pageIndicator", currentPage + 1, getNumPages()),
|
||||
x + 150, y + 9, 0x43ffffff, false);
|
||||
|
||||
for (int i = 0; i < currentEntries.size(); i++) {
|
||||
ClipboardEntry clipboardEntry = currentEntries.get(i);
|
||||
boolean checked = clipboardEntry.checked;
|
||||
int iconOffset = clipboardEntry.icon.isEmpty() ? 0 : 16;
|
||||
|
||||
graphics.drawString(font, "\u25A1", x + 45, y + 51, checked ? 0x668D7F6B : 0xff8D7F6B, false);
|
||||
if (checked)
|
||||
graphics.drawString(font, "\u2714", x + 45, y + 50, 0x31B25D, false);
|
||||
MutableComponent text = clipboardEntry.text;
|
||||
String string = text.getString();
|
||||
boolean isAddress = string.startsWith("#") && !string.substring(1)
|
||||
.isBlank();
|
||||
|
||||
List<FormattedCharSequence> split = font.split(clipboardEntry.text, 150 - iconOffset);
|
||||
if (isAddress) {
|
||||
RenderSystem.enableBlend();
|
||||
(checked ? AllGuiTextures.CLIPBOARD_ADDRESS_INACTIVE : AllGuiTextures.CLIPBOARD_ADDRESS)
|
||||
.render(graphics, x + 44, y + 50);
|
||||
text = Components.literal(string.substring(1)
|
||||
.stripLeading());
|
||||
} else {
|
||||
graphics.drawString(font, "\u25A1", x + 45, y + 51, checked ? 0x668D7F6B : 0xff8D7F6B, false);
|
||||
if (checked)
|
||||
graphics.drawString(font, "\u2714", x + 45, y + 50, 0x31B25D, false);
|
||||
}
|
||||
|
||||
List<FormattedCharSequence> split = font.split(text, 150 - iconOffset);
|
||||
if (split.isEmpty()) {
|
||||
y += 12;
|
||||
continue;
|
||||
|
@ -303,7 +317,8 @@ public class ClipboardScreen extends AbstractSimiScreen {
|
|||
|
||||
for (FormattedCharSequence sequence : split) {
|
||||
if (i != editingIndex)
|
||||
graphics.drawString(font, sequence, x + 58 + iconOffset, y + 50, checked ? 0x31B25D : 0x311A00, false);
|
||||
graphics.drawString(font, sequence, x + 58 + iconOffset, y + 50,
|
||||
checked ? isAddress ? 0x668D7F6B : 0x31B25D : 0x311A00, false);
|
||||
y += 9;
|
||||
}
|
||||
y += 3;
|
||||
|
@ -312,13 +327,11 @@ public class ClipboardScreen extends AbstractSimiScreen {
|
|||
if (editingIndex == -1)
|
||||
return;
|
||||
|
||||
boolean checked = currentEntries.get(editingIndex).checked;
|
||||
|
||||
setFocused(null);
|
||||
DisplayCache cache = getDisplayCache();
|
||||
|
||||
for (LineInfo line : cache.lines)
|
||||
graphics.drawString(font, line.asComponent, line.x, line.y, checked ? 0x31B25D : 0x311A00, false);
|
||||
graphics.drawString(font, line.asComponent, line.x, line.y, 0x311A00, false);
|
||||
|
||||
renderHighlight(cache.selection);
|
||||
renderCursor(graphics, cache.cursor, cache.cursorAtEnd);
|
||||
|
@ -583,8 +596,16 @@ public class ClipboardScreen extends AbstractSimiScreen {
|
|||
editingIndex = -1;
|
||||
if (hoveredEntry < currentEntries.size()) {
|
||||
currentEntries.get(hoveredEntry).checked ^= true;
|
||||
if (currentEntries.get(hoveredEntry).checked == true) Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(AllSoundEvents.CLIPBOARD_CHECKMARK.getMainEvent(), 0.95f + (float)Math.random() * 0.05f));
|
||||
else Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(AllSoundEvents.CLIPBOARD_ERASE.getMainEvent(), 0.90f + (float)Math.random() * 0.2f));
|
||||
if (currentEntries.get(hoveredEntry).checked == true)
|
||||
Minecraft.getInstance()
|
||||
.getSoundManager()
|
||||
.play(SimpleSoundInstance.forUI(AllSoundEvents.CLIPBOARD_CHECKMARK.getMainEvent(),
|
||||
0.95f + (float) Math.random() * 0.05f));
|
||||
else
|
||||
Minecraft.getInstance()
|
||||
.getSoundManager()
|
||||
.play(SimpleSoundInstance.forUI(AllSoundEvents.CLIPBOARD_ERASE.getMainEvent(),
|
||||
0.90f + (float) Math.random() * 0.2f));
|
||||
}
|
||||
sendIfEditingBlock();
|
||||
return true;
|
||||
|
@ -673,12 +694,27 @@ public class ClipboardScreen extends AbstractSimiScreen {
|
|||
}
|
||||
|
||||
private DisplayCache rebuildDisplayCache() {
|
||||
String s = getCurrentEntryText();
|
||||
if (s.isEmpty())
|
||||
String current = getCurrentEntryText();
|
||||
boolean address = current.startsWith("#") && !current.substring(1)
|
||||
.isBlank();
|
||||
int offset = 0;
|
||||
|
||||
if (address) {
|
||||
String stripped = current.substring(1)
|
||||
.stripLeading();
|
||||
offset = current.length() - stripped.length();
|
||||
current = stripped;
|
||||
}
|
||||
|
||||
if (current.isEmpty())
|
||||
return DisplayCache.EMPTY;
|
||||
|
||||
String s = current;
|
||||
int i = editContext.getCursorPos();
|
||||
int j = editContext.getSelectionPos();
|
||||
i = Mth.clamp(i - offset, 0, s.length());
|
||||
j = Mth.clamp(j - offset, 0, s.length());
|
||||
|
||||
IntList intlist = new IntArrayList();
|
||||
List<LineInfo> list = Lists.newArrayList();
|
||||
MutableInt mutableint = new MutableInt();
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
package com.simibubi.create.content.logistics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.trains.schedule.DestinationSuggestions;
|
||||
import com.simibubi.create.foundation.gui.widget.ScrollInput;
|
||||
import com.simibubi.create.foundation.utility.CreateLang;
|
||||
|
||||
import net.createmod.catnip.utility.lang.Components;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class AddressEditBox extends EditBox {
|
||||
|
||||
private DestinationSuggestions destinationSuggestions;
|
||||
private Consumer<String> mainResponder;
|
||||
|
||||
public AddressEditBox(Screen screen, Font pFont, int pX, int pY, int pWidth, int pHeight) {
|
||||
super(pFont, pX, pY, pWidth, pHeight, Components.empty());
|
||||
destinationSuggestions = AddressEditBoxHelper.createSuggestions(screen, this);
|
||||
destinationSuggestions.setAllowSuggestions(true);
|
||||
destinationSuggestions.updateCommandInfo();
|
||||
mainResponder = t -> destinationSuggestions.updateCommandInfo();
|
||||
setResponder(mainResponder);
|
||||
setBordered(false);
|
||||
setFocused(false);
|
||||
mouseClicked(0, 0, 0);
|
||||
setMaxLength(25);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
|
||||
if (destinationSuggestions.keyPressed(pKeyCode, pScanCode, pModifiers))
|
||||
return true;
|
||||
if (isFocused() && pKeyCode == GLFW.GLFW_KEY_ENTER) {
|
||||
setFocused(false);
|
||||
mouseClicked(0, 0, 0);
|
||||
return true;
|
||||
}
|
||||
return super.keyPressed(pKeyCode, pScanCode, pModifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double pMouseX, double pMouseY, double pDelta) {
|
||||
if (destinationSuggestions.mouseScrolled(Mth.clamp(pDelta, -1.0D, 1.0D)))
|
||||
return true;
|
||||
return super.mouseScrolled(pMouseX, pMouseY, pDelta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) {
|
||||
if (super.mouseClicked(pMouseX, pMouseY, pButton))
|
||||
return true;
|
||||
if (destinationSuggestions.mouseClicked((int) pMouseX, (int) pMouseY, pButton))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWidget(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
|
||||
super.renderWidget(pGuiGraphics, pMouseX, pMouseY, pPartialTick);
|
||||
PoseStack matrixStack = pGuiGraphics.pose();
|
||||
matrixStack.pushPose();
|
||||
matrixStack.translate(0, 0, 500);
|
||||
destinationSuggestions.render(pGuiGraphics, pMouseX, pMouseY);
|
||||
matrixStack.popPose();
|
||||
|
||||
if (!destinationSuggestions.isEmpty())
|
||||
return;
|
||||
|
||||
int itemX = getX() + width + 4;
|
||||
int itemY = getY() - 3;
|
||||
pGuiGraphics.renderItem(AllBlocks.CLIPBOARD.asStack(), itemX, itemY);
|
||||
if (pMouseX >= itemX && pMouseX < itemX + 16 && pMouseY >= itemY && pMouseY < itemY + 16) {
|
||||
List<Component> promiseTip = List.of();
|
||||
promiseTip = List.of(CreateLang.temporaryText("Keeping Track")
|
||||
.color(ScrollInput.HEADER_RGB)
|
||||
.component(),
|
||||
CreateLang.temporaryText("Entries starting with '#' on")
|
||||
.style(ChatFormatting.GRAY)
|
||||
.component(),
|
||||
CreateLang.temporaryText("held or nearby clipboards will")
|
||||
.style(ChatFormatting.GRAY)
|
||||
.component(),
|
||||
CreateLang.temporaryText("help auto-complete this input.")
|
||||
.style(ChatFormatting.GRAY)
|
||||
.component(),
|
||||
CreateLang.temporaryText("(e.g. #storage, #factory)")
|
||||
.style(ChatFormatting.DARK_GRAY)
|
||||
.component());
|
||||
pGuiGraphics.renderComponentTooltip(Minecraft.getInstance().font, promiseTip, pMouseX, pMouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponder(Consumer<String> pResponder) {
|
||||
super.setResponder(pResponder == mainResponder ? mainResponder : mainResponder.andThen(pResponder));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (!isFocused())
|
||||
destinationSuggestions.hide();
|
||||
if (isFocused() && destinationSuggestions.suggestions == null)
|
||||
destinationSuggestions.updateCommandInfo();
|
||||
destinationSuggestions.tick();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.simibubi.create.content.logistics;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.equipment.clipboard.ClipboardBlockEntity;
|
||||
import com.simibubi.create.content.equipment.clipboard.ClipboardEntry;
|
||||
import com.simibubi.create.content.trains.schedule.DestinationSuggestions;
|
||||
|
||||
import net.createmod.catnip.utility.IntAttached;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class AddressEditBoxHelper {
|
||||
|
||||
private static Cache<BlockPos, WeakReference<ClipboardBlockEntity>> NEARBY_CLIPBOARDS = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(1, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
public static void advertiseClipboard(ClipboardBlockEntity blockEntity) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
if (player == null)
|
||||
return;
|
||||
BlockPos blockPos = blockEntity.getBlockPos();
|
||||
if (player.distanceToSqr(Vec3.atCenterOf(blockPos)) > 32 * 32)
|
||||
return;
|
||||
NEARBY_CLIPBOARDS.put(blockPos, new WeakReference<>(blockEntity));
|
||||
}
|
||||
|
||||
public static DestinationSuggestions createSuggestions(Screen screen, EditBox pInput) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
Player player = mc.player;
|
||||
List<IntAttached<String>> options = new ArrayList<>();
|
||||
DestinationSuggestions destinationSuggestions =
|
||||
new DestinationSuggestions(mc, screen, pInput, mc.font, options, -72 + pInput.getY() + pInput.getHeight());
|
||||
|
||||
if (player == null)
|
||||
return destinationSuggestions;
|
||||
|
||||
for (int i = 0; i < Inventory.INVENTORY_SIZE; i++)
|
||||
appendAddresses(options, player.getInventory()
|
||||
.getItem(i));
|
||||
|
||||
for (WeakReference<ClipboardBlockEntity> wr : NEARBY_CLIPBOARDS.asMap()
|
||||
.values()) {
|
||||
ClipboardBlockEntity cbe = wr.get();
|
||||
if (cbe != null)
|
||||
appendAddresses(options, cbe.dataContainer);
|
||||
}
|
||||
|
||||
return destinationSuggestions;
|
||||
}
|
||||
|
||||
private static void appendAddresses(List<IntAttached<String>> options, ItemStack item) {
|
||||
if (item == null || !AllBlocks.CLIPBOARD.isIn(item))
|
||||
return;
|
||||
|
||||
List<List<ClipboardEntry>> pages = ClipboardEntry.readAll(item);
|
||||
pages.forEach(page -> page.forEach(entry -> {
|
||||
String string = entry.text.getString();
|
||||
if (entry.checked)
|
||||
return;
|
||||
if (!string.startsWith("#") || string.length() <= 1)
|
||||
return;
|
||||
String address = string.substring(1);
|
||||
if (address.isBlank())
|
||||
return;
|
||||
options.add(IntAttached.withZero(address.trim()));
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.content.logistics.AddressEditBox;
|
||||
import com.simibubi.create.content.logistics.BigItemStack;
|
||||
import com.simibubi.create.content.trains.station.NoShadowFontWrapper;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
|
@ -72,22 +73,18 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
|
||||
if (addressBox == null) {
|
||||
addressBox =
|
||||
new EditBox(new NoShadowFontWrapper(font), x + 38, y + 30 + middleHeight(), 110, 10, Component.empty());
|
||||
new AddressEditBox(this, new NoShadowFontWrapper(font), x + 38, y + 30 + middleHeight(), 110, 10);
|
||||
addressBox.setValue(behaviour.recipeAddress);
|
||||
addressBox.setBordered(false);
|
||||
addressBox.setTextColor(0x555555);
|
||||
addressBox.setFocused(false);
|
||||
addressBox.mouseClicked(0, 0, 0);
|
||||
addressBox.setMaxLength(25);
|
||||
}
|
||||
addressBox.setY(y + 30 + middleHeight());
|
||||
addRenderableWidget(addressBox);
|
||||
|
||||
confirmButton = new IconButton(x + sizeX - 61, y + sizeY - 22, AllIcons.I_CONFIRM);
|
||||
confirmButton = new IconButton(x + sizeX - 51, y + sizeY - 22, AllIcons.I_CONFIRM);
|
||||
confirmButton.withCallback(() -> minecraft.setScreen(null));
|
||||
addRenderableWidget(confirmButton);
|
||||
|
||||
promiseExpiration = new ScrollInput(x + 102, y + 54 + middleHeight(), 25, 16).withRange(-1, 31)
|
||||
promiseExpiration = new ScrollInput(x + 112, y + 54 + middleHeight(), 25, 16).withRange(-1, 31)
|
||||
.titled(CreateLang.temporaryText("Promises expire after")
|
||||
.component());
|
||||
promiseExpiration.setState(behaviour.promiseClearingInterval);
|
||||
|
@ -95,7 +92,7 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
|
||||
if (behaviour.targetedBy.size() < 9) {
|
||||
int slot = behaviour.targetedBy.size();
|
||||
newInputButton = new IconButton(x + 19 + (slot % 3 * 18), y + 27 + (slot / 3 * 18), AllIcons.I_ADD);
|
||||
newInputButton = new IconButton(x + 24 + (slot % 3 * 18), y + 27 + (slot / 3 * 18), AllIcons.I_ADD);
|
||||
newInputButton.withCallback(() -> {
|
||||
FactoryPanelConnectionHandler.startConnection(behaviour);
|
||||
minecraft.setScreen(null);
|
||||
|
@ -120,6 +117,7 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
updateConfigs();
|
||||
init();
|
||||
}
|
||||
addressBox.tick();
|
||||
promiseExpiration.titled(CreateLang
|
||||
.temporaryText(promiseExpiration.getState() == -1 ? "Promises do not expire" : "Promises expire after:")
|
||||
.component());
|
||||
|
@ -145,14 +143,14 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
AllGuiTextures sprite =
|
||||
frame == 0 ? AllGuiTextures.FACTORY_PANEL_SLOT_FRAME : AllGuiTextures.FACTORY_PANEL_SLOT;
|
||||
for (slot = 0; slot < behaviour.targetedBy.size(); slot++)
|
||||
sprite.render(graphics, x + 18 + frame + (slot % 3 * 18), y + 26 + frame + (slot / 3 * 18));
|
||||
sprite.render(graphics, x + 23 + frame + (slot % 3 * 18), y + 26 + frame + (slot / 3 * 18));
|
||||
if (slot < 9)
|
||||
sprite.render(graphics, x + 18 + frame + (slot % 3 * 18), y + 26 + frame + (slot / 3 * 18));
|
||||
sprite.render(graphics, x + 23 + frame + (slot % 3 * 18), y + 26 + frame + (slot / 3 * 18));
|
||||
}
|
||||
|
||||
slot = 0;
|
||||
for (BigItemStack itemStack : inputConfig) {
|
||||
int inputX = x + 20 + (slot % 3 * 18);
|
||||
int inputX = x + 25 + (slot % 3 * 18);
|
||||
int inputY = y + 28 + (slot / 3 * 18);
|
||||
graphics.renderItem(itemStack.stack, inputX, inputY);
|
||||
if (!itemStack.stack.isEmpty())
|
||||
|
@ -190,8 +188,8 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
|
||||
if (inputConfig.size() > 0) {
|
||||
AllGuiTextures.FACTORY_PANEL_ARROW.render(graphics,
|
||||
x + 70 + Mth.clamp(behaviour.targetedBy.size(), 0, 2) * 9, y + 16 + middleHeight() / 2);
|
||||
int outputX = x + 128;
|
||||
x + 75 + Mth.clamp(behaviour.targetedBy.size(), 0, 2) * 9, y + 16 + middleHeight() / 2);
|
||||
int outputX = x + 130;
|
||||
int outputY = y + 16 + middleHeight() / 2;
|
||||
AllGuiTextures.FACTORY_PANEL_SLOT_FRAME.render(graphics, outputX - 2, outputY - 2);
|
||||
graphics.renderItem(outputConfig.stack, outputX, outputY);
|
||||
|
@ -247,7 +245,7 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
// TITLE
|
||||
Component title = CreateLang.temporaryText("Logistics Recipe")
|
||||
.component();
|
||||
graphics.drawString(font, title, x + 82 - font.width(title) / 2, y + 7, 0x3D3C48, false);
|
||||
graphics.drawString(font, title, x + 87 - font.width(title) / 2, y + 7, 0x3D3C48, false);
|
||||
|
||||
// ITEM PREVIEW
|
||||
ms.pushPose();
|
||||
|
@ -255,13 +253,13 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
GuiGameElement.of(AllBlocks.FACTORY_PANEL.asStack())
|
||||
.scale(4)
|
||||
.at(0, 0, -200)
|
||||
.render(graphics, x + 165, y + 55);
|
||||
.render(graphics, x + 175, y + 55);
|
||||
if (!behaviour.getFilter()
|
||||
.isEmpty()) {
|
||||
GuiGameElement.of(behaviour.getFilter())
|
||||
.scale(1.625)
|
||||
.at(0, 0, 200)
|
||||
.render(graphics, x + 184, y + 68);
|
||||
.render(graphics, x + 194, y + 68);
|
||||
}
|
||||
ms.popPose();
|
||||
|
||||
|
@ -272,7 +270,7 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
|
||||
ItemStack asStack = AllItems.CARDBOARD_PACKAGE_12x12.asStack();
|
||||
int itemY = y + 54 + middleHeight();
|
||||
int itemX = x + 78;
|
||||
int itemX = x + 88;
|
||||
graphics.renderItem(asStack, itemX, itemY);
|
||||
int promised = behaviour.getPromised();
|
||||
graphics.renderItemDecorations(font, asStack, itemX, itemY, promised + "");
|
||||
|
@ -323,7 +321,7 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
|
||||
// Remove connections
|
||||
for (int i = 0; i < connections.size(); i++) {
|
||||
int inputX = x + 20 + (i % 3 * 18);
|
||||
int inputX = x + 25 + (i % 3 * 18);
|
||||
int inputY = y + 28 + (i / 3 * 18);
|
||||
if (mouseX >= inputX && mouseX < inputX + 16 && mouseY >= inputY && mouseY < inputY + 16) {
|
||||
sendIt(connections.get(i)
|
||||
|
@ -334,7 +332,7 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
|
||||
// Clear promises
|
||||
int itemY = y + 54 + middleHeight();
|
||||
int itemX = x + 78;
|
||||
int itemX = x + 88;
|
||||
if (mouseX >= itemX && mouseX < itemX + 16 && mouseY >= itemY && mouseY < itemY + 16) {
|
||||
sendIt(null, true);
|
||||
return true;
|
||||
|
@ -349,7 +347,7 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
int y = guiTop;
|
||||
|
||||
for (int i = 0; i < inputConfig.size(); i++) {
|
||||
int inputX = x + 20 + (i % 3 * 18);
|
||||
int inputX = x + 25 + (i % 3 * 18);
|
||||
int inputY = y + 28 + (i / 3 * 18);
|
||||
if (mouseX >= inputX && mouseX < inputX + 16 && mouseY >= inputY && mouseY < inputY + 16) {
|
||||
BigItemStack itemStack = inputConfig.get(i);
|
||||
|
@ -362,7 +360,7 @@ public class FactoryPanelScreen extends AbstractSimiScreen {
|
|||
}
|
||||
|
||||
if (inputConfig.size() > 0) {
|
||||
int outputX = x + 128;
|
||||
int outputX = x + 130;
|
||||
int outputY = y + 16 + middleHeight() / 2;
|
||||
if (mouseX >= outputX && mouseX < outputX + 16 && mouseY >= outputY && mouseY < outputY + 16) {
|
||||
BigItemStack itemStack = outputConfig;
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.lwjgl.glfw.GLFW;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.content.logistics.AddressEditBox;
|
||||
import com.simibubi.create.content.logistics.filter.FilterScreenPacket.Option;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
import com.simibubi.create.foundation.gui.widget.IconButton;
|
||||
|
@ -33,6 +34,7 @@ public class PackageFilterScreen extends AbstractFilterScreen<PackageFilterMenu>
|
|||
deferFocus = false;
|
||||
setFocused(addressBox);
|
||||
}
|
||||
addressBox.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,9 +45,7 @@ public class PackageFilterScreen extends AbstractFilterScreen<PackageFilterMenu>
|
|||
int x = leftPos;
|
||||
int y = topPos;
|
||||
|
||||
addressBox = new EditBox(this.font, x + 44, y + 28, 140, 9, Component.empty());
|
||||
addressBox.setMaxLength(50);
|
||||
addressBox.setBordered(false);
|
||||
addressBox = new AddressEditBox(this, this.font, x + 44, y + 28, 140, 9);
|
||||
addressBox.setTextColor(0xffffff);
|
||||
addressBox.setValue(menu.address);
|
||||
addressBox.setResponder(this::onAddressEdited);
|
||||
|
@ -90,6 +90,7 @@ public class PackageFilterScreen extends AbstractFilterScreen<PackageFilterMenu>
|
|||
public boolean charTyped(char pCodePoint, int pModifiers) {
|
||||
return super.charTyped(pCodePoint, pModifiers);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void contentsCleared() {
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
package com.simibubi.create.content.logistics.packagePort;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.equipment.clipboard.ClipboardEntry;
|
||||
import com.simibubi.create.content.equipment.clipboard.ClipboardOverrides;
|
||||
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
|
||||
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
|
||||
import com.simibubi.create.foundation.item.SmartInventory;
|
||||
import com.simibubi.create.foundation.utility.CreateLang;
|
||||
|
||||
import net.createmod.catnip.utility.lang.Components;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -134,10 +139,51 @@ public abstract class PackagePortBlockEntity extends SmartBlockEntity implements
|
|||
if (level.isClientSide)
|
||||
return InteractionResult.SUCCESS;
|
||||
|
||||
ItemStack mainHandItem = player.getMainHandItem();
|
||||
if (AllBlocks.CLIPBOARD.isIn(mainHandItem)) {
|
||||
addAddressToClipboard(player, mainHandItem);
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
NetworkHooks.openScreen((ServerPlayer) player, this, worldPosition);
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
private void addAddressToClipboard(Player player, ItemStack mainHandItem) {
|
||||
if (addressFilter == null || addressFilter.isBlank())
|
||||
return;
|
||||
|
||||
List<List<ClipboardEntry>> list = ClipboardEntry.readAll(mainHandItem);
|
||||
for (List<ClipboardEntry> page : list) {
|
||||
for (ClipboardEntry entry : page) {
|
||||
String existing = entry.text.getString();
|
||||
if (existing.equals("#" + addressFilter) || existing.equals("# " + addressFilter))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
List<ClipboardEntry> page = null;
|
||||
|
||||
for (List<ClipboardEntry> freePage : list) {
|
||||
if (freePage.size() > 16)
|
||||
continue;
|
||||
page = freePage;
|
||||
break;
|
||||
}
|
||||
|
||||
if (page == null) {
|
||||
page = new ArrayList<>();
|
||||
list.add(page);
|
||||
}
|
||||
|
||||
page.add(new ClipboardEntry(false, Components.literal("#" + addressFilter)));
|
||||
player.displayClientMessage(CreateLang.temporaryText("'" + addressFilter + "' added to Clipboard")
|
||||
.component(), true);
|
||||
|
||||
ClipboardEntry.saveAll(list, mainHandItem);
|
||||
mainHandItem.getTag().putInt("Type", ClipboardOverrides.ClipboardType.WRITTEN.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Components.empty();
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.content.logistics.AddressEditBox;
|
||||
import com.simibubi.create.content.logistics.BigItemStack;
|
||||
import com.simibubi.create.content.trains.station.NoShadowFontWrapper;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
|
@ -51,6 +52,7 @@ public class RedstoneRequesterScreen extends AbstractSimiContainerScreen<Redston
|
|||
@Override
|
||||
protected void containerTick() {
|
||||
super.containerTick();
|
||||
addressBox.tick();
|
||||
for (int i = 0; i < amounts.size(); i++)
|
||||
if (menu.ghostInventory.getStackInSlot(i)
|
||||
.isEmpty())
|
||||
|
@ -68,13 +70,9 @@ public class RedstoneRequesterScreen extends AbstractSimiContainerScreen<Redston
|
|||
int y = getGuiTop();
|
||||
|
||||
if (addressBox == null) {
|
||||
addressBox = new EditBox(new NoShadowFontWrapper(font), x + 50, y + 53, 110, 10, Component.empty());
|
||||
addressBox = new AddressEditBox(this, new NoShadowFontWrapper(font), x + 50, y + 53, 110, 10);
|
||||
addressBox.setValue(menu.contentHolder.encodedTargetAdress);
|
||||
addressBox.setBordered(false);
|
||||
addressBox.setTextColor(0x555555);
|
||||
addressBox.setFocused(false);
|
||||
addressBox.mouseClicked(0, 0, 0);
|
||||
addressBox.setMaxLength(25);
|
||||
}
|
||||
addRenderableWidget(addressBox);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.AllPackets;
|
||||
import com.simibubi.create.content.logistics.AddressEditBox;
|
||||
import com.simibubi.create.content.logistics.BigItemStack;
|
||||
import com.simibubi.create.foundation.utility.CreateLang;
|
||||
|
||||
|
@ -91,11 +92,8 @@ public class StockTickerRequestScreen extends AbstractSimiScreen {
|
|||
searchBox.setTextColor(0xffffff);
|
||||
addRenderableWidget(searchBox);
|
||||
|
||||
MutableComponent addressLabel = CreateLang.translateDirect("gui.stock_ticker.package_adress");
|
||||
boolean initial = addressBox == null;
|
||||
addressBox = new EditBox(this.font, itemsX + 1, orderY + rowHeight + 10, 120, 9, addressLabel);
|
||||
addressBox.setMaxLength(50);
|
||||
addressBox.setBordered(false);
|
||||
addressBox = new AddressEditBox(this, font, itemsX + 1, orderY + rowHeight + 10, 120, 9);
|
||||
addressBox.setTextColor(0xffffff);
|
||||
if (initial)
|
||||
addressBox.setValue(blockEntity.previouslyUsedAddress);
|
||||
|
@ -164,6 +162,7 @@ public class StockTickerRequestScreen extends AbstractSimiScreen {
|
|||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
addressBox.tick();
|
||||
|
||||
if (displayedItems.isEmpty())
|
||||
emptyTicks++;
|
||||
|
|
|
@ -81,5 +81,9 @@ public class DestinationSuggestions extends CommandSuggestions {
|
|||
int x = Mth.clamp(textBox.getScreenX(0), 0, textBox.getScreenX(0) + textBox.getInnerWidth() - width);
|
||||
suggestions = new CommandSuggestions.SuggestionsList(x, 72 + yOffset, width, currentSuggestions, false);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return viableStations.isEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -78,6 +78,8 @@ public enum AllGuiTextures implements ScreenElement, TextureSheetSegment {
|
|||
BLUEPRINT("curiosities_2", 0, 109, 179, 109),
|
||||
|
||||
CLIPBOARD("clipboard", 0, 0, 256, 256),
|
||||
CLIPBOARD_ADDRESS("widgets", 116, 7, 8, 8),
|
||||
CLIPBOARD_ADDRESS_INACTIVE("widgets", 125, 7, 8, 8),
|
||||
|
||||
DATA_GATHERER("display_link", 235, 162),
|
||||
DATA_AREA_START("display_link", 0, 163, 2, 18),
|
||||
|
@ -151,9 +153,9 @@ public enum AllGuiTextures implements ScreenElement, TextureSheetSegment {
|
|||
VALUE_SETTINGS_LABEL_BG("value_settings", 0, 31, 81, 11),
|
||||
|
||||
// HILO
|
||||
FACTORY_PANEL_TOP("restocker_and_requester", 0, 0, 172, 23),
|
||||
FACTORY_PANEL_MIDDLE("restocker_and_requester", 0, 23, 172, 26),
|
||||
FACTORY_PANEL_BOTTOM("restocker_and_requester", 0, 49, 172, 54),
|
||||
FACTORY_PANEL_TOP("restocker_and_requester", 0, 0, 182, 23),
|
||||
FACTORY_PANEL_MIDDLE("restocker_and_requester", 0, 23, 182, 26),
|
||||
FACTORY_PANEL_BOTTOM("restocker_and_requester", 0, 49, 182, 54),
|
||||
FACTORY_PANEL_SLOT_FRAME("restocker_and_requester", 3, 106, 20, 20),
|
||||
FACTORY_PANEL_SLOT("restocker_and_requester", 4, 107, 18, 18),
|
||||
FACTORY_PANEL_ARROW("restocker_and_requester", 27, 108, 22, 16),
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Loading…
Add table
Reference in a new issue