aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java86
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java382
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java18
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java543
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java176
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java172
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java50
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java259
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java70
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/Options.java205
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java9
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java3
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java15
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java95
22 files changed, 1691 insertions, 441 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java
index 1011f3cc..d8d84144 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java
@@ -4,6 +4,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -226,7 +227,7 @@ public class AccessoryBagOverlay {
private static Set<ItemStack> duplicates = null;
public static void renderDuplicatesOverlay(int x, int y) {
if(duplicates == null) {
- JsonObject misc = Utils.getConstant("misc");
+ JsonObject misc = Constants.MISC;
if(misc == null) {
Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
new Color(80, 80, 80).getRGB());
@@ -297,7 +298,7 @@ public class AccessoryBagOverlay {
private static List<ItemStack> missing = null;
public static void renderMissingOverlay(int x, int y) {
if(missing == null) {
- JsonObject misc = Utils.getConstant("misc");
+ JsonObject misc = Constants.MISC;
if(misc == null) {
Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70,
new Color(80, 80, 80).getRGB());
@@ -788,7 +789,7 @@ public class AccessoryBagOverlay {
}
public static boolean isAccessory(ItemStack stack) {
- return checkItemType(stack, false, "ACCESSORY", "HATCCESSORY") >= 0;
+ return checkItemType(stack, true, "ACCESSORY", "HATCCESSORY") >= 0;
}
public static int getRarity(ItemStack stack) {
@@ -800,7 +801,7 @@ public class AccessoryBagOverlay {
for (int i = list.tagCount(); i >= 0; i--) {
String line = list.getStringTagAt(i);
for(int j=0; j<rarityArrC.length; j++) {
- if(line.startsWith(rarityArrC[j])) {
+ if(line.contains(rarityArrC[j])) {
return j;
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java b/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java
index 6a876201..1a7cd803 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java
@@ -25,6 +25,7 @@ import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
import java.util.Random;
public class BetterContainers {
@@ -43,14 +44,19 @@ public class BetterContainers {
private static int lastClickedSlot = 0;
private static int clickedSlot = 0;
private static long clickedSlotMillis = 0;
+ public static long lastRenderMillis = 0;
+
+ public static HashMap<Integer, ItemStack> itemCache = new HashMap<>();
+ public static boolean lastUsingCached = false;
+ public static boolean usingCached = false;
public static void clickSlot(int slot) {
- clickedSlot = slot;
clickedSlotMillis = System.currentTimeMillis();
+ clickedSlot = slot;
}
public static int getClickedSlot() {
- if(clickedSlotMillis - System.currentTimeMillis() < 200) {
+ if(System.currentTimeMillis() - clickedSlotMillis < 500) {
return clickedSlot;
}
return -1;
@@ -58,11 +64,32 @@ public class BetterContainers {
public static void bindHook(TextureManager textureManager, ResourceLocation location) {
if(isChestOpen()) {
- if(lastClickedSlot != getClickedSlot() || (texture == null && !loaded)) {
+ Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
+ if(container instanceof ContainerChest) {
+ usingCached = true;
+ IInventory lower = ((ContainerChest)container).getLowerChestInventory();
+ int size = lower.getSizeInventory();
+ for(int index=0; index<size; index++) {
+ if(lower.getStackInSlot(index) != null) {
+ for(int index2=0; index2<size; index2++) {
+ itemCache.put(index2, lower.getStackInSlot(index2));
+ }
+ usingCached = false;
+ break;
+ }
+ }
+ }
+
+ if((texture != null && loaded && lastClickedSlot != getClickedSlot()) ||
+ lastUsingCached != getUsingCache() ||
+ (texture == null && !loaded)) {
+ lastUsingCached = getUsingCache();
lastClickedSlot = getClickedSlot();
generateTex(location);
}
- if(isOverriding()) {
+ if(texture != null && loaded) {
+ if(!usingCached) lastRenderMillis = System.currentTimeMillis();
+ lastRenderMillis = System.currentTimeMillis();
textureManager.loadTexture(rl, texture);
textureManager.bindTexture(rl);
return;
@@ -71,6 +98,10 @@ public class BetterContainers {
textureManager.bindTexture(location);
}
+ public static boolean getUsingCache() {
+ return usingCached && System.currentTimeMillis() - lastRenderMillis < 300;
+ }
+
public static boolean isAh() {
if(!isChestOpen()) return false;
@@ -81,7 +112,7 @@ public class BetterContainers {
}
public static boolean isOverriding() {
- return isChestOpen() && loaded && texture != null && !Keyboard.isKeyDown(Keyboard.KEY_B);
+ return isChestOpen() && ((loaded && texture != null));
}
public static boolean isBlankStack(ItemStack stack) {
@@ -126,23 +157,24 @@ public class BetterContainers {
private static void generateTex(ResourceLocation location) {
if(!hasItem()) return;
+ texture = null;
loaded = true;
Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
- int backgroundStyle = NotEnoughUpdates.INSTANCE.manager.config.dynamicMenuBackgroundStyle.value.intValue();
- backgroundStyle = Math.max(1, Math.min(10, backgroundStyle));
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(
- new ResourceLocation("notenoughupdates:dynamic_54/style"+ backgroundStyle+"/dynamic_config.json")).getInputStream(), StandardCharsets.UTF_8));
- JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
- String textColourS = json.get("text-colour").getAsString();
- textColour = (int)Long.parseLong(textColourS, 16);
- } catch(Exception e) {
- textColour = 4210752;
- e.printStackTrace();
- }
-
if(hasNullPane() && container instanceof ContainerChest) {
+ int backgroundStyle = NotEnoughUpdates.INSTANCE.manager.config.dynamicMenuBackgroundStyle.value.intValue();
+ backgroundStyle = Math.max(1, Math.min(10, backgroundStyle));
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(
+ new ResourceLocation("notenoughupdates:dynamic_54/style"+ backgroundStyle+"/dynamic_config.json")).getInputStream(), StandardCharsets.UTF_8));
+ JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class);
+ String textColourS = json.get("text-colour").getAsString();
+ textColour = (int)Long.parseLong(textColourS, 16);
+ } catch(Exception e) {
+ textColour = 4210752;
+ e.printStackTrace();
+ }
+
try {
BufferedImage bufferedImageOn = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(TOGGLE_ON).getInputStream());
BufferedImage bufferedImageOff = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(TOGGLE_OFF).getInputStream());
@@ -179,10 +211,10 @@ public class BetterContainers {
boolean[][] slots = new boolean[9][size/9];
boolean[][] buttons = new boolean[9][size/9];
for (int index = 0; index < size; index++) {
- ItemStack stack = lower.getStackInSlot(index);
+ ItemStack stack = getStackCached(lower, index);
buttons[index%9][index/9] = isButtonStack(stack);
- if(buttons[index%9][index/9] && getClickedSlot() == index) {
+ if(buttons[index%9][index/9] && lastClickedSlot == index) {
buttons[index%9][index/9] = false;
slots[index%9][index/9] = true;
} else {
@@ -190,7 +222,7 @@ public class BetterContainers {
}
}
for (int index = 0; index < size; index++) {
- ItemStack stack = lower.getStackInSlot(index);
+ ItemStack stack = getStackCached(lower, index);
int xi = index%9;
int yi = index/9;
if(slots[xi][yi] || buttons[xi][yi]) {
@@ -277,12 +309,20 @@ public class BetterContainers {
IInventory lower = ((ContainerChest)container).getLowerChestInventory();
int size = lower.getSizeInventory();
for(int index=0; index<size; index++) {
- if(lower.getStackInSlot(index) != null) return true;
+ if(getStackCached(lower, index) != null) return true;
}
}
return false;
}
+ private static ItemStack getStackCached(IInventory lower, int index) {
+ if(getUsingCache()) {
+ return itemCache.get(index);
+ } else {
+ return lower.getStackInSlot(index);
+ }
+ }
+
private static boolean hasNullPane() {
if(!isChestOpen()) return false;
Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
@@ -290,7 +330,7 @@ public class BetterContainers {
IInventory lower = ((ContainerChest)container).getLowerChestInventory();
int size = lower.getSizeInventory();
for(int index=0; index<size; index++) {
- if(isBlankStack(lower.getStackInSlot(index))) return true;
+ if(isBlankStack(getStackCached(lower, index))) return true;
}
}
return false;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java
index cc94981f..0fa4aa96 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java
@@ -1,38 +1,55 @@
package io.github.moulberry.notenoughupdates;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
+import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
+import net.minecraft.block.state.BlockState;
+import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.ActiveRenderInfo;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.*;
+import net.minecraft.client.renderer.block.model.BakedQuad;
+import net.minecraft.client.renderer.texture.TextureAtlasSprite;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.nbt.CompressedStreamTools;
+import net.minecraft.nbt.NBTTagByteArray;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.*;
import net.minecraftforge.client.event.DrawBlockHighlightEvent;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.client.event.RenderBlockOverlayEvent;
+import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
+import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.vector.Vector3f;
+import scala.tools.cmd.Spec;
import java.awt.*;
-import java.util.HashSet;
-import java.util.LinkedList;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.*;
+import java.util.List;
public class CustomItemEffects {
public static final CustomItemEffects INSTANCE = new CustomItemEffects();
+ private static final int MAX_BUILDERS_BLOCKS = 164;
+
public long aoteUseMillis = 0;
public int aoteTeleportationMillis = 0;
public Vector3f aoteTeleportationCurr = null;
@@ -116,15 +133,118 @@ public class CustomItemEffects {
}
@SubscribeEvent
+ public void onOverlayDrawn(RenderGameOverlayEvent event) {
+ if(!NotEnoughUpdates.INSTANCE.manager.config.disableWandOverlay.value &&
+ Minecraft.getMinecraft().objectMouseOver != null &&
+ Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK &&
+ ((event.type == null && Loader.isModLoaded("labymod")) ||
+ event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS)) {
+
+ IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(
+ Minecraft.getMinecraft().objectMouseOver.getBlockPos().offset(
+ Minecraft.getMinecraft().objectMouseOver.sideHit, 1));
+ if(hover.getBlock() == Blocks.air) {
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+
+ if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+
+ HashSet<BlockPos> candidatesOld = new HashSet<>();
+ TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>();
+
+ IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos());
+ Item matchItem = Item.getItemFromBlock(match.getBlock());
+ if(matchItem != null) {
+ ItemStack matchStack = new ItemStack(matchItem, 1,
+ match.getBlock().getDamageValue(Minecraft.getMinecraft().theWorld, Minecraft.getMinecraft().objectMouseOver.getBlockPos()));
+ int itemCount = countItemsInInventoryAndStorage(matchStack);
+
+ getBuildersWandCandidates(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().objectMouseOver, event.partialTicks,
+ candidatesOld, candidatesOldSorted, 999-MAX_BUILDERS_BLOCKS);
+
+ if(candidatesOld.size() > MAX_BUILDERS_BLOCKS) {
+ Utils.drawStringCentered(EnumChatFormatting.RED.toString()+candidatesOld.size()+"/"+MAX_BUILDERS_BLOCKS,
+ Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0);
+ } else {
+ String pre = EnumChatFormatting.GREEN.toString();
+ if(itemCount < candidatesOld.size()) {
+ pre = EnumChatFormatting.RED.toString();
+ }
+ Utils.drawStringCentered(pre+Math.min(candidatesOld.size(), itemCount)+"/"+
+ Math.min(candidatesOld.size(), MAX_BUILDERS_BLOCKS),
+ Minecraft.getMinecraft().fontRendererObj,
+ scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0);
+ }
+
+ String itemCountS = EnumChatFormatting.DARK_GRAY+"x"+EnumChatFormatting.RESET+countItemsInInventoryAndStorage(matchStack);
+ int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS);
+
+ if(NotEnoughUpdates.INSTANCE.manager.config.wandBlockCount.value) {
+ Utils.drawItemStack(matchStack, scaledResolution.getScaledWidth()/2 - (itemCountLen+16)/2, scaledResolution.getScaledHeight()/2+10+4);
+ Minecraft.getMinecraft().fontRendererObj.drawString(itemCountS,
+ scaledResolution.getScaledWidth()/2f - (itemCountLen+16)/2f+16, scaledResolution.getScaledHeight()/2f+10+8,
+ -1,
+ true);
+ }
+
+ GlStateManager.color(1, 1, 1, 1);
+ }
+
+ }
+ }
+ }
+ }
+
+ public int countItemsInInventoryAndStorage(ItemStack match) {
+ int count = 0;
+
+ for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) {
+ if(match.isItemEqual(stack)) {
+ count += stack.stackSize;
+ }
+ }
+
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
+
+ if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) {
+ //System.out.println("1");
+ if(held.hasTagCompound() && held.getTagCompound().hasKey("ExtraAttributes", 10) &&
+ held.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("builder's_wand_data", 7)) {
+ //System.out.println("2");
+ byte[] bytes = held.getTagCompound().getCompoundTag("ExtraAttributes").getByteArray("builder's_wand_data");
+ try {
+ NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes));
+ NBTTagList items = contents_nbt.getTagList("i", 10);
+ for(int j=0; j<items.tagCount(); j++) {
+ NBTTagCompound buildersItem = items.getCompoundTagAt(j);
+ if(buildersItem.getKeySet().size() > 0) {
+ if(buildersItem.getInteger("id") == Item.getIdFromItem(match.getItem())) {
+ count += items.getCompoundTagAt(j).getByte("Count");
+ }
+ }
+ }
+ } catch(Exception e) {
+ return count;
+ }
+ }
+ }
+
+ return count;
+ }
+
+ @SubscribeEvent
public void renderBlockOverlay(DrawBlockHighlightEvent event) {
if(aoteTeleportationCurr != null && aoteTeleportationMillis > 0) {
event.setCanceled(true);
}
- if(NotEnoughUpdates.INSTANCE.manager.config.disableTreecapOverlay.value) return;
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held);
if(heldInternal != null) {
- if(heldInternal.equals("JUNGLE_AXE") || heldInternal.equals("TREECAPITATOR_AXE")) {
+ if(!NotEnoughUpdates.INSTANCE.manager.config.disableTreecapOverlay.value &&
+ (heldInternal.equals("JUNGLE_AXE") || heldInternal.equals("TREECAPITATOR_AXE"))) {
int maxWood = 10;
if(heldInternal.equals("TREECAPITATOR_AXE")) maxWood = 35;
@@ -185,9 +305,9 @@ public class CustomItemEffects {
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)event.partialTicks;
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)event.partialTicks;
- drawSelectionBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
+ drawFilledBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
.expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2),
- random ? 0.5f : 1f);
+ random ? 0.5f : 1f, NotEnoughUpdates.INSTANCE.manager.config.treecapOverlayColour.value);
}
}
}
@@ -196,14 +316,205 @@ public class CustomItemEffects {
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
+ } else if(!NotEnoughUpdates.INSTANCE.manager.config.disableWandOverlay.value && heldInternal.equals("BUILDERS_WAND")) {
+ int maxBlocks = 164;
+ if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
+ IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos().offset(event.target.sideHit, 1));
+ if(hover.getBlock() == Blocks.air) {
+ EntityPlayer player = event.player;
+
+ IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos());
+ Item matchItem = Item.getItemFromBlock(match.getBlock());
+ if(matchItem != null) {
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(false);
+
+ ItemStack matchStack = new ItemStack(matchItem, 1, match.getBlock().getMetaFromState(match));
+ int itemCount = countItemsInInventoryAndStorage(matchStack);
+
+ HashSet<BlockPos> candidatesOld = new HashSet<>();
+ TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>();
+
+ getBuildersWandCandidates(player, event.target, event.partialTicks, candidatesOld, candidatesOldSorted, 10);
+
+ String special = (candidatesOld.size() <= itemCount) ? NotEnoughUpdates.INSTANCE.manager.config.wandOverlayColour.value :
+ "0:255:255:0:0";
+
+ if(candidatesOld.size() <= maxBlocks) {
+ double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)event.partialTicks;
+ double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)event.partialTicks;
+ double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)event.partialTicks;
+
+ for(Set<BlockPos> candidatesSorted : candidatesOldSorted.values()) {
+ for(BlockPos candidate : candidatesSorted) {
+ match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
+ AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
+ .offset(event.target.sideHit.getFrontOffsetX(), event.target.sideHit.getFrontOffsetY(),
+ event.target.sideHit.getFrontOffsetZ());
+
+ drawBlock((int)bb.minX, (int)bb.minY, (int)bb.minZ+1, match, event.partialTicks, 0.75f);
+ }
+ }
+
+ for(BlockPos candidate : candidatesOld) {
+ match.getBlock().setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate);
+ AxisAlignedBB bb = match.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate)
+ .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2)
+ .offset(event.target.sideHit.getFrontOffsetX(), event.target.sideHit.getFrontOffsetY(),
+ event.target.sideHit.getFrontOffsetZ());
+
+ drawOutlineBoundingBox(bb, 1f, special);
+ }
+ }
+
+ GlStateManager.depthMask(true);
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ }
+ }
+ }
}
}
}
- public static void drawSelectionBoundingBox(AxisAlignedBB p_181561_0_, float alpha) {
- Color c = new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.treecapOverlayColour.value), true);
+ public void getBuildersWandCandidates(EntityPlayer player, MovingObjectPosition target, float partialTicks,
+ HashSet<BlockPos> candidatesOld, TreeMap<Float, Set<BlockPos>> candidatesOldSorted, int extraMax) {
+ IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(target.getBlockPos());
+
+ candidatesOld.clear();
+ candidatesOldSorted.clear();
+ LinkedList<BlockPos> candidates = new LinkedList<>();
+ LinkedList<BlockPos> candidatesNew = new LinkedList<>();
+
+ candidatesNew.add(target.getBlockPos());
+
+ double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
+ double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
+ double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
+
+ while(candidatesOld.size() <= MAX_BUILDERS_BLOCKS+extraMax) {
+ if(candidatesNew.isEmpty()) {
+ break;
+ }
+
+ candidates.addAll(candidatesNew);
+ candidatesNew.clear();
+
+ while(!candidates.isEmpty()) {
+ if(candidatesOld.size() > MAX_BUILDERS_BLOCKS+extraMax) break;
+
+ BlockPos candidate = candidates.pop();
+
+ float distSq = (float)((candidate.getX()+0.5f-d0)*(candidate.getX()+0.5f-d0) +
+ (candidate.getY()+0.5f-d1-player.getEyeHeight())*(candidate.getY()+0.5f-d1-player.getEyeHeight()) +
+ (candidate.getZ()+0.5f-d2)*(candidate.getZ()+0.5f-d2));
+ candidatesOldSorted.computeIfAbsent(distSq, k->new HashSet<>()).add(candidate);
+
+ candidatesOld.add(candidate);
+
+ for(int x = -1; x <= 1; x++) {
+ for(int y = -1; y <= 1; y++) {
+ for(int z = -1; z <= 1; z++) {
+ if(x*x+y*y+z*z == 1) {
+ if(((x == 0) && (target.sideHit.getAxis() == EnumFacing.Axis.X)) ||
+ ((y == 0) && (target.sideHit.getAxis() == EnumFacing.Axis.Y)) ||
+ ((z == 0) && (target.sideHit.getAxis() == EnumFacing.Axis.Z))) {
+ if(Minecraft.getMinecraft().theWorld.getBlockState(candidate.add(
+ x+target.sideHit.getFrontOffsetX(),
+ y+target.sideHit.getFrontOffsetY(),
+ z+target.sideHit.getFrontOffsetZ())).getBlock() == Blocks.air) {
+ BlockPos posNew = candidate.add(x, y, z);
+ if(!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(posNew)) {
+ IBlockState blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew);
+ if(blockNew == match) {
+ candidatesNew.add(posNew);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static void drawBlock(int x, int y, int z, IBlockState state, float partialTicks, float brightness) {
+ EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
+ double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
+ double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
+
+ BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
+
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableLighting();
+ GlStateManager.enableBlend();
+ GlStateManager.blendFunc(770, 771);
+
+ GlStateManager.enableDepth();
+ GlStateManager.depthMask(true);
+ GlStateManager.enableCull();
+ GlStateManager.cullFace(GL11.GL_BACK);
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(x-d0, y-d1, z-d2);
+
+ int i = state.getBlock().getRenderType();
+ if(i == 3) {
+ IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(state, Minecraft.getMinecraft().theWorld, null);
+
+ Block block = state.getBlock();
+ block.setBlockBoundsForItemRender();
+ GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
+ int colour = block.getRenderColor(block.getStateForEntityRender(state));
+
+ if (EntityRenderer.anaglyphEnable) {
+ colour = TextureUtil.anaglyphColor(i);
+ }
+
+ colour = (colour & 0x00FFFFFF) | (100 << 24); //Set alpha to 100
+
+ for (EnumFacing enumfacing : EnumFacing.values()) {
+ renderModelBrightnessColorQuads(colour, ibakedmodel.getFaceQuads(enumfacing));
+ }
+
+ renderModelBrightnessColorQuads(colour, ibakedmodel.getGeneralQuads());
+ }
+
+ GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
+ GlStateManager.translate(-x+d0, -y+d1, -z+d2);
+ GlStateManager.popMatrix();
+ }
+
+ private static void renderModelBrightnessColorQuads(int c, List<BakedQuad> listQuads) {
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+
+ for (BakedQuad bakedquad : listQuads) {
+ worldrenderer.begin(7, DefaultVertexFormats.ITEM);
+ worldrenderer.addVertexData(bakedquad.getVertexData());
+
+ worldrenderer.putColor4(c);
+
+ Vec3i vec3i = bakedquad.getFace().getDirectionVec();
+ worldrenderer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
+ tessellator.draw();
+ }
+ }
+
+ public static void drawFilledBoundingBox(AxisAlignedBB p_181561_0_, float alpha, String special) {
+ Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
GlStateManager.color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha);
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(false);
+
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
//vertical
@@ -250,4 +561,45 @@ public class CustomItemEffects {
}
+ public static void drawOutlineBoundingBox(AxisAlignedBB p_181561_0_, float alpha, String special) {
+ Color c = new Color(SpecialColour.specialToChromaRGB(special), true);
+ GlStateManager.color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha);
+
+ GlStateManager.enableBlend();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.disableTexture2D();
+ GlStateManager.depthMask(false);
+
+ GL11.glLineWidth(3);
+
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(3, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ tessellator.draw();
+ worldrenderer.begin(3, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ tessellator.draw();
+ worldrenderer.begin(1, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
+ worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
+ tessellator.draw();
+
+ GL11.glLineWidth(1);
+ }
+
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java
index a97032c4..f0b92c6a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java
@@ -84,7 +84,7 @@ public class DungeonBlocks implements IResourceManagerReloadListener {
}
for (int i = 0; i <= mipmapLevels; ++i) {
- GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, w >> i, h >> i, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)((IntBuffer)null));
+ GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, w >> i, h >> i, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, ((IntBuffer)null));
}
GlStateManager.bindTexture(textureId);
@@ -159,7 +159,7 @@ public class DungeonBlocks implements IResourceManagerReloadListener {
}
for (int i = 0; i <= mipmapLevels; ++i) {
- GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, w >> i, h >> i, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, (IntBuffer)((IntBuffer)null));
+ GL11.glTexImage2D(GL11.GL_TEXTURE_2D, i, GL11.GL_RGBA, w >> i, h >> i, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, ((IntBuffer)null));
}
}
GlStateManager.bindTexture(textureId);
@@ -193,20 +193,6 @@ public class DungeonBlocks implements IResourceManagerReloadListener {
int index = x+y*w2;
int newCol = entry.getValue();
- /*float newAlpha = ((newCol >> 24) & 0xFF)/255f;
- float newRed = ((newCol >> 16) & 0xFF)/255f;
- float newGreen = ((newCol >> 8) & 0xFF)/255f;
- float newBlue = (newCol & 0xFF)/255f;*/
-
- /*int oldCol = intbuffer.get(index);
- int oldAlpha = (oldCol >> 24) & 0xFF;
- float oldRed = ((oldCol >> 16) & 0xFF)/255f;
- float oldGreen = ((oldCol >> 8) & 0xFF)/255f;
- float oldBlue = (oldCol & 0xFF)/255f;
-
- int r = (int)((newRed*newAlpha + oldRed*(1-newAlpha))*255);
- int g = (int)((newGreen*newAlpha + oldGreen*(1-newAlpha))*255);
- int b = (int)((newBlue*newAlpha + oldBlue*(1-newAlpha))*255);*/
intbuffer.put(index, newCol);
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java
index b32e3452..c9be3dab 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java
@@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.block.material.MapColor;
+import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.MapItemRenderer;
@@ -10,30 +11,57 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.DynamicTexture;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
import net.minecraft.item.ItemMap;
import net.minecraft.item.ItemStack;
+import net.minecraft.scoreboard.ScorePlayerTeam;
+import net.minecraft.util.BlockPos;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec4b;
import net.minecraft.world.storage.MapData;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.*;
+import java.util.List;
public class DungeonMap {
- private int[] mapTextureData = null;
- private DynamicTexture dynamicTexture = new DynamicTexture(128, 128);
- private ResourceLocation dynamicRL = new ResourceLocation("notenoughupdates:dynamic_dungeonmap.png");
+ private static final ResourceLocation GREEN_CHECK = new ResourceLocation("notenoughupdates:dungeon_map/green_check.png");
+ private static final ResourceLocation WHITE_CHECK = new ResourceLocation("notenoughupdates:dungeon_map/white_check.png");
+ private static final ResourceLocation QUESTION = new ResourceLocation("notenoughupdates:dungeon_map/question.png");
- private void setMapRGB(int x, int y, int rgb) {
- if(mapTextureData != null) {
- mapTextureData[x+y*128] = rgb;
- }
- }
+ private static final ResourceLocation ROOM_RED = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/red_room.png");
+ private static final ResourceLocation ROOM_BROWN = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/brown_room.png");
+ private static final ResourceLocation ROOM_GRAY = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/gray_room.png");
+ private static final ResourceLocation ROOM_GREEN = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/green_room.png");
+ private static final ResourceLocation ROOM_PINK = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/pink_room.png");
+ private static final ResourceLocation ROOM_PURPLE = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/purple_room.png");
+ private static final ResourceLocation ROOM_YELLOW = new ResourceLocation("notenoughupdates:dungeon_map/rooms_default/yellow_room.png");
+
+ private static final int RENDER_ROOM_SIZE = 16;
+ private static final int RENDER_CONN_SIZE = 4;
+
+ private final HashMap<RoomOffset, Room> roomMap = new HashMap<>();
+ private Color[][] colourMap = new Color[128][128];
+ private int startRoomX = -1;
+ private int startRoomY = -1;
+ private int connectorSize = 5;
+ private int roomSize = 0;
+
+ private int roomSizeBlocks = 7;
+
+ private final List<MapDecoration> decorations = new ArrayList<>();
+ private final List<MapDecoration> lastDecorations = new ArrayList<>();
+ private long lastDecorationsMillis = -1;
+ private long lastLastDecorationsMillis = -1;
+
+ private Map<EntityPlayer, MapPosition> playerMapPositions = new HashMap<>();
private class RoomOffset {
int x;
@@ -117,7 +145,30 @@ public class DungeonMap {
RoomConnection down = new RoomConnection(RoomConnectionType.NONE, new Color(0, true));
public void render(int roomSize, int connectorSize) {
- Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB());
+ ResourceLocation roomTex = null;
+ if(colour.getRed() == 114 && colour.getGreen() == 67 && colour.getBlue() == 27) {
+ roomTex = ROOM_BROWN;
+ } else if(colour.getRed() == 65 && colour.getGreen() == 65 && colour.getBlue() == 65) {
+ roomTex = ROOM_GRAY;
+ } else if(colour.getRed() == 0 && colour.getGreen() == 124 && colour.getBlue() == 0) {
+ roomTex = ROOM_GREEN;
+ } else if(colour.getRed() == 242 && colour.getGreen() == 127 && colour.getBlue() == 165) {
+ roomTex = ROOM_PINK;
+ } else if(colour.getRed() == 178 && colour.getGreen() == 76 && colour.getBlue() == 216) {
+ roomTex = ROOM_PURPLE;
+ } else if(colour.getRed() == 255 && colour.getGreen() == 0 && colour.getBlue() == 0) {
+ roomTex = ROOM_RED;
+ } else if(colour.getRed() == 229 && colour.getGreen() == 229 && colour.getBlue() == 51) {
+ roomTex = ROOM_YELLOW;
+ }
+
+ if(roomTex != null) {
+ Minecraft.getMinecraft().getTextureManager().bindTexture(roomTex);
+ GlStateManager.color(1, 1, 1, 1);
+ Utils.drawTexturedRect(0, 0, roomSize, roomSize, GL11.GL_LINEAR);
+ }
+
+ //Gui.drawRect(0, 0, roomSize, roomSize, colour.getRGB());
if(tickColour != 0) {
Gui.drawRect(roomSize/2-4, roomSize/2-4, roomSize/2+4, roomSize/2+4, tickColour);
}
@@ -181,13 +232,6 @@ public class DungeonMap {
}
}
}
-
- public void render(int[] renderTo, int x, int y, int rgb) {
- int i = x+y*128;
- if(i >= 0 && i < renderTo.length) {
- renderTo[i] = rgb;
- }
- }
private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png");
@@ -203,23 +247,42 @@ public class DungeonMap {
maxRoomY = Math.max(offset.y, maxRoomY);
}
- int roomSize = 16;
- int connSize = 4;
-
- Gui.drawRect(8, 8, 8+(maxRoomX-minRoomX+1)*(roomSize+connSize), 8+(maxRoomY-minRoomY+1)*(roomSize+connSize),
+ /*Set<Color> uniques = new HashSet<>();
+ for(Color[] cs : colourMap) {
+ for(Color c : cs) {
+ uniques.add(c);
+ }
+ }
+ System.out.println("Unique colours:");
+ for(Color c : uniques) {
+ System.out.println(c + "" + c.getAlpha());
+ }*/
+
+ int centerX = 80;
+ int centerY = 80;
+ int rotation = (int)Minecraft.getMinecraft().thePlayer.rotationYawHead;
+
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(centerX, centerY, 0);
+ GlStateManager.rotate(-rotation+180, 0, 0, 1);
+ GlStateManager.translate(-(maxRoomX-minRoomX+1)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE)/2f,
+ -(maxRoomY-minRoomY+1)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE)/2f, 0);
+
+ Gui.drawRect(-10, -10, (maxRoomX-minRoomX)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE)+RENDER_ROOM_SIZE+10,
+ (maxRoomY-minRoomY)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE)+RENDER_ROOM_SIZE+10,
new Color(200, 200, 200).getRGB());
for(Map.Entry<RoomOffset, Room> entry : roomMap.entrySet()) {
RoomOffset roomOffset = entry.getKey();
Room room = entry.getValue();
- int x = (roomOffset.x-minRoomX)*(roomSize+connSize);
- int y = (roomOffset.y-minRoomY)*(roomSize+connSize);
+ int x = (roomOffset.x-minRoomX)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE);
+ int y = (roomOffset.y-minRoomY)*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE);
GlStateManager.pushMatrix();
- GlStateManager.translate(x+10, y+10, 0);
- room.render(roomSize, connSize);
- GlStateManager.translate(-(x+10), -(y+10), 0);
+ GlStateManager.translate(x, y, 0);
+ room.render(RENDER_ROOM_SIZE, RENDER_CONN_SIZE);
+ GlStateManager.translate(-x, -y, 0);
GlStateManager.popMatrix();
}
@@ -228,39 +291,89 @@ public class DungeonMap {
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons);
int k = 0;
- for(MapDecoration decoration : decorations) {
- float x = (decoration.roomsOffsetX+decoration.roomInPercentX)*roomSize +
- (decoration.connOffsetX+decoration.connInPercentX)*connectorSize;
- float y = (decoration.roomsOffsetY+decoration.roomInPercentY)*roomSize +
- (decoration.connOffsetY+decoration.connInPercentY)*connectorSize;
+ for(int i=0; i<decorations.size(); i++) {
+ MapDecoration decoration = decorations.get(i);
+ float minU = (float)(decoration.id % 4) / 4.0F;
+ float minV = (float)(decoration.id / 4) / 4.0F;
+
+ float x = decoration.position.getRenderX();
+ float y = decoration.position.getRenderY();
+ float angle = decoration.angle;
+
+ if(decoration.id == 1) {
+ angle = Minecraft.getMinecraft().thePlayer.rotationYawHead;
+ } else {
+ if(false && i < lastDecorations.size()) {
+ MapDecoration last = lastDecorations.get(i);
+ float xLast = last.position.getRenderX();
+ float yLast = last.position.getRenderY();
+
+ float distSq = (x-xLast)*(x-xLast)+(y-yLast)*(y-yLast);
+ if(distSq < RENDER_ROOM_SIZE*RENDER_ROOM_SIZE) {
+ float angleLast = last.angle;
+ if(angle > 180 && angleLast < 180) angleLast += 360;
+ if(angleLast > 180 && angle < 180) angle += 360;
+
+ float interpFactor = Math.round((System.currentTimeMillis() - lastDecorationsMillis)*100f)/100f/(lastDecorationsMillis - lastLastDecorationsMillis);
+ interpFactor = Math.max(0, Math.min(1, interpFactor));
+
+ x = xLast+(x - xLast)*interpFactor;
+ y = yLast+(y - yLast)*interpFactor;
+ angle = angleLast+(angle - angleLast)*interpFactor;
+ angle %= 360;
+ }
+ }
+ }
- x -= minRoomX*(roomSize+connSize);
- y -= minRoomY*(roomSize+connSize);
+ if(decoration.id == 3 || decoration.id == 1) {
+ float closestDistSq = RENDER_ROOM_SIZE*RENDER_ROOM_SIZE;
+ EntityPlayer closestPlayer = null;
+ for(Map.Entry<EntityPlayer, MapPosition> entry : playerMapPositions.entrySet()) {
+ if(Minecraft.getMinecraft().thePlayer.getName().equalsIgnoreCase(entry.getKey().getName()) != (decoration.id == 1)) {
+ continue;
+ }
+
+ float playerX = entry.getValue().getRenderX();
+ float playerY = entry.getValue().getRenderY();
+
+ float distSq = (playerX-x)*(playerX-x) + (playerY-y)*(playerY-y);
+
+ if(distSq < closestDistSq) {
+ closestDistSq = distSq;
+ closestPlayer = entry.getKey();
+ }
+ }
+
+ if(closestPlayer != null) {
+ x = playerMapPositions.get(closestPlayer).getRenderX();
+ y = playerMapPositions.get(closestPlayer).getRenderY();
+ angle = closestPlayer.rotationYawHead;
+ }
+ }
- //System.out.println(decoration.angle);
+ x -= minRoomX*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE);
+ y -= minRoomY*(RENDER_ROOM_SIZE+RENDER_CONN_SIZE);
GlStateManager.pushMatrix();
- GlStateManager.translate(x+10, y+10, -0.02F);
- GlStateManager.rotate(decoration.angle, 0.0F, 0.0F, 1.0F);
+ GlStateManager.translate(x, y, -0.02F);
+ GlStateManager.rotate(angle, 0.0F, 0.0F, 1.0F);
GlStateManager.scale(4.0F, 4.0F, 3.0F);
GlStateManager.translate(-0.125F, 0.125F, 0.0F);
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
- worldrenderer.pos(-1.0D, 1.0D, 10+((float)k * -0.001F)).tex(decoration.minU, decoration.minV).endVertex();
- worldrenderer.pos(1.0D, 1.0D, 10+((float)k * -0.001F)).tex(decoration.minU+1/4f, decoration.minV).endVertex();
- worldrenderer.pos(1.0D, -1.0D, 10+((float)k * -0.001F)).tex(decoration.minU+1/4f, decoration.minV+1/4f).endVertex();
- worldrenderer.pos(-1.0D, -1.0D, 10+((float)k * -0.001F)).tex(decoration.minU, decoration.minV+1/4f).endVertex();
+ worldrenderer.pos(-1.0D, 1.0D, 10+((float)k * -0.001F)).tex(minU, minV).endVertex();
+ worldrenderer.pos(1.0D, 1.0D, 10+((float)k * -0.001F)).tex(minU+1/4f, minV).endVertex();
+ worldrenderer.pos(1.0D, -1.0D, 10+((float)k * -0.001F)).tex(minU+1/4f, minV+1/4f).endVertex();
+ worldrenderer.pos(-1.0D, -1.0D, 10+((float)k * -0.001F)).tex(minU, minV+1/4f).endVertex();
tessellator.draw();
GlStateManager.popMatrix();
k--;
}
+
+ GlStateManager.rotate(rotation-180, 0, 0, 1);
+ GlStateManager.translate(-centerX, -centerY, 0);
+ GlStateManager.popMatrix();
}
- private HashMap<RoomOffset, Room> roomMap = new HashMap<>();
- private Color[][] colourMap = new Color[128][128];
- private int startRoomX = -1;
- private int startRoomY = -1;
- private int connectorSize = 5;
- private int roomSize = 0;
public void updateRoomConnections(RoomOffset roomOffset) {
if(roomMap.containsKey(roomOffset)) {
@@ -273,7 +386,7 @@ public class DungeonMap {
int x = startRoomX + roomOffset.x*(roomSize+connectorSize) + xOff;
int y = startRoomY + roomOffset.y*(roomSize+connectorSize) + yOff;
- if(x < colourMap.length && y < colourMap[x].length) {
+ if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
Color c = colourMap[x][y];
if(!c.equals(room.colour)) {
if(otherPixelColour == c.getRGB()) {
@@ -317,7 +430,7 @@ public class DungeonMap {
y += i;
}
- if(x < colourMap.length && y < colourMap[x].length) {
+ if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
if(colourMap[x][y].equals(room.colour)) {
totalFilled++;
}
@@ -343,6 +456,7 @@ public class DungeonMap {
}
}
+ room.fillCorner = false;
if(room.left.type == RoomConnectionType.ROOM_DIVIDER && room.up.type == RoomConnectionType.ROOM_DIVIDER) {
RoomOffset upleft = new RoomOffset(roomOffset.x-1, roomOffset.y-1);
if(roomMap.containsKey(upleft)) {
@@ -365,8 +479,10 @@ public class DungeonMap {
int y = startRoomY + neighbor.y*(roomSize+connectorSize);
if(x > 0 && y > 0 && x+roomSize < colourMap.length && y+roomSize < colourMap[x].length) {
- roomMap.put(neighbor, new Room());
- loadNeighbors(neighbor);
+ if(colourMap[x][y].getAlpha() > 100) {
+ roomMap.put(neighbor, new Room());
+ loadNeighbors(neighbor);
+ }
}
}
}
@@ -383,48 +499,77 @@ public class DungeonMap {
}
}
- private Set<MapDecoration> decorations = new HashSet<>();
class MapDecoration {
- float roomInPercentX;
- float connInPercentX;
- float roomsOffsetX;
- float connOffsetX;
- float roomInPercentY;
- float connInPercentY;
- float roomsOffsetY;
- float connOffsetY;
-
- float minU;
- float minV;
-
+ MapPosition position;
+ int id;
float angle;
- public MapDecoration(float roomInPercentX, float connInPercentX, float roomsOffsetX, float connOffsetX,
- float roomInPercentY, float connInPercentY, float roomsOffsetY, float connOffsetY, float minU, float minV, float angle) {
- this.roomInPercentX = roomInPercentX;
- this.connInPercentX = connInPercentX;
- this.roomsOffsetX = roomsOffsetX;
+ public MapDecoration(MapPosition position, int id, float angle) {
+ this.position = position;
+ this.id = id;
+ this.angle = angle;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ MapDecoration that = (MapDecoration) o;
+ return id == that.id &&
+ Float.compare(that.angle, angle) == 0 &&
+ Objects.equals(position, that.position);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(position, id, angle);
+ }
+ }
+
+ private class MapPosition {
+ public float roomOffsetX;
+ public float connOffsetX;
+
+ public float roomOffsetY;
+ public float connOffsetY;
+
+ public MapPosition(float roomOffsetX, float connOffsetX, float roomOffsetY, float connOffsetY) {
+ this.roomOffsetX = roomOffsetX;
this.connOffsetX = connOffsetX;
- this.roomInPercentY = roomInPercentY;
- this.connInPercentY = connInPercentY;
- this.roomsOffsetY = roomsOffsetY;
+ this.roomOffsetY = roomOffsetY;
this.connOffsetY = connOffsetY;
- this.minU = minU;
- this.minV = minV;
- this.angle = angle;
+ }
+
+ public float getRenderX() {
+ return roomOffsetX*RENDER_ROOM_SIZE + connOffsetX*RENDER_CONN_SIZE;
+ }
+
+ public float getRenderY() {
+ return roomOffsetY*RENDER_ROOM_SIZE + connOffsetY*RENDER_CONN_SIZE;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ MapPosition that = (MapPosition) o;
+ return Float.compare(that.roomOffsetX, roomOffsetX) == 0 &&
+ Float.compare(that.connOffsetX, connOffsetX) == 0 &&
+ Float.compare(that.roomOffsetY, roomOffsetY) == 0 &&
+ Float.compare(that.connOffsetY, connOffsetY) == 0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(roomOffsetX, connOffsetX, roomOffsetY, connOffsetY);
}
}
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent event) {
- //System.out.println("render overlayw");
if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
ItemStack stack = Minecraft.getMinecraft().thePlayer.inventory.mainInventory[8];
- if(NotEnoughUpdates.INSTANCE.colourMap != null || stack != null && stack.getItem() instanceof ItemMap) {
- if(mapTextureData == null) {
- mapTextureData = dynamicTexture.getTextureData();
- }
-
+ if(NotEnoughUpdates.INSTANCE.colourMap != null || (stack != null && stack.getItem() instanceof ItemMap)) {
if(NotEnoughUpdates.INSTANCE.colourMap != null) {
colourMap = NotEnoughUpdates.INSTANCE.colourMap;
} else {
@@ -452,6 +597,12 @@ public class DungeonMap {
//mapData.
}
+ roomMap.clear();
+ startRoomX = -1;
+ startRoomY = -1;
+ connectorSize = 5;
+ roomSize = 0;
+
for(int x=0; x<colourMap.length; x++) {
for(int y=0; y<colourMap[x].length; y++) {
Color c = colourMap[x][y];
@@ -503,7 +654,7 @@ public class DungeonMap {
y = startRoomY+i;
}
- if(x < colourMap.length && y < colourMap[x].length) {
+ if(x > 0 && y > 0 && x < colourMap.length && y < colourMap[x].length) {
if(colourMap[x][y].getAlpha() > 80) {
if(j == 1) {
break;
@@ -515,6 +666,92 @@ public class DungeonMap {
}
}
+ List<Integer> dists = new ArrayList<>();
+ int currentBlockCount = 0;
+ for(int i=0; i<300; i++) {
+ IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(0, 99, i));
+ if(state == null || state.getBlock() == Blocks.air) {
+ if(currentBlockCount > 0) dists.add(currentBlockCount);
+ currentBlockCount = 0;
+ } else {
+ currentBlockCount++;
+ }
+ }
+ //roomSizeBlocks = 7;
+ currentBlockCount = 0;
+ for(int i=0; i<300; i++) {
+ IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(new BlockPos(i, 99, 0));
+ if(state == null || state.getBlock() == Blocks.air) {
+ if(currentBlockCount > 0) dists.add(currentBlockCount);
+ currentBlockCount = 0;
+ } else {
+ currentBlockCount++;
+ }
+ }
+ int count = 0;
+ int mostCommonDist = -1;
+ for(int dist : dists) {
+ if(dist == mostCommonDist) {
+ count++;
+ } else {
+ if(--count < 0) {
+ count = 1;
+ mostCommonDist = dist;
+ }
+ }
+ }
+ if(mostCommonDist != -1) roomSizeBlocks = Math.max(31, mostCommonDist);
+ if(Keyboard.isKeyDown(Keyboard.KEY_N)) System.out.println(roomSizeBlocks + ":" + dists.size());
+
+ Set<String> actualPlayers = new HashSet<>();
+ for(ScorePlayerTeam team : Minecraft.getMinecraft().thePlayer.getWorldScoreboard().getTeams()) {
+ if(team.getTeamName().startsWith("a")) {
+ for(String player : team.getMembershipCollection()) {
+ actualPlayers.add(player.toLowerCase());
+ }
+ }
+ }
+
+ playerMapPositions.clear();
+ for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) {
+ if(actualPlayers.isEmpty() || actualPlayers.contains(player.getName().toLowerCase())) {
+ float roomX = (float)player.posX / (roomSizeBlocks+1);
+ float roomY = (float)player.posZ / (roomSizeBlocks+1);
+
+ float playerRoomOffsetX = (float) Math.floor(roomX);
+ float playerConnOffsetX = (float) Math.floor(roomX);
+ float playerRoomOffsetY = (float) Math.floor(roomY);
+ float playerConnOffsetY = (float) Math.floor(roomY);
+
+ float roomXInBlocks = (float)player.posX % (roomSizeBlocks+1);
+ if(roomXInBlocks < 2) { //0,1
+ playerConnOffsetX -= roomXInBlocks/5f;
+ } else if(roomXInBlocks > roomSizeBlocks-3) { //31,30,29
+ playerRoomOffsetX++;
+ playerConnOffsetX += (roomXInBlocks - (roomSizeBlocks-3))/5f;
+ } else {
+ playerRoomOffsetX += (roomXInBlocks-2) / (roomSizeBlocks-5);
+ }
+
+ float roomYInBlocks = (float)player.posZ % (roomSizeBlocks+1);
+ if(roomYInBlocks < 2) { //0,1
+ playerConnOffsetY -= roomYInBlocks/5f;
+ } else if(roomYInBlocks > roomSizeBlocks-3) { //31,30,29
+ playerRoomOffsetY++;
+ playerConnOffsetY += (roomYInBlocks - (roomSizeBlocks-3))/5f;
+ } else {
+ playerRoomOffsetY += (roomYInBlocks-2) / (roomSizeBlocks-5);
+ }
+
+ playerRoomOffsetX -= startRoomX/(roomSize+connectorSize);
+ playerRoomOffsetY -= startRoomY/(roomSize+connectorSize);
+ playerConnOffsetX -= startRoomX/(roomSize+connectorSize);
+ playerConnOffsetY -= startRoomY/(roomSize+connectorSize);
+
+ playerMapPositions.put(player, new MapPosition(playerRoomOffsetX, playerConnOffsetX, playerRoomOffsetY, playerConnOffsetY));
+ }
+ }
+
loadNeighbors(new RoomOffset(0, 0));
updateRoomColours();
for(RoomOffset offset : roomMap.keySet()) {
@@ -526,85 +763,97 @@ public class DungeonMap {
MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld);
if(mapData.mapDecorations.size() > 0) {
- decorations.clear();
- }
- for (Vec4b vec4b : mapData.mapDecorations.values()) {
- byte b0 = vec4b.func_176110_a();
-
- float x = (float)vec4b.func_176112_b() / 2.0F + 64.0F;
- float y = (float)vec4b.func_176113_c() / 2.0F + 64.0F;
- float minU = (float)(b0 % 4 + 0) / 4.0F;
- float minV = (float)(b0 / 4 + 0) / 4.0F;
-
- float deltaX = x - startRoomX;
- float deltaY = y - startRoomY;
-
- float roomInPercentX = 0;
- float connInPercentX = 0;
- float roomsOffsetX = (int)Math.floor(deltaX / (roomSize+connectorSize));
- float connOffsetX = (int)Math.floor(deltaX / (roomSize+connectorSize));
- float xRemainder = deltaX % (roomSize+connectorSize);
- if(xRemainder > roomSize) {
- roomsOffsetX++;
- connInPercentX = (xRemainder-roomSize)/connectorSize;
- } else {
- roomInPercentX = xRemainder/roomSize;
- }
- float roomInPercentY = 0;
- float connInPercentY = 0;
- float roomsOffsetY = (int)Math.floor(deltaY / (roomSize+connectorSize));
- float connOffsetY = (int)Math.floor(deltaY / (roomSize+connectorSize));
- float yRemainder = deltaY % (roomSize+connectorSize);
- if(yRemainder > roomSize) {
- roomsOffsetY++;
- connInPercentY = (yRemainder-roomSize)/connectorSize;
- } else {
- roomInPercentY = yRemainder/roomSize;
- }
+ boolean different = mapData.mapDecorations.size() != decorations.size();
- float angle = (float)(vec4b.func_176111_d() * 360) / 16.0F;
+ List<MapDecoration> decorationsNew = new ArrayList<>();
- //System.out.println((float)(vec4b.func_176111_d() * 360) / 16.0F);
- decorations.add(new MapDecoration(roomInPercentX, connInPercentX, roomsOffsetX, connOffsetX, roomInPercentY, connInPercentY,
- roomsOffsetY, connOffsetY, minU, minV, angle));
- }
+ for (Vec4b vec4b : mapData.mapDecorations.values()) {
+ byte b0 = vec4b.func_176110_a();
- }
+ float x = (float)vec4b.func_176112_b() / 2.0F + 64.0F;
+ float y = (float)vec4b.func_176113_c() / 2.0F + 64.0F;
+ float deltaX = x - startRoomX;
+ float deltaY = y - startRoomY;
- //System.out.println("room x: " + startRoomX + "room y: " + startRoomY + " size: " + roomSize + " connector: " + connectorSize);
+ float roomsOffsetX = (int)Math.floor(deltaX / (roomSize+connectorSize));
+ float connOffsetX = (int)Math.floor(deltaX / (roomSize+connectorSize));
+ float xRemainder = deltaX % (roomSize+connectorSize);
+ if(Math.abs(xRemainder) > roomSize) {
+ roomsOffsetX++;
+ connOffsetX += (xRemainder-roomSize)/connectorSize;
+ } else {
+ roomsOffsetX += xRemainder/roomSize;
+ }
+ if(deltaX < 0) {
+ roomsOffsetX++;
+ connOffsetX++;
+ }
+ float roomsOffsetY = (int)Math.floor(deltaY / (roomSize+connectorSize));
+ float connOffsetY = (int)Math.floor(deltaY / (roomSize+connectorSize));
+ float yRemainder = deltaY % (roomSize+connectorSize);
+ if(Math.abs(yRemainder) > roomSize) {
+ roomsOffsetY++;
+ connOffsetY += Math.abs(yRemainder-roomSize)/connectorSize;
+ } else {
+ roomsOffsetY += yRemainder/roomSize;
+ }
+ if(deltaY < 0) {
+ roomsOffsetY++;
+ connOffsetY++;
+ }
- //rendering
- for (int i = 0; i < 16384; ++i) {
- mapTextureData[i] = 0;
- }
+ float angle = (float)(vec4b.func_176111_d() * 360) / 16.0F;
- if(!roomMap.isEmpty()) {
- int minRoomX = 999;
- int minRoomY = 999;
- int maxRoomX = -999;
- int maxRoomY = -999;
- for(RoomOffset offset : roomMap.keySet()) {
- minRoomX = Math.min(offset.x, minRoomX);
- minRoomY = Math.min(offset.y, minRoomY);
- maxRoomX = Math.max(offset.x, maxRoomX);
- maxRoomY = Math.max(offset.y, maxRoomY);
- }
+ MapDecoration decoration = new MapDecoration(new MapPosition(roomsOffsetX, connOffsetX, roomsOffsetY, connOffsetY), (int)b0, angle);
+ if(!different && !decorations.contains(decoration)) {
+ different = true;
+ }
+ decorationsNew.add(decoration);
+ }
- for(RoomOffset offset : roomMap.keySet()) {
- //render(offset, mapTextureData, minRoomX, minRoomY);
- }
+ if(different) {
+ lastDecorations.clear();
- render();
+ for(int i=0; i<decorations.size() && i<decorationsNew.size(); i++) {
+ MapDecoration match = decorationsNew.get(i);
+
+ float lowestDistSq = 999;
+ MapDecoration closest = null;
+
+ for(int j=0; j<decorations.size(); j++) {
+ MapDecoration old = decorations.get(j);
+
+ if(old.id != match.id) continue;
+
+ float xOff = (old.position.roomOffsetX*RENDER_ROOM_SIZE+old.position.connOffsetX*RENDER_CONN_SIZE) -
+ (match.position.roomOffsetX*RENDER_ROOM_SIZE+match.position.connOffsetX*RENDER_CONN_SIZE);
+ float yOff = (old.position.roomOffsetY*RENDER_ROOM_SIZE+old.position.connOffsetY*RENDER_CONN_SIZE) -
+ (match.position.roomOffsetY*RENDER_ROOM_SIZE+match.position.connOffsetY*RENDER_CONN_SIZE);
+ float distSq = xOff*xOff + yOff*yOff;
+ if(distSq < lowestDistSq) {
+ lowestDistSq = distSq;
+ closest = old;
+ }
+ }
+
+ if(closest != null) {
+ lastDecorations.add(closest);
+ }
+ }
- //process
+ decorations.clear();
+ decorations.addAll(decorationsNew);
+
+ lastLastDecorationsMillis = lastDecorationsMillis;
+ lastDecorationsMillis = System.currentTimeMillis();
+ }
+ }
- dynamicTexture.updateDynamicTexture();
- Minecraft.getMinecraft().getTextureManager().loadTexture(dynamicRL, dynamicTexture);
+ }
- GlStateManager.color(1, 1, 1, 1);
- Minecraft.getMinecraft().getTextureManager().bindTexture(dynamicRL);
- Utils.drawTexturedRect(0, 0, 128, 128, GL11.GL_NEAREST);
+ if(!roomMap.isEmpty()) {
+ render();
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java
index 6e25e7fd..c450c6f4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java
@@ -231,7 +231,7 @@ public class GuiEnchantColour extends GuiScreen {
}
if(mouseX >= guiLeft+42 && mouseX <= guiLeft+42+88) {
if(mouseY >= guiTop+ySize-30 && mouseY <= guiTop+ySize-10) {
- NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add("[a-zA-Z ]+:>:5:9");
+ NotEnoughUpdates.INSTANCE.manager.config.enchantColours.value.add("[a-zA-Z\\- ]+:>:5:9");
NotEnoughUpdates.INSTANCE.manager.saveConfig();
}
}
@@ -243,7 +243,7 @@ public class GuiEnchantColour extends GuiScreen {
} else {
switch(index) {
case 0:
- return "[a-zA-Z ]+";
+ return "[a-zA-Z\\- ]+";
case 1:
return ">";
case 2:
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java
index c9ca87fd..05fb792a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java
@@ -25,6 +25,8 @@ public class GuiTextures {
public static final ResourceLocation item_haschild = new ResourceLocation("notenoughupdates:item_haschild.png");
public static final ResourceLocation button_tex = new ResourceLocation("notenoughupdates:button.png");
+ public static final ResourceLocation setting_border = new ResourceLocation("notenoughupdates:setting_border.png");
+
public static final ResourceLocation button_white = new ResourceLocation("notenoughupdates:button_white.png");
public static final ResourceLocation colour_selector_dot = new ResourceLocation("notenoughupdates:colour_selector_dot.png");
public static final ResourceLocation colour_selector_bar = new ResourceLocation("notenoughupdates:colour_selector_bar.png");
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
index ed5be01a..29a25d56 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java
@@ -1,5 +1,7 @@
package io.github.moulberry.notenoughupdates;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.auction.APIManager;
import io.github.moulberry.notenoughupdates.auction.CustomAHGui;
@@ -8,6 +10,7 @@ import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
import io.github.moulberry.notenoughupdates.questing.SBInfo;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
@@ -35,6 +38,8 @@ import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.text.WordUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -537,7 +542,7 @@ public class NEUEventListener {
}
if(focusInv) {
try {
- neu.overlay.render(event.getMouseX(), event.getMouseY(), hoverInv && focusInv);
+ neu.overlay.render(hoverInv && focusInv);
} catch(ConcurrentModificationException e) {e.printStackTrace();}
GL11.glTranslatef(0, 0, 10);
}
@@ -545,7 +550,9 @@ public class NEUEventListener {
if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) {
renderDungeonChestOverlay(event.gui);
- AccessoryBagOverlay.renderOverlay();
+ if(neu.manager.config.accessoryBagOverlay.value) {
+ AccessoryBagOverlay.renderOverlay();
+ }
}
}
@@ -568,9 +575,9 @@ public class NEUEventListener {
} else {
TradeWindow.render(event.mouseX, event.mouseY);
}
- neu.overlay.render(event.mouseX, event.mouseY, false);
+ neu.overlay.render(false);
} else {
- neu.overlay.render(event.mouseX, event.mouseY, false);
+ neu.overlay.render(false);
if(event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView()) {
neu.manager.auctionManager.customAH.drawScreen(event.mouseX, event.mouseY);
} else {
@@ -605,10 +612,10 @@ public class NEUEventListener {
if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) {
if(!focusInv) {
GL11.glTranslatef(0, 0, 300);
- neu.overlay.render(event.mouseX, event.mouseY, hoverInv && focusInv);
+ neu.overlay.render(hoverInv && focusInv);
GL11.glTranslatef(0, 0, -300);
}
- neu.overlay.renderOverlay(event.mouseX, event.mouseY);
+ neu.overlay.renderOverlay();
}
}
}
@@ -783,7 +790,7 @@ public class NEUEventListener {
return;
}
if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) {
- if(AccessoryBagOverlay.mouseClick()) {
+ if(neu.manager.config.accessoryBagOverlay.value && AccessoryBagOverlay.mouseClick()) {
event.setCanceled(true);
} else {
if(!(hoverInv && focusInv)) {
@@ -945,15 +952,124 @@ public class NEUEventListener {
}*/
}
+ private static String[] rarityArrC = new String[] {
+ EnumChatFormatting.WHITE+EnumChatFormatting.BOLD.toString()+"COMMON",
+ EnumChatFormatting.GREEN+EnumChatFormatting.BOLD.toString()+"UNCOMMON",
+ EnumChatFormatting.BLUE+EnumChatFormatting.BOLD.toString()+"RARE",
+ EnumChatFormatting.DARK_PURPLE+EnumChatFormatting.BOLD.toString()+"EPIC",
+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD.toString()+"LEGENDARY",
+ EnumChatFormatting.LIGHT_PURPLE+EnumChatFormatting.BOLD.toString()+"MYTHIC",
+ EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"SPECIAL",
+ EnumChatFormatting.RED+EnumChatFormatting.BOLD.toString()+"VERY SPECIAL",
+ EnumChatFormatting.DARK_RED+EnumChatFormatting.BOLD.toString()+"SUPREME",
+ };
@SubscribeEvent(priority = EventPriority.LOW)
public void onItemTooltipLow(ItemTooltipEvent event) {
if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return;
+ boolean hasEnchantments = event.itemStack.hasTagCompound() && event.itemStack.getTagCompound().hasKey("ExtraAttributes", 10) &&
+ event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").hasKey("enchantments", 10);
+ Set<String> enchantIds = new HashSet<>();
+ if(hasEnchantments) enchantIds = event.itemStack.getTagCompound().getCompoundTag("ExtraAttributes").getCompoundTag("enchantments").getKeySet();
+
+ JsonObject enchantsConst = Constants.ENCHANTS;
+ JsonArray allItemEnchs = null;
+ Set<String> ignoreFromPool = new HashSet<>();
+ if(enchantsConst != null && hasEnchantments && NotEnoughUpdates.INSTANCE.manager.config.missingEnchantList.value) {
+ try {
+ JsonArray enchantPools = enchantsConst.get("enchant_pools").getAsJsonArray();
+ for(JsonElement element : enchantPools) {
+ Set<String> currentPool = new HashSet<>();
+ for(JsonElement poolElement : element.getAsJsonArray()) {
+ String poolS = poolElement.getAsString();
+ currentPool.add(poolS);
+ }
+ for(JsonElement poolElement : element.getAsJsonArray()) {
+ String poolS = poolElement.getAsString();
+ if(enchantIds.contains(poolS)) {
+ ignoreFromPool.addAll(currentPool);
+ break;
+ }
+ }
+ }
+
+ JsonObject enchantsObj = enchantsConst.get("enchants").getAsJsonObject();
+ NBTTagCompound tag = event.itemStack.getTagCompound();
+ if(tag != null) {
+ NBTTagCompound display = tag.getCompoundTag("display");
+ if (display.hasKey("Lore", 9)) {
+ NBTTagList list = display.getTagList("Lore", 8);
+ out:
+ for (int i = list.tagCount(); i >= 0; i--) {
+ String line = list.getStringTagAt(i);
+ for(int j=0; j<rarityArrC.length; j++) {
+ for(Map.Entry<String, JsonElement> entry : enchantsObj.entrySet()) {
+ if(line.contains(rarityArrC[j] + " " + entry.getKey()) || line.contains(rarityArrC[j] + " DUNGEON " + entry.getKey())) {
+ allItemEnchs = entry.getValue().getAsJsonArray();
+ break out;
+ }
+ }
+ }
+ }
+ }
+ }
+ } catch(Exception e) {}
+ }
+
+ boolean gotToEnchants = false;
+ boolean passedEnchants = false;
+
boolean dungeonProfit = false;
int index = 0;
List<String> newTooltip = new ArrayList<>();
for(String line : event.toolTip) {
- if(event.itemStack.isItemEnchanted()) {
+ if(line.contains("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune")) {
+ line = line.replace("\u00A7cR\u00A76a\u00A7ei\u00A7an\u00A7bb\u00A79o\u00A7dw\u00A79 Rune",
+ Utils.chromaString("Rainbow Rune", index, false)+EnumChatFormatting.BLUE);
+ } else if(hasEnchantments) {
+ if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && NotEnoughUpdates.INSTANCE.manager.config.missingEnchantList.value) {
+ boolean lineHasEnch = false;
+ for(String s : enchantIds) {
+ String enchantName = WordUtils.capitalizeFully(s.replace("_", " "));
+ if(line.contains(enchantName)) {
+ lineHasEnch = true;
+ break;
+ }
+ }
+ if(lineHasEnch) {
+ gotToEnchants = true;
+ } else {
+ if(gotToEnchants && !passedEnchants && Utils.cleanColour(line).trim().length() == 0) {
+ if(enchantsConst != null && allItemEnchs != null) {
+ List<String> missing = new ArrayList<>();
+ for(JsonElement enchIdElement : allItemEnchs) {
+ String enchId = enchIdElement.getAsString();
+ if(!enchId.startsWith("ultimate_") && !ignoreFromPool.contains(enchId) && !enchantIds.contains(enchId)) {
+ missing.add(enchId);
+ }
+ }
+ newTooltip.add("");
+ StringBuilder currentLine = new StringBuilder(EnumChatFormatting.RED+"Missing: "+EnumChatFormatting.GRAY);
+ for(int i=0; i<missing.size(); i++) {
+ String enchName = WordUtils.capitalizeFully(missing.get(i).replace("_", " "));
+ if(currentLine.length() != 0 && (Utils.cleanColour(currentLine.toString()).length() + enchName.length()) > 40) {
+ newTooltip.add(currentLine.toString());
+ currentLine = new StringBuilder();
+ }
+ if(currentLine.length() != 0 && i != 0) {
+ currentLine.append(", ").append(enchName);
+ } else {
+ currentLine.append(EnumChatFormatting.GRAY).append(enchName);
+ }
+ }
+ if(currentLine.length() != 0) {
+ newTooltip.add(currentLine.toString());
+ }
+ }
+ passedEnchants = true;
+ }
+ }
+ }
for(String op : neu.manager.config.enchantColours.value) {
List<String> colourOps = GuiEnchantColour.splitter.splitToList(op);
String enchantName = GuiEnchantColour.getColourOpIndex(colourOps, 0);
@@ -966,8 +1082,6 @@ public class NEUEventListener {
if(comparison.length() == 0) continue;
if(colourCode.length() == 0) continue;
- if(enchantName.contains("(") || enchantName.contains(")")) continue;
-
int comparatorI = ">=<".indexOf(comparator.charAt(0));
int levelToFind = -1;
@@ -982,16 +1096,17 @@ public class NEUEventListener {
//9([a-zA-Z ]+?) ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$)
Pattern pattern;
try {
- String prefix = "\u00A79";
- if(enchantName.startsWith("ULT_")) prefix = "\u00A7l\u00A7d";
- pattern = Pattern.compile(prefix+"("+enchantName+") ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$)");
+ pattern = Pattern.compile("(\\u00A79|\\u00A79\\u00A7d\\u00A7l)("+enchantName+") " +
+ "([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV|XVI|XVII|XVIII|XIX|XX))(,|$)");
} catch(Exception e) {continue;} //malformed regex
Matcher matcher = pattern.matcher(line);
int matchCount = 0;
while(matcher.find() && matchCount < 5) {
+ if(Utils.cleanColour(matcher.group(2)).startsWith(" ")) continue;
+
matchCount++;
int level = -1;
- String levelStr = matcher.group(2);
+ String levelStr = matcher.group(matcher.groupCount()-2);
if(levelStr == null) continue;
try {
level = Integer.parseInt(levelStr);
@@ -1017,6 +1132,26 @@ public class NEUEventListener {
level = 9; break;
case "X":
level = 10; break;
+ case "XI":
+ level = 11; break;
+ case "XII":
+ level = 12; break;
+ case "XIII":
+ level = 13; break;
+ case "XIV":
+ level = 14; break;
+ case "XV":
+ level = 15; break;
+ case "XVI":
+ level = 16; break;
+ case "XVII":
+ level = 17; break;
+ case "XVIII":
+ level = 18; break;
+ case "XIX":
+ level = 19; break;
+ case "XX":
+ level = 20; break;
}
}
boolean matches = false;
@@ -1032,9 +1167,18 @@ public class NEUEventListener {
}
if(matches) {
if(!colourCode.equals("z")) {
- line = line.replaceAll("\\u00A79"+matcher.group(1), "\u00A7"+colourCode+matcher.group(1));
+ line = line.replace("\u00A79"+matcher.group(2), "\u00A7"+colourCode+matcher.group(2));
+ line = line.replace("\u00A79\u00A7d\u00A7l"+matcher.group(2), "\u00A7"+colourCode+
+ EnumChatFormatting.BOLD+matcher.group(2));
} else {
- line = line.replaceAll("\\u00A79"+matcher.group(1), Utils.chromaString(matcher.group(1)));
+ int offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll(
+ "\\u00A79"+matcher.group(2)+".*", ""));
+ line = line.replace("\u00A79"+matcher.group(2), Utils.chromaString(matcher.group(2), offset/12f+index, false));
+
+ offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll(
+ "\\u00A79\\u00A7d\\u00A7l"+matcher.group(2)+".*", ""));
+ line = line.replace("\u00A79\u00A7d\u00A7l"+matcher.group(2), Utils.chromaString(matcher.group(2),
+ offset/12f+index, true));
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
index c78885c3..9c90532a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java
@@ -5,6 +5,7 @@ import com.google.gson.*;
import io.github.moulberry.notenoughupdates.auction.APIManager;
import io.github.moulberry.notenoughupdates.cosmetics.CapeManager;
import io.github.moulberry.notenoughupdates.options.Options;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.HypixelApi;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -1286,7 +1287,7 @@ public class NEUManager {
public HashMap<String, String> getLoreReplacements(String petname, String tier, int level) {
JsonObject petnums = null;
if(petname != null && tier != null) {
- petnums = Utils.getConstant("petnums");
+ petnums = Constants.PETNUMS;
}
HashMap<String, String> replacements = new HashMap<>();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
index 450653da..f0d46f7f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java
@@ -135,8 +135,6 @@ public class NEUOverlay extends Gui {
private static final int SORT_MODE_ARMOR = 4;
private static final int SORT_MODE_ACCESSORY = 5;
- private ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
-
private boolean disabled = false;
private int lastScreenWidth;
@@ -431,8 +429,8 @@ public class NEUOverlay extends Gui {
Utils.drawTexturedRect(x, y,
bigItemSize + paddingUnscaled*2, bigItemSize + paddingUnscaled*2, GL11.GL_NEAREST);
- int mouseX = Mouse.getX() * scaledresolution.getScaledWidth() / Minecraft.getMinecraft().displayWidth;
- int mouseY = scaledresolution.getScaledHeight() - Mouse.getY() * scaledresolution.getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1;
+ int mouseX = Mouse.getX() * Utils.peekGuiScale().getScaledWidth() / Minecraft.getMinecraft().displayWidth;
+ int mouseY = Utils.peekGuiScale().getScaledHeight() - Mouse.getY() * Utils.peekGuiScale().getScaledHeight() / Minecraft.getMinecraft().displayHeight - 1;
if(mouseX > x && mouseX < x+bigItemSize) {
if(mouseY > y && mouseY < y+bigItemSize) {
@@ -489,7 +487,7 @@ public class NEUOverlay extends Gui {
map.put(createSearchBarGroup(), searchBarAnchor);
map.put(createQuickCommandGroup(), quickCommandAnchor);
- return new MBGuiGroupFloating(scaledresolution.getScaledWidth(), scaledresolution.getScaledHeight(), map);
+ return new MBGuiGroupFloating(Utils.peekGuiScale().getScaledWidth(), Utils.peekGuiScale().getScaledHeight(), map);
}
public void resetAnchors(boolean onlyIfNull) {
@@ -594,11 +592,12 @@ public class NEUOverlay extends Gui {
return false;
}
- int width = scaledresolution.getScaledWidth();
- int height = scaledresolution.getScaledHeight();
+ Utils.pushGuiScale(manager.config.paneGuiScale.value.intValue());
- int mouseX = Mouse.getX() / scaledresolution.getScaleFactor();
- int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor();
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
//if(lastMouseX != mouseX || lastMouseY != mouseY) {
// millisLastMouseMove = System.currentTimeMillis();
@@ -635,6 +634,7 @@ public class NEUOverlay extends Gui {
searchMode = true;
}
}
+ Utils.pushGuiScale(-1);
return true;
}
}
@@ -643,7 +643,10 @@ public class NEUOverlay extends Gui {
//Item selection (right) gui
if(mouseX > width*getItemPaneOffsetFactor()) {
- if(!Mouse.getEventButtonState()) return true; //End early if the mouse isn't pressed, but still cancel event.
+ if(!Mouse.getEventButtonState()) {
+ Utils.pushGuiScale(-1);
+ return true; //End early if the mouse isn't pressed, but still cancel event.
+ }
AtomicBoolean clickedItem = new AtomicBoolean(false);
iterateItemSlots(new ItemSlotConsumer() {
@@ -676,7 +679,7 @@ public class NEUOverlay extends Gui {
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
int maxPages = getMaxPages();
- String name = scaledresolution.getScaleFactor()<4?"Page: ":"";
+ String name = Utils.peekGuiScale().getScaleFactor()<4?"Page: ":"";
float maxStrLen = fr.getStringWidth(EnumChatFormatting.BOLD+name + maxPages + "/" + maxPages);
float maxButtonXSize = (rightSide-leftSide+2 - maxStrLen*0.5f - 10)/2f;
int buttonXSize = (int)Math.min(maxButtonXSize, getSearchBarYSize()*480/160f);
@@ -731,32 +734,60 @@ public class NEUOverlay extends Gui {
}
}
}
+ Utils.pushGuiScale(-1);
return true;
}
//Clicking on "close info pane" button
- if(mouseX > width*getInfoPaneOffsetFactor()-getBoxPadding()-8 && mouseX < width*getInfoPaneOffsetFactor()-getBoxPadding()+8) {
- if(mouseY > getBoxPadding()-8 && mouseY < getBoxPadding()+8) {
- if(Mouse.getEventButtonState() && Mouse.getEventButton() < 2) { //Left or right click up
- displayInformationPane(null);
- return true;
+ if(activeInfoPane instanceof SettingsInfoPane) {
+ Utils.pushGuiScale(2);
+
+ int widthN = Utils.peekGuiScale().getScaledWidth();
+ int heightN = Utils.peekGuiScale().getScaledHeight();
+ int mouseXN = Mouse.getX() * widthN / Minecraft.getMinecraft().displayWidth;
+ int mouseYN = heightN - Mouse.getY() * heightN / Minecraft.getMinecraft().displayHeight - 1;
+
+ if(mouseXN > widthN*getInfoPaneOffsetFactor()-getBoxPadding()-8 && mouseXN < widthN*getInfoPaneOffsetFactor()-getBoxPadding()+8) {
+ if(mouseYN > getBoxPadding()-8 && mouseYN < getBoxPadding()+8) {
+ if(Mouse.getEventButtonState() && Mouse.getEventButton() < 2) { //Left or right click up
+ displayInformationPane(null);
+
+ Utils.pushGuiScale(-1);
+ Utils.pushGuiScale(-1);
+ return true;
+ }
+ }
+ }
+
+ Utils.pushGuiScale(-1);
+ } else {
+ if(mouseX > width*getInfoPaneOffsetFactor()-getBoxPadding()-8 && mouseX < width*getInfoPaneOffsetFactor()-getBoxPadding()+8) {
+ if(mouseY > getBoxPadding()-8 && mouseY < getBoxPadding()+8) {
+ if(Mouse.getEventButtonState() && Mouse.getEventButton() < 2) { //Left or right click up
+ displayInformationPane(null);
+ Utils.pushGuiScale(-1);
+ return true;
+ }
}
}
}
+
if(activeInfoPane != null) {
if(mouseX < width*getInfoPaneOffsetFactor()) {
activeInfoPane.mouseInput(width, height, mouseX, mouseY, mouseDown);
+ Utils.pushGuiScale(-1);
return true;
} else if(Mouse.getEventButton() <= 1 && Mouse.getEventButtonState()) { //Left or right click
activeInfoPane.mouseInputOutside();
}
}
+ Utils.pushGuiScale(-1);
return false;
}
public int getPaddingUnscaled() {
- int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor();
+ int paddingUnscaled = searchBarPadding/Utils.peekGuiScale().getScaleFactor();
if(paddingUnscaled < 1) paddingUnscaled = 1;
return paddingUnscaled;
@@ -766,7 +797,7 @@ public class NEUOverlay extends Gui {
* Returns searchBarXSize, scaled by 0.8 if gui scale == AUTO.
*/
public int getSearchBarXSize() {
- if(scaledresolution.getScaleFactor()==4) return (int)(searchBarXSize*0.8);
+ if(Utils.peekGuiScale().getScaleFactor()==4) return (int)(searchBarXSize*0.8);
return (int)(searchBarXSize);
}
@@ -791,8 +822,8 @@ public class NEUOverlay extends Gui {
* Finds the index of the character inside the search bar that was clicked, used to set the caret.
*/
public int getClickedIndex(int mouseX, int mouseY) {
- int width = scaledresolution.getScaledWidth();
- int height = scaledresolution.getScaledHeight();
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
int xComp = mouseX - (width/2 - getSearchBarXSize()/2 + 5);
@@ -833,7 +864,7 @@ public class NEUOverlay extends Gui {
}
if(Keyboard.isKeyDown(Keyboard.KEY_Y) && manager.config.dev.value) {
- displayInformationPane(new DevInfoPane(this, manager));
+ //displayInformationPane(new DevInfoPane(this, manager));
//displayInformationPane(new QOLInfoPane(this, manager));
}
@@ -876,10 +907,12 @@ public class NEUOverlay extends Gui {
itemstack.set(hover);
}
} else if(!hoverInv) {
- int height = scaledresolution.getScaledHeight();
+ Utils.pushGuiScale(manager.config.paneGuiScale.value.intValue());
- int mouseX = Mouse.getX() / scaledresolution.getScaleFactor();
- int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor();
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
iterateItemSlots(new ItemSlotConsumer() {
public void consume(int x, int y, int id) {
@@ -891,6 +924,8 @@ public class NEUOverlay extends Gui {
}
}
});
+
+ Utils.pushGuiScale(-1);
}
if(internalname.get() != null) {
if(itemstack.get() != null) {
@@ -1191,13 +1226,13 @@ public class NEUOverlay extends Gui {
}
public int getItemBoxXPadding() {
- int width = scaledresolution.getScaledWidth();
+ int width = Utils.peekGuiScale().getScaledWidth();
return (((int)(width/3*getWidthMult())-2*getBoxPadding())%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2;
}
public int getBoxPadding() {
double panePadding = Math.max(0, Math.min(20, manager.config.panePadding.value));
- return (int)(panePadding*2/scaledresolution.getScaleFactor()+5);
+ return (int)(panePadding*2/Utils.peekGuiScale().getScaleFactor()+5);
}
private abstract class ItemSlotConsumer {
@@ -1205,7 +1240,7 @@ public class NEUOverlay extends Gui {
}
public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer) {
- int width = scaledresolution.getScaledWidth();
+ int width = Utils.peekGuiScale().getScaledWidth();
int itemBoxXPadding = getItemBoxXPadding();
iterateItemSlots(itemSlotConsumer, (int)(width*getItemPaneOffsetFactor())+getBoxPadding()+itemBoxXPadding);
}
@@ -1216,8 +1251,8 @@ public class NEUOverlay extends Gui {
* code duplication issues.
*/
public void iterateItemSlots(ItemSlotConsumer itemSlotConsumer, int xStart) {
- int width = scaledresolution.getScaledWidth();
- int height = scaledresolution.getScaledHeight();
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
int paneWidth = (int)(width/3*getWidthMult());
int itemBoxYPadding = ((height-getSearchBarYSize()-2*getBoxPadding()-ITEM_SIZE-2)%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2;
@@ -1238,7 +1273,7 @@ public class NEUOverlay extends Gui {
public float getWidthMult() {
float scaleFMult = 1;
- if(scaledresolution.getScaleFactor()==4) scaleFMult *= 0.9f;
+ if(Utils.peekGuiScale().getScaleFactor()==4) scaleFMult *= 0.9f;
if(manager.auctionManager.customAH.isRenderOverAuctionView()) scaleFMult *= 0.8f;
return (float)Math.max(0.5, Math.min(1.5, manager.config.paneWidthMult.value.floatValue()))*scaleFMult;
}
@@ -1247,7 +1282,7 @@ public class NEUOverlay extends Gui {
* Calculates the number of horizontal item slots.
*/
public int getSlotsXSize() {
- int width = scaledresolution.getScaledWidth();
+ int width = Utils.peekGuiScale().getScaledWidth();
int paneWidth = (int)(width/3*getWidthMult());
int itemBoxXPadding = (((int)(width-width*getItemPaneOffsetFactor())-2*getBoxPadding())%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2;
@@ -1261,7 +1296,7 @@ public class NEUOverlay extends Gui {
* Calculates the number of vertical item slots.
*/
public int getSlotsYSize() {
- int height = scaledresolution.getScaledHeight();
+ int height = Utils.peekGuiScale().getScaledHeight();
int itemBoxYPadding = ((height-getSearchBarYSize()-2*getBoxPadding()-ITEM_SIZE-2)%(ITEM_SIZE+ITEM_PADDING)+ITEM_PADDING)/2;
int yStart = getBoxPadding()+getSearchBarYSize()+itemBoxYPadding;
@@ -1276,7 +1311,7 @@ public class NEUOverlay extends Gui {
}
public int getSearchBarYSize() {
- return Math.max(searchBarYSize/scaledresolution.getScaleFactor(), ITEM_SIZE);
+ return Math.max(searchBarYSize/Utils.peekGuiScale().getScaleFactor(), ITEM_SIZE);
}
/**
@@ -1299,10 +1334,11 @@ public class NEUOverlay extends Gui {
int rightPressed = 0;
if(Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
- int height = scaledresolution.getScaledHeight();
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
- int mouseX = Mouse.getX() / scaledresolution.getScaleFactor();
- int mouseY = height - Mouse.getY() / scaledresolution.getScaleFactor();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
if(mouseY >= top && mouseY <= top+ySize) {
int leftPrev = leftSide-1;
@@ -1442,7 +1478,12 @@ public class NEUOverlay extends Gui {
* Renders black squares over the inventory to indicate items that do not match a specific search. (When searchMode
* is enabled)
*/
- public void renderOverlay(int mouseX, int mouseY) {
+ public void renderOverlay() {
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
if(searchMode && textField.getText().length() > 0) {
if(Minecraft.getMinecraft().currentScreen instanceof GuiContainer) {
GuiContainer inv = (GuiContainer) Minecraft.getMinecraft().currentScreen;
@@ -1571,7 +1612,6 @@ public class NEUOverlay extends Gui {
public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) {
if(manager.config.bgBlurFactor.value <= 0 || !OpenGlHelper.isFramebufferEnabled()) return;
- int f = scaledresolution.getScaleFactor();
float uMin = x/(float)width;
float uMax = (x+blurWidth)/(float)width;
float vMin = y/(float)height;
@@ -1586,11 +1626,11 @@ public class NEUOverlay extends Gui {
}
public void updateGuiGroupSize() {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledresolution.getScaledWidth();
- int height = scaledresolution.getScaledHeight();
+ Utils.pushGuiScale(manager.config.paneGuiScale.value.intValue());
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
- if(lastScreenWidth != width || lastScreenHeight != height || scaledresolution.getScaleFactor() != lastScale) {
+ if(lastScreenWidth != width || lastScreenHeight != height || Utils.peekGuiScale().getScaleFactor() != lastScale) {
guiGroup.width = width;
guiGroup.height = height;
@@ -1599,8 +1639,10 @@ public class NEUOverlay extends Gui {
lastScreenWidth = width;
lastScreenHeight = height;
- lastScale = scaledresolution.getScaleFactor();
+ lastScale = Utils.peekGuiScale().getScaleFactor();
}
+
+ Utils.pushGuiScale(-1);
}
int guiScaleLast = 0;
@@ -1609,16 +1651,20 @@ public class NEUOverlay extends Gui {
/**
* Renders the search bar, quick commands, item selection (right) and item info (left) gui elements.
*/
- public void render(int mouseX, int mouseY, boolean hoverInv) {
+ public void render(boolean hoverInv) {
if(disabled) {
return;
}
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
- int width = scaledresolution.getScaledWidth();
- int height = scaledresolution.getScaledHeight();
-
+ Utils.resetGuiScale();
+ Utils.pushGuiScale(manager.config.paneGuiScale.value.intValue());
+
+ int width = Utils.peekGuiScale().getScaledWidth();
+ int height = Utils.peekGuiScale().getScaledHeight();
+ int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
+ int mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
+
if(showVanillaLast != manager.config.showVanillaItems.value) {
showVanillaLast = manager.config.showVanillaItems.value;
updateSearch();
@@ -1633,8 +1679,8 @@ public class NEUOverlay extends Gui {
updateGuiGroupSize();
- if(guiScaleLast != scaledresolution.getScaleFactor()) {
- guiScaleLast = scaledresolution.getScaleFactor();
+ if(guiScaleLast != Utils.peekGuiScale().getScaleFactor()) {
+ guiScaleLast = Utils.peekGuiScale().getScaleFactor();
redrawItems = true;
}
@@ -1722,7 +1768,7 @@ public class NEUOverlay extends Gui {
leftSide+paneWidth-getBoxPadding()+5, height-getBoxPadding()+5, bg.getRGB());
renderNavElement(leftSide+getBoxPadding()+getItemBoxXPadding(), rightSide, getMaxPages(), page+1,
- scaledresolution.getScaleFactor()<4?"Page: ":"");
+ Utils.peekGuiScale().getScaleFactor()<4?"Page: ":"");
//Sort bar
drawRect(leftSide+getBoxPadding()+getItemBoxXPadding()-1,
@@ -1915,11 +1961,21 @@ public class NEUOverlay extends Gui {
if(activeInfoPane != null) {
activeInfoPane.tick();
- activeInfoPane.render(width, height, bg, fg, scaledresolution, mouseX, mouseY);
+ activeInfoPane.render(width, height, bg, fg, Utils.peekGuiScale(), mouseX, mouseY);
GlStateManager.color(1f, 1f, 1f, 1f);
Minecraft.getMinecraft().getTextureManager().bindTexture(close);
- Utils.drawTexturedRect(rightSide-getBoxPadding()-8, getBoxPadding()-8, 16, 16);
+ if(activeInfoPane instanceof SettingsInfoPane) {
+ Utils.pushGuiScale(2);
+
+ int widthN = Utils.peekGuiScale().getScaledWidth();
+ int rightSideN = (int)(widthN*getInfoPaneOffsetFactor());
+ Utils.drawTexturedRect(rightSideN-getBoxPadding()-8, getBoxPadding()-8, 16, 16);
+
+ Utils.pushGuiScale(-1);
+ } else {
+ Utils.drawTexturedRect(rightSide-getBoxPadding()-8, getBoxPadding()-8, 16, 16);
+ }
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
}
@@ -2027,6 +2083,8 @@ public class NEUOverlay extends Gui {
GlStateManager.enableAlpha();
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.disableLighting();
+
+ Utils.pushGuiScale(-1);
}
/**
@@ -2052,8 +2110,8 @@ public class NEUOverlay extends Gui {
* itemPane should be redrawn.
*/
private void checkFramebufferSizes(int width, int height) {
- int sw = width*scaledresolution.getScaleFactor();
- int sh = height*scaledresolution.getScaleFactor();
+ int sw = width*Utils.peekGuiScale().getScaleFactor();
+ int sh = height*Utils.peekGuiScale().getScaleFactor();
for(int i=0; i<itemFramebuffers.length; i++) {
if(itemFramebuffers[i] == null || itemFramebuffers[i].framebufferWidth != sw || itemFramebuffers[i].framebufferHeight != sh) {
if(itemFramebuffers[i] == null) {
@@ -2084,8 +2142,8 @@ public class NEUOverlay extends Gui {
*/
private void renderItemsToImage(int width, int height, Color fgFavourite2,
Color fgFavourite, Color fgCustomOpacity, boolean items, boolean entities) {
- int sw = width*scaledresolution.getScaleFactor();
- int sh = height*scaledresolution.getScaleFactor();
+ int sw = width*Utils.peekGuiScale().getScaleFactor();
+ int sh = height*Utils.peekGuiScale().getScaleFactor();
GL11.glPushMatrix();
prepareFramebuffer(itemFramebuffers[0], sw, sh);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
index 77855b3e..fe31ce01 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java
@@ -14,6 +14,7 @@ import io.github.moulberry.notenoughupdates.cosmetics.GuiCosmetics;
import io.github.moulberry.notenoughupdates.gamemodes.GuiGamemodes;
import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes;
import io.github.moulberry.notenoughupdates.infopanes.CollectionLogInfoPane;
+import io.github.moulberry.notenoughupdates.infopanes.SettingsInfoPane;
import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer;
import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats;
import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer;
@@ -80,6 +81,8 @@ import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
@Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true)
public class NotEnoughUpdates {
@@ -97,7 +100,7 @@ public class NotEnoughUpdates {
private String currChatMessage = null;
//Stolen from Biscut and used for detecting whether in skyblock
- private static final Set<String> SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK","\u7A7A\u5C9B\u751F\u5B58");
+ private static final Set<String> SKYBLOCK_IN_ALL_LANGUAGES = Sets.newHashSet("SKYBLOCK","\u7A7A\u5C9B\u751F\u5B58", "\u7A7A\u5CF6\u751F\u5B58");
private GuiScreen openGui = null;
@@ -757,6 +760,24 @@ public class NotEnoughUpdates {
}
});
+ SimpleCommand settingsCommand = new SimpleCommand("neusettings", new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ overlay.displayInformationPane(new SettingsInfoPane(overlay, manager));
+ if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ openGui = new GuiInventory(Minecraft.getMinecraft().thePlayer);
+ }
+ }
+ });
+
+ SimpleCommand settingsCommand2 = new SimpleCommand("neuconfig", new SimpleCommand.ProcessCommandRunnable() {
+ public void processCommand(ICommandSender sender, String[] args) {
+ overlay.displayInformationPane(new SettingsInfoPane(overlay, manager));
+ if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) {
+ openGui = new GuiInventory(Minecraft.getMinecraft().thePlayer);
+ }
+ }
+ });
+
SimpleCommand neuAhCommand = new SimpleCommand("neuah", new SimpleCommand.ProcessCommandRunnable() {
public void processCommand(ICommandSender sender, String[] args) {
if(!hasSkyblockScoreboard()) {
@@ -770,6 +791,8 @@ public class NotEnoughUpdates {
manager.auctionManager.customAH.lastOpen = System.currentTimeMillis();
manager.auctionManager.customAH.clearSearch();
manager.auctionManager.customAH.updateSearch();
+
+ if(args.length > 0) manager.auctionManager.customAH.setSearch(StringUtils.join(args, " "));
}
}
});
@@ -815,6 +838,8 @@ public class NotEnoughUpdates {
ClientCommandHandler.instance.registerCommand(neuAhCommand);
ClientCommandHandler.instance.registerCommand(pcStatsCommand);
ClientCommandHandler.instance.registerCommand(neumapCommand);
+ ClientCommandHandler.instance.registerCommand(settingsCommand);
+ ClientCommandHandler.instance.registerCommand(settingsCommand2);
manager = new NEUManager(this, f);
manager.loadItemInformation();
@@ -961,9 +986,30 @@ public class NotEnoughUpdates {
//Stolen from Biscut's SkyblockAddons
public void updateSkyblockScoreboard() {
+ final Pattern SERVER_BRAND_PATTERN = Pattern.compile("(.+) <- (?:.+)");
+ final String HYPIXEL_SERVER_BRAND = "BungeeCord (Hypixel)";
+
Minecraft mc = Minecraft.getMinecraft();
- if (mc != null && mc.theWorld != null) {
+ if (mc != null && mc.theWorld != null && mc.thePlayer != null) {
+ if (!mc.isSingleplayer() && mc.thePlayer.getClientBrand() != null) {
+ Matcher matcher = SERVER_BRAND_PATTERN.matcher(mc.thePlayer.getClientBrand());
+
+ if (matcher.find()) {
+ // Group 1 is the server brand.
+ if(!matcher.group(1).equals(HYPIXEL_SERVER_BRAND)) {
+ hasSkyblockScoreboard = false;
+ return;
+ }
+ } else {
+ hasSkyblockScoreboard = false;
+ return;
+ }
+ } else {
+ hasSkyblockScoreboard = false;
+ return;
+ }
+
Scoreboard scoreboard = mc.theWorld.getScoreboard();
ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1);
if (sidebarObjective != null) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
index b466d226..92d95e74 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java
@@ -4,6 +4,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.github.moulberry.notenoughupdates.NEUManager;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.event.ClickEvent;
@@ -183,8 +184,8 @@ public class APIManager {
updatePageTickShort();
ahNotification();
}
- if(currentTime - lastAuctionAvgUpdate > 120*60*1000) { //2 hours
- lastAuctionAvgUpdate = currentTime - 118*60*1000; //Try again in 2 minutes if updateAvgPrices doesn't succeed
+ if(currentTime - lastAuctionAvgUpdate > 30*60*1000) { //30 minutes
+ lastAuctionAvgUpdate = currentTime - 28*60*1000; //Try again in 2 minutes if updateAvgPrices doesn't succeed
updateAvgPrices();
}
if(currentTime - lastBazaarUpdate > 10*60*1000) {
@@ -312,7 +313,7 @@ public class APIManager {
if(firstHypixelApiUpdate == 0 || (System.currentTimeMillis() - firstHypixelApiUpdate)%(60*1000) > 15*1000) return;
- JsonObject disable = Utils.getConstant("disable");
+ JsonObject disable = Constants.DISABLE;
if(disable != null && disable.get("auctions").getAsBoolean()) return;
while(!pagesToDownload.isEmpty()) {
@@ -322,7 +323,7 @@ public class APIManager {
}
private void updatePageTick() {
- JsonObject disable = Utils.getConstant("disable");
+ JsonObject disable = Constants.DISABLE;
if(disable != null && disable.get("auctions").getAsBoolean()) return;
if(pagesToDownload == null) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
index 8f17037b..430584e4 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java
@@ -200,6 +200,11 @@ public class CustomAH extends Gui {
priceField.setText("");
}
+ public void setSearch(String search) {
+ searchField.setText(search);
+ updateSearch();
+ }
+
public void tick() {
if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || renderOverAuctionView) {
if(shouldUpdateSearch) updateSearch();
@@ -1401,7 +1406,11 @@ public class CustomAH extends Gui {
}
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
+ boolean wasFocused = searchField.isFocused();
searchField.mouseClicked(mouseX, mouseY, mouseButton);
+ if(mouseButton == 1 && !wasFocused && searchField.isFocused()) {
+ searchField.setText("");
+ }
priceField.mouseClicked(mouseX, mouseY, mouseButton);
int totalItems = auctionIds.size();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java
index e5fc10b2..4938770d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java
@@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.infopanes;
import io.github.moulberry.notenoughupdates.BetterContainers;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NEUOverlay;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.Utils;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
@@ -34,6 +35,11 @@ import static io.github.moulberry.notenoughupdates.GuiTextures.*;
public class SettingsInfoPane extends InfoPane {
+ private int currentCategory = Options.CAT_ALL;
+ private final String[] CATEGORY_NAMES = {"All", "Misc", "Features", "Sliders", "Colours"};
+
+ private GuiElementTextField searchBar = new GuiElementTextField("", 0);
+
private final Map<Options.Option<?>, GuiElementTextField> textConfigMap = new HashMap<>();
private int page = 0;
private int maxPages = 1;
@@ -80,15 +86,22 @@ public class SettingsInfoPane extends InfoPane {
hexField.otherComponentClick();
}
- public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX,
+ public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledResolution, int mouseX,
int mouseY) {
+ Utils.pushGuiScale(2);
+
+ int widthN = Utils.peekGuiScale().getScaledWidth();
+ int heightN = Utils.peekGuiScale().getScaledHeight();
+ int mouseXN = Mouse.getX() * widthN / Minecraft.getMinecraft().displayWidth;
+ int mouseYN = heightN - Mouse.getY() * heightN / Minecraft.getMinecraft().displayHeight - 1;
+
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
+ int paneWidth = (int)(widthN/3*overlay.getWidthMult());
+ int rightSide = (int)(widthN*overlay.getInfoPaneOffsetFactor());
int leftSide = rightSide - paneWidth;
- this.renderDefaultBackground(width, height, bg);
+ this.renderDefaultBackground(widthN, heightN, bg);
if(page > maxPages-1) page = maxPages-1;
if(page < 0) page = 0;
@@ -96,6 +109,29 @@ public class SettingsInfoPane extends InfoPane {
overlay.renderNavElement(leftSide+overlay.getBoxPadding(), rightSide-overlay.getBoxPadding(),
maxPages,page+1,"Settings: ");
+ int area = rightSide-leftSide-overlay.getBoxPadding()*2;
+ int categoryArea = (area-3*4)/5;
+ int ySize = overlay.getSearchBarYSize();
+ int yStartCat = overlay.getBoxPadding()+overlay.getSearchBarYSize()+3;
+ for(int i=0; i<5; i++) {
+ boolean pressed = currentCategory == i;
+ drawRect(leftSide+overlay.getBoxPadding()+i*(categoryArea+3), yStartCat,
+ leftSide+overlay.getBoxPadding()+i*(categoryArea+3)+categoryArea, yStartCat+ySize, fg.getRGB());
+ GlStateManager.color(1, 1, 1, 1);
+ Minecraft.getMinecraft().getTextureManager().bindTexture(rightarrow_overlay);
+ Utils.drawTexturedRect(leftSide+overlay.getBoxPadding()+i*(categoryArea+3),
+ yStartCat, categoryArea, ySize, pressed?0:1, pressed?1:0, pressed?0:1, pressed?1:0, GL11.GL_NEAREST);
+
+ Utils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.BOLD+CATEGORY_NAMES[i],
+ Minecraft.getMinecraft().fontRendererObj,
+ leftSide+overlay.getBoxPadding()+i*(categoryArea+3)+categoryArea/2f,
+ yStartCat+ySize/2f, false, categoryArea-6, 0);
+ }
+
+ searchBar.setSize(area-5, ySize);
+ searchBar.setMaxStringLength(45);
+ searchBar.render(leftSide+overlay.getBoxPadding()+1, overlay.getBoxPadding()+overlay.getSearchBarYSize()*2+7);
+
AtomicReference<List<String>> textToDisplay = new AtomicReference<>(null);
AtomicReference<GuiElementTextField> tfTop = new AtomicReference<>();
AtomicInteger tfTopX = new AtomicInteger();
@@ -104,14 +140,22 @@ public class SettingsInfoPane extends InfoPane {
public void consume(int x, int y, int tileWidth, int tileHeight, Options.Option<?> option, Options.Button button) {
float mult = tileWidth/90f;
- drawRect(x, y, x+tileWidth, y+tileHeight, fg.getRGB());
+ drawRect(x+2, y+2, x+tileWidth-2, y+tileHeight-2, fg.getRGB());
+
+ Minecraft.getMinecraft().getTextureManager().bindTexture(setting_border);
+ GlStateManager.color(1, 1, 1, 1);
+
+ Utils.drawTexturedRect(x, y, tileWidth, 5, 0, 1, 0, 5/75f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x, y+tileHeight-5, tileWidth, 5, 0, 1, 70/75f, 1, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x, y+5, tileWidth, tileHeight-10, 0, 1, 5/75f, 70/75f, GL11.GL_NEAREST);
+ Utils.drawTexturedRect(x+5, y, tileWidth-10, tileHeight, 5/100f, 95/100f, 0, 1, GL11.GL_NEAREST);
if(manager.config.hideApiKey.value && option==manager.config.apiKey) return;
if(option == null) {
Utils.renderStringTrimWidth(button.displayName, fr, true, x+(int)(8*mult), y+(int)(8*mult),
tileWidth-(int)(16*mult), new Color(100,255,150).getRGB(), 3,
- 2f/scaledresolution.getScaleFactor());
+ 2f/Utils.peekGuiScale().getScaleFactor());
GlStateManager.color(1f, 1f, 1f, 1f);
Minecraft.getMinecraft().getTextureManager().bindTexture(button_tex);
@@ -121,8 +165,8 @@ public class SettingsInfoPane extends InfoPane {
Utils.drawTexturedRect(x + tileWidth/2f + (int) (19 * mult), y + tileHeight - (int) (19 * mult), (int) (14 * mult), (int) (14 * mult));
GlStateManager.bindTexture(0);
- if (mouseX > x + tileWidth / 2 + (int) (19 * mult) && mouseX < x + tileWidth / 2 + (int) (19 * mult) + (int) (14 * mult)) {
- if (mouseY > y + tileHeight - (int) (19 * mult) && mouseY < y + tileHeight - (int) (19 * mult) + (int) (14 * mult)) {
+ if (mouseXN > x + tileWidth / 2 + (int) (19 * mult) && mouseXN < x + tileWidth / 2 + (int) (19 * mult) + (int) (14 * mult)) {
+ if (mouseYN > y + tileHeight - (int) (19 * mult) && mouseYN < y + tileHeight - (int) (19 * mult) + (int) (14 * mult)) {
List<String> textLines = new ArrayList<>();
textLines.add(button.displayName);
textLines.add(EnumChatFormatting.GRAY + button.desc);
@@ -134,7 +178,7 @@ public class SettingsInfoPane extends InfoPane {
Utils.renderStringTrimWidth(option.displayName, fr, true, x+(int)(8*mult), y+(int)(8*mult),
tileWidth-(int)(16*mult), new Color(100,255,150).getRGB(), 3,
- 2f/scaledresolution.getScaleFactor());
+ 2f/Utils.peekGuiScale().getScaleFactor());
if(option.value instanceof Boolean) {
GlStateManager.color(1f, 1f, 1f, 1f);
@@ -145,8 +189,8 @@ public class SettingsInfoPane extends InfoPane {
Utils.drawTexturedRect(x + tileWidth/2f + (int) (19 * mult), y + tileHeight - (int) (19 * mult), (int) (14 * mult), (int) (14 * mult));
GlStateManager.bindTexture(0);
- if (mouseX > x + tileWidth / 2 + (int) (19 * mult) && mouseX < x + tileWidth / 2 + (int) (19 * mult) + (int) (14 * mult)) {
- if (mouseY > y + tileHeight - (int) (19 * mult) && mouseY < y + tileHeight - (int) (19 * mult) + (int) (14 * mult)) {
+ if (mouseXN > x + tileWidth / 2 + (int) (19 * mult) && mouseXN < x + tileWidth / 2 + (int) (19 * mult) + (int) (14 * mult)) {
+ if (mouseYN > y + tileHeight - (int) (19 * mult) && mouseYN < y + tileHeight - (int) (19 * mult) + (int) (14 * mult)) {
List<String> textLines = new ArrayList<>();
textLines.add(option.displayName);
textLines.add(EnumChatFormatting.GRAY + option.desc);
@@ -193,7 +237,7 @@ public class SettingsInfoPane extends InfoPane {
if((option.flags & Options.FLAG_COLOUR) != 0) {
Utils.renderStringTrimWidth(option.displayName, fr, true, x+(int)(8*mult), y+(int)(8*mult),
tileWidth-(int)(16*mult), new Color(100,255,150).getRGB(), 3,
- 2f/scaledresolution.getScaleFactor());
+ 2f/Utils.peekGuiScale().getScaleFactor());
Color c = new Color(SpecialColour.specialToChromaRGB((String)option.value));
GlStateManager.color(
@@ -208,8 +252,8 @@ public class SettingsInfoPane extends InfoPane {
Utils.drawTexturedRect(x + tileWidth/2f + (int) (19 * mult), y + tileHeight - (int) (19 * mult), (int) (14 * mult), (int) (14 * mult));
GlStateManager.bindTexture(0);
- if (mouseX > x + tileWidth / 2 + (int) (19 * mult) && mouseX < x + tileWidth / 2 + (int) (19 * mult) + (int) (14 * mult)) {
- if (mouseY > y + tileHeight - (int) (19 * mult) && mouseY < y + tileHeight - (int) (19 * mult) + (int) (14 * mult)) {
+ if (mouseXN > x + tileWidth / 2 + (int) (19 * mult) && mouseXN < x + tileWidth / 2 + (int) (19 * mult) + (int) (14 * mult)) {
+ if (mouseYN > y + tileHeight - (int) (19 * mult) && mouseYN < y + tileHeight - (int) (19 * mult) + (int) (14 * mult)) {
List<String> textLines = new ArrayList<>();
textLines.add(option.displayName);
textLines.add(EnumChatFormatting.GRAY + option.desc);
@@ -369,8 +413,10 @@ public class SettingsInfoPane extends InfoPane {
}
if(textToDisplay.get() != null) {
- Utils.drawHoveringText(textToDisplay.get(), mouseX, mouseY, width, height, 200, fr);
+ Utils.drawHoveringText(textToDisplay.get(), mouseXN, mouseYN, widthN, heightN, 200, fr);
}
+
+ Utils.pushGuiScale(-1);
}
private void onTextfieldChange(GuiElementTextField tf, Options.Option<?> option) {
@@ -391,16 +437,56 @@ public class SettingsInfoPane extends InfoPane {
}
activeColourEditor = null;
hexField.otherComponentClick();
+ searchBar.otherComponentClick();
}
public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) {
+ Utils.pushGuiScale(2);
+
+ int widthN = Utils.peekGuiScale().getScaledWidth();
+ int heightN = Utils.peekGuiScale().getScaledHeight();
+ int mouseXN = Mouse.getX() * widthN / Minecraft.getMinecraft().displayWidth;
+ int mouseYN = heightN - Mouse.getY() * heightN / Minecraft.getMinecraft().displayHeight - 1;
+
+ int paneWidth = (int)(widthN/3*overlay.getWidthMult());
+ int rightSide = (int)(widthN*overlay.getInfoPaneOffsetFactor());
+ int leftSide = rightSide - paneWidth;
+
+ int area = rightSide-leftSide-overlay.getBoxPadding()*2;
+ int categoryArea = (area-3*4)/5;
+ int ySize = overlay.getSearchBarYSize();
+ int yStartCat = overlay.getBoxPadding()+overlay.getSearchBarYSize()+3;
+ for(int i=0; i<5; i++) {
+ if(mouseDown && mouseXN > leftSide + overlay.getBoxPadding() + i * (categoryArea + 3) &&
+ mouseXN < leftSide + overlay.getBoxPadding() + i * (categoryArea + 3) + categoryArea &&
+ mouseYN > yStartCat && mouseYN < yStartCat + ySize) {
+ currentCategory = i;
+ searchBar.otherComponentClick();
+ Utils.pushGuiScale(-1);
+ return;
+ }
+ }
+
+ if(mouseDown) {
+ if(mouseXN > leftSide+overlay.getBoxPadding() && mouseXN < leftSide+overlay.getBoxPadding()+area-3) {
+ if(mouseYN > overlay.getBoxPadding()+overlay.getSearchBarYSize()*2+7 &&
+ mouseYN < overlay.getBoxPadding()+overlay.getSearchBarYSize()*2+7+ySize) {
+ searchBar.mouseClicked(mouseXN, mouseYN, Mouse.getEventButton());
+ Utils.pushGuiScale(-1);
+ return;
+ }
+ }
+ searchBar.otherComponentClick();
+ }
+
if(activeColourEditor != null && (Mouse.isButtonDown(0) || Mouse.isButtonDown(1))) {
- if(mouseX >= activeColourEditor.x && mouseX <= activeColourEditor.x+119) {
- if(mouseY >= activeColourEditor.y && mouseY <= activeColourEditor.y+89) {
+ if(mouseXN >= activeColourEditor.x && mouseXN <= activeColourEditor.x+119) {
+ if(mouseYN >= activeColourEditor.y && mouseYN <= activeColourEditor.y+89) {
if(Mouse.getEventButtonState()) {
- if(mouseX > activeColourEditor.x+5+8 && mouseX < activeColourEditor.x+5+8+48) {
- if(mouseY > activeColourEditor.y+5+64+5 && mouseY < activeColourEditor.y+5+64+5+10) {
- hexField.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+ if(mouseXN > activeColourEditor.x+5+8 && mouseXN < activeColourEditor.x+5+8+48) {
+ if(mouseYN > activeColourEditor.y+5+64+5 && mouseYN < activeColourEditor.y+5+64+5+10) {
+ hexField.mouseClicked(mouseXN, mouseYN, Mouse.getEventButton());
+ Utils.pushGuiScale(-1);
return;
}
}
@@ -411,8 +497,8 @@ public class SettingsInfoPane extends InfoPane {
Color c = new Color(currentColour, true);
float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
- int xWheel = mouseX - activeColourEditor.x - 5;
- int yWheel = mouseY - activeColourEditor.y - 5;
+ int xWheel = mouseXN - activeColourEditor.x - 5;
+ int yWheel = mouseYN - activeColourEditor.y - 5;
if(xWheel > 0 && xWheel < 64) {
if(yWheel > 0 && yWheel < 64) {
@@ -426,8 +512,8 @@ public class SettingsInfoPane extends InfoPane {
}
}
- int xValue = mouseX - (activeColourEditor.x+5+64+5);
- int y = mouseY - activeColourEditor.y - 5;
+ int xValue = mouseXN - (activeColourEditor.x+5+64+5);
+ int y = mouseYN - activeColourEditor.y - 5;
if(y > -5 && y <= 69) {
y = Math.max(0, Math.min(64, y));
@@ -437,7 +523,7 @@ public class SettingsInfoPane extends InfoPane {
activeColourEditor.option.value = activeColourEditor.special;
}
- int xOpacity = mouseX - (activeColourEditor.x+5+64+5+10+5);
+ int xOpacity = mouseXN - (activeColourEditor.x+5+64+5+10+5);
if(xOpacity > 0 && xOpacity < 10) {
activeColourEditor.special = SpecialColour.special(SpecialColour.getSpeed(activeColourEditor.special),
@@ -448,7 +534,7 @@ public class SettingsInfoPane extends InfoPane {
int chromaSpeed = SpecialColour.getSpeed(activeColourEditor.special);
- int xChroma = mouseX - (activeColourEditor.x+5+64+5+10+5+10+5);
+ int xChroma = mouseXN - (activeColourEditor.x+5+64+5+10+5+10+5);
if(xChroma > 0 && xChroma < 10) {
if(chromaSpeed > 0) {
if(y > -5 && y <= 69) {
@@ -456,12 +542,13 @@ public class SettingsInfoPane extends InfoPane {
activeColourEditor.special = SpecialColour.special(255-Math.round(y/64f*255), c.getAlpha(), currentColour);
activeColourEditor.option.value = activeColourEditor.special;
}
- } else if(mouseY > activeColourEditor.y+5+27 && mouseY < activeColourEditor.y+5+37) {
+ } else if(mouseYN > activeColourEditor.y+5+27 && mouseYN < activeColourEditor.y+5+37) {
activeColourEditor.special = SpecialColour.special(200, c.getAlpha(), currentColour);
activeColourEditor.option.value = activeColourEditor.special;
}
}
+ Utils.pushGuiScale(-1);
return;
}
}
@@ -473,19 +560,21 @@ public class SettingsInfoPane extends InfoPane {
float mult = tileWidth/90f;
if(option == null) {
if(Mouse.getEventButtonState()) {
- if(mouseX > x+tileWidth/2-(int)(32*mult) && mouseX < x+tileWidth/2-(int)(32*mult)+(int)(48*mult)) {
- if(mouseY > y+tileHeight-(int)(20*mult) && mouseY < y+tileHeight-(int)(20*mult)+(int)(16*mult)) {
+ if(mouseXN > x+tileWidth/2-(int)(32*mult) && mouseXN < x+tileWidth/2-(int)(32*mult)+(int)(48*mult)) {
+ if(mouseYN > y+tileHeight-(int)(20*mult) && mouseYN < y+tileHeight-(int)(20*mult)+(int)(16*mult)) {
button.click.run();
+ Utils.pushGuiScale(-1);
return;
}
}
}
} else if(option.value instanceof Boolean) {
if(Mouse.getEventButtonState()) {
- if(mouseX > x+tileWidth/2-(int)(32*mult) && mouseX < x+tileWidth/2-(int)(32*mult)+(int)(48*mult)) {
- if(mouseY > y+tileHeight-(int)(20*mult) && mouseY < y+tileHeight-(int)(20*mult)+(int)(16*mult)) {
+ if(mouseXN > x+tileWidth/2-(int)(32*mult) && mouseXN < x+tileWidth/2-(int)(32*mult)+(int)(48*mult)) {
+ if(mouseYN > y+tileHeight-(int)(20*mult) && mouseYN < y+tileHeight-(int)(20*mult)+(int)(16*mult)) {
((Options.Option<Boolean>)option).value = !((Boolean)option.value);
overlay.redrawItems();
+ Utils.pushGuiScale(-1);
return;
}
}
@@ -501,17 +590,19 @@ public class SettingsInfoPane extends InfoPane {
int tfY = y+tileHeight-(int)(20*mult);
int tfWidth = tf.getWidth();
int tfHeight = tf.getHeight();
- if(mouseY > tfY && mouseY < tfY+tfHeight) {
- if(mouseX > tfX && mouseX < tfX+tfWidth) {
+ if(mouseYN > tfY && mouseYN < tfY+tfHeight) {
+ if(mouseXN > tfX && mouseXN < tfX+tfWidth) {
if(Mouse.getEventButtonState()) {
- tf.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+ tf.mouseClicked(mouseXN, mouseYN, Mouse.getEventButton());
onTextfieldChange(tf, option);
+ Utils.pushGuiScale(-1);
return;
} else if(Mouse.getEventButton() == -1 && mouseDown) {
- tf.mouseClickMove(mouseX, mouseY, 0, 0); //last 2 values are unused
+ tf.mouseClickMove(mouseXN, mouseYN, 0, 0); //last 2 values are unused
+ Utils.pushGuiScale(-1);
return;
}
- } else if(clickedSlider != option && Mouse.getEventButtonState() && mouseX > x+1*mult && mouseX < x+63*mult) {
+ } else if(clickedSlider != option && Mouse.getEventButtonState() && mouseXN > x+1*mult && mouseXN < x+63*mult) {
clickedSlider = option;
clickedSliderX = x;
clickedSliderMult = mult;
@@ -522,13 +613,13 @@ public class SettingsInfoPane extends InfoPane {
float xMin = clickedSliderX+5*clickedSliderMult;
float xMax = clickedSliderX+59*clickedSliderMult;
- float sliderAmount = (mouseX - xMin)/(xMax - xMin);
+ float sliderAmount = (mouseXN - xMin)/(xMax - xMin);
sliderAmount = Math.max(0, Math.min(1, sliderAmount));
double range = option.maxValue - option.minValue;
double value = option.minValue + sliderAmount*range;
- if(range >= 10) {
+ if(range >= 10 || (option.flags & Options.FLAG_INT) != 0) {
value = Math.round(value);
} else if(range >= 1) {
value = Math.round(value*10)/10.0;
@@ -550,11 +641,12 @@ public class SettingsInfoPane extends InfoPane {
} else {
if((option.flags & Options.FLAG_COLOUR) != 0) {
if(Mouse.getEventButtonState()) {
- if(mouseX > x+tileWidth/2-(int)(32*mult) && mouseX < x+tileWidth/2-(int)(32*mult)+(int)(48*mult)) {
- if(mouseY > y+tileHeight-(int)(20*mult) && mouseY < y+tileHeight-(int)(20*mult)+(int)(16*mult)) {
- int editorX = (int)Math.min(mouseX, width*overlay.getInfoPaneOffsetFactor()-129);
- int editorY = Math.min(mouseY, height-99);
+ if(mouseXN > x+tileWidth/2-(int)(32*mult) && mouseXN < x+tileWidth/2-(int)(32*mult)+(int)(48*mult)) {
+ if(mouseYN > y+tileHeight-(int)(20*mult) && mouseYN < y+tileHeight-(int)(20*mult)+(int)(16*mult)) {
+ int editorX = (int)Math.min(mouseXN, widthN*overlay.getInfoPaneOffsetFactor()-129);
+ int editorY = Math.min(mouseYN, heightN-99);
showColourEditor(editorX, editorY, (Options.Option<String>) option, (String)option.value);
+ Utils.pushGuiScale(-1);
return;
}
}
@@ -568,14 +660,16 @@ public class SettingsInfoPane extends InfoPane {
int tfY = y+tileHeight-(int)(20*mult);
int tfWidth = tf.getWidth();
int tfHeight = tf.getHeight();
- if(mouseX > tfX && mouseX < tfX+tfWidth) {
- if(mouseY > tfY && mouseY < tfY+tfHeight) {
+ if(mouseXN > tfX && mouseXN < tfX+tfWidth) {
+ if(mouseYN > tfY && mouseYN < tfY+tfHeight) {
if(Mouse.getEventButtonState()) {
- tf.mouseClicked(mouseX, mouseY, Mouse.getEventButton());
+ tf.mouseClicked(mouseXN, mouseYN, Mouse.getEventButton());
onTextfieldChange(tf, option);
+ Utils.pushGuiScale(-1);
return;
} else if(Mouse.getEventButton() == -1 && mouseDown) {
- tf.mouseClickMove(mouseX, mouseY, 0, 0); //last 2 values are unused
+ tf.mouseClickMove(mouseXN, mouseYN, 0, 0); //last 2 values are unused
+ Utils.pushGuiScale(-1);
return;
}
}
@@ -587,9 +681,6 @@ public class SettingsInfoPane extends InfoPane {
});
if(Mouse.getEventButtonState()) {
- int paneWidth = (int)(width/3*overlay.getWidthMult());
- int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
- int leftSide = rightSide - paneWidth;
rightSide -= overlay.getBoxPadding();
leftSide += overlay.getBoxPadding();
@@ -597,24 +688,31 @@ public class SettingsInfoPane extends InfoPane {
float maxStrLen = fr.getStringWidth(EnumChatFormatting.BOLD+"Settings: " + maxPages + "/" + maxPages);
float maxButtonXSize = (rightSide-leftSide+2 - maxStrLen*0.5f - 10)/2f;
int buttonXSize = (int)Math.min(maxButtonXSize, overlay.getSearchBarYSize()*480/160f);
- int ySize = (int)(buttonXSize/480f*160);
- int yOffset = (int)((overlay.getSearchBarYSize()-ySize)/2f);
+ int ySize2 = (int)(buttonXSize/480f*160);
+ int yOffset = (int)((overlay.getSearchBarYSize()-ySize2)/2f);
int top = overlay.getBoxPadding()+yOffset;
- if(mouseY >= top && mouseY <= top+ySize) {
+ if(mouseYN >= top && mouseYN <= top+ySize2) {
int leftPrev = leftSide-1;
- if(mouseX > leftPrev && mouseX < leftPrev+buttonXSize) { //"Previous" button
+ if(mouseXN > leftPrev && mouseXN < leftPrev+buttonXSize) { //"Previous" button
page--;
}
int leftNext = rightSide+1-buttonXSize;
- if(mouseX > leftNext && mouseX < leftNext+buttonXSize) { //"Next" button
+ if(mouseXN > leftNext && mouseXN < leftNext+buttonXSize) { //"Next" button
page++;
}
}
}
+
+ Utils.pushGuiScale(-1);
}
public boolean keyboardInput() {
+ if(searchBar.getFocus()) {
+ searchBar.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
+ return true;
+ }
+
AtomicBoolean ret = new AtomicBoolean(false);
iterateSettingTile(new SettingsTileConsumer() {
@Override
@@ -661,7 +759,7 @@ public class SettingsInfoPane extends InfoPane {
}
public void iterateSettingTile(SettingsTileConsumer settingsTileConsumer) {
- ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ ScaledResolution scaledresolution = Utils.pushGuiScale(2);
int width = scaledresolution.getScaledWidth();
int height = scaledresolution.getScaledHeight();
@@ -671,28 +769,64 @@ public class SettingsInfoPane extends InfoPane {
int rightSide = (int)(width*overlay.getInfoPaneOffsetFactor());
int leftSide = rightSide - paneWidth;
- int boxLeft = leftSide+overlay.getBoxPadding()-5;
- int boxRight = rightSide-overlay.getBoxPadding()+5;
+ int padding = overlay.getBoxPadding();
+
+ int boxLeft = leftSide+padding-5;
+ int boxRight = rightSide-padding+5;
- int boxBottom = height - overlay.getBoxPadding() + 5;
+ int boxBottom = height - padding + 5;
int boxWidth = boxRight-boxLeft;
int tilePadding = 7;
int tileWidth = (boxWidth-tilePadding*4)/numHorz;
int tileHeight = tileWidth*3/4;
+ int top = tilePadding+padding+overlay.getSearchBarYSize()*3+3*2;
+ int bottom = height - padding;
+ int leftover = (bottom-top)%(tileHeight+tilePadding);
+
+ top += leftover/2;
+
maxPages=1;
int currPage=0;
int x=0;
- int y=tilePadding+overlay.getBoxPadding()+overlay.getSearchBarYSize();
+ int y=top;
+ int tileCount = 0;
+ out:
for(int i=0; i<manager.config.getOptions().size()+manager.config.getButtons().size(); i++) {
- if(i!=0 && i%numHorz==0) {
+ if(i < manager.config.getButtons().size()) {
+ if(currentCategory != Options.CAT_ALL || searchBar.getText().trim().length() != 0) {
+ continue;
+ }
+ } else {
+ Options.Option<?> option = manager.config.getOptions().get(i-manager.config.getButtons().size());
+ if(searchBar.getText().trim().length() != 0) {
+ for(String s : searchBar.getText().split(" ")) {
+ s = s.replaceAll("[^A-Za-z]", "").toLowerCase();
+ boolean contains = false;
+ for(String tag : option.tags) {
+ if(tag.contains(s)) {
+ contains = true;
+ break;
+ }
+ }
+ if(!contains) {
+ continue out;
+ }
+ }
+ }
+ if(currentCategory != Options.CAT_ALL && currentCategory != option.category) {
+ continue;
+ }
+ }
+
+ if(tileCount != 0 && tileCount % numHorz == 0) {
x = 0;
y += tileHeight+tilePadding;
}
if(y + tileHeight > boxBottom) {
x=0;
- y=tilePadding+overlay.getBoxPadding()+overlay.getSearchBarYSize();
+ y=top;
currPage++;
maxPages = currPage+1;
}
@@ -708,7 +842,10 @@ public class SettingsInfoPane extends InfoPane {
}
}
+ tileCount++;
x+=tileWidth;
}
+
+ Utils.pushGuiScale(-1);
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
index 5a5bfb5c..7b279ac9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java
@@ -47,6 +47,10 @@ public class GuiElementTextField extends GuiElement {
this.options = options;
}
+ public void setMaxStringLength(int len) {
+ textField.setMaxStringLength(len);
+ }
+
public void setCustomBorderColour(int colour) {
this.customBorderColour = colour;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
index e8b635c1..ee8282e9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java
@@ -1,14 +1,19 @@
package io.github.moulberry.notenoughupdates.mixins;
import io.github.moulberry.notenoughupdates.BetterContainers;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.inventory.GuiChest;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -22,15 +27,72 @@ public abstract class MixinGuiContainer {
@Inject(method="drawSlot", at=@At("HEAD"), cancellable = true)
public void drawSlot(Slot slot, CallbackInfo ci) {
- if(slot != null && BetterContainers.isOverriding() && !BetterContainers.shouldRenderStack(slot.getStack())) {
+ if(slot == null) return;
+
+ GuiContainer $this = (GuiContainer)(Object)this;
+ ItemStack stack = slot.getStack();
+
+ if(stack == null && System.currentTimeMillis() - BetterContainers.lastRenderMillis < 300 && $this instanceof GuiChest) {
+ Container container = ((GuiChest)$this).inventorySlots;
+ if(container instanceof ContainerChest) {
+ IInventory lower = ((ContainerChest)container).getLowerChestInventory();
+ int size = lower.getSizeInventory();
+ if(slot.slotNumber < size) {
+ boolean found = false;
+ for(int index=0; index<size; index++) {
+ if(lower.getStackInSlot(index) != null) {
+ found = true;
+ break;
+ }
+ }
+ if(!found) {
+ stack = BetterContainers.itemCache.get(slot.slotNumber);
+ }
+ }
+
+ }
+ }
+
+ if(BetterContainers.isOverriding() && !BetterContainers.shouldRenderStack(stack)) {
ci.cancel();
}
}
+ private static final String TARGET_GETSTACK = "Lnet/minecraft/inventory/Slot;getStack()Lnet/minecraft/item/ItemStack;";
+ @Redirect(method="drawSlot", at=@At(value="INVOKE", target=TARGET_GETSTACK))
+ public ItemStack drawSlot_getStack(Slot slot) {
+ GuiContainer $this = (GuiContainer)(Object)this;
+ ItemStack stack = slot.getStack();
+
+ if($this instanceof GuiChest) {
+ Container container = ((GuiChest)$this).inventorySlots;
+ if(container instanceof ContainerChest) {
+ IInventory lower = ((ContainerChest)container).getLowerChestInventory();
+ int size = lower.getSizeInventory();
+ if(slot.slotNumber >= size) {
+ return stack;
+ }
+ if(System.currentTimeMillis() - BetterContainers.lastRenderMillis < 300 && stack == null) {
+ for(int index=0; index<size; index++) {
+ if(lower.getStackInSlot(index) != null) {
+ BetterContainers.itemCache.put(slot.slotNumber, null);
+ return null;
+ }
+ }
+ return BetterContainers.itemCache.get(slot.slotNumber);
+ } else {
+ BetterContainers.itemCache.put(slot.slotNumber, stack);
+ }
+ }
+ }
+ return stack;
+ }
+
private static final String TARGET_CANBEHOVERED = "Lnet/minecraft/inventory/Slot;canBeHovered()Z";
@Redirect(method="drawScreen", at=@At(value="INVOKE", target=TARGET_CANBEHOVERED))
public boolean drawScreen_canBeHovered(Slot slot) {
- if(BetterContainers.isBlankStack(slot.getStack())) {
+ if(NotEnoughUpdates.INSTANCE.manager.config.hideEmptyPanes.value &&
+ BetterContainers.isOverriding() && BetterContainers.isBlankStack(slot.getStack())) {
return false;
}
return slot.canBeHovered();
@@ -43,11 +105,11 @@ public abstract class MixinGuiContainer {
BetterContainers.clickSlot(slotIn.getSlotIndex());
Utils.playPressSound();
- /*if(!BetterContainers.isAh()) {
+ if(BetterContainers.isBlankStack(slotIn.getStack())) {
GuiContainer $this = (GuiContainer)(Object)this;
$this.mc.playerController.windowClick($this.inventorySlots.windowId, slotId, 2, clickType, $this.mc.thePlayer);
ci.cancel();
- }*/
+ }
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
index 55f81f53..62d12062 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java
@@ -30,249 +30,287 @@ public class Options {
*/
public static final transient int FLAG_COLOUR = 0b1;
+ public static final transient int FLAG_INT = 0b10;
+
+ public static final int CAT_ALL = 0;
+ public static final int CAT_MISC = 1;
+ public static final int CAT_FEATURES = 2;
+ public static final int CAT_SLIDERS = 3;
+ public static final int CAT_COLOURS = 4;
public Option<Boolean> enableItemEditing = new Option(
false,
"Enable Item Editing",
true,
- "Dev Feature.");
+ "Dev Feature.", CAT_ALL);
public Option<Boolean> onlyShowOnSkyblock = new Option(
true,
"Only Show On Skyblock",
false,
- "NEU Overlay only appears when you are playing Skyblock.");
+ "NEU Overlay only appears when you are playing Skyblock.", CAT_MISC);
public Option<Boolean> showVanillaItems = new Option(
true,
"Show Vanilla Items",
false,
- "Shows vanilla items in the itemlist.");
+ "Shows vanilla items in the itemlist.", CAT_MISC);
public Option<Boolean> hidePotionEffect = new Option(
true,
"Hide Potion Effects",
false,
- "Potion effects are hidden in the inventory GUI. Contrib: All the gamers that play on GUI AUTO");
+ "Potion effects are hidden in the inventory GUI. Contrib: All the gamers that play on GUI AUTO", CAT_MISC);
public Option<Boolean> showQuickCommands = new Option(
true,
"Quick Commands",
false,
- "Shows QuickCommands\u2122 above search bar.");
+ "Shows QuickCommands\u2122 above search bar.", CAT_FEATURES);
public Option<Boolean> showUpdateMsg = new Option(
true,
"Show Update Notifs",
false,
- "Shows update messages if NEU is out-of-date.");
+ "Shows update messages if NEU is out-of-date.", CAT_MISC);
public Option<Boolean> tooltipBorderColours = new Option(
true,
"Coloured Tooltip Borders",
false,
- "Makes the border of tooltips coloured. (Only NEU Tooltips)");
+ "Makes the border of tooltips coloured. (Only NEU Tooltips)", CAT_MISC);
public Option<Boolean> disableAhScroll = new Option(
false,
"No NeuAH Scroll",
false,
- "Disables Scrolling in NeuAH");
+ "Disables Scrolling in NeuAH", CAT_MISC);
public Option<Boolean> advancedPriceInfo = new Option(
false,
"Adv. Item Price Info",
false,
- "Shows some extra information about item prices.");
+ "Shows some extra information about item prices.", CAT_MISC);
public Option<Boolean> cacheRenderedItempane = new Option(
true,
"Cache Itempane",
false,
- "Caches the drawn itempane, drastically improving performance. Animated textures will not work.");
+ "Caches the drawn itempane, drastically improving performance. Animated textures will not work.", CAT_MISC);
public Option<Boolean> streamerMode = new Option(
false,
"Streamer Mode",
false,
- "Hides or randomises some stuff on your screen to prevent sniping.");
+ "Hides or randomises some stuff on your screen to prevent sniping", CAT_MISC);
public Option<Boolean> disableTreecapOverlay = new Option(
false,
"Disable Treecap Overlay",
false,
- "Disables the treecapitator overlay effect.");
+ "Disables the treecapitator overlay effect", CAT_FEATURES);
+ public Option<Boolean> disableWandOverlay = new Option(
+ false,
+ "Disable Builder's Wand Overlay",
+ false,
+ "Disables the builder's wand overlay effect", CAT_FEATURES);
+ public Option<Boolean> wandBlockCount = new Option(
+ true,
+ "Builder's Wand Block Count",
+ false,
+ "If true, will show how many blocks you have remaining when holding a builder's wand.", CAT_MISC);
public Option<Boolean> hideApiKey = new Option(
false,
"Hide Apikey Setting",
false,
- "Hides the Apikey setting (please try not to leak Apikey if you're recording)");
+ "Hides the Apikey setting (please try not to leak Apikey if you're recording)", CAT_MISC);
public Option<Double> bgBlurFactor = new Option(
5.0,
"Background Blur",
false,
- "Changes the strength of pane background blur. 0-50.", 0, 50);
+ "Changes the strength of pane background blur. 0-50.", 0, 50, CAT_SLIDERS);
public Option<String> apiKey = new Option(
"",
"Api Key",
false,
- "Type /api new to receive key and put it here.");
+ "Type /api new to receive key and put it here.", CAT_MISC);
public Option<Boolean> autoupdate = new Option(
true,
"Automatically Update Items",
false,
- "If true, updated items will automatically download from the remote repository when you start the game. \nHIGHLY RECOMMENDED.");
+ "If true, updated items will automatically download from the remote repository when you start the game. \nHIGHLY RECOMMENDED.", CAT_MISC);
public Option<Boolean> quickcommandMousePress = new Option(
false,
"QuickCommand on Mouse Press",
false,
- "If true, quickcommands will trigger on mouse down instead of mouse up.");
+ "If true, quickcommands will trigger on mouse down instead of mouse up.", CAT_MISC);
public Option<Boolean> disableItemTabOpen = new Option(
false,
"No Tab Open",
false,
- "If True, moving your mouse to the item tab on the right side won't open the itempane.");
+ "If True, moving your mouse to the item tab on the right side won't open the itempane.", CAT_MISC);
public Option<Boolean> keepopen = new Option(
false,
"Keep Itempane Open",
false,
- "If true, the itempane will stay open after the gui is closed.");
+ "If true, the itempane will stay open after the gui is closed.", CAT_MISC);
public Option<Boolean> itemStyle = new Option(
true,
"Circular Item Style",
false,
- "Uses the circular item background style instead of the square style. Contrib: Calyps0");
+ "Uses the circular item background style instead of the square style. Contrib: Calyps0", CAT_MISC);
public Option<Boolean> hideEmptyPanes = new Option(
true,
"Hide GUI Filler Tooltips",
false,
- "Hides the tooltip of glass panes in skyblock GUIs. Contrib: ThatGravyBoat");
+ "Hides the tooltip of glass panes in skyblock GUIs. Contrib: ThatGravyBoat", CAT_MISC);
public Option<Boolean> dungeonProfitLore = new Option(
false,
"Dungeon Profit in Lore",
false,
- "If true, will show the dungeon profit on the tooltip of the 'reward chest' instead of as a GUI.");
+ "If true, will show the dungeon profit on the tooltip of the 'reward chest' instead of as a GUI.", CAT_MISC);
public Option<Boolean> auctionPriceInfo = new Option(
true,
"Price Info in Auction Lore",
false,
- "If true, will show price information about an item inside the auction house item tooltip.");
+ "If true, will show price information about an item inside the auction house item tooltip.", CAT_MISC);
public Option<Boolean> useCustomTrade = new Option(
true,
"Custom Trade",
false,
- "If true, uses the custom trade window for skyblock trades.");
+ "If true, uses the custom trade window for skyblock trades.", CAT_FEATURES);
public Option<Boolean> invBazaarPrice = new Option(
false,
"Show Bazaar Price In Inventory",
false,
- "If true, shows the bazaar price for the item you hover in your inventory.");
+ "If true, shows the bazaar price for the item you hover in your inventory.", CAT_MISC);
public Option<Boolean> invAuctionPrice = new Option(
false,
"Show Auction Price In Inventory",
false,
- "If true, shows the auction price for the item you hover in your inventory.");
+ "If true, shows the auction price for the item you hover in your inventory.", CAT_MISC);
public Option<Boolean> dungeonBlocksEverywhere = new Option(
false,
"Show Dungeon Block Overlay Everywhere",
false,
- "If true, will show the overlay for cracked bricks, etc. even when not in dungeons.");
+ "If true, will show the overlay for cracked bricks, etc. even when not in dungeons.", CAT_MISC);
public Option<Boolean> disableDungeonBlocks = new Option(
false,
"Disables the dungeon blocks feature",
false,
- "If true, the dungeon block overlay will be disabled.");
+ "If true, the dungeon block overlay will be disabled.", CAT_FEATURES);
+ public Option<Boolean> missingEnchantList = new Option(
+ true,
+ "Missing Enchant List",
+ false,
+ "If true, will show enchants that are missing on an enchanted item when LSHIFT is pressed.", CAT_FEATURES);
+ public Option<Boolean> accessoryBagOverlay = new Option(
+ true,
+ "Accessory Bag Overlay",
+ false,
+ "If true, will an overlay with useful information in your accessory bag.", CAT_FEATURES);
+ public Option<Double> paneGuiScale = new Option(
+ 0.0,
+ "Pane GUI Scale",
+ false,
+ "Changes the GUI scale of the item pane. 0 = use game default. 1-4 = scale", FLAG_INT, 0, 4, CAT_SLIDERS);
public Option<Double> paneWidthMult = new Option(
1.0,
"Pane Width",
false,
- "Changes how wide the item and info panes are. Value between 0.5-1.5.", 0.5, 1.5);
+ "Changes how wide the item and info panes are. Value between 0.5-1.5.", 0.5, 1.5, CAT_SLIDERS);
public Option<Double> smoothAoteMillis = new Option(
175.0,
"Smooth AOTE Milliseconds",
false,
- "How long teleporting with the AOTE takes. 0 = disable.", 0, 300);
+ "How long teleporting with the AOTE takes. 0 = disable.", 0, 300, CAT_SLIDERS);
public Option<Double> itemHighlightOpacity = new Option(
178.0,
"Item Highlight Opacity",
false,
- "Changes the opacity of item highlights. Value between 0-255.", 0, 255);
+ "Changes the opacity of item highlights. Value between 0-255.", 0, 255, CAT_SLIDERS);
public Option<Double> panePadding = new Option(
10.0,
"Pane Padding",
false,
- "Changes the padding of the panes. Value between 0-20.", 0, 20);
+ "Changes the padding of the panes. Value between 0-20.", 0, 20, CAT_SLIDERS);
public Option<Double> ahNotification = new Option(
2.0,
"AH Notification (Mins, 0 = off)",
false,
- "Minutes before AH ends to notify. 0-10.", 0, 10);
+ "Minutes before AH ends to notify. 0-10.", 0, 10, CAT_SLIDERS);
public Option<Double> tooltipBorderOpacity = new Option(
200.0,
"Coloured Tooltip Border Opacity",
false,
- "Coloured tooltips only apply to tooltips in my GUIs. Value between 0-255.", 0, 255);
+ "Coloured tooltips only apply to tooltips in my GUIs. Value between 0-255.", 0, 255, CAT_SLIDERS);
public Option<Double> dynamicMenuBackgroundStyle = new Option(
1.0,
"SBMenu Background Style",
false,
- "Style of the background used for the skyblock menu.", 0, 10);
+ "Style of the background used for the skyblock menu.", 0, 10, CAT_FEATURES);
public Option<Double> dynamicMenuButtonStyle = new Option(
1.0,
"SBMenu Button Style",
false,
- "Style of the buttons used for the skyblock menu.", 0, 10);
+ "Style of the buttons used for the skyblock menu.", 0, 10, CAT_FEATURES);
public Option<String> itemBackgroundColour = new Option(
"00:255:100:100:100",
"Item BG Colour",
false,
- "Treecapitator Overlay Colour",
- FLAG_COLOUR);
+ "Item BG Colour",
+ FLAG_COLOUR, CAT_COLOURS);
public Option<String> itemFavouriteColour = new Option(
"00:255:200:150:50",
"Item BG Favourite Colour",
false,
"Item BG Favourite Colour",
- FLAG_COLOUR);
+ FLAG_COLOUR, CAT_COLOURS);
public Option<String> paneBackgroundColour = new Option(
"15:6:0:0:255",
"Pane Background Colour",
false,
"Pane Background Colour",
- FLAG_COLOUR);
+ FLAG_COLOUR, CAT_COLOURS);
public Option<String> treecapOverlayColour = new Option(
"00:50:64:224:208",
"Treecapitator Overlay Colour",
false,
"Treecapitator Overlay Colour",
- FLAG_COLOUR);
+ FLAG_COLOUR, CAT_COLOURS);
+ public Option<String> wandOverlayColour = new Option(
+ "00:50:64:224:208",
+ "Builder's Wand Overlay Colour",
+ false,
+ "Builder's Wand Overlay Colour",
+ FLAG_COLOUR, CAT_COLOURS);
public Option<String> dungCrackedColour = new Option(
"0:252:7:255:217",
"Dungeon Cracked Brick Colour",
false,
"Dungeon Cracked Brick Colour",
- FLAG_COLOUR);
+ FLAG_COLOUR, CAT_COLOURS);
public Option<String> dungDispenserColour = new Option(
"0:255:255:76:0",
"Dungeon Dispenser Colour",
false,
"Dungeon Dispenser Colour",
- FLAG_COLOUR);
+ FLAG_COLOUR, CAT_COLOURS);
public Option<String> dungLeverColour = new Option(
"0:252:24:249:255",
"Dungeon Lever Colour",
false,
"Dungeon Lever Colour",
- FLAG_COLOUR);
+ FLAG_COLOUR, CAT_COLOURS);
public Option<String> dungTripWireColour = new Option(
"0:255:255:0:0",
"Dungeon Trip Wire Colour",
false,
"Dungeon Trip Wire Colour",
- FLAG_COLOUR);
+ FLAG_COLOUR, CAT_COLOURS);
public Option<String> dungChestColour = new Option(
"0:255:0:163:36",
"Dungeon Chest Colour",
false,
"Dungeon Chest Colour",
- FLAG_COLOUR);
+ FLAG_COLOUR, CAT_COLOURS);
public Option<String> dungBatColour = new Option(
"0:255:12:255:0",
"Dungeon Bat Colour",
false,
"Dungeon Bat Colour",
- FLAG_COLOUR);
+ FLAG_COLOUR, CAT_COLOURS);
/**
* OPTIONS THAT DON'T SHOW IN GUI
@@ -281,78 +319,78 @@ public class Options {
false,
"Show Dev Options",
true,
- "Dev Feature. Please don't use.");
+ "Dev Feature. Please don't use.", CAT_ALL);
public Option<Boolean> loadedModBefore = new Option(
false,
"loadedModBefore",
true,
- "loadedModBefore");
+ "loadedModBefore", CAT_ALL);
public Option<Boolean> customTradePrices = new Option(
true,
"Trade Item Values",
true,
- "If true, shows a window with the total item value of either side");
+ "If true, shows a window with the total item value of either side", CAT_ALL);
public Option<Boolean> customTradePriceStyle = new Option(
true,
"Trade Prices Style",
true,
- "Changes the style of the top item prices");
+ "Changes the style of the top item prices", CAT_ALL);
public Option<String> selectedCape = new Option(
"",
"Selected Cape",
true,
- "Selected Cape");
+ "Selected Cape", CAT_ALL);
public Option<Double> compareMode = new Option(
0.0,
"Compare Mode",
false,
- "Compare Mode");
+ "Compare Mode", CAT_ALL);
public Option<Double> sortMode = new Option(
0.0,
"Sort Mode",
false,
- "Sort Mode");
+ "Sort Mode", CAT_ALL);
public Option<ArrayList<Boolean>> compareAscending = new Option(
Utils.createList(true, true, true),
"Compare Ascending",
false,
- "Compare Ascending");
+ "Compare Ascending", CAT_ALL);
public Option<ArrayList<String>> favourites = new Option(
new ArrayList<String>(),
"Favourites",
false,
- "Favourites");
+ "Favourites", CAT_ALL);
public Option<Map<String, ArrayList<String>>> collectionLog = new Option(
new HashMap<String, ArrayList<String>>(),
"CollectionLog",
false,
- "CollectionLog");
+ "CollectionLog", CAT_ALL);
public Option<ArrayList<String>> quickCommands = new Option(
createDefaultQuickCommands(),
"Quick Commands",
false,
- "Quick Commands");
+ "Quick Commands", CAT_ALL);
public Option<String> overlaySearchBar = new Option(
"",
"OverlaySearchBar",
false,
- "OverlaySearchBar");
+ "OverlaySearchBar", CAT_ALL);
public Option<String> overlayQuickCommand = new Option(
"",
"OverlaySearchBar",
false,
- "OverlaySearchBar");
+ "OverlaySearchBar", CAT_ALL);
public Option<List<String>> enchantColours = new Option(
- Utils.createList("[a-zA-Z ]+:\u003e:9:6",
- "[a-zA-Z ]+:\u003e:6:c",
- "[a-zA-Z ]+:\u003e:5:5",
+ Utils.createList("[a-zA-Z\\- ]+:\u003e:9:6",
+ "[a-zA-Z\\- ]+:\u003e:6:c",
+ "[a-zA-Z\\- ]+:\u003e:5:5",
"Experience:\u003e:3:5",
"Life Steal:\u003e:3:5",
"Scavenger:\u003e:3:5",
"Looting:\u003e:3:5"),
"enchantColours",
false,
- "enchantColours");
+ "enchantColours", CAT_ALL);
private ArrayList<String> createDefaultQuickCommands() {
ArrayList<String> arr = new ArrayList<>();
@@ -427,6 +465,8 @@ public class Options {
tryAddOption(hideApiKey, options);
tryAddOption(streamerMode, options);
tryAddOption(disableTreecapOverlay, options);
+ tryAddOption(disableWandOverlay, options);
+ tryAddOption(wandBlockCount, options);
tryAddOption(autoupdate, options);
tryAddOption(cacheRenderedItempane, options);
tryAddOption(itemStyle, options);
@@ -441,7 +481,10 @@ public class Options {
tryAddOption(invAuctionPrice, options);
tryAddOption(dungeonBlocksEverywhere, options);
tryAddOption(disableDungeonBlocks, options);
+ tryAddOption(missingEnchantList, options);
+ tryAddOption(accessoryBagOverlay, options);
//Sliders
+ tryAddOption(paneGuiScale, options);
tryAddOption(smoothAoteMillis, options);
tryAddOption(bgBlurFactor, options);
tryAddOption(ahNotification, options);
@@ -457,6 +500,7 @@ public class Options {
tryAddOption(itemBackgroundColour, options);
tryAddOption(itemFavouriteColour, options);
tryAddOption(treecapOverlayColour, options);
+ tryAddOption(wandOverlayColour, options);
tryAddOption(dungCrackedColour, options);
tryAddOption(dungDispenserColour, options);
@@ -483,20 +527,22 @@ public class Options {
public final transient int flags;
public final transient double minValue;
public final transient double maxValue;
+ public final transient int category;
+ public final transient ArrayList<String> tags;
- public Option(T defaultValue, String displayName, boolean secret, String desc) {
- this(defaultValue, displayName, secret, desc, 0, 0, 100);
+ public Option(T defaultValue, String displayName, boolean secret, String desc, int category) {
+ this(defaultValue, displayName, secret, desc, 0, 0, 100, category);
}
- public Option(T defaultValue, String displayName, boolean secret, String desc, int flags) {
- this(defaultValue, displayName, secret, desc, flags, 0, 100);
+ public Option(T defaultValue, String displayName, boolean secret, String desc, int flags, int category) {
+ this(defaultValue, displayName, secret, desc, flags, 0, 100, category);
}
- public Option(T defaultValue, String displayName, boolean secret, String desc, double minValue, double maxValue) {
- this(defaultValue, displayName, secret, desc, 0, minValue, maxValue);
+ public Option(T defaultValue, String displayName, boolean secret, String desc, double minValue, double maxValue, int category) {
+ this(defaultValue, displayName, secret, desc, 0, minValue, maxValue, category);
}
- public Option(T defaultValue, String displayName, boolean secret, String desc, int flags, double minValue, double maxValue) {
+ public Option(T defaultValue, String displayName, boolean secret, String desc, int flags, double minValue, double maxValue, int category) {
this.value = defaultValue;
this.defaultValue = defaultValue;
this.displayName = displayName;
@@ -505,6 +551,21 @@ public class Options {
this.flags = flags;
this.minValue = minValue;
this.maxValue = maxValue;
+ this.category = category;
+
+ this.tags = new ArrayList<>();
+ for(String s : displayName.split(" ")) {
+ s = s.replaceAll("[^A-Za-z]", "").toLowerCase();
+ if(s.length() > 0) {
+ tags.add(s);
+ }
+ }
+ for(String s : desc.split(" ")) {
+ s = s.replaceAll("[^A-Za-z]", "").toLowerCase();
+ if(s.length() >= 4) {
+ tags.add(s);
+ }
+ }
}
public void setValue(String value) {
@@ -530,7 +591,7 @@ public class Options {
public static JsonDeserializer<Option<?>> createDeserializer() {
return (json, typeOfT, context) -> {
try {
- return new Option(context.deserialize(json, Object.class), "unknown", false, "unknown");
+ return new Option(context.deserialize(json, Object.class), "unknown", false, "unknown", CAT_ALL);
} catch (Exception e) {
return null;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
index fc0caa28..111ebea1 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java
@@ -12,6 +12,7 @@ import io.github.moulberry.notenoughupdates.SBAIntegration;
import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager;
import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField;
import io.github.moulberry.notenoughupdates.questing.SBInfo;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityOtherPlayerMP;
@@ -662,7 +663,7 @@ public class GuiProfileViewer extends GuiScreen {
private void drawPetsPage(int mouseX, int mouseY, float partialTicks) {
JsonObject petsInfo = profile.getPetsInfo(profileId);
if(petsInfo == null) return;
- JsonObject petsJson = Utils.getConstant("pets");
+ JsonObject petsJson = Constants.PETS;
if(petsJson == null) return;
String location = null;
@@ -1227,7 +1228,7 @@ public class GuiProfileViewer extends GuiScreen {
private int getAvailableSlotsForInventory(JsonObject inventoryInfo, JsonObject collectionInfo, String invName) {
if(collectionInfo == null) return -1;
- JsonObject misc = Utils.getConstant("misc");
+ JsonObject misc = Constants.MISC;
if(misc == null) return -1;
JsonElement sizesElement = Utils.getElement(misc, "bag_size."+invName+".sizes");
JsonElement collectionElement = Utils.getElement(misc, "bag_size."+invName+".collection");
@@ -1932,7 +1933,7 @@ public class GuiProfileViewer extends GuiScreen {
rankPlusColor = rankPlusColorECF.toString();
}
- JsonObject misc = Utils.getConstant("misc");
+ JsonObject misc = Constants.MISC;
if(misc != null) {
if(misc.has("ranks")) {
String rankName = Utils.getElementAsString(Utils.getElement(misc, "ranks."+rank+".tag"), null);
@@ -2019,7 +2020,7 @@ public class GuiProfileViewer extends GuiScreen {
locationStr = "Ignoring DMs";
} else {
if(location != null) {
- JsonObject misc = Utils.getConstant("misc");
+ JsonObject misc = Constants.MISC;
if(misc != null) {
locationStr = Utils.getElementAsString(Utils.getElement(misc, "area_names."+location), "Unknown");
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
index 36a616bb..e1ee32f6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java
@@ -1,6 +1,7 @@
package io.github.moulberry.notenoughupdates.profileviewer;
import com.google.gson.*;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.nbt.*;
import net.minecraft.util.EnumChatFormatting;
@@ -104,7 +105,7 @@ public class PlayerStats {
}
public static Stats getBaseStats() {
- JsonObject misc = Utils.getConstant("misc");
+ JsonObject misc = Constants.MISC;
if(misc == null) return null;
Stats stats = new Stats();
@@ -129,7 +130,7 @@ public class PlayerStats {
}
private static Stats getSkillBonus(JsonObject skillInfo) {
- JsonObject bonuses = Utils.getConstant("bonuses");
+ JsonObject bonuses = Constants.BONUSES;
if(bonuses == null) return null;
Stats skillBonus = new Stats();
@@ -159,7 +160,7 @@ public class PlayerStats {
}
private static Stats getPetBonus(JsonObject profile) {
- JsonObject bonuses = Utils.getConstant("bonuses");
+ JsonObject bonuses = Constants.BONUSES;
if(bonuses == null) return null;
JsonElement petsElement = Utils.getElement(profile, "pets");
@@ -386,7 +387,7 @@ public class PlayerStats {
return stats;
}
private static Stats getItemBonuses(boolean talismanOnly, JsonArray... inventories) {
- JsonObject misc = Utils.getConstant("misc");
+ JsonObject misc = Constants.MISC;
if(misc == null) return null;
JsonElement talisman_upgrades_element = misc.get("talisman_upgrades");
if(talisman_upgrades_element == null) return null;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
index 9c1de286..007ab7a9 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
@@ -7,6 +7,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
@@ -581,7 +582,7 @@ public class ProfileViewer {
if(profileInfo == null) return null;
if(profileId == null) profileId = latestProfile;
if(skillInfoMap.containsKey(profileId)) return skillInfoMap.get(profileId);
- JsonObject leveling = Utils.getConstant("leveling");
+ JsonObject leveling = Constants.LEVELING;
if(leveling == null) return null;
float experience_skill_taming = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_taming"), 0);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
new file mode 100644
index 00000000..4f8ab5ce
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Constants.java
@@ -0,0 +1,15 @@
+package io.github.moulberry.notenoughupdates.util;
+
+import com.google.gson.JsonObject;
+
+public class Constants {
+
+ public static final JsonObject BONUSES = Utils.getConstant("enchants");
+ public static final JsonObject DISABLE = Utils.getConstant("disable");
+ public static final JsonObject ENCHANTS = Utils.getConstant("enchants");
+ public static final JsonObject LEVELING = Utils.getConstant("leveling");
+ public static final JsonObject MISC = Utils.getConstant("misc");
+ public static final JsonObject PETNUMS = Utils.getConstant("petnums");
+ public static final JsonObject PETS = Utils.getConstant("pets");
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index 7ce180b9..d8df52e7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -16,10 +16,7 @@ import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiContainer;
-import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.client.renderer.RenderHelper;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.WorldRenderer;
+import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.DynamicTexture;
@@ -36,6 +33,8 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.*;
+import net.minecraftforge.fml.common.Loader;
+import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
@@ -48,16 +47,21 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.Proxy;
+import java.nio.FloatBuffer;
import java.nio.file.Files;
-import java.util.ArrayList;
+import java.util.*;
import java.util.List;
-import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Utils {
private static boolean hasEffectOverride = false;
+ private static LinkedList<Integer> guiScales = new LinkedList<>();
+ private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft());
+ //Labymod compatibility
+ private static FloatBuffer projectionMatrixOld = BufferUtils.createFloatBuffer(16);
+ private static FloatBuffer modelviewMatrixOld = BufferUtils.createFloatBuffer(16);
public static <T> ArrayList<T> createList(T... values) {
ArrayList<T> list = new ArrayList<>();
@@ -65,6 +69,67 @@ public class Utils {
return list;
}
+ public static void resetGuiScale() {
+ guiScales.clear();
+ }
+
+ public static ScaledResolution peekGuiScale() {
+ return lastScale;
+ }
+
+ public static ScaledResolution pushGuiScale(int scale) {
+ if(guiScales.size() == 0) {
+ if(Loader.isModLoaded("labymod")) {
+ GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projectionMatrixOld);
+ GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelviewMatrixOld);
+ }
+ }
+
+ if(scale < 0) {
+ if(guiScales.size() > 0) {
+ guiScales.pop();
+ }
+ } else {
+ if(scale == 0) {
+ guiScales.push(Minecraft.getMinecraft().gameSettings.guiScale);
+ } else {
+ guiScales.push(scale);
+ }
+ }
+
+ int newScale = guiScales.size() > 0 ? Math.max(1, Math.min(4, guiScales.peek())) : Minecraft.getMinecraft().gameSettings.guiScale;
+ if(newScale == 0) newScale = Minecraft.getMinecraft().gameSettings.guiScale;
+
+ int oldScale = Minecraft.getMinecraft().gameSettings.guiScale;
+ Minecraft.getMinecraft().gameSettings.guiScale = newScale;
+ ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft());
+ Minecraft.getMinecraft().gameSettings.guiScale = oldScale;
+
+ if(guiScales.size() > 0) {
+ GlStateManager.viewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GlStateManager.loadIdentity();
+ GlStateManager.ortho(0.0D,
+ scaledresolution.getScaledWidth_double(),
+ scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GlStateManager.loadIdentity();
+ GlStateManager.translate(0.0F, 0.0F, -2000.0F);
+ } else {
+ if(Loader.isModLoaded("labymod") && projectionMatrixOld.limit() > 0 && modelviewMatrixOld.limit() > 0) {
+ GlStateManager.matrixMode(GL11.GL_PROJECTION);
+ GL11.glLoadMatrix(projectionMatrixOld);
+ GlStateManager.matrixMode(GL11.GL_MODELVIEW);
+ GL11.glLoadMatrix(modelviewMatrixOld);
+ } else {
+ Minecraft.getMinecraft().entityRenderer.setupOverlayRendering();
+ }
+ }
+
+ lastScale = scaledresolution;
+ return scaledresolution;
+ }
+
public static boolean getHasEffectOverride() {
return hasEffectOverride;
}
@@ -113,14 +178,28 @@ public class Utils {
};
public static String chromaString(String str) {
+ return chromaString(str, 0, false);
+ }
+
+ private static long startTime = 0;
+ public static String chromaString(String str, float offset, boolean bold) {
+ str = cleanColour(str);
+
long currentTimeMillis = System.currentTimeMillis();
+ if(startTime == 0) startTime = currentTimeMillis;
StringBuilder rainbowText = new StringBuilder();
+ int len = 0;
for(int i=0; i<str.length(); i++) {
char c = str.charAt(i);
- int index = (int)(i-currentTimeMillis/100)%rainbow.length;
+ int index = ((int)(offset+len/12f-(currentTimeMillis-startTime)/100))%rainbow.length;
+ len += Minecraft.getMinecraft().fontRendererObj.getCharWidth(c);
+ if(bold) len++;
+
if(index < 0) index += rainbow.length;
- rainbowText.append(rainbow[index]).append(c);
+ rainbowText.append(rainbow[index]);
+ if(bold) rainbowText.append(EnumChatFormatting.BOLD);
+ rainbowText.append(c);
}
return rainbowText.toString();
}