Java Code Examples for net.minecraft.entity.Entity#setPositionAndRotation()
The following examples show how to use
net.minecraft.entity.Entity#setPositionAndRotation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Nyan.java From CommunityMod with GNU Lesser General Public License v2.1 | 4 votes |
private static void updateNyanEntity(MinecraftServer server, WorldServer world, Entity entity, NBTTagCompound data) { Entity nyanEntity = null; if(data.hasUniqueId(NYAN_ENTITY_UUID_KEY)) { nyanEntity = server.getEntityFromUuid(data.getUniqueId(NYAN_ENTITY_UUID_KEY)); } boolean shouldSpawn = false; if(nyanEntity == null || nyanEntity.isDead) { nyanEntity = newNyanEntity(world); nyanEntity.getEntityData().setUniqueId(NYANED_ENTITY_UUID_KEY, entity.getUniqueID()); data.setUniqueId(NYAN_ENTITY_UUID_KEY, nyanEntity.getUniqueID()); shouldSpawn = true; } final BlockPos entityPos = entity.getPosition(); double entityHeightMultiplier = world.getTotalWorldTime() % 2 == 0 ? 3.5 : 4.0; //Account for dab particles if(entity instanceof EntityPlayer) { entityHeightMultiplier += 2.0; } //I *could* disable the AI, but this is more fun nyanEntity.setPositionAndRotation( entityPos.getX(), entityPos.getY() + entity.height * entityHeightMultiplier + nyanEntity.height, entityPos.getZ(), entity.rotationYaw, entity.rotationPitch ); nyanEntity.setRotationYawHead(entity.getRotationYawHead()); nyanEntity.setEntityInvulnerable(true); if(shouldSpawn) { world.spawnEntity(nyanEntity); } final BlockPos nyanPos = nyanEntity.getPosition(); final NyanDirection direction = NyanDirection.getDirectionFacing(nyanEntity, Rotation.CLOCKWISE_90); world.spawnParticle( //Wool EnumParticleTypes.REDSTONE, //Not long distance false, nyanPos.getX() + direction.getXDirection() * 12.0, nyanPos.getY() - 2.5, nyanPos.getZ() + direction.getZDirection() * 12.0, //Number of particles 10, direction.getXDirection() * 5.0, 0.0, direction.getZDirection() * 5.0, //Speed 10.0 ); }