From 3cb08dc571907bdf216ee628c1f8608067a03441 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sun, 23 Aug 2020 11:09:19 +1000 Subject: fine dj --- .../notenoughupdates/CustomItemEffects.java | 7 +- .../moulberry/notenoughupdates/NEUCape2.java | 607 --------------------- .../notenoughupdates/NEUEventListener.java | 272 +++++++-- .../github/moulberry/notenoughupdates/NEUIO.java | 123 ----- .../moulberry/notenoughupdates/NEUManager.java | 286 ++-------- .../moulberry/notenoughupdates/NEUOverlay.java | 65 ++- .../notenoughupdates/NotEnoughUpdates.java | 160 +++++- .../notenoughupdates/auction/APIManager.java | 257 ++++++++- .../notenoughupdates/auction/CustomAH.java | 100 +++- .../notenoughupdates/cosmetics/CapeManager.java | 41 +- .../notenoughupdates/cosmetics/CapeNode.java | 4 +- .../notenoughupdates/cosmetics/NEUCape.java | 115 +++- .../notenoughupdates/gamemodes/SBGamemodes.java | 6 +- .../infopanes/CollectionLogInfoPane.java | 6 +- .../notenoughupdates/infopanes/HTMLInfoPane.java | 8 +- .../mixins/MixinEntityRenderer.java | 2 +- .../notenoughupdates/mixins/MixinItemStack.java | 37 ++ .../mixins/MixinNetHandlerPlayClient.java | 3 +- .../notenoughupdates/options/Options.java | 26 +- .../notenoughupdates/util/HypixelApi.java | 2 +- 20 files changed, 1020 insertions(+), 1107 deletions(-) delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/NEUCape2.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/NEUIO.java (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java index f4fcc41d..fe3c7542 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/CustomItemEffects.java @@ -51,7 +51,9 @@ public class CustomItemEffects { if(delta <= 0) return; - if(aoteTeleportationMillis > 300) aoteTeleportationMillis = 300; + if(aoteTeleportationMillis > NotEnoughUpdates.INSTANCE.manager.config.smoothAoteMillis.value.intValue()*2) { + aoteTeleportationMillis = NotEnoughUpdates.INSTANCE.manager.config.smoothAoteMillis.value.intValue()*2; + } if(aoteTeleportationMillis < 0) aoteTeleportationMillis = 0; if(currentTime - aoteUseMillis > 1000 && aoteTeleportationMillis <= 0) { @@ -91,6 +93,8 @@ public class CustomItemEffects { @SubscribeEvent public void onPlayerInteract(PlayerInteractEvent event) { + if(NotEnoughUpdates.INSTANCE.manager.config.smoothAoteMillis.value <= 0) return; + if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR || event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) { ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); if(held != null) { @@ -113,6 +117,7 @@ public class CustomItemEffects { if(aoteTeleportationCurr != null && aoteTeleportationMillis > 0) { event.setCanceled(true); } + if(NotEnoughUpdates.INSTANCE.manager.config.disableTreecapOverlay.value) return; ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); if(heldInternal != null) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUCape2.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUCape2.java deleted file mode 100644 index 996809da..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUCape2.java +++ /dev/null @@ -1,607 +0,0 @@ -package io.github.moulberry.notenoughupdates; - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.command.CommandBase; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.*; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.client.event.RenderPlayerEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL20; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class NEUCape2 { - - //private ResourceLocation capeImageLocation = new ResourceLocation(Morus.MODID, "cape.jpg"); - //private SimpleTexture capeTexture; - - private long millisLastRenderUpdate = 0; - - private int horzNodes = 20; - private double targetDist = 1/30.0; - - private EntityPlayer player = null; - - private double vertOffset = 1.4; - private double shoulderLength = 0.3; - private double shoulderWidth = 0.13; - private double crouchWidthOffset = -0.05; - private double maxCrouchOffset = 0.35; - - private double resistance = 0.08; - private double gravity = 0.04; - private int steps = 10; - - private List> nodes = new ArrayList<>(); - - /*private void reloadCapeImage() { - if(capeTexture != null) { - capeTexture.deleteGlTexture(); - } - capeTexture = new SimpleTexture(capeImageLocation); - try { - capeTexture.loadTexture(Minecraft.getMinecraft().getResourceManager()); - } catch(IOException e) { - e.printStackTrace(); - } - }*/ - - private void resetNodes(EntityPlayer player) { - nodes.clear(); - for(int i=0; i<50; i++) { - List list = new ArrayList<>(); - for(int j=0; j 1) { - list.add(new Node(player.posX-1, player.posY+2-i*targetDist, player.posZ+((double)j)/(horzNodes-1), i, j)); - } - } - - nodes.add(list); - } - } - - class Node { - public int iIndex; - public int jIndex; - - public boolean fixed = false; - - public double x; - public double y; - public double z; - public double xOld; - public double yOld; - public double zOld; - public double aX; - public double aY; - public double aZ; - - public double normalX; - public double normalY; - public double normalZ; - - public Node(double x, double y, double z, int iIndex, int jIndex) { - this.x = xOld = x; - this.y = xOld = y; - this.z = xOld = z; - this.iIndex = iIndex; - this.jIndex = jIndex; - } - - private void updateNormal(Node up, Node left, Node right, Node down, Node up2, Node left2, Node right2, Node down2) { - Vec3 normal1 = normal(up, left); - Vec3 normal2 = normal(right, up); - Vec3 normal3 = normal(down, right); - Vec3 normal4 = normal(left, down); - Vec3 normal5 = normal(up2, left2); - Vec3 normal6 = normal(right2, up2); - Vec3 normal7 = normal(down2, right2); - Vec3 normal8 = normal(left2, down2); - - Vec3 avgNormal = normal1.add(normal2).add(normal3).add(normal4) - .add(normal5).add(normal6).add(normal7).add(normal8).normalize(); - - normalX = avgNormal.xCoord; - normalY = avgNormal.yCoord; - normalZ = avgNormal.zCoord; - } - - private Vec3 normal(Node node1, Node node2) { - if(node1 == null || node2 == null) { - return new Vec3(0,0,0); - } - Vec3 thisNode = node2vec(this); - Vec3 node1Vec = node2vec(node1); - Vec3 node2Vec = node2vec(node2); - - Vec3 thisTo1 = node1Vec.subtract(thisNode); - Vec3 thisTo2 = node2Vec.subtract(thisNode); - - return thisTo1.crossProduct(thisTo2); - - } - - public void update(double pX, double pY, double pZ, EntityPlayer player) { - if(fixed) { - return; - } - - double xTemp = x; - double yTemp = y; - double zTemp = z; - - double res = resistance; - - BlockPos pos = new BlockPos( - MathHelper.floor_double(x), - MathHelper.floor_double(y), - MathHelper.floor_double(z)); - Block block = Minecraft.getMinecraft().theWorld.getBlockState(pos).getBlock(); - if(block.getMaterial().isLiquid()) { - aX /= 5; - aY /= 5; - aZ /= 5; - - res = Math.sqrt(res); - } - - double xDiff = x-xOld; - double yDiff = y-yOld; - double zDiff = z-zOld; - - xDiff = MathHelper.clamp_double(xDiff, -0.5, 0.5); - yDiff = MathHelper.clamp_double(yDiff, -0.5, 0.5); - zDiff = MathHelper.clamp_double(zDiff, -0.5, 0.5); - - x = x + xDiff*(1-res)+aX*0.2; - y = y + yDiff*(1-res)+aY*0.2; - z = z + zDiff*(1-res)+aZ*0.2; - - resolvePlayerCollision(pX, pY, pZ, player); - - if(!checkCollision(xTemp, yTemp, zTemp)) { - xOld = xTemp; - yOld = yTemp; - zOld = zTemp; - } - - if(checkCollision(x, y, z)) { - updateFromBoundingBox(); - } - - aX = 0; - aY = 0; - aZ = 0; - } - - public boolean resolvePlayerCollision(double pX, double pY, double pZ, EntityPlayer player) { - double angle = Math.toRadians(player.renderYawOffset); - - double offset = 0; - - if(player.getCurrentArmor(1) != null) { - if(player.isSneaking()) { - offset += 0.15; - } else { - offset += 0.06; - } - } - - if(player.isSneaking()) { - offset -= crouchWidthOffset; - - double dY = y - player.posY; - - if(dY < 0.65) { - offset += maxCrouchOffset; - } else if(dY < 1.2) { - offset += maxCrouchOffset*(1.2-dY)/0.55; - } - } - - double x1 = pX+Math.cos(angle)*2-Math.cos(angle+Math.PI/2)*(shoulderWidth+offset); - double z1 = pZ+Math.sin(angle)*2-Math.sin(angle+Math.PI/2)*(shoulderWidth+offset); - double x2 = pX-Math.cos(angle)*2-Math.cos(angle+Math.PI/2)*(shoulderWidth+offset); - double z2 = pZ-Math.sin(angle)*2-Math.sin(angle+Math.PI/2)*(shoulderWidth+offset); - - boolean crossed = ((x2 - x1)*(z - z1) < (z2 - z1)*(x - x1)); - - if(crossed) { - double dot1 = ((x-x2)*(x1-x2)+(z-z2)*(z1-z2)); - double dot2 = (x1-x2)*(x1-x2)+(z1-z2)*(z1-z2); - double k = dot1/dot2; - - x = xOld = (x1-x2)*k+x2; - z = zOld = (z1-z2)*k+z2; - - return true; - } - return false; - } - - public void updateFromBoundingBox() { - BlockPos pos = new BlockPos( - MathHelper.floor_double(x), - MathHelper.floor_double(y), - MathHelper.floor_double(z)); - Block block = Minecraft.getMinecraft().theWorld.getBlockState(pos).getBlock(); - block.setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, pos); - AxisAlignedBB bb = block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, pos); - - Vec3 center = new Vec3((bb.minX + bb.maxX) / 2, (bb.minY + bb.maxY) / 2, (bb.minZ + bb.maxZ) / 2); - MovingObjectPosition mop = bb.calculateIntercept(center.add(new Vec3(x, y, z).subtract(center).normalize()), center); - - if(mop == null) { - return; - } - - Vec3 vec = mop.hitVec; - - if(vec == null) { - return; - } - - double dX = vec.xCoord - x; - double dY = vec.yCoord - y; - double dZ = vec.zCoord - z; - double adX = Math.abs(dX); - double adY = Math.abs(dY); - double adZ = Math.abs(dZ); - - double tot = adX + adY + adZ; - - //Simulate a little bit of friction - if(tot < 0.15 || checkCollision(vec.xCoord, vec.yCoord, vec.zCoord)) { - x = xOld; - y = yOld; - z = zOld; - return; - } - - //>0.3 check reduces the movement at corners a little bit - if(adX/tot > 0.3) x = xOld = vec.xCoord; - if(adY/tot > 0.3) y = yOld = vec.yCoord; - if(adZ/tot > 0.3) z = zOld = vec.zCoord; - } - - public boolean checkCollision(double x, double y, double z) { - BlockPos pos = new BlockPos( - MathHelper.floor_double(x), - MathHelper.floor_double(y), - MathHelper.floor_double(z)); - Block block = Minecraft.getMinecraft().theWorld.getBlockState(pos).getBlock(); - - if(block.getMaterial().isSolid()) { - block.setBlockBoundsBasedOnState(Minecraft.getMinecraft().theWorld, pos); - AxisAlignedBB bb = block.getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, pos); - - return bb.isVecInside(new Vec3(x, y, z)); - } else { - return false; - } - } - } - - @SubscribeEvent - public void onRenderTick(TickEvent.RenderTickEvent e) { - if(Minecraft.getMinecraft().theWorld == null || player == null) { - return; - } - - long delta = System.currentTimeMillis() - millisLastRenderUpdate; - - double lagFactor = delta/(1000/60.0); - if(lagFactor > 3) { - lagFactor = 3; - } - - double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * e.renderTickTime; - double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * e.renderTickTime; - double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * e.renderTickTime; - - updateFixedNodes(playerX, playerY, playerZ, player); - - for(List nodes2 : nodes) { - for(Node node : nodes2) { - node.aY -= gravity*lagFactor; - node.update(playerX, playerY, playerZ, player); - } - } - for(int step=0; step struct = new ArrayList<>(); - List shear = new ArrayList<>(); - List bend = new ArrayList<>(); - - if(i+1 < nodes.size()) struct.add(nodes.get(i+1).get(j)); - if(j+1 < horzNodes) struct.add(nodes.get(i).get(j+1)); - if(i-1 >= 0) struct.add(nodes.get(i-1).get(j)); - if(j-1 >= 0) struct.add(nodes.get(i).get(j-1)); - - if(i+1 < nodes.size() && j+1 < horzNodes) shear.add(nodes.get(i+1).get(j+1)); - if(i+1 < nodes.size() && j-1 >= 0) shear.add(nodes.get(i+1).get(j-1)); - if(i-1 >= 0 && j+1 < horzNodes) shear.add(nodes.get(i-1).get(j+1)); - if(i-1 >= 0 && j-1 >= 0) shear.add(nodes.get(i-1).get(j-1)); - - if(i+2 < nodes.size()) bend.add(nodes.get(i+2).get(j)); - if(j+2 < horzNodes) bend.add(nodes.get(i).get(j+2)); - if(i-2 >= 0) bend.add(nodes.get(i-2).get(j)); - if(j-2 >= 0) bend.add(nodes.get(i).get(j-2)); - - try { - updateNode(node, struct, shear, bend); - } catch(Exception ex) { - - } - } - } - } - for(int i=0; i= 0) up = nodes.get(i-1).get(j); - if(j-1 >= 0) left = nodes.get(i).get(j-1); - - if(i+2 < nodes.size()) down2 = nodes.get(i+2).get(j); - if(j+2 < horzNodes) right2 = nodes.get(i).get(j+2); - if(i-2 >= 0) up2 = nodes.get(i-2).get(j); - if(j-2 >= 0) left2 = nodes.get(i).get(j-2); - - nodes.get(i).get(j).updateNormal(up, left, right, down, up2, left2, right2, down2); - } - } - - millisLastRenderUpdate = System.currentTimeMillis(); - } - - @SubscribeEvent - public void onRenderPlayer(RenderPlayerEvent.Post e) { - EntityPlayer player = e.entityPlayer; - - if(!player.getName().equalsIgnoreCase("Moulberry")) { - return; - } - - if(nodes.size() == 0) { - resetNodes(player); - } - - this.player = player; - - Entity viewer = Minecraft.getMinecraft().getRenderViewEntity(); - - double viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * e.partialRenderTick; - double viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * e.partialRenderTick; - double viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * e.partialRenderTick; - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, - GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); - GL11.glDisable(GL11.GL_CULL_FACE); - GlStateManager.enableTexture2D(); - int currTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); - //GL11.glBindTexture(GL11.GL_TEXTURE_2D, capeTexture.getGlTextureId()); - - //ShaderManager shaderManager = ShaderManager.getInstance(); - - //shaderManager.loadShader("cape"); - - for(int i=0; i struct, List shear, List bend) { - double shearDist = 1.414*targetDist; - double bendDist = 2*targetDist; //Potentially differentiate between corners? - - for(Node bendNode : bend) { - resolve(node, bendNode, bendDist); - } - - for(Node shearNode : shear) { - resolve(node, shearNode, shearDist); - } - - for(Node structNode : struct) { - resolve(node, structNode, targetDist); - } - } - - public void resolve(Node node1, Node node2, double targetDist) { - double dX = node1.x - node2.x; - double dY = node1.y - node2.y; - double dZ = node1.z - node2.z; - - double distSq = dX*dX + dY*dY + dZ*dZ; - double dist = Math.sqrt(distSq); - - dX *= (1 - targetDist/dist)*0.5; - dY *= (1 - targetDist/dist)*0.5; - dZ *= (1 - targetDist/dist)*0.5; - - if(node1.fixed || node2.fixed) { - dX *= 2; - dY *= 2; - dZ *= 2; - } - - if(!node1.fixed) { - node1.x -= dX; - node1.y -= dY; - node1.z -= dZ; - } - - if(!node2.fixed) { - node2.x += dX; - node2.y += dY; - node2.z += dZ; - } - } - - private void updateFixedNodes(double pX, double pY, double pZ, EntityPlayer player) { - double angle = Math.toRadians(player.renderYawOffset); - - double shoulderWidth2 = shoulderWidth + (player.isSneaking()?crouchWidthOffset:0); - if(player.getCurrentArmor(1) != null || player.getCurrentArmor(2) != null) { - if(player.isSneaking()) { - shoulderWidth2 += 0.15; - } else { - shoulderWidth2 += 0.06; - } - } - - Node node = nodes.get(0).get(0); - node.x = pX+Math.cos(angle)*shoulderLength-Math.cos(angle+Math.PI/2)*shoulderWidth2; - node.y = pY+vertOffset-(player.isSneaking()?0.2:0); - node.z = pZ+Math.sin(angle)*shoulderLength-Math.sin(angle+Math.PI/2)*shoulderWidth2; - node.fixed = true; - - node = nodes.get(0).get(nodes.get(0).size()-1); - node.x = pX-Math.cos(angle)*shoulderLength-Math.cos(angle+Math.PI/2)*shoulderWidth2; - node.y = pY+vertOffset-(player.isSneaking()?0.2:0); - node.z = pZ-Math.sin(angle)*shoulderLength-Math.sin(angle+Math.PI/2)*shoulderWidth2; - node.fixed = true; - - - - /*for(int i=0; i 0) { + if(gui instanceof GuiChest && neu.manager.auctionManager.activeAuctions > 0 && !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"); @@ -583,7 +585,7 @@ public class NEUEventListener { Minecraft.getMinecraft().getTextureManager().bindTexture(dungeon_chest_worth); GL11.glColor4f(1, 1, 1, 1); GlStateManager.disableLighting(); - Utils.drawTexturedRect(guiLeft+xSize+4, guiTop, 180, 45, 0, 180/256f, 0, 45/256f, GL11.GL_NEAREST); + Utils.drawTexturedRect(guiLeft+xSize+4, guiTop, 180, 71, 0, 180/256f, 0, 71/256f, GL11.GL_NEAREST); int chestCost = 0; String line6 = Utils.cleanColour(neu.manager.getLoreFromNBT(rewardChest.getTagCompound())[6]); @@ -599,53 +601,84 @@ public class NEUEventListener { } boolean missing = false; - int totalValue = 0; + int totalValueBIN = 0; + int totalValueAUC = 0; for(int i=0; i<5; i++) { ItemStack item = lower.getStackInSlot(11+i); String internal = neu.manager.getInternalNameForItem(item); if(internal != null) { - float worth = neu.manager.auctionManager.getLowestBin(internal); + float worthBIN = neu.manager.auctionManager.getLowestBin(internal); + float worthAUC = -1; + JsonObject aucInfo = neu.manager.auctionManager.getItemAuctionInfo(internal); + if(aucInfo != null) { + worthAUC = aucInfo.get("price").getAsFloat(); + } - if(worth == -1) worth = neu.manager.getCraftCost(internal).craftCost; + if(worthAUC == -1) worthAUC = neu.manager.auctionManager.getCraftCost(internal).craftCost; - if(worth > 0) { - totalValue += worth; - } else { + if(worthAUC <= 0 && worthBIN <= 0) { missing = true; break; } + + if(worthBIN > 0 && totalValueBIN >= 0) { + totalValueBIN += worthBIN; + } else { + totalValueBIN = -1; + } + + if(worthAUC > 0 && totalValueAUC >= 0) { + totalValueAUC += worthAUC; + } else { + totalValueAUC = -1; + } } } - int profitLoss = totalValue - chestCost; - - NumberFormat format = NumberFormat.getInstance(Locale.US); - String valueString; - if(!missing) { - valueString = EnumChatFormatting.BLUE+"Chest value: " + EnumChatFormatting.GOLD - + EnumChatFormatting.BOLD + format.format(totalValue) + " coins"; - } else { - valueString = EnumChatFormatting.BLUE+"Couldn't find item on AH. Item is very rare!"; + if(totalValueAUC <= 0 && totalValueBIN <= 0) { + missing = true; } - String plString; + if(missing) { - plString = ""; - } else if(profitLoss >= 0) { - plString = EnumChatFormatting.BLUE+"Profit/loss: " + EnumChatFormatting.DARK_GREEN - + EnumChatFormatting.BOLD + "+" + format.format(profitLoss) + " coins"; + drawStringShadow(EnumChatFormatting.BLUE+"Couldn't find item on AH. Item is very rare!", + guiLeft+xSize+4+90, guiTop+14, 170); } else { - plString = EnumChatFormatting.BLUE+"Profit/loss: " + EnumChatFormatting.RED - + EnumChatFormatting.BOLD + "-" + format.format(-profitLoss) + " coins"; - } + NumberFormat format = NumberFormat.getInstance(Locale.US); + String valueStringBIN = EnumChatFormatting.YELLOW+"Value (BIN): " + EnumChatFormatting.GOLD + + EnumChatFormatting.BOLD + format.format(totalValueBIN) + " coins"; + String valueStringAUC = EnumChatFormatting.YELLOW+"Value (AUC): " + EnumChatFormatting.GOLD + + EnumChatFormatting.BOLD + format.format(totalValueAUC) + " coins"; + + + int profitLossBIN = totalValueBIN - chestCost; + String plStringBIN; + if(profitLossBIN >= 0) { + plStringBIN = EnumChatFormatting.YELLOW+"Profit/Loss: " + EnumChatFormatting.DARK_GREEN + + EnumChatFormatting.BOLD + "+" + format.format(profitLossBIN) + " coins"; + } else { + plStringBIN = EnumChatFormatting.YELLOW+"Profit/Loss: " + EnumChatFormatting.RED + + EnumChatFormatting.BOLD + "-" + format.format(-profitLossBIN) + " coins"; + } + + int profitLossAUC = totalValueAUC - chestCost; + String plStringAUC; + if(profitLossAUC >= 0) { + plStringAUC = EnumChatFormatting.YELLOW+"Profit/Loss: " + EnumChatFormatting.DARK_GREEN + + EnumChatFormatting.BOLD + "+" + format.format(profitLossAUC) + " coins"; + } else { + plStringAUC = EnumChatFormatting.YELLOW+"Profit/Loss: " + EnumChatFormatting.RED + + EnumChatFormatting.BOLD + "-" + format.format(-profitLossAUC) + " coins"; + } - Minecraft.getMinecraft().getTextureManager().bindTexture(dungeon_chest_worth); - GL11.glColor4f(1, 1, 1, 1); - GlStateManager.disableLighting(); - Utils.drawTexturedRect(guiLeft+xSize+4, guiTop, 180, 45, 0, 180/256f, 0, 45/256f, GL11.GL_NEAREST); + drawStringShadow(valueStringBIN, guiLeft+xSize+4+90, + guiTop+14, 170); + drawStringShadow(plStringBIN, guiLeft+xSize+4+90, + guiTop+26, 170); - Utils.drawStringCenteredScaledMaxWidth(valueString, Minecraft.getMinecraft().fontRendererObj, guiLeft+xSize+4+90, - guiTop+14, true, 170, Color.BLACK.getRGB()); - Utils.drawStringCenteredScaledMaxWidth(plString, Minecraft.getMinecraft().fontRendererObj, guiLeft+xSize+4+90, - guiTop+28, true, 170, Color.BLACK.getRGB()); + drawStringShadow(valueStringAUC, guiLeft+xSize+4+90, + guiTop+44, 170); + drawStringShadow(plStringAUC, guiLeft+xSize+4+90, + guiTop+56, 170); + } } } catch(Exception e) { e.printStackTrace(); @@ -653,6 +686,24 @@ public class NEUEventListener { } } + public void drawStringShadow(String str, float x, float y, int len) { + 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(str), + Minecraft.getMinecraft().fontRendererObj, + x+xOff/2f, y+yOff/2f, false, len, + new Color(20, 20, 20, 100/Math.max(Math.abs(xOff), Math.abs(yOff))).getRGB()); + } + } + } + + Utils.drawStringCenteredScaledMaxWidth(str, + Minecraft.getMinecraft().fontRendererObj, + x, y, false, len, + new Color(64, 64, 64, 255).getRGB()); + } + /** * Sends a mouse event to NEUOverlay if the inventory isn't hovered AND focused. * Will also cancel the event if if NEUOverlay#mouseInput returns true. @@ -669,9 +720,13 @@ public class NEUEventListener { neu.overlay.mouseInput(); return; } - if(shouldRenderOverlay(event.gui) && !(hoverInv && focusInv) && neu.isOnSkyblock()) { - if(neu.overlay.mouseInput()) { - event.setCanceled(true); + if(shouldRenderOverlay(event.gui) && neu.isOnSkyblock()) { + if(!(hoverInv && focusInv)) { + if(neu.overlay.mouseInput()) { + event.setCanceled(true); + } + } else { + neu.overlay.mouseInputInv(); } } } @@ -815,7 +870,7 @@ public class NEUEventListener { @SubscribeEvent(priority = EventPriority.LOW) public void onItemTooltipLow(ItemTooltipEvent event) { - //NotEnoughUpdates.INSTANCE.neu.manager.config.enchantColours.value + boolean dungeonProfit = false; int index = 0; List newTooltip = new ArrayList<>(); for(String line : event.toolTip) { @@ -904,7 +959,150 @@ public class NEUEventListener { } } } + newTooltip.add(line); + + if(neu.manager.config.auctionPriceInfo.value) { + if(line.contains(EnumChatFormatting.GRAY+"Buy it now: ") || + line.contains(EnumChatFormatting.GRAY+"Bidder: ") || + line.contains(EnumChatFormatting.GRAY+"Starting bid: ")) { + String internalname = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); + if(internalname != null) { + newTooltip.add(""); + if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && !Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { + newTooltip.add(EnumChatFormatting.GRAY+"[SHIFT for Price Info]"); + } else { + JsonObject auctionInfo = NotEnoughUpdates.INSTANCE.manager.auctionManager.getItemAuctionInfo(internalname); + + boolean hasAuctionPrice = auctionInfo != null; + + int lowestBin = NotEnoughUpdates.INSTANCE.manager.auctionManager.getLowestBin(internalname); + + NumberFormat format = NumberFormat.getInstance(Locale.US); + APIManager.CraftInfo craftCost = NotEnoughUpdates.INSTANCE.manager.auctionManager.getCraftCost(internalname); + + if(lowestBin > 0) { + newTooltip.add(EnumChatFormatting.GRAY+"Lowest BIN: "+ + EnumChatFormatting.GOLD+format.format(lowestBin)+" coins"); + } + if(hasAuctionPrice) { + int auctionPrice = (int)(auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat()); + newTooltip.add(EnumChatFormatting.GRAY+"AH Price: "+ + EnumChatFormatting.GOLD+format.format(auctionPrice)+" coins"); + newTooltip.add(EnumChatFormatting.GRAY+"AH Sales: "+ + EnumChatFormatting.GOLD+format.format(auctionInfo.get("sales").getAsFloat())+" sales/day"); + if(auctionInfo.has("clean_price")) { + newTooltip.add(EnumChatFormatting.GRAY+"AH Price (Clean): "+ + EnumChatFormatting.GOLD+format.format((int)auctionInfo.get("clean_price").getAsFloat())+" coins"); + newTooltip.add(EnumChatFormatting.GRAY+"AH Sales (Clean): "+ + EnumChatFormatting.GOLD+format.format(auctionInfo.get("clean_sales").getAsFloat())+" sales/day"); + } + + } + if(craftCost.fromRecipe) { + newTooltip.add(EnumChatFormatting.GRAY+"Raw Craft Cost: "+ + EnumChatFormatting.GOLD+format.format((int)craftCost.craftCost)+" coins"); + } + } + } + } + } + + if(neu.manager.config.dungeonProfitLore.value && Minecraft.getMinecraft().currentScreen instanceof GuiChest) { + if(line.contains(EnumChatFormatting.GREEN+"Open Reward Chest")) { + dungeonProfit = true; + } else if(index == 7 && dungeonProfit) { + GuiChest eventGui = (GuiChest) Minecraft.getMinecraft().currentScreen; + ContainerChest cc = (ContainerChest) eventGui.inventorySlots; + IInventory lower = cc.getLowerChestInventory(); + + int chestCost = 0; + String line6 = Utils.cleanColour(line); + StringBuilder cost = new StringBuilder(); + for(int i=0; i= 0) { + cost.append(c); + } + } + if(cost.length() > 0) { + chestCost = Integer.parseInt(cost.toString()); + } + + boolean missing = false; + int totalValueBIN = 0; + int totalValueAUC = 0; + for(int i=0; i<5; i++) { + ItemStack item = lower.getStackInSlot(11+i); + String internal = neu.manager.getInternalNameForItem(item); + if(internal != null) { + float worthBIN = neu.manager.auctionManager.getLowestBin(internal); + float worthAUC = neu.manager.auctionManager.getLowestBin(internal); + + if(worthAUC == -1) worthAUC = neu.manager.auctionManager.getCraftCost(internal).craftCost; + + if(worthAUC <= 0 && worthBIN <= 0) { + missing = true; + break; + } + + if(worthBIN > 0 && totalValueBIN >= 0) { + totalValueBIN += worthBIN; + } else { + totalValueBIN = -1; + } + + if(worthAUC > 0 && totalValueAUC >= 0) { + totalValueAUC += worthAUC; + } else { + totalValueAUC = -1; + } + } + } + if(totalValueAUC <= 0 && totalValueBIN <= 0) { + missing = true; + } + + String neu = EnumChatFormatting.YELLOW + "[NEU] "; + if(missing) { + newTooltip.add(neu + EnumChatFormatting.BLUE+"Couldn't find item on AH. Item is very rare!"); + } else { + NumberFormat format = NumberFormat.getInstance(Locale.US); + String valueStringBIN = EnumChatFormatting.YELLOW+"Value (BIN): " + EnumChatFormatting.GOLD + + EnumChatFormatting.BOLD + format.format(totalValueBIN) + " coins"; + String valueStringAUC = EnumChatFormatting.YELLOW+"Value (AUC): " + EnumChatFormatting.GOLD + + EnumChatFormatting.BOLD + format.format(totalValueAUC) + " coins"; + + + int profitLossBIN = totalValueBIN - chestCost; + String plStringBIN; + if(profitLossBIN >= 0) { + plStringBIN = EnumChatFormatting.YELLOW+"Profit/Loss: " + EnumChatFormatting.DARK_GREEN + + EnumChatFormatting.BOLD + "+" + format.format(profitLossBIN) + " coins"; + } else { + plStringBIN = EnumChatFormatting.YELLOW+"Profit/Loss: " + EnumChatFormatting.RED + + EnumChatFormatting.BOLD + "-" + format.format(-profitLossBIN) + " coins"; + } + + int profitLossAUC = totalValueAUC - chestCost; + String plStringAUC; + if(profitLossAUC >= 0) { + plStringAUC = EnumChatFormatting.YELLOW+"Profit/Loss: " + EnumChatFormatting.DARK_GREEN + + EnumChatFormatting.BOLD + "+" + format.format(profitLossAUC) + " coins"; + } else { + plStringAUC = EnumChatFormatting.YELLOW+"Profit/Loss: " + EnumChatFormatting.RED + + EnumChatFormatting.BOLD + "-" + format.format(-profitLossAUC) + " coins"; + } + + newTooltip.add(neu + valueStringBIN); + newTooltip.add(neu + plStringBIN); + newTooltip.add(neu + valueStringAUC); + newTooltip.add(neu + plStringAUC); + } + } + } + + index++; } event.toolTip.clear(); event.toolTip.addAll(newTooltip); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUIO.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUIO.java deleted file mode 100644 index ac828606..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUIO.java +++ /dev/null @@ -1,123 +0,0 @@ -package io.github.moulberry.notenoughupdates; - -import org.kohsuke.github.*; - -import java.io.IOException; -import java.util.*; - -public class NEUIO { - - private final String accessToken; - - /** - * THIS CLASS PROVIDES METHODS FOR INTERFACING WITH THE GIT REPOSITORY NotEnoughUpdates-REPO. THIS REPOSITORY - * CONTAINS ALL THE JSON ITEMS. THIS SHOULD NOT BE A PERMANENT SOLUTION AND I SHOULD LOOK AT USING SOME FORM OF - * HOSTING SERVICE OTHER THAN A GIT REPOSITORY IF THE USERBASE OF THE MOD GROWS SIGNIFICANTLY. UNFORTUNATELY I - * CANT AFFORD HOSTING RIGHT NOW SO THIS IS WHAT YOU GET AND GITHUB WILL PROBABLY THROW A FIT IF A LARGE NUMBER - * OF USERS START DOWNLOADING FROM THE REPO ALL AT ONCE. - */ - - public NEUIO(String accessToken) { - this.accessToken = accessToken; - } - - /** - * Creates a new branch, commits to it with a single file change and submits a pull request from the new branch - * back to the master branch. - */ - public boolean createNewRequest(String newBranchName, String prTitle, String prBody, String filename, String content) { - try { - GitHub github = new GitHubBuilder().withOAuthToken(accessToken).build(); - System.out.println("Getting repo"); - - //https://github.com/Moulberry/NotEnoughUpdates-REPO - GHRepository repo = github.getRepositoryById("247692460"); - - System.out.println("Getting last commit"); - String lastCommitSha = repo.getRef("heads/master").getObject().getSha(); - System.out.println("Last master commit sha: " + lastCommitSha); - - String lastTreeSha = repo.getCommit(lastCommitSha).getTree().getSha(); - - GHTreeBuilder tb = repo.createTree(); - tb.baseTree(lastTreeSha); - tb.add(filename, content, false); - GHTree tree = tb.create(); - System.out.println("Created new tree: " + tree.getSha()); - - GHCommitBuilder cb = repo.createCommit(); - cb.message(prTitle); - cb.tree(tree.getSha()); - cb.parent(lastCommitSha); - GHCommit commit = cb.create(); - System.out.println("Created commit: " + commit.getSHA1()); - - repo.createRef("refs/heads/"+newBranchName, commit.getSHA1()); - System.out.println("Set new branch head to commit."); - - repo.createPullRequest(prTitle, newBranchName, "master", prBody); - return true; - } catch(IOException e) { - e.printStackTrace(); - return false; - } - } - - public String getLatestCommit() { - try { - GitHub github = new GitHubBuilder().withOAuthToken(accessToken).build(); - GHRepository repo = github.getRepositoryById("247692460"); - - for(GHCommit commit : repo.listCommits()) { - return commit.getSHA1(); - } - } catch(IOException e) { - return null; - } - return ""; - } - - /** - * @param oldShas Map from filename (eg. BOW.json) to the sha in the local repository - * @return Map from filename to the new shas - */ - public Map getChangedItems(Map oldShas) { - HashMap changedFiles = new HashMap<>(); - try { - GitHub github = new GitHubBuilder().withOAuthToken(accessToken).build(); - GHRepository repo = github.getRepositoryById("247692460"); - - for(GHTreeEntry treeEntry : repo.getTreeRecursive("master", 1).getTree()) { - if(treeEntry.getPath().contains(".")) { - String oldSha = oldShas.get(treeEntry.getPath()); - if(!treeEntry.getSha().equals(oldSha)) { - changedFiles.put(treeEntry.getPath(), treeEntry.getSha()); - } - } - } - } catch(IOException e) { - return null; - } - return changedFiles; - } - - public Set getRemovedItems(Set currentlyInstalled) { - Set removedItems = new HashSet<>(); - Set repoItems = new HashSet<>(); - try { - GitHub github = new GitHubBuilder().withOAuthToken(accessToken).build(); - GHRepository repo = github.getRepositoryById("247692460"); - - for(GHTreeEntry treeEntry : repo.getTreeRecursive("master", 1).getTree()) { - String[] split = treeEntry.getPath().split("/"); - repoItems.add(split[split.length-1].split("\\.")[0]); - } - } catch(IOException e) { - e.printStackTrace(); - return removedItems; - } - removedItems.addAll(currentlyInstalled); - removedItems.removeAll(repoItems); - return removedItems; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 2ae298e2..a7303ca4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -36,7 +36,6 @@ import java.util.zip.ZipInputStream; public class NEUManager { private final NotEnoughUpdates neu; - public final NEUIO neuio; public final Gson gson; public final APIManager auctionManager; @@ -51,7 +50,9 @@ public class NEUManager { public final KeyBinding keybindViewRecipe = new KeyBinding("Show recipe for item", Keyboard.KEY_R, "NotEnoughUpdates"); public final KeyBinding keybindToggleDisplay = new KeyBinding("Toggle NEU overlay", 0, "NotEnoughUpdates"); public final KeyBinding keybindClosePanes = new KeyBinding("Close NEU panes", 0, "NotEnoughUpdates"); - public final KeyBinding[] keybinds = new KeyBinding[]{keybindGive, keybindFavourite, keybindViewUsages, keybindViewRecipe, keybindToggleDisplay, keybindClosePanes}; + public final KeyBinding keybindItemSelect = new KeyBinding("Select Item", -98 /*middle*/, "NotEnoughUpdates"); + public final KeyBinding[] keybinds = new KeyBinding[]{ keybindGive, keybindFavourite, keybindViewUsages, keybindViewRecipe, + keybindToggleDisplay, keybindClosePanes, keybindItemSelect}; public String viewItemAttemptID = null; public long viewItemAttemptTime = 0; @@ -63,24 +64,21 @@ public class NEUManager { private ResourceLocation wkZip = new ResourceLocation("notenoughupdates:wkhtmltox.zip"); private Map itemstackCache = new HashMap<>(); - private static final String AUCTIONS_PRICE_URL = "https://moulberry.github.io/files/auc_avg_jsons/average_3day.json.gz"; - private JsonObject auctionPricesJson = null; - private long auctionLastUpdate = 0; + //private static final String AUCTIONS_PRICE_URL = "https://moulberry.github.io/files/auc_avg_jsons/average_3day.json.gz"; + private static final String GIT_COMMITS_URL = "https://api.github.com/repos/Moulberry/NotEnoughUpdates-REPO/commits/master"; - private HashMap craftCost = new HashMap<>(); private HashMap> usagesMap = new HashMap<>(); public File configLocation; public File repoLocation; - private File itemShaLocation; - private JsonObject itemShaConfig; public File configFile; + public File itemRenameFile; + public JsonObject itemRenameJson; public Options config; - public NEUManager(NotEnoughUpdates neu, NEUIO neuio, File configLocation) { + public NEUManager(NotEnoughUpdates neu, File configLocation) { this.neu = neu; this.configLocation = configLocation; - this.neuio = neuio; this.auctionManager = new APIManager(this); GsonBuilder gsonBuilder = new GsonBuilder().setPrettyPrinting(); @@ -93,12 +91,11 @@ public class NEUManager { this.repoLocation = new File(configLocation, "repo"); repoLocation.mkdir(); - this.itemShaLocation = new File(configLocation, "itemSha.json"); - try { - itemShaLocation.createNewFile(); - itemShaConfig = getJsonFromFile(itemShaLocation); - if(itemShaConfig == null) itemShaConfig = new JsonObject(); - } catch(IOException e) { } + this.itemRenameFile = new File(configLocation, "itemRename.json"); + try { itemRenameJson = getJsonFromFile(itemRenameFile); } catch(IOException ignored) {} + if(itemRenameJson == null) { + itemRenameJson = new JsonObject(); + } File wkShell = new File(configLocation, "wkhtmltox/bin/wkhtmltoimage"); if(!wkShell.exists()) { @@ -110,12 +107,6 @@ public class NEUManager { } } - public class CraftInfo { - public boolean fromRecipe = false; - public boolean vanillaItem = false; - public float craftCost = -1; - } - public void setCurrentProfile(String currentProfile) { this.currentProfile = currentProfile; } @@ -132,85 +123,8 @@ public class NEUManager { } } - public boolean isVanillaItem(String internalname) { - //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; - } - } - vanillaName = vanillaName.substring(0, vanillaName.length()-sub).toLowerCase(); - return Item.itemRegistry.getObject(new ResourceLocation(vanillaName)) != null; - } - - /** - * Recursively calculates the cost of crafting an item from raw materials. - */ - public CraftInfo getCraftCost(String internalname) { - if(craftCost.containsKey(internalname)) { - return craftCost.get(internalname); - } else { - CraftInfo ci = new CraftInfo(); - - ci.vanillaItem = isVanillaItem(internalname); - - JsonObject auctionInfo = getItemAuctionInfo(internalname); - JsonObject bazaarInfo = getBazaarInfo(internalname); - - if(bazaarInfo != null) { - float bazaarInstantBuyPrice = bazaarInfo.get("curr_buy").getAsFloat(); - ci.craftCost = bazaarInstantBuyPrice; - } - if(auctionInfo != null && !ci.vanillaItem) { //Don't use auction prices for vanilla items cuz people like to transfer money, messing up the cost of vanilla items. - float auctionPrice = auctionInfo.get("price").getAsFloat() / auctionInfo.get("count").getAsFloat(); - if(ci.craftCost < 0 || auctionPrice < ci.craftCost) { - ci.craftCost = auctionPrice; - } - } - JsonObject item = getItemInformation().get(internalname); - if(item != null && item.has("recipe")) { - float craftPrice = 0; - JsonObject recipe = item.get("recipe").getAsJsonObject(); - - String[] x = {"1","2","3"}; - String[] y = {"A","B","C"}; - for(int i=0; i<9; i++) { - String name = y[i/3]+x[i%3]; - String itemS = recipe.get(name).getAsString(); - if(itemS.length() == 0) continue; - - int count = 1; - if(itemS != null && itemS.split(":").length == 2) { - count = Integer.valueOf(itemS.split(":")[1]); - itemS = itemS.split(":")[0]; - } - float compCost = getCraftCost(itemS).craftCost * count; - if(compCost < 0) { - if(!getCraftCost(itemS).vanillaItem) { //If it's a vanilla item without a cost attached to it, let compCost = 0. - craftCost.put(internalname, ci); - return ci; - } - } else { - craftPrice += compCost; - } - } - - if(ci.craftCost < 0 || craftPrice < ci.craftCost) { - ci.craftCost = craftPrice; - ci.fromRecipe = true; - } - } - craftCost.put(internalname, ci); - return ci; - } + public void saveItemRenameConfig() { + try { writeJson(itemRenameJson, itemRenameFile); } catch(IOException ignored) {} } public void saveConfig() throws IOException { @@ -227,130 +141,6 @@ public class NEUManager { } } - /** - * Downloads and sets auctionPricesJson from the URL specified by AUCTIONS_PRICE_URL. - */ - private ExecutorService es = Executors.newCachedThreadPool(); - public void updatePrices() { - if(System.currentTimeMillis() - auctionLastUpdate > 1000*60*120) { //2 hours - craftCost.clear(); - System.out.println("[NEU] UPDATING PRICE INFORMATION"); - auctionLastUpdate = System.currentTimeMillis(); - es.submit(() -> { - try(Reader inReader = new InputStreamReader(new GZIPInputStream(new URL(AUCTIONS_PRICE_URL).openStream()))) { - auctionPricesJson = gson.fromJson(inReader, JsonObject.class); - } catch (IOException e) { - e.printStackTrace(); - } - }); - } - } - - public boolean hasAuctionInfo(String internalname) { - if(auctionPricesJson == null) return false; - return auctionPricesJson.has("item_data") && auctionPricesJson.get("item_data").getAsJsonObject().has(internalname); - } - - public boolean hasBazaarInfo(String internalname) { - if(auctionPricesJson == null) return false; - return auctionPricesJson.has("bazaar") && auctionPricesJson.get("bazaar").getAsJsonObject().has(internalname); - } - - public JsonObject getItemAuctionInfo(String internalname) { - if(!hasAuctionInfo(internalname)) return null; - JsonElement e = auctionPricesJson.get("item_data").getAsJsonObject().get(internalname); - if(e == null) { - return null; - } - return e.getAsJsonObject(); - } - - public JsonObject getBazaarInfo(String internalname) { - if(!hasBazaarInfo(internalname)) return null; - JsonElement e = auctionPricesJson.get("bazaar").getAsJsonObject().get(internalname); - if(e == null) { - return null; - } - return e.getAsJsonObject(); - } - - /** - * Calculates the cost of enchants + other price modifiers such as pet xp, midas price, etc. - */ - public float getCostOfEnchants(String internalname, NBTTagCompound tag) { - float costOfEnchants = 0; - if(true) return 0; - - JsonObject info = getItemAuctionInfo(internalname); - if(info == null || !info.has("price")) { - return 0; - } - if(auctionPricesJson == null || !auctionPricesJson.has("ench_prices") || !auctionPricesJson.has("ench_maximums")) { - return 0; - } - JsonObject ench_prices = auctionPricesJson.getAsJsonObject("ench_prices"); - JsonObject ench_maximums = auctionPricesJson.getAsJsonObject("ench_maximums"); - if(!ench_prices.has(internalname) || !ench_maximums.has(internalname)) { - return 0; - } - JsonObject iid_variables = ench_prices.getAsJsonObject(internalname); - float ench_maximum = ench_maximums.get(internalname).getAsFloat(); - - int enchants = 0; - float price = getItemAuctionInfo(internalname).get("price").getAsFloat(); - if(tag.hasKey("ExtraAttributes")) { - NBTTagCompound ea = tag.getCompoundTag("ExtraAttributes"); - if(ea.hasKey("enchantments")) { - - NBTTagCompound enchs = ea.getCompoundTag("enchantments"); - for(String ench : enchs.getKeySet()) { - enchants++; - int level = enchs.getInteger(ench); - - for(Map.Entry entry : iid_variables.entrySet()) { - if(matchEnch(ench, level, entry.getKey())) { - costOfEnchants += entry.getValue().getAsJsonObject().get("A").getAsFloat()*price + - entry.getValue().getAsJsonObject().get("B").getAsFloat(); - break; - } - } - } -