Skip to content

Commit

Permalink
Update for Minecraft 1.21-rc1.
Browse files Browse the repository at this point in the history
- Update for Minecraft 1.21-rc1
  • Loading branch information
gniftygnome committed Jun 11, 2024
1 parent 154d2e4 commit 41d98f9
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 53 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/terraformersmc/vistas/Vistas.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public void onInitializeClient() {
}

public static Identifier id(String id) {
return new Identifier(NAMESPACE, id);
return Identifier.of(NAMESPACE, id);
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/terraformersmc/vistas/panorama/Cubemap.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -40,7 +40,7 @@ public Cubemap(Identifier cubemapId, RotationControl rotationControl, VisualCont

@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
public Cubemap(Optional<Identifier> cubemapId, Optional<RotationControl> rotationControl, Optional<VisualControl> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,7 +74,7 @@ public LogoControl(Identifier logoId, double logoX, double logoY, double logoRot

@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
public LogoControl(Optional<Identifier> logoId, Optional<Double> logoX, Optional<Double> logoY, Optional<Double> logoRot, Optional<Boolean> outlined, Optional<Double> splashX, Optional<Double> splashY, Optional<Double> splashRot, Optional<Boolean> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand All @@ -72,7 +72,7 @@ public Panorama(int weight, MusicSound musicSound, Identifier splashText, LogoCo
public Panorama(Optional<Integer> weight, Optional<MusicSound> musicSound, Optional<Identifier> splashText, Optional<LogoControl> logoControl, Optional<List<Cubemap>> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected HashMap<Identifier, Pair<Panorama, List<String>>> 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();
Expand All @@ -57,7 +57,7 @@ protected HashMap<Identifier, Pair<Panorama, List<String>>> 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);
Expand Down Expand Up @@ -126,7 +126,7 @@ protected Pair<List<String>, List<Identifier>> 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ 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;
}

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);
Expand All @@ -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());
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"depends": {
"fabricloader": ">=0.15.3",
"fabric-api": "*",
"minecraft": ">=1.20.5 <1.21"
"minecraft": ">=1.21-beta <1.22"
}
}

0 comments on commit 41d98f9

Please sign in to comment.