Search in sources :

Example 1 with SoloEntitySpider

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntitySpider in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method createCreature.

/**
 * Duplicate of {@link net.minecraft.world.entity.EntityType#create(ServerLevel, CompoundTag, Component, net.minecraft.world.entity.player.Player, BlockPos, MobSpawnType, 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(net.minecraft.world.entity.EntityType<T> entityType, ServerLevel world, CompoundTag nbt, Component component, net.minecraft.world.entity.player.Player player, BlockPos blockPos, MobSpawnType mobSpawnType) {
    T newEntity;
    if (entityType == net.minecraft.world.entity.EntityType.SPIDER) {
        newEntity = (T) new SoloEntitySpider((net.minecraft.world.entity.EntityType<? extends Spider>) entityType, world);
    } else if (entityType == net.minecraft.world.entity.EntityType.STRIDER) {
        newEntity = (T) new SoloEntityStrider((net.minecraft.world.entity.EntityType<? extends Strider>) entityType, world);
    } else {
        newEntity = entityType.create(world);
    }
    if (newEntity == null)
        return null;
    if (field_Entity_spawnReason != null) {
        try {
            field_Entity_spawnReason.set(newEntity, this.toBukkitSpawnReason(mobSpawnType));
        } catch (IllegalAccessException ignored) {
        }
    }
    newEntity.moveTo(blockPos.getX() + 0.5D, blockPos.getY(), blockPos.getZ() + 0.5D, Mth.wrapDegrees(world.random.nextFloat() * 360.0F), 0.0F);
    if (newEntity instanceof Mob) {
        Mob mob = (Mob) newEntity;
        mob.yHeadRot = mob.getYRot();
        mob.yBodyRot = mob.getYRot();
        SpawnGroupData groupDataEntity = null;
        if (entityType == net.minecraft.world.entity.EntityType.DROWNED || entityType == net.minecraft.world.entity.EntityType.HUSK || entityType == net.minecraft.world.entity.EntityType.ZOMBIE_VILLAGER || entityType == net.minecraft.world.entity.EntityType.ZOMBIFIED_PIGLIN || entityType == net.minecraft.world.entity.EntityType.ZOMBIE) {
            // Don't allow chicken jockeys to spawn
            groupDataEntity = new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(world.getRandom()), false);
        }
        mob.finalizeSpawn(world, world.getCurrentDifficultyAt(mob.blockPosition()), mobSpawnType, groupDataEntity, nbt);
    }
    if (component != null && newEntity instanceof Mob)
        newEntity.setCustomName(component);
    net.minecraft.world.entity.EntityType.updateCustomEntityTag(world, player, newEntity, nbt);
    return newEntity;
}
Also used : SpawnGroupData(net.minecraft.world.entity.SpawnGroupData) SoloEntitySpider(dev.rosewood.rosestacker.nms.v1_18_R1.entity.SoloEntitySpider) Mob(net.minecraft.world.entity.Mob) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_18_R1.entity.SoloEntityStrider) Zombie(net.minecraft.world.entity.monster.Zombie) EntityType(org.bukkit.entity.EntityType) Strider(net.minecraft.world.entity.monster.Strider) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_18_R1.entity.SoloEntityStrider)

Example 2 with SoloEntitySpider

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntitySpider in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method createCreature.

/**
 * Duplicate of {@link net.minecraft.world.entity.EntityType#create(ServerLevel, CompoundTag, Component, net.minecraft.world.entity.player.Player, BlockPos, MobSpawnType, 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(net.minecraft.world.entity.EntityType<T> entityType, ServerLevel world, CompoundTag nbt, Component component, net.minecraft.world.entity.player.Player player, BlockPos blockPos, MobSpawnType mobSpawnType) {
    T newEntity;
    if (entityType == net.minecraft.world.entity.EntityType.SPIDER) {
        newEntity = (T) new SoloEntitySpider((net.minecraft.world.entity.EntityType<? extends Spider>) entityType, world);
    } else if (entityType == net.minecraft.world.entity.EntityType.STRIDER) {
        newEntity = (T) new SoloEntityStrider((net.minecraft.world.entity.EntityType<? extends Strider>) entityType, world);
    } else {
        newEntity = entityType.create(world);
    }
    if (newEntity == null)
        return null;
    if (field_Entity_spawnReason != null) {
        try {
            field_Entity_spawnReason.set(newEntity, this.toBukkitSpawnReason(mobSpawnType));
        } catch (IllegalAccessException ignored) {
        }
    }
    newEntity.moveTo(blockPos.getX() + 0.5D, blockPos.getY(), blockPos.getZ() + 0.5D, Mth.wrapDegrees(world.random.nextFloat() * 360.0F), 0.0F);
    if (newEntity instanceof Mob) {
        Mob mob = (Mob) newEntity;
        mob.yHeadRot = mob.getYRot();
        mob.yBodyRot = mob.getYRot();
        SpawnGroupData groupDataEntity = null;
        if (entityType == net.minecraft.world.entity.EntityType.DROWNED || entityType == net.minecraft.world.entity.EntityType.HUSK || entityType == net.minecraft.world.entity.EntityType.ZOMBIE_VILLAGER || entityType == net.minecraft.world.entity.EntityType.ZOMBIFIED_PIGLIN || entityType == net.minecraft.world.entity.EntityType.ZOMBIE) {
            // Don't allow chicken jockeys to spawn
            groupDataEntity = new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(world.getRandom()), false);
        }
        mob.finalizeSpawn(world, world.getCurrentDifficultyAt(mob.blockPosition()), mobSpawnType, groupDataEntity, nbt);
    }
    if (component != null && newEntity instanceof Mob)
        newEntity.setCustomName(component);
    net.minecraft.world.entity.EntityType.updateCustomEntityTag(world, player, newEntity, nbt);
    return newEntity;
}
Also used : SpawnGroupData(net.minecraft.world.entity.SpawnGroupData) SoloEntitySpider(dev.rosewood.rosestacker.nms.v1_18_R2.entity.SoloEntitySpider) Mob(net.minecraft.world.entity.Mob) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_18_R2.entity.SoloEntityStrider) Zombie(net.minecraft.world.entity.monster.Zombie) EntityType(org.bukkit.entity.EntityType) Strider(net.minecraft.world.entity.monster.Strider) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_18_R2.entity.SoloEntityStrider)

Example 3 with SoloEntitySpider

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntitySpider in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method createCreature.

/**
 * Duplicate of {@link net.minecraft.world.entity.EntityType#create(ServerLevel, CompoundTag, Component, net.minecraft.world.entity.player.Player, BlockPos, MobSpawnType, 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(net.minecraft.world.entity.EntityType<T> entityType, ServerLevel world, CompoundTag nbt, Component component, net.minecraft.world.entity.player.Player player, BlockPos blockPos, MobSpawnType mobSpawnType) {
    T newEntity;
    if (entityType == net.minecraft.world.entity.EntityType.SPIDER) {
        newEntity = (T) new SoloEntitySpider((net.minecraft.world.entity.EntityType<? extends Spider>) entityType, world);
    } else if (entityType == net.minecraft.world.entity.EntityType.STRIDER) {
        newEntity = (T) new SoloEntityStrider((net.minecraft.world.entity.EntityType<? extends Strider>) entityType, world);
    } else {
        newEntity = entityType.create(world);
    }
    if (newEntity == null)
        return null;
    if (field_Entity_spawnReason != null) {
        try {
            field_Entity_spawnReason.set(newEntity, this.toBukkitSpawnReason(mobSpawnType));
        } catch (IllegalAccessException ignored) {
        }
    }
    newEntity.moveTo(blockPos.getX() + 0.5D, blockPos.getY(), blockPos.getZ() + 0.5D, Mth.wrapDegrees(world.random.nextFloat() * 360.0F), 0.0F);
    if (newEntity instanceof Mob) {
        Mob mob = (Mob) newEntity;
        mob.yHeadRot = mob.getYRot();
        mob.yBodyRot = mob.getYRot();
        SpawnGroupData groupDataEntity = null;
        if (entityType == net.minecraft.world.entity.EntityType.DROWNED || entityType == net.minecraft.world.entity.EntityType.HUSK || entityType == net.minecraft.world.entity.EntityType.ZOMBIE_VILLAGER || entityType == net.minecraft.world.entity.EntityType.ZOMBIFIED_PIGLIN || entityType == net.minecraft.world.entity.EntityType.ZOMBIE) {
            // Don't allow chicken jockeys to spawn
            groupDataEntity = new Zombie.ZombieGroupData(Zombie.getSpawnAsBabyOdds(world.getRandom()), false);
        }
        mob.finalizeSpawn(world, world.getCurrentDifficultyAt(mob.blockPosition()), mobSpawnType, groupDataEntity, nbt);
    }
    if (component != null && newEntity instanceof Mob)
        newEntity.setCustomName(component);
    net.minecraft.world.entity.EntityType.updateCustomEntityTag(world, player, newEntity, nbt);
    return newEntity;
}
Also used : SpawnGroupData(net.minecraft.world.entity.SpawnGroupData) SoloEntitySpider(dev.rosewood.rosestacker.nms.v1_17_R1.entity.SoloEntitySpider) Mob(net.minecraft.world.entity.Mob) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_17_R1.entity.SoloEntityStrider) Zombie(net.minecraft.world.entity.monster.Zombie) EntityType(org.bukkit.entity.EntityType) SoloEntityStrider(dev.rosewood.rosestacker.nms.v1_17_R1.entity.SoloEntityStrider) Strider(net.minecraft.world.entity.monster.Strider)

Example 4 with SoloEntitySpider

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntitySpider 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 5 with SoloEntitySpider

use of dev.rosewood.rosestacker.nms.v1_16_R2.entity.SoloEntitySpider 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

Mob (net.minecraft.world.entity.Mob)3 SpawnGroupData (net.minecraft.world.entity.SpawnGroupData)3 Strider (net.minecraft.world.entity.monster.Strider)3 Zombie (net.minecraft.world.entity.monster.Zombie)3 EntityType (org.bukkit.entity.EntityType)3 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 SoloEntitySpider (dev.rosewood.rosestacker.nms.v1_17_R1.entity.SoloEntitySpider)1 SoloEntityStrider (dev.rosewood.rosestacker.nms.v1_17_R1.entity.SoloEntityStrider)1 SoloEntitySpider (dev.rosewood.rosestacker.nms.v1_18_R1.entity.SoloEntitySpider)1 SoloEntityStrider (dev.rosewood.rosestacker.nms.v1_18_R1.entity.SoloEntityStrider)1 SoloEntitySpider (dev.rosewood.rosestacker.nms.v1_18_R2.entity.SoloEntitySpider)1 SoloEntityStrider (dev.rosewood.rosestacker.nms.v1_18_R2.entity.SoloEntityStrider)1 EntityInsentient (net.minecraft.server.v1_16_R2.EntityInsentient)1 EntityLiving (net.minecraft.server.v1_16_R2.EntityLiving)1 EntityStrider (net.minecraft.server.v1_16_R2.EntityStrider)1 EntityTypes (net.minecraft.server.v1_16_R2.EntityTypes)1 EntityZombie (net.minecraft.server.v1_16_R2.EntityZombie)1