From e2b09b8ded673e7d7c6059e35066629a17d8e51f Mon Sep 17 00:00:00 2001 From: shedaniel Date: Fri, 18 Feb 2022 11:44:06 +0800 Subject: Fix merge conflicts --- .../rei/impl/client/gui/ScreenOverlayImpl.java | 2 +- .../impl/client/gui/changelog/ChangelogLoader.java | 10 ++++---- .../rei/impl/client/gui/changelog/JParseDown.java | 10 +++++--- .../client/gui/error/ErrorsEntryListWidget.java | 23 +++-------------- .../rei/impl/client/gui/error/ErrorsScreen.java | 4 +-- .../client/gui/widget/CachedEntryListRender.java | 29 ++++++++++------------ .../client/gui/widget/CatchingExceptionUtils.java | 23 +++++++++++++++++ .../impl/client/gui/widget/EntryListWidget.java | 3 +-- 8 files changed, 54 insertions(+), 50 deletions(-) (limited to 'runtime/src/main/java') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java index ced3c1bec..c929c1d8c 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java @@ -276,7 +276,7 @@ public class ScreenOverlayImpl extends ScreenOverlay { .focusable(false)); widgets.add(Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> { helper.setBlitOffset(helper.getBlitOffset() + 1); - RenderSystem.setShaderTexture(0, CHEST_GUI_TEXTURE); + Minecraft.getInstance().getTextureManager().bind(CHEST_GUI_TEXTURE); Rectangle bounds = changelogButton.getBounds(); matrices.pushPose(); matrices.translate(0.5f, 0, 0); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/changelog/ChangelogLoader.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/changelog/ChangelogLoader.java index ae5a41def..f9a6b308d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/changelog/ChangelogLoader.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/changelog/ChangelogLoader.java @@ -25,7 +25,7 @@ package me.shedaniel.rei.impl.client.gui.changelog; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import dev.architectury.platform.Platform; +import me.shedaniel.architectury.platform.Platform; import me.shedaniel.rei.impl.client.gui.error.ErrorsEntryListWidget; import me.shedaniel.rei.impl.client.gui.error.ErrorsScreen; import net.minecraft.client.Minecraft; @@ -64,7 +64,7 @@ public class ChangelogLoader { InputStream changesJsonStream = ChangelogLoader.class.getClassLoader().getResourceAsStream("roughlyenoughitems.changes.json"); if (changesJsonStream != null) { - JsonObject object = JsonParser.parseReader(new InputStreamReader(changesJsonStream)) + JsonObject object = new JsonParser().parse(new InputStreamReader(changesJsonStream)) .getAsJsonObject(); String currentVersion = object.getAsJsonPrimitive("version").getAsString(); if (currentVersion.equals(version)) { @@ -88,7 +88,7 @@ public class ChangelogLoader { components.add(function); } } - + visited = true; BuilderImpl builder = new BuilderImpl(); @@ -96,7 +96,7 @@ public class ChangelogLoader { if (changesJsonStream == null) { builder.add(new TranslatableComponent("rei.changelog.error.missingChangelogFile")); } else { - JsonObject object = JsonParser.parseReader(new InputStreamReader(changesJsonStream)) + JsonObject object = new JsonParser().parse(new InputStreamReader(changesJsonStream)) .getAsJsonObject(); String version = object.getAsJsonPrimitive("version").getAsString(); Path file = Platform.getConfigFolder().resolve("roughlyenoughitems/changelog.txt"); @@ -105,7 +105,7 @@ public class ChangelogLoader { } catch (IOException e) { e.printStackTrace(); } - + InputStream changelogStream = ChangelogLoader.class.getClassLoader().getResourceAsStream("roughlyenoughitems/" + version + "/changelog.md"); if (changelogStream == null) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/changelog/JParseDown.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/changelog/JParseDown.java index 6165f6a7a..d6ce92f7c 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/changelog/JParseDown.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/changelog/JParseDown.java @@ -355,7 +355,7 @@ public class JParseDown { } } - public class BlockList extends Block { + public static class BlockList extends Block { public int indent; public String pattern; public boolean loose = false; @@ -364,6 +364,7 @@ public class JParseDown { public String marker; public String markerType; public String markerTypeRegex; + public JParseDown parseDown; public LinkedList lines = new LinkedList<>(); @@ -399,7 +400,8 @@ public class JParseDown { } String markerWithoutWhitespace = marker.substring(0, marker.indexOf(' ')); - BlockList b = parseDown.new BlockList(); + BlockList b = new BlockList(); + b.parseDown = parseDown; b.indent = line.indent; b.pattern = pattern; b.ordered = ordered; @@ -441,11 +443,11 @@ public class JParseDown { indent = line.indent; lines.add(text); return this; - } else if (line.indent < requiredIndent && BlockList.startBlock(JParseDown.this, line, null) != null) { + } else if (line.indent < requiredIndent && BlockList.startBlock(parseDown, line, null) != null) { return null; } - if (line.text.charAt(0) == '[' && BlockReference.startBlock(JParseDown.this, line, null) != null) { + if (line.text.charAt(0) == '[' && BlockReference.startBlock(parseDown, line, null) != null) { return this; } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java index ff4a99238..cc6230983 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsEntryListWidget.java @@ -24,11 +24,9 @@ package me.shedaniel.rei.impl.client.gui.error; import com.mojang.blaze3d.platform.NativeImage; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Matrix4f; import com.mojang.math.Vector4f; -import me.shedaniel.clothconfig2.gui.AbstractConfigScreen; import me.shedaniel.clothconfig2.gui.widget.DynamicEntryListWidget; import me.shedaniel.clothconfig2.gui.widget.DynamicSmoothScrollingEntryListWidget; import net.minecraft.ChatFormatting; @@ -37,7 +35,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.components.events.ContainerEventHandler; import net.minecraft.client.gui.components.events.GuiEventListener; -import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.resources.sounds.SimpleSoundInstance; @@ -101,10 +98,6 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget } public static abstract class Entry extends DynamicEntryListWidget.Entry { - @Override - public List narratables() { - return Collections.emptyList(); - } } public static class EmptyEntry extends Entry { @@ -148,11 +141,6 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget return getEntry().getItemHeight(); } - @Override - public List narratables() { - return getEntry().narratables(); - } - @Override public List children() { return Collections.singletonList(getEntry()); @@ -223,11 +211,6 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget return getEntry().getItemHeight(); } - @Override - public List narratables() { - return getEntry().narratables(); - } - @Override public List children() { return Collections.singletonList(getEntry()); @@ -338,7 +321,7 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget public boolean changeFocus(boolean boolean_1) { return false; } - + @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { if (button == 0) { @@ -358,7 +341,7 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget return super.mouseClicked(mouseX, mouseY, button); } - + @Nullable private Style getTextAt(double x, double y) { int lineCount = this.textSplit.size(); @@ -420,7 +403,7 @@ public class ErrorsEntryListWidget extends DynamicSmoothScrollingEntryListWidget @Override public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean isSelected, float delta) { - RenderSystem.setShaderTexture(0, id); + Minecraft.getInstance().getTextureManager().bind(id); NativeImage image = texture.getPixels(); width = (entryWidth - 6) / 2; this.height = (int) ((double) width * ((double) image.getHeight() / (double) image.getWidth())); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java index ab0006ea0..ade1de989 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/error/ErrorsScreen.java @@ -81,9 +81,9 @@ public class ErrorsScreen extends Screen { } listWidget._addEntry(new TextEntry(NarratorChatListener.NO_TITLE, listWidget.getItemWidth())); if (quitable) { - addRenderableWidget(doneButton = new Button(width / 2 - 100, height - 26, 200, 20, new TranslatableComponent("gui.done"), button -> Minecraft.getInstance().setScreen(parent))); + addButton(doneButton = new Button(width / 2 - 100, height - 26, 200, 20, new TranslatableComponent("gui.done"), button -> Minecraft.getInstance().setScreen(parent))); } else { - addRenderableWidget(doneButton = new Button(width / 2 - 100, height - 26, 200, 20, new TranslatableComponent("menu.quit"), button -> exit())); + addButton(doneButton = new Button(width / 2 - 100, height - 26, 200, 20, new TranslatableComponent("menu.quit"), button -> exit())); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java index 65447b81b..bda602b35 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java @@ -23,16 +23,15 @@ package me.shedaniel.rei.impl.client.gui.widget; -import com.mojang.blaze3d.pipeline.TextureTarget; +import com.mojang.blaze3d.pipeline.RenderTarget; import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.platform.NativeImage; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import dev.architectury.registry.ReloadListenerRegistry; import it.unimi.dsi.fastutil.longs.Long2LongMap; import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; +import me.shedaniel.architectury.registry.ReloadListeners; import me.shedaniel.math.Rectangle; import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; @@ -70,7 +69,7 @@ public class CachedEntryListRender { } static { - ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, (barrier, resourceManager, preparationProfiler, reloadProfiler, preparationExecutor, reloadExecutor) -> { + ReloadListeners.registerReloadListener(PackType.CLIENT_RESOURCES, (barrier, resourceManager, preparationProfiler, reloadProfiler, preparationExecutor, reloadExecutor) -> { return barrier.wait(Unit.INSTANCE).thenRunAsync(CachedEntryListRender::refresh, reloadExecutor); }); } @@ -130,15 +129,17 @@ public class CachedEntryListRender { hash = new Long2LongOpenHashMap(list.size() + 10); Minecraft minecraft = Minecraft.getInstance(); Window window = minecraft.getWindow(); - TextureTarget target = new TextureTarget(width, height, true, false); + RenderTarget target = new RenderTarget(width, height, true, false); target.bindWrite(true); - Matrix4f projectionMatrix = Matrix4f.orthographic(0.0F, width, 0.0F, height, 1000.0F, 3000.0F); - RenderSystem.setProjectionMatrix(projectionMatrix); - PoseStack modelViewStack = RenderSystem.getModelViewStack(); - modelViewStack.pushPose(); - modelViewStack.setIdentity(); - modelViewStack.translate(0.0D, 0.0D, -2000.0D); - RenderSystem.applyModelViewMatrix(); + + RenderSystem.viewport(0, 0, window.getWidth(), window.getHeight()); + RenderSystem.clear(256, Minecraft.ON_OSX); + RenderSystem.matrixMode(5889); + RenderSystem.loadIdentity(); + RenderSystem.ortho(0.0D, width, height, 0.0D, 1000.0D, 3000.0D); + RenderSystem.matrixMode(5888); + RenderSystem.loadIdentity(); + RenderSystem.translatef(0.0F, 0.0F, -2000.0F); Lighting.setupFor3DItems(); PoseStack matrices = new PoseStack(); @@ -163,11 +164,7 @@ public class CachedEntryListRender { cachedTextureLocation = minecraft.getTextureManager().register("rei_cached_entries", cachedTexture); target.destroyBuffers(); - Minecraft.getInstance().levelRenderer.graphicsChanged(); Minecraft.getInstance().getMainRenderTarget().bindWrite(true); - - modelViewStack.popPose(); - RenderSystem.applyModelViewMatrix(); } private static long pack(int x, int y) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CatchingExceptionUtils.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CatchingExceptionUtils.java index af5b18551..b27b33e8e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CatchingExceptionUtils.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CatchingExceptionUtils.java @@ -1,3 +1,26 @@ +/* + * This file is licensed under the MIT License, part of Roughly Enough Items. + * Copyright (c) 2018, 2019, 2020, 2021, 2022 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.client.gui.widget; import me.shedaniel.rei.api.common.util.ImmutableTextComponent; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java index 0ccd090d5..906c56312 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryListWidget.java @@ -26,7 +26,6 @@ package me.shedaniel.rei.impl.client.gui.widget; import com.google.common.base.Predicates; import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.math.Matrix4f; @@ -320,7 +319,7 @@ public class EntryListWidget extends WidgetWithBounds implements OverlayListWidg entry.our = entry.getCurrentEntry().copy().setting(EntryStack.Settings.RENDERER, stack -> new EntryRenderer() { @Override public void render(EntryStack entry, PoseStack matrices, Rectangle bounds, int mouseX, int mouseY, float delta) { - RenderSystem.setShaderTexture(0, CachedEntryListRender.cachedTextureLocation); + Minecraft.getInstance().getTextureManager().bind(CachedEntryListRender.cachedTextureLocation); innerBlit(matrices.last().pose(), bounds.x, bounds.getMaxX(), bounds.y, bounds.getMaxY(), getBlitOffset(), sprite.u0, sprite.u1, sprite.v0, sprite.v1); } -- cgit