diff options
author | inglettronald <inglettronald@gmail.com> | 2023-04-28 05:12:08 -0500 |
---|---|---|
committer | inglettronald <inglettronald@gmail.com> | 2023-04-28 05:12:08 -0500 |
commit | 650acb70a72c6c2195f4faa8d10529bb808800bd (patch) | |
tree | ec3d3c1149e7bc2b2ca1fdcf9f4d0ae11dd83f97 | |
parent | 2cb65fda1d48b51d288444d14fd94cf40f42a85e (diff) | |
download | DulkirMod-650acb70a72c6c2195f4faa8d10529bb808800bd.tar.gz DulkirMod-650acb70a72c6c2195f4faa8d10529bb808800bd.tar.bz2 DulkirMod-650acb70a72c6c2195f4faa8d10529bb808800bd.zip |
added event EntityRemovedEvent
-rw-r--r-- | src/main/java/dulkirmod/mixins/MixinWorld.java | 13 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/events/Events.kt | 9 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/main/java/dulkirmod/mixins/MixinWorld.java b/src/main/java/dulkirmod/mixins/MixinWorld.java index 1c75281..5b6a267 100644 --- a/src/main/java/dulkirmod/mixins/MixinWorld.java +++ b/src/main/java/dulkirmod/mixins/MixinWorld.java @@ -1,8 +1,11 @@ package dulkirmod.mixins; import dulkirmod.DulkirMod; -import dulkirmod.features.DragonTimer; +import dulkirmod.events.EntityRemovedEvent; +import dulkirmod.features.DragonFeatures; +import net.minecraft.entity.Entity; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -13,7 +16,7 @@ public class MixinWorld { @Inject(method = "spawnParticle(IZDDDDDD[I)V", at = @At("HEAD"), cancellable = true) public void onInitGui(int particleID, boolean p_175720_2_, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int[] p_175720_15_, CallbackInfo ci) { - DragonTimer.INSTANCE.handleNewParticle(particleID, xCoord, yCoord, zCoord); + DragonFeatures.INSTANCE.handleNewParticle(particleID, xCoord, yCoord, zCoord); if (particleID == 25 && DulkirMod.Companion.getConfig().getHideEnchantRune()) { ci.cancel(); @@ -21,4 +24,10 @@ public class MixinWorld { ci.cancel(); } } + + // Source: Aton addons https://github.com/FloppaCoding/AtonAddons/blob/main/src/main/java/atonaddons/mixins/MixinWorld.java + @Inject(method = "removeEntity", at = @At("HEAD")) + public void onEntityRemoved(Entity entityIn, CallbackInfo ci) { + MinecraftForge.EVENT_BUS.post(new EntityRemovedEvent(entityIn)); + } } diff --git a/src/main/kotlin/dulkirmod/events/Events.kt b/src/main/kotlin/dulkirmod/events/Events.kt new file mode 100644 index 0000000..45cc8ff --- /dev/null +++ b/src/main/kotlin/dulkirmod/events/Events.kt @@ -0,0 +1,9 @@ +package dulkirmod.events + +import net.minecraft.entity.Entity +import net.minecraftforge.fml.common.eventhandler.Event + +/** + * Fired when an entity is removed from the world. + */ +class EntityRemovedEvent(val entity: Entity) : Event()
\ No newline at end of file |