From b56e55a84351f9a451d686ed2fef5be52dc3a7cf Mon Sep 17 00:00:00 2001 From: gniftygnome Date: Fri, 26 Apr 2024 22:54:39 -0700 Subject: [PATCH] Update to Minecraft 1.20.5. - Update to Minecraft 1.20.5 * Major changes to pano render to accommodate vanilla menu changes --- .github/workflows/check_build.yml | 11 +- .github/workflows/release.yml | 17 +-- build.gradle | 6 +- gradle.properties | 16 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../vistas/mixin/ScreenMixin.java | 30 +++++ .../vistas/mixin/TitleScreenMixin.java | 49 +------- .../vistas/panorama/RotationControl.java | 16 ++- .../resource/PanoramaResourceReloader.java | 6 +- .../vistas/title/BenignCubemapRenderer.java | 15 --- ...nderer.java => VistasCubemapRenderer.java} | 115 +++++++++--------- .../title/VistasRotatingCubemapRenderer.java | 38 ++++++ src/main/resources/vistas.mixins.json | 5 +- 13 files changed, 175 insertions(+), 151 deletions(-) create mode 100644 src/main/java/com/terraformersmc/vistas/mixin/ScreenMixin.java delete mode 100644 src/main/java/com/terraformersmc/vistas/title/BenignCubemapRenderer.java rename src/main/java/com/terraformersmc/vistas/title/{PanoramaRenderer.java => VistasCubemapRenderer.java} (59%) create mode 100644 src/main/java/com/terraformersmc/vistas/title/VistasRotatingCubemapRenderer.java diff --git a/.github/workflows/check_build.yml b/.github/workflows/check_build.yml index 7764a97..f6b428a 100644 --- a/.github/workflows/check_build.yml +++ b/.github/workflows/check_build.yml @@ -11,19 +11,20 @@ jobs: strategy: matrix: # Use these Java versions - java: [17] + java: [21] os: [ubuntu-20.04] runs-on: ${{ matrix.os }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v1 - name: Setup JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'zulu' java-version: ${{ matrix.java }} - name: Make Gradle wrapper executable if: ${{ runner.os != 'Windows' }} @@ -31,8 +32,8 @@ jobs: - name: Build run: ./gradlew build --stacktrace --parallel - name: Capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from LTS java on one OS - uses: actions/upload-artifact@v2 + if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from LTS java on one OS + uses: actions/upload-artifact@v4 with: name: Artifacts path: build/libs/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a01e08..3e6bf03 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,21 +13,21 @@ jobs: strategy: matrix: # Use these Java versions - java: [17] + java: [21] # and run on both Linux and Windows os: [ubuntu-20.04] runs-on: ${{ matrix.os }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Create version tag - uses: actions/github-script@v3 + uses: actions/github-script@v7 with: github-token: ${{ github.token }} script: | - github.git.createRef({ + github.rest.git.createRef({ owner: context.repo.owner, repo: context.repo.repo, ref: "refs/tags/v${{ github.event.inputs.version }}", @@ -36,10 +36,11 @@ jobs: - name: Fetch tags run: git fetch --tags - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 + uses: gradle/wrapper-validation-action@v2 - name: Setup JDK ${{ matrix.java }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: + distribution: 'zulu' java-version: ${{ matrix.java }} - name: Make Gradle wrapper executable if: ${{ runner.os != 'Windows' }} @@ -55,8 +56,8 @@ jobs: MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} DISCORD_ANNOUNCEMENT_WEBHOOK: ${{ secrets.DISCORD_ANNOUNCEMENT_WEBHOOK }} - name: Capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from LTS java on one OS - uses: actions/upload-artifact@v2 + if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from LTS java on one OS + uses: actions/upload-artifact@v4 with: name: Artifacts path: build/libs/ diff --git a/build.gradle b/build.gradle index 35aa5c4..28f0d36 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ plugins { - id 'fabric-loom' version '1.4.+' + id 'fabric-loom' version '1.6.+' } apply from: 'https://raw.githubusercontent.com/TerraformersMC/GradleScripts/2.6/ferry.gradle' -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 dependencies { minecraft "com.mojang:minecraft:$project.minecraft_version" diff --git a/gradle.properties b/gradle.properties index b43bf4d..d8c8a9a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx1G maven_group=com.terraformersmc archive_name=vistas -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.10 -loader_version=0.15.6 -fabric_version=0.91.0+1.20.1 -modmenu_version=7.2.2 -clothconfig_version=11.1.118 +minecraft_version=1.20.5 +yarn_mappings=1.20.5+build.1 +loader_version=0.15.10 +fabric_version=0.97.7+1.20.5 +modmenu_version=10.0.0-beta.1 +clothconfig_version=14.0.126 # Project Metadata project_name=Vistas @@ -21,14 +21,14 @@ default_release_type=beta # CurseForge Metadata curseforge_slug=vistas curseforge_id=423659 -curseforge_game_versions=1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, Fabric, Quilt +curseforge_game_versions=1.20.5, 1.20.6-Snapshot, Fabric, Quilt curseforge_required_dependencies=fabric-api curseforge_optional_dependencies= # Modrinth Metadata modrinth_slug=vistas modrinth_id=itzZXRxq -modrinth_game_versions=1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4 +modrinth_game_versions=1.20.5, 1.20.6-rc1 modrinth_mod_loaders=fabric, quilt modrinth_required_dependencies=fabric-api diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a595206..17655d0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/terraformersmc/vistas/mixin/ScreenMixin.java b/src/main/java/com/terraformersmc/vistas/mixin/ScreenMixin.java new file mode 100644 index 0000000..6bc16f0 --- /dev/null +++ b/src/main/java/com/terraformersmc/vistas/mixin/ScreenMixin.java @@ -0,0 +1,30 @@ +package com.terraformersmc.vistas.mixin; + +import com.terraformersmc.vistas.title.VistasRotatingCubemapRenderer; +import net.minecraft.client.gui.CubeMapRenderer; +import net.minecraft.client.gui.RotatingCubeMapRenderer; +import net.minecraft.client.gui.screen.Screen; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Screen.class) +public class ScreenMixin { + @Shadow + @Final + protected static CubeMapRenderer PANORAMA_RENDERER; + + @Shadow + @Mutable + @Final + protected static RotatingCubeMapRenderer ROTATING_PANORAMA_RENDERER; + + @Inject(method = "", at = @At("TAIL")) + private static void vistas$useOurRenderer(CallbackInfo ci) { + ROTATING_PANORAMA_RENDERER = new VistasRotatingCubemapRenderer(PANORAMA_RENDERER); + } +} diff --git a/src/main/java/com/terraformersmc/vistas/mixin/TitleScreenMixin.java b/src/main/java/com/terraformersmc/vistas/mixin/TitleScreenMixin.java index ce7510c..fce0e05 100644 --- a/src/main/java/com/terraformersmc/vistas/mixin/TitleScreenMixin.java +++ b/src/main/java/com/terraformersmc/vistas/mixin/TitleScreenMixin.java @@ -1,31 +1,20 @@ package com.terraformersmc.vistas.mixin; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import com.mojang.blaze3d.platform.GlStateManager; -import com.mojang.blaze3d.systems.RenderSystem; import com.terraformersmc.vistas.Vistas; import com.terraformersmc.vistas.config.VistasConfig; import com.terraformersmc.vistas.resource.PanoramaResourceReloader; -import com.terraformersmc.vistas.title.BenignCubemapRenderer; import com.terraformersmc.vistas.title.LogoDrawerAccessor; -import com.terraformersmc.vistas.title.PanoramaRenderer; import com.terraformersmc.vistas.title.VistasTitle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.LogoDrawer; -import net.minecraft.client.gui.RotatingCubeMapRenderer; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.SplashTextRenderer; import net.minecraft.client.gui.screen.TitleScreen; import net.minecraft.text.Text; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -37,29 +26,19 @@ @Mixin(TitleScreen.class) public abstract class TitleScreenMixin extends Screen { @Shadow - @Mutable @Final - private RotatingCubeMapRenderer backgroundRenderer; - - @Shadow - @Final - private boolean doBackgroundFade; + private LogoDrawer logoDrawer; @Nullable @Shadow private SplashTextRenderer splashText; - @Shadow - @Final - private LogoDrawer logoDrawer; - protected TitleScreenMixin(Text title) { super(title); } @Inject(method = "(Z)V", at = @At("TAIL")) private void vistas$init(boolean doBackgroundFade, CallbackInfo ci) { - this.backgroundRenderer = new BenignCubemapRenderer(); ((LogoDrawerAccessor)this.logoDrawer).vistas$setIsVistas(new Random().nextDouble() < 1.0E-4D && VistasTitle.CURRENT.getValue().equals(VistasTitle.PANORAMAS.get(Vistas.DEFAULT))); } @@ -73,30 +52,4 @@ protected TitleScreenMixin(Text title) { this.splashText = null; } } - - @WrapOperation( - method = "render", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/gui/RotatingCubeMapRenderer;render(FF)V" - ) - ) - @SuppressWarnings("unused") - private void vistas$render(RotatingCubeMapRenderer instance, float delta, float fade, Operation operation, DrawContext context) { - assert this.client != null; - PanoramaRenderer.time += delta; - VistasTitle.CURRENT.getValue().getCubemaps().forEach((cubemap) -> { - PanoramaRenderer panoramaRenderer = new PanoramaRenderer(cubemap); - panoramaRenderer.render(delta, fade); - Identifier overlayId = new Identifier(panoramaRenderer.getCubemap().getCubemapId() + "_overlay.png"); - if (this.client.getResourceManager().getResource(overlayId).isPresent()) { - RenderSystem.enableBlend(); - RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.doBackgroundFade ? (float) MathHelper.ceil(fade) : 1.0F); - context.drawTexture(overlayId, 0, 0, this.width, this.height, 0.0F, 0.0F, 16, 128, 16, 128); - } - }); - - operation.call(instance, delta, fade); - } } diff --git a/src/main/java/com/terraformersmc/vistas/panorama/RotationControl.java b/src/main/java/com/terraformersmc/vistas/panorama/RotationControl.java index 01218b7..9d7a292 100644 --- a/src/main/java/com/terraformersmc/vistas/panorama/RotationControl.java +++ b/src/main/java/com/terraformersmc/vistas/panorama/RotationControl.java @@ -2,6 +2,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.client.MinecraftClient; import java.util.Optional; @@ -86,16 +87,25 @@ public double getSpeedMultiplier() { return speedMultiplier; } + public double getSpeed() { + MinecraftClient client = MinecraftClient.getInstance(); + if (client == null) { + return this.getSpeedMultiplier(); + } + + return client.options.getPanoramaSpeed().getValue() * this.getSpeedMultiplier(); + } + public double getPitch(double time) { - return ((this.isWoozy() ? -time * 0.1D : Math.sin(time * 0.001D) * 5.0D + 25.0D) + this.getAddedPitch()) * this.getSpeedMultiplier(); + return ((this.isWoozy() ? -time * 0.1D : Math.sin(time * 0.001D) * 5.0D + 25.0D) + this.getAddedPitch()) * this.getSpeed(); } public double getYaw(double time) { - return ((-time * 0.1D) + this.getAddedYaw()) * this.getSpeedMultiplier(); + return ((-time * 0.1D) + this.getAddedYaw()) * this.getSpeed(); } public double getRoll(double time) { - return (this.getAddedRoll()) * this.getSpeedMultiplier(); + return (this.getAddedRoll()) * this.getSpeed(); } @Override diff --git a/src/main/java/com/terraformersmc/vistas/resource/PanoramaResourceReloader.java b/src/main/java/com/terraformersmc/vistas/resource/PanoramaResourceReloader.java index 67c90b4..225dc57 100644 --- a/src/main/java/com/terraformersmc/vistas/resource/PanoramaResourceReloader.java +++ b/src/main/java/com/terraformersmc/vistas/resource/PanoramaResourceReloader.java @@ -12,7 +12,7 @@ import com.terraformersmc.vistas.panorama.Panorama; import com.terraformersmc.vistas.title.VistasTitle; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.Session; +import net.minecraft.client.session.Session; import net.minecraft.resource.Resource; import net.minecraft.resource.ResourceManager; import net.minecraft.resource.SinglePreparationResourceReloader; @@ -47,7 +47,7 @@ protected HashMap>> prepare(ResourceMana profiler.push(namespace); try { for (Resource resource : manager.getAllResources(new Identifier(namespace, "panoramas.json"))) { - profiler.push(resource.getResourcePackName()); + profiler.push(resource.getPackId()); try { InputStream inputStream = resource.getInputStream(); try { @@ -93,7 +93,7 @@ protected HashMap>> prepare(ResourceMana } inputStream.close(); } catch (RuntimeException runtimeBreak) { - Vistas.LOGGER.warn("Invalid panoramas.json in resourcepack: '{}'", resource.getResourcePackName(), runtimeBreak); + Vistas.LOGGER.warn("Invalid panoramas.json in resourcepack: '{}'", resource.getPackId(), runtimeBreak); } profiler.pop(); } diff --git a/src/main/java/com/terraformersmc/vistas/title/BenignCubemapRenderer.java b/src/main/java/com/terraformersmc/vistas/title/BenignCubemapRenderer.java deleted file mode 100644 index e22628a..0000000 --- a/src/main/java/com/terraformersmc/vistas/title/BenignCubemapRenderer.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.terraformersmc.vistas.title; - -import net.minecraft.client.gui.RotatingCubeMapRenderer; -import net.minecraft.client.gui.screen.TitleScreen; - -public class BenignCubemapRenderer extends RotatingCubeMapRenderer { - public BenignCubemapRenderer() { - super(TitleScreen.PANORAMA_CUBE_MAP); - } - - @Override - public void render(float delta, float alpha) { - - } -} diff --git a/src/main/java/com/terraformersmc/vistas/title/PanoramaRenderer.java b/src/main/java/com/terraformersmc/vistas/title/VistasCubemapRenderer.java similarity index 59% rename from src/main/java/com/terraformersmc/vistas/title/PanoramaRenderer.java rename to src/main/java/com/terraformersmc/vistas/title/VistasCubemapRenderer.java index 9802c43..292bb6a 100644 --- a/src/main/java/com/terraformersmc/vistas/title/PanoramaRenderer.java +++ b/src/main/java/com/terraformersmc/vistas/title/VistasCubemapRenderer.java @@ -5,111 +5,114 @@ import com.terraformersmc.vistas.panorama.Cubemap; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.*; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; import net.minecraft.util.math.RotationAxis; import org.joml.Matrix4f; +import org.joml.Matrix4fStack; -public class PanoramaRenderer { - public static double time = 0.0D; +public class VistasCubemapRenderer { + protected static double time = 0.0D; + + private static final int FACES_COUNT = 6; + private final Identifier[] faces = new Identifier[FACES_COUNT]; - private final MinecraftClient client; private final Cubemap cubemap; - public PanoramaRenderer(Cubemap cubemap) { + public VistasCubemapRenderer(Cubemap cubemap) { + Identifier faces = cubemap.getCubemapId(); + for (int face = 0; face < FACES_COUNT; ++face) { + this.faces[face] = faces.withPath(faces.getPath() + "_" + face + ".png"); + } + this.cubemap = cubemap; - this.client = MinecraftClient.getInstance(); } - @SuppressWarnings("unused") - public void render(float delta, float alpha) { + public void draw(MinecraftClient client, float alpha) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); - Matrix4f matrix4f = new Matrix4f().perspective((float) Math.toRadians(this.cubemap.getVisualControl().getFov()), (float) client.getWindow().getFramebufferWidth() / (float) client.getWindow().getFramebufferHeight(), 0.05F, 100.0F); + + Matrix4f matrix4f = new Matrix4f().setPerspective((float) Math.toRadians(this.cubemap.getVisualControl().getFov()), (float) client.getWindow().getFramebufferWidth() / (float) client.getWindow().getFramebufferHeight(), 0.05F, 100.0F); RenderSystem.backupProjectionMatrix(); RenderSystem.setProjectionMatrix(matrix4f, VertexSorter.BY_DISTANCE); - MatrixStack matrixStack = RenderSystem.getModelViewStack(); - matrixStack.push(); - matrixStack.loadIdentity(); - matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(180.0F)); - RenderSystem.applyModelViewMatrix(); + Matrix4fStack matrixStack = RenderSystem.getModelViewStack(); + matrixStack.pushMatrix(); + matrixStack.rotationX((float) Math.PI); RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); - RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.enableBlend(); RenderSystem.disableCull(); RenderSystem.depthMask(false); - RenderSystem.defaultBlendFunc(); int r = Math.round((float) this.cubemap.getVisualControl().getColorR()); int g = Math.round((float) this.cubemap.getVisualControl().getColorG()); int b = Math.round((float) this.cubemap.getVisualControl().getColorB()); - int l = Math.round((float) this.cubemap.getVisualControl().getColorA() * alpha); + int a = Math.round((float) this.cubemap.getVisualControl().getColorA() * alpha); double w = this.cubemap.getVisualControl().getWidth() / 2.0D; double h = this.cubemap.getVisualControl().getHeight() / 2.0D; double d = this.cubemap.getVisualControl().getDepth() / 2.0D; - matrixStack.push(); - matrixStack.translate(this.cubemap.getVisualControl().getAddedX(), this.cubemap.getVisualControl().getAddedY(), this.cubemap.getVisualControl().getAddedZ()); - matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees((float) this.cubemap.getRotationControl().getPitch(cubemap.getRotationControl().isFrozen() ? 0.0D : time))); - matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((float) this.cubemap.getRotationControl().getYaw(cubemap.getRotationControl().isFrozen() ? 0.0D : time))); - matrixStack.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) this.cubemap.getRotationControl().getRoll(cubemap.getRotationControl().isFrozen() ? 0.0D : time))); + matrixStack.pushMatrix(); + matrixStack.translate((float) this.cubemap.getVisualControl().getAddedX(), (float) this.cubemap.getVisualControl().getAddedY(), (float) this.cubemap.getVisualControl().getAddedZ()); + matrixStack.rotate(RotationAxis.POSITIVE_X.rotationDegrees((float) this.cubemap.getRotationControl().getPitch(cubemap.getRotationControl().isFrozen() ? 0.0D : time))); + matrixStack.rotate(RotationAxis.POSITIVE_Y.rotationDegrees((float) this.cubemap.getRotationControl().getYaw(cubemap.getRotationControl().isFrozen() ? 0.0D : time))); + matrixStack.rotate(RotationAxis.POSITIVE_Z.rotationDegrees((float) this.cubemap.getRotationControl().getRoll(cubemap.getRotationControl().isFrozen() ? 0.0D : time))); RenderSystem.applyModelViewMatrix(); - for (int k = 0; k < 6; ++k) { - RenderSystem.setShaderTexture(0, new Identifier(this.cubemap.getCubemapId().toString() + "_" + k + ".png")); + for (int n = 0; n < 6; ++n) { + RenderSystem.setShaderTexture(0, this.faces[n]); bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); - if (k == 0) { - bufferBuilder.vertex(-w, -h, d).texture(0.0F, 0.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(-w, h, d).texture(0.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, h, d).texture(1.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, -h, d).texture(1.0F, 0.0F).color(r, g, b, l).next(); + if (n == 0) { + bufferBuilder.vertex(-w, -h, d).texture(0.0F, 0.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(-w, h, d).texture(0.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, h, d).texture(1.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, -h, d).texture(1.0F, 0.0F).color(r, g, b, a).next(); } - if (k == 1) { - bufferBuilder.vertex(w, -h, d).texture(0.0F, 0.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, h, d).texture(0.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, l).next(); + if (n == 1) { + bufferBuilder.vertex(w, -h, d).texture(0.0F, 0.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, h, d).texture(0.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a).next(); } - if (k == 2) { - bufferBuilder.vertex(w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, h, -d).texture(0.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(-w, h, -d).texture(1.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(-w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, l).next(); + if (n == 2) { + bufferBuilder.vertex(w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(-w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(-w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a).next(); } - if (k == 3) { - bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(-w, h, d).texture(1.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(-w, -h, d).texture(1.0F, 0.0F).color(r, g, b, l).next(); + if (n == 3) { + bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(-w, h, d).texture(1.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(-w, -h, d).texture(1.0F, 0.0F).color(r, g, b, a).next(); } - if (k == 4) { - bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(-w, -h, d).texture(0.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, -h, d).texture(1.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, l).next(); + if (n == 4) { + bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(-w, -h, d).texture(0.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, -h, d).texture(1.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a).next(); } - if (k == 5) { - bufferBuilder.vertex(-w, h, d).texture(0.0F, 0.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, l).next(); - bufferBuilder.vertex(w, h, d).texture(1.0F, 0.0F).color(r, g, b, l).next(); + if (n == 5) { + bufferBuilder.vertex(-w, h, d).texture(0.0F, 0.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a).next(); + bufferBuilder.vertex(w, h, d).texture(1.0F, 0.0F).color(r, g, b, a).next(); } tessellator.draw(); } - matrixStack.pop(); + matrixStack.popMatrix(); RenderSystem.applyModelViewMatrix(); + RenderSystem.colorMask(true, true, true, true); RenderSystem.restoreProjectionMatrix(); - matrixStack.pop(); + matrixStack.popMatrix(); RenderSystem.applyModelViewMatrix(); RenderSystem.depthMask(true); RenderSystem.enableCull(); diff --git a/src/main/java/com/terraformersmc/vistas/title/VistasRotatingCubemapRenderer.java b/src/main/java/com/terraformersmc/vistas/title/VistasRotatingCubemapRenderer.java new file mode 100644 index 0000000..ab7cebd --- /dev/null +++ b/src/main/java/com/terraformersmc/vistas/title/VistasRotatingCubemapRenderer.java @@ -0,0 +1,38 @@ +package com.terraformersmc.vistas.title; + +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.CubeMapRenderer; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.RotatingCubeMapRenderer; +import net.minecraft.util.Identifier; + +public class VistasRotatingCubemapRenderer extends RotatingCubeMapRenderer { + private final MinecraftClient client; + + public VistasRotatingCubemapRenderer(CubeMapRenderer defaultRenderer) { + super(defaultRenderer); + + this.client = MinecraftClient.getInstance(); + } + + @Override + public void render(DrawContext context, int width, int height, float alpha, float tickDelta) { + VistasCubemapRenderer.time += tickDelta; + + VistasTitle.CURRENT.getValue().getCubemaps().forEach((cubemap) -> { + VistasCubemapRenderer panoramaRenderer = new VistasCubemapRenderer(cubemap); + Identifier overlayId = new Identifier(panoramaRenderer.getCubemap().getCubemapId() + "_overlay.png"); + + panoramaRenderer.draw(this.client, alpha); + + if (this.client.getResourceManager().getResource(overlayId).isPresent()) { + RenderSystem.enableBlend(); + context.setShaderColor(1.0F, 1.0F, 1.0F, alpha); + context.drawTexture(overlayId, 0, 0, width, height, 0.0f, 0.0f, 16, 128, 16, 128); + context.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.disableBlend(); + } + }); + } +} diff --git a/src/main/resources/vistas.mixins.json b/src/main/resources/vistas.mixins.json index 4bab596..0396c98 100644 --- a/src/main/resources/vistas.mixins.json +++ b/src/main/resources/vistas.mixins.json @@ -6,6 +6,7 @@ "client": [ "LogoDrawerMixin", "MinecraftClientMixin", + "ScreenMixin", "ScreenshotRecorderMixin", "SplashTextRendererMixin", "SplashTextResourceSupplierMixin", @@ -13,5 +14,7 @@ ], "injectors": { "defaultRequire": 1 - } + }, + "mixins": [ + ] }