Skip to content

Commit

Permalink
change: Update 0.7.4 to 1.21-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
FlashyReese committed Jun 13, 2024
1 parent c2cee85 commit 18e05e7
Show file tree
Hide file tree
Showing 33 changed files with 139 additions and 154 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.10
minecraft_version=1.21-rc1
yarn_mappings=1.21-rc1+build.1
loader_version=0.15.11
# Mod Properties
mod_version=0.7.4
maven_group=io.github.amerebagatelle
archives_base_name=fabricskyboxes
# Dependencies
fabric_version=0.97.5+1.20.5
fabric_version=0.100.1+1.21
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class IrisCompat {
apiInstance = api.cast(api.getDeclaredMethod("getInstance").invoke(null));
handle = MethodHandles.lookup().findVirtual(api, "getSunPathRotation", MethodType.methodType(float.class));
isIrisPresent = true;
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException |
InvocationTargetException e) {
isIrisPresent = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static Skybox parseSkyboxJson(Identifier id, JsonObjectWrapper objectWrap
try {
metadata = Metadata.CODEC.decode(JsonOps.INSTANCE, objectWrapper.getFocusedObject()).getOrThrow().getFirst();
} catch (RuntimeException e) {
FabricSkyBoxesClient.getLogger().warn("Skipping invalid skybox " + id.toString(), e);
FabricSkyBoxesClient.getLogger().warn("Skipping invalid skybox {}", id.toString(), e);
FabricSkyBoxesClient.getLogger().warn(objectWrapper.toString());
return null;
}
Expand All @@ -57,7 +57,7 @@ public static Skybox parseSkyboxJson(Identifier id, JsonObjectWrapper objectWrap
Preconditions.checkNotNull(type, "Unknown skybox type: " + metadata.getType().getPath().replace('_', '-'));
if (metadata.getSchemaVersion() == 1) {
Preconditions.checkArgument(type.isLegacySupported(), "Unsupported schema version '1' for skybox type " + type.getName());
FabricSkyBoxesClient.getLogger().debug("Using legacy deserializer for skybox " + id.toString());
FabricSkyBoxesClient.getLogger().debug("Using legacy deserializer for skybox {}", id.toString());
skybox = type.instantiate();
//noinspection ConstantConditions
type.getDeserializer().getDeserializer().accept(objectWrapper, skybox);
Expand Down Expand Up @@ -167,6 +167,6 @@ public void onEndTick(ClientWorld client) {
}

public Map<Identifier, Skybox> getSkyboxMap() {
return skyboxMap;
return this.skyboxMap;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

Expand All @@ -25,11 +26,11 @@ public boolean shouldPause() {

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.onHudRender(context, delta);
this.onHudRender(context, MinecraftClient.getInstance().getRenderTickCounter());
}

@Override
public void onHudRender(DrawContext drawContext, float tickDelta) {
public void onHudRender(DrawContext drawContext, RenderTickCounter renderTickCounter) {
if (FabricSkyBoxesClient.config().generalSettings.debugHud || MinecraftClient.getInstance().currentScreen == this) {
int yPadding = 2;
for (Map.Entry<Identifier, Skybox> identifierSkyboxEntry : SkyboxManager.getInstance().getSkyboxMap().entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.github.amerebagatelle.fabricskyboxes.SkyboxManager;
import io.github.amerebagatelle.fabricskyboxes.skyboxes.AbstractSkybox;
import io.github.amerebagatelle.fabricskyboxes.skyboxes.OverworldSkybox;
import net.minecraft.client.render.BackgroundRenderer;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.MathHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import io.github.amerebagatelle.fabricskyboxes.FabricSkyBoxesClient;
import io.github.amerebagatelle.fabricskyboxes.SkyboxManager;
import net.minecraft.block.enums.CameraSubmersionType;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.CameraSubmersionType;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static Identifier getEndSky() {

@Accessor
VertexBuffer getStarsBuffer();

@Accessor
VertexBuffer getDarkSkyBuffer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ public void reload(ResourceManager manager) {
JsonObject json = GSON.fromJson(new InputStreamReader(resource.getInputStream()), JsonObject.class);
skyboxManager.addSkybox(identifier, json);
} catch (Exception e) {
FabricSkyBoxesClient.getLogger().error("Error reading skybox " + identifier.toString());
e.printStackTrace();
FabricSkyBoxesClient.getLogger().error("Error reading skybox {}", identifier.toString(), e);
}
});
}

@Override
public Identifier getFabricId() {
return new Identifier("fabricskyboxes", "skybox_json");
return Identifier.of("fabricskyboxes", "skybox_json");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.github.amerebagatelle.fabricskyboxes.util.object.Decorations;
import io.github.amerebagatelle.fabricskyboxes.util.object.Properties;
import io.github.amerebagatelle.fabricskyboxes.util.object.Weather;
import net.minecraft.block.enums.CameraSubmersionType;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.VertexBuffer;
import net.minecraft.client.network.ClientPlayerEntity;
Expand Down Expand Up @@ -230,7 +231,7 @@ protected boolean checkWeather() {

public abstract SkyboxType<? extends Skybox> getType();

public void renderDecorations(WorldRendererAccess worldRendererAccess, MatrixStack matrixStack, Matrix4f projectionMatrix, float tickDelta, BufferBuilder bufferBuilder, float alpha, Runnable fogCallback) {
public void renderDecorations(WorldRendererAccess worldRendererAccess, MatrixStack matrixStack, Matrix4f projectionMatrix, float tickDelta, float alpha, Runnable fogCallback) {
RenderSystem.enableBlend();
Vector3f rotationStatic = this.decorations.getRotation().getStatic();
Vector3f rotationAxis = this.decorations.getRotation().getAxis();
Expand Down Expand Up @@ -275,11 +276,11 @@ public void renderDecorations(WorldRendererAccess worldRendererAccess, MatrixSta
// Sun
if (this.decorations.isSunEnabled()) {
RenderSystem.setShaderTexture(0, this.decorations.getSunTexture());
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
bufferBuilder.vertex(matrix4f2, -30.0F, 100.0F, -30.0F).texture(0.0F, 0.0F).next();
bufferBuilder.vertex(matrix4f2, 30.0F, 100.0F, -30.0F).texture(1.0F, 0.0F).next();
bufferBuilder.vertex(matrix4f2, 30.0F, 100.0F, 30.0F).texture(1.0F, 1.0F).next();
bufferBuilder.vertex(matrix4f2, -30.0F, 100.0F, 30.0F).texture(0.0F, 1.0F).next();
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
bufferBuilder.vertex(matrix4f2, -30.0F, 100.0F, -30.0F).texture(0.0F, 0.0F);
bufferBuilder.vertex(matrix4f2, 30.0F, 100.0F, -30.0F).texture(1.0F, 0.0F);
bufferBuilder.vertex(matrix4f2, 30.0F, 100.0F, 30.0F).texture(1.0F, 1.0F);
bufferBuilder.vertex(matrix4f2, -30.0F, 100.0F, 30.0F).texture(0.0F, 1.0F);
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
}
// Moon
Expand All @@ -292,11 +293,11 @@ public void renderDecorations(WorldRendererAccess worldRendererAccess, MatrixSta
float startY = yCoord / 2.0F;
float endX = (xCoord + 1) / 4.0F;
float endY = (yCoord + 1) / 2.0F;
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
bufferBuilder.vertex(matrix4f2, -20.0F, -100.0F, 20.0F).texture(endX, endY).next();
bufferBuilder.vertex(matrix4f2, 20.0F, -100.0F, 20.0F).texture(startX, endY).next();
bufferBuilder.vertex(matrix4f2, 20.0F, -100.0F, -20.0F).texture(startX, startY).next();
bufferBuilder.vertex(matrix4f2, -20.0F, -100.0F, -20.0F).texture(endX, startY).next();
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
bufferBuilder.vertex(matrix4f2, -20.0F, -100.0F, 20.0F).texture(endX, endY);
bufferBuilder.vertex(matrix4f2, 20.0F, -100.0F, 20.0F).texture(startX, endY);
bufferBuilder.vertex(matrix4f2, 20.0F, -100.0F, -20.0F).texture(startX, startY);
bufferBuilder.vertex(matrix4f2, -20.0F, -100.0F, -20.0F).texture(endX, startY);
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
}
// Stars
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ public void render(WorldRendererAccess worldRendererAccess, MatrixStack matrices
MinecraftClient client = MinecraftClient.getInstance();
assert client.world != null;

BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();

RenderSystem.enableBlend();
RenderSystem.depthMask(false);
RenderSystem.setShader(GameRenderer::getPositionTexColorProgram);
RenderSystem.setShaderTexture(0, WorldRendererAccess.getEndSky());
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);

for (int i = 0; i < 6; ++i) {
matrices.push();
Expand All @@ -66,15 +64,15 @@ public void render(WorldRendererAccess worldRendererAccess, MatrixStack matrices
}

Matrix4f matrix4f = matrices.peek().getPositionMatrix();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).texture(0.0F, 0.0F).color(40, 40, 40, (int) (255 * this.alpha)).next();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).texture(0.0F, 16.0F).color(40, 40, 40, (int) (255 * this.alpha)).next();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).texture(16.0F, 16.0F).color(40, 40, 40, (int) (255 * this.alpha)).next();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).texture(16.0F, 0.0F).color(40, 40, 40, (int) (255 * this.alpha)).next();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).texture(0.0F, 0.0F).color(40, 40, 40, (int) (255 * this.alpha));
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).texture(0.0F, 16.0F).color(40, 40, 40, (int) (255 * this.alpha));
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).texture(16.0F, 16.0F).color(40, 40, 40, (int) (255 * this.alpha));
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).texture(16.0F, 0.0F).color(40, 40, 40, (int) (255 * this.alpha));
matrices.pop();
}
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

this.renderDecorations(worldRendererAccess, matrices, projectionMatrix, tickDelta, bufferBuilder, this.alpha, fogCallback);
this.renderDecorations(worldRendererAccess, matrices, projectionMatrix, tickDelta, this.alpha, fogCallback);

RenderSystem.depthMask(true);
RenderSystem.disableBlend();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.function.BiConsumer;

public class LegacyDeserializer<T extends Skybox> {
public static final Registry<LegacyDeserializer<? extends Skybox>> REGISTRY = FabricRegistryBuilder.<LegacyDeserializer<? extends Skybox>, SimpleRegistry<LegacyDeserializer<? extends Skybox>>>from(new SimpleRegistry<>(RegistryKey.ofRegistry(new Identifier(FabricSkyBoxesClient.MODID, "legacy_skybox_deserializer")), Lifecycle.stable())).buildAndRegister();
public static final Registry<LegacyDeserializer<? extends Skybox>> REGISTRY = FabricRegistryBuilder.<LegacyDeserializer<? extends Skybox>, SimpleRegistry<LegacyDeserializer<? extends Skybox>>>from(new SimpleRegistry<>(RegistryKey.ofRegistry(Identifier.of(FabricSkyBoxesClient.MODID, "legacy_skybox_deserializer")), Lifecycle.stable())).buildAndRegister();
public static final LegacyDeserializer<MonoColorSkybox> MONO_COLOR_SKYBOX_DESERIALIZER = register(new LegacyDeserializer<>(LegacyDeserializer::decodeMonoColor, MonoColorSkybox.class), "mono_color_skybox_legacy_deserializer");
public static final LegacyDeserializer<SquareTexturedSkybox> SQUARE_TEXTURED_SKYBOX_DESERIALIZER = register(new LegacyDeserializer<>(LegacyDeserializer::decodeSquareTextured, SquareTexturedSkybox.class), "square_textured_skybox_legacy_deserializer");
private final BiConsumer<JsonObjectWrapper, Skybox> deserializer;
Expand Down Expand Up @@ -103,16 +103,16 @@ private static void processIds(JsonElement element, List<Identifier> list) {
if (element != null) {
if (element.isJsonArray()) {
for (JsonElement jsonElement : element.getAsJsonArray()) {
list.add(new Identifier(jsonElement.getAsString()));
list.add(Identifier.of(jsonElement.getAsString()));
}
} else if (JsonHelper.isString(element)) {
list.add(new Identifier(element.getAsString()));
list.add(Identifier.of(element.getAsString()));
}
}
}

private static <T extends Skybox> LegacyDeserializer<T> register(LegacyDeserializer<T> deserializer, String name) {
return Registry.register(LegacyDeserializer.REGISTRY, new Identifier(FabricSkyBoxesClient.MODID, name), deserializer);
return Registry.register(LegacyDeserializer.REGISTRY, Identifier.of(FabricSkyBoxesClient.MODID, name), deserializer);
}

public BiConsumer<JsonObjectWrapper, Skybox> getDeserializer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public void render(WorldRendererAccess worldRendererAccess, MatrixStack matrices
RenderSystem.enableBlend();
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
this.blend.applyBlendFunc(this.alpha);
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);

for (int i = 0; i < 6; ++i) {
matrices.push();
Expand All @@ -64,15 +63,15 @@ public void render(WorldRendererAccess worldRendererAccess, MatrixStack matrices
}

Matrix4f matrix4f = matrices.peek().getPositionMatrix();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha).next();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha).next();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha).next();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha).next();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha);
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha);
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha);
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha);
matrices.pop();
}
BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());

