Skip to content

Commit

Permalink
fixed mob spawner hitbox
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Jul 28, 2024
1 parent 3577dc4 commit 0c5b5e3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public class LayerArrowMixin {

@Inject(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderHelper;disableStandardItemLighting()V"))
private void start(EntityLivingBase entitylivingbaseIn, float f, float g, float partialTicks, float h, float i, float j, float scale, CallbackInfo ci) {
HitboxRenderer.INSTANCE.setDrawingLayer(true);
HitboxRenderer.INSTANCE.setShouldCancel(true);
}

@Inject(method = "doRenderLayer", at = @At(value = "TAIL"))
private void end(EntityLivingBase entitylivingbaseIn, float f, float g, float partialTicks, float h, float i, float j, float scale, CallbackInfo ci) {
HitboxRenderer.INSTANCE.setDrawingLayer(false);
HitboxRenderer.INSTANCE.setShouldCancel(false);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.polyfrost.polyhitbox.mixin;

import net.minecraft.client.renderer.tileentity.TileEntityMobSpawnerRenderer;
import net.minecraft.tileentity.MobSpawnerBaseLogic;
import org.polyfrost.polyhitbox.render.HitboxRenderer;
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(TileEntityMobSpawnerRenderer.class)
public class TileEntityMobSpawnerRendererMixin {

@Inject(method = "renderMob", at = @At("HEAD"))
private static void start(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks, CallbackInfo ci) {
HitboxRenderer.INSTANCE.setShouldCancel(true);
}

@Inject(method = "renderMob", at = @At("TAIL"))
private static void end(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks, CallbackInfo ci) {
HitboxRenderer.INSTANCE.setShouldCancel(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object HitboxRenderer {

var drawingWorld = false

var drawingLayer = false
var shouldCancel = false

fun onRender() {
if (!ModConfig.enabled) return
Expand All @@ -45,7 +45,7 @@ object HitboxRenderer {
}

fun tryAddToQueue(config: HitboxConfig, entity: Entity, x: Double, y: Double, z: Double, partialTicks: Float) {
if (drawingWorld && !drawingLayer) {
if (drawingWorld && !shouldCancel) {
renderQueue.add(RenderInfo(config, entity, x, y, z, partialTicks))
} else {
renderHitbox(config, entity, x, y, z, partialTicks)
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/mixins.polyhitbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"EntityRendererMixin",
"GuiInventoryMixin",
"LayerArrowMixin",
"RenderManagerMixin"
"RenderManagerMixin",
"TileEntityMobSpawnerRendererMixin"
]
}

0 comments on commit 0c5b5e3

Please sign in to comment.