本文整理了Java中net.minecraft.entity.Entity.setLocationAndAngles()
方法的一些代码示例,展示了Entity.setLocationAndAngles()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.setLocationAndAngles()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:setLocationAndAngles
暂无
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
public void placeEntity( World world, Entity entity, float yaw )
{
entity.setLocationAndAngles( this.destination.x, this.destination.y, this.destination.z, yaw, entity.rotationPitch );
entity.motionX = entity.motionY = entity.motionZ = 0.0D;
}
}
代码示例来源:origin: EngineHub/WorldEdit
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
World world = getWorld();
net.minecraft.entity.Entity createdEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entity.getType().getId()), world);
if (createdEntity != null) {
CompoundTag nativeTag = entity.getNbtData();
if (nativeTag != null) {
NBTTagCompound tag = NBTConverter.toNative(entity.getNbtData());
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.removeTag(name);
}
createdEntity.readFromNBT(tag);
}
createdEntity.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
world.spawnEntity(createdEntity);
return new ForgeEntity(createdEntity);
} else {
return null;
}
}
代码示例来源:origin: Vazkii/Botania
entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, world.rand.nextFloat() * 360.0F, 0.0F);
代码示例来源:origin: Silentine/GrimoireOfGaia
private void spawnIt(Entity entity, EntityPlayer player) {
entity.setLocationAndAngles(player.posX, player.posY, player.posZ, 0, 0);
player.world.spawnEntity(entity);
}
代码示例来源:origin: CoFH/CoFHCore
public static boolean teleportEntityTo(Entity entity, double x, double y, double z) {
if (entity instanceof EntityLivingBase) {
return teleportEntityTo((EntityLivingBase) entity, x, y, z);
} else {
entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);
entity.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
}
return true;
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public void placeEntity(World world, Entity entity, float yaw) {
entity.setLocationAndAngles(pos.getX() + 0.5, pos.getY() + 1.1, pos.getZ() + 0.5, entity.rotationYaw, entity.rotationPitch);
entity.motionX = 0;
entity.motionY = 0;
entity.motionZ = 0;
entity.fallDistance = 0;
}
});
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public void placeEntity(World world, Entity entity2, float yaw) {
entity2.setLocationAndAngles(pos.getX() + 0.5, pos.getY() + 1.1, pos.getZ() + 0.5, entity2.rotationYaw, entity2.rotationPitch);
entity2.motionX = 0;
entity2.motionY = 0;
entity2.motionZ = 0;
entity2.fallDistance = 0;
}
});
代码示例来源:origin: WayofTime/BloodMagic
@Override
public void placeInPortal(Entity entity, float rotationYaw) {
entity.setLocationAndAngles(MathHelper.floor(entity.posX), MathHelper.floor(entity.posY) + 2, MathHelper.floor(entity.posZ), entity.rotationYaw, entity.rotationPitch);
}
}
代码示例来源:origin: CoFH/ThermalExpansion
@Nullable
public static Entity spawnGenericCreature(World worldIn, @Nullable ResourceLocation entityID, double x, double y, double z) {
Entity entity = null;
if (entityID != null) {
entity = EntityList.createEntityByIDFromName(entityID, worldIn);
if (entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) entity;
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(worldIn.rand.nextFloat() * 360.0F), 0.0F);
entityliving.rotationYawHead = entityliving.rotationYaw;
entityliving.renderYawOffset = entityliving.rotationYaw;
entityliving.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityliving)), null);
worldIn.spawnEntity(entity);
entityliving.playLivingSound();
}
}
return entity;
}
代码示例来源:origin: CyclopsMC/EvilCraft
/**
* Spawn a creature.
* @param world The world.
* @param entityString The unique entity string.
* @param x X
* @param y Y
* @param z Z
* @return The spawned entity, could be null if not spawnable.
*/
public static Entity spawnCreature(World world, ResourceLocation entityString, double x, double y, double z) {
Entity entity = EntityList.createEntityByIDFromName(entityString, world);
if (entity != null && entity instanceof EntityLivingBase) {
EntityLiving entityliving = (EntityLiving)entity;
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360.0F), 0.0F);
entityliving.rotationYawHead = entityliving.rotationYaw;
entityliving.renderYawOffset = entityliving.rotationYaw;
world.spawnEntity(entity);
entityliving.playLivingSound();
}
return entity;
}
代码示例来源:origin: MCTCP/TerrainControl
@Override
public void spawnEntity(String id, float x, float y, float z, int amount, NamedBinaryTag metaOrNull)
{
String mobTypeName = MobNames.toInternalName(id);
ResourceLocation entityResourceLocation = new ResourceLocation(mobTypeName);
NBTTagCompound nbttagcompound = null;
if (metaOrNull != null)
{
nbttagcompound = NBTHelper.getNMSFromNBTTagCompound(metaOrNull);
}
for (int i = 0; i < amount; i++)
{
Entity entity = createEntity(entityResourceLocation, nbttagcompound);
if (entity == null)
{
return;
}
entity.setLocationAndAngles(x, y, z, world.rand.nextFloat() * 360.0F, 0.0F);
world.spawnEntity(entity);
}
}
}
代码示例来源:origin: CoFH/ThermalExpansion
public static Entity spawnCreature(World world, NBTTagCompound entityData, double x, double y, double z) {
if (entityData.getBoolean(ItemMorb.GENERIC)) {
spawnGenericCreature(world, new ResourceLocation(entityData.getString("id")), x, y, z);
} else {
Entity entity = EntityList.createEntityFromNBT(entityData, world);
if (entity == null) {
return null;
}
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360.0F), 0.0F);
world.spawnEntity(entity);
if (entity instanceof EntityLiving) {
((EntityLiving) entity).playLivingSound();
}
}
return null;
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
protected void onImpact(@Nonnull RayTraceResult impact) {
if (NullHelper.untrust(impact.entityHit) != null) {
impact.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, getThrower()), 0.0F);
}
if (!world.isRemote && rand.nextInt(8) == 0) {
Entity entitychicken = EntityList.createEntityByIDFromName(new ResourceLocation("enderiozoo", "owl"), world);
if (entitychicken instanceof EntityAgeable) {
((EntityAgeable) entitychicken).setGrowingAge(-24000);
entitychicken.setLocationAndAngles(posX, posY, posZ, rotationYaw, 0.0F);
world.spawnEntity(entitychicken);
} else if (thrower instanceof EntityPlayer) {
((EntityPlayer) thrower).sendStatusMessage(Lang.OWL_NO_OWL.toChatServer(), true);
} else {
Log.warn(Lang.OWL_NO_OWL.toChatServer());
}
}
for (int i = 0; i < 8; ++i) {
world.spawnParticle(EnumParticleTypes.ITEM_CRACK, posX, posY, posZ, (rand.nextFloat() - 0.5D) * 0.08D, (rand.nextFloat() - 0.5D) * 0.08D,
(rand.nextFloat() - 0.5D) * 0.08D, new int[] { Item.getIdFromItem(ModObject.item_owl_egg.getItemNN()) });
}
if (!world.isRemote) {
setDead();
}
}
代码示例来源:origin: CoFH/CoFHCore
public static void transferEntityToWorld(Entity entity, double x, double y, double z, WorldServer oldWorld, WorldServer newWorld) {
oldWorld.profiler.startSection("placing");
x = MathHelper.clamp(x, -29999872, 29999872);
z = MathHelper.clamp(z, -29999872, 29999872);
if (entity.isEntityAlive()) {
entity.setLocationAndAngles(x, y, z, entity.rotationYaw, entity.rotationPitch);
newWorld.spawnEntity(entity);
newWorld.updateEntityWithOptionalForce(entity, false);
}
oldWorld.profiler.endSection();
entity.setWorld(newWorld);
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
static void teleportToCoordinates(Entity entity, BlockPos spawn, float yaw) {
if (entity instanceof EntityPlayerMP) {
ReflectionHelper.setPrivateValue(EntityPlayerMP.class, (EntityPlayerMP) entity, true, "invulnerableDimensionChange", "field_184851_cj");
((EntityPlayerMP) entity).connection.setPlayerLocation(spawn.getX() + 0.5D, spawn.getY(), spawn.getZ() + 0.5D, yaw, entity.rotationPitch);
} else {
entity.setLocationAndAngles(spawn.getX() + 0.5D, spawn.getY(), spawn.getZ() + 0.5D, yaw, entity.rotationPitch);
}
}
代码示例来源:origin: Silentine/GrimoireOfGaia
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
BlockPos offsetPos = pos.offset(facing);
if (!player.canPlayerEdit(offsetPos, facing, stack)) {
return EnumActionResult.FAIL;
} else {
if (!player.capabilities.isCreativeMode) {
stack.shrink(1);
}
if (worldIn.isAirBlock(offsetPos) && !worldIn.isRemote) {
Entity spawnEntity = createNPC.apply(worldIn);
spawnEntity.setLocationAndAngles(offsetPos.getX() + 0.5, offsetPos.getY(), offsetPos.getZ() + 0.5, 0, 0);
worldIn.spawnEntity(spawnEntity);
}
return EnumActionResult.SUCCESS;
}
}
}
代码示例来源:origin: Darkhax-Minecraft/Bookshelf
/**
* Changes the world that an entity is in. This allows for changing dimensions safer when
* working with other mods.
*
* @param entity The entity to change the world of.
* @param worldOld The old entity world.
* @param worldNew The new entity world.
*/
public static void changeWorld (Entity entity, WorldServer worldOld, WorldServer worldNew) {
final WorldProvider providerOld = worldOld.provider;
final WorldProvider providerNew = worldNew.provider;
final double moveFactor = providerOld.getMovementFactor() / providerNew.getMovementFactor();
final double x = MathHelper.clamp(entity.posX * moveFactor, -29999872, 29999872);
final double z = MathHelper.clamp(entity.posZ * moveFactor, -29999872, 29999872);
if (entity.isEntityAlive()) {
entity.setLocationAndAngles(x, entity.posY, z, entity.rotationYaw, entity.rotationPitch);
worldNew.spawnEntity(entity);
worldNew.updateEntityWithOptionalForce(entity, false);
}
entity.setWorld(worldNew);
}
代码示例来源:origin: vadis365/TheErebus
public void spawnTrappedEntity() {
if (getWorld().isRemote || entityNBT == null)
return;
Entity entity = EntityList.createEntityFromNBT(entityNBT, getWorld());
entity.setLocationAndAngles(getPos().getX() + 0.5D, getPos().getY(), getPos().getZ() + 0.5D, 0.0F, 0.0F);
getWorld().spawnEntity(entity);
}
}
代码示例来源:origin: CoFH/CoFHCore
public static void transferEntityToWorld(Entity entity, WorldServer oldWorld, WorldServer newWorld) {
WorldProvider pOld = oldWorld.provider;
WorldProvider pNew = newWorld.provider;
double moveFactor = pOld.getMovementFactor() / pNew.getMovementFactor();
double x = entity.posX * moveFactor;
double z = entity.posZ * moveFactor;
oldWorld.profiler.startSection("placing");
x = MathHelper.clamp(x, -29999872, 29999872);
z = MathHelper.clamp(z, -29999872, 29999872);
if (entity.isEntityAlive()) {
entity.setLocationAndAngles(x, entity.posY, z, entity.rotationYaw, entity.rotationPitch);
newWorld.spawnEntity(entity);
newWorld.updateEntityWithOptionalForce(entity, false);
}
oldWorld.profiler.endSection();
entity.setWorld(newWorld);
}
代码示例来源:origin: PrinceOfAmber/Cyclic
@Override
protected void processImpact(RayTraceResult mop) {
if (getCaptured() == null || getCaptured().hasTagCompound() == false) {
//client desync maybe
return;
}
Entity spawnEntity = EntityList.createEntityFromNBT(getCaptured().getTagCompound(), this.getEntityWorld());
if (spawnEntity != null) {
spawnEntity.readFromNBT(getCaptured().getTagCompound());
spawnEntity.setLocationAndAngles(this.posX, this.posY + 1.1F, this.posZ, this.rotationYaw, 0.0F);
this.getEntityWorld().spawnEntity(spawnEntity);
if (spawnEntity instanceof EntityLivingBase) {
UtilSound.playSound((EntityLivingBase) spawnEntity, SoundRegistry.monster_ball_release);
UtilItemStack.dropItemStackInWorld(this.getEntityWorld(), this.getPosition(), new ItemStack(getCaptured().getItem()));
}
}
this.setDead();
}
内容来源于网络,如有侵权,请联系作者删除!