From 6cafb6fd76c0ac5ca7be4371eb2bba5f719be4f4 Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Fri, 23 Jun 2023 11:56:32 +0200 Subject: Various rift related changes (#724) --- .../moulberry/notenoughupdates/NEUOverlay.java | 6 +++ .../entityviewer/EquipmentModifier.java | 3 ++ .../profileviewer/trophy/TrophyFishPage.java | 27 ++++++++++---- .../recipes/generators/NPCLocationExporter.kt | 43 ++++++++++++++++------ 4 files changed, 59 insertions(+), 20 deletions(-) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index c6f0785d..f7f0049f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -1150,6 +1150,8 @@ public class NEUOverlay extends Gui { } else if (keyPressed == manager.keybindViewRecipe.getKeyCode()) { manager.showRecipe(item); return true; + } else if (keyPressed == NotEnoughUpdates.INSTANCE.config.misc.keybindWaypoint && NotEnoughUpdates.INSTANCE.navigation.isValidWaypoint(item)) { + NotEnoughUpdates.INSTANCE.navigation.trackWaypoint(item); } else if (keyPressed == manager.keybindGive.getKeyCode()) { if (Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode) { Minecraft.getMinecraft().thePlayer.inventory.addItemStackToInventory( @@ -2222,12 +2224,16 @@ public class NEUOverlay extends Gui { (json.has("clickcommand") && !json.get("clickcommand").getAsString().isEmpty()) || !manager.getAvailableRecipesFor(internalname).isEmpty(); boolean hasInfo = json.has("info") && json.get("info").getAsJsonArray().size() > 0; + boolean hasWaypoint = NotEnoughUpdates.INSTANCE.navigation.isValidWaypoint(json); if (hasClick || hasInfo) text.add(""); if (hasClick) text.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "LMB/R : View recipe!"); if (hasInfo) text.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + "RMB : View additional information!"); + if (hasWaypoint) + text.add(EnumChatFormatting.YELLOW.toString() + EnumChatFormatting.BOLD + + Keyboard.getKeyName(NotEnoughUpdates.INSTANCE.config.misc.keybindWaypoint) + " : Set waypoint!"); textToDisplay = text; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java index 685e161a..6f0d7b93 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EquipmentModifier.java @@ -22,6 +22,7 @@ package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -35,6 +36,8 @@ public class EquipmentModifier extends EntityViewerModifier { String[] split = item.split("#"); if (split.length == 2) { switch (split[0].intern()) { + case "SKULL": + return Utils.createSkull("Placeholder Skull", "00000000-0000-0000-0000-000000000000", split[1]); case "LEATHER_LEGGINGS": return coloredLeatherArmor(Items.leather_leggings, split[1]); case "LEATHER_HELMET": diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java index 9aaf65a4..2695f8d0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/trophy/TrophyFishPage.java @@ -40,11 +40,13 @@ import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.opengl.GL11; import java.util.ArrayList; +import java.util.Comparator; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import static io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer.pv_elements; @@ -210,21 +212,23 @@ public class TrophyFishPage extends GuiProfileViewerPage { RenderHelper.enableGUIStandardItemLighting(); Minecraft.getMinecraft().getTextureManager().bindTexture(pv_elements); Map trophyFishRarityIntegerMap = value.getTrophyFishRarityIntegerMap(); - if (trophyFishRarityIntegerMap.containsKey(TrophyFish.TrophyFishRarity.BRONZE)) { + TrophyFish.TrophyFishRarity highestRarity = getHighestRarity(trophyFishRarityIntegerMap).orElse(null); + + if (highestRarity == TrophyFish.TrophyFishRarity.BRONZE) { GlStateManager.color(255 / 255f, 130 / 255f, 0 / 255f, 1); } - if (trophyFishRarityIntegerMap.containsKey(TrophyFish.TrophyFishRarity.SILVER)) { + if (highestRarity == TrophyFish.TrophyFishRarity.SILVER) { GlStateManager.color(192 / 255f, 192 / 255f, 192 / 255f, 1); } - if (trophyFishRarityIntegerMap.containsKey(TrophyFish.TrophyFishRarity.GOLD)) { + if (highestRarity == TrophyFish.TrophyFishRarity.GOLD) { GlStateManager.color(1, 0.82F, 0, 1); } - if (trophyFishRarityIntegerMap.containsKey(TrophyFish.TrophyFishRarity.DIAMOND)) { + if (highestRarity == TrophyFish.TrophyFishRarity.DIAMOND) { GlStateManager.color(31 / 255f, 216 / 255f, 241 / 255f, 1); } Utils.drawTexturedRect(x - 2, y - 2, 20, 20, 0, 20 / 256f, 0, 20 / 256f, GL11.GL_NEAREST); GlStateManager.color(1, 1, 1, 1); - Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(getItem(value.getName()), x, y); + Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(getItem(value.getName(), highestRarity), x, y); if (mouseX >= x && mouseX < x + 24) { if (mouseY >= y && mouseY <= y + 24) { @@ -357,14 +361,21 @@ public class TrophyFishPage extends GuiProfileViewerPage { } if (trophyFishRarityIntegerMap.containsKey(rarity)) { - return color + name + ": " + EnumChatFormatting.GOLD + StringUtils.formatNumber(trophyFishRarityIntegerMap.get(rarity)); + return color + name + ": " + EnumChatFormatting.GOLD + StringUtils.formatNumber(trophyFishRarityIntegerMap.get( + rarity)); } else { return color + name + ": " + checkX; } } - private ItemStack getItem(String name) { - String repoName = name.toUpperCase(Locale.US).replace(" ", "_") + "_BRONZE"; + private Optional getHighestRarity(Map trophyFishRarityMap) { + if (trophyFishRarityMap == null) return Optional.empty(); + return trophyFishRarityMap.keySet().stream().max(Comparator.comparing(Enum::ordinal)); + } + + private ItemStack getItem(String name, TrophyFish.TrophyFishRarity highestCaughtRarity) { + String repoName = name.toUpperCase(Locale.US).replace(" ", "_") + "_" + + (highestCaughtRarity == null ? "BRONZE" : highestCaughtRarity.name()); JsonObject jsonItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(repoName); return NotEnoughUpdates.INSTANCE.manager.jsonToStack(jsonItem); } diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/NPCLocationExporter.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/NPCLocationExporter.kt index 7acd88a9..9df738ca 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/NPCLocationExporter.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/NPCLocationExporter.kt @@ -32,7 +32,9 @@ import net.minecraft.client.Minecraft import net.minecraft.client.entity.AbstractClientPlayer import net.minecraft.client.gui.GuiScreen import net.minecraft.client.renderer.GlStateManager +import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.passive.EntityVillager +import net.minecraft.item.ItemStack import net.minecraft.util.BlockPos import net.minecraftforge.client.event.MouseEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -41,9 +43,18 @@ import java.util.* @NEUAutoSubscribe class NPCLocationExporter { - class NPCNamePrompt(val uuid: UUID, val position: BlockPos, val island: String, val skinId: String) : GuiScreen() { + class NPCNamePrompt(val uuid: UUID, val position: BlockPos, val island: String, val itemStack: ItemStack) : + GuiScreen() { + constructor(uuid: UUID, position: BlockPos, island: String, skinId: String) : this( + uuid, position, island, ItemUtils.createSkullItemStack( + uuid.toString(), + uuid.toString(), + "https://textures.minecraft.net/texture/$skinId" + ) + ) + val nameField = GuiElementTextField("§9Unknown (NPC)", GuiElementTextField.COLOUR).also { - it.setSize(100, 20) + it.setSize(200, 20) } var name get() = nameField.text @@ -54,20 +65,14 @@ class NPCLocationExporter { get() = StringUtils.cleanColour(name.replace(" ", "_")) .uppercase() .replace("[^A-Z_0-9]".toRegex(), "") - val itemStack - get() = ItemUtils.createSkullItemStack( - name, - uuid.toString(), - "https://textures.minecraft.net/texture/$skinId" - ) val top get() = height / 2 - 50 val left get() = width / 2 - 100 override fun drawScreen(mouseX: Int, mouseY: Int, partialTicks: Float) { super.drawScreen(mouseX, mouseY, partialTicks) drawDefaultBackground() - RenderUtils.drawFloatingRect(left, top, 200, 100) - nameField.render(left + 48 + 20, top + 20) + RenderUtils.drawFloatingRect(left, top, 250, 100) + nameField.render(left + 25, top + 60) GlStateManager.pushMatrix() GlStateManager.translate((left + 5).toDouble(), (top + 5).toDouble(), 0.0) GlStateManager.scale(3.0, 3.0, 1.0) @@ -80,7 +85,9 @@ class NPCLocationExporter { fun save() { val itemStack = this.itemStack + itemStack.setStackDisplayName(name) ItemUtils.getExtraAttributes(itemStack).setString("id", id) + ItemUtils.appendLore(itemStack, listOf("")) val json = NotEnoughUpdates.INSTANCE.manager.getJsonForItem(itemStack) json["internalname"] = id json["clickcommand"] = "" @@ -106,8 +113,8 @@ class NPCLocationExporter { super.mouseClicked(mouseX, mouseY, mouseButton) val mouseX = Utils.getMouseX() val mouseY = Utils.getMouseY() - if (mouseX - left - 48 - 20 in 0..nameField.width && - mouseY - top - 20 in 0..nameField.height + if (mouseX - left - 25 in 0..nameField.width && + mouseY - top - 60 in 0..nameField.height ) { nameField.mouseClicked(mouseX, mouseY, mouseButton) } else { @@ -137,6 +144,18 @@ class NPCLocationExporter { return } if (pointedEntity !is AbstractClientPlayer) { + if (pointedEntity is EntityLivingBase) { + Minecraft.getMinecraft().displayGuiScreen( + NPCNamePrompt( + pointedEntity.uniqueID, + pointedEntity.position, + SBInfo.getInstance().getLocation(), + pointedEntity.getCurrentArmor(3)?.takeIf { it.stackSize > 0 } + ?: ItemUtils.createQuestionMarkSkull("") + ) + ) + return + } Utils.addChatMessage("Entity under cursor is not a player") return } -- cgit