use of net.minecraft.world.entity.monster.Strider 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;
}
use of net.minecraft.world.entity.monster.Strider 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;
}
use of net.minecraft.world.entity.monster.Strider 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;
}
Aggregations