From f86196a74db27d5492020e514b6c0d819b82fdc2 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Tue, 24 Aug 2021 20:02:25 +0200 Subject: fixes --- .../notenoughupdates/NEUEventListener.java | 1 - .../miscfeatures/CustomItemEffects.java | 60 +++++++++++------- .../profileviewer/GuiProfileViewer.java | 72 ++++++++++++++-------- 3 files changed, 83 insertions(+), 50 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java index 6aa292eb..08ef97a9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUEventListener.java @@ -838,7 +838,6 @@ public class NEUEventListener { if(unformatted.startsWith("[NPC] Keeper of ") | unformatted.startsWith("[NPC] Professor Robot: ") || unformatted.startsWith(" ") || unformatted.startsWith("✦") || unformatted.equals(" You've earned a Crystal Loot Bundle!")) OverlayManager.crystalHollowOverlay.message(unformatted); - System.out.println(unformatted); } public static boolean drawingGuiScreen = false; 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 3ca05dea..0f4e2f4d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CustomItemEffects.java @@ -45,6 +45,8 @@ import java.awt.*; import java.io.ByteArrayInputStream; import java.util.*; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class CustomItemEffects { @@ -59,7 +61,7 @@ public class CustomItemEffects { public long lastUsedHyperion = 0; - + private final Pattern etherwarpDistancePattern = Pattern.compile("up to (?\\d{2}) blocks away\\."); public int aoteTeleportationMillis = 0; public Vector3f aoteTeleportationCurr = null; @@ -262,7 +264,10 @@ public class CustomItemEffects { denyTpReason = "Not solid!"; } else { WorldClient world = Minecraft.getMinecraft().theWorld; - if(world.getBlockState(pos.add(0, 1, 0)).getBlock() != Blocks.air || + Block above = world.getBlockState(pos.add(0, 1, 0)).getBlock(); + if(above != Blocks.air && above.isCollidable() && + above.getCollisionBoundingBox(Minecraft.getMinecraft().theWorld, pos.add(0, 1, 0), + world.getBlockState(pos.add(0, 1, 0))) != null || world.getBlockState(pos.add(0, 2, 0)).getBlock() != Blocks.air) { denyTpReason = "No air above!"; } @@ -543,34 +548,45 @@ public class CustomItemEffects { } if(usingEtherwarp) { - etherwarpRaycast = raycast(Minecraft.getMinecraft().thePlayer, 1f, 60, 0.1f); + int dist = 0; + for (String line : NotEnoughUpdates.INSTANCE.manager.getLoreFromNBT(held.getTagCompound())) { + String cleaned = Utils.cleanColour(line); + Matcher matcher = etherwarpDistancePattern.matcher(cleaned); + if (matcher.matches()) { + dist = Integer.parseInt(matcher.group("distance")); + break; + } + } + if (dist != 0) { + etherwarpRaycast = raycast(Minecraft.getMinecraft().thePlayer, 1f, dist, 0.1f); - if(etherwarpRaycast != null) { - AxisAlignedBB bb = etherwarpRaycast.state.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, etherwarpRaycast.pos) - .expand(0.01D, 0.01D, 0.01D).offset(-d0, -d1, -d2); - drawFilledBoundingBox(bb, 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour); + if (etherwarpRaycast != null) { + AxisAlignedBB bb = etherwarpRaycast.state.getBlock().getSelectedBoundingBox(Minecraft.getMinecraft().theWorld, etherwarpRaycast.pos) + .expand(0.01D, 0.01D, 0.01D).offset(-d0, -d1, -d2); + drawFilledBoundingBox(bb, 1f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour); - GlStateManager.disableDepth(); - drawOutlineBoundingBox(bb, 2f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour); - GlStateManager.enableDepth(); + GlStateManager.disableDepth(); + drawOutlineBoundingBox(bb, 2f, NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpHighlightColour); + GlStateManager.enableDepth(); - GlStateManager.depthMask(true); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); + GlStateManager.depthMask(true); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); - if(NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) { - float distFactor = 1 - (float)Math.sqrt(etherwarpRaycast.pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition()))/60; + if (NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) { + float distFactor = 1 - (float) Math.sqrt(etherwarpRaycast.pos.distanceSq(Minecraft.getMinecraft().thePlayer.getPosition())) / 60; - targetFOVMult = distFactor*distFactor*distFactor*0.75f + 0.25f; - if(targetFOVMult < 0.25f) targetFOVMult = 0.25f; + targetFOVMult = distFactor * distFactor * distFactor * 0.75f + 0.25f; + if (targetFOVMult < 0.25f) targetFOVMult = 0.25f; - targetSensMult = distFactor*0.76f + 0.25f; + targetSensMult = distFactor * 0.76f + 0.25f; + } + } else if (NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) { + targetFOVMult = lastFOVMult; } - } else if(NotEnoughUpdates.INSTANCE.config.itemOverlays.etherwarpZoom) { - targetFOVMult = lastFOVMult; - } - return; + return; + } } } } 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 51810c2d..11a5574d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -11,15 +11,17 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.cosmetics.ShaderManager; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; -import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Constants; +import io.github.moulberry.notenoughupdates.util.SBInfo; 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.*; +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; @@ -32,7 +34,9 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.*; -import net.minecraft.util.*; +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; @@ -49,8 +53,8 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; -import java.util.*; import java.util.List; +import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; @@ -1340,6 +1344,8 @@ public class GuiProfileViewer extends GuiScreen { String petname = pet.get("type").getAsString(); String tier = pet.get("tier").getAsString(); String heldItem = Utils.getElementAsString(pet.get("heldItem"), null); + String skin = Utils.getElementAsString(pet.get("skin"), null); + int candy = pet.get("candyUsed").getAsInt(); JsonObject heldItemJson = heldItem==null?null:NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(heldItem); String tierNum = MINION_RARITY_TO_NUM.get(tier); float exp = pet.get("exp").getAsFloat(); @@ -1407,6 +1413,22 @@ public class GuiProfileViewer extends GuiScreen { newLore.appendTag(new NBTTagString(line)); } Integer secondLastBlank = blankLocations.get(blankLocations.size()-2); + if(skin != null){ + JsonObject petSkin = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("PET_SKIN_" + skin); + if(petSkin != null){ + try { + NBTTagCompound nbt = JsonToNBT.getTagFromJson(petSkin.get("nbttag").getAsString()); + tag.setTag("SkullOwner", nbt.getTag("SkullOwner")); + String name = petSkin.get("displayname").getAsString(); + if(name != null){ + name = Utils.cleanColour(name); + newLore.set(0, new NBTTagString(newLore.get(0).toString().replace("\"" , "") + ", " + name)); + } + } catch (NBTException e) { + e.printStackTrace(); + } + } + } if(heldItemJson != null && secondLastBlank != null) { for(int j=0; j minions = ProfileViewer.getCollectionCatToMinionMap().get(selectedCollectionCategory); if(minions != null) { for(int i=0; i