Search in sources :

Example 1 with EntityBat

use of net.minecraft.entity.passive.EntityBat in project takumicraft by TNTModders.

the class TakumiEvents method checkSpawn.

@SubscribeEvent
public void checkSpawn(LivingSpawnEvent.CheckSpawn e) {
    if (e.getWorld().provider.getDimensionType() == TakumiWorldCore.TAKUMI_WORLD) {
        if (!(e.getEntityLiving() instanceof ITakumiEntity)) {
            e.setResult(Result.DENY);
        }
    }
    if (e.getEntityLiving().getClass() == EntityCreeper.class) {
        ((EntityLiving) e.getEntityLiving()).tasks.addTask(0, new EntityAIFollowCatCreeper((EntityCreeper) e.getEntityLiving()));
    }
    if (!e.getWorld().isRemote) {
        if (e.getEntityLiving().getRNG().nextInt(5) == 0 && e.getEntityLiving() instanceof EntitySlime) {
            EntitySlimeCreeper slimeCreeper = new EntitySlimeCreeper(e.getWorld());
            slimeCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            slimeCreeper.setSlimeSize(e.getEntityLiving().getRNG().nextBoolean() ? 1 : e.getEntityLiving().getRNG().nextBoolean() ? 2 : 4, false);
            if (slimeCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(slimeCreeper);
                e.setResult(Result.DENY);
            }
        }
        if (e.getEntityLiving().getRNG().nextInt(10) == 0 && e.getEntityLiving() instanceof EntityFishCreeper) {
            EntityBigFishCreeper bigFishCreeper = new EntityBigFishCreeper(e.getWorld());
            bigFishCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (bigFishCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(bigFishCreeper);
                e.setResult(Result.DENY);
            }
        } else if (e.getEntityLiving().getRNG().nextInt(10) == 0 && e.getEntityLiving() instanceof EntitySquid) {
            EntitySquidCreeper squidCreeper = new EntitySquidCreeper(e.getWorld());
            squidCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (squidCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(squidCreeper);
                e.setResult(Result.DENY);
            }
        } else if ((e.getEntityLiving().getClass() == EntityZombieCreeper.class || e.getEntityLiving().getClass() == EntityZombieVillagerCreeper.class) && (e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.DESERT || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.DESERT_HILLS || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.MUTATED_DESERT)) {
            EntityHuskCreeper huskCreeper = new EntityHuskCreeper(e.getWorld());
            huskCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (huskCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(huskCreeper);
                e.setResult(Result.DENY);
            }
        } else if (e.getEntityLiving().getClass() == EntitySkeletonCreeper.class && (e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.ICE_MOUNTAINS || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.ICE_PLAINS || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.COLD_BEACH || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.COLD_TAIGA || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.COLD_TAIGA_HILLS || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.FROZEN_OCEAN || e.getWorld().getBiome(e.getEntityLiving().getPosition()) == Biomes.FROZEN_RIVER)) {
            EntityStrayCreeper strayCreeper = new EntityStrayCreeper(e.getWorld());
            strayCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (strayCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(strayCreeper);
                e.setResult(Result.DENY);
            }
        } else if (e.getEntityLiving().getRNG().nextInt(5) == 0 && e.getEntityLiving() instanceof EntityBat) {
            EntityBatCreeper batCreeper = new EntityBatCreeper(e.getWorld());
            batCreeper.copyLocationAndAnglesFrom(e.getEntityLiving());
            if (batCreeper.getCanSpawnHere()) {
                e.getWorld().spawnEntity(batCreeper);
                e.setResult(Result.DENY);
            }
        }
    }
}
Also used : ITakumiEntity(com.tntmodders.takumi.entity.ITakumiEntity) EntityAIFollowCatCreeper(com.tntmodders.takumi.entity.ai.EntityAIFollowCatCreeper) EntitySlime(net.minecraft.entity.monster.EntitySlime) EntitySquid(net.minecraft.entity.passive.EntitySquid) EntityCreeper(net.minecraft.entity.monster.EntityCreeper) EntityBat(net.minecraft.entity.passive.EntityBat) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ITakumiEntity (com.tntmodders.takumi.entity.ITakumiEntity)1 EntityAIFollowCatCreeper (com.tntmodders.takumi.entity.ai.EntityAIFollowCatCreeper)1 EntityCreeper (net.minecraft.entity.monster.EntityCreeper)1 EntitySlime (net.minecraft.entity.monster.EntitySlime)1 EntityBat (net.minecraft.entity.passive.EntityBat)1 EntitySquid (net.minecraft.entity.passive.EntitySquid)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1