From dd20d0eb1ad0b36c936e867576a9cdc68ddf8db6 Mon Sep 17 00:00:00 2001 From: Discreater Date: Sun, 2 May 2021 18:48:03 +0800 Subject: [PATCH] fix: scroll --- README.md | 3 +- .../data/label/labels/LOreDict.java | 53 +++++++++++-------- .../event/handlers/NEIEventHandler.java | 2 +- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 4c90a9a..f50b9b3 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,9 @@ the [release page](https://minecraft.curseforge.com/projects/just-enough-calcula ## Known Issues +- [ ] 无法识别流体 - [x] 无法覆盖NEI默认点击行为 -- [ ] OreDict 渲染存在问题 +- [ ] OreDict 部分渲染存在问题 - [ ] capability - [x] 带 nbt 的物品存储到本地存在问题 - [x] 主界面合成表转移存在问题 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 c376eae..be04b29 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 @@ -12,6 +12,7 @@ import me.towdium.jecalculation.utils.ItemStackHelper; import me.towdium.jecalculation.utils.Utilities; import me.towdium.jecalculation.utils.wrappers.Wrapper; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.oredict.OreDictionary; @@ -33,7 +34,6 @@ import java.util.stream.Collectors; public class LOreDict extends ILabel.Impl { public static final String IDENTIFIER = "oreDict"; public static final String KEY_NAME = "name"; - public static final String KEY_AMOUNT = "amount"; public static final boolean MODE_FORCE = false; protected String name; @@ -62,35 +62,38 @@ public class LOreDict extends ILabel.Impl { LOreDict lodA = (LOreDict) a; LOreDict lodB = (LOreDict) b; return lodA.getName().equals(lodB.getName()); - } else return false; + } else + return false; } public static boolean mergeFuzzy(ILabel a, ILabel b) { if (a instanceof LOreDict && b instanceof LItemStack) { LOreDict lod = (LOreDict) a; LItemStack lis = (LItemStack) b; - return lod.getAmount() * lis.getAmount() < 0 - && OreDictionary.getOres(lod.name).stream().map(Converter::from) - .anyMatch(i -> LItemStack.merge(i, lis)); + return lod.getAmount() * lis.getAmount() < 0 && + OreDictionary.getOres(lod.name).stream().map(Converter::from) + .anyMatch(i -> LItemStack.merge(i, lis)); } return false; } public static List suggest(List iss, @Nullable IRecipeHandler rl) { ILabel l = iss.get(0); - if (!(l instanceof LItemStack)) return new ArrayList<>(); + if (!(l instanceof LItemStack)) + return new ArrayList<>(); LItemStack lis = (LItemStack) l; HashSet ids = new HashSet<>(); long amount = lis.getAmount(); for (int i : OreDictionary.getOreIDs(lis.getRep())) - if (check(i, iss, true)) ids.add(i); - return ids.stream().map(i -> new LOreDict(OreDictionary.getOreName(i), amount)) - .collect(Collectors.toList()); + if (check(i, iss, true)) + ids.add(i); + return ids.stream().map(i -> new LOreDict(OreDictionary.getOreName(i), amount)).collect(Collectors.toList()); } public static List fallback(List iss, @Nullable IRecipeHandler rl) { ILabel l = iss.get(0); - if (!(l instanceof LItemStack)) return new ArrayList<>(); + if (!(l instanceof LItemStack)) + return new ArrayList<>(); LItemStack lis = (LItemStack) l; HashSet ids = new HashSet<>(); long amount = lis.getAmount(); @@ -107,12 +110,13 @@ public class LOreDict extends ILabel.Impl { return false; Wrapper acceptable = new Wrapper<>(true); - BiPredicate match = (l, o) -> l instanceof LItemStack - && OreDictionary.itemMatches(o, ((LItemStack) l).getRep(), false); - if (biDir) ores.stream().filter(ore -> labels.stream().noneMatch(label -> match.test(label, ore))) - .findAny().ifPresent(i -> acceptable.value = false); - labels.stream().filter(label -> ores.stream().noneMatch(ore -> match.test(label, ore))) - .findAny().ifPresent(i -> acceptable.value = false); + BiPredicate match = (l, o) -> l instanceof LItemStack && + OreDictionary.itemMatches(o, ((LItemStack) l).getRep(), false); + if (biDir) + ores.stream().filter(ore -> labels.stream().noneMatch(label -> match.test(label, ore))).findAny() + .ifPresent(i -> acceptable.value = false); + labels.stream().filter(label -> ores.stream().noneMatch(ore -> match.test(label, ore))).findAny() + .ifPresent(i -> acceptable.value = false); return acceptable.value; } @@ -120,12 +124,16 @@ public class LOreDict extends ILabel.Impl { @Nonnull public ItemStack getRepresentation() { NonNullList list = NonNullList.create(); - OreDictionary.getOres(name).forEach(is -> { - if (is.getItemDamage() == OreDictionary.WILDCARD_VALUE) { - is.getItem().getSubItems(is.getItem(), CreativeTabs.tabAllSearch, list); - } else list.add(is); - }); - if (list.isEmpty()) return ItemStackHelper.EMPTY_ITEM_STACK; + for (ItemStack ore : OreDictionary.getOres(name)) { + if (ore.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + Item item = ore.getItem(); + item.getSubItems(item, CreativeTabs.tabAllSearch, list); + } else { + list.add(ore); + } + } + if (list.isEmpty()) + return ItemStackHelper.EMPTY_ITEM_STACK; long index = System.currentTimeMillis() / 1500; return list.get((int) (index % list.size())); } @@ -136,7 +144,6 @@ public class LOreDict extends ILabel.Impl { return Utilities.I18n.get("label.ore_dict.name", name); } - @Override public String getIdentifier() { return IDENTIFIER; diff --git a/src/main/java/me/towdium/jecalculation/event/handlers/NEIEventHandler.java b/src/main/java/me/towdium/jecalculation/event/handlers/NEIEventHandler.java index 9b349a4..604c5a3 100644 --- a/src/main/java/me/towdium/jecalculation/event/handlers/NEIEventHandler.java +++ b/src/main/java/me/towdium/jecalculation/event/handlers/NEIEventHandler.java @@ -37,7 +37,7 @@ public class NEIEventHandler implements IContainerInputHandler { @Override public boolean mouseScrolled(GuiContainer guiContainer, int i, int i1, int i2) { - return false; + return JecaGui.onMouse(); } @Override