aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dulkirmod/mixins/MixinWorld.java
blob: a3c2ec74b9132992a83f222f25392d02abc3329c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package dulkirmod.mixins;

import dulkirmod.DulkirMod;
import dulkirmod.events.EntityRemovedEvent;
import dulkirmod.features.dungeons.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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(World.class)
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) {
        DragonFeatures.INSTANCE.handleNewParticle(particleID, xCoord, yCoord, zCoord);

        if (particleID == 25 && DulkirMod.Companion.getConfig().getHideEnchantRune()) {
            ci.cancel();
        } else if (particleID == 34 && DulkirMod.Companion.getConfig().getHideHeartParticles()) {
            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));
    }
}