diff options
author | Vixid <52578495+VixidDev@users.noreply.github.com> | 2023-02-11 11:42:16 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-11 12:42:16 +0100 |
commit | e87331858675faed39a090cfdd6f6c7ce3b3f0d0 (patch) | |
tree | 09ce0f53a19f17dc54f4ba723f4a81713183cff0 /src | |
parent | 1d1017c55492175b8a2c2329d8c050c71c45ccfe (diff) | |
download | NotEnoughUpdates-e87331858675faed39a090cfdd6f6c7ce3b3f0d0.tar.gz NotEnoughUpdates-e87331858675faed39a090cfdd6f6c7ce3b3f0d0.tar.bz2 NotEnoughUpdates-e87331858675faed39a090cfdd6f6c7ce3b3f0d0.zip |
Frozen treasure pet conflict fix (#571)
* Added Highest Wave completed to Kuudra stats in pv
* Revert "Added Highest Wave completed to Kuudra stats in pv"
This reverts commit 83f78a9815f9d9c682dd5e452e001d853fd78922.
* Resolves Frozen Treasure Highlighter thinking pets are treasures. (I hope)
* Fixes bug with empty tag compounds
---------
Co-authored-by: Vixid <52578495+vixid1@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/FrozenTreasuresHighlighter.java | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/FrozenTreasuresHighlighter.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/FrozenTreasuresHighlighter.java index 2f8071a0..1a541433 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/FrozenTreasuresHighlighter.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/world/FrozenTreasuresHighlighter.java @@ -28,11 +28,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import java.util.ArrayList; +import java.util.Base64; import java.util.List; @NEUAutoSubscribe @@ -40,6 +43,15 @@ public class FrozenTreasuresHighlighter extends GenericBlockHighlighter { private static final FrozenTreasuresHighlighter INSTANCE = new FrozenTreasuresHighlighter(); + private static final List<String> rideablePetTextureUrls = new ArrayList<String>() {{ + // Armadillo + add("http://textures.minecraft.net/texture/c1eb6df4736ae24dd12a3d00f91e6e3aa7ade6bbefb0978afef2f0f92461018f"); + // Rock + add("http://textures.minecraft.net/texture/cb2b5d48e57577563aca31735519cb622219bc058b1f34648b67b8e71bc0fa"); + // Rat + add("http://textures.minecraft.net/texture/a8abb471db0ab78703011979dc8b40798a941f3a4dec3ec61cbeec2af8cffe8"); + }}; + public static FrozenTreasuresHighlighter getInstance() {return INSTANCE;} @Override @@ -62,10 +74,46 @@ public class FrozenTreasuresHighlighter extends GenericBlockHighlighter { World w = Minecraft.getMinecraft().theWorld; if (w == null) return; List<Entity> entities = w.getLoadedEntityList(); - for (Entity e : entities) { - if ((e instanceof EntityArmorStand) && ((EntityArmorStand) e).getCurrentArmor(3) != null) highlightedBlocks.add(e - .getPosition() - .add(0, 1, 0)); + for (Entity entity : entities) { + if ((entity instanceof EntityArmorStand) && + ((EntityArmorStand) entity).getCurrentArmor(3) != null) { + + // If an armor stand has a 'hat' with a NBTTagCompound check if it has a pet texture url + if (((EntityArmorStand) entity).getCurrentArmor(3).hasTagCompound()) { + NBTTagCompound nbtTagCompound = ((EntityArmorStand) entity).getCurrentArmor(3).getTagCompound(); + + // Get Base64 texture value from the tag compound + String textureValue = nbtTagCompound + .getCompoundTag("SkullOwner") + .getCompoundTag("Properties") + .getTagList("textures", 10) + .getCompoundTagAt(0) + .getString("Value"); + + // Decode and find texture url from the texture value + String trimmedJson = new String(Base64.getDecoder().decode(textureValue)).replace(" ", ""); + + + String textureUrl = ""; + if (trimmedJson.contains("url")) { + textureUrl = trimmedJson.substring( + trimmedJson.indexOf("url")+6, // Start of url + trimmedJson.substring( // Get the substring from the start of the url to the end of string + trimmedJson.indexOf("url")+6).indexOf("\"") // Get index of first " after start of url + + trimmedJson.indexOf("url")+6); // Add on the length of numbers up until the start of url to get correct index from overall string + } + + + // If the list of rideable pet texture urls doesn't include the found texture then it is a frozen treasure + if (!rideablePetTextureUrls.contains(textureUrl)) { + highlightedBlocks.add(entity.getPosition().add(0, 1, 0)); + } + } else { + // This is for frozen treasures which are just blocks i.e. Packed Ice, Enchanted Packed Ice etc. + // (Since I don't believe the blocks have NBTTagCompound data) + highlightedBlocks.add(entity.getPosition().add(0, 1, 0)); + } + } } } |