Skip to content

Commit

Permalink
[OC-40] Add PostWorldRenderEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Dec 24, 2024
1 parent a4dc116 commit ebb9a0e
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.polyfrost.oneconfig.api.event.v1.events;

import org.polyfrost.universal.UMatrixStack;

public class PostWorldRenderEvent implements Event {

private final UMatrixStack stack;

private final float partialTicks;

public PostWorldRenderEvent(UMatrixStack stack, float partialTicks) {
this.stack = stack;
this.partialTicks = partialTicks;
}

public UMatrixStack getStack() {
return stack;
}

public float getPartialTicks() {
return partialTicks;
}

}
3 changes: 3 additions & 0 deletions versions/mappings/forge-1.16.5-1.12.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ net.minecraft.client.network.play.NetworkPlayerInfo net.minecraft.client.network
net.minecraft.client.shader.ShaderDefault net.minecraft.client.shader.ShaderUniform
net.minecraft.client.shader.ShaderInstance net.minecraft.client.shader.ShaderManager

net.minecraft.client.renderer.GameRenderer net.minecraft.client.renderer.EntityRenderer
net.minecraft.client.renderer.GameRenderer renderWorld() renderWorldPass()

net.minecraft.client.world.ClientWorld net.minecraft.client.multiplayer.WorldClient

net.minecraft.network.IPacket net.minecraft.network.Packet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package org.polyfrost.oneconfig.internal.mixin;

import net.minecraft.client.renderer.EntityRenderer;
import org.polyfrost.oneconfig.api.event.v1.EventManager;
import org.polyfrost.oneconfig.api.event.v1.events.PostWorldRenderEvent;
import org.polyfrost.universal.UMatrixStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EntityRenderer.class)
public class EntityRendererMixin {

@Inject(
method = "renderWorldPass",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V",
//#if FABRIC
//$$ ordinal = 1
//#else
//#if MC >= 1.16.5
//$$ ordinal = 1
//#else
ordinal = 2
//#endif
//#endif
),
slice = @Slice(
//#if MC >= 1.16.5
//$$ from = @At(
//$$ value = "INVOKE",
//$$ target = "Lnet/minecraft/client/renderer/WorldRenderer;updateCameraAndRender(Lcom/mojang/blaze3d/matrix/MatrixStack;FJZLnet/minecraft/client/renderer/ActiveRenderInfo;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/util/math/vector/Matrix4f;)V"
//$$ ),
//$$ to = @At(
//$$ value = "INVOKE",
//$$ target = "Lnet/minecraft/client/renderer/GameRenderer;renderHand(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/ActiveRenderInfo;F)V"
//$$ )
//#else
from = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/GlStateManager;disableFog()V"
),
to = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/EntityRenderer;renderHand(FI)V"
)
//#endif
)
)
private void onRenderWorldPass(
//#if MC <= 1.12.2
int pass,
//#endif
float partialTicks,
long finishTimeNano,
//#if MC >= 1.16.5
//$$ com.mojang.blaze3d.matrix.MatrixStack matrixStack,
//#endif
CallbackInfo ci
) {
UMatrixStack stack =
//#if MC >= 1.16.5
//$$ new UMatrixStack(matrixStack);
//#else
new UMatrixStack();
//#endif
EventManager.INSTANCE.post(new PostWorldRenderEvent(stack, partialTicks));
}

}
1 change: 1 addition & 0 deletions versions/src/main/resources/mixins.oneconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ShaderGroupAccessor",
"SoundManagerMixin",
"SoundManagerAccessorMixin",
"EntityRendererMixin",
"WorldClientMixin",
"SoundManagerMixin",
"compat.OptifineConfigMixin",
Expand Down

0 comments on commit ebb9a0e

Please sign in to comment.