diff options
| author | BuildTools <james.jenour@protonmail.com> | 2021-02-17 22:50:19 +0800 |
|---|---|---|
| committer | BuildTools <james.jenour@protonmail.com> | 2021-02-17 22:50:19 +0800 |
| commit | de834a97505c66b5655ee7ff91e78e84da3f81f3 (patch) | |
| tree | 93eb09a06d02501c060fb0401221d34a5bc24fd8 /src | |
| parent | a0e7d174472d034142003e58a42d6beefe36a92b (diff) | |
| download | NotEnoughUpdates-de834a97505c66b5655ee7ff91e78e84da3f81f3.tar.gz NotEnoughUpdates-de834a97505c66b5655ee7ff91e78e84da3f81f3.tar.bz2 NotEnoughUpdates-de834a97505c66b5655ee7ff91e78e84da3f81f3.zip | |
PRE22
Diffstat (limited to 'src')
21 files changed, 601 insertions, 342 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index adf204d1..4ba2cba9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -4,9 +4,12 @@ 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.auction.CustomAHGui; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; +import io.github.moulberry.notenoughupdates.core.util.MiscUtils; import io.github.moulberry.notenoughupdates.cosmetics.CapeManager; import io.github.moulberry.notenoughupdates.dungeons.DungeonBlocks; import io.github.moulberry.notenoughupdates.dungeons.DungeonWin; @@ -36,6 +39,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTUtil; import net.minecraft.util.*; import net.minecraftforge.client.event.*; import net.minecraftforge.event.entity.player.EntityInteractEvent; @@ -1318,6 +1322,8 @@ public class NEUEventListener { private boolean pressedArrowLast = false; private boolean pressedShiftLast = false; + private boolean copied = false; + @SubscribeEvent(priority = EventPriority.LOW) public void onItemTooltipLow(ItemTooltipEvent event) { if(!NotEnoughUpdates.INSTANCE.isOnSkyblock()) return; @@ -1573,6 +1579,9 @@ public class NEUEventListener { String comparator = GuiEnchantColour.getColourOpIndex(colourOps, 1); String comparison = GuiEnchantColour.getColourOpIndex(colourOps, 2); String colourCode = GuiEnchantColour.getColourOpIndex(colourOps, 3); + String modifier = GuiEnchantColour.getColourOpIndex(colourOps, 4); + + int modifierI = GuiEnchantColour.getIntModifier(modifier); if(enchantName.length() == 0) continue; if(comparator.length() == 0) continue; @@ -1663,18 +1672,40 @@ public class NEUEventListener { } } if(matches) { + String enchantText = matcher.group(2); + StringBuilder extraModifiersBuilder = new StringBuilder(); + + if((modifierI & GuiEnchantColour.BOLD_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.BOLD); + } + if((modifierI & GuiEnchantColour.ITALIC_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.ITALIC); + } + if((modifierI & GuiEnchantColour.UNDERLINE_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.UNDERLINE); + } + if((modifierI & GuiEnchantColour.OBFUSCATED_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.OBFUSCATED); + } + if((modifierI & GuiEnchantColour.STRIKETHROUGH_MODIFIER) != 0) { + extraModifiersBuilder.append(EnumChatFormatting.STRIKETHROUGH); + } + + String extraMods = extraModifiersBuilder.toString(); + if(!colourCode.equals("z")) { - line = line.replace("\u00A79"+matcher.group(2), "\u00A7"+colourCode+matcher.group(2)); - line = line.replace("\u00A79\u00A7d\u00A7l"+matcher.group(2), "\u00A7"+colourCode+ - EnumChatFormatting.BOLD+matcher.group(2)); + line = line.replace("\u00A79"+enchantText, + "\u00A7"+colourCode+extraMods+enchantText); + line = line.replace("\u00A79\u00A7d\u00A7l"+enchantText, + "\u00A7"+colourCode+extraMods+enchantText); } else { int offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll( - "\\u00A79"+matcher.group(2)+".*", "")); - line = line.replace("\u00A79"+matcher.group(2), Utils.chromaString(matcher.group(2), offset/12f+index, false)); + "\\u00A79"+enchantText+".*", "")); + line = line.replace("\u00A79"+enchantText, Utils.chromaString(enchantText, offset/12f+index, false)); offset = Minecraft.getMinecraft().fontRendererObj.getStringWidth(line.replaceAll( - "\\u00A79\\u00A7d\\u00A7l"+matcher.group(2)+".*", "")); - line = line.replace("\u00A79\u00A7d\u00A7l"+matcher.group(2), Utils.chromaString(matcher.group(2), + "\\u00A79\\u00A7d\\u00A7l"+enchantText+".*", "")); + line = line.replace("\u00A79\u00A7d\u00A7l"+enchantText, Utils.chromaString(enchantText, offset/12f+index, true)); } } @@ -1924,8 +1955,8 @@ public class NEUEventListener { } } }*/ - if(!Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || !neu.config.hidden.dev) return; - if(event.toolTip.size()>0&&event.toolTip.get(event.toolTip.size()-1).startsWith(EnumChatFormatting.DARK_GRAY + "NBT: ")) { + if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && neu.config.hidden.dev && + event.toolTip.size()>0&&event.toolTip.get(event.toolTip.size()-1).startsWith(EnumChatFormatting.DARK_GRAY + "NBT: ")) { event.toolTip.remove(event.toolTip.size()-1); StringBuilder sb = new StringBuilder(); @@ -1954,8 +1985,60 @@ public class NEUEventListener { } event.toolTip.add(sb.toString()); if(Keyboard.isKeyDown(Keyboard.KEY_H)) { - StringSelection selection = new StringSelection(sb.toString()); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); + if(!copied) { + copied = true; + StringSelection selection = new StringSelection(sb.toString()); + Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); + } + } else { + copied = false; + } + } else if(NotEnoughUpdates.INSTANCE.packDevEnabled) { + event.toolTip.add(""); + event.toolTip.add(EnumChatFormatting.AQUA+"NEU Pack Dev Info:"); + event.toolTip.add("Press "+EnumChatFormatting.GOLD+"[KEY]"+EnumChatFormatting.GRAY+" to copy line"); + + String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(event.itemStack); + + boolean k = Keyboard.isKeyDown(Keyboard.KEY_K); + boolean m = Keyboard.isKeyDown(Keyboard.KEY_M); + boolean n = Keyboard.isKeyDown(Keyboard.KEY_N); + + event.toolTip.add(EnumChatFormatting.AQUA+"Internal Name: "+EnumChatFormatting.GRAY+internal+EnumChatFormatting.GOLD+" [K]"); + if(!copied && k) { + MiscUtils.copyToClipboard(internal); + } + + if(event.itemStack.getTagCompound() != null) { + NBTTagCompound tag = event.itemStack.getTagCompound(); + + if (tag.hasKey("SkullOwner", 10)) { + GameProfile gameprofile = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("SkullOwner")); + + if(gameprofile != null) { + event.toolTip.add(EnumChatFormatting.AQUA+"Skull UUID: "+EnumChatFormatting.GRAY+gameprofile.getId()+EnumChatFormatting.GOLD+" [M]"); + if(!copied && m) { + MiscUtils.copyToClipboard(gameprofile.getId().toString()); + } + + Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> map = Minecraft.getMinecraft().getSkinManager().loadSkinFromCache(gameprofile); + + if (map.containsKey(MinecraftProfileTexture.Type.SKIN)) { + MinecraftProfileTexture profTex = map.get(MinecraftProfileTexture.Type.SKIN); + event.toolTip.add(EnumChatFormatting.AQUA+"Skull Texture Link: "+EnumChatFormatting.GRAY+profTex.getUrl()+EnumChatFormatting.GOLD+" [N]"); + + if(!copied && n) { + MiscUtils.copyToClipboard(profTex.getUrl()); + } + } + } + } + } + + if(k || m || n) { + copied = true; + } else { + copied = false; } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 55ba7756..447dc8d1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -668,6 +668,52 @@ public class NotEnoughUpdates { } }); + private static final String[] devFailStrings = {"No.", "I said no.", "You aren't allowed to use this.", + "Are you sure you want to use this? Type 'Yes' in chat.", "Lmao you thought", "Ok please stop", + "What do you want from me?", "This command almost certainly does nothing useful for you", + "Ok, this is the last message, after this it will repeat", "No.", "Dammit. I thought that would work. Uhh...", + "\u00a7dFrom \u00a7c[ADMIN] Minikloon\u00a77: If you use that command again, I'll have to ban you", + "Ok, this is actually the last message, use the command again and you'll crash I promise"}; + private int devFailIndex = 0; + SimpleCommand devTestCommand = new SimpleCommand("neudevtest", new SimpleCommand.ProcessCommandRunnable() { + @Override + public void processCommand(ICommandSender sender, String[] args) { + if(!Minecraft.getMinecraft().thePlayer.getName().equalsIgnoreCase("Moulberry")) { + if(devFailIndex >= devFailStrings.length) { + throw new Error("L") { + @Override + public void printStackTrace() { + throw new Error("Double L"); + } + }; + } + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+devFailStrings[devFailIndex++])); + return; + } + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Executing dubious code")); + /*Minecraft.getMinecraft().thePlayer.rotationYaw = 0; + Minecraft.getMinecraft().thePlayer.rotationPitch = 0; + Minecraft.getMinecraft().thePlayer.setPosition( + Math.floor(Minecraft.getMinecraft().thePlayer.posX) + Float.parseFloat(args[0]), + Minecraft.getMinecraft().thePlayer.posY, + Minecraft.getMinecraft().thePlayer.posZ);*/ + //Hot reload me yay! + } + }); + + public boolean packDevEnabled = false; + SimpleCommand packDevCommand = new SimpleCommand("neupackdev", new SimpleCommand.ProcessCommandRunnable() { + @Override + public void processCommand(ICommandSender sender, String[] args) { + packDevEnabled = !packDevEnabled; + if(packDevEnabled) { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN+"Enabled pack developer mode.")); + } else { + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED+"Disabled pack developer mode.")); + } + } + }); + SimpleCommand dnCommand = new SimpleCommand("dn", new SimpleCommand.ProcessCommandRunnable() { @Override public void processCommand(ICommandSender sender, String[] args) { @@ -888,8 +934,6 @@ public class NotEnoughUpdates { String uuid = Minecraft.getMinecraft().getSession().getPlayerID(); if(uuid.equalsIgnoreCase("ea9b1c5a-bf68-4fa2-9492-2d4e69693228")) throw new RuntimeException("Ding-dong, racism is wrong."); - if(uuid.equalsIgnoreCase("1f4bc571-783a-490a-8ef6-54d18bb72c7c")) throw new RuntimeException("Oops misclicked"); - if(uuid.equalsIgnoreCase("784747a0-3ac9-4ad6-bc75-8cf1bc9d7080")) throw new RuntimeException("Oops did it again"); neuDir = new File(event.getModConfigurationDirectory(), "notenoughupdates"); neuDir.mkdirs(); @@ -945,6 +989,8 @@ public class NotEnoughUpdates { ClientCommandHandler.instance.registerCommand(viewProfileShortCommand); ClientCommandHandler.instance.registerCommand(dhCommand); ClientCommandHandler.instance.registerCommand(dnCommand); + ClientCommandHandler.instance.registerCommand(devTestCommand); + ClientCommandHandler.instance.registerCommand(packDevCommand); if(!Loader.isModLoaded("skyblockextras")) ClientCommandHandler.instance.registerCommand(viewCataCommand); ClientCommandHandler.instance.registerCommand(peekCommand); ClientCommandHandler.instance.registerCommand(tutorialCommand); 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 c0f48b87..6bd8418d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -43,7 +43,7 @@ public class CapeManager { private boolean allAvailable = false; private HashSet<String> availableCapes = new HashSet<>(); - private JsonObject lastJsonSync = null; + public JsonObject lastJsonSync = null; private String[] capes = new String[]{"patreon1", "patreon2", "fade", "contrib", "nullzee", "gravy", "space", "mcworld", "lava", "packshq", "mbstaff", "thebakery", "negative", "void", "ironmoon", "krusty", "furf" }; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java index f6b5b722..019fe9ee 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -1149,6 +1149,7 @@ public class DungeonMap { } } } + actualPlayers.add(Minecraft.getMinecraft().thePlayer.getName()); playerEntityMapPositions.clear(); if(usePlayerPositions) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java index e198e8e5..8eb3430b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java @@ -14,6 +14,9 @@ import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -47,6 +50,11 @@ public class CustomItemEffects { public long lastUsedHyperion = 0; + private boolean heldBonemerang = false; + + public final Set<EntityLivingBase> bonemeragedEntities = new HashSet<>(); + public boolean bonemerangBreak = false; + public int aoteTeleportationMillis = 0; public Vector3f aoteTeleportationCurr = null; @@ -150,84 +158,150 @@ public class CustomItemEffects { } @SubscribeEvent - public void onOverlayDrawn(RenderGameOverlayEvent event) { - if(NotEnoughUpdates.INSTANCE.config.builderWand.enableWandOverlay && - Minecraft.getMinecraft().objectMouseOver != null && - Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && - ((event.type == null && Loader.isModLoaded("labymod")) || - event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS)) { + public void onGameTick(TickEvent.ClientTickEvent event) { + if(event.phase != TickEvent.Phase.END) return; - IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState( - Minecraft.getMinecraft().objectMouseOver.getBlockPos().offset( - Minecraft.getMinecraft().objectMouseOver.sideHit, 1)); - if(hover.getBlock() == Blocks.air) { - ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); - String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); + heldBonemerang = false; + bonemerangBreak = false; + bonemeragedEntities.clear(); + if(Minecraft.getMinecraft().thePlayer == null) return; + if(Minecraft.getMinecraft().theWorld == null) return; - if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); - HashSet<BlockPos> candidatesOld = new HashSet<>(); - TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>(); - - IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos()); - Item matchItem = Item.getItemFromBlock(match.getBlock()); - if(matchItem != null) { - ItemStack matchStack = new ItemStack(matchItem, 1, - match.getBlock().getDamageValue(Minecraft.getMinecraft().theWorld, Minecraft.getMinecraft().objectMouseOver.getBlockPos())); - - getBuildersWandCandidates(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().objectMouseOver, event.partialTicks, - candidatesOld, candidatesOldSorted, 999-MAX_BUILDERS_BLOCKS); - - boolean usingDirtWand = false; - int itemCount; - if(match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) { - itemCount = candidatesOld.size(); - usingDirtWand = true; - } else { - itemCount = countItemsInInventoryAndStorage(matchStack); - } + String internal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); + if(internal != null && internal.equals("BONE_BOOMERANG")) { + heldBonemerang = true; + + EntityPlayerSP p = Minecraft.getMinecraft().thePlayer; + float stepSize = 0.15f; + float bonemerangDistance = 15; + + Vector3f position = new Vector3f((float)p.posX, (float)p.posY + p.getEyeHeight(), (float)p.posZ); + Vec3 look = p.getLook(0); + + Vector3f step = new Vector3f((float)look.xCoord, (float)look.yCoord, (float)look.zCoord); + step.scale(stepSize / step.length()); + + for(int i=0; i<Math.floor(bonemerangDistance/stepSize)-2; i++) { + AxisAlignedBB bb = new AxisAlignedBB(position.x - 0.75f, position.y - 0.1, position.z - 0.75f, + position.x + 0.75f, position.y + 0.25, position.z + 0.75); - if(candidatesOld.size() > MAX_BUILDERS_BLOCKS) { - Utils.drawStringCentered(EnumChatFormatting.RED.toString()+candidatesOld.size()+"/"+MAX_BUILDERS_BLOCKS, - Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0); - } else { - String pre = EnumChatFormatting.GREEN.toString(); - if(itemCount < candidatesOld.size()) { - pre = EnumChatFormatting.RED.toString(); + BlockPos blockPos = new BlockPos(position.x, position.y, position.z); + + if(!Minecraft.getMinecraft().theWorld.isAirBlock(blockPos) && + Minecraft.getMinecraft().theWorld.getBlockState(blockPos).getBlock().isFullCube()) { + if(NotEnoughUpdates.INSTANCE.config.bonemerangOverlay.showBreak) { + bonemerangBreak = true; + } + break; + } + + if(NotEnoughUpdates.INSTANCE.config.bonemerangOverlay.highlightTargeted) { + List<Entity> entities = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(Minecraft.getMinecraft().thePlayer, bb); + for(Entity entity : entities) { + if(entity instanceof EntityLivingBase && !(entity instanceof EntityArmorStand)) { + if(!bonemeragedEntities.contains(entity)) { + bonemeragedEntities.add((EntityLivingBase)entity); } - Utils.drawStringCentered(pre+Math.min(candidatesOld.size(), itemCount)+"/"+ - Math.min(candidatesOld.size(), MAX_BUILDERS_BLOCKS), - Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0); } + } + } + + position.translate(step.x, step.y, step.z); + } + } + - String itemCountS = EnumChatFormatting.DARK_GRAY+"x"+EnumChatFormatting.RESET+itemCount; - int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS); - - if(NotEnoughUpdates.INSTANCE.config.builderWand.wandBlockCount) { - if(usingDirtWand) { - Utils.drawItemStack(new ItemStack(Items.gold_nugget), scaledResolution.getScaledWidth()/2 - (itemCountLen+16)/2, - scaledResolution.getScaledHeight()/2+10+4); - Minecraft.getMinecraft().fontRendererObj.drawString(itemCountS, - scaledResolution.getScaledWidth()/2f - (itemCountLen+16)/2f+11, scaledResolution.getScaledHeight()/2f+10+8, - -1, - true); + } + + @SubscribeEvent + public void onOverlayDrawn(RenderGameOverlayEvent.Post event) { + if(((event.type == null && Loader.isModLoaded("labymod")) || + event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS)) { + if(heldBonemerang) { + if(bonemerangBreak) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + Utils.drawStringCentered(EnumChatFormatting.RED+"Bonemerang will break!", + Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0); + } + } else if(NotEnoughUpdates.INSTANCE.config.builderWand.enableWandOverlay && + Minecraft.getMinecraft().objectMouseOver != null && + Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + + IBlockState hover = Minecraft.getMinecraft().theWorld.getBlockState( + Minecraft.getMinecraft().objectMouseOver.getBlockPos().offset( + Minecraft.getMinecraft().objectMouseOver.sideHit, 1)); + if(hover.getBlock() == Blocks.air) { + ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem(); + String heldInternal = NotEnoughUpdates.INSTANCE.manager.getInternalNameForItem(held); + + if(heldInternal != null && heldInternal.equals("BUILDERS_WAND")) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + + HashSet<BlockPos> candidatesOld = new HashSet<>(); + TreeMap<Float, Set<BlockPos>> candidatesOldSorted = new TreeMap<>(); + + IBlockState match = Minecraft.getMinecraft().theWorld.getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos()); + Item matchItem = Item.getItemFromBlock(match.getBlock()); + if(matchItem != null) { + ItemStack matchStack = new ItemStack(matchItem, 1, + match.getBlock().getDamageValue(Minecraft.getMinecraft().theWorld, Minecraft.getMinecraft().objectMouseOver.getBlockPos())); + + getBuildersWandCandidates(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().objectMouseOver, event.partialTicks, + candidatesOld, candidatesOldSorted, 999-MAX_BUILDERS_BLOCKS); + + boolean usingDirtWand = false; + int itemCount; + if(match.getBlock() == Blocks.dirt && matchStack.getItemDamage() == 0 && hasDirtWand()) { + itemCount = candidatesOld.size(); + usingDirtWand = true; } else { - Utils.drawItemStack(matchStack, scaledResolution.getScaledWidth()/2 - (itemCountLen+16)/2, - scaledResolution.getScaledHeight()/2+10+4); - Minecraft.getMinecraft().fontRendererObj.drawString(itemCountS, - scaledResolution.getScaledWidth()/2f - (itemCountLen+16)/2f+16, scaledResolution.getScaledHeight()/2f+10+8, - -1, - true); + itemCount = countItemsInInventoryAndStorage(matchStack); } + if(candidatesOld.size() > MAX_BUILDERS_BLOCKS) { + Utils.drawStringCentered(EnumChatFormatting.RED.toString()+candidatesOld.size()+"/"+MAX_BUILDERS_BLOCKS, + Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0); + } else { + String pre = EnumChatFormatting.GREEN.toString(); + if(itemCount < candidatesOld.size()) { + pre = EnumChatFormatting.RED.toString(); + } + Utils.drawStringCentered(pre+Math.min(candidatesOld.size(), itemCount)+"/"+ + Math.min(candidatesOld.size(), MAX_BUILDERS_BLOCKS), + Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth()/2f, scaledResolution.getScaledHeight()/2f+10, true, 0); + } + + String itemCountS = EnumChatFormatting.DARK_GRAY+"x"+EnumChatFormatting.RESET+itemCount; + int itemCountLen = Minecraft.getMinecraft().fontRendererObj.getStringWidth(itemCountS); + + if(NotEnoughUpdates.INSTANCE.config.builderWand.wandBlockCount) { + if(usingDirtWand) { + Utils.drawItemStack(new ItemStack(Items.gold_nugget), scaledResolution.getScaledWidth()/2 - (itemCountLen+16)/2, + scaledResolution.getScaledHeight()/2+10+4); + Minecraft.getMinecraft().fontRendererObj.drawString(itemCountS, + scaledResolution.getScaledWidth()/2f - (itemCountLen+16)/2f+11, scaledResolution.getScaledHeight()/2f+10+8, + -1, + true); |
