Skip to content

Commit

Permalink
change: Update to 1.21-rc1
Browse files Browse the repository at this point in the history
NeoForge is currently disabled until a release is available.
  • Loading branch information
FlashyReese committed Jun 13, 2024
1 parent 21d5f9b commit f085dd7
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Objects;

public class DefaultHandler {
public static final ResourceLocation DEFAULT = new ResourceLocation(NuitClient.MOD_ID, "default");
public static final ResourceLocation DEFAULT = ResourceLocation.tryBuild(NuitClient.MOD_ID, "default");

/**
* Stores a Conditions instance concatenated from all Conditions instances in skyboxes in SkyboxManager.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public void render(LevelRendererAccessor worldRendererAccess, PoseStack matrices
RenderSystem.enableBlend();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
this.blend.applyBlendFunc(this.alpha);
BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);
BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR);

for (int i = 0; i < 6; ++i) {
matrices.pushPose();
Expand All @@ -58,13 +57,13 @@ public void render(LevelRendererAccessor worldRendererAccess, PoseStack matrices
}

Matrix4f matrix4f = matrices.last().pose();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha).endVertex();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha).endVertex();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha).endVertex();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).color(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha).endVertex();
bufferBuilder.addVertex(matrix4f, -100.0F, -100.0F, -100.0F).setColor(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha);
bufferBuilder.addVertex(matrix4f, -100.0F, -100.0F, 100.0F).setColor(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha);
bufferBuilder.addVertex(matrix4f, 100.0F, -100.0F, 100.0F).setColor(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha);
bufferBuilder.addVertex(matrix4f, 100.0F, -100.0F, -100.0F).setColor(this.color.getRed(), this.color.getGreen(), this.color.getBlue(), this.alpha);
matrices.popPose();
}
BufferUploader.drawWithShader(bufferBuilder.end());
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());

RenderSystem.disableBlend();
RenderSystem.depthMask(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class SkyboxType<T extends Skybox> {
public static final Codec<ResourceLocation> SKYBOX_ID_CODEC;
public static final ResourceKey<Registry<SkyboxType<? extends Skybox>>> SKYBOX_TYPE_REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(NuitClient.MOD_ID, "skybox_type"));
public static final ResourceKey<Registry<SkyboxType<? extends Skybox>>> SKYBOX_TYPE_REGISTRY_KEY = ResourceKey.createRegistryKey(ResourceLocation.tryBuild(NuitClient.MOD_ID, "skybox_type"));

public static final SkyboxType<OverworldSkybox> OVERWORLD;
public static final SkyboxType<EndSkybox> END;
Expand All @@ -34,9 +34,9 @@ public class SkyboxType<T extends Skybox> {
static {
SKYBOX_ID_CODEC = Codec.STRING.xmap((s) -> {
if (!s.contains(":")) {
return new ResourceLocation(NuitClient.MOD_ID, s.replace('-', '_'));
return ResourceLocation.tryBuild(NuitClient.MOD_ID, s.replace('-', '_'));
}
return new ResourceLocation(s.replace('-', '_'));
return ResourceLocation.tryParse(s.replace('-', '_'));
}, (id) -> {
if (id.getNamespace().equals(NuitClient.MOD_ID)) {
return id.getPath().replace('_', '-');
Expand Down Expand Up @@ -85,7 +85,7 @@ public ResourceLocation createId() {
}

public Function<String, ResourceLocation> createIdFactory() {
return (ns) -> new ResourceLocation(ns, this.getName().replace('-', '_'));
return (ns) -> ResourceLocation.tryBuild(ns, this.getName().replace('-', '_'));
}

public Codec<T> getCodec(int schemaVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ public void render(LevelRendererAccessor levelRendererAccessor, PoseStack poseSt

Matrix4f matrix4f2 = poseStack.last().pose();
RenderSystem.setShader(GameRenderer::getPositionTexShader);
BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
// Sun
if (this.sunEnabled) {
this.renderSun(bufferBuilder, matrix4f2);
this.renderSun(matrix4f2);
}
// Moon
if (this.moonEnabled) {
this.renderMoon(bufferBuilder, matrix4f2);
this.renderMoon(matrix4f2);
}
// Stars
if (this.starsEnabled) {
Expand All @@ -85,17 +84,17 @@ public void render(LevelRendererAccessor levelRendererAccessor, PoseStack poseSt
RenderSystem.defaultBlendFunc();
}

public void renderSun(BufferBuilder bufferBuilder, Matrix4f matrix4f) {
public void renderSun(Matrix4f matrix4f) {
RenderSystem.setShaderTexture(0, this.sunTexture);
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.vertex(matrix4f, -30.0F, 100.0F, -30.0F).uv(0.0F, 0.0F).endVertex();
bufferBuilder.vertex(matrix4f, 30.0F, 100.0F, -30.0F).uv(1.0F, 0.0F).endVertex();
bufferBuilder.vertex(matrix4f, 30.0F, 100.0F, 30.0F).uv(1.0F, 1.0F).endVertex();
bufferBuilder.vertex(matrix4f, -30.0F, 100.0F, 30.0F).uv(0.0F, 1.0F).endVertex();
BufferUploader.drawWithShader(bufferBuilder.end());
BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.addVertex(matrix4f, -30.0F, 100.0F, -30.0F).setUv(0.0F, 0.0F);
bufferBuilder.addVertex(matrix4f, 30.0F, 100.0F, -30.0F).setUv(1.0F, 0.0F);
bufferBuilder.addVertex(matrix4f, 30.0F, 100.0F, 30.0F).setUv(1.0F, 1.0F);
bufferBuilder.addVertex(matrix4f, -30.0F, 100.0F, 30.0F).setUv(0.0F, 1.0F);
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());
}

public void renderMoon(BufferBuilder bufferBuilder, Matrix4f matrix4f) {
public void renderMoon(Matrix4f matrix4f) {
RenderSystem.setShaderTexture(0, this.moonTexture);
int moonPhase = Minecraft.getInstance().level.getMoonPhase();
int xCoord = moonPhase % 4;
Expand All @@ -104,12 +103,12 @@ public void renderMoon(BufferBuilder bufferBuilder, Matrix4f matrix4f) {
float startY = yCoord / 2.0F;
float endX = (xCoord + 1) / 4.0F;
float endY = (yCoord + 1) / 2.0F;
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.vertex(matrix4f, -20.0F, -100.0F, 20.0F).uv(endX, endY).endVertex();
bufferBuilder.vertex(matrix4f, 20.0F, -100.0F, 20.0F).uv(startX, endY).endVertex();
bufferBuilder.vertex(matrix4f, 20.0F, -100.0F, -20.0F).uv(startX, startY).endVertex();
bufferBuilder.vertex(matrix4f, -20.0F, -100.0F, -20.0F).uv(endX, startY).endVertex();
BufferUploader.drawWithShader(bufferBuilder.end());
BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.addVertex(matrix4f, -20.0F, -100.0F, 20.0F).setUv(endX, endY);
bufferBuilder.addVertex(matrix4f, 20.0F, -100.0F, 20.0F).setUv(startX, endY);
bufferBuilder.addVertex(matrix4f, 20.0F, -100.0F, -20.0F).setUv(startX, startY);
bufferBuilder.addVertex(matrix4f, -20.0F, -100.0F, -20.0F).setUv(endX, startY);
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());
}

public void renderStars(LevelRendererAccessor levelRendererAccessor, float tickDelta, PoseStack poseStack, Matrix4f matrix4f) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ public void renderSkybox(LevelRendererAccessor worldRendererAccess, PoseStack ma

// animations
for (AnimatableTexture animatableTexture : this.animatableTextures) {
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferBuilder = tesselator.getBuilder();

bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);

animatableTexture.tick();
UVRange intersect = Utils.findUVIntersection(faceUVRange, animatableTexture.getUvRange()); // todo: cache this intersections so we don't waste gpu cycles
Expand All @@ -77,13 +73,13 @@ public void renderSkybox(LevelRendererAccessor worldRendererAccess, PoseStack ma

// Render the quad at the calculated position
RenderSystem.setShaderTexture(0, animatableTexture.getTexture().getTextureId());

bufferBuilder.vertex(matrix4f, intersectionOnCurrentTexture.getMinU(), -this.quadSize, intersectionOnCurrentTexture.getMinV()).uv(intersectionOnCurrentFrame.getMinU(), intersectionOnCurrentFrame.getMinV()).endVertex();
bufferBuilder.vertex(matrix4f, intersectionOnCurrentTexture.getMinU(), -this.quadSize, intersectionOnCurrentTexture.getMaxV()).uv(intersectionOnCurrentFrame.getMinU(), intersectionOnCurrentFrame.getMaxV()).endVertex();
bufferBuilder.vertex(matrix4f, intersectionOnCurrentTexture.getMaxU(), -this.quadSize, intersectionOnCurrentTexture.getMaxV()).uv(intersectionOnCurrentFrame.getMaxU(), intersectionOnCurrentFrame.getMaxV()).endVertex();
bufferBuilder.vertex(matrix4f, intersectionOnCurrentTexture.getMaxU(), -this.quadSize, intersectionOnCurrentTexture.getMinV()).uv(intersectionOnCurrentFrame.getMaxU(), intersectionOnCurrentFrame.getMinV()).endVertex();
BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.addVertex(matrix4f, intersectionOnCurrentTexture.getMinU(), -this.quadSize, intersectionOnCurrentTexture.getMinV()).setUv(intersectionOnCurrentFrame.getMinU(), intersectionOnCurrentFrame.getMinV());
bufferBuilder.addVertex(matrix4f, intersectionOnCurrentTexture.getMinU(), -this.quadSize, intersectionOnCurrentTexture.getMaxV()).setUv(intersectionOnCurrentFrame.getMinU(), intersectionOnCurrentFrame.getMaxV());
bufferBuilder.addVertex(matrix4f, intersectionOnCurrentTexture.getMaxU(), -this.quadSize, intersectionOnCurrentTexture.getMaxV()).setUv(intersectionOnCurrentFrame.getMaxU(), intersectionOnCurrentFrame.getMaxV());
bufferBuilder.addVertex(matrix4f, intersectionOnCurrentTexture.getMaxU(), -this.quadSize, intersectionOnCurrentTexture.getMinV()).setUv(intersectionOnCurrentFrame.getMaxU(), intersectionOnCurrentFrame.getMinV());
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());
}
BufferUploader.drawWithShader(bufferBuilder.end());
}

matrices.popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public Texture getTexture() {

@Override
public void renderSkybox(LevelRendererAccessor worldRendererAccess, PoseStack matrices, float tickDelta, Camera camera, boolean thickFog, Runnable runnable) {
Tesselator tessellator = Tesselator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuilder();
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
RenderSystem.setShaderTexture(0, this.texture.getTextureId());
for (int face = 0; face < 6; face++) {
// 0 = bottom
Expand Down Expand Up @@ -62,12 +60,12 @@ public void renderSkybox(LevelRendererAccessor worldRendererAccess, PoseStack ma
}

Matrix4f matrix4f = matrices.last().pose();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).uv(tex.getMinU(), tex.getMinV()).endVertex();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).uv(tex.getMinU(), tex.getMaxV()).endVertex();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).uv(tex.getMaxU(), tex.getMaxV()).endVertex();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).uv(tex.getMaxU(), tex.getMinV()).endVertex();
bufferBuilder.addVertex(matrix4f, -100.0F, -100.0F, -100.0F).setUv(tex.getMinU(), tex.getMinV());
bufferBuilder.addVertex(matrix4f, -100.0F, -100.0F, 100.0F).setUv(tex.getMinU(), tex.getMaxV());
bufferBuilder.addVertex(matrix4f, 100.0F, -100.0F, 100.0F).setUv(tex.getMaxU(), tex.getMaxV());
bufferBuilder.addVertex(matrix4f, 100.0F, -100.0F, -100.0F).setUv(tex.getMaxU(), tex.getMinV());
matrices.popPose();
}
BufferUploader.drawWithShader(bufferBuilder.end());
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ public void render(LevelRendererAccessor worldRendererAccess, PoseStack matrices
Minecraft client = Minecraft.getInstance();
assert client.level != null;

BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();

RenderSystem.enableBlend();
RenderSystem.depthMask(false);
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
RenderSystem.setShaderTexture(0, LevelRendererAccessor.getEndSky());
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);

for (int i = 0; i < 6; ++i) {
matrices.pushPose();
Expand All @@ -60,13 +58,13 @@ public void render(LevelRendererAccessor worldRendererAccess, PoseStack matrices
}

Matrix4f matrix4f = matrices.last().pose();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).uv(0.0F, 0.0F).color(40, 40, 40, (int) (255 * this.alpha)).endVertex();
bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).uv(0.0F, 16.0F).color(40, 40, 40, (int) (255 * this.alpha)).endVertex();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).uv(16.0F, 16.0F).color(40, 40, 40, (int) (255 * this.alpha)).endVertex();
bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).uv(16.0F, 0.0F).color(40, 40, 40, (int) (255 * this.alpha)).endVertex();
bufferBuilder.addVertex(matrix4f, -100.0F, -100.0F, -100.0F).setUv(0.0F, 0.0F).setColor(40, 40, 40, (int) (255 * this.alpha));
bufferBuilder.addVertex(matrix4f, -100.0F, -100.0F, 100.0F).setUv(0.0F, 16.0F).setColor(40, 40, 40, (int) (255 * this.alpha));
bufferBuilder.addVertex(matrix4f, 100.0F, -100.0F, 100.0F).setUv(16.0F, 16.0F).setColor(40, 40, 40, (int) (255 * this.alpha));
bufferBuilder.addVertex(matrix4f, 100.0F, -100.0F, -100.0F).setUv(16.0F, 0.0F).setColor(40, 40, 40, (int) (255 * this.alpha));
matrices.popPose();
}
BufferUploader.drawWithShader(bufferBuilder.end());
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());

RenderSystem.depthMask(true);
RenderSystem.disableBlend();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public void render(LevelRendererAccessor worldRendererAccess, PoseStack matrices
ClientLevel world = client.level;
assert client.level != null;

BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();

Vec3 vec3d = world.getSkyColor(client.gameRenderer.getMainCamera().getPosition(), tickDelta);
float f = (float) vec3d.x;
float g = (float) vec3d.y;
Expand Down Expand Up @@ -78,17 +76,17 @@ public void render(LevelRendererAccessor worldRendererAccess, PoseStack matrices
float k = fs[1];
float l = fs[2];
Matrix4f matrix4f = matrices.last().pose();
bufferBuilder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
bufferBuilder.vertex(matrix4f, 0.0F, 100.0F, 0.0F).color(j, k, l, fs[3] * this.alpha).endVertex();
BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
bufferBuilder.addVertex(matrix4f, 0.0F, 100.0F, 0.0F).setColor(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 = Mth.sin(o);
float q = Mth.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).endVertex();
bufferBuilder.addVertex(matrix4f, p * 120.0F, q * 120.0F, -q * 40.0F * fs[3]).setColor(fs[0], fs[1], fs[2], 0.0F);
}

BufferUploader.drawWithShader(bufferBuilder.end());
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());
matrices.popPose();
}

Expand Down
4 changes: 2 additions & 2 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ dependencies {
// Architectury API. This is optional, and you can comment it out if you don't need it.
// modImplementation "dev.architectury:architectury-fabric:$rootProject.architectury_api_version"

modImplementation "maven.modrinth:sodium:mc1.20.6-0.5.8"
modImplementation "maven.modrinth:lithium:mc1.20.6-0.12.3"
//modImplementation "maven.modrinth:sodium:mc1.20.6-0.5.8"
//modImplementation "maven.modrinth:lithium:mc1.20.6-0.12.3"

common(project(path: ':common', configuration: 'namedElements')) { transitive false }
shadowBundle project(path: ':common', configuration: 'transformProductionFabric')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void onInitializeClient() {
ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
@Override
public ResourceLocation getFabricId() {
return new ResourceLocation(NuitClient.MOD_ID, "skybox_reader");
return ResourceLocation.tryBuild(NuitClient.MOD_ID, "skybox_reader");
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ org.gradle.parallel=true
mod_version=1.0.0
maven_group=io.github.amerebagatelle.mods
archives_name=nuit
enabled_platforms=fabric,neoforge
enabled_platforms=fabric
# Minecraft properties
minecraft_version=1.20.6
minecraft_version=1.21-rc1
# Dependencies
architectury_api_version=12.1.2
fabric_loader_version=0.15.11
fabric_api_version=0.100.0+1.20.6
fabric_api_version=0.100.1+1.21
neoforge_version=20.6.116
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ rootProject.name = 'nuit'

include("common")
include("fabric")
include("neoforge")
//include("neoforge")

0 comments on commit f085dd7

Please sign in to comment.