Skip to content

Commit 0c5b5e3

Browse files
committed
fixed mob spawner hitbox
1 parent 3577dc4 commit 0c5b5e3

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

src/main/java/org/polyfrost/polyhitbox/mixin/LayerArrowMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ public class LayerArrowMixin {
1313

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

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

2424
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.polyfrost.polyhitbox.mixin;
2+
3+
import net.minecraft.client.renderer.tileentity.TileEntityMobSpawnerRenderer;
4+
import net.minecraft.tileentity.MobSpawnerBaseLogic;
5+
import org.polyfrost.polyhitbox.render.HitboxRenderer;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.Inject;
9+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
10+
11+
@Mixin(TileEntityMobSpawnerRenderer.class)
12+
public class TileEntityMobSpawnerRendererMixin {
13+
14+
@Inject(method = "renderMob", at = @At("HEAD"))
15+
private static void start(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks, CallbackInfo ci) {
16+
HitboxRenderer.INSTANCE.setShouldCancel(true);
17+
}
18+
19+
@Inject(method = "renderMob", at = @At("TAIL"))
20+
private static void end(MobSpawnerBaseLogic mobSpawnerLogic, double posX, double posY, double posZ, float partialTicks, CallbackInfo ci) {
21+
HitboxRenderer.INSTANCE.setShouldCancel(false);
22+
}
23+
}

src/main/kotlin/org/polyfrost/polyhitbox/render/HitboxRenderer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object HitboxRenderer {
2323

2424
var drawingWorld = false
2525

26-
var drawingLayer = false
26+
var shouldCancel = false
2727

2828
fun onRender() {
2929
if (!ModConfig.enabled) return
@@ -45,7 +45,7 @@ object HitboxRenderer {
4545
}
4646

4747
fun tryAddToQueue(config: HitboxConfig, entity: Entity, x: Double, y: Double, z: Double, partialTicks: Float) {
48-
if (drawingWorld && !drawingLayer) {
48+
if (drawingWorld && !shouldCancel) {
4949
renderQueue.add(RenderInfo(config, entity, x, y, z, partialTicks))
5050
} else {
5151
renderHitbox(config, entity, x, y, z, partialTicks)

src/main/resources/mixins.polyhitbox.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"EntityRendererMixin",
1010
"GuiInventoryMixin",
1111
"LayerArrowMixin",
12-
"RenderManagerMixin"
12+
"RenderManagerMixin",
13+
"TileEntityMobSpawnerRendererMixin"
1314
]
1415
}

0 commit comments

Comments
 (0)