|
24 | 24 | import net.minecraft.entity.Entity; |
25 | 25 | import org.spongepowered.asm.mixin.Mixin; |
26 | 26 | import org.spongepowered.asm.mixin.injection.At; |
27 | | -import org.spongepowered.asm.mixin.injection.Redirect; |
| 27 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 28 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 29 | +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; |
28 | 30 |
|
29 | 31 | /** |
30 | 32 | * @author Brady |
|
33 | 35 | @Mixin(RenderManager.class) |
34 | 36 | public class MixinRenderManager { |
35 | 37 |
|
36 | | - @Redirect(method = "renderEntity(Lnet/minecraft/entity/Entity;DDDFFZ)V", at = @At(value = "INVOKE", target = "net/minecraft/client/renderer/entity/Render.doRender(Lnet/minecraft/entity/Entity;DDDFF)V")) |
37 | | - @SuppressWarnings("unchecked") |
38 | | - private void renderEntity$doRender(Render render, Entity entity, double x, double y, double z, float entityYaw, float partialTicks) { |
39 | | - EntityRenderEvent event = new EntityRenderEvent(EventState.PRE, render, entity, x, y, z, entityYaw, partialTicks); |
40 | | - ClientAPI.EVENT_BUS.post(event); |
41 | | - if (!event.isCancelled()) |
42 | | - render.doRender(entity, x, y, z, entityYaw, partialTicks); |
| 38 | + @Inject( |
| 39 | + method = "renderEntity", |
| 40 | + at = @At( |
| 41 | + value = "INVOKE", |
| 42 | + target = "net/minecraft/client/renderer/entity/Render.setRenderOutlines(Z)V"), |
| 43 | + locals = LocalCapture.CAPTURE_FAILHARD, |
| 44 | + cancellable = true |
| 45 | + ) |
| 46 | + private void preRenderEntity(Entity entityIn, double x, double y, double z, float yaw, float partialTicks, boolean p_188391_10_, CallbackInfo ci, Render render) { |
| 47 | + EntityRenderEvent entityRenderEvent = new EntityRenderEvent(EventState.PRE, render, entityIn, x, y, z, yaw, partialTicks); |
| 48 | + ClientAPI.EVENT_BUS.post(entityRenderEvent); |
| 49 | + if (entityRenderEvent.isCancelled()) { |
| 50 | + ci.cancel(); |
| 51 | + } |
| 52 | + } |
43 | 53 |
|
44 | | - ClientAPI.EVENT_BUS.post(new EntityRenderEvent(EventState.POST, render, entity, x, y, x, entityYaw, partialTicks)); |
| 54 | + @Inject(method = "renderEntity", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD) |
| 55 | + private void postRenderEntity(Entity entityIn, double x, double y, double z, float yaw, float partialTicks, boolean p_188391_10_, CallbackInfo ci, Render render) { |
| 56 | + ClientAPI.EVENT_BUS.post(new EntityRenderEvent(EventState.POST, render, entityIn, x, y, z, yaw, partialTicks)); |
45 | 57 | } |
46 | 58 | } |
0 commit comments