diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-28 16:15:58 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2022-09-28 16:15:58 +0200 |
commit | 7b65b874ece9c4379293f208ba1173ace7c4a3ac (patch) | |
tree | 04f2f1244cb40a6f5e434df71fc23c7936c428b9 /src/main/java/at/hannibal2/skyhanni/mixins | |
parent | b1f14f05fe1933d6ad926d821bcf3fcacca0e184 (diff) | |
download | skyhanni-7b65b874ece9c4379293f208ba1173ace7c4a3ac.tar.gz skyhanni-7b65b874ece9c4379293f208ba1173ace7c4a3ac.tar.bz2 skyhanni-7b65b874ece9c4379293f208ba1173ace7c4a3ac.zip |
used kotlin for the mixin classes, deleted some hooks
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/mixins')
12 files changed, 142 insertions, 208 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt deleted file mode 100644 index b18d80613..000000000 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetHandlerPlayClientHook.kt +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100644 index b9265587a..000000000 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 48d98fb5d..000000000 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderItemHook.kt +++ /dev/null @@ -1,33 +0,0 @@ -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 deleted file mode 100644 index 3e3283662..000000000 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/RenderManagerHook.kt +++ /dev/null @@ -1,25 +0,0 @@ -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<Boolean> -) { - 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 4f951a887..8b6fce6b3 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.mixinhooks.render +package at.hannibal2.skyhanni.mixins.hooks.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 41091580e..edd2c7abc 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) -public interface AccessorGuiPlayerTabOverlay { - @Accessor("footer") - IChatComponent getFooter(); -} +@Mixin(GuiPlayerTabOverlay::class) +interface AccessorGuiPlayerTabOverlay { + @get:Accessor("footer") + val footer: IChatComponent? +}
\ No newline at end of file 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 bd4107369..f620797c8 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetHandlerPlayClient.kt @@ -1,24 +1,25 @@ -package at.hannibal2.skyhanni.mixins.transformers; +package at.hannibal2.skyhanni.mixins.transformers -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; +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 -@Mixin(value = NetHandlerPlayClient.class, priority = 1001) -public abstract class MixinNetHandlerPlayClient implements INetHandlerPlayClient { +@Mixin(value = [NetHandlerPlayClient::class], priority = 1001) +abstract class MixinNetHandlerPlayClient : INetHandlerPlayClient { + //TODO delete this? @Shadow - private WorldClient clientWorldController; + private val clientWorldController: WorldClient? = null - @Inject(method = "addToSendQueue", at = @At("HEAD"), cancellable = true) - private void onSendPacket(Packet<?> packet, CallbackInfo ci) { - NetHandlerPlayClientHookKt.onSendPacket(packet, ci); + @Inject(method = ["addToSendQueue"], at = [At("HEAD")], cancellable = true) + private 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/transformers/MixinNetworkManager.kt b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.kt index 459da17a1..b386a27f7 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinNetworkManager.kt @@ -1,20 +1,19 @@ -package at.hannibal2.skyhanni.mixins.transformers; +package at.hannibal2.skyhanni.mixins.transformers -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; +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 -@Mixin(value = NetworkManager.class, priority = 1001) -public abstract class MixinNetworkManager extends SimpleChannelInboundHandler<Packet<?>> { - - @Inject(method = "channelRead0", at = @At("HEAD"), cancellable = true) - private void onReceivePacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) { - NetworkManagerHookKt.onReceivePacket(context, packet, ci); +@Mixin(value = [NetworkManager::class], priority = 1001) +abstract class MixinNetworkManager : SimpleChannelInboundHandler<Packet<*>?>() { + @Inject(method = ["channelRead0"], at = [At("HEAD")], cancellable = true) + private 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/transformers/MixinRenderItem.kt b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.kt index ebd3161ce..c0dcffcb2 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderItem.kt @@ -1,46 +1,42 @@ -package at.hannibal2.skyhanni.mixins.transformers; +package at.hannibal2.skyhanni.mixins.transformers -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; +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 -@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); +@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() } - // @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 = ["renderEffect"], at = [At("HEAD")], cancellable = true) + fun onRenderEffect(ci: CallbackInfo) { + ci.cancel() } - @Inject(method = "renderItemIntoGUI", at = @At("RETURN")) - public void renderItemReturn(ItemStack stack, int x, int y, CallbackInfo ci) { - RenderItemHookKt.renderItemReturn(stack, x, y, ci); + @Inject(method = ["renderItemIntoGUI"], at = [At("RETURN")]) + fun renderItemReturn(stack: ItemStack?, x: Int, y: Int, ci: CallbackInfo?) { + RenderRealOverlayEvent(stack, x, y).postAndCatch() } -} +}
\ 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 e36b87195..710e79565 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinRenderManager.kt @@ -1,19 +1,25 @@ -package at.hannibal2.skyhanni.mixins.transformers; +package at.hannibal2.skyhanni.mixins.transformers -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; +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 -@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<Boolean> cir) { - RenderManagerHookKt.shouldRender(entityIn, camera, camX, camY, camZ, cir); +@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<Boolean> + ) { + 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/transformers/renderer/MixinBlockRendererDispatcher.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java index 26c9ab76f..32324ce7f 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.mixinhooks.render.BlockRendererDispatcherHookKt; +import at.hannibal2.skyhanni.mixins.hooks.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 657636e87..fdeb6c9cb 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,35 +1,44 @@ -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) -public abstract class MixinRendererLivingEntity<T extends EntityLivingBase> extends Render<T> { - protected MixinRendererLivingEntity(RenderManager renderManager) { - super(renderManager); +@Mixin(RendererLivingEntity::class) +abstract class MixinRendererLivingEntity<T : EntityLivingBase?> protected constructor(renderManager: RenderManager?) : + Render<T>(renderManager) { + @Inject(method = ["getColorMultiplier"], at = [At("HEAD")], cancellable = true) + private fun setColorMultiplier( + entity: T, + lightBrightness: Float, + partialTickTime: Float, + cir: CallbackInfoReturnable<Int> + ) { + val event = RenderMobColoredEvent(entity as EntityLivingBase, 0) + event.postAndCatch() + cir.returnValue = event.color } - @Inject(method = "getColorMultiplier", at = @At("HEAD"), cancellable = true) - private void setColorMultiplier(T entity, float lightBrightness, float partialTickTime, CallbackInfoReturnable<Integer> 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; + @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 } }
\ No newline at end of file |