From 4a9e0c071c3bf1baa57e2cdcb442425e35b84dc4 Mon Sep 17 00:00:00 2001 From: miozune Date: Mon, 15 Aug 2022 19:40:25 +0900 Subject: [PATCH] Meteor NEI improvements --- dependencies.gradle | 6 +- .../client/nei/IMCForNEI.java | 19 ++++- .../client/nei/NEIAltarRecipeHandler.java | 2 +- .../client/nei/NEIMeteorRecipeHandler.java | 66 ++++++++++++------ .../alchemicalwizardry/gui/nei/meteor.png | Bin 3602 -> 3666 bytes 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/dependencies.gradle b/dependencies.gradle index 5dae3fe1..12e5d301 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -6,7 +6,7 @@ dependencies { transitive = false } - compileOnly("com.github.GTNewHorizons:Botania:master-SNAPSHOT:api") { + compileOnly("com.github.GTNewHorizons:Botania:1.9.5-GTNH:api") { transitive = false } compileOnly("com.github.GTNewHorizons:ForestryMC:4.4.4:api") { @@ -17,14 +17,14 @@ dependencies { } compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.1:dev") - compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.2.7-GTNH:dev") { + compileOnly("com.github.GTNewHorizons:NotEnoughItems:2.2.20-GTNH:dev") { transitive = false } compileOnly("com.github.GTNewHorizons:Chisel:2.10.6-GTNH:api") { transitive = false } - compileOnly("com.github.GTNewHorizons:ZenScript:master-SNAPSHOT") { + compileOnly("com.github.GTNewHorizons:ZenScript:1.0.0-GTNH") { transitive = false } compileOnly("com.github.GTNewHorizons:CraftTweaker:3.2.6:dev") { diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/IMCForNEI.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/IMCForNEI.java index 85f557f6..26e3d487 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/IMCForNEI.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/IMCForNEI.java @@ -5,18 +5,31 @@ import net.minecraft.nbt.NBTTagCompound; public class IMCForNEI { public static void IMCSender() { - setNBTAndSend("WayofTime.alchemicalWizardry.client.nei.NEIMeteorRecipeHandler", "AWWayofTime:masterStone", 130); + sendHandler("alchemicalwizardry.meteor", "AWWayofTime:masterStone", 130); + sendCatalyst("alchemicalwizardry.meteor", "AWWayofTime:masterStone"); } - private static void setNBTAndSend(String handlerName, String aBlock, int height) { + private static void sendHandler(String handlerName, String stack, int height) { NBTTagCompound NBT = new NBTTagCompound(); NBT.setString("handler", handlerName); NBT.setString("modName", "Blood Magic"); NBT.setString("modId", "AWWayofTime"); NBT.setBoolean("modRequired", true); - NBT.setString("itemName", aBlock); + NBT.setString("itemName", stack); NBT.setInteger("handlerHeight", height); NBT.setInteger("maxRecipesPerPage", 1); FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", NBT); } + + private static void sendCatalyst(String handlerName, String stack, int priority) { + NBTTagCompound aNBT = new NBTTagCompound(); + aNBT.setString("handlerID", handlerName); + aNBT.setString("itemName", stack); + aNBT.setInteger("priority", priority); + FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT); + } + + private static void sendCatalyst(String handlerName, String stack) { + sendCatalyst(handlerName, stack, 0); + } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIAltarRecipeHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIAltarRecipeHandler.java index fc6fa587..b5cc7772 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIAltarRecipeHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIAltarRecipeHandler.java @@ -84,7 +84,7 @@ public class NEIAltarRecipeHandler extends TemplateRecipeHandler { } @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int id) { + public List handleTooltip(GuiRecipe gui, List currenttip, int id) { super.handleTooltip(gui, currenttip, id); Point mouse = GuiDraw.getMousePosition(); Point root = gui.getRecipePosition(id); diff --git a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java index 7f2c8bb4..7379cf08 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/client/nei/NEIMeteorRecipeHandler.java @@ -16,6 +16,7 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import java.awt.*; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -25,34 +26,42 @@ import java.util.stream.Collectors; public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { public class CachedMeteorRecipe extends CachedRecipe { - private final List components; private final List input = new ArrayList<>(); private final List outputs = new ArrayList<>(); private final int cost; private final int radius; + private Point focus; - public CachedMeteorRecipe(MeteorParadigm meteor) { - this.components = meteor.componentList; + public CachedMeteorRecipe(MeteorParadigm meteor, ItemStack focusStack) { this.input.add(new PositionedStack(meteor.focusStack, 74, 4)); int row = 0; int col = 0; float totalMeteorWeight = meteor.getTotalMeteorWeight(); - - for (MeteorParadigmComponent component : meteor.componentList) { + List sortedComponents = new ArrayList<>(meteor.componentList); + sortedComponents.sort(Comparator.comparingInt(c -> -c.chance)); + + for (MeteorParadigmComponent component : sortedComponents) { ItemStack stack = component.getValidBlockParadigm(); + int xPos = 3 + 18 * col; + int yPos = 37 + 18 * row; + List tooltips = new ArrayList<>(); if (stack == null) { stack = new ItemStack(Blocks.fire); tooltips.add(String.format("no entries found for oredict \"%s\"", component.getOreDictName())); } tooltips.add(I18n.format("nei.recipe.meteor.chance", getFormattedChance(component.getChance() / totalMeteorWeight))); - this.outputs.add(new TooltipStack(stack, 3 + 18 * col, 37 + 18 * row, tooltips)); + this.outputs.add(new TooltipStack(stack, xPos, yPos, tooltips)); col++; if (col > 8) { col = 0; row++; } + + if (focusStack != null && matchItem(focusStack, stack)) { + this.focus = new Point(xPos - 1, yPos - 1); + } } this.radius = meteor.radius; this.cost = meteor.cost; @@ -73,10 +82,6 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { return this.outputs; } - public List getComponents() { - return components; - } - public int getCost() { return cost; } @@ -95,7 +100,7 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { public void loadCraftingRecipes(String outputId, Object... results) { if (outputId.equals(getOverlayIdentifier()) && getClass() == NEIMeteorRecipeHandler.class) { for (MeteorParadigm meteor : getSortedMeteors()) { - arecipes.add(new CachedMeteorRecipe(meteor)); + arecipes.add(new CachedMeteorRecipe(meteor, null)); } } else { super.loadCraftingRecipes(outputId, results); @@ -105,8 +110,8 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { @Override public void loadCraftingRecipes(ItemStack result) { for (MeteorParadigm meteor : getSortedMeteors()) { - if (meteor.componentList.stream().anyMatch(m -> NEIServerUtils.areStacksSameTypeCrafting(result, m.getValidBlockParadigm()))) { - arecipes.add(new CachedMeteorRecipe(meteor)); + if (meteor.componentList.stream().anyMatch(m -> matchItem(result, m.getValidBlockParadigm()))) { + arecipes.add(new CachedMeteorRecipe(meteor, result)); } } } @@ -114,12 +119,24 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { @Override public void loadUsageRecipes(ItemStack ingredient) { for (MeteorParadigm meteor : getSortedMeteors()) { - if (NEIServerUtils.areStacksSameTypeCrafting(ingredient, meteor.focusStack)) { - arecipes.add(new CachedMeteorRecipe(meteor)); + if (matchItem(ingredient, meteor.focusStack)) { + arecipes.add(new CachedMeteorRecipe(meteor, null)); } } } + private boolean matchItem(ItemStack compared, ItemStack compareTo) { + if (NEIServerUtils.areStacksSameTypeCrafting(compared, compareTo)) { + return true; + } + // ignore ore variants (like basalt ore) + if (compared.getUnlocalizedName().startsWith("gt.blockores") + && compareTo.getUnlocalizedName().startsWith("gt.blockores")) { + return compared.getItemDamage() % 1000 == compareTo.getItemDamage() % 1000; + } + return false; + } + @Override public String getGuiTexture() { return new ResourceLocation("alchemicalwizardry", "gui/nei/meteor.png").toString(); @@ -140,14 +157,20 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { } @Override - public void drawBackground(int recipe) { + public void drawBackground(int recipeIndex) { GL11.glColor4f(1, 1, 1, 1); GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 172, 202); + GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 202); + + CachedMeteorRecipe recipe = (CachedMeteorRecipe) this.arecipes.get(recipeIndex); + Point focus = recipe.focus; + if (focus != null) { + GuiDraw.drawTexturedModalRect(focus.x, focus.y, 172, 0, 18, 18); + } } @Override - public List handleItemTooltip(GuiRecipe gui, ItemStack stack, List currenttip, int recipe) { + public List handleItemTooltip(GuiRecipe gui, ItemStack stack, List currenttip, int recipe) { CachedMeteorRecipe meteorRecipe = (CachedMeteorRecipe) this.arecipes.get(recipe); for (PositionedStack pStack : meteorRecipe.outputs) { if (!gui.isMouseOver(pStack, recipe)) continue; @@ -174,10 +197,7 @@ public class NEIMeteorRecipeHandler extends TemplateRecipeHandler { .collect(Collectors.toList()); } - private String getFormattedChance(float chance) { - float percentage = chance * 100.0f; - boolean isInteger = percentage - (int) percentage <= 0.01; - if (isInteger) return String.format("%,d", (int) percentage); - else return String.format("%,.1f", percentage); + private String getFormattedChance(double chance) { + return new DecimalFormat("0.##").format(chance * 100); } } diff --git a/src/main/resources/assets/alchemicalwizardry/gui/nei/meteor.png b/src/main/resources/assets/alchemicalwizardry/gui/nei/meteor.png index 3d09c5e3d09017f58945bd6d4d54c2fb6223e618..3774f089dcc5c1343a2af45d69feca97d6b3b236 100644 GIT binary patch literal 3666 zcmeH~YgAKL7RS%IUg(X0Bm|jI5dwr*ENDP6S|wZ*0zrrr99UA7sQ4I)D8YifuL?y+ z&c!A2hCkpR8c!6j>4tFz`q`-M;UvCi6O z@Bja|&)xTwx6n;*;kyd~0D1y<7ass1c?$uiObZm^`N`BsF~{GBw0QD-4kv} ze|7)We?Kl*UJ@?sapdMNE^LdNnHrmkdf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