diff options
author | nea <romangraef@gmail.com> | 2022-04-30 01:05:31 +0200 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-04-30 01:05:31 +0200 |
commit | 5e9ae961bb88e243e422a5076912df0b12b592e2 (patch) | |
tree | ab1e4d03e3cee729ea51b24ad9eef7702d073ef0 | |
parent | 9633581638016b18e9b9a4384a4b70e1cc1a062c (diff) | |
download | NotEnoughUpdates-5e9ae961bb88e243e422a5076912df0b12b592e2.tar.gz NotEnoughUpdates-5e9ae961bb88e243e422a5076912df0b12b592e2.tar.bz2 NotEnoughUpdates-5e9ae961bb88e243e422a5076912df0b12b592e2.zip |
more recipe stuff
7 files changed, 113 insertions, 59 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/RepoModeCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/RepoModeCommand.java index ef07d72d..46156a47 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/RepoModeCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/repo/RepoModeCommand.java @@ -5,7 +5,9 @@ import io.github.moulberry.notenoughupdates.commands.ClientCommandBase; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; +import net.minecraft.event.ClickEvent; import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; public class RepoModeCommand extends ClientCommandBase { @@ -33,11 +35,17 @@ public class RepoModeCommand extends ClientCommandBase { githubBranch = args[3]; } } - NotEnoughUpdates.INSTANCE.config.hidden.repoURL = "https://github.com/" + githubUser + "/" + githubRepo + "/archive/" + githubBranch + ".zip"; - NotEnoughUpdates.INSTANCE.config.hidden.repoCommitsURL = "https://api.github.com/repos/" + githubUser + "/" + githubRepo + "/commits/" + githubBranch; - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("\u00a75Set NEU repo URL to " + NotEnoughUpdates.INSTANCE.config.hidden.repoURL + - "\n\u00a75Set NEU repo commits URL to " + NotEnoughUpdates.INSTANCE.config.hidden.repoCommitsURL)); - Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("\u00a75Run </neureloadrepo fetch> to redownload your repo.")); + NotEnoughUpdates.INSTANCE.config.hidden.repoURL = + "https://github.com/" + githubUser + "/" + githubRepo + "/archive/" + githubBranch + ".zip"; + NotEnoughUpdates.INSTANCE.config.hidden.repoCommitsURL = + "https://api.github.com/repos/" + githubUser + "/" + githubRepo + "/commits/" + githubBranch; + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText( + "\u00a75Set NEU repo URL to " + NotEnoughUpdates.INSTANCE.config.hidden.repoURL + + "\n\u00a75Set NEU repo commits URL to " + NotEnoughUpdates.INSTANCE.config.hidden.repoCommitsURL)); + Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("\u00a75Run <") + .appendSibling(new ChatComponentText("/neureloadrepo fetch").setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent( + ClickEvent.Action.SUGGEST_COMMAND, "/neureloadrepo fetch")))) + .appendSibling(new ChatComponentText("\u00a75> to redownload your repo."))); } else { Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("\u00a7cUsage:" + diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java index 4703fd0e..b2574b76 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/Navigation.java @@ -12,12 +12,12 @@ import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -72,6 +72,19 @@ public class Navigation { && object.has("internalname"); } + public void trackWaypoint(String trackNow) { + if (trackNow == null) { + trackWaypoint((JsonObject) null); + } else { + JsonObject jsonObject = waypoints.get(trackNow); + if (jsonObject == null) { + showError("Could not track waypoint " + trackNow + ". This is likely due to an outdated or broken repository."); + return; + } + trackWaypoint(jsonObject); + } + } + public void trackWaypoint(JsonObject trackNow) { if (trackNow != null && !isValidWaypoint(trackNow)) { showError("Could not track waypoint. This is likely due to an outdated or broken repository."); @@ -116,7 +129,7 @@ public class Navigation { } public void untrackWaypoint() { - trackWaypoint(null); + trackWaypoint((JsonObject) null); } public JsonObject getTrackedWaypoint() { @@ -199,8 +212,8 @@ public class Navigation { private void showError(String message) { EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; if (player != null) - player.sendChatMessage(EnumChatFormatting.DARK_RED + - "[NEU-Waypoint] " + message); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_RED + + "[NEU-Waypoint] " + message)); new RuntimeException("[NEU-Waypoint] " + message).printStackTrace(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java index 7487ad61..129e25e7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiItemRecipe.java @@ -369,10 +369,14 @@ public class GuiItemRecipe extends GuiScreen { ItemStack itemStack = slot.getItemStack(); if (mouseButton == 0) { manager.displayGuiItemRecipe(manager.getInternalNameForItem(itemStack)); + return; } else if (mouseButton == 1) { manager.displayGuiItemUsages(manager.getInternalNameForItem(itemStack)); + return; } } } + + currentRecipe.mouseClicked(this, mouseX, mouseY, mouseButton); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/ItemShopRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/ItemShopRecipe.java index c1e2f72b..98ec0d8c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/ItemShopRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/ItemShopRecipe.java @@ -6,13 +6,12 @@ import com.google.gson.JsonPrimitive; import io.github.moulberry.notenoughupdates.NEUManager; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.miscgui.GuiItemRecipe; +import io.github.moulberry.notenoughupdates.miscgui.GuiNavigation; import io.github.moulberry.notenoughupdates.util.JsonUtils; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; -import java.util.Arrays; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -26,18 +25,22 @@ public class ItemShopRecipe implements NeuRecipe { private static final int SLOT_IMAGE_U = 176; private static final int SLOT_IMAGE_V = 0; + private static final int SLOT_IMAGE_SIZE = 18; public static final int RESULT_SLOT_Y = 66; public static final int RESULT_SLOT_X = 124; - public static final int BUTTON_X = 20; - public static final int BUTTON_Y = 100; + public static final int BUTTON_X = 130; + public static final int BUTTON_Y = 8; + + private static final int COST_SLOT_X = 30; + private static final int COST_SLOT_SPACING = 6; private final List<Ingredient> cost; private final Ingredient result; + private boolean selected; private final Ingredient npcIngredient; private final JsonObject npcObject; - private final GuiButton trackButton = new GuiButton(0, 80, 36, 65, 15, "Uninitialized"); public ItemShopRecipe(Ingredient npcIngredient, List<Ingredient> cost, Ingredient result, JsonObject npcObject) { this.npcIngredient = npcIngredient; @@ -64,64 +67,68 @@ public class ItemShopRecipe implements NeuRecipe { @Override public List<RecipeSlot> getSlots() { List<RecipeSlot> slots = new ArrayList<>(); - int rowCount = cost.size() / 3; - int startX = 36; - int startY = 66 - rowCount * 8; int i = 0; + int startY = RESULT_SLOT_Y + 8 - (SLOT_IMAGE_SIZE * cost.size() + COST_SLOT_SPACING * (cost.size() - 1)) / 2; for (Ingredient ingredient : cost) { - int x = i % 3; - int y = i / 3; - slots.add(new RecipeSlot(startX + x * 18, startY + y * 18, ingredient.getItemStack())); + slots.add(new RecipeSlot( + COST_SLOT_X + 1, + startY + i * (SLOT_IMAGE_SIZE + COST_SLOT_SPACING) + 1, + ingredient.getItemStack() + )); i++; } slots.add(new RecipeSlot(RESULT_SLOT_X, RESULT_SLOT_Y, result.getItemStack())); return slots; } - public GuiButton getAndUpdateTrackButton() { - if (NotEnoughUpdates.INSTANCE.navigation.getTrackedWaypoint() == npcObject) { - trackButton.displayString = EnumChatFormatting.GREEN + "NPC Tracked"; - trackButton.enabled = false; - } else { - trackButton.displayString = "Track NPC"; - trackButton.enabled = true; - } - return trackButton; - } - - @Override - public List<GuiButton> getExtraButtons(GuiItemRecipe guiItemRecipe) { - trackButton.xPosition = BUTTON_X + guiItemRecipe.guiLeft; - trackButton.yPosition = BUTTON_Y + guiItemRecipe.guiTop; - return Arrays.asList(new GuiButton[]{getAndUpdateTrackButton()}); - } - - @Override - public void actionPerformed(GuiButton button) { - if (button == trackButton) { - NotEnoughUpdates.INSTANCE.navigation.trackWaypoint(npcObject); - getAndUpdateTrackButton(); - } - } - @Override public void drawExtraBackground(GuiItemRecipe gui, int mouseX, int mouseY) { Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND); - int rowCount = cost.size() / 3; - int startX = 36 - 1; - int startY = 66 - rowCount * 8 - 1; + int startY = RESULT_SLOT_Y + 8 - (SLOT_IMAGE_SIZE * cost.size() + COST_SLOT_SPACING * (cost.size() - 1)) / 2; for (int i = 0; i < cost.size(); i++) { - int x = i % 3; - int y = i / 3; gui.drawTexturedModalRect( - gui.guiLeft + startX + x * 18, - gui.guiTop + startY + y * 18, + gui.guiLeft + COST_SLOT_X, + gui.guiTop + startY + i * (SLOT_IMAGE_SIZE + COST_SLOT_SPACING), SLOT_IMAGE_U, SLOT_IMAGE_V, SLOT_IMAGE_SIZE, SLOT_IMAGE_SIZE ); } + Minecraft.getMinecraft().getTextureManager().bindTexture(GuiNavigation.BACKGROUND); + selected = npcIngredient.getInternalItemId().equals(NotEnoughUpdates.INSTANCE.navigation.getInternalname()); + gui.drawTexturedModalRect( + gui.guiLeft + BUTTON_X, + gui.guiTop + BUTTON_Y, + selected ? GuiNavigation.TICK_POSITION_U : GuiNavigation.PIN_POSITION_U, + selected ? GuiNavigation.TICK_POSITION_V : GuiNavigation.PIN_POSITION_V, + GuiNavigation.ICON_SIZE, + GuiNavigation.ICON_SIZE + ); + } + @Override + public void mouseClicked(GuiItemRecipe gui, int mouseX, int mouseY, int mouseButton) { + if (Utils.isWithinRect( + mouseX - gui.guiLeft, + mouseY - gui.guiTop, + BUTTON_X, + BUTTON_Y, + GuiNavigation.ICON_SIZE, + GuiNavigation.ICON_SIZE + )) { + if (selected) { + NotEnoughUpdates.INSTANCE.navigation.untrackWaypoint(); + } else { + NotEnoughUpdates.INSTANCE.navigation.trackWaypoint(npcIngredient.getInternalItemId()); + } + Utils.playPressSound(); + selected = !selected; + } + } + + @Override + public String getTitle() { + return npcObject.get("displayname").getAsString(); } @Override diff --git a/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java b/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java index fbe264e8..04945cc5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/recipes/NeuRecipe.java @@ -33,6 +33,10 @@ public interface NeuRecipe { default void drawHoverInformation(GuiItemRecipe gui, int mouseX, int mouseY) { } + default void mouseClicked(GuiItemRecipe gui, int mouseX, int mouseY, int mouseButton) {} + + default void handleKeyboardInput() {} + default Set<Ingredient> getCatalystItems() { return Collections.emptySet(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java index e3d90aaa..f5e552a2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ItemUtils.java @@ -1,6 +1,5 @@ package io.github.moulberry.notenoughupdates.util; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -10,10 +9,29 @@ import java.util.List; public class ItemUtils { - public static ItemStack getCoinItemStack(int coinAmount) { - ItemStack itemStack = new ItemStack(Items.gold_nugget); - itemStack.setStackDisplayName("\u00A7r\u00A76" + Utils.formatNumberWithDots(coinAmount) + " Coins"); - return itemStack; + public static ItemStack getCoinItemStack(long coinAmount) { + String uuid = "2070f6cb-f5db-367a-acd0-64d39a7e5d1b"; + String texture = + "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTM4MDcxNzIxY2M1YjRjZDQwNmNlNDMxYTEzZjg2MDgzYTg5NzNlMTA2NGQyZjg4OTc4Njk5MzBlZTZlNTIzNyJ9fX0="; + if (coinAmount >= 100000) { + uuid = "94fa2455-2881-31fe-bb4e-e3e24d58dbe3"; + texture = + "eyJ0aW1lc3RhbXAiOjE2MzU5NTczOTM4MDMsInByb2ZpbGVJZCI6ImJiN2NjYTcxMDQzNDQ0MTI4ZDMwODllMTNiZGZhYjU5IiwicHJvZmlsZU5hbWUiOiJsYXVyZW5jaW8zMDMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2M5Yjc3OTk5ZmVkM2EyNzU4YmZlYWYwNzkzZTUyMjgzODE3YmVhNjQwNDRiZjQzZWYyOTQzM2Y5NTRiYjUyZjYiLCJtZXRhZGF0YSI6eyJtb2RlbCI6InNsaW0ifX19fQo="; + } + if (coinAmount >= 10000000) { + uuid = "0af8df1f-098c-3b72-ac6b-65d65fd0b668"; + texture = + "ewogICJ0aW1lc3RhbXAiIDogMTYzNTk1NzQ4ODQxNywKICAicHJvZmlsZUlkIiA6ICJmNThkZWJkNTlmNTA0MjIyOGY2MDIyMjExZDRjMTQwYyIsCiAgInByb2ZpbGVOYW1lIiA6ICJ1bnZlbnRpdmV0YWxlbnQiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2I5NTFmZWQ2YTdiMmNiYzIwMzY5MTZkZWM3YTQ2YzRhNTY0ODE1NjRkMTRmOTQ1YjZlYmMwMzM4Mjc2NmQzYiIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9"; + } + ItemStack skull = Utils.createSkull( + "\u00A7r\u00A76" + Utils.formatNumberWithDots(coinAmount) + " Coins", + uuid, + texture + ); + NBTTagCompound extraAttributes = skull.getTagCompound().getCompoundTag("ExtraAttributes"); + extraAttributes.setString("id", "SKYBLOCK_COIN"); + skull.getTagCompound().setTag("ExtraAttributes", extraAttributes); + return skull; } public static void appendLore(ItemStack is, List<String> moreLore) { diff --git a/src/main/resources/assets/notenoughupdates/textures/gui/item_shop_recipe.png b/src/main/resources/assets/notenoughupdates/textures/gui/item_shop_recipe.png Binary files differindex 0815ce35..e78c0f44 100644 --- a/src/main/resources/assets/notenoughupdates/textures/gui/item_shop_recipe.png +++ b/src/main/resources/assets/notenoughupdates/textures/gui/item_shop_recipe.png |