diff options
Diffstat (limited to 'src/main/java/io')
21 files changed, 1202 insertions, 135 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 59d71520..4682a744 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -4,7 +4,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; -import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; @@ -12,8 +11,8 @@ import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.miscfeatures.*; import io.github.moulberry.notenoughupdates.miscgui.*; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; -import io.github.moulberry.notenoughupdates.textoverlays.TextOverlay; -import io.github.moulberry.notenoughupdates.textoverlays.TextOverlayStyle; +import io.github.moulberry.notenoughupdates.overlays.TextOverlay; +import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.RequestFocusListener; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -176,6 +175,7 @@ public class NEUEventListener { CrystalOverlay.tick(); DwarvenMinesTextures.tick(); FairySouls.tick(); + MiningStuff.tick(); for(TextOverlay overlay : textOverlays) { overlay.tick(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 12a95484..9012e67e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1512,6 +1512,8 @@ public class NEUOverlay extends Gui { * is enabled) */ public void renderOverlay() { + GlStateManager.enableDepth(); + int width = Utils.peekGuiScale().getScaledWidth(); int height = Utils.peekGuiScale().getScaledHeight(); int mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index ad42fcfd..f2f41b17 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -24,6 +24,7 @@ import io.github.moulberry.notenoughupdates.miscgui.HelpGUI; import io.github.moulberry.notenoughupdates.miscgui.NEUOverlayPlacements; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; +import io.github.moulberry.notenoughupdates.overlays.FuelBar; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; @@ -80,8 +81,8 @@ import java.util.regex.Pattern; @Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true) public class NotEnoughUpdates { public static final String MODID = "notenoughupdates"; - public static final String VERSION = "1.7.1-REL"; - public static final int VERSION_ID = 10701; + public static final String VERSION = "2.0.0-REL"; + public static final int VERSION_ID = 20000; public static NotEnoughUpdates INSTANCE = null; @@ -767,7 +768,7 @@ public class NotEnoughUpdates { if (j / 4 == 0) { c = new Color((i + i / 128 & 1) * 8 + 16 << 24, true); } else { - c = new Color(MapColor.mapColorArray[j / 4].func_151643_b(j & 3), true); + c = new Color(MapColor.mapColorArray[j / 4].getMapColor(j & 3), true); } json.addProperty(x+":"+y, c.getRGB()); @@ -906,6 +907,8 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new CrystalOverlay()); MinecraftForge.EVENT_BUS.register(new ItemCooldowns()); MinecraftForge.EVENT_BUS.register(new DwarvenMinesTextures()); + MinecraftForge.EVENT_BUS.register(new DwarvenMinesWaypoints()); + MinecraftForge.EVENT_BUS.register(new FuelBar()); ClientCommandHandler.instance.registerCommand(collectionLogCommand); ClientCommandHandler.instance.registerCommand(cosmeticsCommand); @@ -1057,7 +1060,6 @@ 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(); @@ -1067,7 +1069,7 @@ public class NotEnoughUpdates { if (matcher.find()) { // Group 1 is the server brand. - if(!matcher.group(1).equals(HYPIXEL_SERVER_BRAND)) { + if(!matcher.group(1).toLowerCase().contains("hypixel")) { hasSkyblockScoreboard = false; return; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java index b30aa680..3bd4e9d2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java @@ -9,16 +9,34 @@ public class Position { private int x; @Expose private int y; + @Expose + private boolean centerX; + @Expose + private boolean centerY; public Position(int x, int y) { + this(x, y, false, false); + } + + public Position(int x, int y, boolean centerX, boolean centerY) { this.x = x; this.y = y; + this.centerX = centerX; + this.centerY = centerY; } public Position clone() { return new Position(x, y); } + public boolean isCenterX() { + return centerX; + } + + public boolean isCenterY() { + return centerY; + } + public int getRawX() { return x; } @@ -28,19 +46,39 @@ public class Position { } public int getAbsX(ScaledResolution scaledResolution) { + int width = scaledResolution.getScaledWidth(); + + if(centerX) { + return width/2 + x; + } + + int ret = x; if(x < 0) { - return scaledResolution.getScaledWidth() + x; - } else { - return x; + ret = width + x; } + + if(ret < 0) ret = 0; + if(ret > width) ret = width; + + return ret; } public int getAbsY(ScaledResolution scaledResolution) { + int height = scaledResolution.getScaledHeight(); + + if(centerY) { + return height/2 + y; + } + + int ret = y; if(y < 0) { - return scaledResolution.getScaledHeight() + y; - } else { - return y; + ret = height + y; } + + if(ret < 0) ret = 0; + if(ret > height) ret = height; + + return ret; } public int moveX(int deltaX, int objWidth, ScaledResolution scaledResolution) { @@ -48,6 +86,21 @@ public class Position { boolean wasPositiveX = this.x >= 0; this.x += deltaX; + if(centerX) { + if(wasPositiveX) { + if(this.x > screenWidth/2-objWidth) { + deltaX += screenWidth/2-objWidth-this.x; + this.x = screenWidth/2-objWidth; + } + } else { + if(this.x < -screenWidth/2) { + deltaX += -screenWidth/2-this.x; + this.x = -screenWidth/2; + } + } + return deltaX; + } + if(wasPositiveX) { if(this.x < 2) { deltaX += 2-this.x; @@ -82,6 +135,21 @@ public class Position { boolean wasPositiveY = this.y >= 0; this.y += deltaY; + if(centerY) { + if(wasPositiveY) { + if(this.y > screenHeight/2-objHeight) { + deltaY += screenHeight/2-objHeight-this.y; + this.y = screenHeight/2-objHeight; + } + } else { + if(this.y < -screenHeight/2) { + deltaY += -screenHeight/2-this.y; + this.y = -screenHeight/2; + } + } + return deltaY; + } + if(wasPositiveY) { if(this.y < 2) { deltaY += 2-this.y; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java index 117a97bd..c5b6b3d8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java @@ -2,10 +2,12 @@ package io.github.moulberry.notenoughupdates.core.config.gui; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; +import org.lwjgl.input.Mouse; import java.io.IOException; @@ -25,6 +27,8 @@ public class GuiPositionEditor extends GuiScreen { private int oldMouseX = 0; private int oldMouseY = 0; + private int guiScaleOverride = -1; + public GuiPositionEditor(Position position, int elementWidth, int elementHeight, Runnable renderCallback, Runnable positionChangedCallback, @@ -38,6 +42,11 @@ public class GuiPositionEditor extends GuiScreen { this.closedCallback = closedCallback; } + public GuiPositionEditor withScale(int scale) { + this.guiScaleOverride = scale; + return this; + } + @Override public void onGuiClosed() { super.onGuiClosed(); @@ -47,10 +56,18 @@ public class GuiPositionEditor extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + ScaledResolution scaledResolution; + if(guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + this.width = scaledResolution.getScaledWidth(); this.height = scaledResolution.getScaledHeight(); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; drawDefaultBackground(); @@ -64,7 +81,13 @@ public class GuiPositionEditor extends GuiScreen { int x = position.getAbsX(scaledResolution); int y = position.getAbsY(scaledResolution); + if(position.isCenterX()) x -= elementWidth/2; + if(position.isCenterY()) y -= elementHeight/2; Gui.drawRect(x, y, x+elementWidth, y+elementHeight, 0x80404040); + + if(guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } } @Override @@ -72,10 +95,19 @@ public class GuiPositionEditor extends GuiScreen { super.mouseClicked(mouseX, mouseY, mouseButton); if(mouseButton == 0) { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + ScaledResolution scaledResolution; + if(guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; int x = position.getAbsX(scaledResolution); int y = position.getAbsY(scaledResolution); + if(position.isCenterX()) x -= elementWidth/2; + if(position.isCenterY()) y -= elementHeight/2; if(mouseX >= x && mouseY >= y && mouseX <= x+elementWidth && mouseY <= y+elementHeight) { @@ -83,6 +115,10 @@ public class GuiPositionEditor extends GuiScreen { grabbedX = mouseX; grabbedY = mouseY; } + + if(guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } } } @@ -96,14 +132,26 @@ public class GuiPositionEditor extends GuiScreen { protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); if(clicked) { + ScaledResolution scaledResolution; + if(guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + oldMouseX = mouseX; oldMouseY = mouseY; grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); positionChangedCallback.run(); + + if(guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java index be2b030a..993eb78b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -1400,7 +1400,7 @@ public class DungeonMap { if (j / 4 == 0) { c = new Color((i + i / 128 & 1) * 8 + 16 << 24, true); } else { - c = new Color(MapColor.mapColorArray[j / 4].func_151643_b(j & 3), true); + c = new Color(MapColor.mapColorArray[j / 4].getMapColor(j & 3), true); } colourMap[x][y] = c; @@ -1469,8 +1469,10 @@ public class DungeonMap { Position pos = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition; int size = 80 + Math.round(40*NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize); - renderMap(pos.getAbsX(event.resolution)+size/2, pos.getAbsY(event.resolution)+size/2, + ScaledResolution scaledResolution = Utils.pushGuiScale(2); + renderMap(pos.getAbsX(scaledResolution)+size/2, pos.getAbsY(scaledResolution)+size/2, colourMap, decorations, roomSizeBlocks, actualPlayers, true, event.partialTicks); + Utils.pushGuiScale(-1); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java index cd951830..041cd842 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -353,11 +353,11 @@ public class GuiDungeonMapEditor extends GuiScreen { Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, 200, Minecraft.getMinecraft().fontRendererObj); } + Utils.pushGuiScale(-1); + if(activeColourEditor != null) { activeColourEditor.render(); } - - Utils.pushGuiScale(-1); } public void drawSlider(Field option, int centerX, int centerY) { @@ -474,18 +474,18 @@ public class GuiDungeonMapEditor extends GuiScreen { players.add(Minecraft.getMinecraft().thePlayer.getName()); GlStateManager.color(1, 1, 1, 1); - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition, size, size, () -> { + ScaledResolution scaledResolution = Utils.pushGuiScale(2); demoMap.renderMap(NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsX(scaledResolution)+size/2, NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition.getAbsY(scaledResolution)+size/2, NotEnoughUpdates.INSTANCE.colourMap, decorations, 0, players, false, 0); + Utils.pushGuiScale(-1); }, () -> { }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor() - )); + ).withScale(2)); return; } } @@ -497,9 +497,10 @@ public class GuiDungeonMapEditor extends GuiScreen { public void handleMouseInput() throws IOException { super.handleMouseInput(); - int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth; - int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; if(activeColourEditor != null) { + ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft()); + int mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth; + int mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1; activeColourEditor.mouseInput(mouseX, mouseY); } } @@ -567,13 +568,21 @@ public class GuiDungeonMapEditor extends GuiScreen { options.dmCompat++; if(options.dmCompat > 2) options.dmCompat = 0; break; - case 26: - activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBackgroundColour, - (col) -> options.dmBackgroundColour = col, () -> activeColourEditor = null); + case 26: { + ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft()); + mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth; + mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1; + activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBackgroundColour, + (col) -> options.dmBackgroundColour = col, () -> activeColourEditor = null); + } break; - case 27: - activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBorderColour, - (col) -> options.dmBorderColour = col, () -> activeColourEditor = null); + case 27: { + ScaledResolution realRes = new ScaledResolution(Minecraft.getMinecraft()); + mouseX = Mouse.getEventX() * realRes.getScaledWidth() / this.mc.displayWidth; + mouseY = realRes.getScaledHeight() - Mouse.getEventY() * realRes.getScaledHeight() / this.mc.displayHeight - 1; + activeColourEditor = new GuiElementColour(mouseX, mouseY, options.dmBorderColour, + (col) -> options.dmBorderColour = col, () -> activeColourEditor = null); + } break; case 28: options.dmChromaBorder = !options.dmChromaBorder; break; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CommissionOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CommissionOverlay.java index 33cf9c4b..decfbf3f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CommissionOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CommissionOverlay.java @@ -6,8 +6,8 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils; -import io.github.moulberry.notenoughupdates.textoverlays.TextOverlay; -import io.github.moulberry.notenoughupdates.textoverlays.TextOverlayStyle; +import io.github.moulberry.notenoughupdates.overlays.TextOverlay; +import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetworkPlayerInfo; @@ -28,14 +28,17 @@ public class CommissionOverlay extends TextOverlay { super(position, styleSupplier); } + public static Map<String, Float> commissionProgress = new LinkedHashMap<>(); + @Override public void update() { - overlayStrings = new ArrayList<>(); + overlayStrings = null; if(SBInfo.getInstance().getLocation() == null) return; if(!SBInfo.getInstance().getLocation().equals("mining_3")) return; - Map<String, Float> commissionProgress = new LinkedHashMap<>(); + overlayStrings = new ArrayList<>(); + commissionProgress.clear(); List<String> forgeStrings = new ArrayList<>(); String mithrilPowder = null; @@ -44,7 +47,7 @@ public class CommissionOverlay extends TextOverlay { List<NetworkPlayerInfo> players = playerOrdering.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); for(NetworkPlayerInfo info : players) { String name = Minecraft.getMinecraft().ingameGUI.getTabList().getPlayerName(info); - if(name.contains("Mithril Powder")) { + if(name.contains("Mithril Powder:")) { mithrilPowder = trimIgnoreColour(name); } if(name.equals(RESET.toString()+BLUE+BOLD+"Forges"+RESET)) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java index 4a639287..42712c39 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesTextures.java @@ -1,27 +1,232 @@ package io.github.moulberry.notenoughupdates.miscfeatures; +import com.google.gson.*; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import net.minecraft.block.BlockClay; +import net.minecraft.block.BlockColored; +import net.minecraft.block.BlockHardenedClay; +import net.minecraft.block.BlockStone; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumDyeColor; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.client.event.RenderWorldLastEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.*; public class DwarvenMinesTextures { - private static final byte biomeId1 = (byte)(BiomeGenBase.extremeHillsEdge.biomeID & 255); - private static final byte[] biomeMap1 = new byte[16*16]; - private static final byte biomeId2 = (byte)(BiomeGenBase.extremeHillsPlus.biomeID & 255); - private static final byte[] biomeMap2 = new byte[16*16]; - static { - Arrays.fill(biomeMap1, biomeId1); - Arrays.fill(biomeMap2, biomeId2); + /*private static final HashSet<BlockPos> blocks = new HashSet<>(); + private static final HashSet<ChunkCoordIntPair> ignoredChunks = new HashSet<>(); + private static final HashMap<ChunkCoordIntPair, HashMap<ChunkCoordIntPair, Set<BlockPos>>> ignoredBlocks = new HashMap<>(); + private static final HashMap<ChunkCoordIntPair, HashMap<ChunkCoordIntPair, Set<BlockPos>>> whitelistBlocks = new HashMap<>();*/ + + private static class IgnoreColumn { + boolean always; + int minY; + int maxY; + + public IgnoreColumn(boolean always, int minY, int maxY) { + this.always = always; + this.minY = minY; + this.maxY = maxY; + } } + private static HashSet<ChunkCoordIntPair> ignoredChunks = null; + private static final HashMap<ChunkCoordIntPair, HashMap<ChunkCoordIntPair, IgnoreColumn>> loadedChunkData = new HashMap<>(); + private static final HashMap<ChunkCoordIntPair, Long> lastRetextureCheck = new HashMap<>(); + private static long time; + private static boolean error = false; + + public static boolean shouldBeRetextured(BlockPos pos) { + if(error) return false; + if(Minecraft.getMinecraft().theWorld == null) return false; + + if(SBInfo.getInstance().getLocation() == null) return false; + if(!SBInfo.getInstance().getLocation().equals("mining_3")) return false; + + IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(pos); + boolean titanium = state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH; + if(titanium) { + IBlockState plus = Minecraft.getMinecraft().theWorld.getBlockState(pos.add(1, 0, 0)); + if(plus.getBlock() == Blocks.double_stone_slab) { + return false; + } + IBlockState minus = Minecraft.getMinecraft().theWorld.getBlockState(pos.add(-1, 0, 0)); + if(minus.getBlock() == Blocks.double_stone_slab) { + return false; + } + } + + if(titanium || (state.getBlock() == Blocks.stained_hardened_clay && state.getValue(BlockColored.COLOR) == EnumDyeColor.CYAN) || + (state.getBlock() == Blocks.wool && state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY)) { + + if(ignoredChunks == null) { + try { + ignoredChunks = new HashSet<>(); + ResourceLocation loc = new ResourceLocation("notenoughupdates:dwarven_data/all.json"); + InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream(); + + try(BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { + JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class); + for(Map.Entry<String, JsonElement> entry : json.entrySet()) { + String coord = entry.getKey(); + String[] split = coord.split("_"); + int left = Integer.parseInt(split[0]); + int right = Integer.parseInt(split[1]); + ignoredChunks.add(new ChunkCoordIntPair(left, right)); + } + } + } catch(Exception e) { + e.printStackTrace(); + error = true; + return false; + } + } + if(ignoredChunks != null) { + ChunkCoordIntPair pair = new ChunkCoordIntPair(MathHelper.floor_float(pos.getX()/16f), + MathHelper.floor_float(pos.getZ()/16f)); + + lastRetextureCheck.put(pair, time); + + if(ignoredChunks.contains(pair)) { + return false; + } + if(titanium) { + return true; + } + + if(!loadedChunkData.containsKey(pair)) { + try { + HashMap<ChunkCoordIntPair, IgnoreColumn> map = new HashMap<>(); + loadedChunkData.put(pair, map); + + ResourceLocation loc = new ResourceLocation("notenoughupdates:dwarven_data/"+ + pair.chunkXPos+"_"+pair.chunkZPos+".json"); + InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(loc).getInputStream(); + + try(BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { + JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class); + for(Map.Entry<String, JsonElement> entry : json.entrySet()) { + String coord = entry.getKey(); + String[] split = coord.split(":"); + int left = Integer.parseInt(split[0]); + int right = Integer.parseInt(split[1]); + + IgnoreColumn ignore = null; + if(entry.getValue().isJsonPrimitive()) { + JsonPrimitive prim = entry.getValue().getAsJsonPrimitive(); + if(prim.isBoolean()) { + ignore = new IgnoreColumn(true, 0, 0); + } else if(prim.isNumber()) { + int y = prim.getAsInt(); + ignore = new IgnoreColumn(false, y, y); + } + } else if(entry.getValue().isJsonArray()) { + JsonArray arr = entry.getValue().getAsJsonArray(); + if(arr.size() == 2) { + int min = arr.get(0).getAsInt(); + int max = arr.get(1).getAsInt(); + ignore = new IgnoreColumn(false, min, max); + } + } + if (ignore != null) { + ChunkCoordIntPair offset = new ChunkCoordIntPair(left, right); + map.put(offset, ignore); + } + } + } + } catch(Exception e) { + e.printStackTrace(); + loadedChunkData.put(pair, null); + } + } + if(loadedChunkData.get(pair) != null) { + HashMap<ChunkCoordIntPair, IgnoreColumn> map = loadedChunkData.get(pair); + + int modX = pos.getX() % 16; + int modZ = pos.getZ() % 16; + if(modX < 0) modX += 16; + if(modZ < 0) modZ += 16; + ChunkCoordIntPair offset = new ChunkCoordIntPair(modX, modZ); + + if(map.containsKey(offset)) { + IgnoreColumn ignore = map.get(offset); + if(ignore.always) { + return false; + } else { + int y = pos.getY(); + if(y >= ignore.minY && y <= ignore.maxY) { + return false; + } + } + } + } + } + } + + return true; + } + + /*@SubscribeEvent + public void onRender(RenderWorldLastEvent event) { + Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); + double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * event.partialTicks; + double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * event.partialTicks; + double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * event.partialTicks; + + int x = MathHelper.floor_double(viewer.posX/16f); + int z = MathHelper.floor_double(viewer.posZ/16f); + File file = new File("C:/Users/James/Desktop/testfolder/"+x+"_"+z+".json"); + + int col = 0xff0000; + if(file.exists()) { + col = 0x00ff00; + if(Keyboard.isKeyDown(Keyboard.KEY_K)) { + file.delete(); + } + + } + + AxisAlignedBB bb = new AxisAlignedBB( + MathHelper.floor_double(viewerX/16)*16-viewerX, + 0-viewerY, + MathHelper.floor_double(viewerZ/16)*16-viewerZ, + MathHelper.floor_double(viewerX/16)*16+16-viewerX, + 255-viewerY, + MathHelper.floor_double(viewerZ/16)*16+16-viewerZ).expand(0.01f, 0.01f, 0.01f); + + GlStateManager.disableCull(); + CustomItemEffects.drawFilledBoundingBox(bb, 1f, SpecialColour.special(0, 100, col)); + GlStateManager.enableCull(); + GlStateManager.enableTexture2D(); + }*/ + + //Render all blocks - extremeHillsEdge + //Don't render smooth diorite - extremeHillsPlus + //Don't render clay - mesaPlateau_F + public static void tick() { - if(Minecraft.getMinecraft().theWorld == null) return; + time = System.currentTimeMillis(); + lastRetextureCheck.entrySet().removeIf((checks) -> time - checks.getValue() > 30*1000); + + /*if(Minecraft.getMinecraft().theWorld == null) return; if(SBInfo.getInstance().getLocation() == null) return; if(!SBInfo.getInstance().getLocation().equals("mining_3")) return; @@ -29,62 +234,161 @@ public class DwarvenMinesTextures { int playerX = (int)Minecraft.getMinecraft().thePlayer.posX; int playerZ = (int)Minecraft.getMinecraft().thePlayer.posZ; + + if(Keyboard.isKeyDown(Keyboard.KEY_C)) { + ignoredBlocks.clear(); + whitelistBlocks.clear(); + } + if(Keyboard.isKeyDown(Keyboard.KEY_R)) { + ignoredChunks.clear(); + } + if(Keyboard.isKeyDown(Keyboard.KEY_P)) { + Gson gson = new GsonBuilder().create(); + JsonObject obj = new JsonObject(); + + for(Map.Entry<ChunkCoordIntPair, HashMap<ChunkCoordIntPair, Set<BlockPos>>> entry : ignoredBlocks.entrySet()) { + String chunkId = entry.getKey().chunkXPos + "_" + entry.getKey().chunkZPos; + if(!whitelistBlocks.containsKey(entry.getKey()) || whitelistBlocks.get(entry.getKey()).isEmpty()) { + obj.addProperty(chunkId, true); + } else { + HashMap<ChunkCoordIntPair, Set<BlockPos>> whitelistMap = whitelistBlocks.get(entry.getKey()); + JsonObject subChunkObj = new JsonObject(); + + for(Map.Entry<ChunkCoordIntPair, Set<BlockPos>> columnEntry : entry.getValue().entrySet()) { + String columnId = columnEntry.getKey().chunkXPos + ":" + columnEntry.getKey().chunkZPos; + + if(!whitelistMap.containsKey(columnEntry.getKey()) || whitelistMap.get(columnEntry.getKey()).isEmpty()) { + subChunkObj.addProperty(columnId, true); + } else if(!columnEntry.getValue().isEmpty()) { + JsonArray whitelistedBlocksInColumn = new JsonArray(); + + int min = 300; + int max = 0; + for(BlockPos pos : columnEntry.getValue()) { + int y = pos.getY(); + if(y < min) { + min = y; + } + if(y > max) { + max = y; + } + } + whitelistedBlocksInColumn.add(new JsonPrimitive(min)); + whitelistedBlocksInColumn.add(new JsonPrimitive(max)); + if(min < max) { + subChunkObj.add(columnId, whitelistedBlocksInColumn); + } else { + subChunkObj.addProperty(columnId, min); + } + } + } + try { + File file = new File("C:/Users/James/Desktop/testfolder/"+chunkId+".json"); + file.createNewFile(); + + try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) { + writer.write(gson.toJson(subChunkObj)); + } + } catch(IOException ignored) { + ignored.printStackTrace(); + } + } + } + + try { + File file = new File("C:/Users/James/Desktop/testfolder/all.json"); + file.createNewFile(); + + try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) { + writer.write(gson.toJson(obj)); + } + } catch(IOException ignored) { + ignored.printStackTrace(); + } + + } + for(int xC=-10; xC<=10; xC++) { + out: for(int zC=-10; zC<=10; zC++) { ChunkCoordIntPair pair = new ChunkCoordIntPair(playerX/16+xC, playerZ/16+zC); if(!ignoredChunks.contains(pair)) { - Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(pair.chunkXPos, pair.chunkZPos).setBiomeArray(biomeMap1); - } else { - Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(pair.chunkXPos, pair.chunkZPos).setBiomeArray(biomeMap2); + ignoredChunks.add(pair); + + boolean add = false; + for(int x=0; x<16; x++) { + for(int y=0; y<255; y++) { + for(int z=0; z<16; z++) { + BlockPos pos = new BlockPos(pair.chunkXPos*16+x, y, pair.chunkZPos*16+z); + IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(pos); + + ChunkCoordIntPair column = new ChunkCoordIntPair(x, z); + + if(state != null && state.getBlock() != Blocks.air) add = true; + + if(state != null && ((state.getBlock() == Blocks.stained_hardened_clay && + state.getValue(BlockColored.COLOR) == EnumDyeColor.CYAN) || + (state.getBlock() == Blocks.wool) && state.getValue(BlockColored.COLOR) == EnumDyeColor.GRAY || + (state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH))) { + + boolean hasAir = false; + for(int xO=-1; xO<=1; xO++) { + for (int yO = -1; yO <= 1; yO++) { + for (int zO = -1; zO <= 1; zO++) { + int tot = Math.abs(xO) + Math.abs(yO) + Math.abs(zO); + if(tot == 1) { + BlockPos pos2 = pos.add(xO, yO, zO); + IBlockState state2 = Minecraft.getMinecraft().theWorld.getBlockState(pos2); + + if(state2 == null) { + continue out; + } else if(state2.getBlock() == Blocks.air) { + hasAir = true; + } + } + } + } + } + if(!hasAir) continue; + + boolean found = false; + out2: + for(int xO=-4; xO<=4; xO++) { + for(int yO=-4; yO<=4; yO++) { + for(int zO=-4; zO<=4; zO++) { + int distSq = xO*xO + yO*yO + zO*zO; + if(distSq < 4*4) { + BlockPos pos2 = pos.add(xO, yO, zO); + IBlockState state2 = Minecraft.getMinecraft().theWorld.getBlockState(pos2); + + if(state2 == null) { + continue out; + } else if(state2.getBlock() == Blocks.prismarine) { + ignoredBlocks.computeIfAbsent(pair, k->new HashMap<>()) + .computeIfAbsent(column, k-> new HashSet<>()).remove(pos); + whitelistBlocks.computeIfAbsent(pair, k->new HashMap<>()) + .computeIfAbsent(column, k-> new HashSet<>()).add(pos); + found = true; + break out2; + } + } + } + } + } + if(!found) { + ignoredBlocks.computeIfAbsent(pair, k->new HashMap<>()) + .computeIfAbsent(column, k-> new HashSet<>()).add(pos); + } + + } + } + } + } } - } - } - } - private static Set<ChunkCoordIntPair> ignoredChunks = new HashSet<>(); - static { - ignoredChunks.add(new ChunkCoordIntPair(9, 3)); - ignoredChunks.add(new ChunkCoordIntPair(6, 0)); - ignoredChunks.add(new ChunkCoordIntPair(0, -4)); - ignoredChunks.add(new ChunkCoordIntPair(1, -6)); - ignoredChunks.add(new ChunkCoordIntPair(-1, -3)); - ignoredChunks.add(new ChunkCoordIntPair(6, 5)); - ignoredChunks.add(new ChunkCoordIntPair(-1, -2)); - ignoredChunks.add(new ChunkCoordIntPair(8, -1)); - ignoredChunks.add(new ChunkCoordIntPair(8, -2)); - ignoredChunks.add(new ChunkCoordIntPair(6, 6)); - ignoredChunks.add(new ChunkCoordIntPair(6, 1)); - ignoredChunks.add(new ChunkCoordIntPair(9, -1)); - ignoredChunks.add(new ChunkCoordIntPair(9, 4)); - ignoredChunks.add(new ChunkCoordIntPair(8, 0)); - ignoredChunks.add(new ChunkCoordIntPair(9, 2)); - ignoredChunks.add(new ChunkCoordIntPair(1, -4)); - ignoredChunks.add(new ChunkCoordIntPair(0, -6)); - ignoredChunks.add(new ChunkCoordIntPair(-1, -5)); - ignoredChunks.add(new ChunkCoordIntPair(9, 1)); - ignoredChunks.add(new ChunkCoordIntPair(9, 6)); - ignoredChunks.add(new ChunkCoordIntPair(-1, -6)); - ignoredChunks.add(new ChunkCoordIntPair(6, 4)); - ignoredChunks.add(new ChunkCoordIntPair(1, -3)); - ignoredChunks.add(new ChunkCoordIntPair(9, 5)); - ignoredChunks.add(new ChunkCoordIntPair(1, -2)); - ignoredChunks.add(new ChunkCoordIntPair(0, -5)); - ignoredChunks.add(new ChunkCoordIntPair(7, -1)); - ignoredChunks.add(new ChunkCoordIntPair(7, -2)); - ignoredChunks.add(new ChunkCoordIntPair(9, 0)); - ignoredChunks.add(new ChunkCoordIntPair(6, 3)); - ignoredChunks.add(new ChunkCoordIntPair(0, -3)); - ignoredChunks.add(new ChunkCoordIntPair(-1, -4)); - ignoredChunks.add(new ChunkCoordIntPair(1, -5)); - ignoredChunks.add(new ChunkCoordIntPair(6, 2)); - ignoredChunks.add(new ChunkCoordIntPair(0, -2)); - ignoredChunks.add(new ChunkCoordIntPair(-2, -4)); - ignoredChunks.add(new ChunkCoordIntPair(-2, -5)); - ignoredChunks.add(new ChunkCoordIntPair(-2, -6)); - ignoredChunks.add(new ChunkCoordIntPair(-1, -7)); - ignoredChunks.add(new ChunkCoordIntPair(0, -7)); - ignoredChunks.add(new ChunkCoordIntPair(1, -7)); + } + }*/ } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java new file mode 100644 index 00000000..58cf4d20 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/DwarvenMinesWaypoints.java @@ -0,0 +1,314 @@ +package io.github.moulberry.notenoughupdates.miscfeatures; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.options.NEUConfig; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.client.event.RenderLivingEvent; +import net.minecraftforge.client.event.RenderWorldLastEvent; +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 java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +public class DwarvenMinesWaypoints { + + private HashMap<String, Vector3f> waypointsMap = new HashMap<>(); + { + waypointsMap.put("Dwarven Village", new Vector3f(-37, 199, -122)); + waypointsMap.put("Miner's Guild", new Vector3f(-74, 220, -122)); + waypointsMap.put("Fetchur", new Vector3f(85, 223, -120)); + waypointsMap.put("Palace Bridge", new Vector3f(129, 186, 8)); + waypointsMap.put("Royal Palace", new Vector3f(129, 194, 194)); + waypointsMap.put("Puzzler", new Vector3f(181, 195, 135)); + waypointsMap.put("Grand Library", new Vector3f(183, 195, 181)); + waypointsMap.put("Barracks of Heroes", new Vector3f(93, 195, 181)); + waypointsMap.put("Royal Mines", new Vector3f(178, 149, 71)); + waypointsMap.put("Cliffside Veins", new Vector3f(40, 136, 17)); + waypointsMap.put("Forge Basin", new Vector3f(0, 169, -2)); + waypointsMap.put("The Forge", new Vector3f(0, 148, -69)); + waypointsMap.put("Rampart's Quarry", new Vector3f(-106, 147, 2)); + waypointsMap.put("Far Reserve", new Vector3f(-160, 148, 17)); + waypointsMap.put("Upper Mines", new Vector3f(-123, 170, -71)); + waypointsMap.put("Goblin Burrows", new Vector3f(-138, 143, 141)); + waypointsMap.put("Great Ice Wall", new Vector3f(0, 127, 160)); + waypointsMap.put("Aristocrat Passage", new Vector3f(129, 150, 137)); + waypointsMap.put("Hanging Court", new Vector3f(91, 186, 129)); + waypointsMap.put("Divan's Gateway", new Vector3f(0, 127, 87)); + waypointsMap.put("Lava Springs", new Vector3f(57, 196, -15)); + waypointsMap.put("The Mist", new Vector3f(0, 75, 82)); + } + + private static final HashSet<String> emissaryNames = new HashSet<>(); + static { + emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Ceanna"+EnumChatFormatting.RESET); + emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Carlton"+EnumChatFormatting.RESET); + emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Wilson"+EnumChatFormatting.RESET); + emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Lilith"+EnumChatFormatting.RESET); + emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Frasier"+EnumChatFormatting.RESET); + emissaryNames.add(EnumChatFormatting.GOLD+"Emissary Eliza"+EnumChatFormatting.RESET); + emissaryNames.add(EnumChatFormatting.GOLD.toString()+EnumChatFormatting.BOLD+"King Thormyr"+EnumChatFormatting.RESET); + } + + private enum Emissary { + THORMYR("King Thormyr", 0, new Vector3f(129, 196, 196)), + CEANNA("Emissary Ceanna", 1, new Vector3f(42, 134, 22)), + CARLTON("Emissary Carlton", 1, new Vector3f(-73, 153, -11)), + WILSON("Emissary Wilson", 2, new Vector3f(171, 150, 31)), + LILITH("Emissary Lilith", 2, new Vector3f(58, 198, -8)), + FRAISER("Emissary Frasier", 3, new Vector3f(-132, 174, -50)), + ELIZA("Emissary Eliza", 3, new Vector3f(-37, 200, -131)); + + String name; + int minMilestone; + Vector3f loc; + Emissary(String name, int minMilestone, Vector3f loc) { + this.name = name; + this.minMilestone = minMilestone; + this.loc = loc; + } + } + + private long powderGhastMillis = 0; + private String powderGhastLocation = null; + private final String ghastString = "\u00A7r\u00A7eFind the \u00A7r\u00A76Powder Ghast\u00A7r\u00A7e near the \u00A7r\u00A7b"; + + @SubscribeEvent + public void onChat(ClientChatReceivedEvent event) { + if(event.message.getFormattedText().startsWith(ghastString)) { + String sub = event.message.getFormattedText().substring(ghastString.length()); + powderGhastLocation = Utils.cleanColour(sub).replace("!", "").trim(); + powderGhastMillis = System.currentTimeMillis(); + } + } + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + emissaryRemovedDistSq = -1; + + if(SBInfo.getInstance().getLocation() == null) return; + if(!SBInfo.getInstance().getLocation().equals("mining_3")) return; + + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest container = (ContainerChest) chest.inventorySlots; + IInventory lower = container.getLowerChestInventory(); + + if(lower.getDisplayName().getFormattedText().contains("Commissions")) { + for(int i=0; i<lower.getSizeInventory(); i++) { + ItemStack stack = lower.getStackInSlot(i); + if(stack == null) continue; + if(stack.getDisplayName().equals(EnumChatFormatting.YELLOW+"Commission Milestones")) { + NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 5; + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(stack.getTagCompound()); + for(String line : lore) { + String clean = Utils.cleanColour(line); + if(clean.equals("Tier I Rewards:")) { + NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 0; + } else if(clean.equals("Tier II Rewards:")) { + NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 1; + } else if(clean.equals("Tier III Rewards:")) { + NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 2; + } else if(clean.equals("Tier IV Rewards:")) { + NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 3; + } else if(clean.equals("Tier V Rewards:")) { + NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone = 4; + } + } + return; + } + } + } + } + } + + private boolean commissionFinished = false; + private double emissaryRemovedDistSq = 0; + + @SubscribeEvent + public void onRenderSpecial(RenderLivingEvent.Specials.Pre<EntityArmorStand> event) { + if(SBInfo.getInstance().getLocation() == null) return; + if(!SBInfo.getInstance().getLocation().equals("mining_3")) return; + + if(commissionFinished && event.entity instanceof EntityArmorStand) { + String name = event.entity.getDisplayName().getFormattedText(); + if(emissaryRemovedDistSq > 0 && name.equals(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"CLICK"+EnumChatFormatting.RESET)) { + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + double distSq = event.entity.getDistanceSq(p.posX, p.posY, p.posZ); + if(Math.abs(distSq - emissaryRemovedDistSq) < 1) { + event.setCanceled(true); + } + } else if(emissaryNames.contains(name)) { + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + double distSq = event.entity.getDistanceSq(p.posX, p.posY, p.posZ); + if(distSq >= 12*12) { + emissaryRemovedDistSq = distSq; + event.setCanceled(true); + } + } + } + } + + + @SubscribeEvent + public void onRenderLast(RenderWorldLastEvent event) { + if(SBInfo.getInstance().getLocation() == null) return; + if(!SBInfo.getInstance().getLocation().equals("mining_3")) return; + + int locWaypoint = NotEnoughUpdates.INSTANCE.config.mining.locWaypoints; + + if(powderGhastLocation != null && + System.currentTimeMillis() - powderGhastMillis < 30*1000) { + for(Map.Entry<String, Vector3f> entry : waypointsMap.entrySet()) { + if(entry.getKey().equals(powderGhastLocation)) { + renderWayPoint(EnumChatFormatting.GOLD+"Powder Ghast", + new Vector3f(entry.getValue()).translate(0, 5, 0), event.partialTicks); + break; + } + } + } + + if(locWaypoint >= 1) { + for(Map.Entry<String, Vector3f> entry : waypointsMap.entrySet()) { + if(locWaypoint >= 2) { + renderWayPoint(EnumChatFormatting.AQUA+entry.getKey(), entry.getValue(), event.partialTicks); + } else { + for(String commissionName : CommissionOverlay.commissionProgress.keySet()) { + if(commissionName.toLowerCase().contains(entry.getKey().toLowerCase())) { + renderWayPoint(EnumChatFormatting.AQUA+entry.getKey(), entry.getValue(), event.partialTicks); + } + } + } + } + } + + commissionFinished = NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints >= 2; + + if(NotEnoughUpdates.INSTANCE.config.mining.emissaryWaypoints == 0) return; + + if(!commissionFinished) { + for(float f : CommissionOverlay.commissionProgress.values()) { + if (f >= 1) { + commissionFinished = true; + break; + } + } + } + if(commissionFinished) { + for(Emissary emissary : Emissary.values()) { + if(NotEnoughUpdates.INSTANCE.config.hidden.commissionMilestone >= emissary.minMilestone) { + + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + double dX = emissary.loc.x + 0.5f - p.posX; + double dY = emissary.loc.y + 0.188f - p.posY; + double dZ = emissary.loc.z + 0.5f - p.posZ; + + double distSq = dX*dX + dY*dY + dZ*dZ; + if(distSq >= 12*12) { + renderWayPoint(EnumChatFormatting.GOLD+emissary.name, + new Vector3f(emissary.loc).translate(0.5f, 2.488f, 0.5f), + event.partialTicks); + } + } + } + } + } + + + private void renderWayPoint(String str, Vector3f loc, float partialTicks) { + GlStateManager.alphaFunc(516, 0.1F); + + GlStateManager.pushMatrix(); + + Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); + double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks; + double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks; + double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks; + + double x = loc.x-viewerX; + double y = loc.y-viewerY-viewer.getEyeHeight(); + double z = loc.z-viewerZ; + + double distSq = x*x + y*y + z*z; + double dist = Math.sqrt(distSq); + if(distSq > 144) { + x *= 12/dist; + y *= 12/dist; + z *= 12/dist; + } + GlStateManager.translate(x, y, z); + GlStateManager.translate(0, viewer.getEyeHeight(), 0); + + renderNametag(str); + + GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); + GlStateManager.translate(0, -0.25f, 0); + GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); + + renderNametag(EnumChatFormatting.YELLOW.toString()+Math.round(dist)+"m"); + + GlStateManager.popMatrix(); + + GlStateManager.disableLighting(); + } + + private void renderNametag(String str) { + FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj; + float f = 1.6F; + float f1 = 0.016666668F * f; + GlStateManager.pushMatrix(); + GL11.glNormal3f(0.0F, 1.0F, 0.0F); + GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F); + GlStateManager.scale(-f1, -f1, f1); + GlStateManager.disableLighting(); + GlStateManager.depthMask(false); + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + int i = 0; + + int j = fontrenderer.getStringWidth(str) / 2; + GlStateManager.disableTexture2D(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer.pos((double)(-j - 1), (double)(-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); + worldrenderer.pos((double)(-j - 1), (double)(8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); + worldrenderer.pos((double)(j + 1), (double)(8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); + worldrenderer.pos((double)(j + 1), (double)(-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, 553648127); + GlStateManager.depthMask(true); + + fontrenderer.drawString(str, -fontrenderer.getStringWidth(str) / 2, i, -1); + + GlStateManager.enableDepth(); + GlStateManager.enableBlend(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.popMatrix(); + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java index 8edd9217..f567ead5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java @@ -80,7 +80,7 @@ public class ItemCooldowns { } private static Pattern PICKAXE_ABILITY_REGEX = Pattern.compile("\\u00a7r\\u00a7aYou used your " + - "\\u00a7r\\u00a7e.+ \\u00a7r\\u00a7aPickaxe Ability!\\u00a7r"); + "\\u00a7r\\u00a7..+ \\u00a7r\\u00a7aPickaxe Ability!\\u00a7r"); @SubscribeEvent public void onChatMessage(ClientChatReceivedEvent event) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java index d803778b..3e4649be 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/MiningStuff.java @@ -1,6 +1,8 @@ package io.github.moulberry.notenoughupdates.miscfeatures; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; +import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; @@ -10,15 +12,18 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; +import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.init.Blocks; import net.minecraft.network.play.server.S23PacketBlockChange; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.util.vector.Vector3f; import org.lwjgl.util.vector.Vector4f; @@ -28,28 +33,42 @@ public class MiningStuff { private static long titaniumNotifMillis = 0; public static void processBlockChangePacket(S23PacketBlockChange packetIn) { + if(!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) { + return; + } + IBlockState state = packetIn.getBlockState(); if(SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().startsWith("mining_") && state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) { - BlockPos pos = packetIn.getBlockPosition(); - IBlockState existingBlock = Minecraft.getMinecraft().theWorld.getBlockState(pos); - if(existingBlock == null) return; - if(existingBlock.getBlock() == Blocks.stone && existingBlock.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) return; + for(String s : CommissionOverlay.commissionProgress.keySet()) { + if(s.contains("Titanium")) { + BlockPos pos = packetIn.getBlockPosition(); - BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); + IBlockState existingBlock = Minecraft.getMinecraft().theWorld.getBlockState(pos); + if(existingBlock == null) return; + if(existingBlock.getBlock() == Blocks.stone && existingBlock.getValue(BlockStone.VARIANT) == BlockStone.EnumType.DIORITE_SMOOTH) return; - double distSq = pos.distanceSq(player); + BlockPos player = Minecraft.getMinecraft().thePlayer.getPosition(); - if(distSq < 8*8) { - titaniumNotifMillis = System.currentTimeMillis(); + double distSq = pos.distanceSq(player); + + if(distSq < 12*12) { + titaniumNotifMillis = System.currentTimeMillis(); + } + return; + } } } } @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent.Post event) { + if(!NotEnoughUpdates.INSTANCE.config.mining.titaniumAlert) { + return; + } + int delta = (int)(System.currentTimeMillis() - titaniumNotifMillis); int notifLen = 5000; int fadeLen = 500; @@ -88,8 +107,24 @@ public class MiningStuff { } } - public static Vector3f getCreeperColour() { - return new Vector3f(0, 1, 0); + public static void tick() { + if(SBInfo.getInstance().getLocation() == null) return; + if(!SBInfo.getInstance().getLocation().equals("mining_3")) return; + if(Minecraft.getMinecraft().theWorld == null) return; + + for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { + if(entity instanceof EntityCreeper) { + EntityCreeper creeper = (EntityCreeper) entity; + if(creeper.isInvisible() && creeper.getPowered()) { + + BlockPos below = creeper.getPosition().down(); + IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(below); + if(state != null && state.getBlock() == Blocks.stained_glass) { + creeper.setInvisible(!NotEnoughUpdates.INSTANCE.config.mining.revealMistCreepers); + } + } + } + } } @SubscribeEvent @@ -122,6 +157,11 @@ public class MiningStuff { @SubscribeEvent public void onChatRecevied(ClientChatReceivedEvent event) { + if(!NotEnoughUpdates.INSTANCE.config.mining.puzzlerSolver) { + overlayLoc = null; + return; + } + if(event.message.getFormattedText().startsWith("\u00A7e[NPC] \u00A7dPuzzler") && event.message.getUnformattedText().contains(":")) { String clean = Utils.cleanColour(event.message.getUnformattedText()); @@ -149,10 +189,18 @@ public class MiningStuff { } } - public static void blockClicked(BlockPos loc) { + public static boolean blockClicked(BlockPos loc) { if(loc.equals(overlayLoc)) { overlayLoc = null; } + IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(loc); + if(NotEnoughUpdates.INSTANCE.config.mining.dontMineStone && + state != null && SBInfo.getInstance().getLocation() != null && + SBInfo.getInstance().getLocation().startsWith("mining_") && + state.getBlock() == Blocks.stone && state.getValue(BlockStone.VARIANT) == BlockStone.EnumType.STONE) { + return true; + } + return false; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java index c7e01bfa..a6042134 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/AccessoryBagOverlay.java @@ -6,11 +6,9 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; -import io.github.moulberry.notenoughupdates.textoverlays.TextOverlayStyle; 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; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiChest; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java index b821113b..a1565b07 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinPlayerControllerMP.java @@ -1,5 +1,6 @@ package io.github.moulberry.notenoughupdates.mixins; +import io.github.moulberry.notenoughupdates.miscfeatures.DwarvenMinesTextures; import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; import io.github.moulberry.notenoughupdates.miscfeatures.MiningStuff; @@ -14,10 +15,13 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerControllerMP.class) public class MixinPlayerControllerMP { - @Inject(method="clickBlock", at=@At("HEAD")) + @Inject(method="clickBlock", at=@At("HEAD"), cancellable = true) public void clickBlock(BlockPos loc, EnumFacing face, CallbackInfoReturnable<Boolean> cir) { - MiningStuff.blockClicked(loc); ItemCooldowns.blockClicked(loc); + //DwarvenMinesTextures.blockClicked(loc); + if(MiningStuff.blockClicked(loc)) { + cir.setReturnValue(false); + } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java index bedfafc9..4a282d09 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinWorld.java @@ -2,11 +2,15 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscfeatures.CustomItemEffects; +import io.github.moulberry.notenoughupdates.miscfeatures.DwarvenMinesTextures; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(World.class) public class MixinWorld { @@ -22,4 +26,11 @@ public class MixinWorld { } } + @Inject(method="getBiomeGenForCoords", at=@At("HEAD"), cancellable = true) + public void getBiomeGenForCoords(BlockPos pos, CallbackInfoReturnable<BiomeGenBase> cir) { + if(DwarvenMinesTextures.shouldBeRetextured(pos)) { + cir.setReturnValue(BiomeGenBase.extremeHillsEdge); + } + } + } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 163a35f0..44d2faa1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -10,15 +10,12 @@ import io.github.moulberry.notenoughupdates.core.config.Config; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.config.annotations.*; import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; -import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; import io.github.moulberry.notenoughupdates.miscfeatures.CommissionOverlay; -import io.github.moulberry.notenoughupdates.textoverlays.TextOverlay; -import io.github.moulberry.notenoughupdates.textoverlays.TextOverlayStyle; +import io.github.moulberry.notenoughupdates.overlays.TextOverlayStyle; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientCommandHandler; import java.util.ArrayList; -import java.util.regex.Pattern; public class NEUConfig extends Config { @@ -58,6 +55,15 @@ public class NEUConfig extends Config { )); } return; + case 2: + Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( + NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition, + NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12, () -> { + }, () -> { + }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper( + new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config)) + )); + return; } } @@ -755,6 +761,47 @@ public class NEUConfig extends Config { @ConfigEditorBoolean public boolean titaniumAlert = true; + + @Expose + @ConfigOption( + name = "Don't Mine Stone", + desc = "Prevent mining stone blocks in mining areas" + ) + @ConfigEditorBoolean + public boolean dontMineStone = true; + + @Expose + @ConfigOption( + name = "Reveal Mist Creepers", + desc = "Make the creepers in the Dwarven Mines mist visible" + ) + @ConfigEditorBoolean + public boolean revealMistCreepers = true; + + @Expose + @ConfigOption( + name = "Mines Waypoints", + desc = "Show waypoints in the Dwarven mines to the various locations\n" + + "Use \"Commissions Only\" to only show active commission locations" + ) + @ConfigEditorDropdown( + values = {"Hide", "Commissions Only", "Always"}, + initialIndex = 1 + ) + public int locWaypoints = 1; + + @Expose + @ConfigOption( + name = "Emissary Waypoints", + desc = "Show waypoints in the Dwarven mines to emissaries\n" + + "Use \"Commission End\" to only show after finishing commissions" + ) + @ConfigEditorDropdown( + values = {"Hide", "Commission End", "Always"}, + initialIndex = 1 + ) + public int emissaryWaypoints = 1; + @Expose @ConfigOption( name = "Overlay Position", @@ -808,7 +855,36 @@ public class NEUConfig extends Config { @ConfigEditorBoolean public boolean hideEmptyForges = true; + @Expose + @ConfigOption( + name = "Drill Fuel Bar", + desc = "Show a fancy drill fuel bar when holding a drill in mining areas" + ) + @ConfigEditorBoolean + public boolean drillFuelBar = true; + + @Expose + @ConfigOption( + name = "Fuel Bar Width", + desc = "Change the width of the drill fuel bar" + ) + @ConfigEditorSlider( + minValue = 50, + maxValue = 400, + minStep = 10 + ) + public int drillFuelBarWidth = 200; + @Expose + @ConfigOption( + name = "Fuel Bar Position", + desc = "Set the position of the drill fuel bar" + ) + @ConfigEditorButton( + runnableId = 2, + buttonText = "Edit" + ) + public Position drillFuelBarPosition = new Position(0, -100, true, false); } public static class NeuAuctionHouse { @@ -1217,6 +1293,7 @@ public class NEUConfig extends Config { } public static class Hidden { + @Expose public int commissionMilestone = 0; @Expose public boolean enableItemEditing = false; @Expose public boolean cacheRenderedItempane = true; @Expose public boolean autoupdate = true; @@ -1251,7 +1328,7 @@ public class NEUConfig extends Config { @ConfigEditorSlider( minValue = 0, maxValue = 5, - minStep = 1 + minStep = 0.25f ) public int dmBorderSize = 1; @@ -1263,7 +1340,7 @@ public class NEUConfig extends Config { @ConfigEditorSlider( minValue = 0, maxValue = 5, - minStep = 1 + minStep = 0.25f ) public int dmRoomSize = 1; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java new file mode 100644 index 00000000..256026e3 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java @@ -0,0 +1,170 @@ +package io.github.moulberry.notenoughupdates.overlays; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.options.NEUConfig; +import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.util.Random; + +public class FuelBar { + + public static final ResourceLocation FUEL_BAR = new ResourceLocation("notenoughupdates:fuel_bar.png"); + + private float fuelAmount = -1; + private String fuelString = ""; + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + fuelAmount = -1; + + if(SBInfo.getInstance().getLocation() == null) return; + if(!SBInfo.getInstance().getLocation().startsWith("mining_")) return; + + if(Minecraft.getMinecraft().thePlayer == null) return; + if(!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return; + + ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); + if(held != null) { + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); + if(internalname.contains("_DRILL_")) { + String[] lore = NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(held.getTagCompound()); + for(String line : lore) { + try { + if(line.startsWith("\u00A77Fuel: ")) { + String[] split = Utils.cleanColour(line).split("/"); + if(split.length == 2) { + String fuelS = split[0].split(" ")[1]; + int fuel = Integer.parseInt(fuelS.replace(",","").trim()); + + String maxFuelS = split[1].trim(); + int mult = 1; + if(maxFuelS.endsWith("k")) { + mult = 1000; + } + int maxFuel = Integer.parseInt(maxFuelS.replace("k", "").trim())*mult; + fuelAmount = fuel/(float)maxFuel; + if(fuelAmount > 1) { + fuelAmount = 1; + } + fuelString = line; + + break; + } + } + } catch(Exception ignored) {} + } + } + } + } + + @SubscribeEvent + public void onRenderScreen(RenderGameOverlayEvent.Post event) { + if(fuelAmount < 0) return; + if(!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return; + if(event.type == RenderGameOverlayEvent.ElementType.ALL) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + + Position position = NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition; + int x = position.getAbsX(scaledResolution); + int y = position.getAbsY(scaledResolution); + x -= NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth/2; + renderBar(x, y+4, NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, fuelAmount); + + String str = fuelString.replace("\u00A77", EnumChatFormatting.DARK_GREEN.toString()) + + EnumChatFormatting.GOLD + String.format(" (%d%%)", (int)(fuelAmount*100)); + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + + String clean = Utils.cleanColourNotModifiers(str); + for(int xO=-2; xO<=2; xO++) { + for(int yO=-2; yO<=2; yO++) { + if(Math.abs(xO) != Math.abs(yO)) { + Minecraft.getMinecraft().fontRendererObj.drawString(clean, + x+2+xO/2f, y+yO/2f, + new Color(0, 0, 0, 200/Math.max(Math.abs(xO), Math.abs(yO))).getRGB(), false); + } + } + } + Minecraft.getMinecraft().fontRendererObj.drawString(str, + x+2, y, 0xffffff, false); + } + } + + private void renderBarCap(float x, float y, boolean left, float rCapSize, float completion) { + float size = left ? 10 : rCapSize; + int startTexX = left ? 0 : (170 + 11-(int)Math.ceil(rCapSize)); + + if(completion < 1) { + Utils.drawTexturedRect(x, y, size, 5, + startTexX/181f, 1, 0/10f, 5/10f, GL11.GL_NEAREST); + } + if(completion > 0) { + Utils.drawTexturedRect(x, y, size*completion, 5, + startTexX/181f, (startTexX+size*completion)/181f, 5/10f, 10/10f, GL11.GL_NEAREST); + } + } + + private void renderBarNotch(float x, float y, int id, float completion) { + id = id % 16; + + int startTexX = 10 + id*10; + + if(completion < 1) { + Utils.drawTexturedRect(x, y, 10, 5, + startTexX/181f, (startTexX+10)/181f, 0/10f, 5/10f, GL11.GL_NEAREST); + } + if(completion > 0) { + Utils.drawTexturedRect(x, y, 10*completion, 5, + startTexX/181f, (startTexX+10*completion)/181f, 5/10f, 10/10f, GL11.GL_NEAREST); + } + + } + + private void renderBar(float x, float y, float xSize, float completed) { + Minecraft.getMinecraft().getTextureManager().bindTexture(FUEL_BAR); + + GlStateManager.pushMatrix(); + GlStateManager.translate(x, y, 0); + xSize = xSize/1.5f; + GlStateManager.scale(1.5f, 1.5f, 1); + + Color c = Color.getHSBColor(148/360f*completed-20/360f, 0.9f, 1-0.5f*completed); + GlStateManager.color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, 1); + + float offsetCompleteX = xSize*completed; + for(int xOffset = 0; xOffset < xSize; xOffset += 10) { + float notchCompl = 1; + if(xOffset > offsetCompleteX) { + notchCompl = 0; + } else if(xOffset+10 > offsetCompleteX) { + notchCompl = (offsetCompleteX-xOffset)/10f; + } + if(xOffset == 0) { + renderBarCap(0, 0, true, 0, notchCompl); + } else if(xOffset + 11 > xSize) { + renderBarCap(xOffset, 0, false, xSize-xOffset, notchCompl); + } else { + renderBarNotch(xOffset, 0, xOffset/10, notchCompl); + } + } + + GlStateManager.popMatrix(); + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/textoverlays/TextOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java index f111f20a..ed1b6b21 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/textoverlays/TextOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java @@ -1,11 +1,13 @@ -package io.github.moulberry.notenoughupdates.textoverlays; +package io.github.moulberry.notenoughupdates.overlays; import io.github.moulberry.notenoughupdates.core.config.Position; -import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; import java.awt.*; import java.util.List; @@ -66,6 +68,11 @@ public abstract class TextOverlay { if(s == null) { yOff += 3; } else { + + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + if(style == TextOverlayStyle.FULL_SHADOW) { String clean = Utils.cleanColourNotModifiers(s); for(int xO=-2; xO<=2; xO++) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/textoverlays/TextOverlayStyle.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlayStyle.java index 7bd620b6..b9b314d4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/textoverlays/TextOverlayStyle.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlayStyle.java @@ -1,4 +1,4 @@ -package io.github.moulberry.notenoughupdates.textoverlays; +package io.github.moulberry.notenoughupdates.overlays; public enum TextOverlayStyle { 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 bd3fad1b..e52bcc2d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -2092,7 +2092,7 @@ public class GuiProfileViewer extends GuiScreen { float fairySouls = Utils.getElementAsFloat(Utils.getElement(profileInfo, "fairy_souls_collected"), 0); - Utils.renderAlignedString(EnumChatFormatting.LIGHT_PURPLE+"Fairy Souls", EnumChatFormatting.WHITE.toString()+(int)fairySouls+"/209", + Utils.renderAlignedString(EnumChatFormatting.LIGHT_PURPLE+"Fairy Souls", EnumChatFormatting.WHITE.toString()+(int)fairySouls+"/220", guiLeft+xStart, guiTop+yStartBottom, 76); if(skillInfo != null) { float totalSkillLVL = 0; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java index d9d9dd90..12c9a380 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ReverseWorldRenderer.java @@ -71,7 +71,7 @@ public class ReverseWorldRenderer { final float[] afloat = new float[i]; for (int j = 0; j < i; ++j) { - afloat[j] = func_181665_a(this.rawFloatBuffer, (float) ((double) p_181674_1_ + this.xOffset), (float) ((double) p_181674_2_ + this.yOffset), (float) ((double) p_181674_3_ + this.zOffset), this.vertexFormat.func_181719_f(), j * this.vertexFormat.getNextOffset()); + afloat[j] = func_181665_a(this.rawFloatBuffer, (float) ((double) p_181674_1_ + this.xOffset), (float) ((double) p_181674_2_ + this.yOffset), (float) ((double) p_181674_3_ + this.zOffset), this.vertexFormat.getIntegerSize(), j * this.vertexFormat.getNextOffset()); } Integer[] ainteger = new Integer[i]; @@ -130,7 +130,7 @@ public class ReverseWorldRenderer { } private int getBufferSize() { - return this.vertexCount * this.vertexFormat.func_181719_f(); + return this.vertexCount * this.vertexFormat.getIntegerSize(); } private static float func_181665_a(FloatBuffer p_181665_0_, float p_181665_1_, float p_181665_2_, float p_181665_3_, int p_181665_4_, int p_181665_5_) { @@ -181,7 +181,7 @@ public class ReverseWorldRenderer { } public ReverseWorldRenderer tex(double u, double v) { - int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.func_181720_d(this.vertexFormatIndex); + int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); switch (this.vertexFormatElement.getType()) { case FLOAT: @@ -209,7 +209,7 @@ public class ReverseWorldRenderer { } public ReverseWorldRenderer lightmap(int p_181671_1_, int p_181671_2_) { - int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.func_181720_d(this.vertexFormatIndex); + int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); switch (this.vertexFormatElement.getType()) { case FLOAT: @@ -237,7 +237,7 @@ public class ReverseWorldRenderer { } public void putBrightness4(int p_178962_1_, int p_178962_2_, int p_178962_3_, int p_178962_4_) { - int i = (this.vertexCount - 4) * this.vertexFormat.func_181719_f() + this.vertexFormat.getUvOffsetById(1) / 4; + int i = (this.vertexCount - 4) * this.vertexFormat.getIntegerSize() + this.vertexFormat.getUvOffsetById(1) / 4; int j = this.vertexFormat.getNextOffset() >> 2; this.rawIntBuffer.put(i, p_178962_1_); this.rawIntBuffer.put(i + j, p_178962_2_); @@ -246,7 +246,7 @@ public class ReverseWorldRenderer { } public void putPosition(double x, double y, double z) { - int i = this.vertexFormat.func_181719_f(); + int i = this.vertexFormat.getIntegerSize(); int j = (this.vertexCount - 4) * i; for (int k = 0; k < 4; ++k) { @@ -331,7 +331,7 @@ public class ReverseWorldRenderer { if (this.noColor) { return this; } else { - int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.func_181720_d(this.vertexFormatIndex); + int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); switch (this.vertexFormatElement.getType()) { case FLOAT: @@ -379,16 +379,16 @@ public class ReverseWorldRenderer { this.growBuffer(vertexData.length); this.rawIntBuffer.position(this.getBufferSize()); this.rawIntBuffer.put(vertexData); - this.vertexCount += vertexData.length / this.vertexFormat.func_181719_f(); + this.vertexCount += vertexData.length / this.vertexFormat.getIntegerSize(); } public void endVertex() { ++this.vertexCount; - this.growBuffer(this.vertexFormat.func_181719_f()); + this.growBuffer(this.vertexFormat.getIntegerSize()); } public ReverseWorldRenderer pos(double x, double y, double z) { - int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.func_181720_d(this.vertexFormatIndex); + int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); switch (this.vertexFormatElement.getType()) { case FLOAT: @@ -443,7 +443,7 @@ public class ReverseWorldRenderer { } public ReverseWorldRenderer normal(float p_181663_1_, float p_181663_2_, float p_181663_3_) { - int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.func_181720_d(this.vertexFormatIndex); + int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); switch (this.vertexFormatElement.getType()) { case FLOAT: @@ -542,7 +542,7 @@ public class ReverseWorldRenderer { } public int getVertexCount() { - return this.stateRawBuffer.length / this.stateVertexFormat.func_181719_f(); + return this.stateRawBuffer.length / this.stateVertexFormat.getIntegerSize(); } public VertexFormat getVertexFormat() { |