Skip to content

Commit

Permalink
the wheel is gone
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Jun 7, 2024
1 parent e29314c commit 2f83dcc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,6 @@ public VertexConsumer setNormal(float x, float y, float z) {
return this;
}

public VertexConsumer endVertex() {
if (!filledPosition || !filledTexture || !filledNormal) {
throw new IllegalStateException("Not filled all elements of the vertex");
}

filledPosition = false;
filledTexture = false;
filledNormal = false;
vertexCount++;

long byteSize = (vertexCount + 1) * STRIDE;
long capacity = data.size();
if (byteSize > capacity) {
data = data.realloc(capacity * 2);
}

return this;
}

private long vertexPtr() {
return data.ptr() + vertexCount * STRIDE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import java.util.SortedSet;

import com.llamalad7.mixinextras.sugar.Share;

import com.llamalad7.mixinextras.sugar.ref.LocalRef;

import net.minecraft.client.DeltaTracker;

import org.jetbrains.annotations.Nullable;
Expand All @@ -15,6 +19,7 @@
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.mojang.blaze3d.vertex.PoseStack;
Expand Down Expand Up @@ -52,11 +57,19 @@ abstract class LevelRendererMixin {

// @Inject(method = "renderLevel", at = @At("HEAD"))
@Inject(method = "renderLevel", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"))
private void flywheel$beginRender(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, Matrix4f frustrumMatrix, CallbackInfo ci) {
private void flywheel$beginRender(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightTexture, Matrix4f projectionMatrix, Matrix4f frustrumMatrix, CallbackInfo ci, @Share("poseStack") LocalRef<PoseStack> sharedPose) {
PoseStack pose = new PoseStack();
// fixme - is the delta stuff correct? no idea!
flywheel$renderContext = RenderContextImpl.create((LevelRenderer) (Object) this, level, renderBuffers, new PoseStack(), projectionMatrix, camera, deltaTracker.getGameTimeDeltaTicks());
flywheel$renderContext = RenderContextImpl.create((LevelRenderer) (Object) this, level, renderBuffers, pose, projectionMatrix, camera, deltaTracker.getGameTimeDeltaTicks());

FlwImplXplat.INSTANCE.dispatchBeginFrameEvent(flywheel$renderContext);

sharedPose.set(pose);
}

@Redirect(method = "renderLevel", at = @At(value = "NEW", target = "com/mojang/blaze3d/vertex/PoseStack"))
private PoseStack flywheel$fixPoseStack(@Share("poseStack") LocalRef<PoseStack> sharedPose) {
return sharedPose.get();
}

@Inject(method = "renderLevel", at = @At("RETURN"))
Expand Down

0 comments on commit 2f83dcc

Please sign in to comment.