From 9784e9f7228fc0aa3ca814e3830dbd81996a3693 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Tue, 15 Dec 2020 20:45:35 +0800 Subject: wip Signed-off-by: shedaniel --- .../rei/gui/plugin/DefaultRuntimePlugin.java | 11 ++- .../rei/gui/plugin/entry/FluidEntryDefinition.java | 23 ++++++ .../rei/gui/plugin/entry/ItemEntryDefinition.java | 23 ++++++ .../me/shedaniel/rei/gui/widget/EntryWidget.java | 2 +- .../rei/gui/widget/FavoritesListWidget.java | 84 ++++++++++++++-------- .../me/shedaniel/rei/impl/EntryTypeDeferred.java | 31 ++++++-- .../shedaniel/rei/impl/EntryTypeRegistryImpl.java | 25 +++++++ .../java/me/shedaniel/rei/impl/IssuesDetector.java | 23 ++++++ .../me/shedaniel/rei/impl/RecipeHelperImpl.java | 2 +- .../me/shedaniel/rei/impl/TypedEntryStack.java | 23 ++++++ .../rei/impl/entry/EmptyEntryDefinition.java | 31 ++++++-- 11 files changed, 236 insertions(+), 42 deletions(-) (limited to 'RoughlyEnoughItems-runtime/src/main/java') diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java index 6e15e230c..fc0e911a6 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java @@ -30,17 +30,22 @@ import me.shedaniel.architectury.utils.Fraction; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.*; -import me.shedaniel.rei.api.entry.*; +import me.shedaniel.rei.api.entry.ComparisonContext; +import me.shedaniel.rei.api.entry.EntryStacks; +import me.shedaniel.rei.api.entry.EntryTypeRegistry; +import me.shedaniel.rei.api.entry.VanillaEntryTypes; import me.shedaniel.rei.api.favorites.FavoriteEntry; import me.shedaniel.rei.api.favorites.FavoriteEntryType; import me.shedaniel.rei.api.fluid.FluidSupportProvider; import me.shedaniel.rei.api.plugins.REIPluginV0; import me.shedaniel.rei.api.widgets.Panel; import me.shedaniel.rei.api.widgets.Tooltip; +import me.shedaniel.rei.gui.ContainerScreenOverlay; import me.shedaniel.rei.gui.RecipeViewingScreen; import me.shedaniel.rei.gui.VillagerRecipeViewingScreen; import me.shedaniel.rei.gui.plugin.entry.FluidEntryDefinition; import me.shedaniel.rei.gui.plugin.entry.ItemEntryDefinition; +import me.shedaniel.rei.gui.widget.FavoritesListWidget; import me.shedaniel.rei.impl.ClientHelperImpl; import me.shedaniel.rei.impl.RenderingEntry; import me.shedaniel.rei.plugin.autocrafting.DefaultCategoryHandler; @@ -119,14 +124,14 @@ public class DefaultRuntimePlugin implements REIPluginV0 { return Collections.emptyList(); return Collections.singletonList(widget.getBounds().clone()); }); - /*baseBoundsHandler.registerExclusionZones(Screen.class, () -> { + baseBoundsHandler.registerExclusionZones(Screen.class, () -> { FavoritesListWidget widget = ContainerScreenOverlay.getFavoritesListWidget(); if (widget != null) { if (widget.favoritePanelButton.isVisible()) return Collections.singletonList(widget.favoritePanelButton.bounds); } return Collections.emptyList(); - });*/ + }); displayHelper.registerProvider(new DisplayHelper.DisplayBoundsProvider() { @Override public Rectangle getScreenBounds(RecipeViewingScreen screen) { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java index de4658b36..9c7941985 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.gui.plugin.entry; import com.google.common.collect.Lists; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/ItemEntryDefinition.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/ItemEntryDefinition.java index a1b8d6b38..4407563f3 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/ItemEntryDefinition.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/ItemEntryDefinition.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.gui.plugin.entry; import com.google.common.collect.Lists; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java index e345be523..6b236dfe7 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/EntryWidget.java @@ -283,7 +283,7 @@ public class EntryWidget extends Slot { } protected void drawCurrentEntry(PoseStack matrices, int mouseX, int mouseY, float delta) { - EntryStack entry = getCurrentEntry(); + EntryStack entry = getCurrentEntry(); entry.setZ(100); entry.render(matrices, getInnerBounds(), mouseX, mouseY, delta); } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java index fea93b2d5..04365980f 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/gui/widget/FavoritesListWidget.java @@ -26,9 +26,11 @@ package me.shedaniel.rei.gui.widget; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.objects.ObjectIterator; import me.shedaniel.clothconfig2.ClothConfigInitializer; +import me.shedaniel.clothconfig2.api.LazyResettable; import me.shedaniel.clothconfig2.api.ScissorsHandler; import me.shedaniel.clothconfig2.api.ScrollingContainer; import me.shedaniel.clothconfig2.gui.widget.DynamicNewSmoothScrollingEntryListWidget; @@ -39,6 +41,7 @@ import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.*; import me.shedaniel.rei.api.entry.BatchEntryRenderer; import me.shedaniel.rei.api.favorites.FavoriteEntry; +import me.shedaniel.rei.api.favorites.FavoriteEntryType; import me.shedaniel.rei.api.favorites.FavoriteMenuEntry; import me.shedaniel.rei.api.widgets.Tooltip; import me.shedaniel.rei.gui.ContainerScreenOverlay; @@ -46,9 +49,14 @@ import me.shedaniel.rei.gui.modules.Menu; import me.shedaniel.rei.gui.modules.MenuEntry; import me.shedaniel.rei.impl.*; import me.shedaniel.rei.utils.CollectionUtils; +import me.shedaniel.rei.utils.ImmutableLiteralText; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.events.AbstractContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.util.Mth; import net.minecraft.util.Tuple; import org.jetbrains.annotations.ApiStatus; @@ -91,9 +99,9 @@ public class FavoritesListWidget extends WidgetWithBounds { private List entriesList = Lists.newArrayList(); private List children = Lists.newArrayList(); private Entry lastTouchedEntry = null; - -// public final AddFavoritePanel favoritePanel = new AddFavoritePanel(this); -// public final ToggleAddFavoritePanelButton favoritePanelButton = new ToggleAddFavoritePanelButton(this); + + public final AddFavoritePanel favoritePanel = new AddFavoritePanel(this); + public final ToggleAddFavoritePanelButton favoritePanelButton = new ToggleAddFavoritePanelButton(this); private static Rectangle updateInnerBounds(Rectangle bounds) { int entrySize = entrySize(); @@ -114,9 +122,9 @@ public class FavoritesListWidget extends WidgetWithBounds { return true; } } else { -// if (favoritePanel.mouseScrolled(double_1, double_2, double_3)) { -// return true; -// } + if (favoritePanel.mouseScrolled(double_1, double_2, double_3)) { + return true; + } scrolling.offset(ClothConfigInitializer.getScrollStep() * -double_3, true); return true; } @@ -191,8 +199,8 @@ public class FavoritesListWidget extends WidgetWithBounds { } private void renderAddFavorite(PoseStack matrices, int mouseX, int mouseY, float delta) { -// this.favoritePanel.render(matrices, mouseX, mouseY, delta); -// this.favoritePanelButton.render(matrices, mouseX, mouseY, delta); + this.favoritePanel.render(matrices, mouseX, mouseY, delta); + this.favoritePanelButton.render(matrices, mouseX, mouseY, delta); } @Override @@ -278,15 +286,17 @@ public class FavoritesListWidget extends WidgetWithBounds { this.entriesList = Stream.concat(entries.values().stream().map(Entry::getWidget), removedEntries.values().stream().map(Entry::getWidget)).collect(Collectors.toList()); this.children = Stream.>of( entries.values().stream().map(Entry::getWidget), - removedEntries.values().stream().map(Entry::getWidget) -// Stream.of(favoritePanelButton, favoritePanel) + removedEntries.values().stream().map(Entry::getWidget), + Stream.of(favoritePanelButton, favoritePanel) ).flatMap(Function.identity()).collect(Collectors.toList()); } public void updateEntriesPosition(Predicate animated) { int entrySize = entrySize(); this.blockedCount = 0; - this.currentBounds.setBounds(this.fullBounds); + if (favoritePanel.getBounds().height > 20) + this.currentBounds.setBounds(this.fullBounds.x, this.fullBounds.y, this.fullBounds.width, this.fullBounds.height - (this.fullBounds.getMaxY() - this.favoritePanel.bounds.y) - 4); + else this.currentBounds.setBounds(this.fullBounds); this.innerBounds = updateInnerBounds(currentBounds); int width = innerBounds.width / entrySize; int currentX = 0; @@ -456,7 +466,7 @@ public class FavoritesListWidget extends WidgetWithBounds { break; } } - } /*else if (favoritePanel.bounds.contains(mouseX, mouseY)) { + } else if (favoritePanel.bounds.contains(mouseX, mouseY)) { back: for (AddFavoritePanel.Row row : favoritePanel.rows.get()) { if (row instanceof AddFavoritePanel.SectionEntriesRow) { @@ -476,7 +486,7 @@ public class FavoritesListWidget extends WidgetWithBounds { } } } - }*/ + } for (Widget widget : children()) if (widget.mouseClicked(mouseX, mouseY, int_1)) return true; @@ -561,6 +571,23 @@ public class FavoritesListWidget extends WidgetWithBounds { } } + private static EntryStack wrapRendererInStack(Renderer renderer) { + if (renderer instanceof EntryStack) { + return (EntryStack) renderer; + } + return new RenderingEntry() { + @Override + public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { + renderer.render(matrices, bounds, mouseX, mouseY, delta); + } + + @Override + public @Nullable Tooltip getTooltip(Point mouse) { + return renderer.getTooltip(mouse); + } + }; + } + private class EntryListEntry extends EntryListEntryWidget { private final Entry entry; private final FavoriteEntry favoriteEntry; @@ -569,18 +596,7 @@ public class FavoritesListWidget extends WidgetWithBounds { super(new Point(x, y), entrySize); this.entry = entry; this.favoriteEntry = favoriteEntry; - Renderer renderer = this.favoriteEntry.getRenderer(false); - this.clearEntries().entry(new RenderingEntry() { - @Override - public void render(PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { - renderer.render(matrices, bounds, mouseX, mouseY, delta); - } - - @Override - public @Nullable Tooltip getTooltip(Point mouse) { - return renderer.getTooltip(mouse); - } - }); + this.clearEntries().entry(wrapRendererInStack(this.favoriteEntry.getRenderer(false))); } @Override @@ -683,7 +699,7 @@ public class FavoritesListWidget extends WidgetWithBounds { } } - /*public static class ToggleAddFavoritePanelButton extends WidgetWithBounds { + public static class ToggleAddFavoritePanelButton extends WidgetWithBounds { private final FavoritesListWidget widget; public boolean wasClicked = false; public final Animator alpha = new Animator(0); @@ -895,7 +911,7 @@ public class FavoritesListWidget extends WidgetWithBounds { @Override public int getRowHeight() { - return Mth.ceil((entries.size() + blockedCount) / (scrollBounds.width / (float) entrySize())) * entrySize(); + return Mth.ceil((entries.size() + blockedCount) / (scrollBounds.width / (float) entrySize())) * entrySize() + 5; } @Override @@ -929,7 +945,7 @@ public class FavoritesListWidget extends WidgetWithBounds { protected SectionFavoriteWidget(Point point, int entrySize, FavoriteEntry entry) { super(point, entrySize); this.entry = entry; - entry(entry.getWidget(true)); + entry(wrapRendererInStack(entry.getRenderer(true))); noBackground(); } @@ -952,6 +968,16 @@ public class FavoritesListWidget extends WidgetWithBounds { this.getBounds().x = (int) Math.round(x.doubleValue() + offsetSize); this.getBounds().y = (int) Math.round(y.doubleValue() + offsetSize) - (int) scroller.scrollAmount; } + + @Override + public @Nullable Tooltip getCurrentTooltip(Point point) { + Tooltip tooltip = super.getCurrentTooltip(point); + if (tooltip != null) { + tooltip.getText().add(ImmutableLiteralText.EMPTY); + tooltip.getText().add(new TranslatableComponent("tooltip.rei.drag_to_add_favorites")); + } + return tooltip; + } } public void updateEntriesPosition(Predicate animated) { @@ -983,5 +1009,5 @@ public class FavoritesListWidget extends WidgetWithBounds { } } } - }*/ + } } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/EntryTypeDeferred.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/EntryTypeDeferred.java index 61e34042f..8a9153bf3 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/EntryTypeDeferred.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/EntryTypeDeferred.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.impl; import me.shedaniel.rei.api.entry.EntryDefinition; @@ -13,7 +36,7 @@ import java.util.concurrent.atomic.AtomicReference; @ApiStatus.Internal public class EntryTypeDeferred implements EntryType { private final ResourceLocation id; - private AtomicReference>> value = new AtomicReference<>(); + private WeakReference> reference; public EntryTypeDeferred(ResourceLocation id) { this.id = id; @@ -26,7 +49,6 @@ public class EntryTypeDeferred implements EntryType { @Override public @NotNull EntryDefinition getDefinition() { - WeakReference> reference = value.get(); if (reference != null) { EntryDefinition definition = reference.get(); if (definition != null) { @@ -34,10 +56,11 @@ public class EntryTypeDeferred implements EntryType { } } EntryDefinition d = EntryTypeRegistry.getInstance().get(id); - if (d == null) + if (d == null) { throw new NullPointerException("Entry type " + id + " doesn't exist!"); + } EntryDefinition definition = d.cast(); - value.set(new WeakReference<>(definition)); + reference = new WeakReference<>(definition); return definition; } } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/EntryTypeRegistryImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/EntryTypeRegistryImpl.java index c336c03f7..c7dec1540 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/EntryTypeRegistryImpl.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/EntryTypeRegistryImpl.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.impl; import com.google.common.collect.BiMap; @@ -10,6 +33,7 @@ import me.shedaniel.rei.api.entry.EntryTypeBridge; import me.shedaniel.rei.api.entry.EntryTypeRegistry; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collections; @@ -45,6 +69,7 @@ public class EntryTypeRegistryImpl implements EntryTypeRegistry { } @Override + @NotNull public Iterable> getBridgesFor(EntryType original, EntryType destination) { List> list = this.typeBridges.get(original.getId(), destination.getId()); if (list == null) { diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/IssuesDetector.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/IssuesDetector.java index b6b8e64fb..326425a93 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/IssuesDetector.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/IssuesDetector.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.impl; import me.shedaniel.rei.RoughlyEnoughItemsState; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java index 6a15f25c8..d48fcec02 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/RecipeHelperImpl.java @@ -206,7 +206,7 @@ public class RecipeHelperImpl implements RecipeHelper { } for (EntryStack stack : usagesFor) { if (isStackWorkStationOfCategory(categoryId, stack)) { - set.addAll(allRecipesFromCategory); + set.addAll(CollectionUtils.filter(allRecipesFromCategory, this::isDisplayVisible)); break; } } diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/TypedEntryStack.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/TypedEntryStack.java index a4336580d..bda1f2b42 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/TypedEntryStack.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/TypedEntryStack.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.impl; import it.unimi.dsi.fastutil.shorts.Short2ObjectMap; diff --git a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/entry/EmptyEntryDefinition.java b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/entry/EmptyEntryDefinition.java index 98b8d8b9c..a4daa0b3e 100644 --- a/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/entry/EmptyEntryDefinition.java +++ b/RoughlyEnoughItems-runtime/src/main/java/me/shedaniel/rei/impl/entry/EmptyEntryDefinition.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020 shedaniel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package me.shedaniel.rei.impl.entry; import com.mojang.blaze3d.vertex.PoseStack; @@ -73,7 +96,7 @@ public enum EmptyEntryDefinition implements EntryDefinition { @Override public int hash(EntryStack entry, Unit value, ComparisonContext context) { - return 0; + return ordinal(); } @Override @@ -98,12 +121,12 @@ public enum EmptyEntryDefinition implements EntryDefinition { private enum EmptyRenderer implements EntryRenderer { INSTANCE; - + @Override public void render(EntryStack entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { - + } - + @Override public @Nullable Tooltip getTooltip(EntryStack entry, Point mouse) { return null; -- cgit