From f0293a74282cece3aa8a2a328559889d6e187209 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sun, 26 Jul 2020 12:12:25 +1000 Subject: 1.11.7 --- src/main/resources/mixins.notenoughupdates.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/resources/mixins.notenoughupdates.json') diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index 49e37916..8f07f5cc 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -5,6 +5,7 @@ "mixins": [ "MixinItemStack", "MixinInventoryEffectRenderer", - "MixinGuiIngame" + "MixinGuiIngame", + "MixinRenderItem" ] } \ No newline at end of file -- cgit From ea1391e0c6f0db863bbb61511eb6e9acb57a5968 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Wed, 19 Aug 2020 12:16:12 +1000 Subject: 1.1.5 --- build.gradle | 2 +- .../notenoughupdates/CustomItemEffects.java | 244 ++++++++++ .../notenoughupdates/NEUEventListener.java | 6 + .../moulberry/notenoughupdates/NEUManager.java | 8 +- .../notenoughupdates/NotEnoughUpdates.java | 42 +- .../notenoughupdates/auction/APIManager.java | 2 +- .../notenoughupdates/auction/CustomAH.java | 39 +- .../notenoughupdates/cosmetics/CapeManager.java | 175 ++++--- .../notenoughupdates/cosmetics/GuiCosmetics.java | 517 +++++++++++++++++++++ .../notenoughupdates/cosmetics/NEUCape.java | 4 +- .../notenoughupdates/gamemodes/SBGamemodes.java | 24 +- .../infopanes/CosmeticsInfoPane.java | 83 ---- .../notenoughupdates/infopanes/HTMLInfoPane.java | 11 +- .../mixins/MixinEntityRenderer.java | 77 +++ .../mixins/MixinNetHandlerPlayClient.java | 26 ++ .../notenoughupdates/mixins/MixinRenderGlobal.java | 69 +++ .../notenoughupdates/options/Options.java | 6 + .../profileviewer/GuiProfileViewer.java | 1 + .../notenoughupdates/util/HypixelApi.java | 29 ++ .../moulberry/notenoughupdates/util/Utils.java | 24 +- .../assets/notenoughupdates/capes/contrib.png | Bin 0 -> 189394 bytes .../assets/notenoughupdates/capes/fade.png | Bin 0 -> 18572 bytes .../assets/notenoughupdates/capes/gravy.png | Bin 0 -> 58330 bytes .../assets/notenoughupdates/capes/nullzee.png | Bin 0 -> 108263 bytes .../assets/notenoughupdates/capes/patreon1.png | Bin 0 -> 46767 bytes .../assets/notenoughupdates/capes/patreon2.png | Bin 0 -> 45479 bytes .../assets/notenoughupdates/capes/testcape.png | Bin 0 -> 21571 bytes .../resources/assets/notenoughupdates/contrib.png | Bin 189394 -> 0 bytes .../assets/notenoughupdates/cosmetics_fg.png | Bin 0 -> 1607 bytes .../resources/assets/notenoughupdates/fade.png | Bin 18572 -> 0 bytes .../resources/assets/notenoughupdates/gravy.png | Bin 58330 -> 0 bytes .../resources/assets/notenoughupdates/nullzee.png | Bin 108263 -> 0 bytes .../resources/assets/notenoughupdates/patreon1.png | Bin 46767 -> 0 bytes .../resources/assets/notenoughupdates/patreon2.png | Bin 45479 -> 0 bytes .../assets/notenoughupdates/pv_elements.png | Bin 2567 -> 4636 bytes .../resources/assets/notenoughupdates/testcape.png | Bin 21571 -> 0 bytes src/main/resources/mixins.notenoughupdates.json | 5 +- 37 files changed, 1217 insertions(+), 177 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/infopanes/CosmeticsInfoPane.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java create mode 100644 src/main/resources/assets/notenoughupdates/capes/contrib.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/fade.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/gravy.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/nullzee.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/patreon1.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/patreon2.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/testcape.png delete mode 100644 src/main/resources/assets/notenoughupdates/contrib.png create mode 100644 src/main/resources/assets/notenoughupdates/cosmetics_fg.png delete mode 100644 src/main/resources/assets/notenoughupdates/fade.png delete mode 100644 src/main/resources/assets/notenoughupdates/gravy.png delete mode 100644 src/main/resources/assets/notenoughupdates/nullzee.png delete mode 100644 src/main/resources/assets/notenoughupdates/patreon1.png delete mode 100644 src/main/resources/assets/notenoughupdates/patreon2.png delete mode 100644 src/main/resources/assets/notenoughupdates/testcape.png (limited to 'src/main/resources/mixins.notenoughupdates.json') diff --git a/build.gradle b/build.gradle index 6670a9a2..84143858 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'com.github.johnrengelman.shadow' sourceCompatibility = 1.8 targetCompatibility = 1.8 -version = "1.1.3-REL" +version = "1.1.4-REL" group= "io.github.moulberry" archivesBaseName = "NotEnoughUpdates" String modid = "notenoughupdates" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java new file mode 100644 index 00000000..500587f5 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java @@ -0,0 +1,244 @@ +package io.github.moulberry.notenoughupdates; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +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.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MovingObjectPosition; +import net.minecraftforge.client.event.DrawBlockHighlightEvent; +import net.minecraftforge.client.event.EntityViewRenderEvent; +import net.minecraftforge.client.event.RenderBlockOverlayEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +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.HashSet; +import java.util.LinkedList; + +public class CustomItemEffects { + + public static final CustomItemEffects INSTANCE = new CustomItemEffects(); + + public int aoteUseTicks = 0; + public int aoteTeleportationTicks = 0; + public Vector3f aoteTeleportationLast = null; + public Vector3f aoteTeleportationCurr = null; + public boolean teleported = false; + public float partialTicks; + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if(aoteTeleportationTicks > 7) aoteTeleportationTicks = 7; + + if(aoteUseTicks > 20 && aoteTeleportationCurr != null && !teleported) { + aoteTeleportationCurr = null; + aoteTeleportationTicks = 0; + } + + if(aoteTeleportationCurr != null && aoteTeleportationTicks > 0) { + aoteUseTicks++; + if(teleported) { + float factor = 1f/aoteTeleportationTicks; + + aoteTeleportationLast = new Vector3f(aoteTeleportationCurr); + + float dX = aoteTeleportationCurr.x - (float)Minecraft.getMinecraft().thePlayer.posX; + float dY = aoteTeleportationCurr.y - (float)Minecraft.getMinecraft().thePlayer.posY; + float dZ = aoteTeleportationCurr.z - (float)Minecraft.getMinecraft().thePlayer.posZ; + + aoteTeleportationCurr.x -= dX*factor; + aoteTeleportationCurr.y -= dY*factor; + aoteTeleportationCurr.z -= dZ*factor; + + aoteTeleportationTicks--; + } else { + aoteTeleportationCurr.x = (float) Minecraft.getMinecraft().thePlayer.posX; + aoteTeleportationCurr.y = (float) Minecraft.getMinecraft().thePlayer.posY; + aoteTeleportationCurr.z = (float) Minecraft.getMinecraft().thePlayer.posZ; + aoteTeleportationLast = new Vector3f(aoteTeleportationCurr); + } + } else { + aoteTeleportationCurr = null; + aoteUseTicks = 0; + teleported = false; + } + } + + public Vector3f getCurrentPosition() { + if(!teleported || aoteTeleportationLast == null || aoteTeleportationCurr == null) return null; + return new Vector3f(aoteTeleportationLast.x + (aoteTeleportationCurr.x - aoteTeleportationLast.x) * partialTicks, + aoteTeleportationLast.y + (aoteTeleportationCurr.y - aoteTeleportationLast.y) * partialTicks, + aoteTeleportationLast.z + (aoteTeleportationCurr.z - aoteTeleportationLast.z) * partialTicks); + } + + @SubscribeEvent + public void renderBlockOverlay(DrawBlockHighlightEvent event) { + if(aoteTeleportationCurr != null && aoteTeleportationTicks > 0 && teleported) { + event.setCanceled(true); + } + 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")) { + int maxWood = 10; + if(heldInternal.equals("TREECAPITATOR_AXE")) maxWood = 35; + + if (event.target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F); + GL11.glLineWidth(2.0F); + GlStateManager.disableTexture2D(); + GlStateManager.depthMask(false); + float f = 0.002F; + //BlockPos blockpos = ; + //Block block = Minecraft.getMinecraft().theWorld.getBlockState(blockpos).getBlock(); + + if(Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()).getBlock() == Blocks.log || + Minecraft.getMinecraft().theWorld.getBlockState(event.target.getBlockPos()).getBlock() == Blocks.log2) { + EntityPlayer player = event.player; + + int woods = 0; + + HashSet candidatesOld = new HashSet<>(); + LinkedList candidates = new LinkedList<>(); + LinkedList candidatesNew = new LinkedList<>(); + + candidatesNew.add(event.target.getBlockPos()); + + while(woods < maxWood) { + if(candidatesNew.isEmpty()) { + break; + } + + candidates.addAll(candidatesNew); + candidatesNew.clear(); + + woods += candidates.size(); + boolean random = woods > maxWood; + + while(!candidates.isEmpty()) { + BlockPos candidate = candidates.pop(); + Block block = Minecraft.getMinecraft().theWorld.getBlockState(candidate).getBlock(); + + 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 != 0 || y != 0 || z != 0) { + BlockPos posNew = candidate.add(x, y, z); + if(!candidatesOld.contains(posNew) && !candidates.contains(posNew) && !candidatesNew.contains(posNew)) { + Block blockNew = Minecraft.getMinecraft().theWorld.getBlockState(posNew).getBlock(); + if(blockNew == Blocks.log || blockNew == Blocks.log2) { + candidatesNew.add(posNew); + } + } + } + } + } + } + + block.setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, candidate); + 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; + + drawSelectionBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate) + .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2), + random ? 0.1f : 0.2f); + } + } + } + + GlStateManager.depthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + } + } + } + + public static void drawSelectionBoundingBox(AxisAlignedBB p_181561_0_, float alpha) { + GlStateManager.color(64/255f, 224/255f, 208/255f, alpha); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + //vertical + worldrenderer.begin(GL11.GL_QUADS, 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(); + tessellator.draw(); + worldrenderer.begin(GL11.GL_QUADS, 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(); + tessellator.draw(); + //x + + worldrenderer.begin(GL11.GL_QUADS, 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_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex(); + worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex(); + tessellator.draw(); + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + 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_.maxY, p_181561_0_.maxZ).endVertex(); + worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex(); + tessellator.draw(); + + //z + worldrenderer.begin(GL11.GL_QUADS, 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_.maxY, p_181561_0_.minZ).endVertex(); + worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex(); + tessellator.draw(); + worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); + worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).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_.maxY, p_181561_0_.maxZ).endVertex(); + tessellator.draw(); + + } + + @SubscribeEvent + public void onPlayerInteract(PlayerInteractEvent event) { + if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR || event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { + ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); + if(held != null) { + String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); + if(internal != null && internal.equals("ASPECT_OF_THE_END")) { + aoteTeleportationTicks += 5; + + if(aoteTeleportationCurr == null) { + aoteTeleportationCurr = new Vector3f(); + aoteTeleportationCurr.x = (float) Minecraft.getMinecraft().thePlayer.posX; + aoteTeleportationCurr.y = (float) Minecraft.getMinecraft().thePlayer.posY; + aoteTeleportationCurr.z = (float) Minecraft.getMinecraft().thePlayer.posZ; + } + + } + } + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index fc7db07b..af23787a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; +import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.gamemodes.SBGamemodes; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; @@ -33,6 +34,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import javax.swing.*; @@ -131,6 +133,7 @@ public class NEUEventListener { } if(longUpdate) { neu.updateSkyblockScoreboard(); + CapeManager.getInstance().tick(); if(neu.hasSkyblockScoreboard()) { lastSkyblockScoreboard = currentTime; if(!joinedSB) { @@ -657,6 +660,9 @@ public class NEUEventListener { */ @SubscribeEvent public void onGuiScreenMouse(GuiScreenEvent.MouseInputEvent.Pre event) { + if(!event.isCanceled()) { + Utils.scrollTooltip(Mouse.getEventDWheel()); + } if(event.gui instanceof CustomAHGui || neu.manager.auctionManager.customAH.isRenderOverAuctionView()) { event.setCanceled(true); neu.manager.auctionManager.customAH.handleMouseInput(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 2cfe9d91..2ae298e2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -464,8 +464,8 @@ public class NEUManager { } URL url = new URL(dlUrl+name); URLConnection urlConnection = url.openConnection(); - urlConnection.setConnectTimeout(3000); - urlConnection.setReadTimeout(3000); + urlConnection.setConnectTimeout(5000); + urlConnection.setReadTimeout(5000); try (BufferedInputStream inStream = new BufferedInputStream(urlConnection.getInputStream()); FileOutputStream fileOutputStream = new FileOutputStream(item)) { byte dataBuffer[] = new byte[1024]; @@ -503,8 +503,8 @@ public class NEUManager { } URL url = new URL(dlUrl); URLConnection urlConnection = url.openConnection(); - urlConnection.setConnectTimeout(3000); - urlConnection.setReadTimeout(3000); + urlConnection.setConnectTimeout(15000); + urlConnection.setReadTimeout(20000); try (BufferedInputStream inStream = new BufferedInputStream(urlConnection.getInputStream()); FileOutputStream fileOutputStream = new FileOutputStream(itemsZip)) { byte dataBuffer[] = new byte[1024]; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 6e01e409..aa604854 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -9,10 +9,10 @@ import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.commands.SimpleCommand; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; +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.CosmeticsInfoPane; import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.questing.GuiQuestLine; @@ -40,8 +40,6 @@ import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.StringUtils; import javax.swing.*; @@ -128,6 +126,37 @@ public class NotEnoughUpdates { } }); + SimpleCommand peekCommand = new SimpleCommand("peek", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + profileViewer.getProfileByName(args[0], profile -> { + if (profile != null) { + profile.resetCache(); + + float overallScore = 0; + + JsonObject profileInfo = profile.getProfileInformation(null); + + JsonObject skill = profile.getSkillInfo(null); + } + }); + } + }, new SimpleCommand.TabCompleteRunnable() { + @Override + public List tabComplete(ICommandSender sender, String[] args, BlockPos pos) { + if (args.length != 1) return null; + + String lastArg = args[args.length - 1]; + List playerMatches = new ArrayList<>(); + for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { + String playerName = player.getName(); + if (playerName.toLowerCase().startsWith(lastArg.toLowerCase())) { + playerMatches.add(playerName); + } + } + return playerMatches; + } + }); + public static ProfileViewer profileViewer; SimpleCommand.ProcessCommandRunnable viewProfileRunnable = new SimpleCommand.ProcessCommandRunnable() { @@ -252,10 +281,7 @@ public class NotEnoughUpdates { SimpleCommand cosmeticsCommand = new SimpleCommand("neucosmetics", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { - if(!(Minecraft.getMinecraft().currentScreen instanceof GuiContainer)) { - openGui = new GuiInventory(Minecraft.getMinecraft().thePlayer); - } - overlay.displayInformationPane(new CosmeticsInfoPane(overlay, manager)); + openGui = new GuiCosmetics(); } }); @@ -288,6 +314,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new NEUEventListener(this)); MinecraftForge.EVENT_BUS.register(CapeManager.getInstance()); MinecraftForge.EVENT_BUS.register(new SBGamemodes()); + MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); File f = new File(event.getModConfigurationDirectory(), "notenoughupdates"); f.mkdirs(); @@ -425,6 +452,7 @@ public class NotEnoughUpdates { long currentTime = System.currentTimeMillis(); if (openGui != null) { + Minecraft.getMinecraft().thePlayer.closeScreen(); Minecraft.getMinecraft().displayGuiScreen(openGui); openGui = 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 de03baa9..457c06d0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -309,7 +309,7 @@ public class APIManager { getPageFromAPI(0); } - manager.hypixelApi.getApiGZIPAsync("http://moulberry.codes/auction.json.gz", jsonObject -> { + manager.hypixelApi.getMyApiGZIPAsync("auction.json.gz", jsonObject -> { if(jsonObject.get("success").getAsBoolean()) { long apiUpdate = (long)jsonObject.get("time").getAsFloat(); if(lastApiUpdate == apiUpdate) { 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 3780db3d..817c9e96 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -1,6 +1,7 @@ package io.github.moulberry.notenoughupdates.auction; import io.github.moulberry.notenoughupdates.NEUManager; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -405,13 +406,12 @@ public class CustomAH extends Gui { return -1; } - public String findEndsInStr(ItemStack stack) { + public String findStrStart(ItemStack stack, String toFind) { if(stack.hasTagCompound()) { //ยง7Ends in: - String endsIn = EnumChatFormatting.GRAY+"Ends in: "; for(String line : manager.getLoreFromNBT(stack.getTagCompound())) { - if(line.trim().startsWith(endsIn)) { - return line.substring(endsIn.length()); + if(line.trim().startsWith(toFind)) { + return line.substring(toFind.length()); } } } @@ -419,6 +419,10 @@ public class CustomAH extends Gui { return null; } + public String findEndsInStr(ItemStack stack) { + return findStrStart(stack, EnumChatFormatting.GRAY+"Ends in: "); + } + public void drawScreen(int mouseX, int mouseY) { if(System.currentTimeMillis() - lastOpen < 1000) Mouse.setGrabbed(false); @@ -522,7 +526,11 @@ public class CustomAH extends Gui { if(mouseX > auctionViewLeft+31 && mouseX guiTop+35 && mouseY < guiTop+35+16) { - if(topStack != null) tooltipToRender = topStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + if(topStack != null) { + tooltipToRender = topStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); + tooltipToRender.add(""); + tooltipToRender.add(EnumChatFormatting.YELLOW+"Click to copy seller name!"); + } } else if(mouseY > guiTop+100 && mouseY < guiTop+100+16) { if(leftStack != null) tooltipToRender = leftStack.getTooltip(Minecraft.getMinecraft().thePlayer, false); } else if(mouseY > guiTop+61 && mouseY < guiTop+61+16) { @@ -916,11 +924,13 @@ public class CustomAH extends Gui { mouseClickMove(mouseX, mouseY, this.eventButton, l); } - int dWheel = Mouse.getEventDWheel(); - dWheel = Math.max(-1, Math.min(1, dWheel)); + if(!manager.config.disableAhScroll.value) { + int dWheel = Mouse.getEventDWheel(); + dWheel = Math.max(-1, Math.min(1, dWheel)); - scrollAmount = scrollAmount - dWheel/(float)(auctionIds.size()/9-(5+splits)); - scrollAmount = Math.max(0, Math.min(1, scrollAmount)); + scrollAmount = scrollAmount - dWheel/(float)(auctionIds.size()/9-(5+splits)); + scrollAmount = Math.max(0, Math.min(1, scrollAmount)); + } } private String niceAucId(String aucId) { @@ -1362,7 +1372,16 @@ public class CustomAH extends Gui { if(containerName.trim().equals("Auction View") || containerName.trim().equals("BIN Auction View")) { if(mouseX > guiLeft+getXSize()+4+31 && mouseX < guiLeft+getXSize()+4+31+16) { boolean leftFiller = isGuiFiller(auctionView.inventorySlots.getSlot(29).getStack());//isBin - if(mouseY > guiTop+100 && mouseY < guiTop+100+16) { + if(mouseY > guiTop+35 && mouseY < guiTop+35+16) { + ItemStack topStack = auctionView.inventorySlots.getSlot(13).getStack(); + if(topStack != null) { + String line = findStrStart(topStack, EnumChatFormatting.GRAY+"Seller: "); + String[] split = line.split(" "); + String seller = split[split.length-1]; + StringSelection selection = new StringSelection(seller); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); + } + } else if(mouseY > guiTop+100 && mouseY < guiTop+100+16) { int slotClick = leftFiller ? 31 : 29; Minecraft.getMinecraft().playerController.windowClick(auctionView.inventorySlots.windowId, slotClick, 2, 3, Minecraft.getMinecraft().thePlayer); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java index e78d078c..906ccda4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -1,7 +1,10 @@ package io.github.moulberry.notenoughupdates.cosmetics; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.HypixelApi; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.client.event.RenderPlayerEvent; @@ -11,6 +14,7 @@ import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; +import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Set; @@ -18,28 +22,94 @@ import java.util.Set; public class CapeManager { public static final CapeManager INSTANCE = new CapeManager(); + public long lastCapeUpdate = 0; + public long lastCapeSynced = 0; + public Pair localCape = null; private HashMap> capeMap = new HashMap<>(); - private String[] capes = new String[]{"patreon1", "patreon2", "gravy", "fade", "contrib"}; + + private boolean allAvailable = false; + private HashSet availableCapes = new HashSet<>(); + + private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", "gravy" }; + public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true }; public static CapeManager getInstance() { return INSTANCE; } - public void setCape(String player, String capename) { - if(capename == null) { - NotEnoughUpdates.INSTANCE.manager.config.selectedCape.value = ""; - capeMap.remove(player); - return; + public void tick() { + long currentTime = System.currentTimeMillis(); + if(currentTime - lastCapeUpdate > 60*1000) { + lastCapeUpdate = currentTime; + updateCapes(); } - if(player.equalsIgnoreCase(Minecraft.getMinecraft().thePlayer.getName())) { - NotEnoughUpdates.INSTANCE.manager.config.selectedCape.value = capename; + } + + private void updateCapes() { + NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/getactivecape.py", (jsonObject) -> { + if(jsonObject.get("success").getAsBoolean()) { + lastCapeSynced = System.currentTimeMillis(); + for(JsonElement active : jsonObject.get("active").getAsJsonArray()) { + if(active.isJsonObject()) { + JsonObject activeObj = (JsonObject) active; + setCape(activeObj.get("_id").getAsString(), activeObj.get("capeType").getAsString(), false); + } + } + } + }, () -> { + System.out.println("[MBAPI] Update capes errored"); + }); + if(Minecraft.getMinecraft().thePlayer != null) { + NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/getpermscape.py?uuid="+ + Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), (jsonObject) -> { + if(jsonObject.get("success").getAsBoolean()) { + availableCapes.clear(); + for(JsonElement perm : jsonObject.get("perms").getAsJsonObject().get("perms").getAsJsonArray()) { + if(perm.isJsonPrimitive()) { + String cape = perm.getAsString(); + if(cape.equals("*")) { + allAvailable = true; + } else { + availableCapes.add(cape); + } + } + } + } + }, () -> { + System.out.println("[MBAPI] Update capes errored - perms"); + }); } - if(capeMap.containsKey(player)) { - Pair capePair = capeMap.get(player); - capePair.setValue(capename); - } else { - capeMap.put(player, new MutablePair<>(new NEUCape(capename), capename)); + } + + public HashSet getAvailableCapes() { + return allAvailable ? availableCapes : availableCapes; + } + + public void setCape(String playerUUID, String capename, boolean updateConfig) { + boolean none = capename == null || capename.equals("null"); + + updateConfig = updateConfig && playerUUID.equals(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")); + if(updateConfig) { + NotEnoughUpdates.INSTANCE.manager.config.selectedCape.value = String.valueOf(capename); + try { NotEnoughUpdates.INSTANCE.manager.saveConfig(); } catch(IOException ignored) {} + } + + if(updateConfig) { + if(none) { + localCape = null; + } else { + localCape = new MutablePair<>(new NEUCape(capename), capename); + } + } else if(capeMap.containsKey(playerUUID)) { + if(none) { + capeMap.remove(playerUUID); + } else { + Pair capePair = capeMap.get(playerUUID); + capePair.setValue(capename); + } + } else if(!none) { + capeMap.put(playerUUID, new MutablePair<>(new NEUCape(capename), capename)); } } @@ -50,10 +120,10 @@ public class CapeManager { return null; } - public EntityPlayer getPlayerForName(String name) { + public EntityPlayer getPlayerForUUID(String uuid) { if(Minecraft.getMinecraft().theWorld != null) { for(EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { - if(player.getName().equals(name)) { + if(player.getUniqueID().toString().replace("-", "").equals(uuid)) { return player; } } @@ -63,38 +133,55 @@ public class CapeManager { @SubscribeEvent public void onRenderPlayer(RenderPlayerEvent.Post e) { - //if(e.partialRenderTick == 1.0F) return; //rendering in inventory - if(Minecraft.getMinecraft().thePlayer != null && - e.entityPlayer.getName().equals(Minecraft.getMinecraft().thePlayer.getName())) { - if(NotEnoughUpdates.INSTANCE.manager.config.selectedCape.value != null && - !NotEnoughUpdates.INSTANCE.manager.config.selectedCape.value.isEmpty()) { - setCape(Minecraft.getMinecraft().thePlayer.getName(), - NotEnoughUpdates.INSTANCE.manager.config.selectedCape.value); + if(e.partialRenderTick == 1.0F) return; //rendering in inventory + + String uuid = e.entityPlayer.getUniqueID().toString().replace("-", ""); + String clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""); + + if(Minecraft.getMinecraft().thePlayer != null && uuid.equals(clientUuid)) { + String selCape = NotEnoughUpdates.INSTANCE.manager.config.selectedCape.value; + if(selCape != null && !selCape.isEmpty()) { + if(localCape == null) { + localCape = new MutablePair<>(new NEUCape(selCape), selCape); + } else { + localCape.setValue(selCape); + } } } - if(e.entityPlayer.getName().equals("Moulberry")) setCape(e.entityPlayer.getName(), "fade"); - if(capeMap.containsKey(e.entityPlayer.getName())) { - capeMap.get(e.entityPlayer.getName()).getLeft().onRenderPlayer(e); + if(uuid.equals(clientUuid) && localCape != null && localCape.getRight() != null && !localCape.getRight().equals("null")) { + localCape.getLeft().onRenderPlayer(e); + } else if(capeMap.containsKey(uuid)) { + capeMap.get(uuid).getLeft().onRenderPlayer(e); } } @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { + String clientUuid = null; + if(Minecraft.getMinecraft().thePlayer != null) { + clientUuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""); + } + Set toRemove = new HashSet<>(); - for(String playerName : capeMap.keySet()) { - EntityPlayer player = getPlayerForName(playerName); - if(player == null) { - toRemove.add(playerName); - } else { - String capeName = capeMap.get(playerName).getRight(); - if(capeName != null) { - capeMap.get(playerName).getLeft().setCapeTexture(capeName); - capeMap.get(playerName).getLeft().onTick(event, player); + for(String playerUUID : capeMap.keySet()) { + EntityPlayer player = getPlayerForUUID(playerUUID); + if(player != null) { + String capeName = capeMap.get(playerUUID).getRight(); + if(capeName != null && !capeName.equals("null")) { + if(playerUUID.equals(clientUuid) && localCape != null && localCape.getRight() != null && !localCape.getRight().equals("null")) { + continue; + } + capeMap.get(playerUUID).getLeft().setCapeTexture(capeName); + capeMap.get(playerUUID).getLeft().onTick(event, player); } else { - toRemove.add(playerName); + toRemove.add(playerUUID); } } } + if(localCape != null) { + localCape.getLeft().setCapeTexture(localCape.getValue()); + localCape.getLeft().onTick(event, Minecraft.getMinecraft().thePlayer); + } for(String playerName : toRemove) { capeMap.remove(playerName); } @@ -104,22 +191,6 @@ public class CapeManager { return capes; } - private String[] contributors = new String[]{"thatgravyboat", "twasnt", "traxyrr", "some1sm", "meguminqt", "marethyu_77"}; - - public boolean getPermissionForCape(String player, String capename) { - if(capename == null) { - return false; - } else if(player.equalsIgnoreCase("Moulberry")) { - return true; //Oh yeah gimme gimme - } else { - switch(capename) { - case "nullzee": return player.equalsIgnoreCase("Nullzee"); - case "gravy": return player.equalsIgnoreCase("ThatGravyBoat"); - case "contrib": return ArrayUtils.contains(contributors, player.toLowerCase()); - case "fade": return true; - } - } - return false; - } + //private String[] contributors = new String[]{"thatgravyboat", "twasnt", "traxyrr", "some1sm", "meguminqt", "marethyu_77"}; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java new file mode 100644 index 00000000..f9c4995e --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java @@ -0,0 +1,517 @@ +package io.github.moulberry.notenoughupdates.cosmetics; + +import com.google.common.base.Splitter; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.SBAIntegration; +import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; +import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; +import io.github.moulberry.notenoughupdates.profileviewer.Panorama; +import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; +import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; +import io.github.moulberry.notenoughupdates.questing.SBScoreboardData; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.DefaultPlayerSkin; +import net.minecraft.client.resources.SkinManager; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.client.shader.Shader; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EnumPlayerModelParts; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagByteArray; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.Matrix4f; +import net.minecraft.util.ResourceLocation; +import org.apache.commons.lang3.text.WordUtils; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; +import org.lwjgl.opengl.GL20; + +import java.awt.*; +import java.io.IOException; +import java.text.NumberFormat; +import java.util.List; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class GuiCosmetics extends GuiScreen { + + public static final ResourceLocation pv_bg = new ResourceLocation("notenoughupdates:pv_bg.png"); + public static final ResourceLocation pv_dropdown = new ResourceLocation("notenoughupdates:pv_dropdown.png"); + public static final ResourceLocation cosmetics_fg = new ResourceLocation("notenoughupdates:cosmetics_fg.png"); + public static final ResourceLocation pv_elements = new ResourceLocation("notenoughupdates:pv_elements.png"); + + private static final NumberFormat numberFormat = NumberFormat.getInstance(Locale.US); + + private CosmeticsPage currentPage = CosmeticsPage.CAPES; + private int sizeX; + private int sizeY; + private int guiLeft; + private int guiTop; + + private String wantToEquipCape = null; + private long lastCapeEquip = 0; + + private List tooltipToDisplay = null; + + public enum CosmeticsPage { + CAPES(new ItemStack(Items.chainmail_chestplate)); + + public final ItemStack stack; + + CosmeticsPage(ItemStack stack) { + this.stack = stack; + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + this.sizeX = 431; + this.sizeY = 202; + this.guiLeft = (this.width-this.sizeX)/2; + this.guiTop = (this.height-this.sizeY)/2; + + super.drawScreen(mouseX, mouseY, partialTicks); + drawDefaultBackground(); + + blurBackground(); + renderBlurredBackground(width, height, guiLeft+2, guiTop+2, sizeX-4, sizeY-4); + + GlStateManager.enableDepth(); + GlStateManager.translate(0, 0, 5); + renderTabs(true); + GlStateManager.translate(0, 0, -3); + + GlStateManager.disableDepth(); + GlStateManager.translate(0, 0, -2); + renderTabs(false); + GlStateManager.translate(0, 0, 2); + + GlStateManager.disableLighting(); + GlStateManager.enableDepth(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.enableAlpha(); + GlStateManager.alphaFunc(516, 0.1F); + + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg); + Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); + + GlStateManager.color(1, 1, 1, 1); + switch (currentPage) { + case CAPES: + drawCapesPage(mouseX, mouseY, partialTicks); + break; + } + + if(tooltipToDisplay != null) { + List grayTooltip = new ArrayList<>(tooltipToDisplay.size()); + for(String line : tooltipToDisplay) { + grayTooltip.add(EnumChatFormatting.GRAY + line); + } + Utils.drawHoveringText(grayTooltip, mouseX, mouseY, width, height, -1, Minecraft.getMinecraft().fontRendererObj); + tooltipToDisplay = null; + } + + StringBuilder statusMsg = new StringBuilder("Last Sync: "); + if(CapeManager.INSTANCE.lastCapeSynced == 0) { + statusMsg.append("Not Synced"); + } else { + statusMsg.append((System.currentTimeMillis() - CapeManager.INSTANCE.lastCapeSynced)/1000).append("s ago"); + } + statusMsg.append(" - Next Sync: "); + if(CapeManager.INSTANCE.lastCapeUpdate == 0) { + statusMsg.append("ASAP"); + } else { + statusMsg.append(60 - (System.currentTimeMillis() - CapeManager.INSTANCE.lastCapeUpdate)/1000).append("s"); + } + + Minecraft.getMinecraft().fontRendererObj.drawString(EnumChatFormatting.AQUA+statusMsg.toString(), + guiLeft+sizeX-Minecraft.getMinecraft().fontRendererObj.getStringWidth(statusMsg.toString()), guiTop-12, 0, true); + + if(currentPage == CosmeticsPage.CAPES && wantToEquipCape != null) { + GlStateManager.color(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown); + Utils.drawTexturedRect(guiLeft+sizeX/2f-50, guiTop+sizeY+5, 100, 20, 0, 100/200f, 0, 20/185f, GL11.GL_NEAREST); + + String equipMsg = EnumChatFormatting.GREEN + "Equip Cape"; + if(System.currentTimeMillis() - lastCapeEquip < 20*1000) { + equipMsg += " - " + (20 - (System.currentTimeMillis() - lastCapeEquip)/1000) + "s"; + } + + Utils.drawStringCenteredScaledMaxWidth(equipMsg, Minecraft.getMinecraft().fontRendererObj, + guiLeft+sizeX/2f, guiTop+sizeY+5+10, false, 90, 0); + } + } + + private void renderTabs(boolean renderPressed) { + int ignoredTabs = 0; + for(int i = 0; i< CosmeticsPage.values().length; i++) { + CosmeticsPage page = CosmeticsPage.values()[i]; + if(page.stack == null) { + ignoredTabs++; + continue; + } + boolean pressed = page == currentPage; + if(pressed == renderPressed) { + renderTab(page.stack, i-ignoredTabs, pressed); + } + } + } + + private void renderTab(ItemStack stack, int xIndex, boolean pressed) { + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.enableAlpha(); + GlStateManager.alphaFunc(516, 0.1F); + + int x = guiLeft+xIndex*28; + int y = guiTop-28; + + float uMin = 0; + float uMax = 28/256f; + float vMin = 20/256f; + float vMax = 51/256f; + if(pressed) { + vMin = 52/256f; + vMax = 84/256f; + + if(xIndex != 0) { + uMin = 28/256f; + uMax = 56/256f; + } + + renderBlurredBackground(width, height, x+2, y+2, 28-4, 28-4); + } else { + renderBlurredBackground(width, height, x+2, y+4, 28-4, 28-4); + } + + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.enableAlpha(); + GlStateManager.alphaFunc(516, 0.1F); + + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + Utils.drawTexturedRect(x, y, 28, pressed?32:31, uMin, uMax, vMin, vMax, GL11.GL_NEAREST); + + GlStateManager.enableDepth(); + Utils.drawItemStack(stack, x+6, y+9); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { + for (int i = 0; i < CosmeticsPage.values().length; i++) { + CosmeticsPage page = CosmeticsPage.values()[i]; + int x = guiLeft + i * 28; + int y = guiTop - 28; + + if (mouseX > x && mouseX < x + 28) { + if (mouseY > y && mouseY < y + 32) { + if (currentPage != page) Utils.playPressSound(); + currentPage = page; + return; + } + } + } + if(mouseY > guiTop+177 && mouseY < guiTop+177+12) { + if(mouseX > guiLeft+15+371*scroll && mouseX < guiLeft+15+371*scroll+32) { + scrollClickedX = mouseX - (int)(guiLeft+15+371*scroll); + return; + } + } + + int index = 0; + int displayingCapes = 0; + for(String cape : CapeManager.INSTANCE.getCapes()) { + boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || CapeManager.INSTANCE.getAvailableCapes().contains(cape); + if (!CapeManager.INSTANCE.specialCapes[index++] || equipable) { + displayingCapes++; + } + } + + float totalNeeded = 91*displayingCapes; + float totalAvail = sizeX-20; + float xOffset = scroll*(totalNeeded-totalAvail); + + index = 0; + int displayIndex = 0; + for(String cape : CapeManager.INSTANCE.getCapes()) { + boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || CapeManager.INSTANCE.getAvailableCapes().contains(cape); + if(CapeManager.INSTANCE.specialCapes[index++] && !equipable) continue; + + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(guiLeft + 20 + 91 * displayIndex - xOffset, guiTop + 123, 81, 20, + 0, 81 / 256f, 216 / 256f, 236 / 256f, GL11.GL_NEAREST); + + if(mouseX > guiLeft + 20 + 91 * displayIndex - xOffset && mouseX < guiLeft + 20 + 91 * displayIndex - xOffset+81) { + if(mouseY > guiTop + 123 && mouseY < guiTop + 123 + 20) { + if(CapeManager.INSTANCE.localCape != null && CapeManager.INSTANCE.localCape.getRight().equals(cape)) { + CapeManager.INSTANCE.setCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), + "null", true); + } else { + CapeManager.INSTANCE.setCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), + cape, true); + } + + return; + } else if(equipable && mouseY > guiTop + 149 && mouseY < guiTop + 149 + 20) { + wantToEquipCape = cape; + return; + } + } + + displayIndex++; + } + + if(currentPage == CosmeticsPage.CAPES && wantToEquipCape != null) { + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_dropdown); + Utils.drawTexturedRect(guiLeft+sizeX/2f-50, guiTop+sizeY+5, 100, 20, 0, 100/200f, 0, 20/185f, GL11.GL_NEAREST); + + if(mouseX > guiLeft+sizeX/2f-50 && mouseX < guiLeft+sizeX/2f+50) { + if(mouseY > guiTop+sizeY+5 && mouseY < guiTop+sizeY+25) { + if(System.currentTimeMillis() - lastCapeEquip > 20*1000) { + lastCapeEquip = System.currentTimeMillis(); + NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/changecape.py?capeType="+wantToEquipCape+"&accessToken="+ + Minecraft.getMinecraft().getSession().getToken(), (jsonObject) -> {}, () -> {}); + } + } + } + } + } + + @Override + protected void mouseReleased(int mouseX, int mouseY, int state) { + super.mouseReleased(mouseX, mouseY, state); + + scrollClickedX = -1; + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + + if(scrollClickedX >= 0) { + float scrollStartX = mouseX - scrollClickedX; + scroll = (scrollStartX-(guiLeft+15))/371f; + scroll = Math.max(0, Math.min(1, scroll)); + } + } + + private HashMap capesLocation = new HashMap<>(); + private float scroll = 0f; + private int scrollClickedX = -1; + private void drawCapesPage(int mouseX, int mouseY, float partialTicks) { + Minecraft.getMinecraft().getTextureManager().bindTexture(cosmetics_fg); + Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); + + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + Utils.drawTexturedRect(guiLeft+15+371*scroll, guiTop+177, 32, 12, + 0, 32/256f, 192/256f, 204/256f, GL11.GL_NEAREST); + + GL11.glEnable(GL11.GL_SCISSOR_TEST); + GL11.glScissor(Minecraft.getMinecraft().displayWidth*(guiLeft+3)/width, 0, + Minecraft.getMinecraft().displayWidth*(sizeX-6)/width, Minecraft.getMinecraft().displayHeight); + + int index = 0; + int displayingCapes = 0; + for(String cape : CapeManager.INSTANCE.getCapes()) { + boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || CapeManager.INSTANCE.getAvailableCapes().contains(cape); + if (!CapeManager.INSTANCE.specialCapes[index++] || equipable) { + displayingCapes++; + } + } + + float totalNeeded = 91*displayingCapes; + float totalAvail = sizeX-20; + float xOffset = scroll*(totalNeeded-totalAvail); + + index = 0; + int displayIndex = 0; + for(String cape : CapeManager.INSTANCE.getCapes()) { + boolean equipable = CapeManager.INSTANCE.getAvailableCapes() == null || CapeManager.INSTANCE.getAvailableCapes().contains(cape); + if(CapeManager.INSTANCE.specialCapes[index++] && !equipable) continue; + + if(cape.equals(CapeManager.INSTANCE.getCape(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")))) { + GlStateManager.color(250 / 255f, 200 / 255f, 0 / 255f, 1); + Utils.drawGradientRect(guiLeft + 20 + 91 * displayIndex - (int) xOffset, guiTop + 10, + guiLeft + 20 + 91 * displayIndex - (int) xOffset + 81, guiTop + 10 + 108, + new Color(150, 100, 0, 40).getRGB(), new Color(250, 200, 0, 40).getRGB()); + } else if(cape.equals(wantToEquipCape)) { + GlStateManager.color(0, 200 / 255f, 250 / 255f, 1); + Utils.drawGradientRect(guiLeft + 20 + 91 * displayIndex - (int) xOffset, guiTop + 10, + guiLeft + 20 + 91 * displayIndex - (int) xOffset + 81, guiTop + 10 + 108, + new Color(0, 100, 150, 40).getRGB(), new Color(0, 200, 250, 40).getRGB()); + } else if(CapeManager.INSTANCE.localCape != null && CapeManager.INSTANCE.localCape.getRight().equals(cape)) { + GlStateManager.color(100/255f, 250/255f, 150/255f, 1); + Utils.drawGradientRect(guiLeft+20+91*displayIndex-(int)xOffset, guiTop+10, + guiLeft+20+91*displayIndex-(int)xOffset+81, guiTop+10+108, + new Color(50, 100, 75, 40).getRGB(), new Color(100, 250, 150, 40).getRGB()); + } + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + Utils.drawTexturedRect(guiLeft+20+91*displayIndex-xOffset, guiTop+10, 81, 108, + 0, 81/256f, 84/256f, 192/256f, GL11.GL_NEAREST); + GlStateManager.color(1, 1, 1, 1); + + Utils.drawTexturedRect(guiLeft+20+91*displayIndex-xOffset, guiTop+123, 81, 20, + 0, 81/256f, 216/256f, 236/256f, GL11.GL_NEAREST); + + boolean equipPressed = cape.equals(wantToEquipCape); + if(!equipable) GlStateManager.color(1, 1, 1, 0.5f); + Utils.drawTexturedRect(guiLeft+20+91*displayIndex-xOffset, guiTop+149, 81, 20, + equipPressed?81/256f:0, equipPressed?0:81/256f, equipPressed?236/256f:216/256f, equipPressed?216/256f:236/256f, GL11.GL_NEAREST); + + Utils.drawStringCenteredScaledMaxWidth("Try it out", Minecraft.getMinecraft().fontRendererObj, + guiLeft+20+91*displayIndex+81/2f-xOffset, guiTop+123+10, false, 75, new Color(100, 250, 150).getRGB()); + if(equipable) { + Utils.drawStringCenteredScaledMaxWidth("Equip", Minecraft.getMinecraft().fontRendererObj, + guiLeft+20+91*displayIndex+81/2f-xOffset, guiTop+149+10, false, 75, new Color(100, 250, 150).getRGB()); + } else { + Utils.drawStringCenteredScaledMaxWidth("Not Unlocked", Minecraft.getMinecraft().fontRendererObj, + guiLeft+20+91*displayIndex+81/2f-xOffset, guiTop+149+10, false, 75, new Color(200, 50, 50, 100).getRGB()); + } + GlStateManager.color(1, 1, 1, 1); + + ResourceLocation capeTexture = capesLocation.computeIfAbsent(cape, k -> new ResourceLocation("notenoughupdates", "capes/"+cape+".png")); + Minecraft.getMinecraft().getTextureManager().bindTexture(capeTexture); + Utils.drawTexturedRect(guiLeft+31+91*displayIndex-xOffset, guiTop+24, 59, 84, + 0, 293/1024f, 0, 420/1024f, GL11.GL_NEAREST); + + displayIndex++; + } + + GL11.glScissor(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + + Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); + } + + Shader blurShaderHorz = null; + Framebuffer blurOutputHorz = null; + Shader blurShaderVert = null; + Framebuffer blurOutputVert = null; + + /** + * Creates a projection matrix that projects from our coordinate space [0->width; 0->height] to OpenGL coordinate + * space [-1 -> 1; 1 -> -1] (Note: flipped y-axis). + * + * This is so that we can render to and from the framebuffer in a way that is familiar to us, instead of needing to + * apply scales and translations manually. + */ + private Matrix4f createProjectionMatrix(int width, int height) { + Matrix4f projMatrix = new Matrix4f(); + projMatrix.setIdentity(); + projMatrix.m00 = 2.0F / (float)width; + projMatrix.m11 = 2.0F / (float)(-height); + projMatrix.m22 = -0.0020001999F; + projMatrix.m33 = 1.0F; + projMatrix.m03 = -1.0F; + projMatrix.m13 = 1.0F; + projMatrix.m23 = -1.0001999F; + return projMatrix; + } + + /** + * Renders whatever is currently in the Minecraft framebuffer to our two framebuffers, applying a horizontal + * and vertical blur separately in order to significantly save computation time. + * This is only possible if framebuffers are supported by the system, so this method will exit prematurely + * if framebuffers are not available. (Apple machines, for example, have poor framebuffer support). + */ + private double lastBgBlurFactor = -1; + private void blurBackground() { + int width = Minecraft.getMinecraft().displayWidth; + int height = Minecraft.getMinecraft().displayHeight; + + if(blurOutputHorz == null) { + blurOutputHorz = new Framebuffer(width, height, false); + blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST); + } + if(blurOutputVert == null) { + blurOutputVert = new Framebuffer(width, height, false); + blurOutputVert.setFramebufferFilter(GL11.GL_NEAREST); + } + if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) { + blurOutputHorz.createBindFramebuffer(width, height); + blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); + } + if(blurOutputVert.framebufferWidth != width || blurOutputVert.framebufferHeight != height) { + blurOutputVert.createBindFramebuffer(width, height); + blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); + } + + if(blurShaderHorz == null) { + try { + blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", + Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); + blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); + blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); + } catch(Exception e) { } + } + if(blurShaderVert == null) { + try { + blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", + blurOutputHorz, blurOutputVert); + blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); + blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); + } catch(Exception e) { } + } + if(blurShaderHorz != null && blurShaderVert != null) { + if(15 != lastBgBlurFactor) { + blurShaderHorz.getShaderManager().getShaderUniform("Radius").set((float)15); + blurShaderVert.getShaderManager().getShaderUniform("Radius").set((float)15); + lastBgBlurFactor = 15; + } + GL11.glPushMatrix(); + blurShaderHorz.loadShader(0); + blurShaderVert.loadShader(0); + GlStateManager.enableDepth(); + GL11.glPopMatrix(); + + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); + } + } + + /** + * Renders a subsection of the blurred framebuffer on to the corresponding section of the screen. + * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] + */ + public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) { + float uMin = x/(float)width; + float uMax = (x+blurWidth)/(float)width; + float vMin = (height-y)/(float)height; + float vMax = (height-y-blurHeight)/(float)height; + + blurOutputVert.bindFramebufferTexture(); + GlStateManager.color(1f, 1f, 1f, 1f); + //Utils.setScreen(width*f, height*f, f); + Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax); + //Utils.setScreen(width, height, f); + blurOutputVert.unbindFramebufferTexture(); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java index 9848f495..985bc14c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java @@ -62,7 +62,7 @@ public class NEUCape { } else { shaderName = "cape"; } - capeTex = new ResourceLocation("notenoughupdates:"+capeName+".png"); + capeTex = new ResourceLocation("notenoughupdates:capes/"+capeName+".png"); startTime = System.currentTimeMillis(); } } @@ -229,8 +229,6 @@ public class NEUCape { if(currentPlayer != null && currentPlayer != player) return; - if(e.partialRenderTick == 1) return; - if(player.getActivePotionEffect(Potion.invisibility) != null) return; if(player.isSpectator() || player.isInvisible()) return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java index cdda9957..de8fe562 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java @@ -231,17 +231,19 @@ public class SBGamemodes { if(!"Your Island".equals(SBScoreboardData.getInstance().location)) return; - if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { - if(Math.abs(event.pos.getX()) > 40 || Math.abs(event.pos.getZ()) > 40) { - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.YELLOW+"[NPC] Builder"+ - EnumChatFormatting.WHITE+": Sorry, "+Minecraft.getMinecraft().thePlayer.getName()+ - ", due to budget cuts your skyblock island is now only 80 blocks wide.")); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( - EnumChatFormatting.AQUA+"(Use "+EnumChatFormatting.YELLOW+"/neugamemodes"+ - EnumChatFormatting.AQUA+" if you would like to build further out)")); - - event.setCanceled(true); + if((getGamemode().gamemodeModifiers & MODIFIER_SMALLISLAND) != 0) { + if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { + if(Math.abs(event.pos.getX()) > 40 || Math.abs(event.pos.getZ()) > 40) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.YELLOW+"[NPC] Builder"+ + EnumChatFormatting.WHITE+": Sorry, "+Minecraft.getMinecraft().thePlayer.getName()+ + ", due to budget cuts your skyblock island is now only 80 blocks wide.")); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + EnumChatFormatting.AQUA+"(Use "+EnumChatFormatting.YELLOW+"/neugamemodes"+ + EnumChatFormatting.AQUA+" if you would like to build further out)")); + + event.setCanceled(true); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CosmeticsInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CosmeticsInfoPane.java deleted file mode 100644 index 707968e3..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CosmeticsInfoPane.java +++ /dev/null @@ -1,83 +0,0 @@ -package io.github.moulberry.notenoughupdates.infopanes; - -import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; -import io.github.moulberry.notenoughupdates.NEUManager; -import io.github.moulberry.notenoughupdates.NEUOverlay; -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; - -import java.awt.*; -import java.util.HashMap; - -public class CosmeticsInfoPane extends InfoPane { - - public CosmeticsInfoPane(NEUOverlay overlay, NEUManager manager) { - super(overlay, manager); - } - - private HashMap capeTextures = new HashMap<>(); - - private String selectedCape = null; - - public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX, - int mouseY) { - super.renderDefaultBackground(width, height, bg); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - int currentY = overlay.getBoxPadding()+10; - fr.drawString("NEU Capes", overlay.getBoxPadding()+10, currentY, Color.WHITE.getRGB(), true); currentY += 10; - - selectedCape = null; - for(String cape : CapeManager.getInstance().getCapes()) { - if(CapeManager.getInstance().getPermissionForCape(Minecraft.getMinecraft().thePlayer.getName(), cape)) { - currentY += renderCapeSelector(cape, currentY, mouseX, mouseY); - currentY += 5; - } - } - } - - public int renderCapeSelector(String capename, int y, int mouseX, int mouseY) { - if(mouseX > overlay.getBoxPadding()+5 && mouseX < overlay.getBoxPadding()+75) { - if(mouseY > y && mouseY < y+100) { - selectedCape = capename; - } - } - boolean selected = capename.equals(CapeManager.getInstance().getCape(Minecraft.getMinecraft().thePlayer.getName())); - - if(selected) { - drawRect(overlay.getBoxPadding()+5, y, overlay.getBoxPadding()+75, y+100, Color.YELLOW.getRGB()); - drawGradientRect(overlay.getBoxPadding()+10, y+5, overlay.getBoxPadding()+70, y+95, Color.GRAY.darker().getRGB(), Color.GRAY.getRGB()); - } else { - drawGradientRect(overlay.getBoxPadding()+5, y, overlay.getBoxPadding()+75, y+100, Color.GRAY.darker().getRGB(), Color.GRAY.getRGB()); - } - - GlStateManager.color(1, 1, 1, 1); - - ResourceLocation capeTex = capeTextures.computeIfAbsent(capename, k -> new ResourceLocation("notenoughupdates:"+capename+".png")); - - Minecraft.getMinecraft().getTextureManager().bindTexture(capeTex); - Utils.drawTexturedRect(overlay.getBoxPadding()+10, y+10, 60, 80, 0, 300/1024f, 0, 425/1024f); - return 100; - } - - public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) { - if(mouseDown && selectedCape != null) { - if(selectedCape.equals(CapeManager.getInstance().getCape(Minecraft.getMinecraft().thePlayer.getName()))) { - CapeManager.getInstance().setCape(Minecraft.getMinecraft().thePlayer.getName(), null); - } else { - CapeManager.getInstance().setCape(Minecraft.getMinecraft().thePlayer.getName(), selectedCape); - } - } - } - - @Override - public boolean keyboardInput() { - return false; - } - -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java index 3e9cdb3f..234d06a8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/HTMLInfoPane.java @@ -136,6 +136,10 @@ public class HTMLInfoPane extends TextInfoPane { return new HTMLInfoPane(overlay, manager, name, filename, html); } + private String spaceEscape(String str) { + return str.replace(" ", "\\ "); + } + /** * Uses the wkhtmltoimage command-line tool to generate an image from the HTML code. This * generation is done asynchronously as sometimes it can take up to 10 seconds for more @@ -190,9 +194,12 @@ public class HTMLInfoPane extends TextInfoPane { EnumChatFormatting.GRAY+"), please wait..."; Runtime runtime = Runtime.getRuntime(); - Process p = runtime.exec("\""+wkHtmlToImage.getAbsolutePath() + "\" --width "+ + Process p = runtime.exec(spaceEscape(wkHtmlToImage.getAbsolutePath()) + " --width "+ + IMAGE_WIDTH*ZOOM_FACTOR+" --transparent --zoom "+ZOOM_FACTOR + " " + spaceEscape(input.getAbsolutePath()) + + " " + spaceEscape(output.getAbsolutePath())); + /*Process p = runtime.exec("\""+wkHtmlToImage.getAbsolutePath() + "\" --width "+ IMAGE_WIDTH*ZOOM_FACTOR+" --transparent --zoom "+ZOOM_FACTOR+" \"" + input.getAbsolutePath() + - "\" \"" + output.getAbsolutePath() + "\""); + "\" \"" + output.getAbsolutePath() + "\"");*/ /*Process p2 = runtime.exec("\""+wkHtmlToImage.getAbsolutePath() + "\" --width "+ (IMAGE_WIDTH+EXT_WIDTH)*ZOOM_FACTOR+" --transparent --zoom "+ZOOM_FACTOR+" \"" + input.getAbsolutePath() + "\" \"" + outputExt.getAbsolutePath() + "\"");*/ diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java new file mode 100644 index 00000000..de86198e --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityRenderer.java @@ -0,0 +1,77 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.CustomItemEffects; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import net.minecraft.client.renderer.EntityRenderer; +import org.lwjgl.util.vector.Vector3f; +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.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(EntityRenderer.class) +public class MixinEntityRenderer { + + //orientCamera + @ModifyVariable(method="orientCamera", at=@At(value="STORE"), ordinal = 0) + public double orientCamera_d0(double d0) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.x; + } + return d0; + } + + @ModifyVariable(method="orientCamera", at=@At(value="STORE"), ordinal = 1) + public double orientCamera_d1(double d1) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.y; + } + return d1; + } + + @ModifyVariable(method="orientCamera", at=@At(value="STORE"), ordinal = 2) + public double orientCamera_d2(double d2) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.z; + } + return d2; + } + + //renderWorldPass + @Inject(method="renderWorldPass", at=@At("HEAD")) + public void renderWorldPass(int pass, float partialTicks, long finishTimeNano, CallbackInfo ci) { + CustomItemEffects.INSTANCE.partialTicks = partialTicks; + } + + @ModifyVariable(method="renderWorldPass", at=@At(value="STORE"), ordinal = 0) + public double renderWorldPass_d0(double d0) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.x; + } + return d0; + } + + @ModifyVariable(method="renderWorldPass", at=@At(value="STORE"), ordinal = 1) + public double renderWorldPass_d1(double d1) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.y; + } + return d1; + } + + @ModifyVariable(method="renderWorldPass", at=@At(value="STORE"), ordinal = 2, print = true) + public double renderWorldPass_d2(double d2) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.z; + } + return d2; + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java new file mode 100644 index 00000000..2337aa8b --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinNetHandlerPlayClient.java @@ -0,0 +1,26 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.CustomItemEffects; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.StreamerMode; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Team; +import org.lwjgl.util.vector.Vector3f; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(NetHandlerPlayClient.class) +public class MixinNetHandlerPlayClient { + + private static final String TARGET = "Lnet/minecraft/entity/player/EntityPlayer;" + + "setPositionAndRotation(DDDFF)V"; + @Redirect(method="handlePlayerPosLook", at=@At(value="INVOKE", target=TARGET)) + public void handlePlayerPosLook_setPositionAndRotation(EntityPlayer player, double x, double y, double z, float yaw, float pitch) { + CustomItemEffects.INSTANCE.teleported = true; + player.setPositionAndRotation(x, y, z, yaw, pitch); + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java new file mode 100644 index 00000000..2bb5503b --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderGlobal.java @@ -0,0 +1,69 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.CustomItemEffects; +import net.minecraft.client.renderer.RenderGlobal; +import org.lwjgl.util.vector.Vector3f; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(RenderGlobal.class) +public class MixinRenderGlobal { + + //setupTerrain + @ModifyVariable(method="setupTerrain", at=@At(value="STORE"), ordinal = 4) + public double setupTerrain_d0(double d3) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.x; + } + return d3; + } + + @ModifyVariable(method="setupTerrain", at=@At(value="STORE"), ordinal = 5) + public double setupTerrain_d1(double d4) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.y; + } + return d4; + } + + @ModifyVariable(method="setupTerrain", at=@At(value="STORE"), ordinal = 6) + public double setupTerrain_d2(double d5) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.z; + } + return d5; + } + + //renderEntities + @ModifyVariable(method="renderEntities", at=@At(value="STORE"), ordinal = 3) + public double renderEntities_d0(double d3) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.x; + } + return d3; + } + + @ModifyVariable(method="renderEntities", at=@At(value="STORE"), ordinal = 4) + public double renderEntities_d1(double d4) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.y; + } + return d4; + } + + @ModifyVariable(method="renderEntities", at=@At(value="STORE"), ordinal = 5) + public double renderEntities_d2(double d5) { + Vector3f currentPosition = CustomItemEffects.INSTANCE.getCurrentPosition(); + if(currentPosition != null) { + return currentPosition.z; + } + return d5; + } + +} 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 88165d08..4906fa4d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java @@ -58,6 +58,11 @@ public class Options { "Coloured Tooltip Borders", false, "Makes the border of tooltips coloured. (Only NEU Tooltips)"); + public Option disableAhScroll = new Option( + false, + "No NeuAH Scroll", + false, + "Disables Scrolling in NeuAH"); public Option advancedPriceInfo = new Option( false, "Adv. Item Price Info", @@ -292,6 +297,7 @@ public class Options { //tryAddOption(advancedPriceInfo, options); tryAddOption(showUpdateMsg, options); tryAddOption(tooltipBorderColours, options); + tryAddOption(disableAhScroll, options); tryAddOption(hideApiKey, options); tryAddOption(streamerMode, options); tryAddOption(autoupdate, options); 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 e8432d63..14966b2f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -1695,6 +1695,7 @@ public class GuiProfileViewer extends GuiScreen { for(Map.Entry entry : skillInfo.entrySet()) { if(entry.getKey().startsWith("level_skill")) { if(entry.getKey().contains("runecrafting")) continue; + if(entry.getKey().contains("carpentry")) continue; totalSkillLVL += entry.getValue().getAsFloat(); totalSkillCount++; } else if(entry.getKey().startsWith("level_slayer")) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java index ca6c30af..b925f6da 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java @@ -23,6 +23,9 @@ public class HypixelApi { private Gson gson = new Gson(); private ExecutorService es = Executors.newFixedThreadPool(3); + private int myApiErrors = 0; + private String[] myApiURLs = {"https://moulberry.codes/", "https://51.89.22.3/", "http://moulberry.codes/", "http://51.89.22.3/"}; + public void getHypixelApiAsync(String apiKey, String method, HashMap args, Consumer consumer) { getHypixelApiAsync(apiKey, method, args, consumer, () -> {}); } @@ -31,6 +34,10 @@ public class HypixelApi { getApiAsync(generateApiUrl(apiKey.trim(), method, args), consumer, error); } + private String getMyApiURL() { + return myApiURLs[myApiErrors%myApiURLs.length]; + } + public void getApiAsync(String urlS, Consumer consumer, Runnable error) { es.submit(() -> { try { @@ -41,6 +48,28 @@ public class HypixelApi { }); } + public void getMyApiAsync(String urlS, Consumer consumer, Runnable error) { + es.submit(() -> { + try { + consumer.accept(getApiSync(getMyApiURL()+urlS)); + } catch(IOException e) { + myApiErrors++; + error.run(); + } + }); + } + + public void getMyApiGZIPAsync(String urlS, Consumer consumer, Runnable error) { + es.submit(() -> { + try { + consumer.accept(getApiGZIPSync(getMyApiURL()+urlS)); + } catch(IOException e) { + myApiErrors++; + error.run(); + } + }); + } + public void getApiGZIPAsync(String urlS, Consumer consumer, Runnable error) { es.submit(() -> { try { 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 73c15a7b..428a43b2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -619,7 +619,12 @@ public class Utils { return new Color(colourInt).darker(); } - //private static List + public static void scrollTooltip(int dY) { + scrollY.setTarget(scrollY.getTarget()+dY/10f); + scrollY.resetTimer(); + } + + private static LerpingFloat scrollY = new LerpingFloat(0, 100); public static void drawHoveringText(List textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font, boolean coloured) { if (!textLines.isEmpty()) { @@ -713,9 +718,24 @@ public class Utils { } } + //Scrollable tooltips + if(tooltipHeight + 6 > screenHeight) { + if(scrollY.getTarget() < 0) { + scrollY.setTarget(0); + scrollY.resetTimer(); + } else if(screenHeight - tooltipHeight - 12 + (int)scrollY.getTarget() > 0) { + scrollY.setTarget(-screenHeight + tooltipHeight + 12); + scrollY.resetTimer(); + } + } else { + scrollY.setValue(0); + scrollY.resetTimer(); + } + scrollY.tick(); + if (tooltipY + tooltipHeight + 6 > screenHeight) { - tooltipY = screenHeight - tooltipHeight - 6; + tooltipY = screenHeight - tooltipHeight - 6 + (int)scrollY.getValue(); } final int zLevel = 300; diff --git a/src/main/resources/assets/notenoughupdates/capes/contrib.png b/src/main/resources/assets/notenoughupdates/capes/contrib.png new file mode 100644 index 00000000..51699e6e Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/contrib.png differ diff --git a/src/main/resources/assets/notenoughupdates/capes/fade.png b/src/main/resources/assets/notenoughupdates/capes/fade.png new file mode 100644 index 00000000..d898ec4d Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/fade.png differ diff --git a/src/main/resources/assets/notenoughupdates/capes/gravy.png b/src/main/resources/assets/notenoughupdates/capes/gravy.png new file mode 100644 index 00000000..e43ba7d2 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/gravy.png differ diff --git a/src/main/resources/assets/notenoughupdates/capes/nullzee.png b/src/main/resources/assets/notenoughupdates/capes/nullzee.png new file mode 100644 index 00000000..5939034b Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/nullzee.png differ diff --git a/src/main/resources/assets/notenoughupdates/capes/patreon1.png b/src/main/resources/assets/notenoughupdates/capes/patreon1.png new file mode 100644 index 00000000..aba027bc Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/patreon1.png differ diff --git a/src/main/resources/assets/notenoughupdates/capes/patreon2.png b/src/main/resources/assets/notenoughupdates/capes/patreon2.png new file mode 100644 index 00000000..1c5a848a Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/patreon2.png differ diff --git a/src/main/resources/assets/notenoughupdates/capes/testcape.png b/src/main/resources/assets/notenoughupdates/capes/testcape.png new file mode 100644 index 00000000..4b8ba499 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/testcape.png differ diff --git a/src/main/resources/assets/notenoughupdates/contrib.png b/src/main/resources/assets/notenoughupdates/contrib.png deleted file mode 100644 index 51699e6e..00000000 Binary files a/src/main/resources/assets/notenoughupdates/contrib.png and /dev/null differ diff --git a/src/main/resources/assets/notenoughupdates/cosmetics_fg.png b/src/main/resources/assets/notenoughupdates/cosmetics_fg.png new file mode 100644 index 00000000..445753ac Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/cosmetics_fg.png differ diff --git a/src/main/resources/assets/notenoughupdates/fade.png b/src/main/resources/assets/notenoughupdates/fade.png deleted file mode 100644 index d898ec4d..00000000 Binary files a/src/main/resources/assets/notenoughupdates/fade.png and /dev/null differ diff --git a/src/main/resources/assets/notenoughupdates/gravy.png b/src/main/resources/assets/notenoughupdates/gravy.png deleted file mode 100644 index e43ba7d2..00000000 Binary files a/src/main/resources/assets/notenoughupdates/gravy.png and /dev/null differ diff --git a/src/main/resources/assets/notenoughupdates/nullzee.png b/src/main/resources/assets/notenoughupdates/nullzee.png deleted file mode 100644 index 5939034b..00000000 Binary files a/src/main/resources/assets/notenoughupdates/nullzee.png and /dev/null differ diff --git a/src/main/resources/assets/notenoughupdates/patreon1.png b/src/main/resources/assets/notenoughupdates/patreon1.png deleted file mode 100644 index aba027bc..00000000 Binary files a/src/main/resources/assets/notenoughupdates/patreon1.png and /dev/null differ diff --git a/src/main/resources/assets/notenoughupdates/patreon2.png b/src/main/resources/assets/notenoughupdates/patreon2.png deleted file mode 100644 index 1c5a848a..00000000 Binary files a/src/main/resources/assets/notenoughupdates/patreon2.png and /dev/null differ diff --git a/src/main/resources/assets/notenoughupdates/pv_elements.png b/src/main/resources/assets/notenoughupdates/pv_elements.png index 0020478e..d742301e 100644 Binary files a/src/main/resources/assets/notenoughupdates/pv_elements.png and b/src/main/resources/assets/notenoughupdates/pv_elements.png differ diff --git a/src/main/resources/assets/notenoughupdates/testcape.png b/src/main/resources/assets/notenoughupdates/testcape.png deleted file mode 100644 index 4b8ba499..00000000 Binary files a/src/main/resources/assets/notenoughupdates/testcape.png and /dev/null differ diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index 8f07f5cc..f797c921 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -6,6 +6,9 @@ "MixinItemStack", "MixinInventoryEffectRenderer", "MixinGuiIngame", - "MixinRenderItem" + "MixinRenderItem", + "MixinEntityRenderer", + "MixinRenderGlobal", + "MixinNetHandlerPlayClient" ] } \ No newline at end of file -- cgit From 275fe45caa8eb1048914d864aafae21f3f3a1157 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sat, 3 Oct 2020 06:09:28 +1000 Subject: 1.3.3-ALPA --- build.gradle | 6 +- deps/Morus-1.0.jar | Bin 0 -> 74917 bytes .../notenoughupdates/AccessoryBagOverlay.java | 527 +++++++++++++ .../notenoughupdates/BetterContainers.java | 333 ++++++++ .../moulberry/notenoughupdates/BetterPortals.java | 206 +++++ .../moulberry/notenoughupdates/GuiTextures.java | 5 + .../notenoughupdates/MorusIntegration.java | 60 ++ .../notenoughupdates/NEUEventListener.java | 29 +- .../moulberry/notenoughupdates/NEUOverlay.java | 171 +++- .../notenoughupdates/NEUOverlayPlacements.java | 63 +- .../notenoughupdates/NotEnoughUpdates.java | 18 +- .../moulberry/notenoughupdates/SBAIntegration.java | 21 +- .../moulberry/notenoughupdates/TradeWindow.java | 22 +- .../notenoughupdates/auction/APIManager.java | 78 +- .../notenoughupdates/auction/CustomAH.java | 4 +- .../notenoughupdates/infopanes/DevInfoPane.java | 862 ++++++++++++++++++++- .../infopanes/SettingsInfoPane.java | 2 + .../notenoughupdates/mbgui/MBAnchorPoint.java | 18 +- .../notenoughupdates/mbgui/MBDeserializer.java | 20 + .../notenoughupdates/mbgui/MBGuiElement.java | 2 + .../notenoughupdates/mbgui/MBGuiGroupAligned.java | 67 ++ .../notenoughupdates/mbgui/MBGuiGroupFloating.java | 23 +- .../notenoughupdates/mbgui/MBGuiGroupHorz.java | 47 -- .../notenoughupdates/mixins/MixinGuiChest.java | 32 + .../notenoughupdates/mixins/MixinGuiContainer.java | 52 ++ .../notenoughupdates/options/Options.java | 12 + .../profileviewer/GuiProfileViewer.java | 67 +- .../profileviewer/PlayerStats.java | 21 +- .../profileviewer/ProfileViewer.java | 162 +--- .../notenoughupdates/util/HypixelApi.java | 2 + .../moulberry/notenoughupdates/util/TexLoc.java | 8 +- .../notenoughupdates/accessory_bag_overlay.png | Bin 0 -> 973 bytes .../dynamic_54/dynamic_54_button_ctm.png | Bin 0 -> 543 bytes .../dynamic_54/style1/dynamic_54.png | Bin 0 -> 5234 bytes .../dynamic_54/style1/dynamic_54_button_ctm.png | Bin 0 -> 607 bytes .../dynamic_54/style1/dynamic_54_slot_ctm.png | Bin 0 -> 539 bytes .../dynamic_54/style2/dynamic_54.png | Bin 0 -> 5429 bytes .../dynamic_54/style3/dynamic_54.png | Bin 0 -> 5519 bytes .../dynamic_54/style3/dynamic_54_button_ctm.png | Bin 0 -> 539 bytes .../dynamic_54/style4/dynamic_54_button_ctm.png | Bin 0 -> 3437 bytes .../assets/notenoughupdates/item_haschild.png | Bin 0 -> 263 bytes .../notenoughupdates/quickcommand_background.png | Bin 0 -> 429 bytes .../notenoughupdates/shaders/space_cape.frag | 6 +- src/main/resources/mixins.notenoughupdates.json | 4 +- 44 files changed, 2571 insertions(+), 379 deletions(-) create mode 100644 deps/Morus-1.0.jar create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/BetterPortals.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupHorz.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java create mode 100644 src/main/resources/assets/notenoughupdates/accessory_bag_overlay.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/dynamic_54_button_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_button_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_slot_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_button_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_button_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/item_haschild.png create mode 100644 src/main/resources/assets/notenoughupdates/quickcommand_background.png (limited to 'src/main/resources/mixins.notenoughupdates.json') diff --git a/build.gradle b/build.gradle index 9155a4eb..06d19abe 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'com.github.johnrengelman.shadow' sourceCompatibility = 1.8 targetCompatibility = 1.8 -version = "1.2.2-BETA" +version = "1.3-REL" group= "io.github.moulberry" archivesBaseName = "NotEnoughUpdates" String modid = "notenoughupdates" @@ -34,6 +34,9 @@ minecraft { repositories { jcenter() maven { url 'https://repo.spongepowered.org/maven/' } + flatDir { + dirs 'deps' + } } dependencies { @@ -42,6 +45,7 @@ dependencies { //compile('org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r') compile('com.fasterxml.jackson.core:jackson-core:2.10.2') compile('info.bliki.wiki:bliki-core:3.1.0') + implementation name: 'Morus-1.0' } mixin { diff --git a/deps/Morus-1.0.jar b/deps/Morus-1.0.jar new file mode 100644 index 00000000..92276d72 Binary files /dev/null and b/deps/Morus-1.0.jar differ diff --git a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java new file mode 100644 index 00000000..65d4efc7 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java @@ -0,0 +1,527 @@ +package io.github.moulberry.notenoughupdates; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.ContainerChest; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; + +import java.awt.*; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.*; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static io.github.moulberry.notenoughupdates.GuiTextures.*; + +public class AccessoryBagOverlay { + + private static final int TAB_BASIC = 0; + private static final int TAB_TOTAL = 1; + private static final int TAB_BONUS = 2; + private static final int TAB_DUP = 3; + private static final int TAB_MISSING = 4; + + private static final ItemStack[] TAB_STACKS = new ItemStack[] { + Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA+"Basic Information", + 10, EnumChatFormatting.GREEN+"- Talis count by rarity"), + Utils.createItemStack(Items.diamond_sword, EnumChatFormatting.DARK_AQUA+"Total Stat Bonuses", + 0), + Utils.createItemStack(Item.getItemFromBlock(Blocks.anvil), EnumChatFormatting.DARK_AQUA+"Total Stat Bonuses (from reforges)", + 0), + Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA+"Duplicates", + 8), + Utils.createItemStack(Item.getItemFromBlock(Blocks.barrier), EnumChatFormatting.DARK_AQUA+"Missing", + 0), + }; + + private static int currentTab = TAB_BASIC; + + public static boolean mouseClick() { + if(!Mouse.getEventButtonState()) return false; + try { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + + int width = scaledResolution.getScaledWidth(); + int height = scaledResolution.getScaledHeight(); + + int mouseX = Mouse.getX() / scaledResolution.getScaleFactor(); + int mouseY = height - Mouse.getY() / scaledResolution.getScaleFactor(); + + int xSize = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "xSize", "field_146999_f"); + int ySize = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "ySize", "field_147000_g"); + int guiLeft = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiLeft", "field_147003_i"); + int guiTop = (int) Utils.getField(GuiContainer.class, Minecraft.getMinecraft().currentScreen, "guiTop", "field_147009_r"); + + if(mouseX < guiLeft+xSize+3 || mouseX > guiLeft+xSize+80+28) return false; + if(mouseY < guiTop || mouseY > guiTop+166) return false; + + if(mouseX > guiLeft+xSize+83 && mouseY < guiTop+20*TAB_MISSING+22) { + currentTab = (mouseY - guiTop)/20; + if(currentTab < 0) currentTab = 0; + if(currentTab > TAB_MISSING) currentTab = TAB_MISSING; + } + + return true; + } catch(Exception e) { + return false; + } + } + + public static void resetCache() { + accessoryStacks = new HashSet<>(); + pagesVisited = new HashSet<>(); + talismanCountRarity = null; + totalStats = null; + reforgeStats = null; + } + + private static Set accessoryStacks = new HashSet<>(); + private static Set pagesVisited = new HashSet<>(); + + public static void renderVisitOverlay(int x, int y) { + Utils.drawStringCenteredScaledMaxWidth("Please visit all", Minecraft.getMinecraft().fontRendererObj, x+40, y+78, true, 70, -1); + Utils.drawStringCenteredScaledMaxWidth("pages of the bag", Minecraft.getMinecraft().fontRendererObj, x+40, y+86, true, 70, -1); + } + + private static TreeMap talismanCountRarity = null; + public static void renderBasicOverlay(int x, int y) { + if(talismanCountRarity == null) { + talismanCountRarity = new TreeMap<>(); + for(ItemStack stack : accessoryStacks) { + int rarity = getRarity(stack); + if(rarity >= 0) { + talismanCountRarity.put(rarity, talismanCountRarity.getOrDefault(rarity, 0)+1); + } + } + } + + Utils.drawStringCenteredScaledMaxWidth("# By Rarity", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, true, 70, + new Color(80, 80, 80).getRGB()); + + int yIndex = 0; + for(Map.Entry entry : talismanCountRarity.descendingMap().entrySet()) { + String rarityName = rarityArrC[entry.getKey()]; + renderAlignedString(rarityName, EnumChatFormatting.WHITE.toString()+entry.getValue(), x+5, y+20+11*yIndex, 70); + yIndex++; + } + } + + + private static PlayerStats.Stats totalStats = null; + public static void renderTotalStatsOverlay(int x, int y) { + if(totalStats == null) { + totalStats = new PlayerStats.Stats(); + for(ItemStack stack : accessoryStacks) { + if(stack != null) totalStats.add(getStatForItem(stack, STAT_PATTERN_MAP, true)); + } + } + + Utils.drawStringCenteredScaledMaxWidth("Total Stats", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, true, 70, + new Color(80, 80, 80).getRGB()); + int yIndex = 0; + for(int i=0; i duplicates = new HashSet<>(); + public static void renderDuplicatesOverlay(int x, int y) { + Utils.drawStringCenteredScaledMaxWidth("Duplicates", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, true, 70, + new Color(80, 80, 80).getRGB()); + } + + public static void renderMissingOverlay(int x, int y) { + } + + public static void renderOverlay() { + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + if(containerName.trim().startsWith("Accessory Bag")) { + try { + int xSize = (int) Utils.getField(GuiContainer.class, eventGui, "xSize", "field_146999_f"); + int ySize = (int) Utils.getField(GuiContainer.class, eventGui, "ySize", "field_147000_g"); + int guiLeft = (int) Utils.getField(GuiContainer.class, eventGui, "guiLeft", "field_147003_i"); + int guiTop = (int) Utils.getField(GuiContainer.class, eventGui, "guiTop", "field_147009_r"); + + if(accessoryStacks.isEmpty()) { + for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { + if(stack != null && isAccessory(stack)) { + accessoryStacks.add(stack); + } + } + } + + if(containerName.trim().contains("(")) { + String first = containerName.trim().split("\\(")[1].split("/")[0]; + Integer currentPageNumber = Integer.parseInt(first); + //System.out.println("current:"+currentPageNumber); + if(!pagesVisited.contains(currentPageNumber)) { + boolean hasStack = false; + if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) { + IInventory inv = ((ContainerChest)Minecraft.getMinecraft().thePlayer.openContainer).getLowerChestInventory(); + for(int i=0; i pagesVisited.size()) { + Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay); + Utils.drawTexturedRect(guiLeft+xSize+3, guiTop, 80, 149, 0, 80/256f, 0, 149/256f, GL11.GL_NEAREST); + + renderVisitOverlay(guiLeft+xSize+3, guiTop); + return; + } + } else if(pagesVisited.isEmpty()) { + boolean hasStack = false; + if(Minecraft.getMinecraft().thePlayer.openContainer instanceof ContainerChest) { + IInventory inv = ((ContainerChest)Minecraft.getMinecraft().thePlayer.openContainer).getLowerChestInventory(); + for(int i=0; i= length) { + for(int xOff=-2; xOff<=2; xOff++) { + for(int yOff=-2; yOff<=2; yOff++) { + if(Math.abs(xOff) != Math.abs(yOff)) { + Utils.drawStringCenteredScaledMaxWidth(Utils.cleanColourNotModifiers(first + " " + second), Minecraft.getMinecraft().fontRendererObj, + x+length/2f+xOff/2f, y+4+yOff/2f, false, length, + new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()); + } + } + } + + GlStateManager.color(1, 1, 1, 1); + Utils.drawStringCenteredScaledMaxWidth(first + " " + second, Minecraft.getMinecraft().fontRendererObj, + x+length/2f, y+4, false, length, 4210752); + } else { + for(int xOff=-2; xOff<=2; xOff++) { + for(int yOff=-2; yOff<=2; yOff++) { + if(Math.abs(xOff) != Math.abs(yOff)) { + fontRendererObj.drawString(Utils.cleanColourNotModifiers(first), + x+xOff/2f, y+yOff/2f, + new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false); + } + } + } + + int secondLen = fontRendererObj.getStringWidth(second); + GlStateManager.color(1, 1, 1, 1); + fontRendererObj.drawString(first, x, y, 4210752, false); + for(int xOff=-2; xOff<=2; xOff++) { + for(int yOff=-2; yOff<=2; yOff++) { + if(Math.abs(xOff) != Math.abs(yOff)) { + fontRendererObj.drawString(Utils.cleanColourNotModifiers(second), + x+length-secondLen+xOff/2f, y+yOff/2f, + new Color(0, 0, 0, 200/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB(), false); + } + } + } + + GlStateManager.color(1, 1, 1, 1); + fontRendererObj.drawString(second, x+length-secondLen, y, 4210752, false); + } + } + + private static final Pattern HEALTH_PATTERN_BONUS = Pattern.compile("^Health: (?:\\+|-)[0-9]+ HP \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern DEFENCE_PATTERN_BONUS = Pattern.compile("^Defense: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern STRENGTH_PATTERN_BONUS = Pattern.compile("^Strength: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern SPEED_PATTERN_BONUS = Pattern.compile("^Speed: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern CC_PATTERN_BONUS = Pattern.compile("^Crit Chance: (?:\\+|-)[0-9]+% \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern CD_PATTERN_BONUS = Pattern.compile("^Crit Damage: (?:\\+|-)[0-9]+% \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern ATKSPEED_PATTERN_BONUS = Pattern.compile("^Bonus Attack Speed: (?:\\+|-)[0-9]+% \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern INTELLIGENCE_PATTERN_BONUS = Pattern.compile("^Intelligence: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final Pattern SCC_PATTERN_BONUS = Pattern.compile("^Sea Creature Chance: (?:\\+|-)[0-9]+ \\([a-zA-Z]+ ((?:\\+|-)[0-9]+)"); + private static final HashMap STAT_PATTERN_MAP_BONUS = new HashMap<>(); + static { + STAT_PATTERN_MAP_BONUS.put("health", HEALTH_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("defence", DEFENCE_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("strength", STRENGTH_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("speed", SPEED_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("crit_chance", CC_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("crit_damage", CD_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("bonus_attack_speed", ATKSPEED_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("intelligence", INTELLIGENCE_PATTERN_BONUS); + STAT_PATTERN_MAP_BONUS.put("sea_creature_chance", SCC_PATTERN_BONUS); + } + + private static final Pattern HEALTH_PATTERN = Pattern.compile("^Health: ((?:\\+|-)[0-9]+)"); + private static final Pattern DEFENCE_PATTERN = Pattern.compile("^Defense: ((?:\\+|-)[0-9]+)"); + private static final Pattern STRENGTH_PATTERN = Pattern.compile("^Strength: ((?:\\+|-)[0-9]+)"); + private static final Pattern SPEED_PATTERN = Pattern.compile("^Speed: ((?:\\+|-)[0-9]+)"); + private static final Pattern CC_PATTERN = Pattern.compile("^Crit Chance: ((?:\\+|-)[0-9]+)"); + private static final Pattern CD_PATTERN = Pattern.compile("^Crit Damage: ((?:\\+|-)[0-9]+)"); + private static final Pattern ATKSPEED_PATTERN = Pattern.compile("^Bonus Attack Speed: ((?:\\+|-)[0-9]+)"); + private static final Pattern INTELLIGENCE_PATTERN = Pattern.compile("^Intelligence: ((?:\\+|-)[0-9]+)"); + private static final Pattern SCC_PATTERN = Pattern.compile("^Sea Creature Chance: ((?:\\+|-)[0-9]+)"); + private static final HashMap STAT_PATTERN_MAP = new HashMap<>(); + static { + STAT_PATTERN_MAP.put("health", HEALTH_PATTERN); + STAT_PATTERN_MAP.put("defence", DEFENCE_PATTERN); + STAT_PATTERN_MAP.put("strength", STRENGTH_PATTERN); + STAT_PATTERN_MAP.put("speed", SPEED_PATTERN); + STAT_PATTERN_MAP.put("crit_chance", CC_PATTERN); + STAT_PATTERN_MAP.put("crit_damage", CD_PATTERN); + STAT_PATTERN_MAP.put("bonus_attack_speed", ATKSPEED_PATTERN); + STAT_PATTERN_MAP.put("intelligence", INTELLIGENCE_PATTERN); + STAT_PATTERN_MAP.put("sea_creature_chance", SCC_PATTERN); + } + private static PlayerStats.Stats getStatForItem(ItemStack stack, HashMap patternMap, boolean addExtras) { + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack); + NBTTagCompound tag = stack.getTagCompound(); + PlayerStats.Stats stats = new PlayerStats.Stats(); + + if(internalname == null) { + return stats; + } + + if(tag != null) { + NBTTagCompound display = tag.getCompoundTag("display"); + if (display.hasKey("Lore", 9)) { + NBTTagList list = display.getTagList("Lore", 8); + for (int i = 0; i < list.tagCount(); i++) { + String line = list.getStringTagAt(i); + for(Map.Entry entry : patternMap.entrySet()) { + Matcher matcher = entry.getValue().matcher(Utils.cleanColour(line)); + if(matcher.find()) { + int bonus = Integer.parseInt(matcher.group(1)); + stats.addStat(entry.getKey(), bonus); + } + } + } + } + } + + if(!addExtras) return stats; + + if(internalname.equals("DAY_CRYSTAL") || internalname.equals("NIGHT_CRYSTAL")) { + stats.addStat(PlayerStats.STRENGTH, 2.5f); + stats.addStat(PlayerStats.DEFENCE, 2.5f); + } + + if(internalname.equals("NEW_YEAR_CAKE_BAG") && tag != null && tag.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); + + byte[] bytes = null; + for (String key : ea.getKeySet()) { + if (key.endsWith("backpack_data") || key.equals("new_year_cake_bag_data")) { + bytes = ea.getByteArray(key); + try { + NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes)); + NBTTagList items = contents_nbt.getTagList("i", 10); + HashSet cakes = new HashSet<>(); + for(int j=0; j 0) { + NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag"); + if(nbt != null && nbt.hasKey("ExtraAttributes", 10)) { + NBTTagCompound ea2 = nbt.getCompoundTag("ExtraAttributes"); + if (ea2.hasKey("new_years_cake")) { + cakes.add(ea2.getInteger("new_years_cake")); + } + } + } + } + stats.addStat(PlayerStats.HEALTH, cakes.size()); + } catch(IOException e) { + e.printStackTrace(); + return stats; + } + break; + } + } + } + return stats; + } + + private static String[] rarityArr = new String[] { + "COMMON", "UNCOMMON", "RARE", "EPIC", "LEGENDARY", "MYTHIC", "SPECIAL", "VERY SPECIAL", + }; + 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", + }; + public static int checkItemType(ItemStack stack, boolean contains, String... typeMatches) { + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null) { + NBTTagCompound display = tag.getCompoundTag("display"); + if (display.hasKey("Lore", 9)) { + NBTTagList list = display.getTagList("Lore", 8); + for (int i = list.tagCount()-1; i >= 0; i--) { + String line = list.getStringTagAt(i); + for(String rarity : rarityArr) { + for(int j=0; j= 0; + } + + public static int getRarity(ItemStack stack) { + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null) { + NBTTagCompound display = tag.getCompoundTag("display"); + if (display.hasKey("Lore", 9)) { + NBTTagList list = display.getTagList("Lore", 8); + for (int i = list.tagCount(); i >= 0; i--) { + String line = list.getStringTagAt(i); + for(int j=0; j 0 && buttons[xi][yi-1]; + boolean right = xi < buttons.length-1 && buttons[xi+1][yi]; + boolean down = yi < buttons[xi].length-1 && buttons[xi][yi+1]; + boolean left = xi > 0 && buttons[xi-1][yi]; + + boolean upleft = yi > 0 && xi > 0 && buttons[xi-1][yi-1]; + boolean upright = yi > 0 && xi < buttons.length-1 && buttons[xi+1][yi-1]; + boolean downright = xi < buttons.length-1 && yi < buttons[xi+1].length-1 && buttons[xi+1][yi+1]; + boolean downleft = xi > 0 && yi < buttons[xi-1].length-1 && buttons[xi-1][yi+1]; + + int ctmIndex = getCTMIndex(up, right, down, left, upleft, upright, downright, downleft); + int[] rgbs = bufferedImageButton.getRGB((ctmIndex%12)*19*horzTexMult, (ctmIndex/12)*19*vertTexMult, + 18*horzTexMult, 18*vertTexMult, null, 0, 18*vertTexMult); + bufferedImageNew.setRGB(x, y, 18*horzTexMult, 18*vertTexMult, rgbs, 0, 18*vertTexMult); + } else { + boolean up = yi > 0 && slots[xi][yi-1]; + boolean right = xi < slots.length-1 && slots[xi+1][yi]; + boolean down = yi < slots[xi].length-1 && slots[xi][yi+1]; + boolean left = xi > 0 && slots[xi-1][yi]; + + boolean upleft = yi > 0 && xi > 0 && slots[xi-1][yi-1]; + boolean upright = yi > 0 && xi < slots.length-1 && slots[xi+1][yi-1]; + boolean downright = xi < slots.length-1 && yi < slots[xi+1].length-1 && slots[xi+1][yi+1]; + boolean downleft = xi > 0 && yi < slots[xi-1].length-1 && slots[xi-1][yi+1]; + + int ctmIndex = getCTMIndex(up, right, down, left, upleft, upright, downright, downleft); + int[] rgbs = bufferedImageSlot.getRGB((ctmIndex%12)*19*horzTexMult, (ctmIndex/12)*19*vertTexMult, + 18*horzTexMult, 18*vertTexMult, null, 0, 18*vertTexMult); + bufferedImageNew.setRGB(x, y, 18*horzTexMult, 18*vertTexMult, rgbs, 0, 18*vertTexMult); + } + } + } + texture = new DynamicTexture(bufferedImageNew); + } catch(Exception e) { + e.printStackTrace(); + } + } + } + + public static void reset() { + texture = null; + loaded = false; + clickedSlot = -1; + clickedSlotMillis = 0; + } + + private static boolean isChestOpen() { + return Minecraft.getMinecraft().currentScreen instanceof GuiChest && + NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() && + (NotEnoughUpdates.INSTANCE.manager.config.dynamicMenuBackgroundStyle.value >= 1 && + NotEnoughUpdates.INSTANCE.manager.config.dynamicMenuButtonStyle.value >= 1); + } + + private static boolean hasItem() { + if(!isChestOpen()) return false; + Container container = ((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots; + if(container instanceof ContainerChest) { + IInventory lower = ((ContainerChest)container).getLowerChestInventory(); + int size = lower.getSizeInventory(); + for(int index=0; index loadedPortals = new HashSet<>(); + private HashMap portalNameMap = new HashMap<>(); + + @SubscribeEvent + public void onWorldChange(WorldEvent.Load event) { + portalNameMap.clear(); + loadedPortals.clear(); + } + + /** The current GL viewport */ + private static final IntBuffer VIEWPORT = GLAllocation.createDirectIntBuffer(16); + /** The current GL modelview matrix */ + private static final FloatBuffer MODELVIEW = GLAllocation.createDirectFloatBuffer(16); + /** The current GL projection matrix */ + private static final FloatBuffer PROJECTION = GLAllocation.createDirectFloatBuffer(16); + private static final FloatBuffer WINCOORDS = GLAllocation.createDirectFloatBuffer(3); + + private float getFOVModifier(float partialTicks) { + Entity entity = Minecraft.getMinecraft().getRenderViewEntity(); + + float f = Minecraft.getMinecraft().gameSettings.fovSetting; + //f = f * (this.fovModifierHandPrev + (this.fovModifierHand - this.fovModifierHandPrev) * partialTicks); + + if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).getHealth() <= 0.0F) { + float f1 = (float)((EntityLivingBase)entity).deathTime + partialTicks; + f /= (1.0F - 500.0F / (f1 + 500.0F)) * 2.0F + 1.0F; + } + + Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(Minecraft.getMinecraft().theWorld, entity, partialTicks); + + if (block.getMaterial() == Material.water) { + f = f * 60.0F / 70.0F; + } + + return net.minecraftforge.client.ForgeHooksClient.getFOVModifier(Minecraft.getMinecraft().entityRenderer, entity, block, partialTicks, f); + } + + TexLoc tl = new TexLoc(0, 1, Keyboard.KEY_M); + + @SubscribeEvent + public void renderWorld(RenderGameOverlayEvent event) { + + GlStateManager.getFloat(2982, MODELVIEW); + GlStateManager.getFloat(2983, PROJECTION); + GL11.glGetInteger(GL11.GL_VIEWPORT, VIEWPORT); + + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + GlStateManager.disableCull(); + + tl.handleKeyboardInput(); + + WINCOORDS.flip().limit(3); + + /*float objx = -(float)(0-player.posX); + float objy = (float)(100-player.posY-player.eyeHeight); + float objz = (float)(0-player.posZ);*/ + + float dX = -(float)(0-player.posX); + float dY = (float)(100-player.posY-player.eyeHeight); + float dZ = (float)(0-player.posZ); + + //GLU.gluProject(objx, objy, objz, MODELVIEW, PROJECTION, VIEWPORT, WINCOORDS); + + double x = dX*Math.cos(Math.toRadians(player.rotationYawHead))-dZ*Math.sin(Math.toRadians(player.rotationYawHead)); + double z = dX*Math.sin(Math.toRadians(player.rotationYawHead))+dZ*Math.cos(Math.toRadians(player.rotationYawHead)); + + float fov = getFOVModifier(event.partialTicks); + x = x / z * Math.toRadians(fov); + dY = (float)(dY / z * Math.toRadians(fov)); + + //System.out.println(z); + + //GLU.gluProject((float)x, dY, (float)z, MODELVIEW, PROJECTION, VIEWPORT, WINCOORDS); + //x = x / z * 2; + //dY = (float)(dY / z * 2); + + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + GL11.glScissor((int)(x*Minecraft.getMinecraft().displayWidth*tl.x/tl.y)+Minecraft.getMinecraft().displayWidth/2, + (int)(dY+Minecraft.getMinecraft().displayHeight/2), 2, 2); + + drawRect(0, 0, 2000, 2000, -1); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + + /*for(BlockPos pos : portalNameMap.keySet()) { + WINCOORDS.flip().limit(3); + + /*float objx = -(float)((pos.getX()-player.posX)*Math.cos(Math.toRadians(player.rotationYawHead))*Math.cos(Math.toRadians(player.rotationPitch))); + float objy = (float)((pos.getY()-player.posY)*Math.sin(Math.toRadians(player.rotationPitch))); + float objz = (float)((pos.getZ()-player.posZ)*Math.sin(Math.toRadians(player.rotationYawHead))); + + float objx = -(float)(pos.getX()-player.posX); + float objy = (float)(pos.getY()-player.posY-player.eyeHeight); + float objz = (float)(pos.getZ()-player.posZ); + + GLU.gluProject(objx, objy, objz, MODELVIEW, PROJECTION, VIEWPORT, WINCOORDS); + //GLU.glu + + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + //System.out.println(WINCOORDS.get(1)); + + GL11.glScissor((int)WINCOORDS.get(0)*2, + Minecraft.getMinecraft().displayHeight-(int)WINCOORDS.get(1), (int)50, (int)50); + + //0-1 + //-1 - 1 + //0-1920 + + drawRect(0, 0, 2000, 2000, -1); + + GL11.glDisable(GL11.GL_SCISSOR_TEST); + }*/ + + GlStateManager.enableCull(); + } + + @SubscribeEvent + public void tick(TickEvent.ClientTickEvent event) { + if(Minecraft.getMinecraft().theWorld != null) { + List travelToPositions = new ArrayList<>(); + for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { + if(entity instanceof EntityArmorStand) { + EntityArmorStand armorStand = (EntityArmorStand) entity; + if(armorStand.isInvisible() && armorStand.hasCustomName()) { + String customName = armorStand.getCustomNameTag(); + if(customName.equals(EnumChatFormatting.AQUA+"Travel to:")) { + travelToPositions.add(new Vector3f((float)armorStand.posX, (float)armorStand.posY, (float)armorStand.posZ)); + } + } + } + } + travelToPositions.removeAll(loadedPortals); + for(Entity entity : Minecraft.getMinecraft().theWorld.loadedEntityList) { + if(entity instanceof EntityArmorStand) { + EntityArmorStand armorStand = (EntityArmorStand) entity; + if(armorStand.isInvisible() && armorStand.hasCustomName()) { + String customName = armorStand.getCustomNameTag(); + for(Vector3f position : travelToPositions) { + if(position.x == (float)armorStand.posX && position.y-0.375 == (float)armorStand.posY && position.z == (float)armorStand.posZ) { + float smallestDist = 999; + BlockPos closestPortal = null; + for(int xOff=-3; xOff<=3; xOff++) { + for(int zOff=-3; zOff<=3; zOff++) { + if(xOff != 0 && zOff != 0) continue; + BlockPos pos = new BlockPos(armorStand.posX+xOff, armorStand.posY+2, armorStand.posZ+zOff); + if(Minecraft.getMinecraft().theWorld.getBlockState(pos).getBlock() == Blocks.portal) { + float dist = (float)(armorStand.posX-(pos.getX()+0.5) + armorStand.posZ-(pos.getZ()+0.5)); + if(closestPortal == null || dist < smallestDist) { + smallestDist = dist; + closestPortal = pos; + } + } + } + } + if(closestPortal != null) { + portalNameMap.put(closestPortal, customName); + } + } + } + } + } + } + loadedPortals.addAll(travelToPositions); + } + } + + public void tryRegisterPortal() { + + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java index 9fcb218f..fb8671cb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java @@ -22,8 +22,13 @@ public class GuiTextures { public static final ResourceLocation slider_button = new ResourceLocation("notenoughupdates:slider_button.png"); public static final ResourceLocation item_mask = new ResourceLocation("notenoughupdates:item_mask.png"); + 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 accessory_bag_overlay = new ResourceLocation("notenoughupdates:accessory_bag_overlay.png"); + + public static final ResourceLocation quickcommand_background = new ResourceLocation("notenoughupdates:quickcommand_background.png"); + public static final ResourceLocation gamemodes = new ResourceLocation("notenoughupdates:gamemodes.png"); public static final ResourceLocation radial_square_off = new ResourceLocation("notenoughupdates:radial_square_off.png"); public static final ResourceLocation radial_square_on = new ResourceLocation("notenoughupdates:radial_square_on.png"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java b/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java new file mode 100644 index 00000000..8ec4263a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/MorusIntegration.java @@ -0,0 +1,60 @@ +package io.github.moulberry.notenoughupdates; + +import io.github.moulberry.morus.MorusSubstitutor; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; + +import java.util.HashMap; +import java.util.Map; + +public class MorusIntegration { + + private static MorusIntegration INSTANCE = new MorusIntegration(); + + public static MorusIntegration getInstance() { + return INSTANCE; + } + + private HashMap itemDrops = null; + private HashMap inventoryItems = null; + + public void tick() { + if(itemDrops == null) { + itemDrops = new HashMap<>(); + for(String item : NotEnoughUpdates.INSTANCE.manager.getItemInformation().keySet()) { + itemDrops.put(item, 0); + } + } + + HashMap newInventoryItems = getInventoryItems(); + if(inventoryItems != null) { + for(String internal : newInventoryItems.keySet()) { + int newAmount = newInventoryItems.get(internal); + int oldAmount = inventoryItems.getOrDefault(internal, 0); + if(newAmount > oldAmount) { + itemDrops.put(internal, itemDrops.getOrDefault(internal, 0)+newAmount-oldAmount); + } + } + } + inventoryItems = newInventoryItems; + + for(Map.Entry entry : itemDrops.entrySet()) { + MorusSubstitutor.putSubstiution("notenoughupdates", "itemdrops."+entry.getKey().toLowerCase(), ""+entry.getValue()); + } + + } + + public HashMap getInventoryItems() { + HashMap inventoryItems = new HashMap<>(); + if(Minecraft.getMinecraft().thePlayer != null) { + for(ItemStack stack : Minecraft.getMinecraft().thePlayer.inventory.mainInventory) { + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack); + if(internalname != null) { + inventoryItems.put(internalname, inventoryItems.getOrDefault(internalname, 0)+stack.stackSize); + } + } + } + return inventoryItems; + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index fb6348ee..95eefef5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -32,6 +32,7 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.*; import net.minecraftforge.event.entity.player.ItemTooltipEvent; +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; @@ -136,7 +137,15 @@ public class NEUEventListener { if(longUpdate) { neu.updateSkyblockScoreboard(); CapeManager.getInstance().tick(); + + if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) { + AccessoryBagOverlay.resetCache(); + } + if(neu.hasSkyblockScoreboard()) { + if(Loader.isModLoaded("morus")) { + MorusIntegration.getInstance().tick(); + } lastSkyblockScoreboard = currentTime; if(!joinedSB) { joinedSB = true; @@ -173,8 +182,8 @@ public class NEUEventListener { } if(longUpdate && neu.hasSkyblockScoreboard()) { if(neu.manager.getCurrentProfile() == null || neu.manager.getCurrentProfile().length() == 0) { - ProfileViewer.Profile profile = neu.profileViewer.getProfile( - Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), (json) -> {}); + ProfileViewer.Profile profile = neu.profileViewer.getProfile(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""), + callback->{}); if(profile != null) { String latest = profile.getLatestProfile(); if(latest != null) { @@ -276,6 +285,7 @@ public class NEUEventListener { @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { neu.manager.auctionManager.customAH.lastGuiScreenSwitch = System.currentTimeMillis(); + BetterContainers.reset(); if(event.gui == null && neu.manager.auctionManager.customAH.isRenderOverAuctionView() && !(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui)) { @@ -511,6 +521,7 @@ public class NEUEventListener { if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { renderDungeonChestOverlay(event.gui); + AccessoryBagOverlay.renderOverlay(); } } @@ -748,12 +759,16 @@ public class NEUEventListener { return; } if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { - if(!(hoverInv && focusInv)) { - if(neu.overlay.mouseInput()) { - event.setCanceled(true); - } + if(AccessoryBagOverlay.mouseClick()) { + event.setCanceled(true); } else { - neu.overlay.mouseInputInv(); + if(!(hoverInv && focusInv)) { + if(neu.overlay.mouseInput()) { + event.setCanceled(true); + } + } else { + neu.overlay.mouseInputInv(); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index a3670a86..49a886b6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -8,8 +8,8 @@ import io.github.moulberry.notenoughupdates.infopanes.*; import io.github.moulberry.notenoughupdates.itemeditor.NEUItemEditor; import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint; import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement; +import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupAligned; import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating; -import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupHorz; import io.github.moulberry.notenoughupdates.util.LerpingFloat; import io.github.moulberry.notenoughupdates.util.LerpingInteger; import io.github.moulberry.notenoughupdates.util.Utils; @@ -96,6 +96,13 @@ public class NEUOverlay extends Gui { private TreeSet searchedItems = null; private JsonObject[] searchedItemsArr = null; + private HashMap> searchedItemsSubgroup = new HashMap<>(); + + private long selectedItemMillis = 0; + private int selectedItemGroupX = -1; + private int selectedItemGroupY = -1; + private List selectedItemGroup = null; + private boolean itemPaneOpen = false; private int page = 0; @@ -272,20 +279,17 @@ public class NEUOverlay extends Gui { @Override public void render(float x, float y) { int paddingUnscaled = getPaddingUnscaled(); + int searchYSize = getSearchBarYSize(); - Minecraft.getMinecraft().getTextureManager().bindTexture(settings); - drawRect((int)x, (int)y, - (int)x + getWidth(), (int)y + getHeight(), - Color.WHITE.getRGB()); - - - drawRect((int)x + paddingUnscaled, (int)y + paddingUnscaled, - (int)x + getWidth() - paddingUnscaled, (int)y + getHeight() - paddingUnscaled, - Color.GRAY.getRGB()); + Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(x, y, + searchYSize + paddingUnscaled*2, searchYSize + paddingUnscaled*2, GL11.GL_NEAREST); + Minecraft.getMinecraft().getTextureManager().bindTexture(settings); GlStateManager.color(1f, 1f, 1f, 1f); Utils.drawTexturedRect((int)x + paddingUnscaled, (int)y + paddingUnscaled, - getSearchBarYSize(), getSearchBarYSize()); + searchYSize, searchYSize); GlStateManager.bindTexture(0); } }; @@ -324,16 +328,14 @@ public class NEUOverlay extends Gui { @Override public void render(float x, float y) { int paddingUnscaled = getPaddingUnscaled(); + int searchYSize = getSearchBarYSize(); - Minecraft.getMinecraft().getTextureManager().bindTexture(help); - drawRect((int)x, (int)y, - (int)x + getWidth(), (int)y + getHeight(), - Color.WHITE.getRGB()); - - drawRect((int)x + paddingUnscaled, (int)y + paddingUnscaled, - (int)x + getWidth() - paddingUnscaled, (int)y + getHeight() - paddingUnscaled, - Color.GRAY.getRGB()); + Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(x, y, + searchYSize + paddingUnscaled*2, searchYSize + paddingUnscaled*2, GL11.GL_NEAREST); + Minecraft.getMinecraft().getTextureManager().bindTexture(help); GlStateManager.color(1f, 1f, 1f, 1f); Utils.drawTexturedRect((int)x + paddingUnscaled, (int)y + paddingUnscaled, getSearchBarYSize(), getSearchBarYSize()); @@ -402,7 +404,6 @@ public class NEUOverlay extends Gui { NBTTagList textures = new NBTTagList(); NBTTagCompound textures_0 = new NBTTagCompound(); - String uuid = UUID.nameUUIDFromBytes(display.getBytes()).toString(); skullOwner.setString("Id", uuid); skullOwner.setString("Name", uuid); @@ -425,13 +426,10 @@ public class NEUOverlay extends Gui { } } if(render != null) { - Minecraft.getMinecraft().getTextureManager().bindTexture(item_mask); + Minecraft.getMinecraft().getTextureManager().bindTexture(quickcommand_background); GlStateManager.color(1, 1, 1, 1); Utils.drawTexturedRect(x, y, - bigItemSize + paddingUnscaled*2, bigItemSize + paddingUnscaled*2, GL11.GL_LINEAR); - GlStateManager.color(fg.getRed() / 255f,fg.getGreen() / 255f, - fg.getBlue() / 255f, fg.getAlpha() / 255f); - Utils.drawTexturedRect(x+paddingUnscaled, y+paddingUnscaled, bigItemSize, bigItemSize, GL11.GL_LINEAR); + 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; @@ -455,21 +453,21 @@ public class NEUOverlay extends Gui { }; } - private MBGuiGroupHorz createQuickCommandGroup() { + private MBGuiGroupAligned createQuickCommandGroup() { List children = new ArrayList<>(); for(String quickCommand : manager.config.quickCommands.value) { children.add(createQuickCommand(quickCommand)); } - return new MBGuiGroupHorz(children) { + return new MBGuiGroupAligned(children, false) { public int getPadding() { return getPaddingUnscaled()*4; } }; } - private MBGuiGroupHorz createSearchBarGroup() { + private MBGuiGroupAligned createSearchBarGroup() { List children = Lists.newArrayList(createSettingsButton(this), createSearchBar(), createHelpButton(this)); - return new MBGuiGroupHorz(children) { + return new MBGuiGroupAligned(children, false) { public int getPadding() { return getPaddingUnscaled()*4; } @@ -619,6 +617,29 @@ public class NEUOverlay extends Gui { guiGroup.mouseClick(0, 0, mouseX, mouseY); + if(selectedItemGroup != null) { + int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size()); + if(mouseY > selectedItemGroupY+17 && mouseY < selectedItemGroupY+35) { + for(int i=0; i= selectedX-1+18*i && mouseX <= selectedX+17+18*i) { + JsonObject item = selectedItemGroup.get(i); + if (item != null) { + if(Mouse.getEventButton() == 0) { + manager.showRecipe(item); + } else if(Mouse.getEventButton() == 1) { + showInfo(item); + } else if(Mouse.getEventButton() == manager.keybindItemSelect.getKeyCode()+100) { + textField.setText("id:"+item.get("internalname").getAsString()); + updateSearch(); + searchMode = true; + } + } + return true; + } + } + } + } + //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. @@ -1076,13 +1097,31 @@ public class NEUOverlay extends Gui { public void updateSearch() { if(searchedItems==null) searchedItems = new TreeSet<>(getItemComparator()); searchedItems.clear(); + searchedItemsSubgroup.clear(); searchedItemsArr = null; redrawItems = true; Set itemsMatch = manager.search(textField.getText(), true); for(String itemname : itemsMatch) { JsonObject item = manager.getItemInformation().get(itemname); if(checkMatchesSort(itemname, item)) { - searchedItems.add(item); + if(item.has("parent") && item.get("parent").isJsonPrimitive()) { + searchedItemsSubgroup + .computeIfAbsent(item.get("parent").getAsString(), k->new HashSet<>()) + .add(item.get("internalname").getAsString()); + } else { + searchedItems.add(item); + } + } + } + out: + for(Map.Entry> entry : searchedItemsSubgroup.entrySet()) { + if(searchedItems.contains(manager.getItemInformation().get(entry.getKey()))) { + continue; + } + for(String itemname : entry.getValue()) { + JsonObject item = manager.getItemInformation().get(itemname); + System.out.println("searching "+itemname); + if(item != null) searchedItems.add(item); } } switch(textField.getText().toLowerCase().trim()) { @@ -1741,6 +1780,18 @@ public class NEUOverlay extends Gui { millisLastMouseMove = System.currentTimeMillis(); } + if(selectedItemGroup != null) { + if(mouseX < selectedItemGroupX-1 || mouseX > selectedItemGroupX+17 || + mouseY < selectedItemGroupY-1 || mouseY > selectedItemGroupY+17) { + int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size()); + if(mouseX < selectedX-1 || mouseX > selectedX-1+18*selectedItemGroup.size() || + mouseY < selectedItemGroupY+17 || mouseY > selectedItemGroupY+35) { + selectedItemGroup = null; + selectedItemMillis = -1; + } + } + } + if(!hoverInv) { iterateItemSlots(new ItemSlotConsumer() { public void consume(int x, int y, int id) { @@ -1750,7 +1801,25 @@ public class NEUOverlay extends Gui { } if (mouseX > x - 1 && mouseX < x + ITEM_SIZE + 1) { if (mouseY > y - 1 && mouseY < y + ITEM_SIZE + 1) { - tooltipToDisplay.set(json); + String internalname = json.get("internalname").getAsString(); + if(searchedItemsSubgroup.containsKey(internalname)) { + if(selectedItemMillis == -1) selectedItemMillis = System.currentTimeMillis(); + if(System.currentTimeMillis() - selectedItemMillis > 200 && + (selectedItemGroup == null || selectedItemGroup.isEmpty())) { + + ArrayList children = new ArrayList<>(); + children.add(json); + for(String itemname : searchedItemsSubgroup.get(internalname)) { + children.add(manager.getItemInformation().get(itemname)); + } + + selectedItemGroup = children; + selectedItemGroupX = x; + selectedItemGroupY = y; + } + } else { + tooltipToDisplay.set(json); + } } } } @@ -1775,6 +1844,38 @@ public class NEUOverlay extends Gui { renderItems(xStart, true, true, true); } + if(selectedItemGroup != null) { + GL11.glTranslatef(0, 0, 10); + + int selectedX = Math.min(selectedItemGroupX, width-getBoxPadding()-18*selectedItemGroup.size()); + + GlStateManager.depthFunc(GL11.GL_LESS); + drawRect(selectedX, selectedItemGroupY+18, + selectedX-2+18*selectedItemGroup.size(), selectedItemGroupY+34, fgCustomOpacity.getRGB()); + drawRect(selectedX, selectedItemGroupY+18, + selectedX-1+18*selectedItemGroup.size(), selectedItemGroupY+35, new Color(30, 30, 30).getRGB()); + drawRect(selectedX-1, selectedItemGroupY+17, + selectedX-2+18*selectedItemGroup.size(), selectedItemGroupY+34, new Color(180, 180, 180).getRGB()); + GlStateManager.depthFunc(GL11.GL_LEQUAL); + + GL11.glTranslatef(0, 0, 10); + + tooltipToDisplay.set(null); + if(mouseY > selectedItemGroupY+17 && mouseY < selectedItemGroupY+35) { + for(int i=0; i= selectedX-1+18*i && mouseX <= selectedX+17+18*i) { + tooltipToDisplay.set(selectedItemGroup.get(i)); + } + } + } + for(int i=0; i3?(wolf>6?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED; EnumChatFormatting avgPrefix = avgSkillLVL>20?(avgSkillLVL>35?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED; - overallScore += combat*combat/2000f; overallScore += zombie*zombie/81f; overallScore += spider*spider/81f; overallScore += wolf*wolf/81f; overallScore += avgSkillLVL/20f; - - int cata = profile.getDungeonCatacombsLevel(null); + int cata = (int)Utils.getElementAsFloat(skill.get("level_skill_catacombs"), 0); EnumChatFormatting cataPrefix = cata>15?(cata>25?EnumChatFormatting.GREEN:EnumChatFormatting.YELLOW):EnumChatFormatting.RED; + overallScore += cata*cata/2000f; + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( g+"Combat: "+combatPrefix+(int)Math.floor(combat) + (cata > 0 ? g+" - Cata: "+cataPrefix+cata : "")+ @@ -610,6 +610,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(CapeManager.getInstance()); MinecraftForge.EVENT_BUS.register(new SBGamemodes()); MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); + //MinecraftForge.EVENT_BUS.register(new BetterPortals()); File f = new File(event.getModConfigurationDirectory(), "notenoughupdates"); f.mkdirs(); @@ -724,7 +725,6 @@ public class NotEnoughUpdates { ChatComponentText github = new ChatComponentText(EnumChatFormatting.GRAY+"["+EnumChatFormatting.DARK_PURPLE+"GitHub"+EnumChatFormatting.GRAY+"]"); github.setChatStyle(Utils.createClickStyle(ClickEvent.Action.OPEN_URL, github_link)); - links.appendSibling(separator); links.appendSibling(discord); links.appendSibling(separator); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/SBAIntegration.java b/src/main/java/io/github/moulberry/notenoughupdates/SBAIntegration.java index 2a19b16e..d9e9217a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/SBAIntegration.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/SBAIntegration.java @@ -38,13 +38,13 @@ public class SBAIntegration { skyblockAddons_getUtils = skyblockAddonsClass.getDeclaredMethod("getUtils"); } if(backpackManagerClass == null) { - backpackManagerClass = Class.forName("codes.biscuit.skyblockaddons.utils.BackpackManager"); + backpackManagerClass = Class.forName("codes.biscuit.skyblockaddons.features.backpacks.BackpackManager"); } if(backpackManager_getFromItem == null) { backpackManager_getFromItem = backpackManagerClass.getDeclaredMethod("getFromItem", ItemStack.class); } if(backpackClass == null) { - backpackClass = Class.forName("codes.biscuit.skyblockaddons.utils.Backpack"); + backpackClass = Class.forName("codes.biscuit.skyblockaddons.features.backpacks.Backpack"); } if(backpackClass_setX == null) { backpackClass_setX = backpackClass.getDeclaredMethod("setX", int.class); @@ -74,7 +74,10 @@ public class SBAIntegration { backpackClass_setY.invoke(backpack, mouseY); utils_setBackpackToPreview.invoke(utils, backpack); } - } catch(Exception e) { return false; } + } catch(Exception e) { + e.printStackTrace(); + return false; + } return true; } @@ -97,6 +100,7 @@ public class SBAIntegration { try { return (boolean) guiContainerHook_freezeBackpack.get(null); } catch(Exception e) { + e.printStackTrace(); return false; } } @@ -120,6 +124,7 @@ public class SBAIntegration { guiContainerHook_freezeBackpack.set(null, freezeBackpack); return true; } catch(Exception e) { + e.printStackTrace(); return false; } } @@ -156,7 +161,10 @@ public class SBAIntegration { } else { guiContainerHook_keyTyped.invoke(null, keyCode); } - } catch(Exception e) { return false; } + } catch(Exception e) { + e.printStackTrace(); + return false; + } return true; } @@ -193,7 +201,10 @@ public class SBAIntegration { guiContainerHook_drawBackpacks.invoke(null, container, mouseX, mouseY, fontRendererObj); } - } catch(Exception e) { return false; } + } catch(Exception e) { + e.printStackTrace(); + return false; + } return true; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/TradeWindow.java b/src/main/java/io/github/moulberry/notenoughupdates/TradeWindow.java index 1669d617..6bdf2c5d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/TradeWindow.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/TradeWindow.java @@ -58,6 +58,7 @@ public class TradeWindow { private static int lastBackpackY; public static boolean tradeWindowActive() { + if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return false; if(!NotEnoughUpdates.INSTANCE.manager.config.useCustomTrade.value) return false; GuiScreen guiScreen = Minecraft.getMinecraft().currentScreen; @@ -110,14 +111,17 @@ public class TradeWindow { StringBuilder sb = new StringBuilder(); for(int index = 0; index < clean.length(); index++) { char c = clean.charAt(index); - if("0123456789".indexOf(c) >= 0) { + if("0123456789.".indexOf(c) >= 0) { sb.append(c); } else { switch(c) { + case 'K': case 'k': mult = 1000; break; + case 'M': case 'm': mult = 1000000; break; + case 'B': case 'b': mult = 1000000000; break; default: @@ -127,7 +131,7 @@ public class TradeWindow { } } try { - int coins = Integer.parseInt(sb.toString())*mult; + int coins = (int)(Float.parseFloat(sb.toString())*mult); topItemsStack.putIfAbsent("TRADE_COINS", stack); @@ -318,14 +322,17 @@ public class TradeWindow { StringBuilder sb = new StringBuilder(); for(int index = 0; index < clean.length(); index++) { char c = clean.charAt(index); - if("0123456789".indexOf(c) >= 0) { + if("0123456789.".indexOf(c) >= 0) { sb.append(c); } else { switch(c) { + case 'K': case 'k': mult = 1000; break; + case 'M': case 'm': mult = 1000000; break; + case 'B': case 'b': mult = 1000000000; break; default: @@ -335,7 +342,7 @@ public class TradeWindow { } } try { - int coins = Integer.parseInt(sb.toString())*mult; + int coins = (int)(Float.parseFloat(sb.toString())*mult); List list = ourTradeMap.computeIfAbsent(coins, k -> new ArrayList<>()); list.add(containerIndex); @@ -413,14 +420,17 @@ public class TradeWindow { StringBuilder sb = new StringBuilder(); for(int index = 0; index < clean.length(); index++) { char c = clean.charAt(index); - if("0123456789".indexOf(c) >= 0) { + if("0123456789.".indexOf(c) >= 0) { sb.append(c); } else { switch(c) { + case 'K': case 'k': mult = 1000; break; + case 'M': case 'm': mult = 1000000; break; + case 'B': case 'b': mult = 1000000000; break; default: @@ -430,7 +440,7 @@ public class TradeWindow { } } try { - int coins = Integer.parseInt(sb.toString())*mult; + int coins = (int)(Float.parseFloat(sb.toString())*mult); List list = theirTradeMap.computeIfAbsent(coins, k -> new ArrayList<>()); list.add(containerIndex); 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 82b33611..03796993 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -25,6 +25,7 @@ import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; public class APIManager { @@ -188,7 +189,7 @@ public class APIManager { lastBazaarUpdate = currentTime; updateBazaar(); } - if(currentTime - lastCleanup > 120*1000) { + if(currentTime - lastCleanup > 60*1000) { lastCleanup = currentTime; cleanup(); } @@ -326,14 +327,8 @@ public class APIManager { getPageFromAPI(0); } - manager.hypixelApi.getMyApiGZIPAsync("auction.json.gz", jsonObject -> { + Consumer process = jsonObject -> { if(jsonObject.get("success").getAsBoolean()) { - long apiUpdate = (long)jsonObject.get("time").getAsFloat(); - if(lastApiUpdate == apiUpdate) { - lastAuctionUpdate -= 30*1000; - } - lastApiUpdate = apiUpdate; - JsonArray new_auctions = jsonObject.get("new_auctions").getAsJsonArray(); for(JsonElement auctionElement : new_auctions) { JsonObject auction = auctionElement.getAsJsonObject(); @@ -365,9 +360,26 @@ public class APIManager { } remove(toRemove); } - }, () -> { + }; + + manager.hypixelApi.getMyApiGZIPAsync("auctionLast.json.gz", process, () -> { System.out.println("Error downloading auction from Moulberry's jank API. :("); }); + + manager.hypixelApi.getMyApiGZIPAsync("auction.json.gz", jsonObject -> { + if(jsonObject.get("success").getAsBoolean()) { + long apiUpdate = (long) jsonObject.get("time").getAsFloat(); + if (lastApiUpdate == apiUpdate) { + lastAuctionUpdate -= 30 * 1000; + } + lastApiUpdate = apiUpdate; + + process.accept(jsonObject); + } + }, () -> { + System.out.println("Error downloading auction from Moulberry's jank API. :("); + }); + } public void calculateStats() { @@ -503,7 +515,7 @@ public class APIManager { int count = item_tag.getInteger("Count"); int price = starting_bid/(count>0?count:1); lowestBINs.computeIfAbsent(price, k -> new HashSet<>()).add(auctionUuid); - if(lowestBINs.size() > 10) { + if(lowestBINs.size() > 50) { lowestBINs.keySet().remove(lowestBINs.lastKey()); } } @@ -640,6 +652,15 @@ public class APIManager { }, () -> {}); } + public Set getItemAuctionInfoKeySet() { + if(auctionPricesJson == null) return new HashSet<>(); + HashSet keys = new HashSet<>(); + for(Map.Entry entry : auctionPricesJson.entrySet()) { + keys.add(entry.getKey()); + } + return keys; + } + public JsonObject getItemAuctionInfo(String internalname) { if(auctionPricesJson == null) return null; JsonElement e = auctionPricesJson.get(internalname); @@ -660,26 +681,18 @@ public class APIManager { private static final List hardcodedVanillaItems = Utils.createList( "WOOD_AXE", "WOOD_HOE", "WOOD_PICKAXE","WOOD_SPADE", "WOOD_SWORD", - "GOLD_AXE", "GOLD_HOE", "GOLD_PICKAXE", "GOLD_SPADE", "GOLD_SWORD" + "GOLD_AXE", "GOLD_HOE", "GOLD_PICKAXE", "GOLD_SPADE", "GOLD_SWORD", + "ROOKIE_HOE" ); public boolean isVanillaItem(String internalname) { if(hardcodedVanillaItems.contains(internalname)) return true; //Removes trailing numbers and underscores, eg. LEAVES_2-3 -> LEAVES String vanillaName = internalname.split("-")[0]; - int sub = 0; - for(int i=vanillaName.length()-1; i>1; i--) { - char c = vanillaName.charAt(i); - if((int)c >= 48 && (int)c <= 57) { //0-9 - sub++; - } else if(c == '_') { - sub++; - break; - } else { - break; - } + if(manager.getItemInformation().containsKey(vanillaName)) { + JsonObject json = manager.getItemInformation().get(vanillaName); + if(json != null && json.has("vanilla") && json.get("vanilla").getAsBoolean()) return true; } - vanillaName = vanillaName.substring(0, vanillaName.length()-sub).toLowerCase(); return Item.itemRegistry.getObject(new ResourceLocation(vanillaName)) != null; } @@ -689,10 +702,14 @@ public class APIManager { public float craftCost = -1; } + public CraftInfo getCraftCost(String internalname) { + return getCraftCost(internalname, 0); + } + /** * Recursively calculates the cost of crafting an item from raw materials. */ - public CraftInfo getCraftCost(String internalname) { + public CraftInfo getCraftCost(String internalname, int depth) { if(craftCost.containsKey(internalname)) { return craftCost.get(internalname); } else { @@ -714,6 +731,12 @@ public class APIManager { ci.craftCost = auctionPrice; } } + + if(depth > 16) { + craftCost.put(internalname, ci); + return ci; + } + JsonObject item = manager.getItemInformation().get(internalname); if(item != null && item.has("recipe")) { float craftPrice = 0; @@ -731,7 +754,12 @@ public class APIManager { count = Integer.parseInt(itemS.split(":")[1]); itemS = itemS.split(":")[0]; } - float compCost = getCraftCost(itemS).craftCost * count; + if(itemS.equals(internalname)) { //if item is used a crafting component in its own recipe, return + craftCost.put(internalname, ci); + return ci; + } + + float compCost = getCraftCost(itemS, depth+1).craftCost * count; if(compCost < 0) { //If it's a custom item without a cost, return if(!getCraftCost(itemS).vanillaItem) { 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 06211f59..f23b87fd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/CustomAH.java @@ -87,8 +87,8 @@ public class CustomAH extends Gui { private float scrollAmount; - public int guiLeft = 0; - public int guiTop = 0; + public int guiLeft = -1; + public int guiTop = -1; private Category CATEGORY_SWORD = new Category("sword", "Swords", "diamond_sword"); private Category CATEGORY_ARMOR = new Category("armor", "Armor", "diamond_chestplate"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java index ec5f8209..22427cee 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/DevInfoPane.java @@ -4,10 +4,25 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NEUOverlay; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.item.crafting.ShapedRecipes; +import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; import org.lwjgl.input.Keyboard; +import java.io.IOException; import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -45,7 +60,8 @@ public class DevInfoPane extends TextInfoPane { }*/ //if(true) return text; - for(String internalname : manager.auctionManager.internalnameToAucIdMap.keySet()) { + for(String internalname : manager.auctionManager.getItemAuctionInfoKeySet()) { + if(internalname.contains("-")) continue; if(!manager.getItemInformation().containsKey(internalname)) { text += internalname + "\n"; } @@ -69,12 +85,852 @@ public class DevInfoPane extends TextInfoPane { AtomicBoolean running = new AtomicBoolean(false); ScheduledExecutorService ses = Executors.newScheduledThreadPool(1); + String[] bukkitList = new String[] { + "ACACIA_DOOR_ITEM", + "ACACIA_FENCE", + "ACACIA_FENCE_GATE", + "ACACIA_STAIRS", + "ACTIVATOR_RAIL", + "ANVIL", + "APPLE", + "ARMOR_STAND", + "ARROW", + "BAKED_POTATO", + "BANNER", + "BARRIER", + "BEACON", + "BED", + "BEDROCK", + "BIRCH_DOOR_ITEM", + "BIRCH_FENCE", + "BIRCH_FENCE_GATE", + "BIRCH_WOOD_STAIRS@birch_stairs", + "BLAZE_POWDER", + "BLAZE_ROD", + "BOAT", + "BONE", + "BOOK", + "BOOK_AND_QUILL@writable_book", + "BOOKSHELF", + "BOW", + "BOWL", + "BREAD", + "BREWING_STAND_ITEM", + "BRICK@brick_block", + "BRICK_STAIRS", + "BROWN_MUSHROOM", + "BUCKET", + "CACTUS", + "CAKE", + "CARPET", + "CARROT_ITEM", + "CARROT_STICK@carrot_on_a_stick", + "CAULDRON_ITEM", + "CHAINMAIL_BOOTS", + "CHAINMAIL_CHESTPLATE", + "CHAINMAIL_HELMET", + "CHAINMAIL_LEGGINGS", + "CHEST", + "CLAY", + "CLAY_BALL", + "CLAY_BRICK@brick", + "COAL", + "COAL_BLOCK", + "COAL_ORE", + "COBBLE_WALL@cobblestone_wall", + "COBBLESTONE", + "COBBLESTONE_STAIRS@stone_stairs", + "COMMAND@command_block", + "COMMAND_MINECART@command_block_minecart", + "COMPASS", + "COOKED_BEEF", + "COOKED_CHICKEN", + "COOKED_FISH", + "COOKED_MUTTON", + "COOKED_RABBIT", + "COOKIE", + "DARK_OAK_DOOR_ITEM", + "DARK_OAK_FENCE", + "DARK_OAK_FENCE_GATE", + "DARK_OAK_STAIRS", + "DAYLIGHT_DETECTOR", + "DEAD_BUSH@deadbush", + "DETECTOR_RAIL", + "DIAMOND", + "DIAMOND_AXE", + "DIAMOND_BARDING@diamond_horse_armor", + "DIAMOND_BLOCK", + "DIAMOND_BOOTS", + "DIAMOND_CHESTPLATE", + "DIAMOND_HELMET", + "DIAMOND_HOE", + "DIAMOND_LEGGINGS", + "DIAMOND_ORE", + "DIAMOND_PICKAXE", + "DIAMOND_SPADE@diamond_shovel", + "DIAMOND_SWORD", + "DIODE@repeater", + "DIRT", + "DISPENSER", + "DOUBLE_PLANT", + "DRAGON_EGG", + "DROPPER", + "EGG", + "EMERALD", + "EMERALD_BLOCK", + "EMERALD_ORE", + "EMPTY_MAP@map", + "ENCHANTED_BOOK", + "ENCHANTMENT_TABLE@enchanting_table", + "ENDER_CHEST", + "ENDER_PEARL", + "ENDER_PORTAL_FRAME@end_portal_frame", + "ENDER_STONE@end_stone", + "EXP_BOTTLE@experience_bottle", + "EXPLOSIVE_MINECART@tnt_minecart", + "EYE_OF_ENDER@ender_eye", + "FEATHER", + "FENCE", + "FENCE_GATE", + "FERMENTED_SPIDER_EYE", + "FIREBALL@fire_charge", + "FIREWORK@fireworks", + "FIREWORK_CHARGE", + "FISHING_ROD", + "FLINT", + "FLINT_AND_STEEL", + "FLOWER_POT_ITEM", + "FURNACE", + "GHAST_TEAR", + "GLASS", + "GLASS_BOTTLE", + "GLOWSTONE", + "GLOWSTONE_DUST", + "GOLD_AXE@golden_axe", + "GOLD_BARDING@golden_horse_armor", + "GOLD_BLOCK", + "GOLD_BOOTS@golden_boots", + "GOLD_CHESTPLATE@golden_chestplate", + "GOLD_HELMET@golden_helmet", + "GOLD_HOE@golden_hoe", + "GOLD_INGOT", + "GOLD_LEGGINGS@golden_leggings", + "GOLD_NUGGET", + "GOLD_ORE", + "GOLD_PICKAXE@golden_pickaxe", + "GOLD_PLATE@light_weighted_pressure_plate", + "GOLD_RECORD@record_13", + "GOLD_SPADE@golden_shovel", + "GOLD_SWORD@golden_sword", + "GOLDEN_APPLE", + "GOLDEN_CARROT", + "GRASS", + "GRAVEL", + "GREEN_RECORD@record_cat", + "GRILLED_PORK@cooked_porkchop", + "HARD_CLAY@hardened_clay", + "HAY_BLOCK", + "HOPPER", + "HOPPER_MINECART", + "ICE", + "INK_SACK@dye", + "IRON_AXE", + "IRON_BARDING@iron_horse_armor", + "IRON_BLOCK", + "IRON_BOOTS", + "IRON_CHESTPLATE", + "IRON_DOOR", + "IRON_FENCE@iron_bars", + "IRON_HELMET", + "IRON_HOE", + "IRON_INGOT", + "IRON_LEGGINGS", + "IRON_ORE", + "IRON_PICKAXE", + "IRON_PLATE@heavy_weighted_pressure_plate", + "IRON_SPADE@iron_shovel", + "IRON_SWORD", + "IRON_TRAPDOOR", + "ITEM_FRAME", + "JACK_O_LANTERN@lit_pumpkin", + "JUKEBOX", + "JUNGLE_DOOR_ITEM", + "JUNGLE_FENCE", + "JUNGLE_FENCE_GATE", + "JUNGLE_WOOD_STAIRS@jungle_stairs", + "LADDER", + "LAPIS_BLOCK", + "LAPIS_ORE", + "LAVA_BUCKET", + "LEASH@lead", + "LEATHER", + "LEATHER_BOOTS", + "LEATHER_CHESTPLATE", + "LEATHER_HELMET", + "LEATHER_LEGGINGS", + "LEAVES", + "LEAVES_2@leaves2", + "LEVER", + "LOG", + "LOG_2@log2", + "LONG_GRASS@tallgrass", + "MAGMA_CREAM", + "MAP", + "MELON", + "MELON_BLOCK", + "MELON_SEEDS", + "MILK_BUCKET", + "MINECART", + "MOB_SPAWNER", + "MONSTER_EGG", + "MONSTER_EGGS@spawn_egg", + "MOSSY_COBBLESTONE", + "MUSHROOM_SOUP@mushroom_stew", + "MUTTON", + "MYCEL@mycelium", + "NAME_TAG", + "NETHER_BRICK", + "NETHER_BRICK_ITEM", + "NETHER_BRICK_STAIRS", + "NETHER_FENCE@nether_brick_fence", + "NETHER_STAR", + "NETHER_WARTS@nether_wart", + "NETHERRACK", + "NOTE_BLOCK@noteblock", + "OBSIDIAN", + "PACKED_ICE", + "PAINTING", + "PAPER", + "PISTON_BASE@piston", + "PISTON_STICKY_BASE@sticky_piston", + "POISONOUS_POTATO", + "PORK@porkchop", + "POTATO_ITEM", + "POTION", + "POWERED_MINECART@furnace_minecart", + "POWERED_RAIL@golden_rail", + "PRISMARINE", + "PRISMARINE_CRYSTALS", + "PRISMARINE_SHARD", + "PUMPKIN", + "PUMPKIN_PIE", + "PUMPKIN_SEEDS", + "QUARTZ", + "QUARTZ_BLOCK", + "QUARTZ_ORE", + "QUARTZ_STAIRS", + "RABBIT", + "RABBIT_FOOT", + "RABBIT_HIDE", + "RABBIT_STEW", + "RAILS@rail", + "RAW_BEEF@beef", + "RAW_CHICKEN@chicken", + "RAW_FISH@fish", + "RECORD_10@record_ward", + "RECORD_11", + "RECORD_12@record_wait", + "RECORD_3@record_blocks", + "RECORD_4@record_chirp", + "RECORD_5@record_far", + "RECORD_6@record_mall", + "RECORD_7@record_mellohi", + "RECORD_8@record_stal", + "RECORD_9@record_strad", + "RED_MUSHROOM", + "RED_ROSE@red_flower", + "RED_SANDSTONE", + "RED_SANDSTONE_STAIRS", + "REDSTONE", + "REDSTONE_BLOCK", + "REDSTONE_COMPARATOR@comparator", + "REDSTONE_LAMP_OFF@redstone_lamp", + "REDSTONE_ORE", + "REDSTONE_TORCH_ON@redstone_torch", + "ROTTEN_FLESH", + "SADDLE", + "SAND", + "SANDSTONE", + "SANDSTONE_STAIRS", + "SAPLING", + "SEA_LANTERN", + "SEEDS@wheat_seeds", + "SHEARS", + "SIGN", + "SKULL_ITEM", + "SLIME_BALL", + "SLIME_BLOCK@slime", + "SMOOTH_BRICK@stonebrick", + "SMOOTH_STAIRS@stone_brick_stairs", + "SNOW@snow_layer", + "SNOW_BALL@snowball", + "SNOW_BLOCK@snow", + "SOUL_SAND", + "SPECKLED_MELON", + "SPIDER_EYE", + "SPONGE", + "SPRUCE_DOOR_ITEM", + "SPRUCE_FENCE", + "SPRUCE_FENCE_GATE", + "SPRUCE_WOOD_STAIRS@spruce_stairs", + "STAINED_CLAY@stained_hardened_clay", + "STAINED_GLASS", + "STAINED_GLASS_PANE", + "STEP@stone_slab", + "STICK", + "STONE", + "STONE_AXE", + "STONE_BUTTON", + "STONE_HOE", + "STONE_PICKAXE", + "STONE_PLATE@stone_pressure_plate", + "STONE_SLAB2", + "STONE_SPADE@stone_shovel", + "STONE_SWORD", + "STORAGE_MINECART@chest_minecart", + "STRING", + "SUGAR", + "SUGAR_CANE@reeds", + "SULPHUR@gunpowder", + "THIN_GLASS@glass_pane", + "TNT", + "TORCH", + "TRAP_DOOR@trapdoor", + "TRAPPED_CHEST", + "TRIPWIRE_HOOK", + "VINE", + "WATCH@clock", + "WATER_BUCKET", + "WATER_LILY@waterlily", + "WEB", + "WHEAT", + "WOOD@planks", + "WOOD_AXE@wooden_axe", + "WOOD_BUTTON@wooden_button", + "WOOD_DOOR@wooden_door", + "WOOD_HOE@wooden_hoe", + "WOOD_PICKAXE@wooden_pickaxe", + "WOOD_PLATE@wooden_pressure_plate", + "WOOD_SPADE@wooden_shovel", + "WOOD_STAIRS@oak_stairs", + "WOOD_STEP@wooden_slab", + "WOOD_SWORD@wooden_sword", + "WOOL", + "WORKBENCH@crafting_table", + "WRITTEN_BOOK", + "YELLOW_FLOWER" + }; + + private void addStack(ItemStack stackToAdd, int depth) { + if(depth > 16) return; + + String regName2 = stackToAdd.getItem().getRegistryName().replace("minecraft:", ""); + String internalname = null; + for(String bukkit2 : bukkitList) { + if(bukkit2.equalsIgnoreCase(regName2) || + (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName2))) { + internalname = bukkit2.split("@")[0]; + break; + } + } + if(internalname == null) return; + + if(stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) { + internalname += "-" + stackToAdd.getItemDamage(); + } + + if(manager.getItemInformation().containsKey(internalname)) return; + + JsonObject recipeJson = null; + for(IRecipe recipe : CraftingManager.getInstance().getRecipeList()) { + ItemStack out = recipe.getRecipeOutput(); + if(out != null && out.getItem() == stackToAdd.getItem() && + (stackToAdd.getItemDamage() >= 32000 || out.getItemDamage() == stackToAdd.getItemDamage())) { + recipeJson = new JsonObject(); + + if (recipe instanceof ShapedRecipes) { + ShapedRecipes shaped = (ShapedRecipes) recipe; + + String[] x = {"1","2","3"}; + String[] y = {"A","B","C"}; + for(int i=0; i<9; i++) { + int xi = i%3; + int yi = i/3; + + String stacki = ""; + + int recipeIndex = i-(3-shaped.recipeWidth)*yi; + if(xi < shaped.recipeWidth && recipeIndex < shaped.recipeItems.length) { + ItemStack stack = shaped.recipeItems[recipeIndex]; + if(stack != null) { + if(stack.getItem() != stackToAdd.getItem() || + (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) addStack(stack, depth+1); + + Item stackItem = stack.getItem(); + String regName = stackItem.getRegistryName().replace("minecraft:", ""); + for(String bukkit2 : bukkitList) { + if(bukkit2.equalsIgnoreCase(regName) || + (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) { + stacki = bukkit2.split("@")[0]; + break; + } + } + if(!stacki.isEmpty()) { + if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) { + stacki += "-" + stack.getItemDamage(); + } + stacki += ":"+stack.stackSize; + } + } + } + + recipeJson.addProperty(y[yi]+x[xi], stacki); + } + break; + } else if(recipe instanceof ShapedOreRecipe) { + ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; + int width = (int)Utils.getField(ShapedOreRecipe.class, recipe, "width"); + String[] x = {"1","2","3"}; + String[] y = {"A","B","C"}; + for(int i=0; i<9; i++) { + int xi = i%3; + int yi = i/3; + + String stacki = ""; + + int recipeIndex = i - (3 - width) * yi; + if (xi < width && recipeIndex < shaped.getRecipeSize()) { + ItemStack stack = null; + if(recipeIndex < shaped.getRecipeSize()) { + Object o = shaped.getInput()[recipeIndex]; + if(o instanceof ItemStack) { + stack = (ItemStack) o; + } else if(o instanceof List) { + for(Object o2 : (List)o) { + if(o2 instanceof ItemStack) { + stack = (ItemStack) o2; + break; + } + } + } + } + if(stack != null) { + if(stack.getItem() != stackToAdd.getItem() || + (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) addStack(stack, depth+1); + Item stackItem = stack.getItem(); + String regName = stackItem.getRegistryName().replace("minecraft:", ""); + for(String bukkit2 : bukkitList) { + if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") || + (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) { + stacki = bukkit2.split("@")[0]; + break; + } + } + if(!stacki.isEmpty()) { + if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) { + stacki += "-" + stack.getItemDamage(); + } + //stacki += ":"+stack.stackSize; + stacki += ":1"; + } + } + } + + recipeJson.addProperty(y[yi]+x[xi], stacki); + } + } else if (recipe instanceof ShapelessRecipes) { + ShapelessRecipes shapeless = (ShapelessRecipes) recipe; + String[] x = {"1","2","3"}; + String[] y = {"A","B","C"}; + for(int i=0; i<9; i++) { + int xi = i%3; + int yi = i/3; + + String stacki = ""; + + ItemStack stack = null; + if(i < shapeless.recipeItems.size()) { + stack = shapeless.recipeItems.get(i); + } + if(stack != null) { + if(stack.getItem() != stackToAdd.getItem() || + (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) addStack(stack, depth+1); + Item stackItem = stack.getItem(); + String regName = stackItem.getRegistryName().replace("minecraft:", ""); + for(String bukkit2 : bukkitList) { + if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") || + (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) { + stacki = bukkit2.split("@")[0]; + break; + } + } + if(!stacki.isEmpty()) { + if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) { + stacki += "-" + stack.getItemDamage(); + } + //stacki += ":"+stack.stackSize; + stacki += ":1"; + } + } + + recipeJson.addProperty(y[yi]+x[xi], stacki); + } + break; + } else if (recipe instanceof ShapelessOreRecipe) { + ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; + String[] x = {"1","2","3"}; + String[] y = {"A","B","C"}; + for(int i=0; i<9; i++) { + int xi = i%3; + int yi = i/3; + + String stacki = ""; + + ItemStack stack = null; + if(i < shapeless.getRecipeSize()) { + Object o = shapeless.getInput().get(i);; + if(o instanceof ItemStack) { + stack = (ItemStack) o; + } else if(o instanceof List) { + for(Object o2 : (List)o) { + if(o2 instanceof ItemStack) { + stack = (ItemStack) o2; + break; + } + } + } + } + if(stack != null) { + if(stack.getItem() != stackToAdd.getItem() || + (stackToAdd.getItemDamage() < 32000 && stack.getItemDamage() != stackToAdd.getItemDamage())) addStack(stack, depth+1); + Item stackItem = stack.getItem(); + String regName = stackItem.getRegistryName().replace("minecraft:", ""); + for(String bukkit2 : bukkitList) { + if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") || + (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) { + stacki = bukkit2.split("@")[0]; + break; + } + } + if(!stacki.isEmpty()) { + if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) { + stacki += "-" + stack.getItemDamage(); + } + //stacki += ":"+stack.stackSize; + stacki += ":1"; + } + } + + recipeJson.addProperty(y[yi]+x[xi], stacki); + } + break; + } + } + + } + ItemStack res = Utils.createItemStack(stackToAdd.getItem(), + EnumChatFormatting.WHITE+stackToAdd.getItem().getItemStackDisplayName(stackToAdd), + EnumChatFormatting.WHITE.toString()+EnumChatFormatting.BOLD+"COMMON"); + if(stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) { + res.setItemDamage(stackToAdd.getItemDamage()); + } + res.getTagCompound().setInteger("HideFlags", 254); + NBTTagCompound ea = new NBTTagCompound(); + ea.setString("id", internalname); + res.getTagCompound().setTag("ExtraAttributes", ea); + + + JsonObject json = manager.getJsonForItem(res); + if(stackToAdd.getItemDamage() != 0 && stackToAdd.getItemDamage() < 32000) { + json.addProperty("parent", internalname.split("-")[0]); + } + + json.addProperty("internalname", internalname); + json.addProperty("modver", NotEnoughUpdates.VERSION); + json.addProperty("vanilla", true); + + if(recipeJson != null) { + json.add("recipe", recipeJson); + json.addProperty("clickcommand", "viewrecipe"); + } else { + json.addProperty("clickcommand", ""); + } + + json.addProperty("modver", NotEnoughUpdates.VERSION); + + try { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname)); + manager.writeJsonDefaultDir(json, internalname+".json"); + manager.loadItem(internalname); + } catch(IOException e) {} + } + @Override public boolean keyboardInput() { + if(running.get() || true) return false; if(Keyboard.isKeyDown(Keyboard.KEY_J)) { running.set(!running.get()); - for(Map.Entry item : manager.getItemInformation().entrySet()) { + for(String bukkit : bukkitList) { + String internalname = bukkit.split("@")[0]; + if(true || !manager.getItemInformation().containsKey(internalname)) { + //System.out.println("adding vanilla: " + internalname); + String vanilla = internalname.toLowerCase().replace("_item", ""); + if(bukkit.contains("@")) { + vanilla = bukkit.split("@")[1]; + } + Item item = Item.itemRegistry.getObject(new ResourceLocation(vanilla)); + if(item == null) { + item = Item.getItemFromBlock(Block.blockRegistry.getObject(new ResourceLocation(vanilla))); + } + if(item != null) { + HashMap recipeJsonForDamage = new HashMap<>(); + for(IRecipe recipe : CraftingManager.getInstance().getRecipeList()) { + ItemStack out = recipe.getRecipeOutput(); + if(out != null && out.getItem() == item) { + System.out.println("Found recipe for : " + internalname + ":" + recipe); + JsonObject obj = new JsonObject(); + + if (recipe instanceof ShapedRecipes) { + ShapedRecipes shaped = (ShapedRecipes) recipe; + String[] x = {"1", "2", "3"}; + String[] y = {"A", "B", "C"}; + for (int i = 0; i < 9; i++) { + int xi = i % 3; + int yi = i / 3; + + String stacki = ""; + + int recipeIndex = i - (3 - shaped.recipeWidth) * yi; + if (xi < shaped.recipeWidth && recipeIndex < shaped.recipeItems.length) { + ItemStack stack = shaped.recipeItems[recipeIndex]; + if (stack != null) { + addStack(stack, 0); + Item stackItem = stack.getItem(); + String regName = stackItem.getRegistryName().replace("minecraft:", ""); + for (String bukkit2 : bukkitList) { + if (bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName + "_ITEM") || + (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) { + stacki = bukkit2.split("@")[0]; + break; + } + } + if (!stacki.isEmpty()) { + if (stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) { + stacki += "-" + stack.getItemDamage(); + } + //stacki += ":"+stack.stackSize; + stacki += ":1"; + } + } + } + + obj.addProperty(y[yi] + x[xi], stacki); + } + recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj); + } else if(recipe instanceof ShapedOreRecipe) { + ShapedOreRecipe shaped = (ShapedOreRecipe) recipe; + int width = (int)Utils.getField(ShapedOreRecipe.class, recipe, "width"); + String[] x = {"1","2","3"}; + String[] y = {"A","B","C"}; + for(int i=0; i<9; i++) { + int xi = i%3; + int yi = i/3; + + String stacki = ""; + + int recipeIndex = i - (3 - width) * yi; + if (xi < width && recipeIndex < shaped.getRecipeSize()) { + ItemStack stack = null; + if(recipeIndex < shaped.getRecipeSize()) { + Object o = shaped.getInput()[recipeIndex]; + if(o instanceof ItemStack) { + stack = (ItemStack) o; + } else if(o instanceof List) { + for(Object o2 : (List)o) { + if(o2 instanceof ItemStack) { + stack = (ItemStack) o2; + break; + } + } + } + } + if(stack != null) { + addStack(stack, 0); + Item stackItem = stack.getItem(); + String regName = stackItem.getRegistryName().replace("minecraft:", ""); + for(String bukkit2 : bukkitList) { + if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") || + (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) { + stacki = bukkit2.split("@")[0]; + break; + } + } + if(!stacki.isEmpty()) { + if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) { + stacki += "-" + stack.getItemDamage(); + } + //stacki += ":"+stack.stackSize; + stacki += ":1"; + } + } + } + + obj.addProperty(y[yi]+x[xi], stacki); + } + recipeJsonForDamage.put(out.getItemDamage()>32000?0:out.getItemDamage(), obj); + } else if (recipe instanceof ShapelessRecipes) { + ShapelessRecipes shapeless = (ShapelessRecipes) recipe; + String[] x = {"1","2","3"}; + String[] y = {"A","B","C"}; + for(int i=0; i<9; i++) { + int xi = i%3; + int yi = i/3; + + String stacki = ""; + + ItemStack stack = null; + if(i < shapeless.recipeItems.size()) { + stack = shapeless.recipeItems.get(i); + } + if(stack != null) { + addStack(stack, 0); + Item stackItem = stack.getItem(); + String regName = stackItem.getRegistryName().replace("minecraft:", ""); + for(String bukkit2 : bukkitList) { + if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") || + (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) { + stacki = bukkit2.split("@")[0]; + break; + } + } + if(!stacki.isEmpty()) { + if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) { + stacki += "-" + stack.getItemDamage(); + } + //stacki += ":"+stack.stackSize; + stacki += ":1"; + } + } + + obj.addProperty(y[yi]+x[xi], stacki); + } + recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj); + break; + } else if (recipe instanceof ShapelessOreRecipe) { + ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe; + String[] x = {"1","2","3"}; + String[] y = {"A","B","C"}; + for(int i=0; i<9; i++) { + int xi = i%3; + int yi = i/3; + + String stacki = ""; + + ItemStack stack = null; + if(i < shapeless.getRecipeSize()) { + Object o = shapeless.getInput().get(i);; + if(o instanceof ItemStack) { + stack = (ItemStack) o; + } else if(o instanceof List) { + for(Object o2 : (List)o) { + if(o2 instanceof ItemStack) { + stack = (ItemStack) o2; + break; + } + } + } + } + if(stack != null) { + addStack(stack, 0); + Item stackItem = stack.getItem(); + String regName = stackItem.getRegistryName().replace("minecraft:", ""); + for(String bukkit2 : bukkitList) { + if(bukkit2.equalsIgnoreCase(regName) || bukkit2.equalsIgnoreCase(regName+"_ITEM") || + (bukkit2.contains("@") && bukkit2.split("@")[1].equalsIgnoreCase(regName))) { + stacki = bukkit2.split("@")[0]; + break; + } + } + if(!stacki.isEmpty()) { + if(stack.getItemDamage() != 0 && stack.getItemDamage() < 32000) { + stacki += "-" + stack.getItemDamage(); + } + //stacki += ":"+stack.stackSize; + stacki += ":1"; + } + } + + obj.addProperty(y[yi]+x[xi], stacki); + } + recipeJsonForDamage.put(out.getItemDamage() > 32000 ? 0 : out.getItemDamage(), obj); + break; + } + } + } + + if(recipeJsonForDamage.isEmpty()) { + ItemStack res = Utils.createItemStack(item, + EnumChatFormatting.WHITE+item.getItemStackDisplayName(new ItemStack(item)), + EnumChatFormatting.WHITE.toString()+EnumChatFormatting.BOLD+"COMMON"); + res.getTagCompound().setInteger("HideFlags", 254); + NBTTagCompound ea = new NBTTagCompound(); + ea.setString("id", internalname); + res.getTagCompound().setTag("ExtraAttributes", ea); + + JsonObject json = manager.getJsonForItem(res); + json.addProperty("internalname", internalname); + + json.addProperty("modver", NotEnoughUpdates.VERSION); + json.addProperty("vanilla", true); + + json.addProperty("clickcommand", ""); + try { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname)); + manager.writeJsonDefaultDir(json, internalname+".json"); + manager.loadItem(internalname); + } catch(IOException e) {} + } else { + System.out.println("writing with recipe:" + internalname); + for(Map.Entry entry : recipeJsonForDamage.entrySet()) { + ItemStack res = Utils.createItemStack(item, + EnumChatFormatting.WHITE+item.getItemStackDisplayName(new ItemStack(item, 1, entry.getKey())), + EnumChatFormatting.WHITE.toString()+EnumChatFormatting.BOLD+"COMMON"); + res.setItemDamage(entry.getKey()); + res.getTagCompound().setInteger("HideFlags", 254); + NBTTagCompound ea = new NBTTagCompound(); + ea.setString("id", internalname); + res.getTagCompound().setTag("ExtraAttributes", ea); + + JsonObject json = manager.getJsonForItem(res); + + if(entry.getKey() != 0 && entry.getKey() < 32000) { + json.addProperty("internalname", internalname+"-"+entry.getKey()); + json.addProperty("parent", internalname); + } else { + json.addProperty("internalname", internalname); + } + + json.addProperty("modver", NotEnoughUpdates.VERSION); + json.addProperty("vanilla", true); + json.addProperty("clickcommand", "viewrecipe"); + json.add("recipe", entry.getValue()); + try { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Added: " + internalname)); + if(entry.getKey() != 0 && entry.getKey() < 32000) { + manager.writeJsonDefaultDir(json, internalname+"-"+entry.getKey()+".json"); + } else { + manager.writeJsonDefaultDir(json, internalname+".json"); + } + manager.loadItem(internalname); + } catch(IOException e) {} + } + } + } + } + } + + //for(Map.Entry item : manager.getItemInformation().entrySet()) { /*if(!item.getValue().has("infoType") || item.getValue().get("infoType").getAsString().isEmpty()) { if(item.getValue().has("info") && item.getValue().get("info").getAsJsonArray().size()>0) { item.getValue().addProperty("infoType", "WIKI_URL"); @@ -167,7 +1023,7 @@ public class DevInfoPane extends TextInfoPane { } }, 1000L, TimeUnit.MILLISECONDS); }*/ - } + //} /*if(Keyboard.isKeyDown(Keyboard.KEY_J) && !running) { running = true; List add = new ArrayList<>(); 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 8b35f5cb..00716271 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java @@ -1,5 +1,6 @@ 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.util.Utils; @@ -175,6 +176,7 @@ public class SettingsInfoPane extends InfoPane { tf.setCustomBorderColour(-1); option.setValue(tf.getText()); overlay.redrawItems(); + BetterContainers.reset(); } catch(Exception e) { tf.setCustomBorderColour(Color.RED.getRGB()); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java index 06dfd246..da1b9ddc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBAnchorPoint.java @@ -9,9 +9,7 @@ public class MBAnchorPoint implements Serializable { public enum AnchorPoint { TOPLEFT(0, 0), TOPMID(0.5f, 0), TOPRIGHT(1, 0), MIDRIGHT(1, 0.5f), BOTRIGHT(1, 1), BOTMID(0.5f, 1), - BOTLEFT(0, 1), MIDLEFT(0, 0.5f), MIDMID(0.5f, 0.5f), - - INV_BOTMID(0.5f, 1f); + BOTLEFT(0, 1), MIDLEFT(0, 0.5f), MIDMID(0.5f, 0.5f); public final float x; public final float y; @@ -24,27 +22,33 @@ public class MBAnchorPoint implements Serializable { public AnchorPoint anchorPoint; public Vector2f offset; + public boolean inventoryRelative; public MBAnchorPoint(AnchorPoint anchorPoint, Vector2f offset) { + this(anchorPoint, offset, false); + } + + public MBAnchorPoint(AnchorPoint anchorPoint, Vector2f offset, boolean inventoryRelative) { this.anchorPoint = anchorPoint; this.offset = offset; + this.inventoryRelative = inventoryRelative; } public static MBAnchorPoint createFromString(String str) { - if(str == null || str.split(":").length != 3) { + if(str == null || str.split(":").length != 4) { return null; } try { String[] split = str.split(":"); AnchorPoint point = AnchorPoint.valueOf(split[0].toUpperCase()); - Vector2f pos = new Vector2f(Float.valueOf(split[1]), Float.valueOf(split[2])); - return new MBAnchorPoint(point, pos); + Vector2f pos = new Vector2f(Float.parseFloat(split[1]), Float.parseFloat(split[2])); + return new MBAnchorPoint(point, pos, Boolean.parseBoolean(split[3])); } catch(Exception e) { return null; } } @Override public String toString() { - return anchorPoint.toString() + ":" + offset.x + ":" + offset.y; + return anchorPoint.toString() + ":" + offset.x + ":" + offset.y + ":" + inventoryRelative; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java new file mode 100644 index 00000000..8f7d1bc0 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBDeserializer.java @@ -0,0 +1,20 @@ +package io.github.moulberry.notenoughupdates.mbgui; + +import com.google.gson.JsonObject; + +import java.io.IOException; + +public class MBDeserializer { + + public static MBGuiElement deserialize(JsonObject json) { + return null; + } + + public static void serializeAndSave(MBGuiElement element, String filename) throws IOException { + /*JsonObject json = element.serialize(); + + File file = new File(NotEnoughUpdates.INSTANCE.manager.configLocation, filename+".json"); + NotEnoughUpdates.INSTANCE.manager.writeJson(json, file);*/ + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java index 56a3f42c..1ff51238 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiElement.java @@ -9,4 +9,6 @@ public abstract class MBGuiElement { public abstract void mouseClickOutside(); public abstract void render(float x, float y); + //public abstract JsonObject serialize(); + } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java new file mode 100644 index 00000000..77a28fd5 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupAligned.java @@ -0,0 +1,67 @@ +package io.github.moulberry.notenoughupdates.mbgui; + +import org.lwjgl.util.vector.Vector2f; + +import java.util.Collection; +import java.util.List; + +public abstract class MBGuiGroupAligned extends MBGuiGroup { + + //Serialized + private List children; + private boolean vertical; + + public MBGuiGroupAligned(List children, boolean vertical) { + this.children = children; + this.vertical = vertical; + recalculate(); + } + + public abstract int getPadding(); + + public Collection getChildren() { + return children; + } + + public void recalculate() { + for(MBGuiElement child : children) { + child.recalculate(); + } + + if(vertical) { + height = 0; + for(int i=0; i width) { + width = childWidth; + } + } + } else { + width = 0; + for(int i=0; i height) { + height = childHeight; + } + } + } + + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java index 0c44932a..293fc241 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupFloating.java @@ -2,11 +2,11 @@ package io.github.moulberry.notenoughupdates.mbgui; import io.github.moulberry.notenoughupdates.GuiItemRecipe; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.auction.CustomAH; import io.github.moulberry.notenoughupdates.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainer; import org.lwjgl.util.vector.Vector2f; @@ -14,10 +14,12 @@ import java.util.*; public class MBGuiGroupFloating extends MBGuiGroup { - private LinkedHashMap children; private GuiScreen lastScreen = null; private HashMap childrenPositionOffset = new HashMap<>(); + //Serialized + private LinkedHashMap children; + public MBGuiGroupFloating(int width, int height, LinkedHashMap children) { this.width = width; this.height = height; @@ -39,6 +41,10 @@ public class MBGuiGroupFloating extends MBGuiGroup { if(lastScreen != currentScreen) { lastScreen = currentScreen; + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + int screenWidth = scaledResolution.getScaledWidth(); + int screenHeight = scaledResolution.getScaledHeight(); + int xSize = -1; int ySize = -1; int guiLeft = -1; @@ -83,13 +89,12 @@ public class MBGuiGroupFloating extends MBGuiGroup { childPos = new Vector2f(); } + if(anchorPoint.inventoryRelative) { + int defGuiLeft = (screenWidth - xSize) / 2; + int defGuiTop = (screenHeight - ySize) / 2; - if(anchorPoint.anchorPoint == MBAnchorPoint.AnchorPoint.INV_BOTMID) { - int defGuiLeft = (this.width - xSize) / 2; - int defGuiTop = (this.height - ySize) / 2; - - childPos.x += guiLeft-defGuiLeft + (anchorPoint.anchorPoint.x-0.5f)*xSize; - childPos.y += guiTop-defGuiTop + (anchorPoint.anchorPoint.y-0.5f)*ySize; + childPos.x += guiLeft-defGuiLeft + (0.5f-anchorPoint.anchorPoint.x)*xSize; + childPos.y += guiTop-defGuiTop + (0.5f-anchorPoint.anchorPoint.y)*ySize; } childrenPositionOffset.put(child, childPos); @@ -115,7 +120,7 @@ public class MBGuiGroupFloating extends MBGuiGroup { float x = anchorPoint.anchorPoint.x * width - anchorPoint.anchorPoint.x * child.getWidth() + anchorPoint.offset.x; float y = anchorPoint.anchorPoint.y * height - anchorPoint.anchorPoint.y * child.getHeight() + anchorPoint.offset.y; - if(anchorPoint.anchorPoint == MBAnchorPoint.AnchorPoint.INV_BOTMID) { + if(anchorPoint.inventoryRelative) { x = width*0.5f + anchorPoint.offset.x; y = height*0.5f + anchorPoint.offset.y; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupHorz.java b/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupHorz.java deleted file mode 100644 index cf477eac..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/mbgui/MBGuiGroupHorz.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.github.moulberry.notenoughupdates.mbgui; - -import org.lwjgl.util.vector.Vector2f; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; - -public abstract class MBGuiGroupHorz extends MBGuiGroup { - - private List children; - - public MBGuiGroupHorz(List children) { - this.children = children; - recalculate(); - } - - public abstract int getPadding(); - - public Collection getChildren() { - return children; - } - - public void recalculate() { - for(MBGuiElement child : children) { - child.recalculate(); - } - - width = 0; - for(int i=0; i height) { - height = childHeight; - } - } - } - -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java new file mode 100644 index 00000000..f56093b8 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java @@ -0,0 +1,32 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.BetterContainers; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.StreamerMode; +import net.minecraft.client.gui.GuiIngame; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Team; +import net.minecraft.util.ResourceLocation; +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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin({GuiChest.class}) +public class MixinGuiChest { + + private static final String TARGET = "Lnet/minecraft/client/renderer/texture/TextureManager;" + + "bindTexture(Lnet/minecraft/util/ResourceLocation;)V"; + @Redirect(method="drawGuiContainerBackgroundLayer", at=@At(value="INVOKE", target=TARGET)) + public void drawGuiContainerBackgroundLayer_bindTexture(TextureManager textureManager, ResourceLocation location) { + BetterContainers.bindHook(textureManager, location); + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java new file mode 100644 index 00000000..879d348b --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -0,0 +1,52 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.BetterContainers; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +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.Slot; +import net.minecraft.util.ResourceLocation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(GuiContainer.class) +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.isBlankStack(slot.getStack())) { + ci.cancel(); + } + } + + 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())) { + return false; + } + return slot.canBeHovered(); + } + + @Inject(method="handleMouseClick", at=@At(value="HEAD"), cancellable = true) + public void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType, CallbackInfo ci) { + if(slotIn != null && BetterContainers.isOverriding() && (BetterContainers.isBlankStack(slotIn.getStack()) || + BetterContainers.isButtonStack(slotIn.getStack()))) { + BetterContainers.clickSlot(slotIn.getSlotIndex()); + Utils.playPressSound(); + + 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 9dc0e714..294a8873 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java @@ -183,6 +183,16 @@ public class Options { "Coloured Tooltip Border Opacity", false, "Coloured tooltips only apply to tooltips in my GUIs. Value between 0-255.", 0, 255); + public Option dynamicMenuBackgroundStyle = new Option( + 1.0, + "SBMenu Background Style", + false, + "Style of the background used for the skyblock menu.", 0, 10); + public Option dynamicMenuButtonStyle = new Option( + 1.0, + "SBMenu Button Style", + false, + "Style of the buttons used for the skyblock menu.", 0, 10); /** * OPTIONS THAT DON'T SHOW IN GUI @@ -355,6 +365,8 @@ public class Options { tryAddOption(itemHighlightOpacity, options); tryAddOption(panePadding, options); tryAddOption(tooltipBorderOpacity, options); + tryAddOption(dynamicMenuBackgroundStyle, options); + tryAddOption(dynamicMenuButtonStyle, options); //Text tryAddOption(apiKey, options); 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 ae64c548..837addf3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -7,35 +7,24 @@ import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.mojang.authlib.GameProfile; import com.mojang.authlib.minecraft.MinecraftProfileTexture; -import com.mojang.authlib.properties.Property; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; 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.SBScoreboardData; -import io.github.moulberry.notenoughupdates.util.TexLoc; import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.texture.TextureUtil; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.client.resources.SkinManager; import net.minecraft.client.shader.Framebuffer; import net.minecraft.client.shader.Shader; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EnumPlayerModelParts; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -43,14 +32,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.*; import net.minecraft.util.*; -import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.Charsets; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.WordUtils; -import org.luaj.vm2.ast.Str; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @@ -58,9 +40,7 @@ import org.lwjgl.opengl.GL14; import org.lwjgl.opengl.GL20; import java.awt.*; -import java.io.ByteArrayInputStream; import java.io.IOException; -import java.nio.charset.Charset; import java.text.NumberFormat; import java.util.*; import java.util.List; @@ -174,7 +154,7 @@ public class GuiProfileViewer extends GuiScreen { Minecraft.getMinecraft().getTextureManager().bindTexture(pv_bg); Utils.drawTexturedRect(guiLeft, guiTop, sizeX, sizeY, GL11.GL_NEAREST); - if(!(currentPage == ProfileViewerPage.LOADING)) { + if(!(currentPage == ProfileViewerPage.LOADING) && profileId != null) { playerNameTextField.render(guiLeft+sizeX-100, guiTop+sizeY+5); ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); @@ -200,7 +180,7 @@ public class GuiProfileViewer extends GuiScreen { Utils.drawTexturedRect(guiLeft, guiTop+sizeY+23, 100, sizeYDropdown-4, 100/200f, 1, (181-sizeYDropdown)/185f, 181/185f, GL11.GL_NEAREST); - for(int yIndex=0; yIndex 0) { - int yPosition = 3; - int xPosition = 1; - - int x = guiLeft+237+86*xPosition; - int y = guiTop+31+21*yPosition; - - renderAlignedString(EnumChatFormatting.GRAY+"Catacombs", EnumChatFormatting.WHITE.toString()+cata, x+14, y-4, 60); - - renderBar(x, y+6, 80, cata/50f); - - if(mouseX > x && mouseX < x+80) { - if(mouseY > y-4 && mouseY < y+13) { - String levelStr; - if(cata == 50) { - levelStr = EnumChatFormatting.GOLD+"MAXED!"; - } else { - levelStr = EnumChatFormatting.DARK_PURPLE.toString() + cata + "/50"; - } - - tooltipToDisplay = Utils.createList(levelStr); - } - } - - GL11.glTranslatef((x), (y-6f), 0); - GL11.glScalef(0.7f, 0.7f, 1); - Utils.drawItemStackLinear(new ItemStack(Item.getItemFromBlock(Blocks.deadbush)), 0, 0); - GL11.glScalef(1/0.7f, 1/0.7f, 1); - GL11.glTranslatef(-(x), -(y-6f), 0); - } - if(skillInfo != null) { int position = 0; for(Map.Entry entry : ProfileViewer.getSkillToSkillDisplayMap().entrySet()) { 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 dac93e6f..36a616bb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/PlayerStats.java @@ -137,17 +137,20 @@ public class PlayerStats { for(Map.Entry entry : skillInfo.entrySet()) { if(entry.getKey().startsWith("level_")) { String skill = entry.getKey().substring("level_".length()); - JsonObject skillStatMap = Utils.getElement(bonuses, "bonus_stats."+skill).getAsJsonObject(); - - Stats currentBonus = new Stats(); - for(int i=1; i<=entry.getValue().getAsFloat(); i++) { - if(skillStatMap.has(""+i)) { - currentBonus = new Stats(); - for(Map.Entry entry2 : skillStatMap.get(""+i).getAsJsonObject().entrySet()) { - currentBonus.addStat(entry2.getKey(), entry2.getValue().getAsFloat()); + JsonElement element = Utils.getElement(bonuses, "bonus_stats."+skill); + if(element != null && element.isJsonObject()) { + JsonObject skillStatMap = element.getAsJsonObject(); + + Stats currentBonus = new Stats(); + for(int i=1; i<=entry.getValue().getAsFloat(); i++) { + if(skillStatMap.has(""+i)) { + currentBonus = new Stats(); + for(Map.Entry entry2 : skillStatMap.get(""+i).getAsJsonObject().entrySet()) { + currentBonus.addStat(entry2.getKey(), entry2.getValue().getAsFloat()); + } } + skillBonus.add(currentBonus); } - skillBonus.add(currentBonus); } } } 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 b6a0ce06..9c1de286 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -58,7 +58,7 @@ public class ProfileViewer { skillToSkillDisplayMap.put("skill_fishing", Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA+"Fishing")); skillToSkillDisplayMap.put("skill_alchemy", Utils.createItemStack(Items.brewing_stand, EnumChatFormatting.BLUE+"Alchemy")); skillToSkillDisplayMap.put("skill_runecrafting", Utils.createItemStack(Items.magma_cream, EnumChatFormatting.DARK_PURPLE+"Runecrafting")); - skillToSkillDisplayMap.put(null, null); + skillToSkillDisplayMap.put("skill_catacombs", Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush), EnumChatFormatting.GOLD+"Catacombs")); skillToSkillDisplayMap.put("slayer_zombie", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.GOLD+"Rev Slayer")); skillToSkillDisplayMap.put("slayer_spider", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.GOLD+"Tara Slayer")); skillToSkillDisplayMap.put("slayer_wolf", Utils.createItemStack(Items.bone, EnumChatFormatting.GOLD+"Sven Slayer")); @@ -127,7 +127,7 @@ public class ProfileViewer { EnumChatFormatting.YELLOW+"Seeds")); collectionToCollectionDisplayMap.put("MUSHROOM_COLLECTION", Utils.createItemStack(Item.getItemFromBlock(Blocks.red_mushroom) - , EnumChatFormatting.YELLOW+"Mushroom")); + , EnumChatFormatting.YELLOW+"Mushroom")); collectionToCollectionDisplayMap.put("INK_SACK:3", Utils.createItemStack(Items.dye, EnumChatFormatting.YELLOW+"Cocoa Beans", 3)); collectionToCollectionDisplayMap.put("CACTUS", Utils.createItemStack(Item.getItemFromBlock(Blocks.cactus), @@ -163,7 +163,7 @@ public class ProfileViewer { collectionToCollectionDisplayMap.put("INK_SACK:4", Utils.createItemStack(Items.dye, EnumChatFormatting.GRAY+"Lapis Lazuli", 4)); collectionToCollectionDisplayMap.put("EMERALD", Utils.createItemStack(Items.emerald, - EnumChatFormatting.GRAY+"Emerald")); + EnumChatFormatting.GRAY+"Emerald")); collectionToCollectionDisplayMap.put("REDSTONE", Utils.createItemStack(Items.redstone, EnumChatFormatting.GRAY+"Redstone")); collectionToCollectionDisplayMap.put("QUARTZ", Utils.createItemStack(Items.quartz, @@ -276,7 +276,6 @@ public class ProfileViewer { private HashMap stats = new HashMap<>(); private HashMap passiveStats = new HashMap<>(); private long networth = -1; - private int dungeonCatacombsLevel = -1; public Profile(String uuid) { this.uuid = uuid; @@ -294,123 +293,19 @@ public class ProfileViewer { HashMap args = new HashMap<>(); args.put("uuid", ""+uuid); manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "status", - args, jsonObject -> { - if(jsonObject == null) return; + args, jsonObject -> { + if(jsonObject == null) return; - updatingPlayerStatusState.set(false); - if(jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) { - playerStatus = jsonObject.get("session").getAsJsonObject(); - } - }, () -> updatingPlayerStatusState.set(false) + updatingPlayerStatusState.set(false); + if(jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) { + playerStatus = jsonObject.get("session").getAsJsonObject(); + } + }, () -> updatingPlayerStatusState.set(false) ); return null; } - public int getDungeonCatacombsLevel(String profileId) { - if (dungeonCatacombsLevel != -1) return dungeonCatacombsLevel; - if (getInventoryInfo(profileId) == null) return -1; - - JsonObject inventoryInfo = getInventoryInfo(profileId); - - Pattern pattern = Pattern.compile("\\u00A77[A-Za-z ]+: \\u00A7[a-f0-9]\\+(\\d+).+\\u00A78\\(\\+?([0-9\\.]+)(%| HP)?\\)"); - - List nums = new ArrayList<>(); - - try { - for(Map.Entry entry : inventoryInfo.entrySet()) { - if(entry.getValue().isJsonArray()) { - for(JsonElement element : entry.getValue().getAsJsonArray()) { - if(element != null && element.isJsonObject()) { - JsonObject item = element.getAsJsonObject(); - String internalname = item.get("internalname").getAsString(); - - //TODO: Make sure item is a catacombs level (using internalname) - - int dungeon_item_level = 0; - if(item.has("dungeon_item_level")) { - dungeon_item_level = item.get("dungeon_item_level").getAsInt(); - } - - if(item.has("lore") && item.get("lore").isJsonArray()) { - for(JsonElement lineElement : item.get("lore").getAsJsonArray()) { - if(lineElement.isJsonPrimitive()) { - String line = lineElement.getAsString(); - Matcher matcher = pattern.matcher(line); - if(matcher.matches()) { - String num1S = matcher.group(1); - String num2S = matcher.group(2); - - int num1 = Integer.parseInt(num1S); - float num2 = Float.parseFloat(num2S); - - float bonus = num2/num1 - dungeon_item_level*0.1f; - - if(bonus > 1) nums.add(bonus); - } - } - } - } - - try { - if(item.has("item_contents")) { - JsonArray bytesArr = item.get("item_contents").getAsJsonArray(); - byte[] bytes = new byte[bytesArr.size()]; - for (int bytesArrI = 0; bytesArrI < bytesArr.size(); bytesArrI++) { - bytes[bytesArrI] = bytesArr.get(bytesArrI).getAsByte(); - } - NBTTagCompound contents_nbt = CompressedStreamTools.readCompressed(new ByteArrayInputStream(bytes)); - NBTTagList items = contents_nbt.getTagList("i", 10); - for(int j=0; j 0) { - JsonObject item2 = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j)); - - int dungeon_item_level2 = 0; - if(item2.has("dungeon_item_level")) { - dungeon_item_level2 = item2.get("dungeon_item_level").getAsInt(); - } - - if(item2.has("lore") && item2.get("lore").isJsonArray()) { - for(JsonElement lineElement : item2.get("lore").getAsJsonArray()) { - if(lineElement.isJsonPrimitive()) { - String line = lineElement.getAsString(); - Matcher matcher = pattern.matcher(line); - if(matcher.matches()) { - String num1S = matcher.group(1); - String num2S = matcher.group(2); - - int num1 = Integer.parseInt(num1S); - float num2 = Float.parseFloat(num2S); - - float bonus = num2/num1 - dungeon_item_level2*0.1f; - - if(bonus > 1) nums.add(bonus); - } - } - } - } - } - } - } - } catch(IOException ignored) {} - } - } - } - } - } catch(Exception ignored) {} - - if(nums.size() > 0) { - nums.sort(Comparator.naturalOrder()); - int bonus = -100+Math.round(100*nums.get(nums.size()/2)); - dungeonCatacombsLevel = 0; - while(bonus > 0) { - dungeonCatacombsLevel++; - bonus -= 3+Math.ceil(dungeonCatacombsLevel/5f); - } - } - return dungeonCatacombsLevel; - } - public long getNetWorth(String profileId) { if(networth != -1) return networth; if(getProfileInformation(profileId) == null) return -1; @@ -448,6 +343,8 @@ public class ProfileViewer { NBTTagCompound nbt = items.getCompoundTagAt(j).getCompoundTag("tag"); String internalname2 = manager.getInternalnameFromNBT(nbt); if(internalname2 != null) { + if(manager.auctionManager.isVanillaItem(internalname2)) continue; + JsonObject info2 = manager.auctionManager.getItemAuctionInfo(internalname2); if(info2 == null || !info2.has("price") || !info2.has("count")) continue; int auctionPrice2 = (int)(info2.get("price").getAsFloat() / info2.get("count").getAsFloat()); @@ -647,7 +544,6 @@ public class ProfileViewer { inventoryInfoMap.clear(); collectionInfoMap.clear(); networth = -1; - dungeonCatacombsLevel = -1; } private class Level { @@ -699,6 +595,9 @@ public class ProfileViewer { float experience_skill_alchemy = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_alchemy"), 0); float experience_skill_runecrafting = Utils.getElementAsFloat(Utils.getElement(profileInfo, "experience_skill_runecrafting"), 0); + float experience_skill_catacombs = Utils.getElementAsFloat(Utils.getElement(profileInfo, "dungeons.dungeon_types.catacombs.experience"), 0); + if(uuid.equals("d14403fd77664905929ee1a6e365e623")) experience_skill_catacombs = 569809640; //lvl 50 + float experience_slayer_zombie = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.zombie.xp"), 0); float experience_slayer_spider = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.spider.xp"), 0); float experience_slayer_wolf = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses.wolf.xp"), 0); @@ -706,6 +605,7 @@ public class ProfileViewer { float totalSkillXP = experience_skill_taming + experience_skill_mining + experience_skill_foraging + experience_skill_enchanting + experience_skill_carpentry + experience_skill_farming + experience_skill_combat + experience_skill_fishing + experience_skill_alchemy + + experience_skill_catacombs + experience_skill_runecrafting; if(totalSkillXP <= 0) { @@ -725,6 +625,8 @@ public class ProfileViewer { skillInfo.addProperty("experience_skill_alchemy", experience_skill_alchemy); skillInfo.addProperty("experience_skill_runecrafting", experience_skill_runecrafting); + skillInfo.addProperty("experience_skill_catacombs", experience_skill_catacombs); + skillInfo.addProperty("experience_slayer_zombie", experience_slayer_zombie); skillInfo.addProperty("experience_slayer_spider", experience_slayer_spider); skillInfo.addProperty("experience_slayer_wolf", experience_slayer_wolf); @@ -740,6 +642,8 @@ public class ProfileViewer { Level level_skill_alchemy = getLevel(Utils.getElement(leveling, "leveling_xp").getAsJsonArray(), experience_skill_alchemy, false); Level level_skill_runecrafting = getLevel(Utils.getElement(leveling, "runecrafting_xp").getAsJsonArray(), experience_skill_runecrafting, false); + Level level_skill_catacombs = getLevel(Utils.getElement(leveling, "catacombs").getAsJsonArray(), experience_skill_catacombs, false); + Level level_slayer_zombie = getLevel(Utils.getElement(leveling, "slayer_xp.zombie").getAsJsonArray(), experience_slayer_zombie, true); Level level_slayer_spider = getLevel(Utils.getElement(leveling, "slayer_xp.spider").getAsJsonArray(), experience_slayer_spider, true); Level level_slayer_wolf = getLevel(Utils.getElement(leveling, "slayer_xp.wolf").getAsJsonArray(), experience_slayer_wolf, true); @@ -755,6 +659,8 @@ public class ProfileViewer { skillInfo.addProperty("level_skill_alchemy", level_skill_alchemy.level); skillInfo.addProperty("level_skill_runecrafting", level_skill_runecrafting.level); + skillInfo.addProperty("level_skill_catacombs", level_skill_catacombs.level); + skillInfo.addProperty("level_slayer_zombie", level_slayer_zombie.level); skillInfo.addProperty("level_slayer_spider", level_slayer_spider.level); skillInfo.addProperty("level_slayer_wolf", level_slayer_wolf.level); @@ -770,6 +676,8 @@ public class ProfileViewer { skillInfo.addProperty("maxed_skill_alchemy", level_skill_alchemy.maxed); skillInfo.addProperty("maxed_skill_runecrafting", level_skill_runecrafting.maxed); + skillInfo.addProperty("maxed_skill_catacombs", level_skill_catacombs.maxed); + skillInfo.addProperty("maxed_slayer_zombie", level_slayer_zombie.maxed); skillInfo.addProperty("maxed_slayer_spider", level_slayer_spider.maxed); skillInfo.addProperty("maxed_slayer_wolf", level_slayer_wolf.maxed); @@ -785,6 +693,8 @@ public class ProfileViewer { skillInfo.addProperty("maxxp_skill_alchemy", level_skill_alchemy.maxXpForLevel); skillInfo.addProperty("maxxp_skill_runecrafting", level_skill_runecrafting.maxXpForLevel); + skillInfo.addProperty("maxxp_skill_catacombs", level_skill_catacombs.maxXpForLevel); + skillInfo.addProperty("maxxp_slayer_zombie", level_slayer_zombie.maxXpForLevel); skillInfo.addProperty("maxxp_slayer_spider", level_slayer_spider.maxXpForLevel); skillInfo.addProperty("maxxp_slayer_wolf", level_slayer_wolf.maxXpForLevel); @@ -1030,17 +940,17 @@ public class ProfileViewer { HashMap args = new HashMap<>(); args.put("name", ""+name); manager.hypixelApi.getHypixelApiAsync(manager.config.apiKey.value, "player", - args, jsonObject -> { - if(jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean() - && jsonObject.get("player").isJsonObject()) { - nameToHypixelProfile.put(name, jsonObject.get("player").getAsJsonObject()); - uuidToHypixelProfile.put(jsonObject.get("player").getAsJsonObject().get("uuid").getAsString(), jsonObject.get("player").getAsJsonObject()); - if(callback != null) callback.accept(jsonObject); - } else { - if(callback != null) callback.accept(null); - return; + args, jsonObject -> { + if(jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean() + && jsonObject.get("player").isJsonObject()) { + nameToHypixelProfile.put(name, jsonObject.get("player").getAsJsonObject()); + uuidToHypixelProfile.put(jsonObject.get("player").getAsJsonObject().get("uuid").getAsString(), jsonObject.get("player").getAsJsonObject()); + if(callback != null) callback.accept(jsonObject); + } else { + if(callback != null) callback.accept(null); + return; + } } - } ); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java index 5ea6c023..d6f89409 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java @@ -84,6 +84,7 @@ public class HypixelApi { URL url = new URL(urlS); URLConnection connection = url.openConnection(); connection.setConnectTimeout(3000); + connection.setReadTimeout(10000); String response = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8); @@ -95,6 +96,7 @@ public class HypixelApi { URL url = new URL(urlS); URLConnection connection = url.openConnection(); connection.setConnectTimeout(3000); + connection.setReadTimeout(10000); String response = IOUtils.toString(new GZIPInputStream(connection.getInputStream()), StandardCharsets.UTF_8); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java b/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java index 48eea22d..5e792cf5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/TexLoc.java @@ -20,7 +20,7 @@ public class TexLoc { this.toggleKey = toggleKey; } - public void handleKeyboardInput() { + public boolean handleKeyboardInput() { int mult=1; if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) mult=10; if(Keyboard.isKeyDown(toggleKey)) { @@ -31,7 +31,7 @@ public class TexLoc { } else { pressedLastTick = false; } - if(toggled) { + if(toggled || toggleKey == 0) { if(Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { if(!dirPressed) x-=mult; dirPressed = true; @@ -46,10 +46,12 @@ public class TexLoc { dirPressed = true; } else { dirPressed = false; - return; + return false; } System.out.println("X: " + x + " ; Y: " + y); + return true; } + return false; } } diff --git a/src/main/resources/assets/notenoughupdates/accessory_bag_overlay.png b/src/main/resources/assets/notenoughupdates/accessory_bag_overlay.png new file mode 100644 index 00000000..6fcac4d1 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/accessory_bag_overlay.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/dynamic_54_button_ctm.png new file mode 100644 index 00000000..bab0eab7 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54.png new file mode 100644 index 00000000..934f6b4a Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_button_ctm.png new file mode 100644 index 00000000..956d085a Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_slot_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_slot_ctm.png new file mode 100644 index 00000000..fa43a0ed Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_slot_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54.png new file mode 100644 index 00000000..73711ee8 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54.png new file mode 100644 index 00000000..3a24654d Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_button_ctm.png new file mode 100644 index 00000000..fa43a0ed Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_button_ctm.png new file mode 100644 index 00000000..ea57f0d0 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/item_haschild.png b/src/main/resources/assets/notenoughupdates/item_haschild.png new file mode 100644 index 00000000..c3f3369a Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/item_haschild.png differ diff --git a/src/main/resources/assets/notenoughupdates/quickcommand_background.png b/src/main/resources/assets/notenoughupdates/quickcommand_background.png new file mode 100644 index 00000000..d3c2a3ad Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/quickcommand_background.png differ diff --git a/src/main/resources/assets/notenoughupdates/shaders/space_cape.frag b/src/main/resources/assets/notenoughupdates/shaders/space_cape.frag index b3cb8a1d..e3e5d56e 100644 --- a/src/main/resources/assets/notenoughupdates/shaders/space_cape.frag +++ b/src/main/resources/assets/notenoughupdates/shaders/space_cape.frag @@ -23,7 +23,7 @@ void main() { } } } else if(eventRand < 0.45f) { - vec2 extraPos = vec2(-30.0f+eventMillis/2000f*370.0f, 50.0f+(eventRand-0.4f)/0.05f*300.0f)/1024.0f; + vec2 extraPos = vec2(-30.0f+eventMillis/2000.0f*370.0f, 50.0f+(eventRand-0.4f)/0.05f*300.0f)/1024.0f; vec2 extraTexCoord = vec2(gl_TexCoord[0].s-extraPos.x+248.0f/1024.0f, gl_TexCoord[0].t-extraPos.y+894.0f/1024.0f); if(extraTexCoord.x > 200.0f/1024.0f && extraTexCoord.x < 300.0f/1024.0f) { if(extraTexCoord.y > 843.0f/1024.0f && extraTexCoord.y < 943.0f/1024.0f) { @@ -31,7 +31,7 @@ void main() { } } } else if(eventRand < 0.47f) { - vec2 extraPos = vec2(-30.0f+eventMillis/2000f*370.0f, 50.0f+(eventRand-0.45f)/0.02f*300.0f)/1024.0f; + vec2 extraPos = vec2(-30.0f+eventMillis/2000.0f*370.0f, 50.0f+(eventRand-0.45f)/0.02f*300.0f)/1024.0f; vec2 extraTexCoord = vec2(gl_TexCoord[0].s-extraPos.x+348.0f/1024.0f, gl_TexCoord[0].t-extraPos.y+894.0f/1024.0f); if(extraTexCoord.x > 300.0f/1024.0f && extraTexCoord.x < 400.0f/1024.0f) { if(extraTexCoord.y > 843.0f/1024.0f && extraTexCoord.y < 943.0f/1024.0f) { @@ -39,7 +39,7 @@ void main() { } } } else if(eventRand < 0.48f) { - vec2 extraPos = vec2(-30.0f+eventMillis/2000f*370.0f, 50.0f+(eventRand-0.47f)/0.01f*300.0f)/1024.0f; + vec2 extraPos = vec2(-30.0f+eventMillis/2000.0f*370.0f, 50.0f+(eventRand-0.47f)/0.01f*300.0f)/1024.0f; vec2 extraTexCoord = vec2(gl_TexCoord[0].s-extraPos.x+448.0f/1024.0f, gl_TexCoord[0].t-extraPos.y+894.0f/1024.0f); if(extraTexCoord.x > 400.0f/1024.0f && extraTexCoord.x < 500.0f/1024.0f) { if(extraTexCoord.y > 843.0f/1024.0f && extraTexCoord.y < 943.0f/1024.0f) { diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index f797c921..1ef9ee69 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -9,6 +9,8 @@ "MixinRenderItem", "MixinEntityRenderer", "MixinRenderGlobal", - "MixinNetHandlerPlayClient" + "MixinNetHandlerPlayClient", + "MixinGuiChest", + "MixinGuiContainer" ] } \ No newline at end of file -- cgit From a0402708801b525145d01d0f4da17f0ba9d93455 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sun, 18 Oct 2020 21:01:11 +1100 Subject: 1.4 --- build.gradle | 2 +- .../notenoughupdates/AccessoryBagOverlay.java | 299 ++++++++++++++- .../notenoughupdates/BetterContainers.java | 92 ++++- .../notenoughupdates/CustomItemEffects.java | 7 +- .../moulberry/notenoughupdates/DungeonBlocks.java | 315 ++++++++++++++++ .../moulberry/notenoughupdates/DungeonMap.java | 416 +++++++++++++++++++++ .../notenoughupdates/GuiEnchantColour.java | 35 +- .../moulberry/notenoughupdates/GuiTextures.java | 6 + .../notenoughupdates/NEUEventListener.java | 260 +++++++++---- .../moulberry/notenoughupdates/NEUManager.java | 22 +- .../moulberry/notenoughupdates/NEUOverlay.java | 102 +++-- .../notenoughupdates/NotEnoughUpdates.java | 193 +++++++++- .../notenoughupdates/auction/APIManager.java | 20 +- .../notenoughupdates/auction/CustomAH.java | 77 +++- .../notenoughupdates/cosmetics/CapeManager.java | 32 +- .../notenoughupdates/cosmetics/GuiCosmetics.java | 46 +-- .../notenoughupdates/cosmetics/NEUCape.java | 4 + .../notenoughupdates/gamemodes/SBGamemodes.java | 14 +- .../infopanes/CollectionLogInfoPane.java | 6 +- .../notenoughupdates/infopanes/InfoPane.java | 2 + .../infopanes/SettingsInfoPane.java | 366 ++++++++++++++++-- .../itemeditor/GuiElementTextField.java | 69 ++-- .../notenoughupdates/mixins/MixinEntityPlayer.java | 34 ++ .../notenoughupdates/mixins/MixinGuiChest.java | 20 + .../notenoughupdates/mixins/MixinGuiContainer.java | 10 +- .../notenoughupdates/mixins/MixinRenderBat.java | 40 ++ .../notenoughupdates/mixins/MixinRenderList.java | 38 ++ .../mixins/MixinTileEntitySpecialRenderer.java | 33 ++ .../mixins/MixinVboRenderList.java | 42 +++ .../notenoughupdates/options/Options.java | 125 ++++++- .../profileviewer/GuiProfileViewer.java | 47 ++- .../notenoughupdates/profileviewer/Panorama.java | 11 + .../notenoughupdates/questing/SBInfo.java | 125 +++++++ .../questing/SBScoreboardData.java | 88 ----- .../requirements/RequirementIslandType.java | 4 +- .../notenoughupdates/util/HypixelApi.java | 14 +- .../notenoughupdates/util/SpecialColour.java | 81 ++++ .../assets/notenoughupdates/button_white.png | Bin 0 -> 6570 bytes .../assets/notenoughupdates/capes/lava.png | Bin 0 -> 169280 bytes .../assets/notenoughupdates/capes/mbstaff.png | Bin 0 -> 470630 bytes .../assets/notenoughupdates/capes/packshq.png | Bin 0 -> 22716 bytes .../notenoughupdates/colour_selector_bar.png | Bin 0 -> 245 bytes .../notenoughupdates/colour_selector_bar_alpha.png | Bin 0 -> 240 bytes .../notenoughupdates/colour_selector_chroma.png | Bin 0 -> 211 bytes .../notenoughupdates/colour_selector_dot.png | Bin 0 -> 3677 bytes .../dynamic_54/dynamic_54_button_ctm.png | Bin 543 -> 0 bytes .../dynamic_54/style1/dynamic_54.png | Bin 5234 -> 4299 bytes .../dynamic_54/style1/dynamic_54_button_ctm.png | Bin 607 -> 4312 bytes .../dynamic_54/style1/dynamic_54_slot_ctm.png | Bin 539 -> 4721 bytes .../dynamic_54/style1/dynamic_config.json | 3 + .../dynamic_54/style2/dynamic_54.png | Bin 5429 -> 4424 bytes .../dynamic_54/style2/dynamic_54_button_ctm.png | Bin 0 -> 4723 bytes .../dynamic_54/style2/dynamic_54_slot_ctm.png | Bin 0 -> 4721 bytes .../dynamic_54/style2/dynamic_config.json | 3 + .../dynamic_54/style3/dynamic_54.png | Bin 5519 -> 2555 bytes .../dynamic_54/style3/dynamic_54_button_ctm.png | Bin 539 -> 4602 bytes .../dynamic_54/style3/dynamic_54_slot_ctm.png | Bin 0 -> 4602 bytes .../dynamic_54/style3/dynamic_config.json | 3 + .../dynamic_54/style4/dynamic_54.png | Bin 0 -> 5234 bytes .../dynamic_54/style4/dynamic_54_button_ctm.png | Bin 3437 -> 607 bytes .../dynamic_54/style4/dynamic_54_slot_ctm.png | Bin 0 -> 539 bytes .../dynamic_54/style5/dynamic_54.png | Bin 0 -> 5429 bytes .../dynamic_54/style5/dynamic_54_button_ctm.png | Bin 0 -> 543 bytes .../dynamic_54/style5/dynamic_54_slot_ctm.png | Bin 0 -> 539 bytes .../dynamic_54/style6/dynamic_54.png | Bin 0 -> 5519 bytes .../dynamic_54/style6/dynamic_54_button_ctm.png | Bin 0 -> 539 bytes .../dynamic_54/style6/dynamic_54_slot_ctm.png | Bin 0 -> 539 bytes .../dynamic_54/style7/dynamic_54.png | Bin 0 -> 5234 bytes .../dynamic_54/style7/dynamic_54_button_ctm.png | Bin 0 -> 3437 bytes .../dynamic_54/style7/dynamic_54_slot_ctm.png | Bin 0 -> 539 bytes .../notenoughupdates/dynamic_54/toggle_off.png | Bin 0 -> 389 bytes .../notenoughupdates/dynamic_54/toggle_on.png | Bin 0 -> 406 bytes .../assets/notenoughupdates/shaders/lava_cape.frag | 32 ++ .../assets/notenoughupdates/shaders/lava_cape.vert | 12 + .../notenoughupdates/supersecretassets/bald.png | Bin 0 -> 19909 bytes src/main/resources/mixins.notenoughupdates.json | 7 +- 76 files changed, 2759 insertions(+), 398 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderBat.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/questing/SBScoreboardData.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java create mode 100644 src/main/resources/assets/notenoughupdates/button_white.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/lava.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/mbstaff.png create mode 100644 src/main/resources/assets/notenoughupdates/capes/packshq.png create mode 100644 src/main/resources/assets/notenoughupdates/colour_selector_bar.png create mode 100644 src/main/resources/assets/notenoughupdates/colour_selector_bar_alpha.png create mode 100644 src/main/resources/assets/notenoughupdates/colour_selector_chroma.png create mode 100644 src/main/resources/assets/notenoughupdates/colour_selector_dot.png delete mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/dynamic_54_button_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_config.json create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54_button_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54_slot_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_config.json create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_slot_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_config.json create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_slot_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54_button_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54_slot_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54_button_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54_slot_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54_button_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54_slot_ctm.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/toggle_off.png create mode 100644 src/main/resources/assets/notenoughupdates/dynamic_54/toggle_on.png create mode 100644 src/main/resources/assets/notenoughupdates/shaders/lava_cape.frag create mode 100644 src/main/resources/assets/notenoughupdates/shaders/lava_cape.vert create mode 100644 src/main/resources/assets/notenoughupdates/supersecretassets/bald.png (limited to 'src/main/resources/mixins.notenoughupdates.json') diff --git a/build.gradle b/build.gradle index 06d19abe..45038326 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'com.github.johnrengelman.shadow' sourceCompatibility = 1.8 targetCompatibility = 1.8 -version = "1.3-REL" +version = "1.4-REL" group= "io.github.moulberry" archivesBaseName = "NotEnoughUpdates" String modid = "notenoughupdates" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java index 65d4efc7..1011f3cc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java @@ -1,11 +1,13 @@ 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.profileviewer.PlayerStats; 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; import net.minecraft.client.gui.inventory.GuiContainer; @@ -41,6 +43,7 @@ public class AccessoryBagOverlay { private static final int TAB_BONUS = 2; private static final int TAB_DUP = 3; private static final int TAB_MISSING = 4; + private static final int TAB_OPTIMIZER = 5; private static final ItemStack[] TAB_STACKS = new ItemStack[] { Utils.createItemStack(Items.dye, EnumChatFormatting.DARK_AQUA+"Basic Information", @@ -53,6 +56,8 @@ public class AccessoryBagOverlay { 8), Utils.createItemStack(Item.getItemFromBlock(Blocks.barrier), EnumChatFormatting.DARK_AQUA+"Missing", 0), + Utils.createItemStack(Item.getItemFromBlock(Blocks.redstone_block), EnumChatFormatting.DARK_AQUA+"Optimizer", + 0), }; private static int currentTab = TAB_BASIC; @@ -82,6 +87,36 @@ public class AccessoryBagOverlay { if(currentTab > TAB_MISSING) currentTab = TAB_MISSING; } + if(currentTab == TAB_OPTIMIZER) { + int x = guiLeft+xSize+3; + int y = guiTop; + + if(mouseY > y+92 && mouseY < y+103) { + if(mouseX > x+5 && mouseX < x+75) { + mainWeapon = (int)Math.floor((mouseX-x-5)/70f*9); + if(mainWeapon < 1) { + mainWeapon = 1; + } else if(mainWeapon > 9) { + mainWeapon = 9; + } + } + } + + if(mouseX > x+5 && mouseX < x+35 || mouseX > x+45 && mouseX < x+75) { + boolean set = mouseX > x+5 && mouseX < x+35; + + if(mouseY > y+32 && mouseY < y+43) { + forceCC = set; + } else if(mouseY > y+52 && mouseY < y+63) { + forceAS = set; + } else if(mouseY > y+72 && mouseY < y+83) { + useGodPot = set; + } else if(mouseY > y+92 && mouseY < y+103) { + allowShaded = set; + } + } + } + return true; } catch(Exception e) { return false; @@ -94,6 +129,8 @@ public class AccessoryBagOverlay { talismanCountRarity = null; totalStats = null; reforgeStats = null; + duplicates = null; + missing = null; } private static Set accessoryStacks = new HashSet<>(); @@ -116,7 +153,7 @@ public class AccessoryBagOverlay { } } - Utils.drawStringCenteredScaledMaxWidth("# By Rarity", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, true, 70, + Utils.drawStringCenteredScaledMaxWidth("# By Rarity", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70, new Color(80, 80, 80).getRGB()); int yIndex = 0; @@ -137,7 +174,7 @@ public class AccessoryBagOverlay { } } - Utils.drawStringCenteredScaledMaxWidth("Total Stats", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, true, 70, + Utils.drawStringCenteredScaledMaxWidth("Total Stats", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70, new Color(80, 80, 80).getRGB()); int yIndex = 0; for(int i=0; i duplicates = new HashSet<>(); + private static Set duplicates = null; public static void renderDuplicatesOverlay(int x, int y) { - Utils.drawStringCenteredScaledMaxWidth("Duplicates", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, true, 70, - new Color(80, 80, 80).getRGB()); + if(duplicates == null) { + JsonObject misc = Utils.getConstant("misc"); + if(misc == null) { + Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70, + new Color(80, 80, 80).getRGB()); + return; + } + JsonElement talisman_upgrades_element = misc.get("talisman_upgrades"); + if(talisman_upgrades_element == null) { + Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70, + new Color(80, 80, 80).getRGB()); + return; + } + JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject(); + + duplicates = new HashSet<>(); + + Set prevInternalnames = new HashSet<>(); + for(ItemStack stack : accessoryStacks) { + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack); + + if(prevInternalnames.contains(internalname)) { + duplicates.add(stack); + continue; + } + prevInternalnames.add(internalname); + + if(talisman_upgrades.has(internalname)) { + JsonArray upgrades = talisman_upgrades.get(internalname).getAsJsonArray(); + for(ItemStack stack2 : accessoryStacks) { + if(stack != stack2) { + String internalname2 = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack2); + for(int j=0; j 11) { + if(++yIndex >= 10) break; + } else { + if(++yIndex >= 11) break; + } + } + + if(duplicates.size() > 11) { + Utils.drawStringCenteredScaledMaxWidth("+" + (duplicates.size()-10) + " More", + Minecraft.getMinecraft().fontRendererObj, x+40, y+16+121, false, 70, + new Color(80, 80, 80).getRGB()); + } + } } + private static List missing = null; public static void renderMissingOverlay(int x, int y) { + if(missing == null) { + JsonObject misc = Utils.getConstant("misc"); + if(misc == null) { + Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70, + new Color(80, 80, 80).getRGB()); + return; + } + JsonElement talisman_upgrades_element = misc.get("talisman_upgrades"); + if(talisman_upgrades_element == null) { + Utils.drawStringCenteredScaledMaxWidth("Duplicates: ERROR", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70, + new Color(80, 80, 80).getRGB()); + return; + } + JsonObject talisman_upgrades = talisman_upgrades_element.getAsJsonObject(); + + missing = new ArrayList<>(); + + List missingInternal = new ArrayList<>(); + for(Map.Entry entry : NotEnoughUpdates.INSTANCE.manager.getItemInformation().entrySet()) { + if(entry.getValue().has("lore")) { + if(checkItemType(entry.getValue().get("lore").getAsJsonArray(), "ACCESSORY", "HATCCESSORY") >= 0) { + missingInternal.add(entry.getKey()); + } + } + } + + for(ItemStack stack : accessoryStacks) { + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack); + missingInternal.remove(internalname); + + for(Map.Entry talisman_upgrade_element : talisman_upgrades.entrySet()) { + JsonArray upgrades = talisman_upgrade_element.getValue().getAsJsonArray(); + for(int j=0; j 11) { + if(++yIndex >= 10) break; + } else { + if(++yIndex >= 11) break; + } + } + + if(missing.size() > 11) { + Utils.drawStringCenteredScaledMaxWidth("+" + (missing.size()-10) + " More", + Minecraft.getMinecraft().fontRendererObj, x+40, y+16+121, false, 70, + new Color(80, 80, 80).getRGB()); + } + } + } + + private static boolean forceCC = false; + private static boolean forceAS = false; + private static boolean useGodPot = true; + private static boolean allowShaded = true; + private static int mainWeapon = 1; + + public static void renderOptimizerOverlay(int x, int y) { + Utils.drawStringCenteredScaledMaxWidth("Optimizer", Minecraft.getMinecraft().fontRendererObj, x+40, y+12, false, 70, + new Color(80, 80, 80).getRGB()); + + int light = new Color(220, 220, 220).getRGB(); + int dark = new Color(170, 170, 170).getRGB(); + + Gui.drawRect(x+5, y+32, x+35, y+43, forceCC?dark:light); + Gui.drawRect(x+45, y+32, x+75, y+43, forceCC?light:dark); + + Gui.drawRect(x+5, y+52, x+35, y+63, forceAS?dark:light); + Gui.drawRect(x+45, y+52, x+75, y+63, forceAS?light:dark); + + Gui.drawRect(x+5, y+72, x+35, y+83, useGodPot?dark:light); + Gui.drawRect(x+45, y+72, x+75, y+83, useGodPot?light:dark); + + Gui.drawRect(x+5, y+92, x+35, y+103, allowShaded?dark:light); + Gui.drawRect(x+45, y+92, x+75, y+103, allowShaded?light:dark); + + Gui.drawRect(x+5, y+102, x+75, y+113, light); + Gui.drawRect(x+5+(int)((mainWeapon-1)/9f*70), y+102, x+5+(int)(mainWeapon/9f*70), y+113, dark); + + Utils.drawStringCenteredScaledMaxWidth("Force 100% CC", Minecraft.getMinecraft().fontRendererObj, x+40, y+27, false, 70, + new Color(80, 80, 80).getRGB()); + Utils.drawStringCenteredScaledMaxWidth((forceCC?EnumChatFormatting.GREEN:EnumChatFormatting.GRAY)+"YES", + Minecraft.getMinecraft().fontRendererObj, x+20, y+37, + true, 30, new Color(80, 80, 80).getRGB()); + Utils.drawStringCenteredScaledMaxWidth((forceCC?EnumChatFormatting.GRAY:EnumChatFormatting.RED)+"NO", Minecraft.getMinecraft().fontRendererObj, x+60, y+37, + true, 30, new Color(80, 80, 80).getRGB()); + + Utils.drawStringCenteredScaledMaxWidth("Force 100% ATKSPEED", Minecraft.getMinecraft().fontRendererObj, x+40, y+47, false, 70, + new Color(80, 80, 80).getRGB()); + Utils.drawStringCenteredScaledMaxWidth((forceAS?EnumChatFormatting.GREEN:EnumChatFormatting.GRAY)+"YES", Minecraft.getMinecraft().fontRendererObj, x+20, y+57, + true, 30, new Color(80, 80, 80).getRGB()); + Utils.drawStringCenteredScaledMaxWidth((forceAS?EnumChatFormatting.GRAY:EnumChatFormatting.RED)+"NO", Minecraft.getMinecraft().fontRendererObj, x+60, y+57, + true, 30, new Color(80, 80, 80).getRGB()); + + Utils.drawStringCenteredScaledMaxWidth("Use God Potion", Minecraft.getMinecraft().fontRendererObj, x+40, y+67, false, 70, + new Color(80, 80, 80).getRGB()); + Utils.drawStringCenteredScaledMaxWidth((useGodPot?EnumChatFormatting.GREEN:EnumChatFormatting.GRAY)+"YES", Minecraft.getMinecraft().fontRendererObj, x+20, y+77, + true, 30, new Color(80, 80, 80).getRGB()); + Utils.drawStringCenteredScaledMaxWidth((useGodPot?EnumChatFormatting.GRAY:EnumChatFormatting.RED)+"NO", Minecraft.getMinecraft().fontRendererObj, x+60, y+77, + true, 30, new Color(80, 80, 80).getRGB()); + + Utils.drawStringCenteredScaledMaxWidth("Use God Potion", Minecraft.getMinecraft().fontRendererObj, x+40, y+87, false, 70, + new Color(80, 80, 80).getRGB()); + Utils.drawStringCenteredScaledMaxWidth((allowShaded?EnumChatFormatting.GREEN:EnumChatFormatting.GRAY)+"YES", + Minecraft.getMinecraft().fontRendererObj, x+20, y+97, + true, 30, new Color(80, 80, 80).getRGB()); + Utils.drawStringCenteredScaledMaxWidth((allowShaded?EnumChatFormatting.GRAY:EnumChatFormatting.RED)+"NO", + Minecraft.getMinecraft().fontRendererObj, x+60, y+97, + true, 30, new Color(80, 80, 80).getRGB()); + + Utils.drawStringCenteredScaledMaxWidth("Main Weapon", Minecraft.getMinecraft().fontRendererObj, x+40, y+107, false, 70, + new Color(80, 80, 80).getRGB()); + Utils.drawStringCenteredScaled("1 2 3 4 5 6 7 8 9", + Minecraft.getMinecraft().fontRendererObj, x+40, y+117, + true, 70, new Color(80, 80, 80).getRGB()); + } + + private static Comparator getItemComparator() { + return (o1, o2) -> { + float cost1; + JsonObject o1Auc = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o1); + if(o1Auc != null && o1Auc.has("price")) { + cost1 = o1Auc.get("price").getAsFloat(); + } else { + cost1 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(o1).craftCost; + } + float cost2; + JsonObject o2Auc = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(o2); + if(o2Auc != null && o2Auc.has("price")) { + cost2 = o2Auc.get("price").getAsFloat(); + } else { + cost2 = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(o2).craftCost; + } + + + if(cost1 < cost2) return -1; + if(cost1 > cost2) return 1; + + return o1.compareTo(o2); + }; } public static void renderOverlay() { @@ -276,6 +541,11 @@ public class AccessoryBagOverlay { Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay); Utils.drawTexturedRect(guiLeft+xSize+3, guiTop, 80, 149, 0, 80/256f, 0, 149/256f, GL11.GL_NEAREST); + if(pagesVisited.size() < 1) { + renderVisitOverlay(guiLeft+xSize+3, guiTop); + return; + } + Minecraft.getMinecraft().getTextureManager().bindTexture(accessory_bag_overlay); Utils.drawTexturedRect(guiLeft+xSize+80, guiTop+20*currentTab, 28, 22, 80/256f, 108/256f, 22/256f, 44/256f, GL11.GL_NEAREST); @@ -292,6 +562,8 @@ public class AccessoryBagOverlay { renderDuplicatesOverlay(guiLeft+xSize+3, guiTop); return; case TAB_MISSING: renderMissingOverlay(guiLeft+xSize+3, guiTop); return; + case TAB_OPTIMIZER: + renderOptimizerOverlay(guiLeft+xSize+3, guiTop); return; } } catch(Exception e) { e.printStackTrace(); @@ -500,6 +772,20 @@ public class AccessoryBagOverlay { } return -1; } + private static int checkItemType(JsonArray lore, String... typeMatches) { + for(int i=lore.size()-1; i>=0; i--) { + String line = lore.get(i).getAsString(); + + for(String rarity : rarityArr) { + for(int j=0; j= 0; @@ -523,5 +809,4 @@ public class AccessoryBagOverlay { } return -1; } - } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java b/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java index b17c84a0..6a876201 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/BetterContainers.java @@ -1,5 +1,6 @@ package io.github.moulberry.notenoughupdates; +import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.util.TexLoc; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -14,22 +15,30 @@ import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; +import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.Random; public class BetterContainers { + private static final ResourceLocation TOGGLE_OFF = new ResourceLocation("notenoughupdates:dynamic_54/toggle_off.png"); + private static final ResourceLocation TOGGLE_ON = new ResourceLocation("notenoughupdates:dynamic_54/toggle_on.png"); + private static final ResourceLocation DYNAMIC_54_BASE = new ResourceLocation("notenoughupdates:dynamic_54/style1/dynamic_54.png"); private static final ResourceLocation DYNAMIC_54_SLOT = new ResourceLocation("notenoughupdates:dynamic_54/style1/dynamic_54_slot_ctm.png"); private static final ResourceLocation DYNAMIC_54_BUTTON = new ResourceLocation("notenoughupdates:dynamic_54/style1/dynamic_54_button_ctm.png"); private static final ResourceLocation rl = new ResourceLocation("notenoughupdates:dynamic_chest_inventory.png"); private static boolean loaded = false; private static DynamicTexture texture = null; + private static int textColour = 4210752; private static int lastClickedSlot = 0; private static int clickedSlot = 0; @@ -62,6 +71,15 @@ public class BetterContainers { textureManager.bindTexture(location); } + public static boolean isAh() { + if(!isChestOpen()) return false; + + GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + return containerName.trim().startsWith("Auctions Browser") || containerName.trim().startsWith("Wardrobe"); + } + public static boolean isOverriding() { return isChestOpen() && loaded && texture != null && !Keyboard.isKeyDown(Keyboard.KEY_B); } @@ -71,21 +89,66 @@ public class BetterContainers { stack.getDisplayName() != null && stack.getDisplayName().trim().isEmpty(); } + public static boolean shouldRenderStack(ItemStack stack) { + return !isBlankStack(stack) && !isToggleOff(stack) && !isToggleOn(stack); + } + public static boolean isButtonStack(ItemStack stack) { return stack != null && stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane) - && NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack) == null; + && NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack) == null && !isToggleOn(stack) && !isToggleOff(stack); + } + + public static int getTextColour() { + return textColour; + } + + public static boolean isToggleOn(ItemStack stack) { + if(stack != null && stack.getTagCompound() != null && stack.getTagCompound().hasKey("display", 10) && + stack.getTagCompound().getCompoundTag("display").hasKey("Lore", 9)) { + NBTTagList lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8); + if(lore.tagCount() == 1 && lore.getStringTagAt(0).equalsIgnoreCase(EnumChatFormatting.GRAY+"click to disable!")) { + return true; + } + } + return false; + } + + public static boolean isToggleOff(ItemStack stack) { + if(stack != null && stack.getTagCompound() != null && stack.getTagCompound().hasKey("display", 10) && + stack.getTagCompound().getCompoundTag("display").hasKey("Lore", 9)) { + NBTTagList lore = stack.getTagCompound().getCompoundTag("display").getTagList("Lore", 8); + if(lore.tagCount() == 1 && lore.getStringTagAt(0).equalsIgnoreCase(EnumChatFormatting.GRAY+"click to enable!")) { + return true; + } + } + return false; } private static void generateTex(ResourceLocation location) { if(!hasItem()) return; 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) { try { + BufferedImage bufferedImageOn = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(TOGGLE_ON).getInputStream()); + BufferedImage bufferedImageOff = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(TOGGLE_OFF).getInputStream()); + BufferedImage bufferedImageBase = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(DYNAMIC_54_BASE).getInputStream()); try { - int backgroundStyle = NotEnoughUpdates.INSTANCE.manager.config.dynamicMenuBackgroundStyle.value.intValue(); - backgroundStyle = Math.max(1, Math.min(10, backgroundStyle)); bufferedImageBase = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource( new ResourceLocation("notenoughupdates:dynamic_54/style"+ backgroundStyle+"/dynamic_54.png")).getInputStream()); } catch(Exception e) {} @@ -117,8 +180,7 @@ public class BetterContainers { boolean[][] buttons = new boolean[9][size/9]; for (int index = 0; index < size; index++) { ItemStack stack = lower.getStackInSlot(index); - buttons[index%9][index/9] = stack != null && stack.getItem() != Item.getItemFromBlock(Blocks.stained_glass_pane) - && NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(stack) == null; + buttons[index%9][index/9] = isButtonStack(stack); if(buttons[index%9][index/9] && getClickedSlot() == index) { buttons[index%9][index/9] = false; @@ -128,12 +190,30 @@ public class BetterContainers { } } for (int index = 0; index < size; index++) { + ItemStack stack = lower.getStackInSlot(index); int xi = index%9; int yi = index/9; if(slots[xi][yi] || buttons[xi][yi]) { int x = 7*horzTexMult + xi*18*horzTexMult; int y = 17*vertTexMult + yi*18*vertTexMult; + boolean on = isToggleOn(stack); + boolean off = isToggleOff(stack); + + if(on || off) { + for(int x2=0; x2<18; x2++) { + for(int y2=0; y2<18; y2++) { + BufferedImage toggle = on ? bufferedImageOn : bufferedImageOff; + Color c = new Color(toggle.getRGB(x2, y2), true); + if(c.getAlpha() < 10) { + continue; + } + bufferedImageNew.setRGB(x+x2, y+y2, c.getRGB()); + } + } + continue; + } + if(buttons[xi][yi]) { boolean up = yi > 0 && buttons[xi][yi-1]; boolean right = xi < buttons.length-1 && buttons[xi+1][yi]; @@ -149,6 +229,7 @@ public class BetterContainers { int[] rgbs = bufferedImageButton.getRGB((ctmIndex%12)*19*horzTexMult, (ctmIndex/12)*19*vertTexMult, 18*horzTexMult, 18*vertTexMult, null, 0, 18*vertTexMult); bufferedImageNew.setRGB(x, y, 18*horzTexMult, 18*vertTexMult, rgbs, 0, 18*vertTexMult); + } else { boolean up = yi > 0 && slots[xi][yi-1]; boolean right = xi < slots.length-1 && slots[xi+1][yi]; @@ -179,6 +260,7 @@ public class BetterContainers { loaded = false; clickedSlot = -1; clickedSlotMillis = 0; + textColour = 4210752; } private static boolean isChestOpen() { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java index 9d3c1c2f..cc94981f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java @@ -1,5 +1,6 @@ package io.github.moulberry.notenoughupdates; +import io.github.moulberry.notenoughupdates.util.SpecialColour; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -24,6 +25,7 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; import org.lwjgl.opengl.GL11; import org.lwjgl.util.vector.Vector3f; +import java.awt.*; import java.util.HashSet; import java.util.LinkedList; @@ -185,7 +187,7 @@ public class CustomItemEffects { drawSelectionBoundingBox(block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, candidate) .expand(0.001D, 0.001D, 0.001D).offset(-d0, -d1, -d2), - random ? 0.1f : 0.2f); + random ? 0.5f : 1f); } } } @@ -199,7 +201,8 @@ public class CustomItemEffects { } public static void drawSelectionBoundingBox(AxisAlignedBB p_181561_0_, float alpha) { - GlStateManager.color(64/255f, 224/255f, 208/255f, alpha); + Color c = new Color(SpecialColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.manager.config.treecapOverlayColour.value), true); + GlStateManager.color(c.getRed()/255f, c.getGreen()/255f, c.getBlue()/255f, c.getAlpha()/255f*alpha); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java new file mode 100644 index 00000000..29f5edc7 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java @@ -0,0 +1,315 @@ +package io.github.moulberry.notenoughupdates; + +import io.github.moulberry.notenoughupdates.questing.SBInfo; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.texture.*; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.*; + +import java.nio.IntBuffer; +import java.util.HashMap; +import java.util.Map; + +public class DungeonBlocks implements IResourceManagerReloadListener { + + //public static Framebuffer framebuffer = null; + private static int textureId = -1; + private static IntBuffer intbuffer = null; + private static HashMap modified = new HashMap<>(); + + @Override + public void onResourceManagerReload(IResourceManager resourceManager) { + reset(); + } + + public static boolean textureExists() { + return textureId != -1 && isInDungeons(); + } + + public static void bindTextureIfExists() { + if(textureExists()) { + GlStateManager.bindTexture(textureId); + } + } + + public static boolean isInDungeons() { + return NotEnoughUpdates.INSTANCE.manager.config.dungeonBlocksEverywhere.value || + (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon")); + } + + public static void reset() { + textureId = -1; + intbuffer = null; + for(int tex : modified.values()) { + GlStateManager.deleteTexture(tex); + } + modified.clear(); + } + + public static int getModifiedTexture(ResourceLocation location, int colour) { + String id = location.getResourceDomain()+":"+location.getResourcePath(); + if(modified.containsKey(id)) { + return modified.get(id); + } + + Minecraft.getMinecraft().getTextureManager().bindTexture(location); + int mipmapLevels = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL); + int w = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); + int h = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT); + + if(intbuffer == null || intbuffer.capacity() < w*h) intbuffer = BufferUtils.createIntBuffer(w*h); + + int textureId = TextureUtil.glGenTextures(); + GlStateManager.bindTexture(textureId); + + if (mipmapLevels >= 0) { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, mipmapLevels); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)mipmapLevels); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); + } + + 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)); + } + + GlStateManager.bindTexture(textureId); + + GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); + GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); + + for (int level = 0; level <= mipmapLevels; level++) { + int w2 = w >> level; + int h2 = h >> level; + + Minecraft.getMinecraft().getTextureManager().bindTexture(location); + GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intbuffer); + + for(int x=0; x> 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, oldAlpha << 24 | r << 16 | g << 8 | b); + } + } + + GlStateManager.bindTexture(textureId); + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, level, GL11.GL_RGBA, w2, h2, + 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intbuffer); + } + + modified.put(id, textureId); + return textureId; + } + + public static void tick() { + if(textureId == -1) { + int locationBlocksId = Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).getGlTextureId(); + + GlStateManager.bindTexture(locationBlocksId); + int mipmapLevels = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL); + int w = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); + int h = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT); + + if(intbuffer == null || intbuffer.capacity() < w*h) intbuffer = BufferUtils.createIntBuffer(w*h); + + if(textureId == -1) { + textureId = TextureUtil.glGenTextures(); + GlStateManager.bindTexture(textureId); + + if (mipmapLevels >= 0) { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, mipmapLevels); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)mipmapLevels); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); + } + + 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)); + } + } + GlStateManager.bindTexture(textureId); + + GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); + GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); + + HashMap spriteMap = new HashMap<>(); + spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/stonebrick_cracked"), + SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungCrackedColour.value)); + spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/dispenser_front_horizontal"), + SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungDispenserColour.value)); + spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/lever"), + SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungLeverColour.value)); + spriteMap.put(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/trip_wire"), + SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungTripWireColour.value)); + + for (int level = 0; level <= mipmapLevels; level++) { + int w2 = w >> level; + int h2 = h >> level; + + GlStateManager.bindTexture(locationBlocksId); + GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intbuffer); + + for(Map.Entry entry : spriteMap.entrySet()) { + TextureAtlasSprite tas = entry.getKey(); + for(int x=(int)(w2*tas.getMinU()); x> 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); + } + } + } + + GlStateManager.bindTexture(textureId); + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, level, GL11.GL_RGBA, w2, h2, + 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intbuffer); + } + } + /*if(framebuffer == null || true) { + Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + int w = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); + int h = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT); + + framebuffer = checkFramebufferSizes(framebuffer, w, h); + + try { + int locationBlocksId = Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).getGlTextureId(); + + //framebuffer2.bindFramebufferTexture(); + //GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, w, h, 0, GL11.GL_RGBA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, ((ByteBuffer)null)); + + //textureId = GlStateManager.generateTexture(); + //GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, w, h, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, ((ByteBuffer)null)); + + GL11.glPushMatrix(); + + GlStateManager.matrixMode(5889); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, w, h, 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(5888); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + + framebuffer.bindFramebufferTexture(); + if (Minecraft.getMinecraft().gameSettings.mipmapLevels >= 0) { + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, Minecraft.getMinecraft().gameSettings.mipmapLevels); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)Minecraft.getMinecraft().gameSettings.mipmapLevels); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); + } + + for (int i = 0; i <= Minecraft.getMinecraft().gameSettings.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)null)); + } + + //framebuffer.framebufferClear(); + framebuffer.bindFramebuffer(true); + GlStateManager.clearColor(1, 1, 1, 0); + GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT); + GL11.glClearColor(1, 1, 1, 0); + + Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(0, 0, w, h, 0, 1, 1, 0, GL11.GL_LINEAR); + + framebuffer.bindFramebufferTexture(); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, Minecraft.getMinecraft().gameSettings.mipmapLevels); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0F); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, (float)Minecraft.getMinecraft().gameSettings.mipmapLevels); + GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0F); + GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); + + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GlStateManager.matrixMode(5889); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, scaledResolution.getScaledWidth_double(), scaledResolution.getScaledHeight_double(), + 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(5888); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + + GL11.glPopMatrix(); + + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); + + + /*framebuffer.bindFramebufferTexture(); + if(Keyboard.isKeyDown(Keyboard.KEY_B)) Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + Utils.drawTexturedRect(0, 0, w, h, GL11.GL_NEAREST);*/ + + /*GlStateManager.bindTexture(textureId); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + + //GlStateManager.enableTexture2D(); + //GlStateManager.enableBlend(); + //GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + + + //GlStateManager.disableBlend(); + + Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(true); + } catch(Exception e) { + e.printStackTrace(); + } + }*/ + } + + private static Framebuffer checkFramebufferSizes(Framebuffer framebuffer, int width, int height) { + if(framebuffer == null || framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) { + if(framebuffer == null) { + framebuffer = new Framebuffer(width, height, false); + framebuffer.framebufferColor[0] = 1f; + framebuffer.framebufferColor[1] = 0f; + framebuffer.framebufferColor[2] = 0f; + framebuffer.framebufferColor[3] = 0; + } else { + framebuffer.createBindFramebuffer(width, height); + } + framebuffer.setFramebufferFilter(GL11.GL_NEAREST); + } + return framebuffer; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java new file mode 100644 index 00000000..aac7726a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java @@ -0,0 +1,416 @@ +package io.github.moulberry.notenoughupdates; + +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.MapData; +import net.minecraftforge.client.event.RenderGameOverlayEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +public class DungeonMap { + + private int[] mapTextureData = null; + private DynamicTexture dynamicTexture = new DynamicTexture(128, 128); + private ResourceLocation dynamicRL = new ResourceLocation("notenoughupdates:dynamic_dungeonmap.png"); + + private void setMapRGB(int x, int y, int rgb) { + if(mapTextureData != null) { + mapTextureData[x+y*128] = rgb; + } + } + + private class RoomOffset { + int x; + int y; + + public RoomOffset(int x, int y) { + this.x = x; + this.y = y; + } + + public RoomOffset left() { + return new RoomOffset(x-1, y); + } + + public RoomOffset right() { + return new RoomOffset(x+1, y); + } + + public RoomOffset up() { + return new RoomOffset(x, y-1); + } + + public RoomOffset down() { + return new RoomOffset(x, y+1); + } + + public RoomOffset[] getNeighbors() { + return new RoomOffset[]{left(), right(), up(), down()}; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RoomOffset that = (RoomOffset) o; + return x == that.x && y == that.y; + } + + @Override + public int hashCode() { + return Objects.hash(x, y); + } + } + + private enum RoomConnectionType { + NONE, WALL, CORRIDOR, ROOM_DIVIDER + } + + private class RoomConnection { + RoomConnectionType type; + Color colour; + + public RoomConnection(RoomConnectionType type, Color colour) { + this.type = type; + this.colour = colour; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RoomConnection that = (RoomConnection) o; + return type == that.type && + Objects.equals(colour, that.colour); + } + + @Override + public int hashCode() { + return Objects.hash(type, colour); + } + } + + private class Room { + Color colour = new Color(0, 0, 0, 0); + + RoomConnection left = new RoomConnection(RoomConnectionType.NONE, new Color(0, true)); + RoomConnection up = new RoomConnection(RoomConnectionType.NONE, new Color(0, true)); + RoomConnection right = new RoomConnection(RoomConnectionType.NONE, new Color(0, true)); + 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()); + } + } + + 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; + } + } + + public void render(RoomOffset roomOffset, int[] renderTo, int startOffsetX, int startOffsetY) { + /*for(Map.Entry entry : roomMap.entrySet()) { + + }*/ + if(roomMap.containsKey(roomOffset)) { + Room room = roomMap.get(roomOffset); + + for(int xo=0; xo<16; xo++) { + for(int yo=0; yo<16; yo++) { + int x = (roomOffset.x-startOffsetX)*20+xo; + int y = (roomOffset.y-startOffsetY)*20+yo; + + render(renderTo, x, y, room.colour.getRGB()); + } + } + + for(int k=0; k<4; k++) { + RoomConnection connection; + if(k == 0) { + connection = room.up; + } else if(k == 1) { + connection = room.right; + } else if(k == 2) { + connection = room.down; + } else { + connection = room.left; + } + if(connection.type == RoomConnectionType.NONE || connection.type == RoomConnectionType.WALL) continue; + for(int o1=1; o1<=4; o1++) { + int min = 0; + int max = 16; + if(connection.type == RoomConnectionType.CORRIDOR) { + min = 6; + max = 10; + } + for (int o2 = min; o2 < max; o2++) { + int x; + int y; + + if(k == 0) { + x = (roomOffset.x-startOffsetX)*20+o2; + y = (roomOffset.y-startOffsetY)*20-o1; + } else if(k == 1) { + x = (roomOffset.x-startOffsetX)*20+15+o1; + y = (roomOffset.y-startOffsetY)*20+o2; + } else if(k == 2) { + x = (roomOffset.x-startOffsetX)*20+o2; + y = (roomOffset.y-startOffsetY)*20+15+o1; + } else { + x = (roomOffset.x-startOffsetX)*20-o1; + y = (roomOffset.y-startOffsetY)*20+o2; + } + + render(renderTo, x, y, connection.colour.getRGB()); + } + } + } + } + + } + + private HashMap 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)) { + Room room = roomMap.get(roomOffset); + + for(int k=0; k<4; k++) { + int totalFilled = 0; + for(int i=0; i 0.8) { + type = RoomConnectionType.ROOM_DIVIDER; + } else if(proportionFilled > 0.1) { + type = RoomConnectionType.CORRIDOR; + } + if(k == 0) { + room.up = new RoomConnection(type, room.colour); + } else if(k == 1) { + room.right = new RoomConnection(type, room.colour); + } else if(k == 2) { + room.down = new RoomConnection(type, room.colour); + } else { + room.left = new RoomConnection(type, room.colour); + } + } + } + } + + public void loadNeighbors(RoomOffset room) { + if(!roomMap.containsKey(room)) { + roomMap.put(room, new Room()); + } + for(RoomOffset neighbor : room.getNeighbors()) { + if(!roomMap.containsKey(neighbor)) { + int x = startRoomX + neighbor.x*(roomSize+connectorSize); + 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); + } + } + } + } + + public void updateRoomColours() { + for(Map.Entry entry : roomMap.entrySet()) { + int x = startRoomX + entry.getKey().x*(roomSize+connectorSize); + int y = startRoomY + entry.getKey().y*(roomSize+connectorSize); + + try { + entry.getValue().colour = colourMap[x][y]; + } catch(Exception e) {} + } + } + + @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) { + colourMap = NotEnoughUpdates.INSTANCE.colourMap; + } else { + ItemMap map = (ItemMap) stack.getItem(); + MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld); + + if(mapData == null) return; + + for (int i = 0; i < 16384; ++i) { + int x = i % 128; + int y = i / 128; + + int j = mapData.colors[i] & 255; + + Color c; + 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); + } + + colourMap[x][y] = c; + } + } + + for(int x=0; x 80) { + if(startRoomX < 0 && startRoomY < 0 && c.getRed() == 0 && c.getGreen() == 124 && c.getBlue() == 0) { + roomSize = 0; + out: + for(int xd=0; xd<=20; xd++) { + for(int yd=0; yd<=20; yd++) { + if(x+xd >= colourMap.length || y+yd >= colourMap[x+xd].length) continue; + Color c2 = colourMap[x+xd][y+yd]; + + if(c2.getGreen() != 124 || c2.getAlpha() <= 80) { + if(xd < 10 && yd < 10) { + break out; + } + } else { + roomSize = Math.max(roomSize, Math.min(xd+1, yd+1)); + } + if(xd == 20 && yd == 20) { + if(roomSize == 0) roomSize = 20; + startRoomX = x; + startRoomY = y; + } + } + } + } + } + } + } + + for(int i=0; i 80) { + if(j == 1) { + break; + } + connectorSize = Math.min(connectorSize, j-1); + } + } + } + } + } + + loadNeighbors(new RoomOffset(0, 0)); + updateRoomColours(); + for(RoomOffset offset : roomMap.keySet()) { + updateRoomConnections(offset); + } + + //System.out.println("room x: " + startRoomX + "room y: " + startRoomY + " size: " + roomSize + " connector: " + connectorSize); + + //rendering + for (int i = 0; i < 16384; ++i) { + mapTextureData[i] = 0; + } + + 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); + } + + for(RoomOffset offset : roomMap.keySet()) { + render(offset, mapTextureData, minRoomX, minRoomY); + } + + //process + + 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); + } + } + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java index 8e14598f..6e25e7fd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiEnchantColour.java @@ -2,6 +2,7 @@ package io.github.moulberry.notenoughupdates; import com.google.common.base.Splitter; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; +import io.github.moulberry.notenoughupdates.util.LerpingInteger; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -9,6 +10,7 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import java.io.IOException; @@ -34,6 +36,8 @@ public class GuiEnchantColour extends GuiScreen { private HashMap comparators = new HashMap<>(); private List guiElementTextFields = new ArrayList<>(); + private LerpingInteger scroll = new LerpingInteger(0, 100); + @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { drawDefaultBackground(); @@ -42,7 +46,21 @@ public class GuiEnchantColour extends GuiScreen { ySize = 53+25*enchantColours.size(); guiLeft = (width-xSize)/2; - guiTop = (height-ySize)/2; + + if(ySize > height) { + if(scroll.getTarget() > 0) { + scroll.setTarget(0); + } else if(scroll.getTarget() < height-ySize) { + scroll.setTarget(height-ySize); + } + scroll.tick(); + guiTop = scroll.getValue(); + } else { + guiTop = (height-ySize)/2; + scroll.setValue(0); + scroll.resetTimer(); + } + NotEnoughUpdates.INSTANCE.manager.loadConfig(); @@ -150,6 +168,21 @@ public class GuiEnchantColour extends GuiScreen { return enchantOp.toString(); } + @Override + public void handleMouseInput() throws IOException { + super.handleMouseInput(); + + int dWheel = Mouse.getEventDWheel(); + + if(dWheel < 0) { + scroll.setTarget(scroll.getTarget()-50); + scroll.resetTimer(); + } else if(dWheel > 0) { + scroll.setTarget(scroll.getTarget()+50); + scroll.resetTimer(); + } + } + @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java index fb8671cb..c9ca87fd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiTextures.java @@ -25,6 +25,12 @@ 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 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"); + public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation("notenoughupdates:colour_selector_bar_alpha.png"); + public static final ResourceLocation colour_selector_chroma = new ResourceLocation("notenoughupdates:colour_selector_chroma.png"); + public static final ResourceLocation accessory_bag_overlay = new ResourceLocation("notenoughupdates:accessory_bag_overlay.png"); public static final ResourceLocation quickcommand_background = new ResourceLocation("notenoughupdates:quickcommand_background.png"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 95eefef5..a2ce0055 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -7,7 +7,7 @@ import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; 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.SBScoreboardData; +import io.github.moulberry.notenoughupdates.questing.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; @@ -23,7 +23,6 @@ import net.minecraft.event.ClickEvent; import net.minecraft.init.Blocks; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -123,22 +122,39 @@ public class NEUEventListener { */ private HashMap newItemAddMap = new HashMap<>(); private long lastLongUpdate = 0; + private long lastVeryLongUpdate = 0; private long lastSkyblockScoreboard = 0; @SubscribeEvent public void onTick(TickEvent.ClientTickEvent event) { if(event.phase != TickEvent.Phase.START) return; boolean longUpdate = false; + boolean veryLongUpdate = false; long currentTime = System.currentTimeMillis(); if(currentTime - lastLongUpdate > 1000) { longUpdate = true; lastLongUpdate = currentTime; } + if(currentTime - lastVeryLongUpdate > 10000) { + veryLongUpdate = true; + lastVeryLongUpdate = currentTime; + } + if(veryLongUpdate) { + DungeonBlocks.reset(); + } if(longUpdate) { + DungeonBlocks.tick(); neu.updateSkyblockScoreboard(); CapeManager.getInstance().tick(); - if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) { + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + if(!containerName.trim().startsWith("Accessory Bag")) { + AccessoryBagOverlay.resetCache(); + } + } else { AccessoryBagOverlay.resetCache(); } @@ -170,7 +186,7 @@ public class NEUEventListener { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("")); } } - SBScoreboardData.getInstance().tick(); + SBInfo.getInstance().tick(); //GuiQuestLine.questLine.tick(); } if(currentTime - lastSkyblockScoreboard < 5*60*1000) { //5 minutes @@ -443,6 +459,14 @@ public class NEUEventListener { EnumChatFormatting.RED+"Invalid recipe ")) { r = ""; } + if(e.message.getFormattedText().contains(EnumChatFormatting.YELLOW+"Visit the Auction House to collect your item!")) { + if(NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid != null && + System.currentTimeMillis() - NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBidMillis < 5000) { + NotEnoughUpdates.INSTANCE.sendChatMessage("/viewauction " + + NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.niceAucId( + NotEnoughUpdates.INSTANCE.manager.auctionManager.customAH.latestBid)); + } + } if(r != null) { if(neu.manager.failViewItem(r)) { e.setCanceled(true); @@ -923,91 +947,95 @@ public class NEUEventListener { @SubscribeEvent(priority = EventPriority.LOW) public void onItemTooltipLow(ItemTooltipEvent event) { + if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return; + boolean dungeonProfit = false; int index = 0; List newTooltip = new ArrayList<>(); for(String line : event.toolTip) { - for(String op : neu.manager.config.enchantColours.value) { - List colourOps = GuiEnchantColour.splitter.splitToList(op); - String enchantName = GuiEnchantColour.getColourOpIndex(colourOps, 0); - String comparator = GuiEnchantColour.getColourOpIndex(colourOps, 1); - String comparison = GuiEnchantColour.getColourOpIndex(colourOps, 2); - String colourCode = GuiEnchantColour.getColourOpIndex(colourOps, 3); + if(event.itemStack.isItemEnchanted()) { + for(String op : neu.manager.config.enchantColours.value) { + List colourOps = GuiEnchantColour.splitter.splitToList(op); + String enchantName = GuiEnchantColour.getColourOpIndex(colourOps, 0); + String comparator = GuiEnchantColour.getColourOpIndex(colourOps, 1); + String comparison = GuiEnchantColour.getColourOpIndex(colourOps, 2); + String colourCode = GuiEnchantColour.getColourOpIndex(colourOps, 3); - if(enchantName.length() == 0) continue; - if(comparator.length() == 0) continue; - if(comparison.length() == 0) continue; - if(colourCode.length() == 0) continue; + if(enchantName.length() == 0) continue; + if(comparator.length() == 0) continue; + if(comparison.length() == 0) continue; + if(colourCode.length() == 0) continue; - if(enchantName.contains("(") || enchantName.contains(")")) continue; + if(enchantName.contains("(") || enchantName.contains(")")) continue; - int comparatorI = ">=<".indexOf(comparator.charAt(0)); + int comparatorI = ">=<".indexOf(comparator.charAt(0)); - int levelToFind = -1; - try { - levelToFind = Integer.parseInt(comparison); - } catch(Exception e) { continue; } + int levelToFind = -1; + try { + levelToFind = Integer.parseInt(comparison); + } catch(Exception e) { continue; } - if(comparatorI < 0) continue; - if("0123456789abcdefz".indexOf(colourCode.charAt(0)) < 0) continue; + if(comparatorI < 0) continue; + if("0123456789abcdefz".indexOf(colourCode.charAt(0)) < 0) continue; - //item_lore = item_lore.replaceAll("\\u00A79("+lvl4Max+" IV)", EnumChatFormatting.DARK_PURPLE+"$1"); - //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))(,|$)"); - } catch(Exception e) {continue;} //malformed regex - Matcher matcher = pattern.matcher(line); - int matchCount = 0; - while(matcher.find() && matchCount < 5) { - matchCount++; - int level = -1; - String levelStr = matcher.group(2); - if(levelStr == null) continue; + //item_lore = item_lore.replaceAll("\\u00A79("+lvl4Max+" IV)", EnumChatFormatting.DARK_PURPLE+"$1"); + //9([a-zA-Z ]+?) ([0-9]+|(I|II|III|IV|V|VI|VII|VIII|IX|X))(,|$) + Pattern pattern; try { - level = Integer.parseInt(levelStr); - } catch(Exception e) { - switch(levelStr) { - case "I": - level = 1; break; - case "II": - level = 2; break; - case "III": - level = 3; break; - case "IV": - level = 4; break; - case "V": - level = 5; break; - case "VI": - level = 6; break; - case "VII": - level = 7; break; - case "VIII": - level = 8; break; - case "IX": - level = 9; break; - case "X": - level = 10; break; + 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))(,|$)"); + } catch(Exception e) {continue;} //malformed regex + Matcher matcher = pattern.matcher(line); + int matchCount = 0; + while(matcher.find() && matchCount < 5) { + matchCount++; + int level = -1; + String levelStr = matcher.group(2); + if(levelStr == null) continue; + try { + level = Integer.parseInt(levelStr); + } catch(Exception e) { + switch(levelStr) { + case "I": + level = 1; break; + case "II": + level = 2; break; + case "III": + level = 3; break; + case "IV": + level = 4; break; + case "V": + level = 5; break; + case "VI": + level = 6; break; + case "VII": + level = 7; break; + case "VIII": + level = 8; break; + case "IX": + level = 9; break; + case "X": + level = 10; break; + } } - } - boolean matches = false; - if(level > 0) { - switch(comparator) { - case ">": - matches = level > levelToFind; break; - case "=": - matches = level == levelToFind; break; - case "<": - matches = level < levelToFind; break; + boolean matches = false; + if(level > 0) { + switch(comparator) { + case ">": + matches = level > levelToFind; break; + case "=": + matches = level == levelToFind; break; + case "<": + matches = level < levelToFind; break; + } } - } - if(matches) { - if(!colourCode.equals("z")) { - line = line.replaceAll("\\u00A79"+matcher.group(1), "\u00A7"+colourCode+matcher.group(1)); - } else { - line = line.replaceAll("\\u00A79"+matcher.group(1), Utils.chromaString(matcher.group(1))); + if(matches) { + if(!colourCode.equals("z")) { + line = line.replaceAll("\\u00A79"+matcher.group(1), "\u00A7"+colourCode+matcher.group(1)); + } else { + line = line.replaceAll("\\u00A79"+matcher.group(1), Utils.chromaString(matcher.group(1))); + } } } } @@ -1157,8 +1185,88 @@ public class NEUEventListener { index++; } + event.toolTip.clear(); event.toolTip.addAll(newTooltip); + + if(neu.manager.config.invAuctionPrice.value || neu.manager.config.invBazaarPrice.value) { + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); + + if(internalname != null) { + JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internalname); + JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internalname); + + boolean hasAuctionPrice = neu.manager.config.invAuctionPrice.value && auctionInfo != null; + boolean hasBazaarPrice = neu.manager.config.invBazaarPrice.value && bazaarInfo != null; + + int lowestBin = neu.manager.auctionManager.getLowestBin(internalname); + + NumberFormat format = NumberFormat.getInstance(Locale.US); + + APIManager.CraftInfo craftCost = neu.manager.auctionManager.getCraftCost(internalname); + + if(hasAuctionPrice || hasBazaarPrice || craftCost.fromRecipe) event.toolTip.add(""); + if(hasAuctionPrice) { + if(lowestBin > 0) { + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Lowest BIN: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBin)+" coins"); + } + int auctionPrice = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Price: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(auctionPrice)+" coins"); + if(neu.manager.config.advancedPriceInfo.value) { + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Sales: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(auctionInfo.get("sales").getAsFloat())+" sales/day"); + } + if(auctionInfo.has("clean_price")) { + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Price (Clean): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format((int)auctionInfo.get("clean_price").getAsFloat())+" coins"); + if(neu.manager.config.advancedPriceInfo.value) { + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Sales (Clean): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(auctionInfo.get("clean_sales").getAsFloat())+" sales/day"); + } + } + + } else if(hasBazaarPrice) { + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat()*64; + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy (Stack): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); + int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat()*64; + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell (Stack): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); + if(neu.manager.config.advancedPriceInfo.value) { + int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat()*64; + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy (Stack): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); + int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat()*64; + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell (Stack): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); + } + } else { + event.toolTip.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show stack]"); + int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat(); + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); + int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat(); + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); + if(neu.manager.config.advancedPriceInfo.value) { + int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat(); + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); + int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat(); + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); + } + } + } + if((hasAuctionPrice || hasBazaarPrice) && craftCost.fromRecipe) { + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Raw Craft Cost: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format((int)craftCost.craftCost)+" coins"); + } + } + } } /** diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index c0932fcf..c78885c3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -69,6 +69,8 @@ public class NEUManager { private HashMap> usagesMap = new HashMap<>(); + public String latestRepoCommit = null; + public File configLocation; public File repoLocation; public File configFile; @@ -92,7 +94,7 @@ public class NEUManager { repoLocation.mkdir(); this.itemRenameFile = new File(configLocation, "itemRename.json"); - try { itemRenameJson = getJsonFromFile(itemRenameFile); } catch(IOException ignored) {} + itemRenameJson = getJsonFromFile(itemRenameFile); if(itemRenameJson == null) { itemRenameJson = new JsonObject(); } @@ -144,13 +146,13 @@ public class NEUManager { /** * Parses a file in to a JsonObject. */ - public JsonObject getJsonFromFile(File file) throws IOException { + public JsonObject getJsonFromFile(File file) { try { InputStream in = new FileInputStream(file); BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); JsonObject json = gson.fromJson(reader, JsonObject.class); return json; - } catch(Exception e) { e.printStackTrace(); return null; } + } catch(Exception e) { return null; } } public void resetRepo() { @@ -210,18 +212,18 @@ public class NEUManager { JsonObject currentCommitJSON = getJsonFromFile(new File(configLocation, "currentCommit.json")); - String latestCommit = null; + latestRepoCommit = null; try(Reader inReader = new InputStreamReader(new URL(GIT_COMMITS_URL).openStream())) { JsonObject commits = gson.fromJson(inReader, JsonObject.class); - latestCommit = commits.get("sha").getAsString(); + latestRepoCommit = commits.get("sha").getAsString(); } catch (Exception e) { e.printStackTrace(); } - if(latestCommit == null || latestCommit.isEmpty()) return; + if(latestRepoCommit == null || latestRepoCommit.isEmpty()) return; if(new File(configLocation, "repo").exists() && new File(configLocation, "repo/items").exists()) { - if(currentCommitJSON != null && currentCommitJSON.get("sha").getAsString().equals(latestCommit)) { + if(currentCommitJSON != null && currentCommitJSON.get("sha").getAsString().equals(latestRepoCommit)) { dialog.setVisible(false); return; } @@ -330,9 +332,9 @@ public class NEUManager { }*/ } - if(currentCommitJSON == null || !currentCommitJSON.get("sha").getAsString().equals(latestCommit)) { + if(currentCommitJSON == null || !currentCommitJSON.get("sha").getAsString().equals(latestRepoCommit)) { JsonObject newCurrentCommitJSON = new JsonObject(); - newCurrentCommitJSON.addProperty("sha", latestCommit); + newCurrentCommitJSON.addProperty("sha", latestRepoCommit); try { writeJson(newCurrentCommitJSON, new File(configLocation, "currentCommit.json")); } catch (IOException e) { @@ -447,7 +449,7 @@ public class NEUManager { } } } - } catch(IOException e) { + } catch(Exception e) { e.printStackTrace(); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 49a886b6..450653da 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -10,9 +10,7 @@ import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint; import io.github.moulberry.notenoughupdates.mbgui.MBGuiElement; import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupAligned; import io.github.moulberry.notenoughupdates.mbgui.MBGuiGroupFloating; -import io.github.moulberry.notenoughupdates.util.LerpingFloat; -import io.github.moulberry.notenoughupdates.util.LerpingInteger; -import io.github.moulberry.notenoughupdates.util.Utils; +import io.github.moulberry.notenoughupdates.util.*; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.*; import net.minecraft.client.gui.inventory.GuiContainer; @@ -58,6 +56,8 @@ import static io.github.moulberry.notenoughupdates.GuiTextures.*; public class NEUOverlay extends Gui { + private static final ResourceLocation SUPERGEHEIMNISVERMOGEN = new ResourceLocation("notenoughupdates:supersecretassets/bald.png"); + private NEUManager manager; private String mobRegex = ".*?((_MONSTER)|(_ANIMAL)|(_MINIBOSS)|(_BOSS)|(_SC))$"; @@ -540,6 +540,7 @@ public class NEUOverlay extends Gui { itemPaneOffsetFactor.setValue(1); itemPaneTabOffset.setValue(20); } + if(activeInfoPane != null) activeInfoPane.reset(); } /** @@ -1072,6 +1073,10 @@ public class NEUOverlay extends Gui { * Checks whether an item matches the current sort mode. */ public boolean checkMatchesSort(String internalname, JsonObject item) { + if(!manager.config.showVanillaItems.value && item.has("vanilla") && item.get("vanilla").getAsBoolean()) { + return false; + } + if(getSortMode() == SORT_MODE_ALL) { return !internalname.matches(mobRegex); } else if(getSortMode() == SORT_MODE_MOB) { @@ -1120,7 +1125,6 @@ public class NEUOverlay extends Gui { } for(String itemname : entry.getValue()) { JsonObject item = manager.getItemInformation().get(itemname); - System.out.println("searching "+itemname); if(item != null) searchedItems.add(item); } } @@ -1600,6 +1604,7 @@ public class NEUOverlay extends Gui { } int guiScaleLast = 0; + private boolean showVanillaLast = false; /** * Renders the search bar, quick commands, item selection (right) and item info (left) gui elements. @@ -1613,6 +1618,18 @@ public class NEUOverlay extends Gui { scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledresolution.getScaledWidth(); int height = scaledresolution.getScaledHeight(); + + if(showVanillaLast != manager.config.showVanillaItems.value) { + showVanillaLast = manager.config.showVanillaItems.value; + updateSearch(); + } + + if(textField.getText().toLowerCase().contains("bald")) { + Minecraft.getMinecraft().getTextureManager().bindTexture(SUPERGEHEIMNISVERMOGEN); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect((width-64)/2f, (height-64)/2f-114, 64, 64, GL11.GL_LINEAR); + GlStateManager.bindTexture(0); + } updateGuiGroupSize(); @@ -1631,13 +1648,13 @@ public class NEUOverlay extends Gui { yaw++; yaw %= 360; - int opacity = Math.min(255, Math.max(0, manager.config.bgOpacity.value.intValue())); - bg = new Color((bg.getRGB() & 0x00ffffff) | opacity << 24, true); + bg = new Color(SpecialColour.specialToChromaRGB(manager.config.paneBackgroundColour.value), true); + fg = new Color(SpecialColour.specialToChromaRGB(manager.config.itemBackgroundColour.value)); + Color fgCustomOpacity = new Color(SpecialColour.specialToChromaRGB(manager.config.itemBackgroundColour.value), true); - opacity = Math.min(255, Math.max(0, manager.config.fgOpacity.value.intValue())); - Color fgCustomOpacity = new Color((fg.getRGB() & 0x00ffffff) | opacity << 24, true); - Color fgFavourite = new Color(limCol(fg.getRed()+20), limCol(fg.getGreen()+10), limCol(fg.getBlue()-10), opacity); - Color fgFavourite2 = new Color(limCol(fg.getRed()+100), limCol(fg.getGreen()+50), limCol(fg.getBlue()-50), opacity); + Color fgFavourite2 = new Color(SpecialColour.specialToChromaRGB(manager.config.itemFavouriteColour.value), true); + Color fgFavourite = new Color((int)(fgFavourite2.getRed()*0.8f), (int)(fgFavourite2.getGreen()*0.8f), + (int)(fgFavourite2.getBlue()*0.8f), fgFavourite2.getAlpha()); if(itemPaneOpen) { if(itemPaneTabOffset.getValue() == 0) { @@ -1915,8 +1932,8 @@ public class NEUOverlay extends Gui { JsonObject auctionInfo = manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = manager.auctionManager.getBazaarInfo(internalname); - boolean hasAuctionPrice = auctionInfo != null; - boolean hasBazaarPrice = bazaarInfo != null; + boolean hasAuctionPrice = !manager.config.invAuctionPrice.value && auctionInfo != null; + boolean hasBazaarPrice = !manager.config.invBazaarPrice.value && bazaarInfo != null; int lowestBin = manager.auctionManager.getLowestBin(internalname); @@ -1924,28 +1941,12 @@ public class NEUOverlay extends Gui { APIManager.CraftInfo craftCost = manager.auctionManager.getCraftCost(json.get("internalname").getAsString()); - if(hasAuctionPrice || hasBazaarPrice || craftCost.fromRecipe || lowestBin > 0) text.add(""); - if(lowestBin > 0) { - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Lowest BIN: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBin)+" coins"); - } - if(hasBazaarPrice) { - int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat(); - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); - int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat(); - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); - if(manager.config.advancedPriceInfo.value) { - int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat(); - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); - int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat(); - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); - } - } + if(hasAuctionPrice || hasBazaarPrice || craftCost.fromRecipe) text.add(""); if(hasAuctionPrice) { + if(lowestBin > 0) { + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Lowest BIN: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBin)+" coins"); + } int auctionPrice = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Price: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(auctionPrice)+" coins"); @@ -1962,8 +1963,41 @@ public class NEUOverlay extends Gui { } } + } else if(hasBazaarPrice) { + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat()*64; + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy (Stack): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); + int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat()*64; + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell (Stack): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); + if(manager.config.advancedPriceInfo.value) { + int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat()*64; + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy (Stack): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); + int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat()*64; + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell (Stack): "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); + } + } else { + text.add(EnumChatFormatting.DARK_GRAY.toString()+"[SHIFT show stack]"); + int bazaarBuyPrice = (int)bazaarInfo.get("avg_buy").getAsFloat(); + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Buy: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarBuyPrice)+" coins"); + int bazaarSellPrice = (int)bazaarInfo.get("avg_sell").getAsFloat(); + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Sell: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarSellPrice)+" coins"); + if(manager.config.advancedPriceInfo.value) { + int bazaarInstantBuyPrice = (int)bazaarInfo.get("curr_buy").getAsFloat(); + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Buy: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantBuyPrice)+" coins"); + int bazaarInstantSellPrice = (int)bazaarInfo.get("curr_sell").getAsFloat(); + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Bazaar Insta-Sell: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(bazaarInstantSellPrice)+" coins"); + } + } } - if(craftCost.fromRecipe) { + if((hasAuctionPrice || hasBazaarPrice) && craftCost.fromRecipe) { text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Raw Craft Cost: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format((int)craftCost.craftCost)+" coins"); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 79e57529..575562a0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -18,38 +18,57 @@ import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.questing.GuiQuestLine; +import io.github.moulberry.notenoughupdates.questing.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.block.material.MapColor; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.resources.IReloadableResourceManager; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.client.settings.KeyBinding; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.event.ClickEvent; import net.minecraft.event.HoverEvent; +import net.minecraft.item.ItemMap; +import net.minecraft.item.ItemStack; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.Scoreboard; import net.minecraft.util.*; +import net.minecraft.world.storage.MapData; import net.minecraftforge.client.ClientCommandHandler; +import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; 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.apache.commons.lang3.text.translate.UnicodeUnescaper; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import javax.imageio.ImageIO; import javax.net.ssl.*; import javax.swing.*; import java.awt.*; import java.awt.datatransfer.StringSelection; +import java.awt.image.BufferedImage; import java.io.*; +import java.lang.management.ManagementFactory; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.net.*; @@ -65,7 +84,7 @@ import java.util.concurrent.TimeUnit; @Mod(modid = NotEnoughUpdates.MODID, version = NotEnoughUpdates.VERSION, clientSideOnly = true) public class NotEnoughUpdates { public static final String MODID = "notenoughupdates"; - public static final String VERSION = "1.3-REL"; + public static final String VERSION = "1.4-REL"; public static NotEnoughUpdates INSTANCE = null; @@ -207,6 +226,21 @@ public class NotEnoughUpdates { } }); + SimpleCommand reloadRepoCommand = new SimpleCommand("neureloadrepo", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + File items = new File(manager.repoLocation, "items"); + if(items.exists()) { + File[] itemFiles = new File(manager.repoLocation, "items").listFiles(); + if(itemFiles != null) { + for(File f : itemFiles) { + String internalname = f.getName().substring(0, f.getName().length()-5); + manager.loadItem(internalname); + } + } + } + } + }); + private static HashMap petRarityToColourMap = new HashMap<>(); static { petRarityToColourMap.put("UNKNOWN", EnumChatFormatting.RED.toString()); @@ -426,6 +460,80 @@ public class NotEnoughUpdates { } }); + + SimpleCommand pcStatsCommand = new SimpleCommand("neustats", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + Minecraft mc = Minecraft.getMinecraft(); + StringBuilder builder = new StringBuilder(); + + if (args.length > 0 && args[0].toLowerCase().equals("modlist")){ + builder.append("```md\n"); + builder.append("# Mods Loaded").append("\n"); + for (ModContainer modContainer : Loader.instance().getActiveModList()) { + builder.append("[").append(modContainer.getName()).append("]") + .append("[").append(modContainer.getSource().getName()).append("]\n"); + } + builder.append("```"); + } else { + long memorySize = -1; + try { + memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize(); + } catch(Exception e){} + long maxMemory = Runtime.getRuntime().maxMemory(); + long totalMemory = Runtime.getRuntime().totalMemory(); + long freeMemory = Runtime.getRuntime().freeMemory(); + long currentMemory = totalMemory - freeMemory; + int modCount = Loader.instance().getModList().size(); + int activeModCount = Loader.instance().getActiveModList().size(); + + builder.append("```md\n"); + builder.append("# System Stats").append("\n"); + builder.append("[OS]").append("[").append(System.getProperty("os.name")).append("]").append("\n"); + builder.append("[CPU]").append("[").append(OpenGlHelper.getCpu()).append("]").append("\n"); + builder.append("[Display]").append("[").append(String.format("%dx%d (%s)", Display.getWidth(), Display.getHeight(), GL11.glGetString(GL11.GL_VENDOR))).append("]").append("\n"); + builder.append("[GPU]").append("[").append(GL11.glGetString(GL11.GL_RENDERER)).append("]").append("\n"); + builder.append("[GPU Driver]").append("[").append(GL11.glGetString(GL11.GL_VERSION)).append("]").append("\n"); + if(memorySize > 0) { + builder.append("[Maximum Memory]").append("[").append(memorySize / 1024L / 1024L).append("MB]").append("\n"); + } + builder.append("[Shaders]").append("[").append((""+OpenGlHelper.areShadersSupported()).toUpperCase()).append("]").append("\n"); + builder.append("[Framebuffers]").append("[").append((""+OpenGlHelper.isFramebufferEnabled()).toUpperCase()).append("]").append("\n"); + builder.append("# Java Stats").append("\n"); + builder.append("[Java]").append("[").append(String.format("%s %dbit", System.getProperty("java.version"), mc.isJava64bit() ? 64 : 32)).append("]").append("\n"); + builder.append("[Memory]").append("[").append(String.format("% 2d%% %03d/%03dMB", currentMemory * 100L / maxMemory, currentMemory / 1024L / 1024L, maxMemory / 1024L / 1024L)).append("]").append("\n"); + builder.append("[Memory Allocated]").append("[").append(String.format("% 2d%% %03dMB", totalMemory * 100L / maxMemory, totalMemory / 1024L / 1024L)).append("]").append("\n"); + builder.append("# Game Stats").append("\n"); + builder.append("[Current FPS]").append("[").append(Minecraft.getDebugFPS()).append("]").append("\n"); + builder.append("[Loaded Mods]").append("[").append(activeModCount).append("/").append(modCount).append("]").append("\n"); + builder.append("[Forge]").append("[").append(ForgeVersion.getVersion()).append("]").append("\n"); + builder.append("# Neu Settings").append("\n"); + builder.append("[API Key]").append("[").append(!INSTANCE.manager.config.apiKey.value.isEmpty()).append("]").append("\n"); + builder.append("[On Skyblock]").append("[").append(hasSkyblockScoreboard).append("]").append("\n"); + builder.append("[Mod Version]").append("[").append(Loader.instance().getIndexedModList().get(MODID).getSource().getName()).append("]").append("\n"); + builder.append("# Repo Stats").append("\n"); + builder.append("[Last Commit]").append("[").append(manager.latestRepoCommit).append("]").append("\n"); + builder.append("[Loaded Items]").append("[").append(manager.getItemInformation().size()).append("]").append("\n"); + if (activeModCount <= 15) { + builder.append("# Mods Loaded").append("\n"); + for (ModContainer modContainer : Loader.instance().getActiveModList()) { + builder.append("[").append(modContainer.getName()).append("]") + .append("[").append(modContainer.getSource().getName()).append("]\n"); + } + builder.append("```"); + } else { + builder.append("```"); + } + } + try { + StringSelection clipboard = new StringSelection(builder.toString()); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(clipboard, clipboard); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "[" + EnumChatFormatting.RED + "NotEnoughUpdates" + EnumChatFormatting.GOLD + "]: " + EnumChatFormatting.GREEN + "Dev info copied to clipboard.")); + } catch (Exception ignored) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "[" + EnumChatFormatting.RED + "NotEnoughUpdates" + EnumChatFormatting.GOLD + "]: " + EnumChatFormatting.DARK_RED + "Could not copy to clipboard.")); + } + } + }); + public static ProfileViewer profileViewer; SimpleCommand.ProcessCommandRunnable viewProfileRunnable = new SimpleCommand.ProcessCommandRunnable() { @@ -439,8 +547,8 @@ public class NotEnoughUpdates { while((line = reader.readLine()) != null) { if(line.contains("ofFastRender:true")) { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + - "This feature is incompatible with OF Fast Render. Go to Video > Performance to disable it.")); - return; + "Some parts of the profile viewer do not work with OF Fast Render. Go to Video > Performance to disable it.")); + break; } } } catch(Exception e) { @@ -574,6 +682,75 @@ public class NotEnoughUpdates { } }); + public Color[][] colourMap = null; + SimpleCommand neumapCommand = new SimpleCommand("neumap", new SimpleCommand.ProcessCommandRunnable() { + public void processCommand(ICommandSender sender, String[] args) { + if(args.length == 1 && args[0] == "reset") { + colourMap = null; + return; + } + + if(args.length != 2) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+ + "Dev feature if you don't know how to use then don't use it 4Head.")); + return; + } + + if(args[0].equals("save")) { + ItemStack stack = Minecraft.getMinecraft().thePlayer.getHeldItem(); + if(stack != null && stack.getItem() instanceof ItemMap) { + ItemMap map = (ItemMap) stack.getItem(); + MapData mapData = map.getMapData(stack, Minecraft.getMinecraft().theWorld); + + if (mapData == null) return; + + JsonObject json = new JsonObject(); + for (int i = 0; i < 16384; ++i) { + int x = i % 128; + int y = i / 128; + + int j = mapData.colors[i] & 255; + + Color c; + 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); + } + + json.addProperty(x+":"+y, c.getRGB()); + } + + try { + new File(manager.configLocation, "maps").mkdirs(); + manager.writeJson(json, new File(manager.configLocation, "maps/"+args[1]+".json")); + } catch(Exception e) { + e.printStackTrace(); + } + + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+ + "Saved to file.")); + } + } + + if(args[0].equals("load")) { + JsonObject json = manager.getJsonFromFile(new File(manager.configLocation, "maps/"+args[1]+".json")); + colourMap = new Color[128][128]; + for(int x=0; x<128; x++) { + for(int y=0; y<128; y++) { + colourMap[x][y] = new Color(0, 0, 0, 0); + } + } + for(Map.Entry entry : json.entrySet()) { + int x = Integer.parseInt(entry.getKey().split(":")[0]); + int y = Integer.parseInt(entry.getKey().split(":")[1]); + + colourMap[x][y] = new Color(entry.getValue().getAsInt(), true); + } + } + } + }); + SimpleCommand cosmeticsCommand = new SimpleCommand("neucosmetics", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { openGui = new GuiCosmetics(); @@ -609,9 +786,16 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new NEUEventListener(this)); MinecraftForge.EVENT_BUS.register(CapeManager.getInstance()); MinecraftForge.EVENT_BUS.register(new SBGamemodes()); + MinecraftForge.EVENT_BUS.register(SBInfo.getInstance()); MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); + MinecraftForge.EVENT_BUS.register(new DungeonMap()); //MinecraftForge.EVENT_BUS.register(new BetterPortals()); + IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager(); + if(resourceManager instanceof IReloadableResourceManager) { + ((IReloadableResourceManager)resourceManager).registerReloadListener(new DungeonBlocks()); + } + File f = new File(event.getModConfigurationDirectory(), "notenoughupdates"); f.mkdirs(); ClientCommandHandler.instance.registerCommand(collectionLogCommand); @@ -619,6 +803,7 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(linksCommand); ClientCommandHandler.instance.registerCommand(gamemodesCommand); ClientCommandHandler.instance.registerCommand(resetRepoCommand); + ClientCommandHandler.instance.registerCommand(reloadRepoCommand); ClientCommandHandler.instance.registerCommand(itemRenameCommand); ClientCommandHandler.instance.registerCommand(viewProfileCommand); ClientCommandHandler.instance.registerCommand(viewProfileShortCommand); @@ -628,6 +813,8 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(overlayPlacementsCommand); ClientCommandHandler.instance.registerCommand(enchantColourCommand); ClientCommandHandler.instance.registerCommand(neuAhCommand); + ClientCommandHandler.instance.registerCommand(pcStatsCommand); + ClientCommandHandler.instance.registerCommand(neumapCommand); manager = new NEUManager(this, f); manager.loadItemInformation(); 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 03796993..b466d226 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -91,6 +91,7 @@ public class APIManager { public boolean bin; public String category; public String rarity; + public int dungeonTier; public String item_tag_str; public NBTTagCompound item_tag = null; private ItemStack stack; @@ -98,7 +99,7 @@ public class APIManager { public int enchLevel = 0; //0 = clean, 1 = ench, 2 = ench/hpb public Auction(String auctioneerUuid, long end, int starting_bid, int highest_bid_amount, int bid_count, - boolean bin, String category, String rarity, String item_tag_str) { + boolean bin, String category, String rarity, int dungeonTier, String item_tag_str) { this.auctioneerUuid = auctioneerUuid; this.end = end; this.starting_bid = starting_bid; @@ -106,6 +107,7 @@ public class APIManager { this.bid_count = bid_count; this.bin = bin; this.category = category; + this.dungeonTier = dungeonTier; this.rarity = rarity; this.item_tag_str = item_tag_str; } @@ -468,7 +470,6 @@ public class APIManager { NBTTagCompound tag = item_tag.getTagList("i", 10).getCompoundTagAt(0).getCompoundTag("tag"); String internalname = manager.getInternalnameFromNBT(tag); - String[] lore = new String[0]; NBTTagCompound display = tag.getCompoundTag("display"); if(display.hasKey("Lore", 9)) { NBTTagList loreList = new NBTTagList(); @@ -527,10 +528,15 @@ public class APIManager { } } + int dungeonTier = -1; if(checkItemType(item_lore, true, "DUNGEON") >= 0) { - HashMap> extrasMap = extrasToAucIdMap.computeIfAbsent("dungeon", k -> new HashMap<>()); - HashSet aucids = extrasMap.computeIfAbsent(0, k -> new HashSet<>()); - aucids.add(auctionUuid); + dungeonTier = 0; + for(int i=0; i(); - for(int i=0; i DUNGEON_FILTER_ALL) { + if(dungeonFilter == DUNGEON_FILTER_DUNGEON && auc.dungeonTier < 0) { + match = false; + } else { + match &= dungeonFilter == auc.dungeonTier+1; + } + } + return match; } @@ -1155,7 +1200,7 @@ public class CustomAH extends Gui { long currentTime = System.currentTimeMillis(); es.submit(() -> { - if(currentTime - lastUpdateSearch < 500) { + if(currentTime - lastUpdateSearch < 100) { shouldUpdateSearch = true; return; } @@ -1405,7 +1450,15 @@ public class CustomAH extends Gui { int index = offset/18; boolean rightClicked = Mouse.getEventButton() == 1; switch(index) { - case 0: break; + case 0: + if(rightClicked) { + dungeonFilter--; + if(dungeonFilter < DUNGEON_FILTER_ALL) dungeonFilter = DUNGEON_FILTER_5; + } else { + dungeonFilter++; + if(dungeonFilter > DUNGEON_FILTER_5) dungeonFilter = DUNGEON_FILTER_ALL; + } + break; case 1: if(rightClicked) { sortMode--; @@ -1505,6 +1558,8 @@ public class CustomAH extends Gui { if(mouseY > guiTop+31 && mouseY < guiTop+31+16) { if(currentAucId != null) { manager.auctionManager.getPlayerBids().add(currentAucId); + latestBid = currentAucId; + latestBidMillis = System.currentTimeMillis(); //reset timer to 2m if below if(manager.auctionManager.getAuctionItems().get(currentAucId).end - System.currentTimeMillis() < 2*60*1000) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java index 98907029..fa1db64e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -32,8 +32,8 @@ public class CapeManager { private boolean allAvailable = false; private HashSet availableCapes = new HashSet<>(); - private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", "gravy", "space", "mcworld" }; - public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false }; + private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", "gravy", "space", "mcworld", "lava", "packshq", "mbstaff" }; + public Boolean[] specialCapes = new Boolean[]{ true, true, false, true, true, true, false, false, true, true, true }; public static CapeManager getInstance() { return INSTANCE; @@ -51,6 +51,7 @@ public class CapeManager { NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("activecapes.json", (jsonObject) -> { if(jsonObject.get("success").getAsBoolean()) { lastCapeSynced = System.currentTimeMillis(); + capeMap.clear(); for(JsonElement active : jsonObject.get("active").getAsJsonArray()) { if(active.isJsonObject()) { JsonObject activeObj = (JsonObject) active; @@ -176,21 +177,24 @@ public class CapeManager { } Set toRemove = new HashSet<>(); - for(String playerUUID : capeMap.keySet()) { - EntityPlayer player = getPlayerForUUID(playerUUID); - if(player != null) { - String capeName = capeMap.get(playerUUID).getRight(); - if(capeName != null && !capeName.equals("null")) { - if(playerUUID.equals(clientUuid) && localCape != null && localCape.getRight() != null && !localCape.getRight().equals("null")) { - continue; + try { + for(String playerUUID : capeMap.keySet()) { + EntityPlayer player = getPlayerForUUID(playerUUID); + if(player != null) { + String capeName = capeMap.get(playerUUID).getRight(); + if(capeName != null && !capeName.equals("null")) { + if(playerUUID.equals(clientUuid) && localCape != null && localCape.getRight() != null && !localCape.getRight().equals("null")) { + continue; + } + capeMap.get(playerUUID).getLeft().setCapeTexture(capeName); + capeMap.get(playerUUID).getLeft().onTick(event, player); + } else { + toRemove.add(playerUUID); } - capeMap.get(playerUUID).getLeft().setCapeTexture(capeName); - capeMap.get(playerUUID).getLeft().onTick(event, player); - } else { - toRemove.add(playerUUID); } } - } + } catch(Exception e) {} + if(localCape != null) { localCape.getLeft().setCapeTexture(localCape.getValue()); localCape.getLeft().onTick(event, Minecraft.getMinecraft().thePlayer); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java index 6712f34f..4723d00f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java @@ -1,61 +1,23 @@ package io.github.moulberry.notenoughupdates.cosmetics; -import com.google.common.base.Splitter; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.SBAIntegration; -import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; -import io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer; -import io.github.moulberry.notenoughupdates.profileviewer.Panorama; -import io.github.moulberry.notenoughupdates.profileviewer.PlayerStats; -import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; -import io.github.moulberry.notenoughupdates.questing.SBScoreboardData; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.resources.DefaultPlayerSkin; -import net.minecraft.client.resources.SkinManager; import net.minecraft.client.shader.Framebuffer; import net.minecraft.client.shader.Shader; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EnumPlayerModelParts; -import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagByteArray; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.Matrix4f; import net.minecraft.util.ResourceLocation; -import org.apache.commons.lang3.text.WordUtils; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; -import org.lwjgl.opengl.GL20; import java.awt.*; -import java.io.IOException; -import java.text.NumberFormat; import java.util.List; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; public class GuiCosmetics extends GuiScreen { @@ -311,10 +273,14 @@ public class GuiCosmetics extends GuiScreen { lastCapeEquip = System.currentTimeMillis(); if(wantToEquipCape == null) { NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/changecape.py?capeType=null&accessToken="+ - Minecraft.getMinecraft().getSession().getToken(), (jsonObject) -> {}, () -> {}); + Minecraft.getMinecraft().getSession().getToken(), (jsonObject) -> { System.out.println(jsonObject); }, () -> { + System.out.println("change cape error"); + }); } else { NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("cgi-bin/changecape.py?capeType="+wantToEquipCape+"&accessToken="+ - Minecraft.getMinecraft().getSession().getToken(), (jsonObject) -> {}, () -> {}); + Minecraft.getMinecraft().getSession().getToken(), (jsonObject) -> { System.out.println(jsonObject); }, () -> { + System.out.println("change cape error"); + }); } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java index 197e5483..13e61a06 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java @@ -79,6 +79,8 @@ public class NEUCape { shaderName = "space_cape"; } else if(capeName.equalsIgnoreCase("mcworld")) { shaderName = "mcworld_cape"; + } else if(capeName.equalsIgnoreCase("lava")) { + shaderName = "lava_cape"; } else { shaderName = "cape"; } @@ -302,6 +304,8 @@ public class NEUCape { shaderManager.loadData(shaderName, "eventRand", eventRandom); } else if(shaderName.equalsIgnoreCase("mcworld_cape")) { shaderManager.loadData(shaderName, "millis", (int) (System.currentTimeMillis() - startTime)); + } else if(shaderName.equalsIgnoreCase("lava_cape")) { + shaderManager.loadData(shaderName, "millis", (int) (System.currentTimeMillis() - startTime)); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java index 696e226b..81be2204 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/gamemodes/SBGamemodes.java @@ -3,25 +3,19 @@ package io.github.moulberry.notenoughupdates.gamemodes; import com.google.gson.Gson; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.options.Options; -import io.github.moulberry.notenoughupdates.questing.SBScoreboardData; +import io.github.moulberry.notenoughupdates.questing.SBInfo; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.ContainerChest; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.input.Keyboard; import javax.crypto.Cipher; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import java.io.*; import java.nio.ByteBuffer; @@ -229,7 +223,7 @@ public class SBGamemodes { public void onPlayerInteract(PlayerInteractEvent event) { if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; - if(!"Your Island".equals(SBScoreboardData.getInstance().location)) return; + if(!"Your Island".equals(SBInfo.getInstance().location)) return; if((getGamemode().gamemodeModifiers & MODIFIER_SMALLISLAND) != 0) { if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { @@ -252,8 +246,8 @@ public class SBGamemodes { public void onTick(TickEvent.ClientTickEvent event) { if(getGamemode() == null || !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; - if("Your Island".equals(SBScoreboardData.getInstance().location) && - (EnumChatFormatting.YELLOW+"Break a log").equals(SBScoreboardData.getInstance().objective)) { + if("Your Island".equals(SBInfo.getInstance().location) && + (EnumChatFormatting.YELLOW+"Break a log").equals(SBInfo.getInstance().objective)) { getGamemode().locked = false; } else { getGamemode().locked = true; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java index 0302d74a..d0600796 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/CollectionLogInfoPane.java @@ -5,6 +5,7 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NEUResourceManager; +import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; @@ -395,9 +396,8 @@ public class CollectionLogInfoPane extends ScrollableInfoPane { } private void renderItemBackgrounds(Color fg, int left, int right, int top, int bottom) { - int opacity = Math.min(255, Math.max(0, manager.config.fgOpacity.value.intValue())); - Color fgGold = new Color(limCol(fg.getRed()+100), limCol(fg.getGreen()+50), limCol(fg.getBlue()-50), opacity); - Color fgCustomOpacity = new Color((fg.getRGB() & 0x00ffffff) | opacity << 24, true); + Color fgCustomOpacity = new Color(SpecialColour.specialToChromaRGB(manager.config.itemBackgroundColour.value), true); + Color fgGold = new Color(SpecialColour.specialToChromaRGB(manager.config.itemFavouriteColour.value), true); String[] items = getItemList(); iterateItemSlots(new ItemSlotConsumer() { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java index 60f8ca72..76b500f5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/InfoPane.java @@ -17,6 +17,8 @@ public abstract class InfoPane extends Gui { this.manager = manager; } + public void reset() {} + public void tick() {} public abstract void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX, 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 00716271..e5fc10b2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/infopanes/SettingsInfoPane.java @@ -3,18 +3,26 @@ 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.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; import io.github.moulberry.notenoughupdates.options.Options; 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.renderer.GlStateManager; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.GL11; +import scala.tools.cmd.Spec; import java.awt.*; +import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -34,10 +42,44 @@ public class SettingsInfoPane extends InfoPane { private int clickedSliderX = 0; private float clickedSliderMult = 0; + private static final int colourEditorBG = new Color(80, 80, 80, 220).getRGB(); + private static ResourceLocation colourPickerLocation = new ResourceLocation("notenoughupdates:dynamic/colourpicker"); + private static ResourceLocation colourPickerBarValueLocation = new ResourceLocation("notenoughupdates:dynamic/colourpickervalue"); + private static ResourceLocation colourPickerBarOpacityLocation = new ResourceLocation("notenoughupdates:dynamic/colourpickeropacity"); + + private GuiElementTextField hexField = new GuiElementTextField("", + GuiElementTextField.SCALE_TEXT | GuiElementTextField.FORCE_CAPS | GuiElementTextField.NO_SPACE); + private ColourEditor activeColourEditor = null; + + private class ColourEditor { + public int x; + public int y; + public Options.Option option; + public String special; + + public ColourEditor(int x, int y, Options.Option option, String special) { + this.x = x; + this.y = y; + this.option = option; + this.special = special; + } + } + public SettingsInfoPane(NEUOverlay overlay, NEUManager manager) { super(overlay, manager); } + public void reset() { + textConfigMap.clear(); + activeColourEditor = null; + hexField.otherComponentClick(); + } + + private void showColourEditor(int mouseX, int mouseY, Options.Option option, String special) { + activeColourEditor = new ColourEditor(mouseX, mouseY, option, special); + hexField.otherComponentClick(); + } + public void render(int width, int height, Color bg, Color fg, ScaledResolution scaledresolution, int mouseX, int mouseY) { FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; @@ -116,6 +158,7 @@ public class SettingsInfoPane extends InfoPane { textConfigMap.put(option, new GuiElementTextField(String.valueOf(option.value), GuiElementTextField.NUM_ONLY | GuiElementTextField.NO_SPACE | GuiElementTextField.SCALE_TEXT)); } + GuiElementTextField tf = textConfigMap.get(option); if(tf.getText().trim().endsWith(".0")) { tf.setText(tf.getText().trim().substring(0, tf.getText().trim().length()-2)); @@ -147,18 +190,46 @@ public class SettingsInfoPane extends InfoPane { Utils.drawTexturedRect(x+1*mult+(float)(54*sliderAmount*mult), y + tileHeight - 20*mult, 8*mult, 16*mult); } else { - if(!textConfigMap.containsKey(option)) { - textConfigMap.put(option, new GuiElementTextField(String.valueOf(option.value), 0)); - } - GuiElementTextField tf = textConfigMap.get(option); - if(tf.getFocus()) { - tf.setSize(Math.max(tileWidth-(int)(20*mult), fr.getStringWidth(tf.getText())+10), (int)(16*mult)); - tfTop.set(tf); - tfTopX.set(x+(int)(10*mult)); - tfTopY.set(y+tileHeight-(int)(20*mult)); + 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()); + + Color c = new Color(SpecialColour.specialToChromaRGB((String)option.value)); + GlStateManager.color( + Math.min(1f, c.getRed()/255f), + Math.min(1f, c.getGreen()/255f), + Math.min(1f, c.getBlue()/255f), 1f); + Minecraft.getMinecraft().getTextureManager().bindTexture(button_white); + Utils.drawTexturedRect(x + tileWidth/2f - (int) (32 * mult), y + tileHeight - (int) (20 * mult), (int) (48 * mult), (int) (16 * mult)); + + GlStateManager.color(1, 1, 1, 1); + Minecraft.getMinecraft().getTextureManager().bindTexture(help); + 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)) { + List textLines = new ArrayList<>(); + textLines.add(option.displayName); + textLines.add(EnumChatFormatting.GRAY + option.desc); + textToDisplay.set(textLines); + } + } } else { - tf.setSize(tileWidth-(int)(20*mult), (int)(16*mult)); - tf.render(x+(int)(10*mult), y+tileHeight-(int)(20*mult)); + if(!textConfigMap.containsKey(option)) { + textConfigMap.put(option, new GuiElementTextField(String.valueOf(option.value), 0)); + } + GuiElementTextField tf = textConfigMap.get(option); + if(tf.getFocus()) { + tf.setSize(Math.max(tileWidth-(int)(20*mult), fr.getStringWidth(tf.getText())+10), (int)(16*mult)); + tfTop.set(tf); + tfTopX.set(x+(int)(10*mult)); + tfTopY.set(y+tileHeight-(int)(20*mult)); + } else { + tf.setSize(tileWidth-(int)(20*mult), (int)(16*mult)); + tf.render(x+(int)(10*mult), y+tileHeight-(int)(20*mult)); + } } } } @@ -166,6 +237,137 @@ public class SettingsInfoPane extends InfoPane { if(tfTop.get() != null) { tfTop.get().render(tfTopX.get(), tfTopY.get()); } + + if(activeColourEditor != null) { + Gui.drawRect(activeColourEditor.x, activeColourEditor.y, activeColourEditor.x+119, activeColourEditor.y+89, colourEditorBG); + + int currentColour = SpecialColour.specialToSimpleRGB(activeColourEditor.special); + Color c = new Color(currentColour, true); + float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); + + BufferedImage bufferedImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB); + for(int x=0; x<256; x++) { + for(int y=0; y<256; y++) { + float radius = (float) Math.sqrt(((x-128)*(x-128)+(y-128)*(y-128))/16384f); + float angle = (float) Math.toDegrees(Math.atan((128-x)/(y-128+1E-5))+Math.PI/2); + if(y < 128) angle += 180; + if(radius <= 1) { + int rgb = Color.getHSBColor(angle/360f, (float)Math.pow(radius, 1.5f), hsv[2]).getRGB(); + bufferedImage.setRGB(x, y, rgb); + } + } + } + + BufferedImage bufferedImageValue = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB); + for(int x=0; x<10; x++) { + for(int y=0; y<64; y++) { + if((x == 0 || x == 9) && (y == 0 || y == 63)) continue; + + int rgb = Color.getHSBColor(hsv[0], hsv[1], (64-y)/64f).getRGB(); + bufferedImageValue.setRGB(x, y, rgb); + } + } + + BufferedImage bufferedImageOpacity = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB); + for(int x=0; x<10; x++) { + for(int y=0; y<64; y++) { + if((x == 0 || x == 9) && (y == 0 || y == 63)) continue; + + int rgb = (currentColour & 0x00FFFFFF) | (Math.min(255, (64-y)*4) << 24); + bufferedImageOpacity.setRGB(x, y, rgb); + } + } + + float selradius = (float) Math.pow(hsv[1], 1/1.5f)*32; + int selx = (int)(Math.cos(Math.toRadians(hsv[0]*360))*selradius); + int sely = (int)(Math.sin(Math.toRadians(hsv[0]*360))*selradius); + + Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar_alpha); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST); + + Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarValueLocation, new DynamicTexture(bufferedImageValue)); + Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarValueLocation); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(activeColourEditor.x+5+64+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST); + + Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarOpacityLocation, new DynamicTexture(bufferedImageOpacity)); + Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarOpacityLocation); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST); + + int chromaSpeed = SpecialColour.getSpeed(activeColourEditor.special); + int currentColourChroma = SpecialColour.specialToChromaRGB(activeColourEditor.special); + Color cChroma = new Color(currentColourChroma, true); + float hsvChroma[] = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null); + + if(chromaSpeed > 0) { + Gui.drawRect(activeColourEditor.x+5+64+5+10+5+10+5+1, activeColourEditor.y+5+1, + activeColourEditor.x+5+64+5+10+5+10+5+10-1, activeColourEditor.y+5+64-1, + Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f)); + } else { + Gui.drawRect(activeColourEditor.x+5+64+5+10+5+10+5+1, activeColourEditor.y+5+27+1, + activeColourEditor.x+5+64+5+10+5+10+5+10-1, activeColourEditor.y+5+37-1, + Color.HSBtoRGB((hsvChroma[0]+(System.currentTimeMillis()-SpecialColour.startTime)/1000f)%1, 0.8f, 0.8f)); + } + + Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(activeColourEditor.x+5+64+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST); + Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST); + + if(chromaSpeed > 0) { + Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5+10+5, activeColourEditor.y+5, 10, 64, GL11.GL_NEAREST); + } else { + Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_chroma); + Utils.drawTexturedRect(activeColourEditor.x+5+64+5+10+5+10+5, activeColourEditor.y+5+27, 10, 10, GL11.GL_NEAREST); + } + + Gui.drawRect(activeColourEditor.x+5+64+5, activeColourEditor.y+5+64-(int)(64*hsv[2]), + activeColourEditor.x+5+64+5+10, activeColourEditor.y+5+64-(int)(64*hsv[2])+1, 0xFF000000); + Gui.drawRect(activeColourEditor.x+5+64+5+10+5, activeColourEditor.y+5+64-c.getAlpha()/4, + activeColourEditor.x+5+64+5+10+5+10, activeColourEditor.y+5+64-c.getAlpha()/4-1, 0xFF000000); + if(chromaSpeed > 0) { + Gui.drawRect(activeColourEditor.x+5+64+5+10+5+10+5, + activeColourEditor.y+5+64-(int)(chromaSpeed/255f*64), + activeColourEditor.x+5+64+5+10+5+10+5+10, + activeColourEditor.y+5+64-(int)(chromaSpeed/255f*64)+1, 0xFF000000); + } + + Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerLocation, new DynamicTexture(bufferedImage)); + Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerLocation); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(activeColourEditor.x+5, activeColourEditor.y+5, 64, 64, GL11.GL_NEAREST); + + Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_dot); + GlStateManager.color(1, 1, 1, 1); + Utils.drawTexturedRect(activeColourEditor.x+5+32+selx-4, activeColourEditor.y+5+32+sely-4, 8, 8, GL11.GL_NEAREST); + + Utils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(hsv[2]*100)+"", + Minecraft.getMinecraft().fontRendererObj, + activeColourEditor.x+5+64+5+5-(Math.round(hsv[2]*100)==100?1:0), activeColourEditor.y+5+64+5+5, true, 13, -1); + Utils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+Math.round(c.getAlpha()/255f*100)+"", + Minecraft.getMinecraft().fontRendererObj, + activeColourEditor.x+5+64+5+15+5, activeColourEditor.y+5+64+5+5, true, 13, -1); + if(chromaSpeed > 0) { + Utils.drawStringCenteredScaledMaxWidth(EnumChatFormatting.GRAY.toString()+(int)SpecialColour.getSecondsForSpeed(chromaSpeed)+"s", + Minecraft.getMinecraft().fontRendererObj, + activeColourEditor.x+5+64+5+30+6, activeColourEditor.y+5+64+5+5, true, 13, -1); + } + + hexField.setSize(48, 10); + if(!hexField.getFocus()) hexField.setText(Integer.toHexString(c.getRGB() & 0xFFFFFF).toUpperCase()); + + StringBuilder sb = new StringBuilder(EnumChatFormatting.GRAY+"#"); + for(int i=0; i<6-hexField.getText().length(); i++) { + sb.append("0"); + } + sb.append(EnumChatFormatting.WHITE); + + hexField.setPrependText(sb.toString()); + hexField.render(activeColourEditor.x+5+8, activeColourEditor.y+5+64+5); + } + if(textToDisplay.get() != null) { Utils.drawHoveringText(textToDisplay.get(), mouseX, mouseY, width, height, 200, fr); } @@ -187,9 +389,84 @@ public class SettingsInfoPane extends InfoPane { for(GuiElementTextField tf : textConfigMap.values()) { tf.otherComponentClick(); } + activeColourEditor = null; + hexField.otherComponentClick(); } public void mouseInput(int width, int height, int mouseX, int mouseY, boolean mouseDown) { + 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(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()); + return; + } + } + } + hexField.otherComponentClick(); + + int currentColour = SpecialColour.specialToSimpleRGB(activeColourEditor.special); + 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; + + if(xWheel > 0 && xWheel < 64) { + if(yWheel > 0 && yWheel < 64) { + float radius = (float) Math.sqrt(((xWheel-32)*(xWheel-32)+(yWheel-32)*(yWheel-32))/1024f); + float angle = (float) Math.toDegrees(Math.atan((32-xWheel)/(yWheel-32+1E-5))+Math.PI/2); + if(yWheel < 32) angle += 180; + + int rgb = Color.getHSBColor(angle/360f, (float)Math.pow(Math.min(1, radius), 1.5f), hsv[2]).getRGB(); + activeColourEditor.special = SpecialColour.special(SpecialColour.getSpeed(activeColourEditor.special), c.getAlpha(), rgb); + activeColourEditor.option.value = (String) activeColourEditor.special; + } + } + + int xValue = mouseX - (activeColourEditor.x+5+64+5); + int y = mouseY - activeColourEditor.y - 5; + + if(y > -5 && y <= 69) { + y = Math.max(0, Math.min(64, y)); + if(xValue > 0 && xValue < 10) { + int rgb = Color.getHSBColor(hsv[0], hsv[1], 1-y/64f).getRGB(); + activeColourEditor.special = SpecialColour.special(SpecialColour.getSpeed(activeColourEditor.special), c.getAlpha(), rgb); + activeColourEditor.option.value = activeColourEditor.special; + } + + int xOpacity = mouseX - (activeColourEditor.x+5+64+5+10+5); + + if(xOpacity > 0 && xOpacity < 10) { + activeColourEditor.special = SpecialColour.special(SpecialColour.getSpeed(activeColourEditor.special), + 255-(int)(y/64f*255), currentColour); + activeColourEditor.option.value = activeColourEditor.special; + } + } + + int chromaSpeed = SpecialColour.getSpeed(activeColourEditor.special); + + int xChroma = mouseX - (activeColourEditor.x+5+64+5+10+5+10+5); + if(xChroma > 0 && xChroma < 10) { + if(chromaSpeed > 0) { + if(y > -5 && y <= 69) { + y = Math.max(0, Math.min(64, y)); + 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) { + activeColourEditor.special = SpecialColour.special(200, c.getAlpha(), currentColour); + activeColourEditor.option.value = activeColourEditor.special; + } + } + + return; + } + } + if(Mouse.getEventButtonState()) activeColourEditor = null; + } iterateSettingTile(new SettingsTileConsumer() { @Override public void consume(int x, int y, int tileWidth, int tileHeight, Options.Option option, Options.Button button) { @@ -271,27 +548,40 @@ public class SettingsInfoPane extends InfoPane { if(Mouse.getEventButtonState()) tf.otherComponentClick(); } else { - if(!textConfigMap.containsKey(option)) { - textConfigMap.put(option, new GuiElementTextField(String.valueOf(option.value), 0)); - } - GuiElementTextField tf = textConfigMap.get(option); - int tfX = x+(int)(10*mult); - 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(Mouse.getEventButtonState()) { - tf.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); - onTextfieldChange(tf, option); - return; - } else if(Mouse.getEventButton() == -1 && mouseDown) { - tf.mouseClickMove(mouseX, mouseY, 0, 0); //last 2 values are unused - return; + 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); + showColourEditor(editorX, editorY, (Options.Option) option, (String)option.value); + return; + } } } + } else { + if(!textConfigMap.containsKey(option)) { + textConfigMap.put(option, new GuiElementTextField(String.valueOf(option.value), 0)); + } + GuiElementTextField tf = textConfigMap.get(option); + int tfX = x+(int)(10*mult); + 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(Mouse.getEventButtonState()) { + tf.mouseClicked(mouseX, mouseY, Mouse.getEventButton()); + onTextfieldChange(tf, option); + return; + } else if(Mouse.getEventButton() == -1 && mouseDown) { + tf.mouseClickMove(mouseX, mouseY, 0, 0); //last 2 values are unused + return; + } + } + } + if(Mouse.getEventButtonState()) tf.otherComponentClick(); } - if(Mouse.getEventButtonState()) tf.otherComponentClick(); } } }); @@ -345,6 +635,24 @@ public class SettingsInfoPane extends InfoPane { } } }); + if(activeColourEditor != null && hexField.getFocus()) { + String old = hexField.getText(); + + hexField.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); + + if(hexField.getText().length() > 6) { + hexField.setText(old); + } else { + try { + String text = hexField.getText().toLowerCase(); + + int rgb = Integer.parseInt(text, 16); + int alpha = (SpecialColour.specialToSimpleRGB(activeColourEditor.special) >> 24) & 0xFF; + activeColourEditor.special = SpecialColour.special(SpecialColour.getSpeed(activeColourEditor.special), alpha, rgb); + activeColourEditor.option.value = activeColourEditor.special; + } catch(Exception e) {}; + } + } return ret.get(); } 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 23f4ad0b..5a5bfb5c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/itemeditor/GuiElementTextField.java @@ -32,6 +32,8 @@ public class GuiElementTextField extends GuiElement { private int x; private int y; + private String prependText = ""; + private GuiTextField textField = new GuiTextField(0, Minecraft.getMinecraft().fontRendererObj, 0 , 0, 0, 0); @@ -53,6 +55,10 @@ public class GuiElementTextField extends GuiElement { return textField.getText(); } + public void setPrependText(String text) { + this.prependText = text; + } + public void setText(String text) { if(textField.getText() == null || !textField.getText().equals(text)) { textField.setText(text); @@ -115,16 +121,20 @@ public class GuiElementTextField extends GuiElement { int extraSize = (searchBarYSize-8)/2+8; + String renderText = prependText + textField.getText(); + int lineNum = Math.round(((yComp - (searchBarYSize-8)/2))/extraSize); Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6])(?!\\u00B6)"); - String text = textField.getText(); - String textNoColour = textField.getText(); - while(true) { - Matcher matcher = patternControlCode.matcher(text); - if(!matcher.find() || matcher.groupCount() < 1) break; - String code = matcher.group(1); - text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code); + String text = renderText; + String textNoColour = renderText; + if((options & COLOUR) != 0) { + while(true) { + Matcher matcher = patternControlCode.matcher(text); + if(!matcher.find() || matcher.groupCount() < 1) break; + String code = matcher.group(1); + text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code); + } } while(true) { Matcher matcher = patternControlCode.matcher(textNoColour); @@ -141,20 +151,31 @@ public class GuiElementTextField extends GuiElement { currentLine++; } } + + String textNC = textNoColour.substring(0, cursorIndex); int colorCodes = StringUtils.countMatches(textNC, "\u00B6"); - String line = text.substring(cursorIndex+colorCodes*2).split("\n")[0]; - String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(line, xComp-5); + String line = text.substring(cursorIndex+(((options & COLOUR) != 0)?colorCodes*2:0)).split("\n")[0]; + int padding = Math.min(5, searchBarXSize-strLenNoColor(line))/2; + String trimmed = Minecraft.getMinecraft().fontRendererObj.trimStringToWidth(line, xComp-padding); int linePos = strLenNoColor(trimmed); if(linePos != strLenNoColor(line)) { char after = line.charAt(linePos); int trimmedWidth = Minecraft.getMinecraft().fontRendererObj.getStringWidth(trimmed); int charWidth = Minecraft.getMinecraft().fontRendererObj.getCharWidth(after); - if(trimmedWidth + charWidth/2 < xComp-5) { + if(trimmedWidth + charWidth/2 < xComp-padding) { linePos++; } } cursorIndex += linePos; + + int pre = Utils.cleanColour(prependText).length(); + if(cursorIndex < pre) { + cursorIndex = 0; + } else { + cursorIndex -= pre; + } + return cursorIndex; } @@ -319,7 +340,6 @@ public class GuiElementTextField extends GuiElement { textField.setCursorPosition(pos+1); } } - } } @@ -336,6 +356,7 @@ public class GuiElementTextField extends GuiElement { private void drawTextbox(int x, int y, int searchBarXSize, int searchBarYSize, int searchBarPadding, GuiTextField textField, boolean focus) { ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); + String renderText = prependText + textField.getText(); GlStateManager.disableLighting(); @@ -345,7 +366,7 @@ public class GuiElementTextField extends GuiElement { int paddingUnscaled = searchBarPadding/scaledresolution.getScaleFactor(); if(paddingUnscaled < 1) paddingUnscaled = 1; - int numLines = StringUtils.countMatches(textField.getText(), "\n")+1; + int numLines = StringUtils.countMatches(renderText, "\n")+1; int extraSize = (searchBarYSize-8)/2+8; int bottomTextBox = y + searchBarYSize + extraSize*(numLines-1); @@ -366,13 +387,15 @@ public class GuiElementTextField extends GuiElement { //bar text Pattern patternControlCode = Pattern.compile("(?i)\\u00A7([^\\u00B6\n])(?!\\u00B6)"); - String text = textField.getText(); - String textNoColor = textField.getText(); - while(true) { - Matcher matcher = patternControlCode.matcher(text); - if(!matcher.find() || matcher.groupCount() < 1) break; - String code = matcher.group(1); - text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code); + String text = renderText; + String textNoColor = renderText; + if((options & COLOUR) != 0) { + while(true) { + Matcher matcher = patternControlCode.matcher(text); + if(!matcher.find() || matcher.groupCount() < 1) break; + String code = matcher.group(1); + text = matcher.replaceFirst("\u00A7"+code+"\u00B6"+code); + } } while(true) { Matcher matcher = patternControlCode.matcher(textNoColor); @@ -403,9 +426,9 @@ public class GuiElementTextField extends GuiElement { } if(focus && System.currentTimeMillis()%1000>500) { - String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition()); + String textNCBeforeCursor = textNoColor.substring(0, textField.getCursorPosition()+prependText.length()); int colorCodes = StringUtils.countMatches(textNCBeforeCursor, "\u00B6"); - String textBeforeCursor = text.substring(0, textField.getCursorPosition()+colorCodes*2); + String textBeforeCursor = text.substring(0, textField.getCursorPosition()+prependText.length()+(((options & COLOUR) != 0) ? colorCodes*2 : 0)); int numLinesBeforeCursor = StringUtils.countMatches(textBeforeCursor, "\n"); int yOff = numLinesBeforeCursor*extraSize; @@ -425,8 +448,8 @@ public class GuiElementTextField extends GuiElement { String selectedText = textField.getSelectedText(); if(!selectedText.isEmpty()) { - int leftIndex = Math.min(textField.getCursorPosition(), textField.getSelectionEnd()); - int rightIndex = Math.max(textField.getCursorPosition(), textField.getSelectionEnd()); + int leftIndex = Math.min(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length()); + int rightIndex = Math.max(textField.getCursorPosition()+prependText.length(), textField.getSelectionEnd()+prependText.length()); float texX = 0; int texY = 0; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java new file mode 100644 index 00000000..78201a8f --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityPlayer.java @@ -0,0 +1,34 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.DungeonBlocks; +import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EnumPlayerModelParts; +import net.minecraft.util.EnumWorldBlockLayer; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.lwjgl.opengl.GL14; +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({EntityPlayer.class}) +public abstract class MixinEntityPlayer { + + @Inject(method="isWearing", at=@At("HEAD"), cancellable = true) + public void isWearing(EnumPlayerModelParts part, CallbackInfoReturnable cir) { + if(part == EnumPlayerModelParts.CAPE) { + EntityPlayer $this = (EntityPlayer)(Object)this; + String uuid = $this.getUniqueID().toString().replace("-", ""); + String cape = CapeManager.getInstance().getCape(uuid); + if(cape != null && !cape.equalsIgnoreCase("null")) { + cir.setReturnValue(false); + } + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java index f56093b8..bd74b44c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiChest.java @@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.BetterContainers; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.StreamerMode; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.renderer.texture.DynamicTexture; @@ -29,4 +30,23 @@ public class MixinGuiChest { BetterContainers.bindHook(textureManager, location); } + private static final String TARGET_DRAWSTRING = "Lnet/minecraft/client/gui/FontRenderer;drawString(Ljava/lang/String;III)I"; + @Redirect(method="drawGuiContainerForegroundLayer", at=@At(value="INVOKE", target = TARGET_DRAWSTRING)) + public int drawGuiContainerForegroundLayer_drawString(FontRenderer fontRenderer, String text, int x, int y, int color) { + return fontRenderer.drawString(text, x, y, BetterContainers.isOverriding() ? BetterContainers.getTextColour() : color); + } + + private static final String TARGET_SBADRAWSTRING = "Lcodes/biscuit/skyblockaddons/asm/hooks/GuiChestHook;" + + "drawString(Lnet/minecraft/client/gui/FontRenderer;Ljava/lang/String;III)I"; + @Redirect(method="drawGuiContainerForegroundLayer", at=@At(value="INVOKE", target = TARGET_SBADRAWSTRING, remap = false)) + public int drawGuiContainerForegroundLayer_SBA_drawString(FontRenderer fontRenderer, String text, int x, int y, int color) { + try { + return (int)Class.forName("codes.biscuit.skyblockaddons.asm.hooks.GuiChestHook") + .getDeclaredMethod("drawString", FontRenderer.class, String.class, int.class, int.class, int.class) + .invoke(null, fontRenderer, text, x, y, BetterContainers.isOverriding() ? BetterContainers.getTextColour() : color); + } catch(Exception e) {} + return fontRenderer.drawString(text, x, y, BetterContainers.isOverriding() ? BetterContainers.getTextColour() : color); + } + + } 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 879d348b..e8b635c1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -22,7 +22,7 @@ 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.isBlankStack(slot.getStack())) { + if(slot != null && BetterContainers.isOverriding() && !BetterContainers.shouldRenderStack(slot.getStack())) { ci.cancel(); } } @@ -43,9 +43,11 @@ public abstract class MixinGuiContainer { BetterContainers.clickSlot(slotIn.getSlotIndex()); Utils.playPressSound(); - GuiContainer $this = (GuiContainer)(Object)this; - $this.mc.playerController.windowClick($this.inventorySlots.windowId, slotId, 2, clickType, $this.mc.thePlayer); - ci.cancel(); + /*if(!BetterContainers.isAh()) { + 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/mixins/MixinRenderBat.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderBat.java new file mode 100644 index 00000000..93182439 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderBat.java @@ -0,0 +1,40 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.DungeonBlocks; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.RenderBat; +import net.minecraft.client.renderer.texture.AbstractTexture; +import net.minecraft.client.renderer.texture.SimpleTexture; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +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; + +import java.io.IOException; + +@Mixin({RenderBat.class}) +public abstract class MixinRenderBat { + + @Inject(method="getEntityTexture", at=@At("HEAD"), cancellable = true) + public void getEntityTexture(EntityBat entity, CallbackInfoReturnable cir) { + if(DungeonBlocks.isInDungeons()) { + ResourceLocation rl = new ResourceLocation("notenoughupdates:dynamic/dungeon_bat"); + Minecraft.getMinecraft().getTextureManager().loadTexture(rl, new AbstractTexture() { + public void loadTexture(IResourceManager resourceManager) { + glTextureId = DungeonBlocks.getModifiedTexture(new ResourceLocation("textures/entity/bat.png"), + SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungBatColour.value)); + } + }); + cir.setReturnValue(rl); + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java new file mode 100644 index 00000000..03300d45 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderList.java @@ -0,0 +1,38 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.DungeonBlocks; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.lwjgl.opengl.GL14; +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 javax.imageio.ImageIO; +import java.awt.image.BufferedImage; + +@Mixin({RenderList.class}) +public abstract class MixinRenderList { + + @Inject(method="renderChunkLayer", at=@At("HEAD")) + public void renderChunkLayer(EnumWorldBlockLayer layer, CallbackInfo ci) { + if(DungeonBlocks.textureExists()) { + DungeonBlocks.bindTextureIfExists(); + + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java new file mode 100644 index 00000000..16e4bfbe --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java @@ -0,0 +1,33 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.DungeonBlocks; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderList; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +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; + +@Mixin({TileEntitySpecialRenderer.class}) +public abstract class MixinTileEntitySpecialRenderer { + + @Inject(method="bindTexture", at=@At("HEAD"), cancellable = true) + public void bindTexture(ResourceLocation location, CallbackInfo info) { + if(DungeonBlocks.isInDungeons() && location.getResourcePath().equals("textures/entity/chest/normal.png")) { + info.cancel(); + + GlStateManager.bindTexture(DungeonBlocks.getModifiedTexture(location, + SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungChestColour.value))); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java new file mode 100644 index 00000000..03dded06 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinVboRenderList.java @@ -0,0 +1,42 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.DungeonBlocks; +import io.github.moulberry.notenoughupdates.ItemRarityHalo; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ChunkRenderContainer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.VboRenderList; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import org.lwjgl.opengl.GL14; +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 javax.imageio.ImageIO; +import java.awt.image.BufferedImage; + +@Mixin({VboRenderList.class}) +public abstract class MixinVboRenderList { + + @Inject(method="renderChunkLayer", at=@At("HEAD")) + public void renderChunkLayer(EnumWorldBlockLayer layer, CallbackInfo ci) { + if(DungeonBlocks.textureExists()) { + DungeonBlocks.bindTextureIfExists(); + + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + } + } +} 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 294a8873..c8a596b1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java @@ -5,6 +5,7 @@ import io.github.moulberry.notenoughupdates.GuiEnchantColour; import io.github.moulberry.notenoughupdates.NEUOverlayPlacements; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.mbgui.MBAnchorPoint; +import io.github.moulberry.notenoughupdates.util.SpecialColour; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.util.Util; @@ -28,6 +29,8 @@ public class Options { * variables with defaults values/etc. It works. I'm happy. */ + public static final transient int FLAG_COLOUR = 0b1; + public Option enableItemEditing = new Option( false, "Enable Item Editing", @@ -38,6 +41,11 @@ public class Options { "Only Show On Skyblock", false, "NEU Overlay only appears when you are playing Skyblock."); + public Option showVanillaItems = new Option( + true, + "Show Vanilla Items", + false, + "Shows vanilla items in the itemlist."); public Option hidePotionEffect = new Option( true, "Hide Potion Effects", @@ -143,6 +151,21 @@ public class Options { "Custom Trade", false, "If true, uses the custom trade window for skyblock trades."); + public Option invBazaarPrice = new Option( + false, + "Show Bazaar Price In Inventory", + false, + "If true, shows the bazaar price for the item you hover in your inventory."); + public Option invAuctionPrice = new Option( + false, + "Show Auction Price In Inventory", + false, + "If true, shows the auction price for the item you hover in your inventory."); + public Option 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."); public Option paneWidthMult = new Option( 1.0, "Pane Width", @@ -153,16 +176,6 @@ public class Options { "Smooth AOTE Milliseconds", false, "How long teleporting with the AOTE takes. 0 = disable.", 0, 300); - public Option bgOpacity = new Option( - 30.0, - "Pane Background Opacity", - false, - "Changes the background colour opacity of item and info panes. Value between 0-255.", 0, 255); - public Option fgOpacity = new Option( - 255.0, - "Item Background Opacity", - false, - "Changes the opacity of item background. Value between 0-255.", 0, 255); public Option itemHighlightOpacity = new Option( 178.0, "Item Highlight Opacity", @@ -194,6 +207,68 @@ public class Options { false, "Style of the buttons used for the skyblock menu.", 0, 10); + public Option itemBackgroundColour = new Option( + "00:255:100:100:100", + "Item BG Colour", + false, + "Treecapitator Overlay Colour", + FLAG_COLOUR); + public Option itemFavouriteColour = new Option( + "00:255:200:150:50", + "Item BG Favourite Colour", + false, + "Item BG Favourite Colour", + FLAG_COLOUR); + public Option paneBackgroundColour = new Option( + "15:6:0:0:255", + "Pane Background Colour", + false, + "Pane Background Colour", + FLAG_COLOUR); + public Option treecapOverlayColour = new Option( + "00:50:64:224:208", + "Treecapitator Overlay Colour", + false, + "Treecapitator Overlay Colour", + FLAG_COLOUR); + + public Option dungCrackedColour = new Option( + "0:252:7:255:217", + "Dungeon Cracked Brick Colour", + false, + "Dungeon Cracked Brick Colour", + FLAG_COLOUR); + public Option dungDispenserColour = new Option( + "0:255:255:76:0", + "Dungeon Dispenser Colour", + false, + "Dungeon Dispenser Colour", + FLAG_COLOUR); + public Option dungLeverColour = new Option( + "0:252:24:249:255", + "Dungeon Lever Colour", + false, + "Dungeon Lever Colour", + FLAG_COLOUR); + public Option dungTripWireColour = new Option( + "0:255:255:0:0", + "Dungeon Trip Wire Colour", + false, + "Dungeon Trip Wire Colour", + FLAG_COLOUR); + public Option dungChestColour = new Option( + "0:255:0:163:36", + "Dungeon Chest Colour", + false, + "Dungeon Chest Colour", + FLAG_COLOUR); + public Option dungBatColour = new Option( + "0:255:12:255:0", + "Dungeon Bat Colour", + false, + "Dungeon Bat Colour", + FLAG_COLOUR); + /** * OPTIONS THAT DON'T SHOW IN GUI */ @@ -336,6 +411,7 @@ public class Options { //Buttons tryAddOption(enableItemEditing, options); tryAddOption(onlyShowOnSkyblock, options); + tryAddOption(showVanillaItems, options); tryAddOption(showQuickCommands, options); tryAddOption(hidePotionEffect, options); tryAddOption(hideEmptyPanes, options); @@ -356,12 +432,13 @@ public class Options { tryAddOption(useCustomTrade, options); tryAddOption(customTradePrices, options); tryAddOption(customTradePriceStyle, options); + tryAddOption(invBazaarPrice, options); + tryAddOption(invAuctionPrice, options); + tryAddOption(dungeonBlocksEverywhere, options); //Sliders tryAddOption(smoothAoteMillis, options); tryAddOption(bgBlurFactor, options); tryAddOption(ahNotification, options); - tryAddOption(bgOpacity, options); - tryAddOption(fgOpacity, options); tryAddOption(itemHighlightOpacity, options); tryAddOption(panePadding, options); tryAddOption(tooltipBorderOpacity, options); @@ -369,6 +446,18 @@ public class Options { tryAddOption(dynamicMenuButtonStyle, options); //Text tryAddOption(apiKey, options); + //Colour + tryAddOption(paneBackgroundColour, options); + tryAddOption(itemBackgroundColour, options); + tryAddOption(itemFavouriteColour, options); + tryAddOption(treecapOverlayColour, options); + + tryAddOption(dungCrackedColour, options); + tryAddOption(dungDispenserColour, options); + tryAddOption(dungLeverColour, options); + tryAddOption(dungTripWireColour, options); + tryAddOption(dungChestColour, options); + tryAddOption(dungBatColour, options); return options; } @@ -385,19 +474,29 @@ public class Options { public final transient String displayName; public final transient boolean secret; public final transient String desc; + public final transient int flags; public final transient double minValue; public final transient double maxValue; public Option(T defaultValue, String displayName, boolean secret, String desc) { - this(defaultValue, displayName, secret, desc, 0, 100); + this(defaultValue, displayName, secret, desc, 0, 0, 100); + } + + 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, double minValue, double maxValue) { + this(defaultValue, displayName, secret, desc, 0, minValue, maxValue); + } + + public Option(T defaultValue, String displayName, boolean secret, String desc, int flags, double minValue, double maxValue) { this.value = defaultValue; this.defaultValue = defaultValue; this.displayName = displayName; this.secret = secret; this.desc = desc; + this.flags = flags; this.minValue = minValue; this.maxValue = maxValue; } 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 837addf3..fc0caa28 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -11,7 +11,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates; 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.SBScoreboardData; +import io.github.moulberry.notenoughupdates.questing.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityOtherPlayerMP; @@ -675,9 +675,9 @@ public class GuiProfileViewer extends GuiScreen { backgroundRotation %= 360; String panoramaIdentifier = "day"; - if(SBScoreboardData.getInstance().currentTimeDate != null) { - if(SBScoreboardData.getInstance().currentTimeDate.getHours() <= 6 || - SBScoreboardData.getInstance().currentTimeDate.getHours() >= 20) { + if(SBInfo.getInstance().currentTimeDate != null) { + if(SBInfo.getInstance().currentTimeDate.getHours() <= 6 || + SBInfo.getInstance().currentTimeDate.getHours() >= 20) { panoramaIdentifier = "night"; } } @@ -1902,9 +1902,9 @@ public class GuiProfileViewer extends GuiScreen { backgroundRotation %= 360; String panoramaIdentifier = "day"; - if(SBScoreboardData.getInstance().currentTimeDate != null) { - if(SBScoreboardData.getInstance().currentTimeDate.getHours() <= 6 || - SBScoreboardData.getInstance().currentTimeDate.getHours() >= 20) { + if(SBInfo.getInstance().currentTimeDate != null) { + if(SBInfo.getInstance().currentTimeDate.getHours() <= 6 || + SBInfo.getInstance().currentTimeDate.getHours() >= 20) { panoramaIdentifier = "night"; } } @@ -1984,6 +1984,30 @@ public class GuiProfileViewer extends GuiScreen { long networth = profile.getNetWorth(profileId); if(networth > 0) { Utils.drawStringCentered(EnumChatFormatting.GREEN+"Net Worth: "+EnumChatFormatting.GOLD+numberFormat.format(networth), fr, guiLeft+63, guiTop+38, true, 0); + try { + double networthInCookies = (networth / NotEnoughUpdates.INSTANCE.manager.auctionManager.getBazaarInfo("BOOSTER_COOKIE").get("avg_buy").getAsDouble()); + String networthIRLMoney = Long.toString(Math.round(((networthInCookies * 325) / 675) * 4.99)); + + if(mouseX > guiLeft+8 && mouseX < guiLeft+8+fontRendererObj.getStringWidth("Net Worth: " + numberFormat.format(networth))) { + if(mouseY > guiTop+32 && mouseY < guiTop+32+fontRendererObj.FONT_HEIGHT) { + tooltipToDisplay = new ArrayList<>(); + tooltipToDisplay.add(EnumChatFormatting.GREEN+"Net worth in IRL money: "+EnumChatFormatting.DARK_GREEN+"$" +EnumChatFormatting.GOLD+networthIRLMoney); + tooltipToDisplay.add(""); + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + tooltipToDisplay.add(EnumChatFormatting.RED+"This is calculated using the current"); + tooltipToDisplay.add(EnumChatFormatting.RED+"price of booster cookies on bazaar and the price"); + tooltipToDisplay.add(EnumChatFormatting.RED+"for cookies using gems, then the price of gems"); + tooltipToDisplay.add(EnumChatFormatting.RED+"is where we get the amount of IRL money you" ); + tooltipToDisplay.add(EnumChatFormatting.RED+"theoretically have on skyblock in net worth."); + } else { + tooltipToDisplay.add(EnumChatFormatting.GRAY+"[SHIFT for Info]"); + } + tooltipToDisplay.add(""); + tooltipToDisplay.add(EnumChatFormatting.RED+"THIS IS IN NO WAY ENDORSING IRL TRADING!"); + + } + } + } catch(Exception e){} } if(status != null) { @@ -2212,6 +2236,11 @@ public class GuiProfileViewer extends GuiScreen { } private void renderGoldBar(float x, float y, float xSize) { + if(!OpenGlHelper.areShadersSupported()) { + renderBar(x, y, xSize, 1); + return; + } + Minecraft.getMinecraft().getTextureManager().bindTexture(icons); ShaderManager shaderManager = ShaderManager.getInstance(); shaderManager.loadShader("make_gold"); @@ -2384,6 +2413,8 @@ public class GuiProfileViewer extends GuiScreen { */ private double lastBgBlurFactor = -1; private void blurBackground() { + if(!OpenGlHelper.isFramebufferEnabled()) return; + int width = Minecraft.getMinecraft().displayWidth; int height = Minecraft.getMinecraft().displayHeight; @@ -2443,6 +2474,8 @@ public class GuiProfileViewer extends GuiScreen { * Essentially, this method will "blur" the background inside the bounds specified by [x->x+blurWidth, y->y+blurHeight] */ public void renderBlurredBackground(int width, int height, int x, int y, int blurWidth, int blurHeight) { + if(!OpenGlHelper.isFramebufferEnabled()) return; + float uMin = x/(float)width; float uMax = (x+blurWidth)/(float)width; float vMin = (height-y)/(float)height; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java index fa585f1e..379935ad 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/Panorama.java @@ -1,9 +1,11 @@ package io.github.moulberry.notenoughupdates.profileviewer; import io.github.moulberry.notenoughupdates.util.TexLoc; +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.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.texture.DynamicTexture; @@ -24,6 +26,15 @@ public class Panorama { private static int lastHeight = 0; public static void drawPanorama(float angle, int x, int y, int width, int height, float yOffset, float zOffset, ResourceLocation[] panoramas) { + if(!OpenGlHelper.isFramebufferEnabled()) { + Minecraft.getMinecraft().getTextureManager().bindTexture(panoramas[0]); + + float aspect = width/(float)height; + Utils.drawTexturedRect(x, y, width, height, 0.5f-aspect/2, 0.5f+aspect/2, 0, 1); + + return; + } + Minecraft.getMinecraft().getFramebuffer().unbindFramebuffer(); ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java new file mode 100644 index 00000000..b647fb1c --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java @@ -0,0 +1,125 @@ +package io.github.moulberry.notenoughupdates.questing; + +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.scoreboard.Score; +import net.minecraft.scoreboard.ScoreObjective; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.scoreboard.Scoreboard; +import net.minecraftforge.client.event.ClientChatReceivedEvent; +import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class SBInfo { + + private static final SBInfo INSTANCE = new SBInfo(); + + private static final Pattern timePattern = Pattern.compile(".+(am|pm)"); + + public String location = ""; + public String date = ""; + public String time = ""; + public String objective = ""; + + public String mode = ""; + + public Date currentTimeDate = null; + + public static SBInfo getInstance() { + return INSTANCE; + } + + private long lastLocRaw = -1; + private JsonObject locraw = null; + + @SubscribeEvent + public void onWorldChange(WorldEvent.Load event) { + lastLocRaw = -1; + locraw = null; + } + + @SubscribeEvent + public void onChatMessage(ClientChatReceivedEvent event) { + if(event.message.getUnformattedText().startsWith("{")) { + try { + JsonObject obj = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(event.message.getUnformattedText(), JsonObject.class); + if(obj.has("server") && obj.has("gametype") && obj.has("mode") && obj.has("map")) { + locraw = obj; + event.setCanceled(true); + } + } catch(Exception e) { + e.printStackTrace(); + } + } + } + + public String getLocation() { + if(locraw == null) { + return null; + } + return locraw.get("mode").getAsString(); + } + + public void tick() { + if(locraw == null && (System.currentTimeMillis() - lastLocRaw) > 20000) { + lastLocRaw = System.currentTimeMillis(); + NotEnoughUpdates.INSTANCE.sendChatMessage("/locraw"); + } + + try { + Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); + + ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); //ยง707/14/20 + + List scores = new ArrayList<>(); + for(Score score : scoreboard.getSortedScores(sidebarObjective)) { + scores.add(score); + } + List lines = new ArrayList<>(); + for(int i=scores.size()-1; i>=0; i--) { + Score score = scores.get(i); + ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score.getPlayerName()); + String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName()); + line = Utils.cleanDuplicateColourCodes(line); + lines.add(line); + } + if(lines.size() >= 5) { + date = Utils.cleanColour(lines.get(1)).trim(); + //ยง74:40am + Matcher matcher = timePattern.matcher(lines.get(2)); + if(matcher.find()) { + time = Utils.cleanColour(matcher.group()).trim(); + try { + String timeSpace = time.replace("am", " am").replace("pm", " pm"); + SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a"); + currentTimeDate = parseFormat.parse(timeSpace); + } catch (ParseException e) {} + } + location = Utils.cleanColour(lines.get(3)).replaceAll("[^A-Za-z0-9() ]", "").trim(); + } + objective = null; + + boolean objTextLast = false; + for(String line : lines) { + if(objTextLast) { + objective = line; + } + + objTextLast = line.equals("Objective"); + } + } catch(Exception e) { + e.printStackTrace(); + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/questing/SBScoreboardData.java b/src/main/java/io/github/moulberry/notenoughupdates/questing/SBScoreboardData.java deleted file mode 100644 index 9735f917..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/questing/SBScoreboardData.java +++ /dev/null @@ -1,88 +0,0 @@ -package io.github.moulberry.notenoughupdates.questing; - -import io.github.moulberry.notenoughupdates.util.Utils; -import net.minecraft.client.Minecraft; -import net.minecraft.scoreboard.Score; -import net.minecraft.scoreboard.ScoreObjective; -import net.minecraft.scoreboard.ScorePlayerTeam; -import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.util.EnumChatFormatting; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class SBScoreboardData { - - private static final SBScoreboardData INSTANCE = new SBScoreboardData(); - - private static final Pattern locationPattern = Pattern.compile("(\\u00a7)(?!.*\\u00a7).+"); - private static final Pattern timePattern = Pattern.compile(".+(am|pm)"); - - public String location = ""; - public String date = ""; - public String time = ""; - public String objective = ""; - - public Date currentTimeDate = null; - - public static SBScoreboardData getInstance() { - return INSTANCE; - } - - public void tick() { - try { - Scoreboard scoreboard = Minecraft.getMinecraft().thePlayer.getWorldScoreboard(); - - ScoreObjective sidebarObjective = scoreboard.getObjectiveInDisplaySlot(1); //ยง707/14/20 - - List scores = new ArrayList<>(); - for(Score score : scoreboard.getSortedScores(sidebarObjective)) { - scores.add(score); - } - List lines = new ArrayList<>(); - for(int i=scores.size()-1; i>=0; i--) { - Score score = scores.get(i); - ScorePlayerTeam scoreplayerteam1 = scoreboard.getPlayersTeam(score.getPlayerName()); - String line = ScorePlayerTeam.formatPlayerName(scoreplayerteam1, score.getPlayerName()); - line = Utils.cleanDuplicateColourCodes(line); - lines.add(line); - } - if(lines.size() >= 5) { - date = Utils.cleanColour(lines.get(2)).trim(); - //ยง74:40am - Matcher matcher = timePattern.matcher(lines.get(3)); - if(matcher.find()) { - time = Utils.cleanColour(matcher.group()).trim(); - try { - String timeSpace = time.replace("am", " am").replace("pm", " pm"); - SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a"); - currentTimeDate = parseFormat.parse(timeSpace); - } catch (ParseException e) {} - } - matcher = locationPattern.matcher(lines.get(4)); - if(matcher.find()) { - location = Utils.cleanColour(matcher.group()).trim(); - } - } - objective = null; - - boolean objTextLast = false; - for(String line : lines) { - if(objTextLast) { - objective = line; - } - - objTextLast = line.equals("Objective"); - } - } catch(Exception e) { - e.printStackTrace(); - } - //System.out.println(date + ":" + time + ":" + location); - } - -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/questing/requirements/RequirementIslandType.java b/src/main/java/io/github/moulberry/notenoughupdates/questing/requirements/RequirementIslandType.java index 319bc1b6..c0aef344 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/questing/requirements/RequirementIslandType.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/questing/requirements/RequirementIslandType.java @@ -1,6 +1,6 @@ package io.github.moulberry.notenoughupdates.questing.requirements; -import io.github.moulberry.notenoughupdates.questing.SBScoreboardData; +import io.github.moulberry.notenoughupdates.questing.SBInfo; public class RequirementIslandType extends Requirement { @@ -14,6 +14,6 @@ public class RequirementIslandType extends Requirement { @Override public void updateRequirement() { - completed = islandType.equalsIgnoreCase(SBScoreboardData.getInstance().location); + completed = islandType.equalsIgnoreCase(SBInfo.getInstance().location); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java index d6f89409..2e6b29da 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java @@ -24,7 +24,7 @@ public class HypixelApi { private ExecutorService es = Executors.newFixedThreadPool(3); private int myApiErrors = 0; - private String[] myApiURLs = {"https://moulberry.codes/", "http://51.89.22.3/", "http://moulberry.codes/", "https://51.89.22.3/"}; + private String[] myApiURLs = {"https://moulberry.codes/", "http://51.75.78.252/", "http://moulberry.codes/" }; public void getHypixelApiAsync(String apiKey, String method, HashMap args, Consumer consumer) { getHypixelApiAsync(apiKey, method, args, consumer, () -> {}); @@ -42,7 +42,7 @@ public class HypixelApi { es.submit(() -> { try { consumer.accept(getApiSync(urlS)); - } catch(IOException e) { + } catch(Exception e) { error.run(); } }); @@ -52,7 +52,7 @@ public class HypixelApi { es.submit(() -> { try { consumer.accept(getApiSync(getMyApiURL()+urlS)); - } catch(IOException e) { + } catch(Exception e) { myApiErrors++; error.run(); } @@ -63,7 +63,7 @@ public class HypixelApi { es.submit(() -> { try { consumer.accept(getApiGZIPSync(getMyApiURL()+urlS)); - } catch(IOException e) { + } catch(Exception e) { myApiErrors++; error.run(); } @@ -74,7 +74,7 @@ public class HypixelApi { es.submit(() -> { try { consumer.accept(getApiGZIPSync(urlS)); - } catch(IOException e) { + } catch(Exception e) { error.run(); } }); @@ -83,7 +83,7 @@ public class HypixelApi { public JsonObject getApiSync(String urlS) throws IOException { URL url = new URL(urlS); URLConnection connection = url.openConnection(); - connection.setConnectTimeout(3000); + connection.setConnectTimeout(10000); connection.setReadTimeout(10000); String response = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8); @@ -95,7 +95,7 @@ public class HypixelApi { public JsonObject getApiGZIPSync(String urlS) throws IOException { URL url = new URL(urlS); URLConnection connection = url.openConnection(); - connection.setConnectTimeout(3000); + connection.setConnectTimeout(10000); connection.setReadTimeout(10000); String response = IOUtils.toString(new GZIPInputStream(connection.getInputStream()), StandardCharsets.UTF_8); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java new file mode 100644 index 00000000..9ec6da3e --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SpecialColour.java @@ -0,0 +1,81 @@ +package io.github.moulberry.notenoughupdates.util; + +import java.awt.*; + +public class SpecialColour { + + public static String special(int chromaSpeed, int alpha, int rgb) { + return special(chromaSpeed, alpha, (rgb & 0xFF0000) >> 16, (rgb & 0x00FF00) >> 8, (rgb & 0x0000FF)); + } + + private static final int RADIX = 10; + + public static String special(int chromaSpeed, int alpha, int r, int g, int b) { + StringBuilder sb = new StringBuilder(); + sb.append(Integer.toString(chromaSpeed, RADIX)).append(":"); + sb.append(Integer.toString(alpha, RADIX)).append(":"); + sb.append(Integer.toString(r, RADIX)).append(":"); + sb.append(Integer.toString(g, RADIX)).append(":"); + sb.append(Integer.toString(b, RADIX)); + return sb.toString(); + } + + private static int[] decompose(String csv) { + String[] split = csv.split(":"); + + int[] arr = new int[split.length]; + + + for(int i=0; i 0) { + float seconds = getSecondsForSpeed(chr); + hsv[0] += (System.currentTimeMillis()-startTime)/1000f/seconds; + hsv[0] %= 1; + if(hsv[0] < 0) hsv[0] += 1; + } + + return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF); + } + + +} diff --git a/src/main/resources/assets/notenoughupdates/button_white.png b/src/main/resources/assets/notenoughupdates/button_white.png new file mode 100644 index 00000000..7763716d Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/button_white.png differ diff --git a/src/main/resources/assets/notenoughupdates/capes/lava.png b/src/main/resources/assets/notenoughupdates/capes/lava.png new file mode 100644 index 00000000..8f60a03e Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/lava.png differ diff --git a/src/main/resources/assets/notenoughupdates/capes/mbstaff.png b/src/main/resources/assets/notenoughupdates/capes/mbstaff.png new file mode 100644 index 00000000..15961c7c Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/mbstaff.png differ diff --git a/src/main/resources/assets/notenoughupdates/capes/packshq.png b/src/main/resources/assets/notenoughupdates/capes/packshq.png new file mode 100644 index 00000000..860b10f5 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/capes/packshq.png differ diff --git a/src/main/resources/assets/notenoughupdates/colour_selector_bar.png b/src/main/resources/assets/notenoughupdates/colour_selector_bar.png new file mode 100644 index 00000000..f176af90 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/colour_selector_bar.png differ diff --git a/src/main/resources/assets/notenoughupdates/colour_selector_bar_alpha.png b/src/main/resources/assets/notenoughupdates/colour_selector_bar_alpha.png new file mode 100644 index 00000000..7a89510c Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/colour_selector_bar_alpha.png differ diff --git a/src/main/resources/assets/notenoughupdates/colour_selector_chroma.png b/src/main/resources/assets/notenoughupdates/colour_selector_chroma.png new file mode 100644 index 00000000..ea273959 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/colour_selector_chroma.png differ diff --git a/src/main/resources/assets/notenoughupdates/colour_selector_dot.png b/src/main/resources/assets/notenoughupdates/colour_selector_dot.png new file mode 100644 index 00000000..1150c8bb Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/colour_selector_dot.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/dynamic_54_button_ctm.png deleted file mode 100644 index bab0eab7..00000000 Binary files a/src/main/resources/assets/notenoughupdates/dynamic_54/dynamic_54_button_ctm.png and /dev/null differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54.png index 934f6b4a..a8c9eac9 100644 Binary files a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54.png and b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_button_ctm.png index 956d085a..a29a685d 100644 Binary files a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_button_ctm.png and b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_slot_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_slot_ctm.png index fa43a0ed..7eaecfc2 100644 Binary files a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_slot_ctm.png and b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_54_slot_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_config.json b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_config.json new file mode 100644 index 00000000..05dbf61a --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dynamic_54/style1/dynamic_config.json @@ -0,0 +1,3 @@ +{ + "text-colour": "FF000000" +} \ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54.png index 73711ee8..63479a74 100644 Binary files a/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54.png and b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54_button_ctm.png new file mode 100644 index 00000000..4b28ee06 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54_slot_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54_slot_ctm.png new file mode 100644 index 00000000..7eaecfc2 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_54_slot_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_config.json b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_config.json new file mode 100644 index 00000000..05dbf61a --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dynamic_54/style2/dynamic_config.json @@ -0,0 +1,3 @@ +{ + "text-colour": "FF000000" +} \ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54.png index 3a24654d..d14f0ed1 100644 Binary files a/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54.png and b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_button_ctm.png index fa43a0ed..800acade 100644 Binary files a/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_button_ctm.png and b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_slot_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_slot_ctm.png new file mode 100644 index 00000000..800acade Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_54_slot_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_config.json b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_config.json new file mode 100644 index 00000000..5ae75066 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/dynamic_54/style3/dynamic_config.json @@ -0,0 +1,3 @@ +{ + "text-colour": "FFC8C8C8" +} \ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54.png new file mode 100644 index 00000000..934f6b4a Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_button_ctm.png index ea57f0d0..956d085a 100644 Binary files a/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_button_ctm.png and b/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_slot_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_slot_ctm.png new file mode 100644 index 00000000..fa43a0ed Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style4/dynamic_54_slot_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54.png new file mode 100644 index 00000000..73711ee8 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54_button_ctm.png new file mode 100644 index 00000000..bab0eab7 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54_slot_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54_slot_ctm.png new file mode 100644 index 00000000..fa43a0ed Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style5/dynamic_54_slot_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54.png new file mode 100644 index 00000000..3a24654d Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54_button_ctm.png new file mode 100644 index 00000000..fa43a0ed Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54_slot_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54_slot_ctm.png new file mode 100644 index 00000000..fa43a0ed Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style6/dynamic_54_slot_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54.png new file mode 100644 index 00000000..934f6b4a Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54_button_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54_button_ctm.png new file mode 100644 index 00000000..ea57f0d0 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54_button_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54_slot_ctm.png b/src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54_slot_ctm.png new file mode 100644 index 00000000..fa43a0ed Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/style7/dynamic_54_slot_ctm.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/toggle_off.png b/src/main/resources/assets/notenoughupdates/dynamic_54/toggle_off.png new file mode 100644 index 00000000..7a1aa4a4 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/toggle_off.png differ diff --git a/src/main/resources/assets/notenoughupdates/dynamic_54/toggle_on.png b/src/main/resources/assets/notenoughupdates/dynamic_54/toggle_on.png new file mode 100644 index 00000000..5f4960f9 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dynamic_54/toggle_on.png differ diff --git a/src/main/resources/assets/notenoughupdates/shaders/lava_cape.frag b/src/main/resources/assets/notenoughupdates/shaders/lava_cape.frag new file mode 100644 index 00000000..9fb35990 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/lava_cape.frag @@ -0,0 +1,32 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; +uniform sampler2D textureIn; + +uniform int millis; + +void main() { + vec4 texture = texture2D(textureIn, gl_TexCoord[0].st); + + float t = gl_TexCoord[0].t; + t = clamp(t, 10.0f/1024.0f, 410.0f/1024.0f); + + float index = mod(millis/30.0f-t*1024.0f, 1024.0f); + float xIndex = mod(index, 1024.0f); + float yIndex = mod(gl_TexCoord[0].s*1024.0f+millis/500.0f, 421.0f)+421.0f; + vec3 lava = texture2D(textureIn, vec2(xIndex/1024.0f, yIndex/1024.0f)).xyz; + + float factor = (lava.r / 0.65f)*(lava.r / 0.65f); + lava.r += sin(mod(millis/2000.0f, 6.28f))*factor*0.15f+sin(mod(millis/500.0f, 6.28f))*factor*0.15f; + lava.g += sin(mod(millis/2000.0f, 6.28f))*factor*0.15f; + lava.b += sin(mod(millis/2000.0f, 6.28f))*factor*0.15f; + + gl_FragColor = vec4(texture.rgb*texture.a + lava*(1.0f-texture.a), 1.0f) * passColour; + + vec3 fakeSunNormal = normalize(vec3(0.2f,1.0f,-0.2f)); + vec3 normNormal = normalize(passNormal); + float shading = max(0.6f, dot(fakeSunNormal, normNormal)); + + gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a); +} diff --git a/src/main/resources/assets/notenoughupdates/shaders/lava_cape.vert b/src/main/resources/assets/notenoughupdates/shaders/lava_cape.vert new file mode 100644 index 00000000..2b5c48f8 --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/lava_cape.vert @@ -0,0 +1,12 @@ +#version 120 + +varying vec4 passColour; +varying vec3 passNormal; + +void main() { + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; + + passColour = gl_Color; + passNormal = normalize(gl_Normal); +} \ No newline at end of file diff --git a/src/main/resources/assets/notenoughupdates/supersecretassets/bald.png b/src/main/resources/assets/notenoughupdates/supersecretassets/bald.png new file mode 100644 index 00000000..4f730a44 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/supersecretassets/bald.png differ diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index 1ef9ee69..cedde696 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -11,6 +11,11 @@ "MixinRenderGlobal", "MixinNetHandlerPlayClient", "MixinGuiChest", - "MixinGuiContainer" + "MixinGuiContainer", + "MixinVboRenderList", + "MixinRenderList", + "MixinEntityPlayer", + "MixinTileEntitySpecialRenderer", + "MixinRenderBat" ] } \ No newline at end of file -- cgit From 7ebee833e54e95ffcd9dcfbad5744e299102acd9 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Mon, 19 Oct 2020 02:06:15 +1100 Subject: 1.4.2 --- .../moulberry/notenoughupdates/DungeonBlocks.java | 24 +- .../moulberry/notenoughupdates/DungeonMap.java | 311 +++++++++++++++++---- .../notenoughupdates/NEUEventListener.java | 2 +- .../notenoughupdates/NotEnoughUpdates.java | 4 +- .../notenoughupdates/mixins/MixinRender.java | 34 +++ .../notenoughupdates/mixins/MixinRenderBat.java | 40 --- .../mixins/MixinTileEntitySpecialRenderer.java | 13 +- .../notenoughupdates/options/Options.java | 6 + .../notenoughupdates/questing/SBInfo.java | 7 +- src/main/resources/mixins.notenoughupdates.json | 2 +- 10 files changed, 330 insertions(+), 113 deletions(-) create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderBat.java (limited to 'src/main/resources/mixins.notenoughupdates.json') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java index 29f5edc7..a97032c4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java @@ -39,13 +39,13 @@ public class DungeonBlocks implements IResourceManagerReloadListener { } public static boolean isInDungeons() { - return NotEnoughUpdates.INSTANCE.manager.config.dungeonBlocksEverywhere.value || - (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon")); + return !NotEnoughUpdates.INSTANCE.manager.config.disableDungeonBlocks.value && + (NotEnoughUpdates.INSTANCE.manager.config.dungeonBlocksEverywhere.value || + (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon"))); } public static void reset() { textureId = -1; - intbuffer = null; for(int tex : modified.values()) { GlStateManager.deleteTexture(tex); } @@ -53,6 +53,14 @@ public class DungeonBlocks implements IResourceManagerReloadListener { } public static int getModifiedTexture(ResourceLocation location, int colour) { + if(!isInDungeons()) { + return -1; + } + + if(((colour >> 24) & 0xFF) < 50) { + return -1; + } + String id = location.getResourceDomain()+":"+location.getResourcePath(); if(modified.containsKey(id)) { return modified.get(id); @@ -125,6 +133,10 @@ public class DungeonBlocks implements IResourceManagerReloadListener { } public static void tick() { + if(!isInDungeons()) { + return; + } + if(textureId == -1) { int locationBlocksId = Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture).getGlTextureId(); @@ -173,16 +185,18 @@ public class DungeonBlocks implements IResourceManagerReloadListener { GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, intbuffer); for(Map.Entry entry : spriteMap.entrySet()) { + if(((entry.getValue() >> 24) & 0xFF) < 50) continue; + TextureAtlasSprite tas = entry.getKey(); for(int x=(int)(w2*tas.getMinU()); x> 24) & 0xFF)/255f; + /*float newAlpha = ((newCol >> 24) & 0xFF)/255f; float newRed = ((newCol >> 16) & 0xFF)/255f; float newGreen = ((newCol >> 8) & 0xFF)/255f; - float newBlue = (newCol & 0xFF)/255f; + float newBlue = (newCol & 0xFF)/255f;*/ /*int oldCol = intbuffer.get(index); int oldAlpha = (oldCol >> 24) & 0xFF; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java index aac7726a..b32e3452 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java @@ -4,11 +4,16 @@ import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.block.material.MapColor; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.MapItemRenderer; import net.minecraft.client.renderer.GlStateManager; +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.item.ItemMap; import net.minecraft.item.ItemStack; 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; @@ -16,10 +21,7 @@ import org.lwjgl.opengl.GL11; import java.awt.*; import java.awt.image.BufferedImage; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.util.*; public class DungeonMap { @@ -106,6 +108,8 @@ public class DungeonMap { private class Room { Color colour = new Color(0, 0, 0, 0); + int tickColour = 0; + boolean fillCorner = false; RoomConnection left = new RoomConnection(RoomConnectionType.NONE, new Color(0, true)); RoomConnection up = new RoomConnection(RoomConnectionType.NONE, new Color(0, true)); @@ -114,6 +118,67 @@ public class DungeonMap { public void render(int roomSize, int connectorSize) { 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); + } + + if(fillCorner) { + Gui.drawRect(-connectorSize, -connectorSize, 0, 0, colour.getRGB()); + } + + for(int k=0; k<4; k++) { + RoomConnection connection = up; + if(k == 1) connection = right; + if(k == 2) connection = down; + if(k == 3) connection = left; + + if(connection.type == RoomConnectionType.NONE || connection.type == RoomConnectionType.WALL) continue; + + int xOffset = 0; + int yOffset = 0; + int width = 0; + int height = 0; + + if(connection == up) { + yOffset = -connectorSize; + width = roomSize; + height = connectorSize; + + if(connection.type == RoomConnectionType.CORRIDOR) { + width = 8; + xOffset += 4; + } + } else if(connection == right) { + xOffset = roomSize; + width = connectorSize; + height = roomSize; + + if(connection.type == RoomConnectionType.CORRIDOR) { + height = 8; + yOffset += 4; + } + } else if(connection == down) { + yOffset = roomSize; + width = roomSize; + height = connectorSize; + + if(connection.type == RoomConnectionType.CORRIDOR) { + width = 8; + xOffset += 4; + } + } else if(connection == left) { + xOffset = -connectorSize; + width = connectorSize; + height = roomSize; + + if(connection.type == RoomConnectionType.CORRIDOR) { + height = 8; + yOffset += 4; + } + } + + Gui.drawRect(xOffset, yOffset, xOffset+width, yOffset+height, connection.colour.getRGB()); + } } } @@ -124,65 +189,70 @@ public class DungeonMap { } } - public void render(RoomOffset roomOffset, int[] renderTo, int startOffsetX, int startOffsetY) { - /*for(Map.Entry entry : roomMap.entrySet()) { + private static final ResourceLocation mapIcons = new ResourceLocation("textures/map/map_icons.png"); + + public void render() { + 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); + } - }*/ - if(roomMap.containsKey(roomOffset)) { - Room room = roomMap.get(roomOffset); + int roomSize = 16; + int connSize = 4; - for(int xo=0; xo<16; xo++) { - for(int yo=0; yo<16; yo++) { - int x = (roomOffset.x-startOffsetX)*20+xo; - int y = (roomOffset.y-startOffsetY)*20+yo; + Gui.drawRect(8, 8, 8+(maxRoomX-minRoomX+1)*(roomSize+connSize), 8+(maxRoomY-minRoomY+1)*(roomSize+connSize), + new Color(200, 200, 200).getRGB()); - render(renderTo, x, y, room.colour.getRGB()); - } - } + for(Map.Entry entry : roomMap.entrySet()) { + RoomOffset roomOffset = entry.getKey(); + Room room = entry.getValue(); - for(int k=0; k<4; k++) { - RoomConnection connection; - if(k == 0) { - connection = room.up; - } else if(k == 1) { - connection = room.right; - } else if(k == 2) { - connection = room.down; - } else { - connection = room.left; - } - if(connection.type == RoomConnectionType.NONE || connection.type == RoomConnectionType.WALL) continue; - for(int o1=1; o1<=4; o1++) { - int min = 0; - int max = 16; - if(connection.type == RoomConnectionType.CORRIDOR) { - min = 6; - max = 10; - } - for (int o2 = min; o2 < max; o2++) { - int x; - int y; + int x = (roomOffset.x-minRoomX)*(roomSize+connSize); + int y = (roomOffset.y-minRoomY)*(roomSize+connSize); - if(k == 0) { - x = (roomOffset.x-startOffsetX)*20+o2; - y = (roomOffset.y-startOffsetY)*20-o1; - } else if(k == 1) { - x = (roomOffset.x-startOffsetX)*20+15+o1; - y = (roomOffset.y-startOffsetY)*20+o2; - } else if(k == 2) { - x = (roomOffset.x-startOffsetX)*20+o2; - y = (roomOffset.y-startOffsetY)*20+15+o1; - } else { - x = (roomOffset.x-startOffsetX)*20-o1; - y = (roomOffset.y-startOffsetY)*20+o2; - } - - render(renderTo, x, y, connection.colour.getRGB()); - } - } - } + GlStateManager.pushMatrix(); + GlStateManager.translate(x+10, y+10, 0); + room.render(roomSize, connSize); + GlStateManager.translate(-(x+10), -(y+10), 0); + GlStateManager.popMatrix(); } + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + 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; + + x -= minRoomX*(roomSize+connSize); + y -= minRoomY*(roomSize+connSize); + + //System.out.println(decoration.angle); + + GlStateManager.pushMatrix(); + GlStateManager.translate(x+10, y+10, -0.02F); + GlStateManager.rotate(decoration.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(); + tessellator.draw(); + GlStateManager.popMatrix(); + k--; + } } private HashMap roomMap = new HashMap<>(); @@ -196,8 +266,38 @@ public class DungeonMap { if(roomMap.containsKey(roomOffset)) { Room room = roomMap.get(roomOffset); + int otherPixelFilled = 0; + int otherPixelColour = 0; + for(int xOff=0; xOff 0.05) { + room.tickColour = otherPixelColour; + } + for(int k=0; k<4; k++) { int totalFilled = 0; + for(int i=0; i 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; + + 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; + this.connOffsetX = connOffsetX; + this.roomInPercentY = roomInPercentY; + this.connInPercentY = connInPercentY; + this.roomsOffsetY = roomsOffsetY; + this.connOffsetY = connOffsetY; + this.minU = minU; + this.minV = minV; + this.angle = angle; + } + } + @SubscribeEvent public void onRenderOverlay(RenderGameOverlayEvent event) { //System.out.println("render overlayw"); @@ -306,6 +448,8 @@ public class DungeonMap { colourMap[x][y] = c; } + + //mapData. } for(int x=0; x 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; + } + + float angle = (float)(vec4b.func_176111_d() * 360) / 16.0F; + + //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)); + } + + } + + //System.out.println("room x: " + startRoomX + "room y: " + startRoomY + " size: " + roomSize + " connector: " + connectorSize); //rendering @@ -397,9 +592,11 @@ public class DungeonMap { } for(RoomOffset offset : roomMap.keySet()) { - render(offset, mapTextureData, minRoomX, minRoomY); + //render(offset, mapTextureData, minRoomX, minRoomY); } + render(); + //process dynamicTexture.updateDynamicTexture(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index a2ce0055..ed5be01a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -135,7 +135,7 @@ public class NEUEventListener { longUpdate = true; lastLongUpdate = currentTime; } - if(currentTime - lastVeryLongUpdate > 10000) { + if(longUpdate && currentTime - lastVeryLongUpdate > 10000) { veryLongUpdate = true; lastVeryLongUpdate = currentTime; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 575562a0..77855b3e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -685,7 +685,7 @@ public class NotEnoughUpdates { public Color[][] colourMap = null; SimpleCommand neumapCommand = new SimpleCommand("neumap", new SimpleCommand.ProcessCommandRunnable() { public void processCommand(ICommandSender sender, String[] args) { - if(args.length == 1 && args[0] == "reset") { + if(args.length == 1 && args[0].equals("reset")) { colourMap = null; return; } @@ -788,7 +788,7 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(new SBGamemodes()); MinecraftForge.EVENT_BUS.register(SBInfo.getInstance()); MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); - MinecraftForge.EVENT_BUS.register(new DungeonMap()); + //MinecraftForge.EVENT_BUS.register(new DungeonMap()); //MinecraftForge.EVENT_BUS.register(new BetterPortals()); IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java new file mode 100644 index 00000000..dcdb4bf4 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRender.java @@ -0,0 +1,34 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.DungeonBlocks; +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.util.ResourceLocation; +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(Render.class) +public class MixinRender { + + @Inject(method="bindEntityTexture", at=@At("HEAD"), cancellable = true) + public void bindEntityTexture(Entity entity, CallbackInfoReturnable cir) { + if(entity instanceof EntityBat && DungeonBlocks.isInDungeons()) { + int tex = DungeonBlocks.getModifiedTexture(new ResourceLocation("textures/entity/bat.png"), + SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungBatColour.value)); + + if(tex >= 0) { + GlStateManager.bindTexture(tex); + cir.setReturnValue(true); + } + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderBat.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderBat.java deleted file mode 100644 index 93182439..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderBat.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.github.moulberry.notenoughupdates.mixins; - -import io.github.moulberry.notenoughupdates.DungeonBlocks; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.util.SpecialColour; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderBat; -import net.minecraft.client.renderer.texture.AbstractTexture; -import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.entity.passive.EntityBat; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; -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; - -import java.io.IOException; - -@Mixin({RenderBat.class}) -public abstract class MixinRenderBat { - - @Inject(method="getEntityTexture", at=@At("HEAD"), cancellable = true) - public void getEntityTexture(EntityBat entity, CallbackInfoReturnable cir) { - if(DungeonBlocks.isInDungeons()) { - ResourceLocation rl = new ResourceLocation("notenoughupdates:dynamic/dungeon_bat"); - Minecraft.getMinecraft().getTextureManager().loadTexture(rl, new AbstractTexture() { - public void loadTexture(IResourceManager resourceManager) { - glTextureId = DungeonBlocks.getModifiedTexture(new ResourceLocation("textures/entity/bat.png"), - SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungBatColour.value)); - } - }); - cir.setReturnValue(rl); - } - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java index 16e4bfbe..b8a77051 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinTileEntitySpecialRenderer.java @@ -22,12 +22,15 @@ public abstract class MixinTileEntitySpecialRenderer { @Inject(method="bindTexture", at=@At("HEAD"), cancellable = true) public void bindTexture(ResourceLocation location, CallbackInfo info) { if(DungeonBlocks.isInDungeons() && location.getResourcePath().equals("textures/entity/chest/normal.png")) { - info.cancel(); + int tex = DungeonBlocks.getModifiedTexture(location, + SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungChestColour.value)); - GlStateManager.bindTexture(DungeonBlocks.getModifiedTexture(location, - SpecialColour.specialToSimpleRGB(NotEnoughUpdates.INSTANCE.manager.config.dungChestColour.value))); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + if(tex >= 0) { + info.cancel(); + GlStateManager.bindTexture(tex); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + } } } } 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 c8a596b1..55f81f53 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java @@ -166,6 +166,11 @@ public class Options { "Show Dungeon Block Overlay Everywhere", false, "If true, will show the overlay for cracked bricks, etc. even when not in dungeons."); + public Option disableDungeonBlocks = new Option( + false, + "Disables the dungeon blocks feature", + false, + "If true, the dungeon block overlay will be disabled."); public Option paneWidthMult = new Option( 1.0, "Pane Width", @@ -435,6 +440,7 @@ public class Options { tryAddOption(invBazaarPrice, options); tryAddOption(invAuctionPrice, options); tryAddOption(dungeonBlocksEverywhere, options); + tryAddOption(disableDungeonBlocks, options); //Sliders tryAddOption(smoothAoteMillis, options); tryAddOption(bgBlurFactor, options); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java index b647fb1c..2d594ccf 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/questing/SBInfo.java @@ -53,10 +53,13 @@ public class SBInfo { if(event.message.getUnformattedText().startsWith("{")) { try { JsonObject obj = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(event.message.getUnformattedText(), JsonObject.class); - if(obj.has("server") && obj.has("gametype") && obj.has("mode") && obj.has("map")) { - locraw = obj; + if(obj.has("server")) { event.setCanceled(true); + if(obj.has("gametype") && obj.has("mode") && obj.has("map")) { + locraw = obj; + } } + } catch(Exception e) { e.printStackTrace(); } diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index cedde696..65957a53 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -16,6 +16,6 @@ "MixinRenderList", "MixinEntityPlayer", "MixinTileEntitySpecialRenderer", - "MixinRenderBat" + "MixinRender" ] } \ No newline at end of file -- cgit From 36af336e49662390c0f553da6f7f5ec424e5d37b Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sun, 1 Nov 2020 04:28:36 +1100 Subject: 1.5 --- build.gradle | 2 +- .../notenoughupdates/AccessoryBagOverlay.java | 11 ++ .../moulberry/notenoughupdates/DumymMod.java | 53 ------- .../moulberry/notenoughupdates/DungeonBlocks.java | 2 +- .../moulberry/notenoughupdates/DungeonMap.java | 42 ++++-- .../moulberry/notenoughupdates/GuiButtonItem.java | 93 ------------ .../notenoughupdates/GuiDungeonMapEditor.java | 159 ++++++++++++++++----- .../notenoughupdates/NEUEventListener.java | 24 ++-- .../moulberry/notenoughupdates/NEUOverlay.java | 47 +++--- .../notenoughupdates/NotEnoughUpdates.java | 3 +- .../notenoughupdates/auction/APIManager.java | 90 ++++++------ .../notenoughupdates/auction/CustomAH.java | 57 +++++--- .../notenoughupdates/mixins/MixinGuiContainer.java | 2 + .../notenoughupdates/mixins/MixinRenderFish.java | 134 +++++++++++++++++ .../notenoughupdates/options/Options.java | 101 ++++++++----- .../profileviewer/GuiProfileViewer.java | 7 + .../assets/notenoughupdates/dungeon_map/cross.png | Bin 0 -> 250 bytes src/main/resources/mixins.notenoughupdates.json | 3 +- 18 files changed, 508 insertions(+), 322 deletions(-) delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/DumymMod.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/GuiButtonItem.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java create mode 100644 src/main/resources/assets/notenoughupdates/dungeon_map/cross.png (limited to 'src/main/resources/mixins.notenoughupdates.json') diff --git a/build.gradle b/build.gradle index 45038326..cc403b6d 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ apply plugin: 'com.github.johnrengelman.shadow' sourceCompatibility = 1.8 targetCompatibility = 1.8 -version = "1.4-REL" +version = "1.5-REL" group= "io.github.moulberry" archivesBaseName = "NotEnoughUpdates" String modid = "notenoughupdates" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java index d8d84144..5ca25082 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/AccessoryBagOverlay.java @@ -64,6 +64,17 @@ public class AccessoryBagOverlay { private static int currentTab = TAB_BASIC; public static boolean mouseClick() { + if(Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + String containerName = cc.getLowerChestInventory().getDisplayName().getUnformattedText(); + if(!containerName.trim().startsWith("Accessory Bag")) { + return false; + } + } else { + return false; + } + if(!Mouse.getEventButtonState()) return false; try { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DumymMod.java b/src/main/java/io/github/moulberry/notenoughupdates/DumymMod.java deleted file mode 100644 index 07205519..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/DumymMod.java +++ /dev/null @@ -1,53 +0,0 @@ -package io.github.moulberry.notenoughupdates; - -import java.util.Arrays; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiChest; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.ModMetadata; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class DumymMod { - - @SubscribeEvent - public void onInitGui(GuiScreenEvent.InitGuiEvent.Post event) { - int width = event.gui.width / 2; - int height = event.gui.height / 2 - 106; - - if (event.gui instanceof GuiChest) - { - event.buttonList.add(new GuiButtonItem(1001, width + 88, height + 47, new ItemStack(Blocks.crafting_table))); - event.buttonList.add(new GuiButtonItem(1000, width + 88, height + 66, new ItemStack(Blocks.ender_chest))); - } - } - - private long lastButtonClick = -1; - - @SubscribeEvent - public void onPostActionPerformedGui(GuiScreenEvent.ActionPerformedEvent.Post event) { - long now = System.currentTimeMillis(); - - if (event.gui instanceof GuiChest) - { - if (now - this.lastButtonClick > 100L) - { - if (event.button.id == 1000) - { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/enderchest"); - } - else if (event.button.id == 1001) - { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/craft"); - } - this.lastButtonClick = now; - } - } - } -} \ No newline at end of file diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java index cdf7b59b..f0b92c6a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonBlocks.java @@ -39,7 +39,7 @@ public class DungeonBlocks implements IResourceManagerReloadListener { } public static boolean isInDungeons() { - return false && !NotEnoughUpdates.INSTANCE.manager.config.disableDungeonBlocks.value && + return !NotEnoughUpdates.INSTANCE.manager.config.disableDungeonBlocks.value && (NotEnoughUpdates.INSTANCE.manager.config.dungeonBlocksEverywhere.value || (SBInfo.getInstance().getLocation() != null && SBInfo.getInstance().getLocation().equals("dungeon"))); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java index daff1a24..79b9e106 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/DungeonMap.java @@ -53,6 +53,7 @@ public class DungeonMap { 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 static final ResourceLocation CROSS = new ResourceLocation("notenoughupdates:dungeon_map/cross.png"); 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"); @@ -187,6 +188,8 @@ public class DungeonMap { indicatorTex = GREEN_CHECK; } else if(tick.getRed() == 13 && tick.getGreen() == 13 && tick.getBlue() == 13) { indicatorTex = QUESTION; + } else if(tick.getRed() == 255 && tick.getGreen() == 0 && tick.getBlue() == 0) { + indicatorTex = CROSS; } if(indicatorTex != null) { Minecraft.getMinecraft().getTextureManager().bindTexture(indicatorTex); @@ -353,12 +356,14 @@ public class DungeonMap { public int getRenderRoomSize() { int roomSizeOption = NotEnoughUpdates.INSTANCE.manager.config.dmRoomSize.value.intValue(); - return roomSizeOption == 0 ? 12 : roomSizeOption == 2 ? 20 : 16; + if(roomSizeOption <= 0) return 12; + return 12 + roomSizeOption*4; } public int getRenderConnSize() { int roomSizeOption = NotEnoughUpdates.INSTANCE.manager.config.dmRoomSize.value.intValue(); - return roomSizeOption == 0 ? 3 : roomSizeOption == 2 ? 5 : 4; + if(roomSizeOption <= 0) return 3; + return 3 + roomSizeOption; } private HashMap borderRadiusCache = new HashMap<>(); @@ -429,8 +434,8 @@ public class DungeonMap { rotation = (int)playerPos.rotation; } - int mapSizeX = borderSizeOption == 0 ? 90 : borderSizeOption == 2 ? 160 : 120; - int mapSizeY = borderSizeOption == 0 ? 90 : borderSizeOption == 2 ? 160 : 120; + int mapSizeX = borderSizeOption == 0 ? 90 : borderSizeOption == 2 ? 160 : borderSizeOption == 3 ? 240 : 120; + int mapSizeY = borderSizeOption == 0 ? 90 : borderSizeOption == 2 ? 160 : borderSizeOption == 3 ? 240 : 120; int roomsSizeX = (maxRoomX-minRoomX)*(renderRoomSize+renderConnSize)+renderRoomSize; int roomsSizeY = (maxRoomY-minRoomY)*(renderRoomSize+renderConnSize)+renderRoomSize; int mapCenterX = mapSizeX/2; @@ -588,7 +593,7 @@ public class DungeonMap { float deltaX = entityPos.getRenderX() - pos.getRenderX(); float deltaY = entityPos.getRenderY() - pos.getRenderY(); - /*if(deltaX > (renderRoomSize + renderConnSize)/2) { + if(deltaX > (renderRoomSize + renderConnSize)/2) { deltaX -= (renderRoomSize + renderConnSize); } else if(deltaX < -(renderRoomSize + renderConnSize)/2) { deltaX += (renderRoomSize + renderConnSize); @@ -597,7 +602,7 @@ public class DungeonMap { deltaY -= (renderRoomSize + renderConnSize); } else if(deltaY < -(renderRoomSize + renderConnSize)/2) { deltaY += (renderRoomSize + renderConnSize); - }*/ + } x += deltaX; y += deltaY; @@ -636,13 +641,18 @@ public class DungeonMap { } } + boolean headLayer = false; int pixelWidth = 8; int pixelHeight = 8; + if(renderRoomSize >= 24) { + pixelWidth = pixelHeight = 12; + } GlStateManager.color(1, 1, 1, 1); if(NotEnoughUpdates.INSTANCE.manager.config.dmPlayerHeads.value >= 1 && playerSkinMap.containsKey(entry.getKey())) { Minecraft.getMinecraft().getTextureManager().bindTexture(playerSkinMap.get(entry.getKey())); + headLayer = true; if(NotEnoughUpdates.INSTANCE.manager.config.dmPlayerHeads.value >= 3) { minU = 9/64f; minV = 9/64f; @@ -656,8 +666,8 @@ public class DungeonMap { } if(NotEnoughUpdates.INSTANCE.manager.config.dmPlayerHeads.value >= 2) { - pixelWidth = 6; - pixelHeight = 6; + pixelWidth = pixelWidth*6/8; + pixelHeight = pixelHeight*6/8; } } else { Minecraft.getMinecraft().getTextureManager().bindTexture(mapIcons); @@ -682,6 +692,14 @@ public class DungeonMap { worldrenderer.pos(-pixelWidth/2f, -pixelHeight/2f, 30+((float)k * -0.005F)).tex(minU, maxV).endVertex(); tessellator.draw(); + if(headLayer) { + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos(-pixelWidth/2f, pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(minU+0.5f, minV).endVertex(); + worldrenderer.pos(pixelWidth/2f, pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(maxU+0.5f, minV).endVertex(); + worldrenderer.pos(pixelWidth/2f, -pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(maxU+0.5f, maxV).endVertex(); + worldrenderer.pos(-pixelWidth/2f, -pixelHeight/2f, 30+((float)k * -0.005F)+0.001f).tex(minU+0.5f, maxV).endVertex(); + tessellator.draw(); + } GlStateManager.popMatrix(); k--; } @@ -775,7 +793,7 @@ public class DungeonMap { Minecraft.getMinecraft().getTextureManager().bindTexture(rl); GlStateManager.color(1, 1, 1, 1); - int size = borderSizeOption == 0 ? 165 : borderSizeOption == 2 ? 300 : 220; + int size = borderSizeOption == 0 ? 165 : borderSizeOption == 2 ? 300 : borderSizeOption == 3 ? 440 : 220; Utils.drawTexturedRect(-size/2, -size/2, size, size, GL11.GL_NEAREST); } @@ -1308,6 +1326,12 @@ public class DungeonMap { if(SBInfo.getInstance().getLocation() == null || !SBInfo.getInstance().getLocation().equals("dungeon")) { return; } + if(Minecraft.getMinecraft().gameSettings.showDebugInfo || + (Minecraft.getMinecraft().gameSettings.keyBindPlayerList.isKeyDown() && + (!Minecraft.getMinecraft().isIntegratedServerRunning() || + Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap().size() > 1))) { + return; + } ItemStack stack = Minecraft.getMinecraft().thePlayer.inventory.mainInventory[8]; boolean holdingBow = stack != null && stack.getItem() == Items.arrow; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiButtonItem.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiButtonItem.java deleted file mode 100644 index a08b27bc..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiButtonItem.java +++ /dev/null @@ -1,93 +0,0 @@ -package io.github.moulberry.notenoughupdates; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; - -public class GuiButtonItem extends GuiButton -{ - private static final ResourceLocation TEXTURE = new ResourceLocation("dummy:textures/gui/blank.png"); - private ItemStack itemStack; - private String customName; - - public GuiButtonItem(int buttonID, int xPos, int yPos, ItemStack itemStack) - { - this(buttonID, xPos, yPos, xPos, itemStack, itemStack.getDisplayName()); - } - - public GuiButtonItem(int buttonID, int xPos, int yPos, int potionX, ItemStack itemStack) - { - this(buttonID, xPos, yPos, potionX, itemStack, itemStack.getDisplayName()); - } - - public GuiButtonItem(int buttonID, int xPos, int yPos, ItemStack itemStack, String customName) - { - this(buttonID, xPos, yPos, xPos, itemStack, customName); - } - - public GuiButtonItem(int buttonID, int xPos, int yPos, int potionX, ItemStack itemStack, String customName) - { - super(buttonID, xPos, yPos, 18, 18, ""); - this.itemStack = itemStack; - this.customName = customName; - } - - @Override - public void drawButton(Minecraft mc, int mouseX, int mouseY) - { - boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; - - if (this.visible) - { - if (this.itemStack.getItem() == Items.nether_star) - { - ItemStack skyBlockMenu = this.itemStack.copy(); - NBTTagList list = new NBTTagList(); - skyBlockMenu.setStackDisplayName("SkyBlock Menu"); - list.appendTag(new NBTTagString(EnumChatFormatting.GRAY + "View all of your SkyBlock")); - skyBlockMenu.getTagCompound().getCompoundTag("display").setTag("Lore", list); - this.itemStack = skyBlockMenu; - } - - mc.getTextureManager().bindTexture(TEXTURE); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - Gui.drawModalRectWithCustomSizedTexture(this.xPosition, this.yPosition, flag ? 18 : 0, 0, this.width, this.height, 36, 18); - - GlStateManager.enableDepth(); - GlStateManager.enableRescaleNormal(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - RenderHelper.enableGUIStandardItemLighting(); - GlStateManager.enableLighting(); - mc.getRenderItem().renderItemAndEffectIntoGUI(this.itemStack, this.xPosition + 1, this.yPosition + 1); - } - } - - public String getName() - { - return this.customName; - } - - public ItemStack getItemStack() - { - return this.itemStack; - } - - public void setName(String name) - { - this.customName = name; - } - - public void setItemStack(ItemStack itemStack) - { - this.itemStack = itemStack; - } -} \ No newline at end of file diff --git a/src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java index 5bc4b6ee..6058dc51 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/GuiDungeonMapEditor.java @@ -78,12 +78,31 @@ public class GuiDungeonMapEditor extends GuiScreen { private int y; private String text; private Color colour = new Color(-1, true); + private Options.Option option; public Button(int id, int x, int y, String text) { + this(id, x, y, text, null); + } + + public Button(int id, int x, int y, String text, Options.Option option) { this.id = id; this.x = x; this.y = y; this.text = text; + this.option = option; + } + + public List getTooltip() { + if(option == null) { + return null; + } + + List tooltip = new ArrayList<>(); + tooltip.add(EnumChatFormatting.YELLOW+option.displayName); + for(String line : option.desc.split("\n")) { + tooltip.add(EnumChatFormatting.AQUA+line); + } + return tooltip; } public void render() { @@ -107,54 +126,58 @@ public class GuiDungeonMapEditor extends GuiScreen { } public GuiDungeonMapEditor() { + Options options = NotEnoughUpdates.INSTANCE.manager.config; //Map Border Size - buttons.add(new Button(0, 6, 37, "Small")); - buttons.add(new Button(1, 52, 37, "Medium")); - buttons.add(new Button(2, 98, 37, "Large")); + buttons.add(new Button(0, 6, 37, "Small", options.dmBorderSize)); + buttons.add(new Button(1, 52, 37, "Medium", options.dmBorderSize)); + buttons.add(new Button(2, 98, 37, "Large", options.dmBorderSize)); //Map Rooms Size - buttons.add(new Button(3, 6, 67, "Small")); - buttons.add(new Button(4, 52, 67, "Medium")); - buttons.add(new Button(5, 98, 67, "Large")); + buttons.add(new Button(3, 6, 67+19, "Small", options.dmRoomSize)); + buttons.add(new Button(4, 52, 67+19, "Medium", options.dmRoomSize)); + buttons.add(new Button(5, 98, 67+19, "Large", options.dmRoomSize)); //Map Border Styles - buttons.add(new Button(6, 6, 97, "Default")); - buttons.add(new Button(7, 52, 97, "Custom")); - buttons.add(new Button(8, 98, 97, "Stone")); - buttons.add(new Button(9, 6, 116, "Wood")); - buttons.add(new Button(10, 52, 116, "Rustic(S)")); - buttons.add(new Button(11, 98, 116, "Rustic(C)")); - buttons.add(new Button(12, 6, 135, "Fade")); - buttons.add(new Button(13, 52, 135, "Ribbons")); - buttons.add(new Button(14, 98, 135, "Paper")); - buttons.add(new Button(15, 6, 154, "Crimson")); - buttons.add(new Button(16, 52, 154, "Ornate")); - buttons.add(new Button(17, 98, 154, "Dragon")); + buttons.add(new Button(6, 6, 97+38, "None")); + buttons.add(new Button(7, 52, 97+38, "Custom")); + buttons.add(new Button(8, 98, 97+38, "Stone")); + buttons.add(new Button(9, 6, 116+38, "Wood")); + buttons.add(new Button(10, 52, 116+38, "Rustic(S)")); + buttons.add(new Button(11, 98, 116+38, "Rustic(C)")); + buttons.add(new Button(12, 6, 135+38, "Fade")); + buttons.add(new Button(13, 52, 135+38, "Ribbons")); + buttons.add(new Button(14, 98, 135+38, "Paper")); + buttons.add(new Button(15, 6, 154+38, "Crimson")); + buttons.add(new Button(16, 52, 154+38, "Ornate")); + buttons.add(new Button(17, 98, 154+38, "Dragon")); //Dungeon Map - buttons.add(new Button(18, 20+139, 36, "Yes/No")); + buttons.add(new Button(18, 20+139, 36, "Yes/No", options.dmEnable)); //Center - buttons.add(new Button(19, 84+139, 36, "Player/Map")); + buttons.add(new Button(19, 84+139, 36, "Player/Map", options.dmCenterPlayer)); //Rotate - buttons.add(new Button(20, 20+139, 65, "Player/No Rotate")); + buttons.add(new Button(20, 20+139, 65, "Player/No Rotate", options.dmRotatePlayer)); //Icon Style - buttons.add(new Button(21, 84+139, 65, "Default/Heads")); + buttons.add(new Button(21, 84+139, 65, "Default/Heads", options.dmPlayerHeads)); //Check Orient - buttons.add(new Button(22, 20+139, 94, "Normal/Reorient")); + buttons.add(new Button(22, 20+139, 94, "Normal/Reorient", options.dmOrientCheck)); //Check Center - buttons.add(new Button(23, 84+139, 94, "Yes/No")); + buttons.add(new Button(23, 84+139, 94, "Yes/No", options.dmCenterCheck)); //Interpolation - buttons.add(new Button(24, 20+139, 123, "Yes/No")); + buttons.add(new Button(24, 20+139, 123, "Yes/No", options.dmPlayerInterp)); //Compatibility - buttons.add(new Button(25, 84+139, 123, "Normal/No SHD/No FB/SHD")); + buttons.add(new Button(25, 84+139, 123, "Normal/No SHD/No FB/SHD", options.dmCompat)); //Background - buttons.add(new Button(26, 20+139, 152, "")); + buttons.add(new Button(26, 20+139, 152, "", options.dmBackgroundColour)); //Border - buttons.add(new Button(27, 84+139, 152, "")); + buttons.add(new Button(27, 84+139, 152, "", options.dmBorderColour)); - //Compatibility - buttons.add(new Button(28, 84+139, 181, "Normal/Scroll")); + //Chroma Mode + buttons.add(new Button(28, 84+139, 181, "Normal/Scroll", options.dmChromaBorder)); + + buttons.add(new Button(29, 52, 86+19, "XLarge", options.dmRoomSize)); + buttons.add(new Button(30, 52, 56, "XLarge", options.dmBorderSize)); xField.setText(String.valueOf(NotEnoughUpdates.INSTANCE.manager.config.dmCenterX.value)); yField.setText(String.valueOf(NotEnoughUpdates.INSTANCE.manager.config.dmCenterY.value)); @@ -172,6 +195,58 @@ public class GuiDungeonMapEditor extends GuiScreen { this.width = scaledResolution.getScaledWidth(); this.height = scaledResolution.getScaledHeight(); + mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth; + mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + + List tooltipToDisplay = null; + for(Button button : buttons) { + if(mouseX >= guiLeft+button.x && mouseX <= guiLeft+button.x+48 && + mouseY >= guiTop+button.y-13 && mouseY <= guiTop+button.y+16) { + if(button.id >= 6 && button.id <= 17) { + String mapDesc = null; + String mapCredit = null; + int id = button.id; + switch(id) { + case 6: + mapDesc = "No Border"; break; + case 7: + mapDesc = "Used by custom Resource Packs"; break; + case 8: + mapDesc = "Simple gray border"; mapCredit = "TomEngMaster"; break; + case 9: + mapDesc = "Viney wood border"; mapCredit = "iDevil4Hell"; break; + case 10: + mapDesc = "Steampunk-inspired square border"; mapCredit = "ThatGravyBoat"; break; + case 11: + mapDesc = "Steampunk-inspired circular border"; mapCredit = "ThatGravyBoat"; break; + case 12: + mapDesc = "Light fade border"; mapCredit = "Qwiken"; break; + case 13: + mapDesc = "Simple gray border with red ribbons"; mapCredit = "Sai"; break; + case 14: + mapDesc = "Paper border"; mapCredit = "KingJames02st"; break; + case 15: + mapDesc = "Nether-inspired border"; break; + case 16: + mapDesc = "Golden ornate border"; mapCredit = "iDevil4Hell"; break; + case 17: + mapDesc = "Stone dragon border"; mapCredit = "ImperiaL"; break; + } + + ArrayList tooltip = new ArrayList<>(); + tooltip.add(EnumChatFormatting.YELLOW+"Border Style"); + tooltip.add(EnumChatFormatting.AQUA+"Customize the look of the dungeon border"); + tooltip.add(""); + if(mapDesc != null) tooltip.add(EnumChatFormatting.YELLOW+"Set to: "+EnumChatFormatting.AQUA+mapDesc); + if(mapCredit != null) tooltip.add(EnumChatFormatting.YELLOW+"Artist: "+EnumChatFormatting.GOLD+mapCredit); + tooltipToDisplay = tooltip; + } else { + tooltipToDisplay = button.getTooltip(); + } + break; + } + } + this.sizeX = 431; this.sizeY = 237; this.guiLeft = (this.width - this.sizeX) / 2; @@ -192,9 +267,9 @@ public class GuiDungeonMapEditor extends GuiScreen { Utils.drawStringCenteredScaledMaxWidth("Map Border Size", Minecraft.getMinecraft().fontRendererObj, guiLeft+76, guiTop+30, false, 137, 0xFFB4B4B4); Utils.drawStringCenteredScaledMaxWidth("Map Rooms Size", Minecraft.getMinecraft().fontRendererObj, - guiLeft+76, guiTop+60, false, 137, 0xFFB4B4B4); + guiLeft+76, guiTop+60+19, false, 137, 0xFFB4B4B4); Utils.drawStringCenteredScaledMaxWidth("Map Border Style", Minecraft.getMinecraft().fontRendererObj, - guiLeft+76, guiTop+90, false, 137, 0xFFB4B4B4); + guiLeft+76, guiTop+90+38, false, 137, 0xFFB4B4B4); Utils.drawStringCenteredScaledMaxWidth("Dungeon Map", Minecraft.getMinecraft().fontRendererObj, guiLeft+44+139, guiTop+30, false, 60, 0xFFB4B4B4); @@ -234,11 +309,11 @@ public class GuiDungeonMapEditor extends GuiScreen { Options options = NotEnoughUpdates.INSTANCE.manager.config; buttons.get(18).text = options.dmEnable.value ? "Enabled" : "Disabled"; buttons.get(19).text = options.dmCenterPlayer.value ? "Player" : "Map"; - buttons.get(20).text = options.dmRotatePlayer.value ? "Player" : "No Rotate"; + buttons.get(20).text = options.dmRotatePlayer.value ? "Player" : "Vertical"; buttons.get(21).text = options.dmPlayerHeads.value <= 0 ? "Default" : options.dmPlayerHeads.value >= 3 ? "SmallHeads" : options.dmPlayerHeads.value == 1 ? "Heads" : "ScaledHeads"; - buttons.get(22).text = options.dmOrientCheck.value ? "Orient" : "Default"; - buttons.get(23).text = options.dmCenterCheck.value ? "Center" : "Default"; + buttons.get(22).text = options.dmOrientCheck.value ? "Orient" : "Off"; + buttons.get(23).text = options.dmCenterCheck.value ? "Center" : "Off"; buttons.get(24).text = options.dmPlayerInterp.value ? "Interp" : "No Interp"; buttons.get(25).text = options.dmCompat.value <= 0 ? "Normal" : options.dmCompat.value >= 2 ? "No FB/SHD" : "No SHD"; @@ -269,6 +344,11 @@ public class GuiDungeonMapEditor extends GuiScreen { button.render(); } + //List textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font + if(tooltipToDisplay != null) { + Utils.drawHoveringText(tooltipToDisplay, mouseX, mouseY, width, height, 200, Minecraft.getMinecraft().fontRendererObj); + } + if(activeColourEditor != null) { Gui.drawRect(activeColourEditor.x, activeColourEditor.y, activeColourEditor.x+119, activeColourEditor.y+89, colourEditorBG); @@ -596,12 +676,16 @@ public class GuiDungeonMapEditor extends GuiScreen { options.dmBorderSize.value = 1.0; break; case 2: options.dmBorderSize.value = 2.0; break; + case 30: + options.dmBorderSize.value = 3.0; break; case 3: options.dmRoomSize.value = 0.0; break; case 4: options.dmRoomSize.value = 1.0; break; case 5: options.dmRoomSize.value = 2.0; break; + case 29: + options.dmRoomSize.value = 3.0; break; case 18: options.dmEnable.value = !options.dmEnable.value; break; case 19: @@ -638,12 +722,17 @@ public class GuiDungeonMapEditor extends GuiScreen { private boolean isButtonPressed(int id) { Options options = NotEnoughUpdates.INSTANCE.manager.config; + if(id >= 0 && id <= 2) { return options.dmBorderSize.value == id; } else if(id >= 3 && id <= 5) { return options.dmRoomSize.value == id-3; } else if(id >= 6 && id <= 17) { return options.dmBorderStyle.value == id-6; + } else if(id == 29) { + return options.dmRoomSize.value == 3; + } else if(id == 30) { + return options.dmBorderSize.value == 3; } return false; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 29a25d56..3c9f0190 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -621,7 +621,7 @@ public class NEUEventListener { } private void renderDungeonChestOverlay(GuiScreen gui) { - if(gui instanceof GuiChest && neu.manager.auctionManager.activeAuctions > 0 && !neu.manager.config.dungeonProfitLore.value) { + if(gui instanceof GuiChest && !neu.manager.config.dungeonProfitLore.value) { try { int xSize = (int) Utils.getField(GuiContainer.class, gui, "xSize", "field_146999_f"); int ySize = (int) Utils.getField(GuiContainer.class, gui, "ySize", "field_147000_g"); @@ -790,9 +790,7 @@ public class NEUEventListener { return; } if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { - if(neu.manager.config.accessoryBagOverlay.value && AccessoryBagOverlay.mouseClick()) { - event.setCanceled(true); - } else { + if(!neu.manager.config.accessoryBagOverlay.value || !AccessoryBagOverlay.mouseClick()) { if(!(hoverInv && focusInv)) { if(neu.overlay.mouseInput()) { event.setCanceled(true); @@ -1340,21 +1338,21 @@ public class NEUEventListener { JsonObject auctionInfo = neu.manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = neu.manager.auctionManager.getBazaarInfo(internalname); + int lowestBin = neu.manager.auctionManager.getLowestBin(internalname); + APIManager.CraftInfo craftCost = neu.manager.auctionManager.getCraftCost(internalname); + boolean hasAuctionPrice = neu.manager.config.invAuctionPrice.value && auctionInfo != null; boolean hasBazaarPrice = neu.manager.config.invBazaarPrice.value && bazaarInfo != null; - - int lowestBin = neu.manager.auctionManager.getLowestBin(internalname); + boolean hasLowestBinPrice = neu.manager.config.invAuctionPrice.value && lowestBin > 0; NumberFormat format = NumberFormat.getInstance(Locale.US); - APIManager.CraftInfo craftCost = neu.manager.auctionManager.getCraftCost(internalname); - - if(hasAuctionPrice || hasBazaarPrice || craftCost.fromRecipe) event.toolTip.add(""); + if(hasAuctionPrice || hasBazaarPrice || hasLowestBinPrice) event.toolTip.add(""); + if(hasLowestBinPrice) { + event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Lowest BIN: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBin)+" coins"); + } if(hasAuctionPrice) { - if(lowestBin > 0) { - event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Lowest BIN: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBin)+" coins"); - } int auctionPrice = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); event.toolTip.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Price: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(auctionPrice)+" coins"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index f0d46f7f..b2742bf9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -864,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)); } @@ -914,16 +914,29 @@ public class NEUOverlay extends Gui { 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) { - if (mouseX >= x - 1 && mouseX <= x + ITEM_SIZE + 1) { - if (mouseY >= y - 1 && mouseY <= y + ITEM_SIZE + 1) { - JsonObject json = getSearchedItemPage(id); - if (json != null) internalname.set(json.get("internalname").getAsString()); + if (selectedItemGroup != null) { + int selectedX = Math.min(selectedItemGroupX, width - getBoxPadding() - 18 * selectedItemGroup.size()); + + if (mouseY > selectedItemGroupY + 17 && mouseY < selectedItemGroupY + 35) { + for (int i = 0; i < selectedItemGroup.size(); i++) { + if (mouseX >= selectedX - 1 + 18 * i && mouseX <= selectedX + 17 + 18 * i) { + internalname.set(selectedItemGroup.get(i).get("internalname").getAsString()); } } } - }); + } else { + iterateItemSlots(new ItemSlotConsumer() { + public void consume(int x, int y, int id) { + if (mouseX >= x - 1 && mouseX <= x + ITEM_SIZE + 1) { + if (mouseY >= y - 1 && mouseY <= y + ITEM_SIZE + 1) { + JsonObject json = getSearchedItemPage(id); + if (json != null) internalname.set(json.get("internalname").getAsString()); + } + } + } + }); + } + Utils.pushGuiScale(-1); } @@ -1988,21 +2001,21 @@ public class NEUOverlay extends Gui { JsonObject auctionInfo = manager.auctionManager.getItemAuctionInfo(internalname); JsonObject bazaarInfo = manager.auctionManager.getBazaarInfo(internalname); + int lowestBin = manager.auctionManager.getLowestBin(internalname); + APIManager.CraftInfo craftCost = manager.auctionManager.getCraftCost(json.get("internalname").getAsString()); + boolean hasAuctionPrice = !manager.config.invAuctionPrice.value && auctionInfo != null; boolean hasBazaarPrice = !manager.config.invBazaarPrice.value && bazaarInfo != null; - - int lowestBin = manager.auctionManager.getLowestBin(internalname); + boolean hasLowestBinPrice = !manager.config.invAuctionPrice.value && lowestBin > 0; NumberFormat format = NumberFormat.getInstance(Locale.US); - APIManager.CraftInfo craftCost = manager.auctionManager.getCraftCost(json.get("internalname").getAsString()); - - if(hasAuctionPrice || hasBazaarPrice || craftCost.fromRecipe) text.add(""); + if(hasAuctionPrice || hasBazaarPrice || hasLowestBinPrice) text.add(""); + if(hasLowestBinPrice) { + text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Lowest BIN: "+ + EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBin)+" coins"); + } if(hasAuctionPrice) { - if(lowestBin > 0) { - text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"Lowest BIN: "+ - EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(lowestBin)+" coins"); - } int auctionPrice = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); text.add(EnumChatFormatting.YELLOW.toString()+EnumChatFormatting.BOLD+"AH Price: "+ EnumChatFormatting.GOLD+EnumChatFormatting.BOLD+format.format(auctionPrice)+" coins"); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index fee96152..891b9711 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -87,7 +87,7 @@ 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.4-REL"; + public static final String VERSION = "1.5-REL"; public static NotEnoughUpdates INSTANCE = null; @@ -844,7 +844,6 @@ public class NotEnoughUpdates { MinecraftForge.EVENT_BUS.register(SBInfo.getInstance()); MinecraftForge.EVENT_BUS.register(CustomItemEffects.INSTANCE); MinecraftForge.EVENT_BUS.register(new DungeonMap()); - MinecraftForge.EVENT_BUS.register(new DumymMod()); //MinecraftForge.EVENT_BUS.register(new BetterPortals()); IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager(); 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 4530fc6e..886ffd73 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -39,7 +39,7 @@ public class APIManager { private HashSet playerBidsNotified = new HashSet<>(); private HashSet playerBidsFinishedNotified = new HashSet<>(); - private HashMap>> internalnameToLowestBIN = new HashMap<>(); + private JsonObject lowestBins = null; private LinkedList pagesToDownload = null; @@ -55,6 +55,7 @@ public class APIManager { private long lastCleanup = 0; private long lastAuctionAvgUpdate = 0; private long lastBazaarUpdate = 0; + private long lastLowestBinUpdate = 0; private long lastApiUpdate = 0; private long firstHypixelApiUpdate = 0; @@ -165,7 +166,6 @@ public class APIManager { auctionMap.clear(); internalnameToAucIdMap.clear(); - internalnameToLowestBIN.clear(); extrasToAucIdMap.clear(); } @@ -174,15 +174,28 @@ public class APIManager { customAH.tick(); long currentTime = System.currentTimeMillis(); - if(currentTime - lastAuctionUpdate > 60*1000) { - lastAuctionUpdate = currentTime; - updatePageTick(); - } + if(manager.config.neuAuctionHouse.value) { + if(currentTime - lastAuctionUpdate > 60*1000) { + lastAuctionUpdate = currentTime; + updatePageTick(); + } - if(currentTime - lastShortAuctionUpdate > 10*1000) { - lastShortAuctionUpdate = currentTime; - updatePageTickShort(); - ahNotification(); + if(currentTime - lastShortAuctionUpdate > 10*1000) { + lastShortAuctionUpdate = currentTime; + updatePageTickShort(); + ahNotification(); + } + if(currentTime - lastCleanup > 60*1000) { + lastCleanup = currentTime; + cleanup(); + } + if(currentTime - lastCustomAHSearch > 60*1000) { + lastCustomAHSearch = currentTime; + if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) { + customAH.updateSearch(); + calculateStats(); + } + } } if(currentTime - lastAuctionAvgUpdate > 30*60*1000) { //30 minutes lastAuctionAvgUpdate = currentTime - 28*60*1000; //Try again in 2 minutes if updateAvgPrices doesn't succeed @@ -192,16 +205,9 @@ public class APIManager { lastBazaarUpdate = currentTime; updateBazaar(); } - if(currentTime - lastCleanup > 60*1000) { - lastCleanup = currentTime; - cleanup(); - } - if(currentTime - lastCustomAHSearch > 60*1000) { - lastCustomAHSearch = currentTime; - if(Minecraft.getMinecraft().currentScreen instanceof CustomAHGui || customAH.isRenderOverAuctionView()) { - customAH.updateSearch(); - calculateStats(); - } + if(currentTime - lastLowestBinUpdate > 2*60*1000) { + lastLowestBinUpdate = currentTime; + updateLowestBin(); } } @@ -222,9 +228,25 @@ public class APIManager { } public int getLowestBin(String internalname) { - TreeMap> lowestBIN = internalnameToLowestBIN.get(internalname); - if(lowestBIN == null || lowestBIN.isEmpty()) return -1; - return lowestBIN.firstKey(); + if(internalname.contains("AUGER")) { + System.out.println("Tried to get auger!"); + } + if(lowestBins != null && lowestBins.has(internalname)) { + JsonElement e = lowestBins.get(internalname); + if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) { + if(internalname.contains("AUGER")) { + System.out.println("s:"+e.getAsInt()); + } + return e.getAsInt(); + } + } + return -1; + } + + public void updateLowestBin() { + manager.hypixelApi.getMyApiGZIPAsync("lowestbin.json.gz", (jsonObject) -> { + lowestBins = jsonObject; + }, () -> {}); } private void ahNotification() { @@ -298,14 +320,6 @@ public class APIManager { for(HashSet aucids : internalnameToAucIdMap.values()) { aucids.removeAll(toRemove); } - for(TreeMap> lowestBINs : internalnameToLowestBIN.values()) { - Set toRemoveSet = new HashSet<>(); - for(Map.Entry> entry : lowestBINs.entrySet()) { - entry.getValue().removeAll(toRemove); - if(entry.getValue().isEmpty()) toRemoveSet.add(entry.getKey()); - } - lowestBINs.keySet().removeAll(toRemoveSet); - } } private void updatePageTickShort() { @@ -314,7 +328,7 @@ public class APIManager { if(firstHypixelApiUpdate == 0 || (System.currentTimeMillis() - firstHypixelApiUpdate)%(60*1000) > 15*1000) return; JsonObject disable = Constants.DISABLE; - if(disable != null && disable.get("auctions").getAsBoolean()) return; + if(disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return; while(!pagesToDownload.isEmpty()) { try { @@ -326,7 +340,7 @@ public class APIManager { private void updatePageTick() { JsonObject disable = Constants.DISABLE; - if(disable != null && disable.get("auctions").getAsBoolean()) return; + if(disable != null && disable.has("auctions_new") && disable.get("auctions_new").getAsBoolean()) return; if(pagesToDownload == null) { getPageFromAPI(0); @@ -514,16 +528,6 @@ public class APIManager { index++; } - if(bin) { - TreeMap> lowestBINs = internalnameToLowestBIN.computeIfAbsent(internalname, k -> new TreeMap<>()); - int count = item_tag.getInteger("Count"); - int price = starting_bid/(count>0?count:1); - lowestBINs.computeIfAbsent(price, k -> new HashSet<>()).add(auctionUuid); - if(lowestBINs.size() > 50) { - lowestBINs.keySet().remove(lowestBINs.lastKey()); - } - } - for(int j=0; j itemX && mouseX < itemX+16) { - if(mouseY > itemY && mouseY < itemY+16) { - tooltipToRender = getTooltipForAucId(aucid); + if(mouseX > itemX && mouseX < itemX+16) { + if(mouseY > itemY && mouseY < itemY+16) { + tooltipToRender = getTooltipForAucId(aucid); + } } + } catch(Exception e) { } - } catch(Exception e) { } } } @@ -901,6 +903,11 @@ public class CustomAH extends Gui { this.drawTexturedModalRect(guiLeft+175, guiTop+18+(int)((95+ySplitSize*2)*scrollAmount), 256-(scrollClicked?12:24), 0, 12, 15); + if(!manager.config.neuAuctionHouse.value) { + Utils.drawStringCentered(EnumChatFormatting.RED+"NEUAH is DISABLED! Enable in /neusettings.", + Minecraft.getMinecraft().fontRendererObj, guiLeft+getXSize()/2, guiTop+getYSize()/2-5, true, 0); + } + if(tooltipToRender != null) { List tooltipGray = new ArrayList<>(); for(String line : tooltipToRender) { @@ -1044,6 +1051,10 @@ public class CustomAH extends Gui { } public void handleMouseInput() { + if(!manager.config.neuAuctionHouse.value) { + return; + } + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); @@ -1201,6 +1212,10 @@ public class CustomAH extends Gui { private ExecutorService es = Executors.newSingleThreadExecutor(); public void updateSearch() { + if(!manager.config.neuAuctionHouse.value) { + return; + } + if(searchField == null || priceField == null) init(); long currentTime = System.currentTimeMillis(); @@ -1305,6 +1320,10 @@ public class CustomAH extends Gui { } public void sortItems() throws ConcurrentModificationException { + if(!manager.config.neuAuctionHouse.value) { + return; + } + try { List sortedAuctionIdsNew = new ArrayList<>(); @@ -1352,6 +1371,10 @@ public class CustomAH extends Gui { } public boolean keyboardInput() { + if(!manager.config.neuAuctionHouse.value) { + return false; + } + Keyboard.enableRepeatEvents(true); if(isEditingPrice() && Keyboard.getEventKey() == Keyboard.KEY_RETURN) { Minecraft.getMinecraft().displayGuiScreen(null); 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 ee8282e9..2290e4a7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiContainer.java @@ -102,10 +102,12 @@ public abstract class MixinGuiContainer { public void handleMouseClick(Slot slotIn, int slotId, int clickedButton, int clickType, CallbackInfo ci) { if(slotIn != null && BetterContainers.isOverriding() && (BetterContainers.isBlankStack(slotIn.getStack()) || BetterContainers.isButtonStack(slotIn.getStack()))) { + System.out.println("handling click"); BetterContainers.clickSlot(slotIn.getSlotIndex()); Utils.playPressSound(); if(BetterContainers.isBlankStack(slotIn.getStack())) { + System.out.println("cancelling click"); 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/mixins/MixinRenderFish.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java new file mode 100644 index 00000000..59ce4852 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderFish.java @@ -0,0 +1,134 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.SpecialColour; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderFish; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.projectile.EntityFishHook; +import net.minecraft.init.Items; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL14; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.awt.*; + +@Mixin(RenderFish.class) +public abstract class MixinRenderFish extends Render { + + protected MixinRenderFish(RenderManager renderManager) { + super(renderManager); + } + + @Inject(method = "doRender(Lnet/minecraft/entity/projectile/EntityFishHook;DDDFF)V", at=@At(value = "HEAD"), cancellable = true) + public void render(EntityFishHook entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { + if(!NotEnoughUpdates.INSTANCE.manager.config.rodColours.value || entity == null) return; + + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(entity.angler.getHeldItem()); + if (NotEnoughUpdates.INSTANCE.isOnSkyblock() && internalname != null && entity.angler != null && + entity.angler.getHeldItem().getItem().equals(Items.fishing_rod)) { + if (!internalname.equals("GRAPPLING_HOOK") && !internalname.endsWith("_WHIP")) { + ci.cancel(); + + GlStateManager.pushMatrix(); + GlStateManager.translate((float)x, (float)y, (float)z); + GlStateManager.enableRescaleNormal(); + GlStateManager.scale(0.5F, 0.5F, 0.5F); + this.bindEntityTexture(entity); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); + GlStateManager.rotate(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL); + worldrenderer.pos(-0.5D, -0.5D, 0.0D).tex(0.0625D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex(); + worldrenderer.pos(0.5D, -0.5D, 0.0D).tex(0.125D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex(); + worldrenderer.pos(0.5D, 0.5D, 0.0D).tex(0.125D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex(); + worldrenderer.pos(-0.5D, 0.5D, 0.0D).tex(0.0625D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex(); + tessellator.draw(); + GlStateManager.disableRescaleNormal(); + GlStateManager.popMatrix(); + + if (entity.angler != null) { + float f7 = entity.angler.getSwingProgress(partialTicks); + float f8 = MathHelper.sin(MathHelper.sqrt_float(f7) * (float)Math.PI); + + double d0; + double d1; + double d2; + double d3; + if(this.renderManager.options.thirdPersonView == 0 && entity.angler == Minecraft.getMinecraft().thePlayer) { + double fov = this.renderManager.options.fovSetting; + fov = fov / 90.0; + double xFactor = 0.5 + 0.55*((fov-0.333)/0.889); + Vec3 vec3 = new Vec3(-xFactor * fov, -0.045D * fov, 0.4D); + vec3 = vec3.rotatePitch(-(entity.angler.prevRotationPitch + (entity.angler.rotationPitch - entity.angler.prevRotationPitch) * partialTicks) * (float)Math.PI / 180.0F); + vec3 = vec3.rotateYaw(-(entity.angler.prevRotationYaw + (entity.angler.rotationYaw - entity.angler.prevRotationYaw) * partialTicks) * (float)Math.PI / 180.0F); + vec3 = vec3.rotateYaw(f8 * 0.5F); + vec3 = vec3.rotatePitch(-f8 * 0.7F); + d0 = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks + vec3.xCoord; + d1 = entity.angler.prevPosY + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks + vec3.yCoord; + d2 = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks + vec3.zCoord; + d3 = entity.angler.getEyeHeight(); + } else { + float f9 = (entity.angler.prevRenderYawOffset + (entity.angler.renderYawOffset - entity.angler.prevRenderYawOffset) * partialTicks) * (float)Math.PI / 180.0F; + double d4 = MathHelper.sin(f9); + double d6 = MathHelper.cos(f9); + d0 = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks - d6 * 0.35D - d4 * 0.8D; + d1 = entity.angler.prevPosY + entity.angler.getEyeHeight() + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks - 0.45D; + d2 = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks - d4 * 0.35D + d6 * 0.8D; + d3 = entity.angler.isSneaking() ? -0.1875D : 0.0D; + } + + double d13 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTicks; + double d5 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTicks + 0.25D; + double d7 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTicks; + double d9 = (double)((float)(d0 - d13)); + double d11 = (double)((float)(d1 - d5)) + d3; + double d12 = (double)((float)(d2 - d7)); + GlStateManager.disableTexture2D(); + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GL14.glBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA); + worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR); + + String specialColour; + if (entity.angler.getUniqueID().equals(Minecraft.getMinecraft().thePlayer.getUniqueID())) { + specialColour = NotEnoughUpdates.INSTANCE.manager.config.selfRodLineColour.value; + } else { + specialColour = NotEnoughUpdates.INSTANCE.manager.config.otherRodLineColour.value; + } + int colourI = SpecialColour.specialToChromaRGB(specialColour); + + for (int l = 0; l <= 16; ++l) { + if(SpecialColour.getSpeed(specialColour) > 0) { //has chroma + colourI = SpecialColour.rotateHue(colourI, 10); + } + Color colour = new Color(colourI, true); + + float f10 = (float)l / 16.0F; + worldrenderer.pos(x + d9 * (double)f10, y + d11 * (double)(f10 * f10 + f10) * 0.5D + 0.25D, z + d12 * (double)f10) + .color(colour.getRed(), colour.getGreen(), colour.getBlue(), colour.getAlpha()).endVertex(); + } + + tessellator.draw(); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.enableTexture2D(); + } + } + } + } + +} \ No newline at end of file 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 f6ce41dd..adaf1ad0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/Options.java @@ -185,20 +185,32 @@ public class Options { false, "If true, will show the overlay for cracked bricks, etc. even when not in dungeons.", CAT_MISC); public Option disableDungeonBlocks = new Option( - false, + true, "Disables the dungeon blocks feature", false, - "If true, the dungeon block overlay will be disabled.", CAT_FEATURES); + "If true, the dungeon block overlay will be disabled. WARNING: May cause memory/fps issues on some machines", CAT_FEATURES); public Option 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 neuAuctionHouse = new Option( + false, + "NEU Auction House", + false, + "Enables the auction house which can be found using /neuah.\n" + + "Don't enable this option unless you use /neuah\n" + + "You *may* need to restart after enabling this for the auctions to download properly", CAT_FEATURES); public Option accessoryBagOverlay = new Option( true, "Accessory Bag Overlay", false, "If true, will an overlay with useful information in your accessory bag.", CAT_FEATURES); + public Option rodColours = new Option( + true, + "Custom Rod Line Colours", + false, + "If true, will use custom colours for fishing line rods in skyblock.", CAT_FEATURES); public Option paneGuiScale = new Option( 0.0, "Pane GUI Scale", @@ -312,6 +324,18 @@ public class Options { false, "Dungeon Bat Colour", FLAG_COLOUR, CAT_COLOURS); + public Option selfRodLineColour = new Option( + "0:255:0:0:0", + "Your Rod Line Colour", + false, + "Changes the colour of your rod's fishing line.\nContrib: ThatGravyBoat", + FLAG_COLOUR, CAT_COLOURS); + public Option otherRodLineColour = new Option( + "0:255:0:0:0", + "Other Rod Line Colour", + false, + "Changes the colour of other players' rod's fishing line.\nContrib: ThatGravyBoat", + FLAG_COLOUR, CAT_COLOURS); /** * OPTIONS THAT DON'T SHOW IN GUI @@ -396,89 +420,89 @@ public class Options { //Dungeon Map Options public Option dmBorderSize = new Option( 1.0, - "dmBorderSize", + "Border Size", false, - "", CAT_ALL); + "Changes the size of the map border, without changing the size of the contents\nSmall = 90x\nMedium = 120x\nLarge = 160x", CAT_ALL); public Option dmRoomSize = new Option( 1.0, - "dmRoomSize", + "Room Size", false, - "", CAT_ALL); + "Changes the size of rooms. Useful for higher dungeons with larger maps\nSmall = 12x\nMedium = 16x\nLarge = 20x\nXLarge = 24x", CAT_ALL); public Option dmBorderStyle = new Option( 0.0, - "dmBorderStyle", + "Border Style", false, - "", CAT_ALL); + "Various custom borders from various talented artists.\nUse 'custom' if your texture pack has a custom border", CAT_ALL); public Option dmEnable = new Option( true, - "dmEnable", + "Show Dungeon Map", false, - "", CAT_ALL); + "Show/hide the NEU dungeon map", CAT_ALL); public Option dmCenterPlayer = new Option( false, - "dmCenterPlayer", + "Map Center", false, - "", CAT_ALL); + "Center on rooms, or center on your player", CAT_ALL); public Option dmRotatePlayer = new Option( true, - "dmCenterPlayer", + "Rotate with Player", false, - "", CAT_ALL); + "Rotate the map to face the same direction as your player", CAT_ALL); public Option dmOrientCheck = new Option( true, - "dmOrientCheck", + "Orient Checkmarks", false, - "", CAT_ALL); + "Checkmarks will always show vertically, regardless of rotation", CAT_ALL); public Option dmCenterCheck = new Option( false, - "dmOrientCheck", + "Center Checkmarks", false, - "", CAT_ALL); + "Checkmarks will show closer to the center of rooms", CAT_ALL); public Option dmPlayerHeads = new Option( 0.0, - "dmPlayerHeads", + "Player Icon Style", false, - "", CAT_ALL); + "Various player icon styles", CAT_ALL); public Option dmPlayerInterp = new Option( true, - "dmPlayerInterp", + "Interpolate Far Players", false, - "", CAT_ALL); + "Will make players far away move smoothly", CAT_ALL); public Option dmCompat = new Option( 0.0, - "dmCompat", + "OpenGL Compatibility", false, - "", CAT_ALL); + "Compatiblity options for people with bad computers. ONLY use this if you know what you are doing, otherwise the map will look worse", CAT_ALL); public Option dmBackgroundColour = new Option( "00:170:75:75:75", - "dmBackgroundColour", + "Background Colour", false, - "", FLAG_COLOUR, CAT_ALL); + "Colour of the map background. Supports opacity & chroma", FLAG_COLOUR, CAT_ALL); public Option dmBorderColour = new Option( "00:0:0:0:0", - "dmBorderColour", + "Border Colour", false, - "", FLAG_COLOUR, CAT_ALL); + "Colour of the map border. Supports opacity & chroma. Turn off custom borders to see", FLAG_COLOUR, CAT_ALL); public Option dmChromaBorder = new Option( false, - "dmChromaBorder", + "Chroma Border Mode", false, - "", CAT_ALL); + "Applies a hue offset around the map border", CAT_ALL); public Option dmBackgroundBlur = new Option( 3.0, - "dmBackgroundBlur", + "Background Blur Factor", false, - "", CAT_ALL); + "Changes the blur factor behind the map. Set to 0 to disable blur", CAT_ALL); public Option dmCenterX = new Option( 8.5, - "dmCenterX", + "Center X (%)", false, - "", CAT_ALL); + "The horizontal position of the map", CAT_ALL); public Option dmCenterY = new Option( 15.0, - "dmCenterY", + "Center Y (%)", false, - "", CAT_ALL); + "The vertical position of the map", CAT_ALL); private ArrayList createDefaultQuickCommands() { ArrayList arr = new ArrayList<>(); @@ -575,12 +599,13 @@ public class Options { tryAddOption(disableDungeonBlocks, options); tryAddOption(missingEnchantList, options); tryAddOption(accessoryBagOverlay, options); + tryAddOption(rodColours, options); + tryAddOption(neuAuctionHouse, options); //Sliders tryAddOption(paneGuiScale, options); tryAddOption(smoothAoteMillis, options); tryAddOption(bgBlurFactor, options); tryAddOption(ahNotification, options); - tryAddOption(itemHighlightOpacity, options); tryAddOption(panePadding, options); tryAddOption(tooltipBorderOpacity, options); tryAddOption(dynamicMenuBackgroundStyle, options); @@ -593,6 +618,8 @@ public class Options { tryAddOption(itemFavouriteColour, options); tryAddOption(treecapOverlayColour, options); tryAddOption(wandOverlayColour, options); + tryAddOption(selfRodLineColour, options); + tryAddOption(otherRodLineColour, options); tryAddOption(dungCrackedColour, options); tryAddOption(dungDispenserColour, options); 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 111ebea1..8e3a5015 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -1670,6 +1670,7 @@ public class GuiProfileViewer extends GuiScreen { guiLeft+xStart, guiTop+yStartBottom, 76); if(skillInfo != null) { float totalSkillLVL = 0; + float totalTrueSkillLVL = 0; float totalSlayerLVL = 0; float totalSkillCount = 0; float totalSlayerCount = 0; @@ -1678,7 +1679,10 @@ public class GuiProfileViewer extends GuiScreen { if(entry.getKey().startsWith("level_skill")) { if(entry.getKey().contains("runecrafting")) continue; if(entry.getKey().contains("carpentry")) continue; + if(entry.getKey().contains("catacombs")) continue; + totalSkillLVL += entry.getValue().getAsFloat(); + totalTrueSkillLVL += Math.floor(entry.getValue().getAsFloat()); totalSkillCount++; } else if(entry.getKey().startsWith("level_slayer")) { totalSlayerLVL += entry.getValue().getAsFloat(); @@ -1687,12 +1691,15 @@ public class GuiProfileViewer extends GuiScreen { } float avgSkillLVL = totalSkillLVL/totalSkillCount; + float avgTrueSkillLVL = totalTrueSkillLVL/totalSkillCount; float avgSlayerLVL = totalSlayerLVL/totalSlayerCount; renderAlignedString(EnumChatFormatting.RED+"AVG Skill Level", EnumChatFormatting.WHITE.toString()+Math.floor(avgSkillLVL*10)/10, guiLeft+xStart, guiTop+yStartBottom+yOffset, 76); renderAlignedString(EnumChatFormatting.RED+"AVG Slayer Level", EnumChatFormatting.WHITE.toString()+Math.floor(avgSlayerLVL*10)/10, guiLeft+xStart, guiTop+yStartBottom+yOffset*2, 76); + renderAlignedString(EnumChatFormatting.RED+"True AVG Skill Level", EnumChatFormatting.WHITE.toString()+Math.floor(avgTrueSkillLVL*10)/10, + guiLeft+xStart, guiTop+yStartBottom+yOffset*3, 76); } diff --git a/src/main/resources/assets/notenoughupdates/dungeon_map/cross.png b/src/main/resources/assets/notenoughupdates/dungeon_map/cross.png new file mode 100644 index 00000000..e98151a8 Binary files /dev/null and b/src/main/resources/assets/notenoughupdates/dungeon_map/cross.png differ diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index 65957a53..a90fbb8d 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -16,6 +16,7 @@ "MixinRenderList", "MixinEntityPlayer", "MixinTileEntitySpecialRenderer", - "MixinRender" + "MixinRender", + "MixinRenderFish" ] } \ No newline at end of file -- cgit