summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/ohmyvanillamc/mixin/DisablePhantomSpawning.java
blob: d5788c71b0f706115af400be43a7d596bd9cebbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.keuin.ohmyvanillamc.mixin;

import com.keuin.ohmyvanillamc.OhMyVanillaMinecraft;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.gen.PhantomSpawner;
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(PhantomSpawner.class)
public class DisablePhantomSpawning {
    /**
     * Disable phantom spawning
     * @author trueKeuin
     */
    @Inject(method = "spawn", at = @At("HEAD"), cancellable = true)
    public void spawn(ServerWorld serverWorld, boolean spawnMonsters, boolean spawnAnimals, CallbackInfo ci) {
        if (OhMyVanillaMinecraft.disablePhantomSpawning)
            ci.cancel();
    }
}