aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-15 15:59:56 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-15 15:59:56 +0200
commit963f66bf4df11ec9de552f50f1d5d65bae9ace0f (patch)
tree7f9919e3a9191aa311e1b665187448baf42d322b /src/main/java
parente07c1db5719bf675da0c5ea8b122f9e56de347f6 (diff)
downloadskyhanni-963f66bf4df11ec9de552f50f1d5d65bae9ace0f.tar.gz
skyhanni-963f66bf4df11ec9de552f50f1d5d65bae9ace0f.tar.bz2
skyhanni-963f66bf4df11ec9de552f50f1d5d65bae9ace0f.zip
add STRG + A, C, V, X support
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java (renamed from src/main/java/at/hannibal2/skyhanni/mixins/MixinNetHandlerPlayClient.java)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java (renamed from src/main/java/at/hannibal2/skyhanni/mixins/MixinNetworkManager.java)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.java (renamed from src/main/java/at/hannibal2/skyhanni/mixins/MixinRenderItem.java)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.java (renamed from src/main/java/at/hannibal2/skyhanni/mixins/MixinRenderManager.java)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiContainer.java (renamed from src/main/java/at/hannibal2/skyhanni/mixins/MixinGuiContainer.java)2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/inventory/GuiEditSignMixin.java265
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/tileentity/TileEntitySignMixin.java63
-rw-r--r--src/main/java/at/hannibal2/skyhanni/sign/IEditSign.java7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/sign/IModifiedSign.java19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/sign/LorenzSignUtils.java64
-rw-r--r--src/main/java/at/hannibal2/skyhanni/sign/SignSelectionList.java241
-rw-r--r--src/main/java/at/hannibal2/skyhanni/sign/SkyBlockEventHandler.java7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/sign/SkyBlockcatiaConfig.java7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/sign/TextInputUtil.java202
14 files changed, 880 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/MixinNetHandlerPlayClient.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java
index 3e91bdfe3..0d48fae00 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/MixinNetHandlerPlayClient.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.java
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.mixins;
+package at.hannibal2.skyhanni.mixins.transformers;
import at.hannibal2.skyhanni.mixinhooks.NetHandlerPlayClientHookKt;
import net.minecraft.client.multiplayer.WorldClient;
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/MixinNetworkManager.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java
index 83f7f51bb..d67243a8c 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/MixinNetworkManager.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.java
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.mixins;
+package at.hannibal2.skyhanni.mixins.transformers;
import at.hannibal2.skyhanni.mixinhooks.NetworkManagerHookKt;
import io.netty.channel.ChannelHandlerContext;
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/MixinRenderItem.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.java
index e2dc8926c..36be30414 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/MixinRenderItem.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.java
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.mixins;
+package at.hannibal2.skyhanni.mixins.transformers;
import at.hannibal2.skyhanni.mixinhooks.RenderItemHookKt;
import net.minecraft.client.gui.FontRenderer;
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/MixinRenderManager.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.java
index f57786a9b..122c7732e 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/MixinRenderManager.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.java
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.mixins;
+package at.hannibal2.skyhanni.mixins.transformers;
import at.hannibal2.skyhanni.mixinhooks.RenderManagerHookKt;
import net.minecraft.client.renderer.culling.ICamera;
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/MixinGuiContainer.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiContainer.java
index 18997c33b..57add8571 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/MixinGuiContainer.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiContainer.java
@@ -1,4 +1,4 @@
-package at.hannibal2.skyhanni.mixins;
+package at.hannibal2.skyhanni.mixins.transformers.gui;
import at.hannibal2.skyhanni.mixinhooks.GuiContainerHook;
import net.minecraft.client.gui.GuiScreen;
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/inventory/GuiEditSignMixin.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/inventory/GuiEditSignMixin.java
new file mode 100644
index 000000000..6777a124d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/inventory/GuiEditSignMixin.java
@@ -0,0 +1,265 @@
+package at.hannibal2.skyhanni.mixins.transformers.gui.inventory;
+
+
+import at.hannibal2.skyhanni.sign.*;
+import net.minecraft.block.Block;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.inventory.GuiEditSign;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
+import net.minecraft.init.Blocks;
+import net.minecraft.tileentity.TileEntitySign;
+import net.minecraft.util.ChatComponentText;
+import org.lwjgl.input.Keyboard;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.At.Shift;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import java.io.IOException;
+import java.util.List;
+
+@Mixin(GuiEditSign.class)
+public class GuiEditSignMixin extends GuiScreen implements IEditSign {
+ private final GuiEditSign that = (GuiEditSign) (Object) this;
+ private TextInputUtil textInputUtil;
+ private SignSelectionList globalSelector;
+
+ @Shadow
+ private int editLine;
+
+ @Shadow
+ private int updateCounter;
+
+ private static TileEntitySign getTileSign(GuiEditSign editSign) {
+ return LorenzSignUtils.getTileSign(editSign);
+ }
+
+ @Inject(method = "initGui()V", at = @At("RETURN"))
+ private void initGui(CallbackInfo info) {
+// this.textInputUtil = new TextInputUtil(this.fontRendererObj, () -> ((IModifiedSign) this.that.tileSign).getText(this.editLine).getUnformattedText(), text -> ((IModifiedSign) this.that.tileSign).setText(this.editLine, new ChatComponentText(text)), 90);
+ this.textInputUtil = new TextInputUtil(this.fontRendererObj, () -> ((IModifiedSign) getTileSign(this.that)).getText(this.editLine).getUnformattedText(), text -> ((IModifiedSign) getTileSign(this.that)).setText(this.editLine, new ChatComponentText(text)), 90);
+
+ if (SkyBlockEventHandler.isSkyBlock && SkyBlockcatiaConfig.enableSignSelectionList) {
+ List<SignSelectionList.Entry> list = null;
+ String title = null;
+
+ if (this.isAuctionStartBidSign()) {
+ list = SignSelectionList.AUCTION_STARTING_BID_PRICES;
+ title = "Select price";
+ }
+ if (this.isAuctionPrice()) {
+ list = SignSelectionList.AUCTION_BID_PRICES;
+ title = "Select bid price";
+ }
+ if (this.isAuctionQuery()) {
+ list = SignSelectionList.AUCTION_QUERIES;
+ title = "Select query";
+ }
+ if (this.isBankWithdraw()) {
+ list = SignSelectionList.BANK_WITHDRAW;
+ title = "Select withdraw";
+ }
+ if (this.isBankDeposit()) {
+ list = SignSelectionList.BANK_DEPOSIT;
+ title = "Select deposit";
+ }
+ if (this.isBazaarOrder()) {
+ list = SignSelectionList.BAZAAR_ORDER;
+ title = "Select bazaar order";
+ }
+ if (this.isBazaarPrice()) {
+ list = SignSelectionList.BAZAAR_PRICE;
+ title = "Select bazaar price";
+ }
+ if (list != null && title != null) {
+ this.globalSelector = new SignSelectionList(this.mc, this.width + 200, this.height, 64, this.height - 64, list, title);
+ }
+ }
+ }
+
+ @Inject(method = "onGuiClosed()V", cancellable = true, at = @At("HEAD"))
+ private void onGuiClosed(CallbackInfo info) {
+ if (SkyBlockcatiaConfig.enableSignSelectionList) {
+ Keyboard.enableRepeatEvents(false);
+
+ if (SkyBlockEventHandler.isSkyBlock) {
+// String text = this.that.tileSign.signText[0].getUnformattedText();
+ String text = getTileSign(this.that).signText[0].getUnformattedText();
+
+// if (!StringUtils.isNullOrEmpty(text))
+// {
+// if (NumberUtils.isNumericWithKM(text) && (!SkyBlockcatiaSettings.INSTANCE.auctionBidConfirm && this.isAuctionPrice() || this.isAuctionStartBidSign() || this.isBazaarPrice() || this.isBankWithdraw() || this.isBankDeposit()))
+// {
+// this.globalSelector.add(text);
+// }
+// else if (NumberUtils.isNumeric(text) && this.isBazaarOrder())
+// {
+// this.globalSelector.add(text);
+// }
+// else if (this.isAuctionQuery())
+// {
+// this.globalSelector.add(text);
+// }
+// }
+ }
+// if (!(SkyBlockcatiaSettings.INSTANCE.auctionBidConfirm && this.isAuctionPrice())) {
+//// SignSelectionList.processSignData(this.that.tileSign);
+// SignSelectionList.processSignData(getTileSign(this.that));
+// }
+ info.cancel();
+ }
+ }
+
+ @Inject(method = "actionPerformed(Lnet/minecraft/client/gui/GuiButton;)V", cancellable = true, at = @At(value = "INVOKE", target = "net/minecraft/tileentity/TileEntitySign.markDirty()V", shift = Shift.AFTER))
+ private void actionPerformed(GuiButton button, CallbackInfo info) throws IOException {
+// if (SkyBlockcatiaSettings.INSTANCE.auctionBidConfirm)
+// {
+// String text = this.that.tileSign.signText[0].getUnformattedText();
+//
+// if (!StringUtils.isNullOrEmpty(text) && NumberUtils.isNumeric(text) && this.isAuctionPrice())
+// {
+// int price = Integer.parseInt(text);
+//
+// if (price >= SkyBlockcatiaSettings.INSTANCE.auctionBidConfirmValue)
+// {
+// this.mc.displayGuiScreen(new GuiYesNo(this, LangUtils.translate("message.bid_confirm_title"), LangUtils.translate("message.bid_confirm"), 201));
+// info.cancel();
+// }
+// else
+// {
+// this.that.tileSign.markDirty();
+// SignSelectionList.processSignData(this.that.tileSign);
+// this.globalSelector.add(text);
+// }
+// }
+// }
+ }
+
+ @Inject(method = "keyTyped(CI)V", cancellable = true, at = @At("HEAD"))
+ private void keyTyped(char typedChar, int keyCode, CallbackInfo info) throws IOException {
+ if (SkyBlockcatiaConfig.enableOverwriteSignEditing) {
+ this.textInputUtil.insert(typedChar);
+ this.keyPressed(keyCode);
+ info.cancel();
+ }
+ }
+
+ @Inject(method = "drawScreen(IIF)V", cancellable = true, at = @At("HEAD"))
+ private void drawScreenPre(int mouseX, int mouseY, float partialTicks, CallbackInfo info) {
+ if (SkyBlockcatiaConfig.enableOverwriteSignEditing) {
+ this.drawDefaultBackground();
+// this.drawCenteredString(this.fontRendererObj, LangUtils.translate("sign.edit"), this.width / 2, 40, 16777215);
+ this.drawCenteredString(this.fontRendererObj, "Sign Edit", this.width / 2, 40, 16777215);
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(this.width / 2d, 0.0F, 50.0F);
+ float f = 93.75F;
+ GlStateManager.scale(-f, -f, -f);
+ GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
+// Block block = this.that.tileSign.getBlockType();
+ Block block = getTileSign(this.that).getBlockType();
+
+ if (block == Blocks.standing_sign) {
+// float f1 = this.that.tileSign.getBlockMetadata() * 360 / 16.0F;
+ float f1 = getTileSign(this.that).getBlockMetadata() * 360 / 16.0F;
+ GlStateManager.rotate(f1, 0.0F, 1.0F, 0.0F);
+ GlStateManager.translate(0.0F, -1.0625F, 0.0F);
+ } else {
+// int i = this.that.tileSign.getBlockMetadata();
+ int i = getTileSign(this.that).getBlockMetadata();
+ float f2 = 0.0F;
+
+ if (i == 2) {
+ f2 = 180.0F;
+ }
+
+ if (i == 4) {
+ f2 = 90.0F;
+ }
+
+ if (i == 5) {
+ f2 = -90.0F;
+ }
+ GlStateManager.rotate(f2, 0.0F, 1.0F, 0.0F);
+ GlStateManager.translate(0.0F, -1.0625F, 0.0F);
+ }
+// ((IModifiedSign) this.that.tileSign).setSelectionState(this.editLine, this.textInputUtil.getSelectionStart(), this.textInputUtil.getSelectionEnd(), this.updateCounter / 6 % 2 == 0);
+ ((IModifiedSign) getTileSign(this.that)).setSelectionState(this.editLine, this.textInputUtil.getSelectionStart(), this.textInputUtil.getSelectionEnd(), this.updateCounter / 6 % 2 == 0);
+// TileEntityRendererDispatcher.instance.renderTileEntityAt(this.that.tileSign, -0.5D, -0.75D, -0.5D, 0.0F);
+ TileEntityRendererDispatcher.instance.renderTileEntityAt(getTileSign(this.that), -0.5D, -0.75D, -0.5D, 0.0F);
+// ((IModifiedSign) this.that.tileSign).resetSelectionState();
+ ((IModifiedSign) getTileSign(this.that)).resetSelectionState();
+ GlStateManager.popMatrix();
+ super.drawScreen(mouseX, mouseY, partialTicks);
+
+ if (SkyBlockEventHandler.isSkyBlock && SkyBlockcatiaConfig.enableSignSelectionList && this.globalSelector != null) {
+ this.globalSelector.drawScreen(mouseX, mouseY, partialTicks);
+ }
+ info.cancel();
+ }
+ }
+
+ @Inject(method = "drawScreen(IIF)V", cancellable = true, at = @At("RETURN"))
+ private void drawScreenPost(int mouseX, int mouseY, float partialTicks, CallbackInfo info) {
+ if (!SkyBlockcatiaConfig.enableOverwriteSignEditing && SkyBlockEventHandler.isSkyBlock && SkyBlockcatiaConfig.enableSignSelectionList && this.globalSelector != null) {
+ this.globalSelector.drawScreen(mouseX, mouseY, partialTicks);
+ }
+ }
+
+ @Override
+ public TextInputUtil getTextInputUtil() {
+ return this.textInputUtil;
+ }
+
+ @Override
+ public SignSelectionList getSignSelectionList() {
+ return this.globalSelector;
+ }
+
+ private boolean keyPressed(int keyCode) {
+ if (keyCode == Keyboard.KEY_UP) {
+ this.editLine = this.editLine - 1 & 3;
+ this.textInputUtil.moveCaretToEnd();
+ return true;
+ } else if (keyCode != Keyboard.KEY_DOWN && keyCode != Keyboard.KEY_RETURN && keyCode != Keyboard.KEY_NUMPADENTER) {
+ return this.textInputUtil.handleSpecialKey(keyCode);
+ } else {
+ this.editLine = this.editLine + 1 & 3;
+ this.textInputUtil.moveCaretToEnd();
+ return true;
+ }
+ }
+
+ private boolean isAuctionStartBidSign() {
+// return this.that.tileSign.signText[2].getUnformattedText().equals("Your auction") && this.that.tileSign.signText[3].getUnformattedText().equals("starting bid");
+ return getTileSign(this.that).signText[2].getUnformattedText().equals("Your auction") && getTileSign(this.that).signText[3].getUnformattedText().equals("starting bid");
+ }
+
+ private boolean isAuctionPrice() {
+ return getTileSign(this.that).signText[2].getUnformattedText().equals("auction bid") && getTileSign(this.that).signText[3].getUnformattedText().equals("amount");
+ }
+
+ private boolean isBazaarPrice() {
+ return getTileSign(this.that).signText[2].getUnformattedText().equals("Enter price") && getTileSign(this.that).signText[3].getUnformattedText().equals("big nerd");
+ }
+
+ private boolean isAuctionQuery() {
+ return getTileSign(this.that).signText[3].getUnformattedText().equals("Enter query");
+ }
+
+ private boolean isBankWithdraw() {
+ return getTileSign(this.that).signText[2].getUnformattedText().equals("Enter the amount") && getTileSign(this.that).signText[3].getUnformattedText().equals("to withdraw");
+ }
+
+ private boolean isBankDeposit() {
+ return getTileSign(this.that).signText[2].getUnformattedText().equals("Enter the amount") && getTileSign(this.that).signText[3].getUnformattedText().equals("to deposit");
+ }
+
+ private boolean isBazaarOrder() {
+ return getTileSign(this.that).signText[2].getUnformattedText().equals("Enter amount") && getTileSign(this.that).signText[3].getUnformattedText().equals("to order");
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/tileentity/TileEntitySignMixin.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/tileentity/TileEntitySignMixin.java
new file mode 100644
index 000000000..0863def9a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/tileentity/TileEntitySignMixin.java
@@ -0,0 +1,63 @@
+package at.hannibal2.skyhanni.mixins.transformers.tileentity;
+
+import at.hannibal2.skyhanni.sign.IModifiedSign;
+import net.minecraft.tileentity.TileEntitySign;
+import net.minecraft.util.IChatComponent;
+import org.spongepowered.asm.mixin.Mixin;
+
+@Mixin(TileEntitySign.class)
+public class TileEntitySignMixin implements IModifiedSign
+{
+ private final TileEntitySign that = (TileEntitySign) (Object) this;
+ private int selectionStart = -1;
+ private int selectionEnd = -1;
+ private boolean caretVisible;
+
+ @Override
+ public IChatComponent getText(int line)
+ {
+ return this.that.signText[line];
+ }
+
+ @Override
+ public void setText(int line, IChatComponent component)
+ {
+ this.that.signText[line] = component;
+ }
+
+ @Override
+ public void setSelectionState(int currentRow, int selectionStart, int selectionEnd, boolean caretVisible)
+ {
+ this.that.lineBeingEdited = currentRow;
+ this.selectionStart = selectionStart;
+ this.selectionEnd = selectionEnd;
+ this.caretVisible = caretVisible;
+ }
+
+ @Override
+ public void resetSelectionState()
+ {
+ this.that.lineBeingEdited = -1;
+ this.selectionStart = -1;
+ this.selectionEnd = -1;
+ this.caretVisible = false;
+ }
+
+ @Override
+ public boolean getCaretVisible()
+ {
+ return this.caretVisible;
+ }
+
+ @Override
+ public int getSelectionStart()
+ {
+ return this.selectionStart;
+ }
+
+ @Override
+ public int getSelectionEnd()
+ {
+ return this.selectionEnd;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/sign/IEditSign.java b/src/main/java/at/hannibal2/skyhanni/sign/IEditSign.java
new file mode 100644
index 000000000..278ec7224
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/sign/IEditSign.java
@@ -0,0 +1,7 @@
+package at.hannibal2.skyhanni.sign;
+
+public interface IEditSign {
+ TextInputUtil getTextInputUtil();
+
+ SignSelectionList getSignSelectionList();
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/sign/IModifiedSign.java b/src/main/java/at/hannibal2/skyhanni/sign/IModifiedSign.java
new file mode 100644
index 000000000..38375d5ac
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/sign/IModifiedSign.java
@@ -0,0 +1,19 @@
+package at.hannibal2.skyhanni.sign;
+
+import net.minecraft.util.IChatComponent;
+
+public interface IModifiedSign {
+ IChatComponent getText(int line);
+
+ void setText(int line, IChatComponent component);
+
+ void setSelectionState(int currentRow, int selectionStart, int selectionEnd, boolean caretVisible);
+
+ void resetSelectionState();
+
+ boolean getCaretVisible();
+
+ int getSelectionStart();
+
+ int getSelectionEnd();
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/sign/LorenzSignUtils.java b/src/main/java/at/hannibal2/skyhanni/sign/LorenzSignUtils.java
new file mode 100644
index 000000000..5b450a734
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/sign/LorenzSignUtils.java
@@ -0,0 +1,64 @@
+package at.hannibal2.skyhanni.sign;
+
+import net.minecraft.client.gui.inventory.GuiEditSign;
+import net.minecraft.tileentity.TileEntitySign;
+
+import java.lang.reflect.Field;
+
+public class LorenzSignUtils {
+
+ private static boolean once = false;
+ private static Field field = null;
+ //(field_146848_f) class net.minecraft.client.gui.inventory.GuiEditSign
+
+ public static TileEntitySign getTileSign(GuiEditSign editSign) {
+
+// Field field1 = ReflectionHelper.findField(editSign.getClass(), "editSign");
+// ObfuscationReflectionHelper.getPrivateValue(editSign.getClass(), editSign, 0)
+
+ if (field != null) {
+ try {
+ return (TileEntitySign) field.get(editSign);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("hidden", e);
+ }
+ }
+
+ if (once) {
+ throw new RuntimeException("hidden");
+ }
+ once = true;
+
+ try {
+ Class<? extends GuiEditSign> aClass = editSign.getClass();
+// System.out.println("");
+// System.out.println("");
+// System.out.println("");
+ for (Field field : aClass.getDeclaredFields()) {
+ String name = field.getName();
+ Class<?> fieldDeclaringClass = field.getDeclaringClass();
+// System.out.println("");
+// System.out.println("(" + name + ") " + fieldDeclaringClass);
+
+ field.setAccessible(true);
+ Object o = field.get(editSign);
+ if (o instanceof TileEntitySign) {
+// System.out.println("DONE!!!!!");
+ LorenzSignUtils.field = field;
+ return (TileEntitySign) o;
+ }
+
+// System.out.println("");
+ }
+
+// System.out.println("");
+// System.out.println("");
+// System.out.println("");
+ Field field = aClass.getDeclaredField("tileSign");
+ field.setAccessible(true);
+ return (TileEntitySign) field.get(editSign);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ throw new RuntimeException("can not refactor getTileSign! (" + e.getMessage() + ")", e);
+ }
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/sign/SignSelectionList.java b/src/main/java/at/hannibal2/skyhanni/sign/SignSelectionList.java
new file mode 100644
index 000000000..c9c963cee
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/sign/SignSelectionList.java
@@ -0,0 +1,241 @@
+package at.hannibal2.skyhanni.sign;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.client.gui.GuiListExtended;
+import net.minecraft.client.gui.inventory.GuiEditSign;
+import net.minecraft.client.network.NetHandlerPlayClient;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.network.play.client.C12PacketUpdateSign;
+import net.minecraft.tileentity.TileEntitySign;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.ResourceLocation;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class SignSelectionList extends GuiListExtended
+{
+ public static final List<Entry> AUCTION_STARTING_BID_PRICES = new ArrayList<>();
+ public static final List<Entry> AUCTION_BID_PRICES = new ArrayList<>();
+ public static final List<Entry> AUCTION_QUERIES = new ArrayList<>();
+ public static final List<Entry> BANK_WITHDRAW = new ArrayList<>();
+ public static final List<Entry> BANK_DEPOSIT = new ArrayList<>();
+ public static final List<Entry> BAZAAR_ORDER = new ArrayList<>();
+ public static final List<Entry> BAZAAR_PRICE = new ArrayList<>();
+ private int selectedSlotIndex = -1;
+ private final List<SignSelectionList.Entry> list;
+ private final String title;
+
+ public SignSelectionList(Minecraft mc, int width, int height, int top, int bottom, List<SignSelectionList.Entry> list, String title)
+ {
+ super(mc, width, height, top, bottom, 16);
+ this.list = list;
+ this.title = title;
+
+ if (this.getSize() > 5)
+ {
+ this.list.remove(0);
+ }
+ Collections.reverse(this.list);
+ }
+
+ @Override
+ protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
+ {
+ this.selectedSlotIndex = slotIndex;
+ }
+
+ @Override
+ public IGuiListEntry getListEntry(int index)
+ {
+ return this.list.stream().distinct().collect(Collectors.toList()).get(index);
+ }
+
+ @Override
+ protected int getSize()
+ {
+ return this.list.stream().distinct().collect(Collectors.toList()).size();
+ }
+
+ @Override
+ protected boolean isSelected(int index)
+ {
+ return index == this.selectedSlotIndex;
+ }
+
+ @Override
+ protected void drawContainerBackground(Tessellator tessellator) {}
+
+ @Override
+ protected void overlayBackground(int startY, int endY, int startAlpha, int endAlpha) {}
+
+ @Override
+ public int getListWidth()
+ {
+ return 100;
+ }
+
+ @Override
+ public int getSlotHeight()
+ {
+ return 10;
+ }
+
+ @Override
+ public void drawScreen(int mouseX, int mouseY, float partialTicks)
+ {
+ if (this.field_178041_q)
+ {
+ this.mouseX = mouseX;
+ this.mouseY = mouseY;
+ this.drawBackground();
+ this.bindAmountScrolled();
+ GlStateManager.disableLighting();
+ GlStateManager.disableFog();
+ Tessellator tessellator = Tessellator.getInstance();
+ this.drawContainerBackground(tessellator);
+ int k = this.left + this.width / 2 - this.getListWidth() / 2 + 2;
+ int l = this.top + 4 - (int)this.amountScrolled;
+
+ if (this.hasListHeader)
+ {
+ this.drawListHeader(k, l, tessellator);
+ }
+
+ this.drawSelectionBox(k, l, mouseX, mouseY);
+ this.mc.fontRendererObj.drawString(this.title + ":", k, l - 12, 16777215);
+ GlStateManager.disableDepth();
+ this.overlayBackground(0, this.top, 255, 255);
+ this.overlayBackground(this.bottom, this.height, 255, 255);
+ this.func_148142_b(mouseX, mouseY);
+ }
+ GlStateManager.enableDepth();
+ }
+
+ public void add(String value)
+ {
+ this.list.add(new Entry(value));
+ }
+
+ public static void clearAll()
+ {
+ SignSelectionList.AUCTION_STARTING_BID_PRICES.clear();
+ SignSelectionList.AUCTION_BID_PRICES.clear();
+ SignSelectionList.AUCTION_QUERIES.clear();
+ SignSelectionList.BANK_WITHDRAW.clear();
+ SignSelectionList.BANK_DEPOSIT.clear();
+ SignSelectionList.BAZAAR_ORDER.clear();
+ SignSelectionList.BAZAAR_PRICE.clear();
+ }
+
+ public static class Entry implements GuiListExtended.IGuiListEntry
+ {
+ private final Minecraft mc;
+ private final String value;
+ private long lastClicked;
+
+ public Entry(String value)
+ {
+ this.mc = Minecraft.getMinecraft();
+ this.value = value;
+ }
+
+ @Override
+ public void setSelected(int p_178011_1_, int p_178011_2_, int p_178011_3_) {}
+
+ @Override
+ public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
+ {
+ this.mc.fontRendererObj.drawString(this.value, x + 2, y + 2, 16777215);
+ }
+
+ @Override
+ public boolean mousePressed(int slotIndex, int mouseX, int mouseY, int mouseEvent, int relativeX, int relativeY)
+ {
+// TileEntitySign sign = ((GuiEditSign)this.mc.currentScreen).tileSign;
+// TileEntitySign sign = ().tileSign;
+ TileEntitySign sign = LorenzSignUtils.getTileSign((GuiEditSign)this.mc.currentScreen);
+ sign.markDirty();
+
+ if (Minecraft.getSystemTime() - this.lastClicked < 250L)
+ {
+// if (SkyBlockcatiaSettings.INSTANCE.auctionBidConfirm && NumberUtils.isNumeric(this.value))
+// {
+// int price = Integer.parseInt(this.value);
+//
+// if (price >= SkyBlockcatiaSettings.INSTANCE.auctionBidConfirmValue)
+// {
+// this.mc.displayGuiScreen(new GuiYesNo(this.mc.currentScreen, LangUtils.translate("message.bid_confirm_title"), LangUtils.translate("message.bid_confirm"), 201));
+// }
+// else
+// {
+// SignSelectionList.processSignData(sign);
+// this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+// this.mc.displayGuiScreen(null);
+// }
+// }
+// else
+// {
+ SignSelectionList.processSignData(sign);
+ this.mc.getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+ this.mc.displayGuiScreen(null);
+// }
+ }
+
+ sign.signText[0] = new ChatComponentText(this.value);
+
+ if (this.mc.currentScreen instanceof IEditSign)
+ {
+ ((IEditSign)this.mc.currentScreen).getTextInputUtil().moveCaretToEnd();
+ }
+ this.lastClicked = Minecraft.getSystemTime();
+ return false;
+ }
+
+ @Override
+ public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) {}
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof Entry))
+ {
+ return false;
+ }
+ if (obj == this)
+ {
+ return true;
+ }
+ Entry other = (Entry) obj;
+ return new EqualsBuilder().append(this.value, other.value).isEquals();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return new HashCodeBuilder().append(this.value).toHashCode();
+ }
+
+ public String getValue()
+ {
+ return this.value;
+ }
+ }
+
+ public static void processSignData(TileEntitySign sign)
+ {
+ NetHandlerPlayClient nethandlerplayclient = Minecraft.getMinecraft().getNetHandler();
+
+ if (nethandlerplayclient != null)
+ {
+ nethandlerplayclient.addToSendQueue(new C12PacketUpdateSign(sign.getPos(), sign.signText));
+ }
+ sign.setEditable(true);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/sign/SkyBlockEventHandler.java b/src/main/java/at/hannibal2/skyhanni/sign/SkyBlockEventHandler.java
new file mode 100644
index 000000000..6934e5820
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/sign/SkyBlockEventHandler.java
@@ -0,0 +1,7 @@
+package at.hannibal2.skyhanni.sign;
+
+import at.hannibal2.skyhanni.utils.LorenzUtils;
+
+public class SkyBlockEventHandler {
+ public static boolean isSkyBlock = LorenzUtils.INSTANCE.getInSkyblock();
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/sign/SkyBlockcatiaConfig.java b/src/main/java/at/hannibal2/skyhanni/sign/SkyBlockcatiaConfig.java
new file mode 100644
index 000000000..2bd80e8df
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/sign/SkyBlockcatiaConfig.java
@@ -0,0 +1,7 @@
+package at.hannibal2.skyhanni.sign;
+
+public class SkyBlockcatiaConfig {
+ public static boolean enableOverwriteSignEditing = true;
+ public static boolean enableSignSelectionList = false;
+}
+
diff --git a/src/main/java/at/hannibal2/skyhanni/sign/TextInputUtil.java b/src/main/java/at/hannibal2/skyhanni/sign/TextInputUtil.java
new file mode 100644
index 000000000..a66b31327
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/sign/TextInputUtil.java
@@ -0,0 +1,202 @@
+package at.hannibal2.skyhanni.sign;
+
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.util.ChatAllowedCharacters;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.MathHelper;
+import org.lwjgl.input.Keyboard;
+
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+public class TextInputUtil {
+ private final FontRenderer fontRenderer;
+ private final Supplier<String> stringSupplier;
+ private final Consumer<String> stringConsumer;
+ private final int maxLength;
+ private int selectionStart;
+ private int selectionEnd;
+
+ public TextInputUtil(FontRenderer fontRenderer, Supplier<String> stringSupplier, Consumer<String> stringConsumer, int maxLength) {
+ this.fontRenderer = fontRenderer;
+ this.stringSupplier = stringSupplier;
+ this.stringConsumer = stringConsumer;
+ this.maxLength = maxLength;
+ this.moveCaretToEnd();
+ }
+
+ public boolean insert(char typedChar) {
+ if (ChatAllowedCharacters.isAllowedCharacter(typedChar)) {
+ this.insert(Character.toString(typedChar));
+ }
+ return true;
+ }
+
+ private void insert(String typedChar) {
+ if (this.selectionEnd != this.selectionStart) {
+ this.deleteSelectedText();
+ }
+
+ String s = this.stringSupplier.get();
+ this.selectionStart = MathHelper.clamp_int(this.selectionStart, 0, s.length());
+ String s1 = new StringBuilder(s).insert(this.selectionStart, typedChar).toString();
+
+ if (this.fontRenderer.getStringWidth(s1) <= this.maxLength) {
+ this.stringConsumer.accept(s1);
+ this.selectionEnd = this.selectionStart = Math.min(s1.length(), this.selectionStart + typedChar.length());
+ }
+ }
+
+ public boolean handleSpecialKey(int keyCode) {
+ String s = this.stringSupplier.get();
+
+ if (GuiScreen.isKeyComboCtrlA(keyCode)) {
+ this.selectionEnd = 0;
+ this.selectionStart = s.length();
+ return true;
+ } else if (GuiScreen.isKeyComboCtrlC(keyCode)) {
+ GuiScreen.setClipboardString(this.getSelectedText());
+ return true;
+ } else if (GuiScreen.isKeyComboCtrlV(keyCode)) {
+ this.insert(ChatAllowedCharacters.filterAllowedCharacters(EnumChatFormatting.getTextWithoutFormattingCodes(GuiScreen.getClipboardString().replaceAll("\\r", ""))));
+ this.selectionEnd = this.selectionStart;
+ return true;
+ } else if (GuiScreen.isKeyComboCtrlX(keyCode)) {
+ GuiScreen.setClipboardString(this.getSelectedText());
+ this.deleteSelectedText();
+ return true;
+ } else {
+ switch (keyCode) {
+ case Keyboard.KEY_BACK:
+ if (!s.isEmpty()) {
+ if (this.selectionEnd != this.selectionStart) {
+ this.deleteSelectedText();
+ } else if (this.selectionStart > 0) {
+ s = new StringBuilder(s).deleteCharAt(Math.max(0, this.selectionStart - 1)).toString();
+ this.selectionEnd = this.selectionStart = Math.max(0, this.selectionStart - 1);
+ this.stringConsumer.accept(s);
+ }
+ }
+ return true;
+ case Keyboard.KEY_DELETE:
+ if (!s.isEmpty()) {
+ if (this.selectionEnd != this.selectionStart) {
+ this.deleteSelectedText();
+ } else if (this.selectionStart < s.length()) {
+ s = new StringBuilder(s).deleteCharAt(Math.max(0, this.selectionStart)).toString();
+ this.stringConsumer.accept(s);
+ }
+ }
+ return true;
+ case Keyboard.KEY_LEFT:
+ int j = this.fontRenderer.getBidiFlag() ? 1 : -1;
+ if (GuiScreen.isCtrlKeyDown()) {
+ this.selectionStart = this.findWordEdge(s, j, this.selectionStart);
+ } else {
+ this.selectionStart = Math.max(0, Math.min(s.length(), this.selectionStart + j));
+ }
+ if (!GuiScreen.isShiftKeyDown()) {
+ this.selectionEnd = this.selectionStart;
+ }
+ return true;
+ case Keyboard.KEY_RIGHT:
+ int i = this.fontRenderer.getBidiFlag() ? -1 : 1;
+ if (GuiScreen.isCtrlKeyDown()) {
+ this.selectionStart = this.findWordEdge(s, i, this.selectionStart);
+ } else {
+ this.selectionStart = Math.max(0, Math.min(s.length(), this.selectionStart + i));
+ }
+ if (!GuiScreen.isShiftKeyDown()) {
+ this.selectionEnd = this.selectionStart;
+ }
+ return true;
+ case Keyboard.KEY_HOME:
+ this.selectionStart = 0;
+ if (!GuiScreen.isShiftKeyDown()) {
+ this.selectionEnd = this.selectionStart;
+ }
+ return true;
+ case Keyboard.KEY_END:
+ this.selectionStart = this.stringSupplier.get().length();
+ if (!GuiScreen.isShiftKeyDown()) {
+ this.selectionEnd = this.selectionStart;
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+ }
+
+ private String getSelectedText() {
+ String s = this.stringSupplier.get();
+ int i = Math.min(this.selectionStart, this.selectionEnd);
+ int j = Math.max(this.selectionStart, this.selectionEnd);
+ return s.substring(i, j);
+ }
+
+ private void deleteSelectedText() {
+ if (this.selectionEnd != this.selectionStart) {
+ String s = this.stringSupplier.get();
+ int i = Math.min(this.selectionStart, this.selectionEnd);
+ int j = Math.max(this.selectionStart, this.selectionEnd);
+ String s1 = s.substring(0, i) + s.substring(j);
+ this.selectionStart = i;
+ this.selectionEnd = this.selectionStart;
+ this.stringConsumer.accept(s1);
+ }
+ }
+
+ public void moveCaretToEnd() {
+ this.selectionEnd = this.selectionStart = this.stringSupplier.get().length();
+ }
+
+ public int getSelectionStart() {
+ return this.selectionStart;
+ }
+
+ public int getSelectionEnd() {
+ return this.selectionEnd;
+ }
+
+ private int findWordEdge(String text, int bidiFlag, int selectionStart) {
+ int i = selectionStart;
+ boolean flag = bidiFlag < 0;
+ int j = Math.abs(bidiFlag);
+
+ for (int k = 0; k < j; ++k) {
+ if (flag) {
+ while (i > 0 && (text.charAt(i - 1) == ' ' || text.charAt(i - 1) == '\n')) {
+ --i;
+ }
+ while (i > 0 && text.charAt(i - 1) != ' ' && text.charAt(i - 1) != '\n') {
+ --i;
+ }
+ } else {
+ int l = text.length();
+ int i1 = text.indexOf(32, i);
+ int j1 = text.indexOf(10, i);
+
+ if (i1 == -1 && j1 == -1) {
+ i = -1;
+ } else if (i1 != -1 && j1 != -1) {
+ i = Math.min(i1, j1);
+ } else if (i1 != -1) {
+ i = i1;
+ } else {
+ i = j1;
+ }
+
+ if (i == -1) {
+ i = l;
+ } else {
+ while (i < l && (text.charAt(i) == ' ' || text.charAt(i) == '\n')) {
+ ++i;
+ }
+ }
+ }
+ }
+ return i;
+ }
+} \ No newline at end of file