From 41d98f93d41114850fbfd064876497857a65ffd5 Mon Sep 17 00:00:00 2001 From: gniftygnome Date: Mon, 10 Jun 2024 18:02:52 -0700 Subject: [PATCH] Update for Minecraft 1.21-rc1. - Update for Minecraft 1.21-rc1 --- gradle.properties | 14 ++--- .../com/terraformersmc/vistas/Vistas.java | 2 +- .../vistas/panorama/Cubemap.java | 4 +- .../vistas/panorama/LogoControl.java | 4 +- .../vistas/panorama/Panorama.java | 6 +- .../resource/PanoramaResourceReloader.java | 6 +- .../vistas/title/VistasCubemapRenderer.java | 62 +++++++++---------- .../title/VistasRotatingCubemapRenderer.java | 2 +- .../vistas/title/VistasTitle.java | 2 +- src/main/resources/fabric.mod.json | 2 +- 10 files changed, 51 insertions(+), 53 deletions(-) diff --git a/gradle.properties b/gradle.properties index 33c7477..0e4b02b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,11 +3,11 @@ org.gradle.jvmargs=-Xmx1G maven_group=com.terraformersmc archive_name=vistas -minecraft_version=1.20.6 -yarn_mappings=1.20.6+build.1 -loader_version=0.15.10 -fabric_version=0.97.8+1.20.6 -modmenu_version=10.0.0-beta.1 +minecraft_version=1.21-rc1 +yarn_mappings=1.21-rc1+build.1 +loader_version=0.15.11 +fabric_version=0.100.0+1.21 +modmenu_version=11.0.0-beta.1 clothconfig_version=14.0.126 # Project Metadata @@ -21,14 +21,14 @@ default_release_type=beta # CurseForge Metadata curseforge_slug=vistas curseforge_id=423659 -curseforge_game_versions=1.20.6, Fabric, Quilt +curseforge_game_versions=1.21-Snapshot, Fabric, Quilt curseforge_required_dependencies=fabric-api curseforge_optional_dependencies= # Modrinth Metadata modrinth_slug=vistas modrinth_id=itzZXRxq -modrinth_game_versions=1.20.6 +modrinth_game_versions=1.21-rc1 modrinth_mod_loaders=fabric, quilt modrinth_required_dependencies=fabric-api diff --git a/src/main/java/com/terraformersmc/vistas/Vistas.java b/src/main/java/com/terraformersmc/vistas/Vistas.java index 65acc4d..0fdca88 100644 --- a/src/main/java/com/terraformersmc/vistas/Vistas.java +++ b/src/main/java/com/terraformersmc/vistas/Vistas.java @@ -25,6 +25,6 @@ public void onInitializeClient() { } public static Identifier id(String id) { - return new Identifier(NAMESPACE, id); + return Identifier.of(NAMESPACE, id); } } diff --git a/src/main/java/com/terraformersmc/vistas/panorama/Cubemap.java b/src/main/java/com/terraformersmc/vistas/panorama/Cubemap.java index d061c0b..36d1eca 100644 --- a/src/main/java/com/terraformersmc/vistas/panorama/Cubemap.java +++ b/src/main/java/com/terraformersmc/vistas/panorama/Cubemap.java @@ -26,7 +26,7 @@ public class Cubemap { private final VisualControl visualControl; public Cubemap() { - this.cubemapId = new Identifier("textures/gui/title/background/panorama"); + this.cubemapId = Identifier.ofVanilla("textures/gui/title/background/panorama"); this.rotationControl = RotationControl.DEFAULT; this.visualControl = VisualControl.DEFAULT; } @@ -40,7 +40,7 @@ public Cubemap(Identifier cubemapId, RotationControl rotationControl, VisualCont @SuppressWarnings("OptionalUsedAsFieldOrParameterType") public Cubemap(Optional cubemapId, Optional rotationControl, Optional visualControl) { - this.cubemapId = cubemapId.orElse(new Identifier("textures/gui/title/background/panorama")); + this.cubemapId = cubemapId.orElse(Identifier.ofVanilla("textures/gui/title/background/panorama")); this.rotationControl = rotationControl.orElse(RotationControl.DEFAULT); this.visualControl = visualControl.orElse(VisualControl.DEFAULT); } diff --git a/src/main/java/com/terraformersmc/vistas/panorama/LogoControl.java b/src/main/java/com/terraformersmc/vistas/panorama/LogoControl.java index cf317c9..bd72570 100644 --- a/src/main/java/com/terraformersmc/vistas/panorama/LogoControl.java +++ b/src/main/java/com/terraformersmc/vistas/panorama/LogoControl.java @@ -46,7 +46,7 @@ public class LogoControl { private final boolean showEdition; public LogoControl() { - this.logoId = new Identifier("textures/gui/title/minecraft.png"); + this.logoId = Identifier.ofVanilla("textures/gui/title/minecraft.png"); this.logoX = 0.0D; this.logoY = 0.0D; this.logoRot = 0.0D; @@ -74,7 +74,7 @@ public LogoControl(Identifier logoId, double logoX, double logoY, double logoRot @SuppressWarnings("OptionalUsedAsFieldOrParameterType") public LogoControl(Optional logoId, Optional logoX, Optional logoY, Optional logoRot, Optional outlined, Optional splashX, Optional splashY, Optional splashRot, Optional showEdition) { - this.logoId = logoId.orElse(new Identifier("textures/gui/title/minecraft.png")); + this.logoId = logoId.orElse(Identifier.ofVanilla("textures/gui/title/minecraft.png")); this.logoX = logoX.orElse(0.0D); this.logoY = logoY.orElse(0.0D); this.logoRot = logoRot.orElse(0.0D); diff --git a/src/main/java/com/terraformersmc/vistas/panorama/Panorama.java b/src/main/java/com/terraformersmc/vistas/panorama/Panorama.java index 5e13ad3..de432f5 100644 --- a/src/main/java/com/terraformersmc/vistas/panorama/Panorama.java +++ b/src/main/java/com/terraformersmc/vistas/panorama/Panorama.java @@ -3,9 +3,9 @@ import com.google.common.collect.Lists; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.client.sound.MusicType; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.sound.MusicSound; +import net.minecraft.sound.MusicType; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; @@ -54,7 +54,7 @@ public class Panorama { public Panorama() { this.weight = 1; this.musicSound = MusicType.MENU; - this.splashText = new Identifier("texts/splashes.txt"); + this.splashText = Identifier.ofVanilla("texts/splashes.txt"); this.logoControl = LogoControl.DEFAULT; this.cubemaps = Lists.newArrayList(Cubemap.DEFAULT); } @@ -72,7 +72,7 @@ public Panorama(int weight, MusicSound musicSound, Identifier splashText, LogoCo public Panorama(Optional weight, Optional musicSound, Optional splashText, Optional logoControl, Optional> cubemaps) { this.weight = weight.orElse(1); this.musicSound = musicSound.orElse(MusicType.MENU); - this.splashText = splashText.orElse(new Identifier("texts/splashes.txt")); + this.splashText = splashText.orElse(Identifier.ofVanilla("texts/splashes.txt")); this.logoControl = logoControl.orElse(LogoControl.DEFAULT); this.cubemaps = cubemaps.orElse(Lists.newArrayList(Cubemap.DEFAULT)); } diff --git a/src/main/java/com/terraformersmc/vistas/resource/PanoramaResourceReloader.java b/src/main/java/com/terraformersmc/vistas/resource/PanoramaResourceReloader.java index 225dc57..bdcf94d 100644 --- a/src/main/java/com/terraformersmc/vistas/resource/PanoramaResourceReloader.java +++ b/src/main/java/com/terraformersmc/vistas/resource/PanoramaResourceReloader.java @@ -46,7 +46,7 @@ protected HashMap>> prepare(ResourceMana for (String namespace : manager.getAllNamespaces()) { profiler.push(namespace); try { - for (Resource resource : manager.getAllResources(new Identifier(namespace, "panoramas.json"))) { + for (Resource resource : manager.getAllResources(Identifier.of(namespace, "panoramas.json"))) { profiler.push(resource.getPackId()); try { InputStream inputStream = resource.getInputStream(); @@ -57,7 +57,7 @@ protected HashMap>> prepare(ResourceMana JsonElement jsonElement = JsonParser.parseReader(reader); jsonElement.getAsJsonObject().entrySet().forEach((pair) -> { - Identifier panoramaId = new Identifier(namespace, pair.getKey()); + Identifier panoramaId = Identifier.of(namespace, pair.getKey()); Panorama panorama = get(Panorama.CODEC, pair.getValue()); if (panorama != null) { panoramas.put(panoramaId, panorama); @@ -126,7 +126,7 @@ protected Pair, List> prepare(Identifier splashId, Reso splashTexts = Lists.newArrayList(bufferedReader.lines().map(String::trim).map((splash) -> { if (splash.startsWith("$vistas$import$")) { try { - imports.add(new Identifier(splash.substring(15))); + imports.add(Identifier.of(splash.substring(15))); } catch (InvalidIdentifierException badId) { Vistas.LOGGER.error("Splash: '{}' imports invalid Identifier: '{}'", splashId, splash.substring(15)); } diff --git a/src/main/java/com/terraformersmc/vistas/title/VistasCubemapRenderer.java b/src/main/java/com/terraformersmc/vistas/title/VistasCubemapRenderer.java index 292bb6a..794a7de 100644 --- a/src/main/java/com/terraformersmc/vistas/title/VistasCubemapRenderer.java +++ b/src/main/java/com/terraformersmc/vistas/title/VistasCubemapRenderer.java @@ -21,7 +21,7 @@ public class VistasCubemapRenderer { 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.faces[face] = faces.withSuffixedPath("_" + face + ".png"); } this.cubemap = cubemap; @@ -29,8 +29,6 @@ public VistasCubemapRenderer(Cubemap cubemap) { public void draw(MinecraftClient client, float alpha) { Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); - 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); @@ -47,9 +45,9 @@ public void draw(MinecraftClient client, float alpha) { int b = Math.round((float) this.cubemap.getVisualControl().getColorB()); 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; + float w = (float) this.cubemap.getVisualControl().getWidth() / 2.0f; + float h = (float) this.cubemap.getVisualControl().getHeight() / 2.0f; + float d = (float) this.cubemap.getVisualControl().getDepth() / 2.0f; matrixStack.pushMatrix(); matrixStack.translate((float) this.cubemap.getVisualControl().getAddedX(), (float) this.cubemap.getVisualControl().getAddedY(), (float) this.cubemap.getVisualControl().getAddedZ()); @@ -60,51 +58,51 @@ public void draw(MinecraftClient client, float alpha) { for (int n = 0; n < 6; ++n) { RenderSystem.setShaderTexture(0, this.faces[n]); - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); + BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 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(); + bufferBuilder.vertex(-w, -h, d).texture(0.0F, 0.0F).color(r, g, b, a); + bufferBuilder.vertex(-w, h, d).texture(0.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(w, h, d).texture(1.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(w, -h, d).texture(1.0F, 0.0F).color(r, g, b, a); } 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(); + bufferBuilder.vertex(w, -h, d).texture(0.0F, 0.0F).color(r, g, b, a); + bufferBuilder.vertex(w, h, d).texture(0.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a); } 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(); + bufferBuilder.vertex(w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a); + bufferBuilder.vertex(w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(-w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(-w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a); } 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(); + bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a); + bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(-w, h, d).texture(1.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(-w, -h, d).texture(1.0F, 0.0F).color(r, g, b, a); } 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(); + bufferBuilder.vertex(-w, -h, -d).texture(0.0F, 0.0F).color(r, g, b, a); + bufferBuilder.vertex(-w, -h, d).texture(0.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(w, -h, d).texture(1.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(w, -h, -d).texture(1.0F, 0.0F).color(r, g, b, a); } 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(); + bufferBuilder.vertex(-w, h, d).texture(0.0F, 0.0F).color(r, g, b, a); + bufferBuilder.vertex(-w, h, -d).texture(0.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(w, h, -d).texture(1.0F, 1.0F).color(r, g, b, a); + bufferBuilder.vertex(w, h, d).texture(1.0F, 0.0F).color(r, g, b, a); } - tessellator.draw(); + BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); } matrixStack.popMatrix(); diff --git a/src/main/java/com/terraformersmc/vistas/title/VistasRotatingCubemapRenderer.java b/src/main/java/com/terraformersmc/vistas/title/VistasRotatingCubemapRenderer.java index ab7cebd..109fba9 100644 --- a/src/main/java/com/terraformersmc/vistas/title/VistasRotatingCubemapRenderer.java +++ b/src/main/java/com/terraformersmc/vistas/title/VistasRotatingCubemapRenderer.java @@ -22,7 +22,7 @@ public void render(DrawContext context, int width, int height, float alpha, floa VistasTitle.CURRENT.getValue().getCubemaps().forEach((cubemap) -> { VistasCubemapRenderer panoramaRenderer = new VistasCubemapRenderer(cubemap); - Identifier overlayId = new Identifier(panoramaRenderer.getCubemap().getCubemapId() + "_overlay.png"); + Identifier overlayId = panoramaRenderer.getCubemap().getCubemapId().withSuffixedPath("_overlay.png"); panoramaRenderer.draw(this.client, alpha); diff --git a/src/main/java/com/terraformersmc/vistas/title/VistasTitle.java b/src/main/java/com/terraformersmc/vistas/title/VistasTitle.java index d514f38..df52490 100644 --- a/src/main/java/com/terraformersmc/vistas/title/VistasTitle.java +++ b/src/main/java/com/terraformersmc/vistas/title/VistasTitle.java @@ -33,7 +33,7 @@ public static void choose(Profiler profiler) { if (VistasConfig.getInstance().forcePanorama) { profiler.push("force"); try { - Panorama panorama = VistasTitle.PANORAMAS.get(new Identifier(VistasConfig.getInstance().panorama)); + Panorama panorama = VistasTitle.PANORAMAS.get(Identifier.of(VistasConfig.getInstance().panorama)); if (panorama == null) { throw new NullPointerException(); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 511e9c3..b161232 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -31,6 +31,6 @@ "depends": { "fabricloader": ">=0.15.3", "fabric-api": "*", - "minecraft": ">=1.20.5 <1.21" + "minecraft": ">=1.21-beta <1.22" } }