aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBuildTools <james.jenour@protonmail.com>2021-05-29 22:02:37 +0800
committerBuildTools <james.jenour@protonmail.com>2021-05-29 22:02:37 +0800
commit1b172089ce502803f7644611afd618ce00dcb860 (patch)
treebcc17b38c97dfdd5a2147aed8e7700700fec732c /src
parent9aa7b49d224bfde055e12bc84f6908ba0a50090d (diff)
downloadNotEnoughUpdates-1b172089ce502803f7644611afd618ce00dcb860.tar.gz
NotEnoughUpdates-1b172089ce502803f7644611afd618ce00dcb860.tar.bz2
NotEnoughUpdates-1b172089ce502803f7644611afd618ce00dcb860.zip
PRE28
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java60
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java63
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java68
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/KeybindHelper.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonWin.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DamageCommas.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FancyPortals.java303
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java549
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCustomizeManager.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/NPCRetexturing.java1
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java295
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java31
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemCustomize.java92
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/InventoryStorageSelector.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/StorageOverlay.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayerSP.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java47
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemRenderer.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinLoadingScreenRenderer.java22
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinMinecraft.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java27
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java21
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorldClient.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java277
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java13
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java22
-rw-r--r--src/main/resources/assets/notenoughupdates/fishing_warning_exclam.pngbin0 -> 5807 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/groundplane.pngbin0 -> 40868 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-1.pngbin0 -> 82574 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-2.pngbin0 -> 1228306 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-3.pngbin0 -> 646267 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-4.pngbin0 -> 668239 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-5.pngbin0 -> 531635 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/portal_panoramas/nether/pansc-6.pngbin0 -> 275559 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/slotlocking/bound.pngbin0 -> 5619 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/storage_gui/storage_gui_3.pngbin3374 -> 7861 bytes
-rw-r--r--src/main/resources/assets/notenoughupdates/storage_gui/storage_preview_3.pngbin7160 -> 4373 bytes
-rw-r--r--src/main/resources/mixins.notenoughupdates.json4
-rw-r--r--src/main/resources/notenoughupdates_at.cfg5
46 files changed, 1785 insertions, 282 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java b/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java
deleted file mode 100644
index 8ec4263a..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package io.github.moulberry.notenoughupdates;
-
-import io.github.moulberry.morus.MorusSubstitutor;
-import net.minecraft.client.Minecraft;
-import net.minecraft.item.ItemStack;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class MorusIntegration {
-
- private static MorusIntegration INSTANCE = new MorusIntegration();
-
- public static MorusIntegration getInstance() {
- return INSTANCE;
- }
-
- private HashMap<String, Integer> itemDrops = null;
- private HashMap<String, Integer> inventoryItems = null;
-
- public void tick() {
- if(itemDrops == null) {
- itemDrops = new HashMap<>();
- for(String item : NotEnoughUpdates.INSTANCE.manager.getItemInformation().keySet()) {
- itemDrops.put(item, 0);
- }
- }
-
- HashMap<String, Integer> newInventoryItems = getInventoryItems();
- if(inventoryItems != null) {
- for(String internal : newInventoryItems.keySet()) {
- int newAmount = newInventoryItems.get(internal);
- int oldAmount = inventoryItems.getOrDefault(internal, 0);
- if(newAmount > oldAmount) {
- itemDrops.put(internal, itemDrops.getOrDefault(internal, 0)+newAmount-oldAmount);
- }
- }
- }
- inventoryItems = newInventoryItems;
-
- for(Map.Entry<String, Integer> entry : itemDrops.entrySet()) {
- MorusSubstitutor.putSubstiution("notenoughupdates", "itemdrops."+entry.getKey().toLowerCase(), ""+entry.getValue());
- }
-
- }
-
- public HashMap<String, Integer> getInventoryItems() {
- HashMap<String, Integer> inventoryItems = new HashMap<>();
- if(Minecraft.getMinecraft().thePlayer != null) {
- for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack);
- if(internalname != null) {
- inventoryItems.put(internalname, inventoryItems.getOrDefault(internalname, 0)+stack.stackSize);
- }
- }
- }
- return inventoryItems;
- }
-
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
index 081a0c1d..98300e73 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -32,6 +32,8 @@ import net.minecraft.client.gui.inventory.GuiEditSign;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.event.ClickEvent;
import net.minecraft.init.Blocks;
@@ -240,7 +242,6 @@ public class NEUEventListener {
DungeonWin.tick();
if(longUpdate) {
-
CrystalOverlay.tick();
DwarvenMinesTextures.tick();
FairySouls.tick();
@@ -260,9 +261,6 @@ public class NEUEventListener {
NotEnoughUpdates.INSTANCE.overlay.redrawItems();
CapeManager.onTickSlow();
- for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
- NotEnoughUpdates.profileViewer.putNameUuid(player.getName(), player.getUniqueID().toString().replace("-", ""));
- }
NotEnoughUpdates.profileViewer.putNameUuid(Minecraft.getMinecraft().thePlayer.getName(),
Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""));
@@ -286,9 +284,6 @@ public class NEUEventListener {
if(neu.hasSkyblockScoreboard()) {
SBInfo.getInstance().tick();
- if(Loader.isModLoaded("morus")) {
- MorusIntegration.getInstance().tick();
- }
lastSkyblockScoreboard = currentTime;
if(!joinedSB) {
joinedSB = true;
@@ -702,7 +697,7 @@ public class NEUEventListener {
* 2) When a /viewrecipe command fails (i.e. player does not have recipe unlocked, will open the custom recipe GUI)
* 3) Replaces lobby join notifications when streamer mode is active
*/
- @SubscribeEvent(priority = EventPriority.LOW)
+ @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
public void onGuiChat(ClientChatReceivedEvent e) {
if(e.type == 2) {
e.message = processChatComponent(e.message);
@@ -1380,9 +1375,10 @@ public class NEUEventListener {
boolean customAhActive = event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView();
if(storageOverlayActive) {
- event.setCanceled(true);
- StorageOverlay.getInstance().keyboardInput();
- return;
+ if(StorageOverlay.getInstance().keyboardInput()) {
+ event.setCanceled(true);
+ return;
+ }
}
if(tradeWindowActive || customAhActive) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 8e0c1444..f9965300 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -73,9 +73,11 @@ import java.lang.management.ManagementFactory;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.List;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
@Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true)
public class NotEnoughUpdates {
@@ -706,6 +708,7 @@ public class NotEnoughUpdates {
}
});
+ private ScheduledExecutorService devES = Executors.newSingleThreadScheduledExecutor();
private static final String[] devFailStrings = {"No.", "I said no.", "You aren't allowed to use this.",
"Are you sure you want to use this? Type 'Yes' in chat.", "Lmao you thought", "Ok please stop",
"What do you want from me?", "This command almost certainly does nothing useful for you",
@@ -716,7 +719,8 @@ public class NotEnoughUpdates {
SimpleCommand devTestCommand = new SimpleCommand("neudevtest", new SimpleCommand.ProcessCommandRunnable() {
@Override
public void processCommand(ICommandSender sender, String[] args) {
- if(!Minecraft.getMinecraft().thePlayer.getName().equalsIgnoreCase("Moulberry")) {
+ if(!Minecraft.getMinecraft().thePlayer.getName().equalsIgnoreCase("Moulberry") &&
+ !Minecraft.getMinecraft().thePlayer.getName().equalsIgnoreCase("LucyCoconut")) {
if(devFailIndex >= devFailStrings.length) {
throw new Error("L") {
@Override
@@ -741,6 +745,14 @@ public class NotEnoughUpdates {
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+devFailStrings[devFailIndex++]));
return;
}
+ /*if(args.length == 1) {
+ DupePOC.doDupe(args[0]);
+ return;
+ }*/
+ if(args.length == 2 && args[0].equalsIgnoreCase("pt")) {
+ EnumParticleTypes t = EnumParticleTypes.valueOf(args[1]);
+ FishingHelper.type = t;
+ }
if(args.length == 1 && args[0].equalsIgnoreCase("dev")) {
NotEnoughUpdates.INSTANCE.config.hidden.dev = true;
return;
@@ -749,6 +761,51 @@ public class NotEnoughUpdates {
saveConfig();
return;
}
+ if(args.length == 1 && args[0].equalsIgnoreCase("center")) {
+ double x = Math.floor(Minecraft.getMinecraft().thePlayer.posX) + 0.5f;
+ double z = Math.floor(Minecraft.getMinecraft().thePlayer.posZ) + 0.5f;
+ Minecraft.getMinecraft().thePlayer.setPosition(x, Minecraft.getMinecraft().thePlayer.posY, z);
+ return;
+ }
+ if(args.length == 1 && args[0].equalsIgnoreCase("pansc")) {
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Taking panorama screenshot"));
+
+ AtomicInteger perspective = new AtomicInteger(0);
+ FancyPortals.perspectiveId = 0;
+
+ EntityPlayerSP p = Minecraft.getMinecraft().thePlayer;
+ p.prevRotationYaw = p.rotationYaw = 0;
+ p.prevRotationPitch = p.rotationPitch = 90;
+ devES.schedule(new Runnable() {
+ @Override
+ public void run() {
+ Minecraft.getMinecraft().addScheduledTask(() -> {
+ ScreenShotHelper.saveScreenshot(new File("C:/Users/James/Desktop/"), "pansc-"+perspective.get()+".png",
+ Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight,
+ Minecraft.getMinecraft().getFramebuffer());
+ });
+ if(perspective.incrementAndGet() >= 6) {
+ FancyPortals.perspectiveId = -1;
+ return;
+ }
+ devES.schedule(() -> {
+ FancyPortals.perspectiveId = perspective.get();
+ if(FancyPortals.perspectiveId == 5) {
+ p.prevRotationYaw = p.rotationYaw = 0;
+ p.prevRotationPitch = p.rotationPitch = -90;
+ } else if(FancyPortals.perspectiveId >= 1 && FancyPortals.perspectiveId <= 4) {
+ float yaw = 90*FancyPortals.perspectiveId-180;
+ if(yaw > 180) yaw -= 360;
+ p.prevRotationYaw = p.rotationYaw = yaw;
+ p.prevRotationPitch = p.rotationPitch = 0;
+ }
+ devES.schedule(this, 3000L, TimeUnit.MILLISECONDS);
+ }, 100L, TimeUnit.MILLISECONDS);
+ }
+ }, 3000L, TimeUnit.MILLISECONDS);
+
+ return;
+ }
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Executing dubious code"));
/*Minecraft.getMinecraft().thePlayer.rotationYaw = 0;
Minecraft.getMinecraft().thePlayer.rotationPitch = 0;
@@ -1070,6 +1127,7 @@ public class NotEnoughUpdates {
StorageManager.getInstance().loadConfig(new File(neuDir, "storageItems.json"));
FairySouls.load(new File(neuDir, "collected_fairy_souls.json"), gson);
PetInfoOverlay.loadConfig(new File(neuDir, "petCache.json"));
+ SlotLocking.getInstance().loadConfig(new File(neuDir, "slotLocking.json"));
if(config == null) {
config = new NEUConfig();
@@ -1093,12 +1151,14 @@ public class NotEnoughUpdates {
MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures());
MinecraftForge.EVENT_BUS.register(new DwarvenMinesWaypoints());
MinecraftForge.EVENT_BUS.register(new FuelBar());
+ //MinecraftForge.EVENT_BUS.register(new FancyPortals());
MinecraftForge.EVENT_BUS.register(XPInformation.getInstance());
MinecraftForge.EVENT_BUS.register(OverlayManager.petInfoOverlay);
MinecraftForge.EVENT_BUS.register(OverlayManager.timersOverlay);
MinecraftForge.EVENT_BUS.register(new NullzeeSphere());
MinecraftForge.EVENT_BUS.register(InventoryStorageSelector.getInstance());
MinecraftForge.EVENT_BUS.register(SlotLocking.getInstance());
+ MinecraftForge.EVENT_BUS.register(FishingHelper.getInstance());
if(Minecraft.getMinecraft().getResourceManager() instanceof IReloadableResourceManager) {
((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(CustomSkulls.getInstance());
@@ -1174,6 +1234,7 @@ public class NotEnoughUpdates {
try { StorageManager.getInstance().saveConfig(new File(neuDir, "storageItems.json")); } catch(Exception ignored) {}
try { FairySouls.save(new File(neuDir, "collected_fairy_souls.json"), gson); } catch(Exception ignored) {}
try { PetInfoOverlay.saveConfig(new File(neuDir, "petCache.json")); } catch(Exception ignored) {}
+ try { SlotLocking.getInstance().saveConfig(new File(neuDir, "slotLocking.json")); } catch(Exception ignored) {}
}
/**
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java
index bc8ea93a..d27e6bd7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/BackgroundBlur.java
@@ -157,7 +157,7 @@ public class BackgroundBlur {
try {
blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz);
+ output, blurOutputHorz);
blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
} catch(Exception e) { }
@@ -177,11 +177,11 @@ public class BackgroundBlur {
blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor);
GL11.glPushMatrix();
- /*GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
+ GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebufferObject);
GL30.glBlitFramebuffer(0, 0, width, height,
0, 0, output.framebufferWidth, output.framebufferHeight,
- GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);*/
+ GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
blurShaderHorz.loadShader(0);
blurShaderVert.loadShader(0);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
index fb75ea23..3ab47531 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementColour.java
@@ -217,13 +217,13 @@ public class GuiElementColour extends GuiElement {
if(opacitySlider) {
TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(c.getAlpha()/255f*100)+"",
Minecraft.getMinecraft().fontRendererObj,
- x+5+64+5+15+5, y+5+64+5+5, true, 13, -1);
+ x+5+64+5+valueOffset+5, y+5+64+5+5, true, 13, -1);
}
if(chromaSpeed > 0) {
TextRenderUtils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+
(int)ChromaColour.getSecondsForSpeed(chromaSpeed)+"s",
Minecraft.getMinecraft().fontRendererObj,
- x+5+64+5+valueOffset+15+6, y+5+64+5+5, true, 13, -1);
+ x+5+64+5+valueOffset+opacityOffset+6, y+5+64+5+5, true, 13, -1);
}
hexField.setSize(48, 10);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
index 965c705d..aded91e6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/GuiElementTextField.java
@@ -16,6 +16,7 @@ import java.util.regex.Pattern;
public class GuiElementTextField {
+ public static final int SCISSOR_TEXT = 0b10000000;
public static final int DISABLE_BG = 0b1000000;
public static final int SCALE_TEXT = 0b100000;
public static final int NUM_ONLY = 0b10000;
@@ -73,6 +74,18 @@ public class GuiElementTextField {
return textField.getText();
}
+ public String getTextDisplay() {
+ String textNoColour = getText();
+ while(true) {
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
+ if(!matcher.find()) break;
+ String code = matcher.group(1);
+ textNoColour = matcher.replaceFirst("\u00B6"+code);
+ }
+
+ return textNoColour;
+ }
+
public void setPrependText(String text) {
this.prependText = text;
}
@@ -130,13 +143,7 @@ public class GuiElementTextField {
return (options & SCALE_TEXT) != 0;
}
- private float getStringWidth(String str) {
- if(isScaling()) {
- return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str)*getScaleFactor(str);
- } else {
- return Minecraft.getMinecraft().fontRendererObj.getStringWidth(str);
- }
- }
+ private static final Pattern PATTERN_CONTROL_CODE = Pattern.compile("(?i)\\u00A7([^\\u00B6]|$)(?!\\u00B6)");
public int getCursorPos(int mouseX, int mouseY) {
int xComp = mouseX - x;
@@ -148,12 +155,11 @@ public class GuiElementTextField {
int lineNum = Math.round(((yComp - (searchBarYSize-8)/2))/extraSize);
- Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6]|$)(?!\\u00B6)");
String text = renderText;
String textNoColour = renderText;
if((options & COLOUR) != 0) {
while(true) {
- Matcher matcher = patternControlCode.matcher(text);
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(text);
if(!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
if(code.isEmpty()) {
@@ -164,7 +170,7 @@ public class GuiElementTextField {
}
}
while(true) {
- Matcher matcher = patternControlCode.matcher(textNoColour);
+ Matcher matcher = PATTERN_CONTROL_CODE.matcher(textNoColour);
if(!matcher.find() || matcher.groupCount() < 1) break;
String code = matcher.group(1);
textNoColour = matcher.replaceFirst("\u00B6"+code);
@@ -351,6 +357,10 @@ public class GuiElementTextField {
if((options & FORCE_CAPS) != 0) typedChar = Character.toUpperCase(typedChar);
if((options & NO_SPACE) != 0 && typedChar == ' ') return;
+ if(typedChar == '\u00B6') {
+ typedChar = '\u00A7';
+ }
+
textField.setFocused(true);
textField.textboxKeyTyped(typedChar, keyCode);
@@ -368,6 +378,19 @@ public class GuiElementTextField {
textField.setCursorPosition(pos+1);
}