Search in sources :

Example 6 with EntityTypes

use of net.minecraft.server.v1_16_R3.EntityTypes in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method createCreature.

/**
 * Duplicate of {@link EntityTypes#createCreature(WorldServer, NBTTagCompound, IChatBaseComponent, EntityHuman, BlockPosition, EnumMobSpawn, boolean, boolean)}.
 * Contains a patch to prevent chicken jockeys from spawning and to not play the mob sound upon creation.
 */
private <T extends Entity> T createCreature(EntityTypes<T> entityTypes, WorldServer worldserver, NBTTagCompound nbttagcompound, IChatBaseComponent ichatbasecomponent, EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn) {
    T newEntity;
    if (entityTypes == EntityTypes.SPIDER) {
        newEntity = (T) new SoloEntitySpider((EntityTypes<? extends EntitySpider>) entityTypes, worldserver);
    } else if (entityTypes == EntityTypes.STRIDER) {
        newEntity = (T) new SoloEntityStrider((EntityTypes<? extends EntityStrider>) entityTypes, worldserver);
    } else {
        newEntity = entityTypes.a(worldserver);
    }
    if (newEntity == null) {
        return null;
    } else {
        if (field_Entity_spawnReason != null) {
            try {
                field_Entity_spawnReason.set(newEntity, this.toBukkitSpawnReason(enummobspawn));
            } catch (IllegalAccessException ignored) {
            }
        }
        newEntity.setPositionRotation(blockposition.getX() + 0.5D, blockposition.getY(), blockposition.getZ() + 0.5D, MathHelper.g(worldserver.random.nextFloat() * 360.0F), 0.0F);
        if (newEntity instanceof EntityInsentient) {
            EntityInsentient entityinsentient = (EntityInsentient) newEntity;
            entityinsentient.aC = entityinsentient.yaw;
            entityinsentient.aA = entityinsentient.yaw;
            GroupDataEntity groupDataEntity = null;
            if (entityTypes == EntityTypes.DROWNED || entityTypes == EntityTypes.HUSK || entityTypes == EntityTypes.ZOMBIE_VILLAGER || entityTypes == EntityTypes.ZOMBIFIED_PIGLIN || entityTypes == EntityTypes.ZOMBIE) {
                // Don't allow chicken jockeys to spawn
                groupDataEntity = new EntityZombie.GroupDataZombie(EntityZombie.a(worldserver.getRandom()), false);
            }
            entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), enummobspawn, groupDataEntity, nbttagcompound);
        }
        if (ichatbasecomponent != null && newEntity instanceof EntityLiving) {
            newEntity.setCustomName(ichatbasecomponent);
        }
        try {
            EntityTypes.a(worldserver, entityhuman, newEntity, nbttagcompound);
        } catch (Throwable ignored) {
        }
        return newEntity;
    }
}
Also used : EntityTypes(net.minecraft.server.v1_16_R2.EntityTypes) SoloEntitySpider(dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntitySpider) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntityStrider) EntityStrider(net.minecraft.server.v1_16_R2.EntityStrider) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntityStrider) EntityLiving(net.minecraft.server.v1_16_R2.EntityLiving) EntityZombie(net.minecraft.server.v1_16_R2.EntityZombie) GroupDataEntity(net.minecraft.server.v1_16_R2.GroupDataEntity) EntityInsentient(net.minecraft.server.v1_16_R2.EntityInsentient)

Example 7 with EntityTypes

use of net.minecraft.server.v1_16_R3.EntityTypes in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method createCreature.

/**
 * Duplicate of {@link EntityTypes#createCreature(WorldServer, NBTTagCompound, IChatBaseComponent, EntityHuman, BlockPosition, EnumMobSpawn, boolean, boolean)}.
 * Contains a patch to prevent chicken jockeys from spawning and to not play the mob sound upon creation.
 */
