Skip to content

Commit

Permalink
WIP update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Aug 3, 2024
1 parent cd9be50 commit ed36f67
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 29 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,21 @@ jobs:
name: ${{github.ref_name}}-1.20.6 - Fabric
files: 'versions/1.20.6-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.20.6
- name: Publish-1.21-fabric-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 681953
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21 - Fabric
files: 'versions/1.21-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21
- name: Publish-1.21-fabric-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: DynYZEae
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21 - Fabric
files: 'versions/1.21-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21
2 changes: 1 addition & 1 deletion gradle-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: '0.0.2'
source: "https://github.com/tr7zw/ProcessedModTemplate/tree/legacy12006"
source: "https://github.com/tr7zw/ProcessedModTemplate/tree/master"
replacements:
name: "Exordium"
id: "exordium"
Expand Down
3 changes: 2 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"versions": [
"1.20.6-fabric"
"1.20.6-fabric",
"1.21-fabric"
]
}
3 changes: 2 additions & 1 deletion src/main/java/dev/tr7zw/exordium/ExordiumMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

import dev.tr7zw.util.NMSHelper;
import dev.tr7zw.exordium.util.ReloadTracker;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
Expand All @@ -22,7 +23,7 @@ public void onInitializeClient() {
.registerReloadListener(new SimpleResourceReloadListener<>() {
@Override
public ResourceLocation getFabricId() {
return new ResourceLocation("exordium", "reload_listener");
return NMSHelper.getResourceLocation("exordium", "reload_listener");
}

@Override
Expand Down
22 changes: 20 additions & 2 deletions src/main/java/dev/tr7zw/exordium/mixin/CrosshairMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,26 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.DebugScreenOverlay;

//spotless:off
//#if MC >= 12100
import net.minecraft.client.DeltaTracker;
//#endif
//spotless:on

@Mixin(Gui.class)
public class CrosshairMixin {

@Shadow
private DebugScreenOverlay debugOverlay;

@Inject(method = "renderCrosshair", at = @At("HEAD"), cancellable = true)
private void renderCrosshairStart(GuiGraphics guiGraphics, float f, CallbackInfo ci) {
//spotless:off
//#if MC >= 12100
private void renderCrosshairStart(GuiGraphics guiGraphics, DeltaTracker delta, CallbackInfo ci) {
//#else
//$$ private void renderCrosshairStart(GuiGraphics guiGraphics, float f, CallbackInfo ci) {
//#endif
//spotless:on
BufferInstance<DebugScreenOverlay> buffer = ExordiumModBase.instance.getBufferManager()
.getBufferInstance(CrosshairComponent.getId(), DebugScreenOverlay.class);
if (buffer.renderBuffer(0, debugOverlay)) {
Expand All @@ -30,7 +42,13 @@ private void renderCrosshairStart(GuiGraphics guiGraphics, float f, CallbackInfo
}

@Inject(method = "renderCrosshair", at = @At("TAIL"))
private void renderCrosshairEnd(GuiGraphics guiGraphics, float f, CallbackInfo ci) {
//spotless:off
//#if MC >= 12100
private void renderCrosshairEnd(GuiGraphics guiGraphics, DeltaTracker delta, CallbackInfo ci) {
//#else
//$$ private void renderCrosshairEnd(GuiGraphics guiGraphics, float f, CallbackInfo ci) {
//#endif
//spotless:on
BufferInstance<DebugScreenOverlay> buffer = ExordiumModBase.instance.getBufferManager()
.getBufferInstance(CrosshairComponent.getId(), DebugScreenOverlay.class);
buffer.postRender(debugOverlay);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/dev/tr7zw/exordium/mixin/GameRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
@Mixin(value = GameRenderer.class, priority = 500) // needs to be lower to cancel Architectury for REI
public abstract class GameRendererMixin {

@Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lorg/joml/Matrix4f;)V"))
public void renderLevel(GameRenderer gr, Matrix4f matrix4f, float f, long l) {
resetProjectionMatrix(matrix4f);
}
// @Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;resetProjectionMatrix(Lorg/joml/Matrix4f;)V"))
// public void renderLevel(GameRenderer gr, Matrix4f matrix4f, float f, long l) {
// resetProjectionMatrix(matrix4f);
// }

@Shadow
public abstract void resetProjectionMatrix(Matrix4f matrix4f);
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/dev/tr7zw/exordium/mixin/GuiHotbarMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@
import dev.tr7zw.exordium.components.vanilla.HotbarComponent;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.spectator.SpectatorGui;

//spotless:off
//#if MC >= 12100
import net.minecraft.client.DeltaTracker;
//#endif
//spotless:on

@Mixin(Gui.class)
public class GuiHotbarMixin {

//spotless:off
//#if MC >= 12100
@WrapOperation(method = "renderHotbarAndDecorations", at = {
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderItemHotbar(Lnet/minecraft/client/gui/GuiGraphics;F)V"), })
private void renderHotbarWrapper(Gui gui, GuiGraphics guiGraphics, float f, final Operation<Void> operation) {
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderItemHotbar(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V")})
private void renderHotbarWrapper(Gui gui, GuiGraphics guiGraphics, DeltaTracker f, final Operation<Void> operation) {
//#else
//$$ @WrapOperation(method = "renderHotbarAndDecorations", at = {
//$$ @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderItemHotbar(Lnet/minecraft/client/gui/GuiGraphics;F)V")})
//$$ private void renderHotbarWrapper(Gui gui, GuiGraphics guiGraphics, float f, final Operation<Void> operation) {
//#endif
//spotless:on
BufferInstance<Void> buffer = ExordiumModBase.instance.getBufferManager()
.getBufferInstance(HotbarComponent.getId(), Void.class);
if (!buffer.renderBuffer(0, null)) {
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/dev/tr7zw/exordium/mixin/GuiMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
import net.minecraft.world.scores.Objective;
import net.minecraft.world.scores.Scoreboard;

//spotless:off
//#if MC >= 12100
import net.minecraft.client.DeltaTracker;
//#endif
//spotless:on

@Mixin(Gui.class)
public abstract class GuiMixin implements GuiAccess {

Expand Down Expand Up @@ -79,7 +85,13 @@ private void renderBossBarWrapper(BossHealthOverlay instance, GuiGraphics guiGra
}

@Inject(method = "render", at = @At(value = "TAIL"))
public void render(GuiGraphics guiGraphics, float partialTick, CallbackInfo ci) {
//spotless:off
//#if MC >= 12100
public void render(GuiGraphics guiGraphics, DeltaTracker partialTick, CallbackInfo ci) {
//#else
//$$ public void render(GuiGraphics guiGraphics, float partialTick, CallbackInfo ci) {
//#endif
//spotless:on
ExordiumModBase.instance.getDelayedRenderCallManager().renderComponents();
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/dev/tr7zw/exordium/mixin/VignetteMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import dev.tr7zw.exordium.ExordiumModBase;
import dev.tr7zw.exordium.components.BufferInstance;
import dev.tr7zw.exordium.components.vanilla.VignetteComponent;
import dev.tr7zw.util.NMSHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
Expand All @@ -27,9 +28,9 @@ public class VignetteMixin {
@Final
private Minecraft minecraft;

private static ResourceLocation FAST_VIGNETTE_LOCATION = new ResourceLocation("exordium",
private static ResourceLocation FAST_VIGNETTE_LOCATION = NMSHelper.getResourceLocation("exordium",
"textures/misc/fast_vignette.png");
private static ResourceLocation FAST_VIGNETTE_DARK_LOCATION = new ResourceLocation("exordium",
private static ResourceLocation FAST_VIGNETTE_DARK_LOCATION = NMSHelper.getResourceLocation("exordium",
"textures/misc/fast_vignette_dark.png");

@WrapOperation(method = "renderCameraOverlays", at = {
Expand Down
54 changes: 41 additions & 13 deletions src/main/java/dev/tr7zw/exordium/render/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,52 @@
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexBuffer;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat.Mode;

import net.minecraft.client.renderer.ShaderInstance;

//spotless:off
//#if MC >= 12100
import com.mojang.blaze3d.vertex.MeshData;
//#else
//$$ import com.mojang.blaze3d.vertex.VertexFormat;
//#endif
//spotless:on

public class Model {
private VertexBuffer toDraw;

public Model(Vector3f[] modelData, Vector2f[] uvData) {
// 4 bytes per float, 5 floats per entry
BufferBuilder bufferbuilder = new BufferBuilder(modelData.length * 4 * 5);

bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
// spotless:off
//#if MC >= 12100
BufferBuilder bufferbuilder = Tesselator.getInstance().begin(Mode.QUADS, DefaultVertexFormat.POSITION_TEX); //new BufferBuilder(modelData.length * 4 * 5);
//#else
//$$ BufferBuilder bufferbuilder = new BufferBuilder(modelData.length * 4 * 5);
//$$ bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
//#endif
//spotless:on
for (int i = 0; i < modelData.length; i++) {
Vector3f pos = modelData[i];
Vector2f uv = uvData[i];
bufferbuilder.vertex(pos.x(), pos.y(), pos.z()).uv(uv.x(), uv.y()).endVertex();
// spotless:off
//#if MC >= 12100
bufferbuilder.addVertex(pos.x(), pos.y(), pos.z()).setUv(uv.x(), uv.y());
//#else
//$$ bufferbuilder.vertex(pos.x(), pos.y(), pos.z()).uv(uv.x(), uv.y()).endVertex();
//#endif
//spotless:on
}
toDraw = new VertexBuffer(VertexBuffer.Usage.STATIC);
upload(bufferbuilder.end());
// spotless:off
//#if MC >= 12100
upload(bufferbuilder.build());
//#else
//$$ upload(bufferbuilder.end());
//#endif
//spotless:on
}

public void drawWithShader(Matrix4f matrix4f, Matrix4f matrix4f2, ShaderInstance shaderInstance) {
Expand All @@ -37,14 +63,16 @@ public void draw(Matrix4f matrix4f) {
drawWithShader(matrix4f, RenderSystem.getProjectionMatrix(), RenderSystem.getShader());
}

private void upload(BufferBuilder.RenderedBuffer renderedBuffer) {
// spotless:off
//#if MC >= 12100
private void upload(MeshData renderedBuffer) {
//#else
//$$ private void upload(BufferBuilder.RenderedBuffer renderedBuffer) {
//#endif
//spotless:on
RenderSystem.assertOnRenderThread();
if (renderedBuffer.isEmpty()) {
renderedBuffer.release();
} else {
toDraw.bind();
toDraw.upload(renderedBuffer);
}
toDraw.bind();
toDraw.upload(renderedBuffer);
}

public void close() {
Expand Down
2 changes: 1 addition & 1 deletion versions/mainProject
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20.6-fabric
1.21-fabric

0 comments on commit ed36f67

Please sign in to comment.