this.renderDecorations(worldRendererAccess, matrices, projectionMatrix, tickDelta, bufferBuilder, this.alpha, fogCallback);
this.renderDecorations(worldRendererAccess, matrices, projectionMatrix, tickDelta, this.alpha, fogCallback);

RenderSystem.disableBlend();
RenderSystem.depthMask(true);
Expand All @@ -84,6 +83,6 @@ public RGBA getColor() {
}

public Blend getBlend() {
return blend;
return this.blend;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public void render(WorldRendererAccess worldRendererAccess, MatrixStack matrices
ClientWorld world = client.world;
assert client.world != null;

BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();

Vec3d vec3d = world.getSkyColor(client.gameRenderer.getCamera().getPos(), tickDelta);
float f = (float) vec3d.x;
float g = (float) vec3d.y;
Expand Down Expand Up @@ -82,22 +80,22 @@ public void render(WorldRendererAccess worldRendererAccess, MatrixStack matrices
float k = fs[1];
float l = fs[2];
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
bufferBuilder.begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(matrix4f, 0.0F, 100.0F, 0.0F).color(j, k, l, fs[3] * this.alpha).next();
BufferBuilder bufferBuilder = Tessellator.getInstance().begin(VertexFormat.DrawMode.TRIANGLE_FAN, VertexFormats.POSITION_COLOR);
bufferBuilder.vertex(matrix4f, 0.0F, 100.0F, 0.0F).color(j, k, l, fs[3] * this.alpha);

for (int n = 0; n <= 16; ++n) {
float o = (float) n * (float) (Math.PI * 2) / 16.0F;
float p = MathHelper.sin(o);
float q = MathHelper.cos(o);
bufferBuilder.vertex(matrix4f, p * 120.0F, q * 120.0F, -q * 40.0F * fs[3]).color(fs[0], fs[1], fs[2], 0.0F).next();
bufferBuilder.vertex(matrix4f, p * 120.0F, q * 120.0F, -q * 40.0F * fs[3]).color(fs[0], fs[1], fs[2], 0.0F);
}

BufferRenderer.drawWithGlobalProgram(bufferBuilder.end());
matrices.pop();
}


this.renderDecorations(worldRendererAccess, matrices, projectionMatrix, tickDelta, bufferBuilder, this.alpha, fogCallback);
this.renderDecorations(worldRendererAccess, matrices, projectionMatrix, tickDelta, this.alpha, fogCallback);

// Dark Sky
RenderSystem.setShaderColor(0.0F, 0.0F, 0.0F, 1.0F);
Expand Down
Loading

0 comments on commit 18e05e7

Please sign in to comment.