From 24a5d83f713f3798074219e9755d7bf799072cc6 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Wed, 28 Sep 2022 18:55:13 +0200 Subject: Revert "used kotlin for the mixin classes, deleted some hooks" This reverts commit ebba81525c95339d8c4a9753eeb9981caa015e32. --- .../skyhanni/events/CheckRenderEntityEvent.kt | 2 +- .../mixins/hooks/NetHandlerPlayClientHook.kt | 9 +++ .../skyhanni/mixins/hooks/NetworkManagerHook.kt | 10 +++ .../skyhanni/mixins/hooks/RenderItemHook.kt | 33 ++++++++++ .../skyhanni/mixins/hooks/RenderManagerHook.kt | 25 ++++++++ .../hooks/render/BlockRendererDispatcherHook.kt | 2 +- .../transformers/AccessorGuiPlayerTabOverlay.kt | 20 +++--- .../transformers/MixinNetHandlerPlayClient.kt | 37 ++++++----- .../mixins/transformers/MixinNetworkManager.kt | 33 +++++----- .../mixins/transformers/MixinRenderItem.kt | 74 ++++++++++++---------- .../mixins/transformers/MixinRenderManager.kt | 38 +++++------ .../renderer/MixinBlockRendererDispatcher.java | 2 +- .../renderer/MixinRendererLivingEntity.kt | 67 +++++++++----------- 13 files changed, 209 insertions(+), 143 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderManagerHook.kt (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt index 386144128..bd9a816cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt @@ -5,7 +5,7 @@ import net.minecraft.entity.Entity import net.minecraftforge.fml.common.eventhandler.Cancelable @Cancelable -class CheckRenderEntityEvent( +data class CheckRenderEntityEvent( val entity: T, val camera: ICamera, val camX: Double, diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt new file mode 100644 index 000000000..b18d80613 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt @@ -0,0 +1,9 @@ +package at.hannibal2.skyhanni.mixins.hooks + +import at.hannibal2.skyhanni.events.PacketEvent +import net.minecraft.network.Packet +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo + +fun onSendPacket(packet: Packet<*>, ci: CallbackInfo) { + if (PacketEvent.SendEvent(packet).postAndCatch()) ci.cancel() +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt new file mode 100644 index 000000000..b9265587a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt @@ -0,0 +1,10 @@ +package at.hannibal2.skyhanni.mixins.hooks + +import at.hannibal2.skyhanni.events.PacketEvent +import io.netty.channel.ChannelHandlerContext +import net.minecraft.network.Packet +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo + +fun onReceivePacket(context: ChannelHandlerContext, packet: Packet<*>, ci: CallbackInfo) { + if (PacketEvent.ReceiveEvent(packet).postAndCatch()) ci.cancel() +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt new file mode 100644 index 000000000..48d98fb5d --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt @@ -0,0 +1,33 @@ +package at.hannibal2.skyhanni.mixins.hooks + +import at.hannibal2.skyhanni.events.GuiRenderItemEvent +import at.hannibal2.skyhanni.events.RenderRealOverlayEvent +import net.minecraft.client.gui.FontRenderer +import net.minecraft.item.ItemStack +import net.minecraft.util.ResourceLocation +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo + +val RES_ITEM_GLINT = ResourceLocation("textures/misc/enchanted_item_glint.png") + +var skipGlint = false + +fun renderItemOverlayPost( + fr: FontRenderer, + stack: ItemStack?, + xPosition: Int, + yPosition: Int, + text: String?, + ci: CallbackInfo +) { + GuiRenderItemEvent.RenderOverlayEvent.Post( + fr, + stack, + xPosition, + yPosition, + text + ).postAndCatch() +} + +fun renderItemReturn(stack: ItemStack, x: Int, y: Int, ci: CallbackInfo) { + RenderRealOverlayEvent(stack, x, y).postAndCatch() +} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderManagerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderManagerHook.kt new file mode 100644 index 000000000..3e3283662 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderManagerHook.kt @@ -0,0 +1,25 @@ +package at.hannibal2.skyhanni.mixins.hooks + +import at.hannibal2.skyhanni.events.CheckRenderEntityEvent +import net.minecraft.client.renderer.culling.ICamera +import net.minecraft.entity.Entity +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable + +fun shouldRender( + entityIn: Entity, + camera: ICamera, + camX: Double, + camY: Double, + camZ: Double, + cir: CallbackInfoReturnable +) { + if ( + CheckRenderEntityEvent( + entityIn, + camera, + camX, + camY, + camZ + ).postAndCatch() + ) cir.returnValue = false +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/render/BlockRendererDispatcherHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/render/BlockRendererDispatcherHook.kt index 8b6fce6b3..4f951a887 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/render/BlockRendererDispatcherHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/render/BlockRendererDispatcherHook.kt @@ -1,4 +1,4 @@ -package at.hannibal2.skyhanni.mixins.hooks.render +package at.hannibal2.skyhanni.mixinhooks.render import at.hannibal2.skyhanni.events.RenderBlockInWorldEvent import net.minecraft.block.state.IBlockState diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/AccessorGuiPlayerTabOverlay.kt b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/AccessorGuiPlayerTabOverlay.kt index edd2c7abc..41091580e 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/AccessorGuiPlayerTabOverlay.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/AccessorGuiPlayerTabOverlay.kt @@ -1,12 +1,12 @@ -package at.hannibal2.skyhanni.mixins.transformers +package at.hannibal2.skyhanni.mixins.transformers; -import net.minecraft.client.gui.GuiPlayerTabOverlay -import net.minecraft.util.IChatComponent -import org.spongepowered.asm.mixin.Mixin -import org.spongepowered.asm.mixin.gen.Accessor +import net.minecraft.client.gui.GuiPlayerTabOverlay; +import net.minecraft.util.IChatComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(GuiPlayerTabOverlay::class) -interface AccessorGuiPlayerTabOverlay { - @get:Accessor("footer") - val footer: IChatComponent? -} \ No newline at end of file +@Mixin(GuiPlayerTabOverlay.class) +public interface AccessorGuiPlayerTabOverlay { + @Accessor("footer") + IChatComponent getFooter(); +} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.kt b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.kt index f620797c8..bd4107369 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.kt @@ -1,25 +1,24 @@ -package at.hannibal2.skyhanni.mixins.transformers +package at.hannibal2.skyhanni.mixins.transformers; -import at.hannibal2.skyhanni.events.PacketEvent -import net.minecraft.client.multiplayer.WorldClient -import net.minecraft.client.network.NetHandlerPlayClient -import net.minecraft.network.Packet -import net.minecraft.network.play.INetHandlerPlayClient -import org.spongepowered.asm.mixin.Mixin -import org.spongepowered.asm.mixin.Shadow -import org.spongepowered.asm.mixin.injection.At -import org.spongepowered.asm.mixin.injection.Inject -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import at.hannibal2.skyhanni.mixins.hooks.NetHandlerPlayClientHookKt; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.Packet; +import net.minecraft.network.play.INetHandlerPlayClient; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -@Mixin(value = [NetHandlerPlayClient::class], priority = 1001) -abstract class MixinNetHandlerPlayClient : INetHandlerPlayClient { +@Mixin(value = NetHandlerPlayClient.class, priority = 1001) +public abstract class MixinNetHandlerPlayClient implements INetHandlerPlayClient { - //TODO delete this? @Shadow - private val clientWorldController: WorldClient? = null + private WorldClient clientWorldController; - @Inject(method = ["addToSendQueue"], at = [At("HEAD")], cancellable = true) - private fun onSendPacket(packet: Packet<*>, ci: CallbackInfo) { - if (PacketEvent.SendEvent(packet).postAndCatch()) ci.cancel() + @Inject(method = "addToSendQueue", at = @At("HEAD"), cancellable = true) + private void onSendPacket(Packet packet, CallbackInfo ci) { + NetHandlerPlayClientHookKt.onSendPacket(packet, ci); } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.kt b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.kt index b386a27f7..459da17a1 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.kt @@ -1,19 +1,20 @@ -package at.hannibal2.skyhanni.mixins.transformers +package at.hannibal2.skyhanni.mixins.transformers; -import at.hannibal2.skyhanni.events.PacketEvent -import io.netty.channel.ChannelHandlerContext -import io.netty.channel.SimpleChannelInboundHandler -import net.minecraft.network.NetworkManager -import net.minecraft.network.Packet -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.callback.CallbackInfo +import at.hannibal2.skyhanni.mixins.hooks.NetworkManagerHookKt; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +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.callback.CallbackInfo; -@Mixin(value = [NetworkManager::class], priority = 1001) -abstract class MixinNetworkManager : SimpleChannelInboundHandler?>() { - @Inject(method = ["channelRead0"], at = [At("HEAD")], cancellable = true) - private fun onReceivePacket(context: ChannelHandlerContext, packet: Packet<*>, ci: CallbackInfo) { - if (PacketEvent.ReceiveEvent(packet).postAndCatch()) ci.cancel() +@Mixin(value = NetworkManager.class, priority = 1001) +public abstract class MixinNetworkManager extends SimpleChannelInboundHandler> { + + @Inject(method = "channelRead0", at = @At("HEAD"), cancellable = true) + private void onReceivePacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { + NetworkManagerHookKt.onReceivePacket(context, packet, ci); } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.kt b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.kt index c0dcffcb2..ebd3161ce 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.kt @@ -1,42 +1,46 @@ -package at.hannibal2.skyhanni.mixins.transformers +package at.hannibal2.skyhanni.mixins.transformers; -import at.hannibal2.skyhanni.events.GuiRenderItemEvent -import at.hannibal2.skyhanni.events.RenderRealOverlayEvent -import net.minecraft.client.gui.FontRenderer -import net.minecraft.client.renderer.entity.RenderItem -import net.minecraft.item.ItemStack -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.callback.CallbackInfo +import at.hannibal2.skyhanni.mixins.hooks.RenderItemHookKt; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.item.ItemStack; +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.callback.CallbackInfo; -@Mixin(RenderItem::class) -abstract class MixinRenderItem { - @Inject(method = ["renderItemOverlayIntoGUI"], at = [At("RETURN")]) - private fun renderItemOverlayPost( - fr: FontRenderer, - stack: ItemStack, - xPosition: Int, - yPosition: Int, - text: String, - ci: CallbackInfo - ) { - GuiRenderItemEvent.RenderOverlayEvent.Post( - fr, - stack, - xPosition, - yPosition, - text - ).postAndCatch() +@Mixin(RenderItem.class) +public abstract class MixinRenderItem { + + // @Inject(method = "renderItemIntoGUI", at = @At("HEAD")) + // private void renderRarity(ItemStack stack, int x, int y, CallbackInfo ci) { + // RenderItemHookKt.renderRarity(stack, x, y, ci); + // } + + @Inject(method = "renderItemOverlayIntoGUI", at = @At("RETURN")) + private void renderItemOverlayPost(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) { + RenderItemHookKt.renderItemOverlayPost(fr, stack, xPosition, yPosition, text, ci); } - @Inject(method = ["renderEffect"], at = [At("HEAD")], cancellable = true) - fun onRenderEffect(ci: CallbackInfo) { - ci.cancel() + // @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "net/minecraft/client/renderer/GlStateManager.scale(FFF)V", shift = At.Shift.AFTER)) + // private void renderItemPre(ItemStack stack, IBakedModel model, CallbackInfo ci) { + // RenderItemHookKt.renderItemPre(stack, model, ci); + // } + // + // @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderEffect(Lnet/minecraft/client/resources/model/IBakedModel;)V", shift = At.Shift.BEFORE), cancellable = true) + // private void modifyGlintRendering(ItemStack stack, IBakedModel model, CallbackInfo ci) { + // RenderItemHookKt.modifyGlintRendering(stack, model, ci); + // } + + @Inject(method = "renderEffect", at = @At("HEAD"), cancellable = true) + public void onRenderEffect(CallbackInfo ci) { + if (RenderItemHookKt.getSkipGlint()) { + ci.cancel(); + } } - @Inject(method = ["renderItemIntoGUI"], at = [At("RETURN")]) - fun renderItemReturn(stack: ItemStack?, x: Int, y: Int, ci: CallbackInfo?) { - RenderRealOverlayEvent(stack, x, y).postAndCatch() + @Inject(method = "renderItemIntoGUI", at = @At("RETURN")) + public void renderItemReturn(ItemStack stack, int x, int y, CallbackInfo ci) { + RenderItemHookKt.renderItemReturn(stack, x, y, ci); } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.kt b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.kt index 710e79565..e36b87195 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.kt @@ -1,25 +1,19 @@ -package at.hannibal2.skyhanni.mixins.transformers +package at.hannibal2.skyhanni.mixins.transformers; -import at.hannibal2.skyhanni.events.CheckRenderEntityEvent -import net.minecraft.client.renderer.culling.ICamera -import net.minecraft.client.renderer.entity.RenderManager -import net.minecraft.entity.Entity -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.callback.CallbackInfoReturnable +import at.hannibal2.skyhanni.mixins.hooks.RenderManagerHookKt; +import net.minecraft.client.renderer.culling.ICamera; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.Entity; +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.callback.CallbackInfoReturnable; -@Mixin(RenderManager::class) -class MixinRenderManager { - @Inject(method = ["shouldRender"], at = [At("HEAD")], cancellable = true) - private fun shouldRender( - entityIn: Entity, - camera: ICamera, - camX: Double, - camY: Double, - camZ: Double, - cir: CallbackInfoReturnable - ) { - if (CheckRenderEntityEvent(entityIn, camera, camX, camY, camZ).postAndCatch()) cir.returnValue = false +@Mixin(RenderManager.class) +public class MixinRenderManager { + + @Inject(method = "shouldRender", at = @At("HEAD"), cancellable = true) + private void shouldRender(Entity entityIn, ICamera camera, double camX, double camY, double camZ, CallbackInfoReturnable cir) { + RenderManagerHookKt.shouldRender(entityIn, camera, camX, camY, camZ, cir); } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java index 32324ce7f..26c9ab76f 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.mixins.transformers.renderer; -import at.hannibal2.skyhanni.mixins.hooks.render.BlockRendererDispatcherHookKt; +import at.hannibal2.skyhanni.mixinhooks.render.BlockRendererDispatcherHookKt; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.resources.IResourceManagerReloadListener; diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.kt b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.kt index fdeb6c9cb..657636e87 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinRendererLivingEntity.kt @@ -1,44 +1,35 @@ -package at.hannibal2.skyhanni.mixins.transformers.renderer +package at.hannibal2.skyhanni.mixins.transformers.renderer; -import at.hannibal2.skyhanni.events.RenderMobColoredEvent -import at.hannibal2.skyhanni.events.ResetEntityHurtEvent -import net.minecraft.client.renderer.entity.Render -import net.minecraft.client.renderer.entity.RenderManager -import net.minecraft.client.renderer.entity.RendererLivingEntity -import net.minecraft.entity.EntityLivingBase -import org.objectweb.asm.Opcodes -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.Redirect -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import at.hannibal2.skyhanni.events.RenderMobColoredEvent; +import at.hannibal2.skyhanni.events.ResetEntityHurtEvent; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.entity.EntityLivingBase; +import org.objectweb.asm.Opcodes; +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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(RendererLivingEntity::class) -abstract class MixinRendererLivingEntity protected constructor(renderManager: RenderManager?) : - Render(renderManager) { - @Inject(method = ["getColorMultiplier"], at = [At("HEAD")], cancellable = true) - private fun setColorMultiplier( - entity: T, - lightBrightness: Float, - partialTickTime: Float, - cir: CallbackInfoReturnable - ) { - val event = RenderMobColoredEvent(entity as EntityLivingBase, 0) - event.postAndCatch() - cir.returnValue = event.color +@Mixin(RendererLivingEntity.class) +public abstract class MixinRendererLivingEntity extends Render { + protected MixinRendererLivingEntity(RenderManager renderManager) { + super(renderManager); } - @Redirect( - method = ["setBrightness"], - at = At( - value = "FIELD", - target = "Lnet/minecraft/entity/EntityLivingBase;hurtTime:I", - opcode = Opcodes.GETFIELD - ) - ) - private fun changeHurtTime(entity: EntityLivingBase): Int { - val event = ResetEntityHurtEvent(entity, false) - event.postAndCatch() - return if (event.shouldReset) 0 else entity.hurtTime + @Inject(method = "getColorMultiplier", at = @At("HEAD"), cancellable = true) + private void setColorMultiplier(T entity, float lightBrightness, float partialTickTime, CallbackInfoReturnable cir) { + RenderMobColoredEvent event = new RenderMobColoredEvent(entity, 0); + event.postAndCatch(); + cir.setReturnValue(event.getColor()); + } + + @Redirect(method = "setBrightness", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/EntityLivingBase;hurtTime:I", opcode = Opcodes.GETFIELD)) + private int changeHurtTime(EntityLivingBase entity) { + ResetEntityHurtEvent event = new ResetEntityHurtEvent(entity, false); + event.postAndCatch(); + return event.getShouldReset() ? 0 : entity.hurtTime; } } \ No newline at end of file -- cgit