From a89ea6b2b962200c6239d61affcb1a983570e53a Mon Sep 17 00:00:00 2001 From: Discreater Date: Wed, 5 May 2021 23:09:41 +0800 Subject: [PATCH] fix: remove the overlay on ore dict label and item label --- README.md | 14 +++++++------ .../jecalculation/data/label/ILabel.java | 6 +----- .../data/label/labels/LItemStack.java | 20 +++++++++---------- .../data/label/labels/LOreDict.java | 3 ++- .../me/towdium/jecalculation/gui/JecaGui.java | 13 ++++++------ .../jecalculation/utils/Utilities.java | 2 -- .../jecalculation/utils/wrappers/Pair.java | 5 +++-- 7 files changed, 30 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 67f3e8f..b2f8964 100644 --- a/README.md +++ b/README.md @@ -25,19 +25,21 @@ the [release page](https://minecraft.curseforge.com/projects/just-enough-calcula - [ ] Others - [x] Item from NEI item panel - [ ] Fluid from NEI item panel (Need to get fluid from labels) -- [x] OreDictionary recognize +- [x] OreDictionary recognize' +## TODO + +- Backport the 1.16 feature + - [ ] Disambiguation in picker + - [ ] Infinite recipe inputs, outputs and catalysts) ## Known Issues - [ ] Client Only - [ ] Fluid from NEI ItemPanel will be recognized as item -- [ ] **Capability** - - [ ] Some OreDict items renders wrong - - [ ] OreDict have many some problems +- [ ] Some OreDict items renders wrong with overlay (Now removed the overlay) - [ ] GUI will cover the NEI's GUI like tooltip on item panel - [ ] Check the nei version and adapter the old version. -- [ ] Fluid from recipe needs lots of adapters, see [Adapter](./src/main/java/me/towdium/jecalculation/nei/Adapter.java). - Currently, only support Forestry +- [ ] Fluid from recipe needs lots of adapters, see [Adapter](./src/main/java/me/towdium/jecalculation/nei/Adapter.java). [1]: http://cf.way2muchnoise.eu/full_just-enough-calculation_downloads.svg diff --git a/src/main/java/me/towdium/jecalculation/data/label/ILabel.java b/src/main/java/me/towdium/jecalculation/data/label/ILabel.java index 31ab050..ea6977c 100644 --- a/src/main/java/me/towdium/jecalculation/data/label/ILabel.java +++ b/src/main/java/me/towdium/jecalculation/data/label/ILabel.java @@ -267,10 +267,6 @@ public interface ILabel { return guess.isEmpty() ? labels.get(0) : guess.get(0); } - public ILabel first(List labels) { - return first(labels, null); - } - // to test if the labels can be converted to other labels (like oreDict) public Pair, List> guess(List labels) { return guess(labels, null); @@ -467,7 +463,7 @@ public interface ILabel { return (int) (amount ^ (percent ? 1 : 0)); } - protected static Merger.MergerFunction form(Class a, Class b, BiPredicate p) { + protected static Merger.MergerFunction form(Class a, Class b, BiPredicate p) { return (c, d) -> { if (a.isInstance(d) && b.isInstance(c)) { ILabel tmp = c; diff --git a/src/main/java/me/towdium/jecalculation/data/label/labels/LItemStack.java b/src/main/java/me/towdium/jecalculation/data/label/labels/LItemStack.java index 78dff11..41739a5 100644 --- a/src/main/java/me/towdium/jecalculation/data/label/labels/LItemStack.java +++ b/src/main/java/me/towdium/jecalculation/data/label/labels/LItemStack.java @@ -6,7 +6,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import me.towdium.jecalculation.data.label.ILabel; import me.towdium.jecalculation.gui.JecaGui; -import me.towdium.jecalculation.gui.Resource; import me.towdium.jecalculation.utils.ItemStackHelper; import me.towdium.jecalculation.utils.Utilities; import net.minecraft.item.Item; @@ -52,10 +51,10 @@ public class LItemStack extends ILabel.Impl { public LItemStack(NBTTagCompound tag) { super(tag); final String strId = tag.getString(KEY_ITEM); - if(!tag.hasKey("id")) + if (!tag.hasKey("id")) tag.setShort("id", (short) GameData.getItemRegistry().getId(strId)); - tag.setByte("Count", (byte)1); - tag.setShort("Damage", tag.hasKey(KEY_META) ? (short)tag.getInteger(KEY_META) : 0); + tag.setByte("Count", (byte) 1); + tag.setShort("Damage", tag.hasKey(KEY_META) ? (short) tag.getInteger(KEY_META) : 0); ItemStack stack = ItemStack.loadItemStackFromNBT(tag); if (ItemStackHelper.isEmpty(stack)) @@ -233,12 +232,13 @@ public class LItemStack extends ILabel.Impl { @SideOnly(Side.CLIENT) public void drawLabel(JecaGui gui) { gui.drawItemStack(0, 0, temp, false); - if (fNbt || fMeta) - gui.drawResource(Resource.LBL_FRAME, 0, 0); - if (fNbt) - gui.drawResource(Resource.LBL_FR_UL, 0, 0); - if (fMeta) - gui.drawResource(Resource.LBL_FR_UR, 0, 0); + // TODO some item won't render correctly with overlay + // if (fNbt || fMeta) + // gui.drawResource(Resource.LBL_FRAME, 0, 0); + // if (fNbt) + // gui.drawResource(Resource.LBL_FR_UL, 0, 0); + // if (fMeta) + // gui.drawResource(Resource.LBL_FR_UR, 0, 0); } @Override diff --git a/src/main/java/me/towdium/jecalculation/data/label/labels/LOreDict.java b/src/main/java/me/towdium/jecalculation/data/label/labels/LOreDict.java index cf12e75..23465e7 100644 --- a/src/main/java/me/towdium/jecalculation/data/label/labels/LOreDict.java +++ b/src/main/java/me/towdium/jecalculation/data/label/labels/LOreDict.java @@ -191,7 +191,8 @@ public class LOreDict extends ILabel.Impl { @SideOnly(Side.CLIENT) public void drawLabel(JecaGui gui) { gui.drawItemStack(0, 0, getRepresentation(), false); - gui.drawResource(Resource.LBL_FRAME, 0, 0); + // TODO some item won't render correctly if has this overlay + // gui.drawResource(Resource.LBL_FRAME, 0, 0); } @Override diff --git a/src/main/java/me/towdium/jecalculation/gui/JecaGui.java b/src/main/java/me/towdium/jecalculation/gui/JecaGui.java index 9c7348a..ed5c3ab 100644 --- a/src/main/java/me/towdium/jecalculation/gui/JecaGui.java +++ b/src/main/java/me/towdium/jecalculation/gui/JecaGui.java @@ -37,8 +37,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; -import static codechicken.lib.gui.GuiDraw.renderEngine; - /** * Author: towdium * Date: 8/12/17. @@ -204,9 +202,7 @@ public class JecaGui extends GuiContainer { @Nullable public ILabel getLabelUnderMouse() { - int xMouse = Mouse.getEventX() * width / mc.displayWidth - guiLeft; - int yMouse = height - Mouse.getEventY() * height / mc.displayHeight - 1 - guiTop; - return root.getLabelUnderMouse(xMouse, yMouse); + return root.getLabelUnderMouse(getMouseX(), getMouseY()); } /** @@ -439,8 +435,11 @@ public class JecaGui extends GuiContainer { float zLevel = itemRender.zLevel += 100F; GlStateManager.enableDepth(); RenderHelper.enableGUIStandardItemLighting(); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, renderEngine, is, xPos, yPos); - itemRender.renderItemOverlayIntoGUI(fontRendererObj, renderEngine, is, xPos, yPos); + FontRenderer font = is.getItem().getFontRenderer(is); + if (font == null) + font = this.fontRendererObj; + itemRender.renderItemAndEffectIntoGUI(font, Minecraft.getMinecraft().renderEngine, is, xPos, yPos); + itemRender.renderItemOverlayIntoGUI(font, Minecraft.getMinecraft().renderEngine, is, xPos, yPos); RenderHelper.disableStandardItemLighting(); GlStateManager.disableDepth(); itemRender.zLevel = zLevel - 100F; diff --git a/src/main/java/me/towdium/jecalculation/utils/Utilities.java b/src/main/java/me/towdium/jecalculation/utils/Utilities.java index b77ea25..c9edb74 100644 --- a/src/main/java/me/towdium/jecalculation/utils/Utilities.java +++ b/src/main/java/me/towdium/jecalculation/utils/Utilities.java @@ -176,7 +176,6 @@ public class Utilities { public long getTime() { return running ? System.currentTimeMillis() - time : 0; } - } @SuppressWarnings("UnusedReturnValue") @@ -196,7 +195,6 @@ public class Utilities { return current + 1 == total ? 0 : current + 1; } - public int prev() { return current == 0 ? total - 1 : current - 1; } diff --git a/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java b/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java index 10794ab..379712d 100644 --- a/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java +++ b/src/main/java/me/towdium/jecalculation/utils/wrappers/Pair.java @@ -20,12 +20,13 @@ public class Pair { @Override public boolean equals(Object obj) { - if (obj instanceof Pair) { - Pair p = (Pair) obj; + if (obj instanceof Pair) { + Pair p = (Pair) obj; return one.equals(p.one) && two.equals(p.two); } return false; } + public boolean swap(Class ke, Class ve) { if (ke.isInstance(one) && ve.isInstance(two)) return true; else if (!(ke.isInstance(two) && ve.isInstance(one))) return false;