Skip to content

Commit 6e1a4ae

Browse files
committed
Add nether roof damage option
1 parent 6990a3f commit 6e1a4ae

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.samo_lego.golfiv.mixin.movement;
2+
3+
import net.minecraft.entity.Entity;
4+
import net.minecraft.server.network.ServerPlayerEntity;
5+
import net.minecraft.world.World;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.Shadow;
8+
import org.spongepowered.asm.mixin.Unique;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
12+
13+
import static org.samo_lego.golfiv.GolfIV.golfConfig;
14+
15+
16+
@Mixin(Entity.class)
17+
public abstract class EntityMixin_NetherRoofDamage {
18+
19+
@Shadow
20+
protected abstract void tickInVoid();
21+
22+
@Unique
23+
private final Entity self = (Entity) (Object) this;
24+
25+
@Inject(method = "attemptTickInVoid", at = @At("RETURN"))
26+
private void golfiv_inflictRoofDamage(CallbackInfo ci) {
27+
if (self instanceof ServerPlayerEntity) {
28+
System.out.printf("%.2f, %d\n", self.getY(), self.getEntityWorld().getTopY());
29+
}
30+
if (golfConfig.main.inflictNetherRoofDamage != -1 &&
31+
self.getY() >= golfConfig.main.inflictNetherRoofDamage &&
32+
self.getEntityWorld().getRegistryKey() == World.NETHER) {
33+
this.tickInVoid();
34+
}
35+
}
36+
}

src/main/resources/golfiv.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"illegal_items.PlayerInventoryMixin_IllegalsCheckInsert",
2929
"illegal_items.ServerPlayNetworkHandlerMixin_CreativeItemsCheck",
3030
"illegal_items.ServerPlayNetworkHandlerMixin_IllegalsCheckSlot",
31+
"movement.EntityMixin_NetherRoofDamage",
3132
"movement.ServerPlayNetworkHandler_OnGroundCheck",
3233
"packets.EntityTrackerUpdateS2CPacketMixin_DataPatch",
3334
"packets.ServerPlayerEntityMixin_CreativeInventoryPatch",

0 commit comments

Comments
 (0)