From 063ea3f1255f3d2b984350af6bd6a0368af29d9c Mon Sep 17 00:00:00 2001 From: My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> Date: Wed, 25 Dec 2024 15:49:29 -0500 Subject: [PATCH] refactor: preprocess LivingEntityPreRenderEvent --- .../render/MixinRendererLivingEntity.java | 23 +++++++++++++++++-- .../gg/skytils/event/impl/render/entity.kt | 19 ++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/events/src/main/java/gg/skytils/event/mixins/render/MixinRendererLivingEntity.java b/events/src/main/java/gg/skytils/event/mixins/render/MixinRendererLivingEntity.java index 4b805267e..003164594 100644 --- a/events/src/main/java/gg/skytils/event/mixins/render/MixinRendererLivingEntity.java +++ b/events/src/main/java/gg/skytils/event/mixins/render/MixinRendererLivingEntity.java @@ -31,12 +31,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; //#if MC>12000 +//$$ import net.minecraft.client.render.entity.model.EntityModel //$$ import net.minecraft.client.render.VertexConsumerProvider; //$$ import net.minecraft.client.util.math.MatrixStack; //#endif @Mixin(RendererLivingEntity.class) -public class MixinRendererLivingEntity { +public class MixinRendererLivingEntity + //#if MC<12000 + + //#else + //$$ > + //#endif +{ //#if MC<12000 @Inject(method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V", at = @At("HEAD"), cancellable = true) private void onRender(T entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { @@ -49,7 +56,19 @@ private void onRender(T entity, double x, double y, double z, float entityYaw, f double renderY = entity.lastTickPosY + (entity.getPositionVector().yCoord - entity.lastTickPosY - viewEntity.getPositionVector().yCoord + viewEntity.lastTickPosY) * partialTicks - viewEntity.lastTickPosY; double renderZ = entity.lastTickPosZ + (entity.getPositionVector().zCoord - entity.lastTickPosZ - viewEntity.getPositionVector().zCoord + viewEntity.lastTickPosZ) * partialTicks - viewEntity.lastTickPosZ; @SuppressWarnings("unchecked") - LivingEntityPreRenderEvent event = new LivingEntityPreRenderEvent<>(entity, (RendererLivingEntity) (Object) this, renderX, renderY, renderZ, partialTicks); + //#if MC<12000 + LivingEntityPreRenderEvent + //#else + //$$ LivingEntityPreRenderEvent + //#endif + event = + new LivingEntityPreRenderEvent<>(entity, + //#if MC<12000 + (RendererLivingEntity) (Object) this, + //#else + //$$ (LivingEntityRenderer) (Object) this, + //#endif + renderX, renderY, renderZ, partialTicks); if (EventsKt.postCancellableSync(event)) { ci.cancel(); } diff --git a/events/src/main/kotlin/gg/skytils/event/impl/render/entity.kt b/events/src/main/kotlin/gg/skytils/event/impl/render/entity.kt index bf4d5696d..15b4ce690 100644 --- a/events/src/main/kotlin/gg/skytils/event/impl/render/entity.kt +++ b/events/src/main/kotlin/gg/skytils/event/impl/render/entity.kt @@ -24,11 +24,28 @@ import net.minecraft.client.renderer.entity.RendererLivingEntity import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase +//#if MC>12000 +//$$ import net.minecraft.client.render.entity.model.EntityModel +//#endif /** * [gg.skytils.event.mixins.render.MixinRendererLivingEntity.onRender] */ -class LivingEntityPreRenderEvent(val entity: T, val renderer: RendererLivingEntity, val x: Double, val y: Double, val z: Double, val partialTicks: Float) : CancellableEvent() +class LivingEntityPreRenderEvent +//#if MC<12000 + + //#else + //$$ > + //#endif + ( + val entity: T, + //#if MC<12000 + val renderer: RendererLivingEntity, + //#else + //$$ val renderer: LivingEntityRenderer, + //#endif + val x: Double, val y: Double, val z: Double, val partialTicks: Float + ) : CancellableEvent() /** * [gg.skytils.event.mixins.render.MixinRendererLivingEntity.onRenderPost]