private <T extends Entity> T createCreature(EntityTypes<T> entityTypes, WorldServer worldserver, NBTTagCompound nbttagcompound, IChatBaseComponent ichatbasecomponent, EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn) {
    T newEntity;
    if (entityTypes == EntityTypes.SPIDER) {
        newEntity = (T) new SoloEntitySpider((EntityTypes<? extends EntitySpider>) entityTypes, worldserver);
    } else if (entityTypes == EntityTypes.STRIDER) {
        newEntity = (T) new SoloEntityStrider((EntityTypes<? extends EntityStrider>) entityTypes, worldserver);
    } else {
        newEntity = entityTypes.a(worldserver);
    }
    if (newEntity == null) {
        return null;
    } else {
        if (field_Entity_spawnReason != null) {
            try {
                field_Entity_spawnReason.set(newEntity, this.toBukkitSpawnReason(enummobspawn));
            } catch (IllegalAccessException ignored) {
            }
        }
        newEntity.setPositionRotation(blockposition.getX() + 0.5D, blockposition.getY(), blockposition.getZ() + 0.5D, MathHelper.g(worldserver.random.nextFloat() * 360.0F), 0.0F);
        if (newEntity instanceof EntityInsentient) {
            EntityInsentient entityinsentient = (EntityInsentient) newEntity;
            entityinsentient.aC = entityinsentient.yaw;
            entityinsentient.aA = entityinsentient.yaw;
            GroupDataEntity groupDataEntity = null;
            if (entityTypes == EntityTypes.DROWNED || entityTypes == EntityTypes.HUSK || entityTypes == EntityTypes.ZOMBIE_VILLAGER || entityTypes == EntityTypes.ZOMBIFIED_PIGLIN || entityTypes == EntityTypes.ZOMBIE) {
                // Don't allow chicken jockeys to spawn
                groupDataEntity = new EntityZombie.GroupDataZombie(EntityZombie.a(worldserver.getRandom()), false);
            }
            entityinsentient.prepare(worldserver, worldserver.getDamageScaler(entityinsentient.getChunkCoordinates()), enummobspawn, groupDataEntity, nbttagcompound);
        }
        if (ichatbasecomponent != null && newEntity instanceof EntityLiving) {
            newEntity.setCustomName(ichatbasecomponent);
        }
        try {
            EntityTypes.a(worldserver, entityhuman, newEntity, nbttagcompound);
        } catch (Throwable ignored) {
        }
        return newEntity;
    }
}
Also used : EntityTypes(net.minecraft.server.v1_16_R3.EntityTypes) SoloEntitySpider(dev.rosewood.rosestacker.nms.v1_16_R3.entity.SoloEntitySpider) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_16_R3.entity.SoloEntityStrider) EntityStrider(net.minecraft.server.v1_16_R3.EntityStrider) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_16_R3.entity.SoloEntityStrider) EntityLiving(net.minecraft.server.v1_16_R3.EntityLiving) EntityZombie(net.minecraft.server.v1_16_R3.EntityZombie) GroupDataEntity(net.minecraft.server.v1_16_R3.GroupDataEntity) EntityInsentient(net.minecraft.server.v1_16_R3.EntityInsentient)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)4 Entity (net.minecraft.server.v1_16_R3.Entity)3 GroupDataEntity (net.minecraft.server.v1_16_R3.GroupDataEntity)3 CraftEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity)3 EntityTypes (net.minecraft.server.v1_16_R2.EntityTypes)2 GroupDataEntity (net.minecraft.server.v1_16_R2.GroupDataEntity)2 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)2 EntityTypes (net.minecraft.server.v1_16_R3.EntityTypes)2 MinecraftKey (net.minecraft.server.v1_16_R3.MinecraftKey)2 TileEntity (net.minecraft.server.v1_16_R3.TileEntity)2 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)2 CraftLivingEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity)2 SoloEntitySpider (dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntitySpider)1 SoloEntityStrider (dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntityStrider)1 SoloEntitySpider (dev.rosewood.rosestacker.nms.v1_16_R3.entity.SoloEntitySpider)1 SoloEntityStrider (dev.rosewood.rosestacker.nms.v1_16_R3.entity.SoloEntityStrider)1 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)1 BlockPosition (net.minecraft.server.v1_16_R2.BlockPosition)1 Chunk (net.minecraft.server.v1_16_R2.Chunk)1 Entity (net.minecraft.server.v1_16_R2.Entity)1