diff options
Diffstat (limited to 'runtime/src/main/java/me')
34 files changed, 388 insertions, 248 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 7c2d9df99..29fa87e01 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -32,8 +32,8 @@ import me.shedaniel.architectury.event.events.client.ClientScreenInputEvent; import me.shedaniel.architectury.networking.NetworkManager; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.api.config.ConfigObject; import me.shedaniel.rei.api.REIHelper; +import me.shedaniel.rei.api.config.ConfigObject; import me.shedaniel.rei.api.favorites.FavoriteEntry; import me.shedaniel.rei.api.favorites.FavoriteEntryType; import me.shedaniel.rei.api.favorites.FavoriteMenuEntry; @@ -41,9 +41,10 @@ import me.shedaniel.rei.api.gui.DrawableConsumer; import me.shedaniel.rei.api.gui.Renderer; import me.shedaniel.rei.api.gui.widgets.*; import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.api.ingredient.entry.BuiltinEntryTypes; -import me.shedaniel.rei.api.ingredient.entry.EntryDefinition; -import me.shedaniel.rei.api.ingredient.entry.EntryType; +import me.shedaniel.rei.api.ingredient.entry.renderer.EntryRenderer; +import me.shedaniel.rei.api.ingredient.entry.type.BuiltinEntryTypes; +import me.shedaniel.rei.api.ingredient.entry.type.EntryDefinition; +import me.shedaniel.rei.api.ingredient.entry.type.EntryType; import me.shedaniel.rei.api.ingredient.util.EntryStacks; import me.shedaniel.rei.api.plugins.PluginManager; import me.shedaniel.rei.api.registry.screen.ClickArea; @@ -56,6 +57,7 @@ import me.shedaniel.rei.gui.widget.QueuedTooltip; import me.shedaniel.rei.impl.*; import me.shedaniel.rei.impl.entry.EmptyEntryDefinition; import me.shedaniel.rei.impl.entry.EntryIngredientImpl; +import me.shedaniel.rei.impl.nbt.NbtHasherProviderImpl; import me.shedaniel.rei.impl.view.ViewsImpl; import me.shedaniel.rei.impl.widgets.*; import me.shedaniel.rei.tests.plugin.REITestPlugin; @@ -123,6 +125,9 @@ public class RoughlyEnoughItemsCore { }, "entryTypeDeferred"); attachInstance(new PluginManagerImpl(), PluginManager.class); attachInstance(new Internals.EntryStackProvider() { + private EntryType<Unit> empty; + private EntryType<Renderer> render; + @Override public EntryStack<Unit> empty() { return TypedEntryStack.EMPTY; @@ -130,39 +135,49 @@ public class RoughlyEnoughItemsCore { @Override public <T> EntryStack<T> of(EntryDefinition<T> definition, T value) { + if (Objects.equals(definition.getType().getId(), BuiltinEntryTypes.EMPTY_ID)) { + return empty().cast(); + } + return new TypedEntryStack<>(definition, value); } @Override public EntryType<Unit> emptyType(ResourceLocation id) { - return new EntryType<Unit>() { - @Override - public @NotNull ResourceLocation getId() { - return id; - } - - @SuppressWarnings("rawtypes") - @Override - public @NotNull EntryDefinition<Unit> getDefinition() { - return (EntryDefinition) EmptyEntryDefinition.EMPTY; - } - }; + if (empty == null) { + empty = new EntryType<Unit>() { + @Override + public @NotNull ResourceLocation getId() { + return id; + } + + @SuppressWarnings("rawtypes") + @Override + public @NotNull EntryDefinition<Unit> getDefinition() { + return (EntryDefinition) EmptyEntryDefinition.EMPTY; + } + }; + } + return empty; } @Override public EntryType<Renderer> renderingType(ResourceLocation id) { - return new EntryType<Renderer>() { - @Override - public @NotNull ResourceLocation getId() { - return id; - } - - @SuppressWarnings("rawtypes") - @Override - public @NotNull EntryDefinition<Renderer> getDefinition() { - return (EntryDefinition) EmptyEntryDefinition.RENDERING; - } - }; + if (render == null) { + render = new EntryType<Renderer>() { + @Override + public @NotNull ResourceLocation getId() { + return id; + } + + @SuppressWarnings("rawtypes") + @Override + public @NotNull EntryDefinition<Renderer> getDefinition() { + return (EntryDefinition) EmptyEntryDefinition.RENDERING; + } + }; + } + return render; } }, Internals.EntryStackProvider.class); attachInstance(new Internals.WidgetsProvider() { @@ -217,7 +232,9 @@ public class RoughlyEnoughItemsCore { } }, Internals.WidgetsProvider.class); attachInstance(new ViewsImpl(), Views.class); + attachInstance(new NbtHasherProviderImpl(), Internals.NbtHasherProvider.class); attachInstance(EntryIngredientImpl.provide(), Internals.EntryIngredientProvider.class); + attachInstance((Supplier<EntryRenderer<?>>) () -> EmptyEntryDefinition.EmptyRenderer.INSTANCE, "emptyEntryRenderer"); attachInstance((BiFunction<Supplier<FavoriteEntry>, Supplier<JsonObject>, FavoriteEntry>) (supplier, toJson) -> new FavoriteEntry() { FavoriteEntry value = null; @@ -512,8 +529,6 @@ public class RoughlyEnoughItemsCore { if (shouldReturn(screen)) return; REIHelper.getInstance().getOverlay().get().render(matrices, mouseX, mouseY, delta); - if (!REIHelper.getInstance().isOverlayVisible()) - return; ((ContainerScreenOverlay) REIHelper.getInstance().getOverlay().get()).lateRender(matrices, mouseX, mouseY, delta); }); ClientScreenInputEvent.MOUSE_DRAGGED_PRE.register((minecraftClient, screen, mouseX1, mouseY1, button, mouseX2, mouseY2) -> { diff --git a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringEntry.java b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringEntry.java index 79c71af8b..ac1e703a2 100644 --- a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringEntry.java @@ -62,7 +62,7 @@ public class FilteringEntry extends AbstractConfigListEntry<List<EntryStack>> { public FilteringEntry(int width, List<EntryStack> configFiltered, List<FilteringRule<?>> rules, List<EntryStack> defaultValue, Consumer<List<EntryStack>> saveConsumer, Consumer<List<FilteringRule<?>>> rulesSaveConsumer) { super(NarratorChatListener.NO_TITLE, false); this.width = width; - this.configFiltered = new TreeSet<>(Comparator.comparing(EntryStacks::hashIgnoreCount)); + this.configFiltered = new TreeSet<>(Comparator.comparing(EntryStacks::hashExact)); this.configFiltered.addAll(configFiltered); this.rules = Lists.newArrayList(rules); this.defaultValue = defaultValue; diff --git a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringScreen.java b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringScreen.java index d061101a3..ac7a5e0d6 100644 --- a/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/api/gui/config/entry/FilteringScreen.java @@ -315,7 +315,7 @@ public class FilteringScreen extends Screen { Set<EntryStack<?>> list = Sets.newLinkedHashSet(); EntryRegistry.getInstance().getEntryStacks().forEach(stack -> { if (canLastSearchTermsBeAppliedTo(stack)) { - list.add(stack.copy().setting(EntryStack.Settings.CHECK_AMOUNT, EntryStack.Settings.FALSE).setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE).setting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE)); + list.add(stack.normalize()); } }); diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java b/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java index 0384a5b49..c7fdcfc54 100644 --- a/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/gui/AbstractRecipeViewingScreen.java @@ -127,7 +127,7 @@ public abstract class AbstractRecipeViewingScreen extends Screen implements Reci if (widget instanceof EntryWidget) { EntryWidget entry = (EntryWidget) widget; if (entry.getNoticeMark() == marker && entry.getEntries().size() > 1) { - EntryStack<?> stack = CollectionUtils.findFirstOrNullEqualsEntryIgnoreAmount(entry.getEntries(), noticeStack); + EntryStack<?> stack = CollectionUtils.findFirstOrNullEqualsExact(entry.getEntries(), noticeStack); if (stack != null) { entry.clearStacks(); entry.entry(stack); diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 5025bf2f1..67dd29cb3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/runtime/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -597,24 +597,27 @@ public class ContainerScreenOverlay extends REIOverlay { if (widget instanceof LateRenderable && (overlayMenu == null || overlayMenu.wrappedMenu != widget)) widget.render(matrices, mouseX, mouseY, delta); } - } - if (overlayMenu != null) { - if (overlayMenu.wrappedMenu.containsMouse(mouseX, mouseY)) { - TOOLTIPS.clear(); + if (overlayMenu != null) { + if (overlayMenu.wrappedMenu.containsMouse(mouseX, mouseY)) { + TOOLTIPS.clear(); + } + overlayMenu.wrappedMenu.render(matrices, mouseX, mouseY, delta); } - overlayMenu.wrappedMenu.render(matrices, mouseX, mouseY, delta); } Screen currentScreen = Minecraft.getInstance().screen; - if (!(currentScreen instanceof RecipeViewingScreen) || !((RecipeViewingScreen) currentScreen).choosePageActivated) + if (!(currentScreen instanceof RecipeViewingScreen) || !((RecipeViewingScreen) currentScreen).choosePageActivated) { for (Tooltip tooltip : TOOLTIPS) { if (tooltip != null) renderTooltip(matrices, tooltip); } - for (Runnable runnable : AFTER_RENDER) { - runnable.run(); } TOOLTIPS.clear(); - AFTER_RENDER.clear(); + if (REIHelper.getInstance().isOverlayVisible()) { + for (Runnable runnable : AFTER_RENDER) { + runnable.run(); + } + AFTER_RENDER.clear(); + } } public void renderTooltip(PoseStack matrices, Tooltip tooltip) { diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/modules/Menu.java b/runtime/src/main/java/me/shedaniel/rei/gui/modules/Menu.java index d4deaf016..b0b47f44b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/gui/modules/Menu.java +++ b/runtime/src/main/java/me/shedaniel/rei/gui/modules/Menu.java @@ -127,9 +127,10 @@ public class Menu extends WidgetWithBounds implements LateRenderable { lastMap = getOrCreateSubEntryInMap(lastMap, pathSegment); } for (EntryStack<?> entry : SubsetsRegistry.getInstance().getPathEntries(path)) { - EntryStack<?> firstStack = CollectionUtils.findFirstOrNullEqualsEntryIgnoreAmount(stacks, entry); - if (firstStack != null) + EntryStack<?> firstStack = CollectionUtils.findFirstOrNullEqualsExact(stacks, entry); + if (firstStack != null) { putEntryInMap(lastMap, firstStack); + } } } return new Menu(menuStartPoint, buildEntries(entries)); diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/modules/entries/EntryStackSubsetsMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/gui/modules/entries/EntryStackSubsetsMenuEntry.java index 43fe57510..21063adfa 100644 --- a/runtime/src/main/java/me/shedaniel/rei/gui/modules/entries/EntryStackSubsetsMenuEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/gui/modules/entries/EntryStackSubsetsMenuEntry.java @@ -27,9 +27,9 @@ import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.RoughlyEnoughItemsCore; +import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.api.config.ConfigManager; import me.shedaniel.rei.api.config.ConfigObject; -import me.shedaniel.rei.api.REIHelper; import me.shedaniel.rei.api.ingredient.EntryStack; import me.shedaniel.rei.api.ingredient.util.EntryStacks; import me.shedaniel.rei.api.registry.entry.EntryRegistry; @@ -98,7 +98,7 @@ public class EntryStackSubsetsMenuEntry extends MenuEntry { minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); List<EntryStack<?>> filteredStacks = ConfigObject.getInstance().getFilteredStacks(); if (isFiltered()) { - filteredStacks.removeIf(next -> EntryStacks.equalsIgnoreCount(next, stack)); + filteredStacks.removeIf(next -> EntryStacks.equalsExact(next, stack)); } else { filteredStacks.add(stack.normalize()); } @@ -117,10 +117,11 @@ public class EntryStackSubsetsMenuEntry extends MenuEntry { void recalculateFilter(Menu menu) { for (MenuEntry child : menu.children()) { - if (child instanceof SubSubsetsMenuEntry && ((SubSubsetsMenuEntry) child).getSubsetsMenu() != null) + if (child instanceof SubSubsetsMenuEntry && ((SubSubsetsMenuEntry) child).getSubsetsMenu() != null) { recalculateFilter(((SubSubsetsMenuEntry) child).getSubsetsMenu()); - else if (child instanceof EntryStackSubsetsMenuEntry && EntryStacks.equalsIgnoreCount(((EntryStackSubsetsMenuEntry) child).stack, stack)) + } else if (child instanceof EntryStackSubsetsMenuEntry && EntryStacks.equalsExact(((EntryStackSubsetsMenuEntry) child).stack, stack)) { ((EntryStackSubsetsMenuEntry) child).isFiltered = null; + } } } @@ -137,7 +138,7 @@ public class EntryStackSubsetsMenuEntry extends MenuEntry { public boolean isFiltered() { if (isFiltered == null) { List<EntryStack<?>> filteredStacks = ConfigObject.getInstance().getFilteredStacks(); - isFiltered = CollectionUtils.findFirstOrNullEqualsEntryIgnoreAmount(filteredStacks, stack) != null; + isFiltered = CollectionUtils.findFirstOrNullEqualsExact(filteredStacks, stack) != null; } return isFiltered; } diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/modules/entries/SubSubsetsMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/gui/modules/entries/SubSubsetsMenuEntry.java index 7efe4f886..4b41d0517 100644 --- a/runtime/src/main/java/me/shedaniel/rei/gui/modules/entries/SubSubsetsMenuEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/gui/modules/entries/SubSubsetsMenuEntry.java @@ -173,7 +173,7 @@ public class SubSubsetsMenuEntry extends MenuEntry { if (entry instanceof EntryStackSubsetsMenuEntry) { if (((EntryStackSubsetsMenuEntry) entry).isFiltered() != filtered) { if (!filtered) { - filteredStacks.removeIf(next -> EntryStacks.equalsIgnoreCount(next, ((EntryStackSubsetsMenuEntry) entry).stack)); + filteredStacks.removeIf(next -> EntryStacks.equalsExact(next, ((EntryStackSubsetsMenuEntry) entry).stack)); } else { filteredStacks.add(((EntryStackSubsetsMenuEntry) entry).stack.normalize()); } diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java b/runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java index f12b169fd..cd2062d7b 100644 --- a/runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java +++ b/runtime/src/main/java/me/shedaniel/rei/gui/plugin/DefaultRuntimePlugin.java @@ -26,7 +26,6 @@ package me.shedaniel.rei.gui.plugin; import com.google.gson.JsonObject; import com.mojang.blaze3d.vertex.PoseStack; import me.shedaniel.architectury.fluid.FluidStack; -import me.shedaniel.architectury.utils.Fraction; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.api.ClientHelper; @@ -38,9 +37,8 @@ import me.shedaniel.rei.api.gui.Renderer; import me.shedaniel.rei.api.gui.widgets.Panel; import me.shedaniel.rei.api.gui.widgets.Tooltip; import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.api.ingredient.entry.ComparisonContext; -import me.shedaniel.rei.api.ingredient.entry.EntryTypeRegistry; -import me.shedaniel.rei.api.ingredient.entry.VanillaEntryTypes; +import me.shedaniel.rei.api.ingredient.entry.type.EntryTypeRegistry; +import me.shedaniel.rei.api.ingredient.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.ingredient.util.EntryStacks; import me.shedaniel.rei.api.plugins.REIPlugin; import me.shedaniel.rei.api.registry.entry.EntryRegistry; @@ -194,11 +192,7 @@ public class DefaultRuntimePlugin implements REIPlugin { public EntryStackFavoriteEntry(EntryStack<?> stack) { this.stack = stack.normalize(); - if (this.stack.getType() == VanillaEntryTypes.ITEM) - this.stack.setting(EntryStack.Settings.RENDER_COUNTS, EntryStack.Settings.FALSE); - else if (this.stack.getType() == VanillaEntryTypes.FLUID) - this.stack.setting(EntryStack.Settings.Fluid.AMOUNT_TOOLTIP, CANCEL_FLUID_AMOUNT); - this.hashIgnoreAmount = EntryStacks.hashIgnoreCount(this.stack); + this.hashIgnoreAmount = EntryStacks.hashExact(this.stack); } @Override @@ -249,7 +243,7 @@ public class DefaultRuntimePlugin implements REIPlugin { public boolean isSame(FavoriteEntry other) { if (!(other instanceof EntryStackFavoriteEntry)) return false; EntryStackFavoriteEntry that = (EntryStackFavoriteEntry) other; - return EntryStacks.equalsIgnoreCount(stack, that.stack); + return EntryStacks.equalsExact(stack, that.stack); } } } diff --git a/runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java b/runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java index 2123001c6..dc3fc0109 100644 --- a/runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java +++ b/runtime/src/main/java/me/shedaniel/rei/gui/plugin/entry/FluidEntryDefinition.java @@ -30,6 +30,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.math.Matrix4f; import me.shedaniel.architectury.fluid.FluidStack; +import me.shedaniel.architectury.platform.Platform; import me.shedaniel.architectury.utils.Fraction; import me.shedaniel.math.Point; import me.shedaniel.math.Rectangle; @@ -37,12 +38,20 @@ import me.shedaniel.rei.api.ClientHelper; import me.shedaniel.rei.api.config.ConfigObject; import me.shedaniel.rei.api.gui.widgets.Tooltip; import me.shedaniel.rei.api.ingredient.EntryStack; -import me.shedaniel.rei.api.ingredient.entry.*; +import me.shedaniel.rei.api.ingredient.entry.EntrySerializer; +import me.shedaniel.rei.api.ingredient.entry.comparison.ComparisonContext; +import me.shedaniel.rei.api.ingredient.entry.renderer.AbstractEntryRenderer; +import me.shedaniel.rei.api.ingredient.entry.renderer.EntryRenderer; +import me.shedaniel.rei.api.ingredient.entry.type.EntryDefinition; +import me.shedaniel.rei.api.ingredient.entry.type.EntryType; +import me.shedaniel.rei.api.ingredient.entry.type.VanillaEntryTypes; +import me.shedaniel.rei.api.ingredient.util.EntryStacks; import me.shedaniel.rei.impl.SimpleFluidRenderer; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.language.I18n; import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -58,6 +67,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntrySerializer<FluidStack> { + private static final String FLUID_AMOUNT = Platform.isForge() ? "tooltip.rei.fluid_amount.forge" : "tooltip.rei.fluid_amount"; private final EntryRenderer<FluidStack> renderer = new FluidEntryRenderer(); @Override @@ -101,8 +111,7 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS public int hash(EntryStack<FluidStack> entry, FluidStack value, ComparisonContext context) { int code = 1; code = 31 * code + value.getFluid().hashCode(); - code = 31 * code + (context.isIgnoresCount() ? 0 : value.getAmount().hashCode()); - code = 31 * code + (context.isIgnoresNbt() || !value.hasTag() ? 0 : value.getTag().hashCode()); + code = 31 * code + (context.isFuzzy() || !value.hasTag() ? 0 : value.getTag().hashCode()); return code; } @@ -110,9 +119,7 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS public boolean equals(FluidStack o1, FluidStack o2, ComparisonContext context) { if (o1.getFluid() != o2.getFluid()) return false; - if (!context.isIgnoresCount() && !o1.getAmount().equals(o2.getAmount())) - return false; - return context.isIgnoresNbt() || isTagEqual(o1, o2); + return context.isFuzzy() || isTagEqual(o1, o2); } private boolean isTagEqual(FluidStack o1, FluidStack o2) { @@ -161,28 +168,26 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS public static class FluidEntryRenderer extends AbstractEntryRenderer<FluidStack> { @Override public void render(EntryStack<FluidStack> entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { - if (entry.get(EntryStack.Settings.RENDER).get()) { - FluidStack stack = entry.getValue(); - SimpleFluidRenderer.FluidRenderingData renderingData = SimpleFluidRenderer.fromFluid(stack.getFluid()); - if (renderingData != null) { - TextureAtlasSprite sprite = renderingData.getSprite(); - int color = renderingData.getColor(); - int a = 255; - int r = (color >> 16 & 255); - int g = (color >> 8 & 255); - int b = (color & 255); - Minecraft.getInstance().getTextureManager().bind(TextureAtlas.LOCATION_BLOCKS); - Tesselator tess = Tesselator.getInstance(); - BufferBuilder bb = tess.getBuilder(); - Matrix4f matrix = matrices.last().pose(); - bb.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR); - int z = entry.getZ(); - bb.vertex(matrix, bounds.getMaxX(), bounds.y, z).uv(sprite.getU1(), sprite.getV0()).color(r, g, b, a).endVertex(); - bb.vertex(matrix, bounds.x, bounds.y, z).uv(sprite.getU0(), sprite.getV0()).color(r, g, b, a).endVertex(); - bb.vertex(matrix, bounds.x, bounds.getMaxY(), z).uv(sprite.getU0(), sprite.getV1()).color(r, g, b, a).endVertex(); - bb.vertex(matrix, bounds.getMaxX(), bounds.getMaxY(), z).uv(sprite.getU1(), sprite.getV1()).color(r, g, b, a).endVertex(); - tess.end(); - } + FluidStack stack = entry.getValue(); + SimpleFluidRenderer.FluidRenderingData renderingData = SimpleFluidRenderer.fromFluid(stack.getFluid()); + if (renderingData != null) { + TextureAtlasSprite sprite = renderingData.getSprite(); + int color = renderingData.getColor(); + int a = 255; + int r = (color >> 16 & 255); + int g = (color >> 8 & 255); + int b = (color & 255); + Minecraft.getInstance().getTextureManager().bind(TextureAtlas.LOCATION_BLOCKS); + Tesselator tess = Tesselator.getInstance(); + BufferBuilder bb = tess.getBuilder(); + Matrix4f matrix = matrices.last().pose(); + bb.begin(7, DefaultVertexFormat.POSITION_TEX_COLOR); + int z = entry.getZ(); + bb.vertex(matrix, bounds.getMaxX(), bounds.y, z).uv(sprite.getU1(), sprite.getV0()).color(r, g, b, a).endVertex(); + bb.vertex(matrix, bounds.x, bounds.y, z).uv(sprite.getU0(), sprite.getV0()).color(r, g, b, a).endVertex(); + bb.vertex(matrix, bounds.x, bounds.getMaxY(), z).uv(sprite.getU0(), sprite.getV1()).color(r, g, b, a).endVertex(); + bb.vertex(matrix, bounds.getMaxX(), bounds.getMaxY(), z).uv(sprite.getU1(), sprite.getV1()).color(r, g, b, a).endVertex(); + tess.end(); } } @@ -193,7 +198,7 @@ public class FluidEntryDefinition implements EntryDefinition<FluidStack>, EntryS List<Component> toolTip = Lists.newArrayList(entry.asFormattedText()); |
