net.minecraft.entity.Entity.setPosition()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(244)

本文整理了Java中net.minecraft.entity.Entity.setPosition()方法的一些代码示例,展示了Entity.setPosition()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.setPosition()方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:setPosition

Entity.setPosition介绍

暂无

代码示例

代码示例来源:origin: SonarSonic/Calculator

@Override
  public void placeInPortal(@Nonnull Entity entity, float rotationYaw){
    entity.setPosition(x, y, z);
    entity.motionX = 0F;
    entity.motionY = 0F;
    entity.motionZ = 0F;
  }
}

代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition

public void Teleport(Entity entity, TransportLocation position) {
  if (!MinecraftForge.EVENT_BUS.post(new MOEventTransport(getPos(), position, entity))) {
    if (entity instanceof EntityLivingBase) {
      entity.setPositionAndUpdate(position.pos.getX(), position.pos.getY() + 1, position.pos.getZ());
    } else {
      entity.setPosition(position.pos.getX(), position.pos.getY() + 1, position.pos.getZ());
    }
  }
}

代码示例来源:origin: Vazkii/Botania

if(e instanceof EntityPlayerMP)
  ((EntityPlayerMP) e).connection.setPlayerLocation(posX, posY, posZ, e.rotationYaw, e.rotationPitch);
else e.setPosition(posX, posY, posZ);

代码示例来源:origin: Electrical-Age/ElectricalAge

public static void serverTeleport(Entity e, double x, double y, double z) {
  if (e instanceof EntityPlayerMP)
    ((EntityPlayerMP) e).setPositionAndUpdate(x, y, z);
  else
    e.setPosition(x, y, z);
}

代码示例来源:origin: vadis365/TheErebus

private void moveToEmptyArea(Entity entity) {
  while (!isClear(entity)) {
    entity.setPosition(entity.posX, entity.posY + 1, entity.posZ);
  }
}

代码示例来源:origin: CoFH/ThermalDynamics

@Override
public void setDead() {
  if (rider != null && !rider.isDead) {
    rider.height = originalHeight;
    rider.width = originalWidth;
    if (rider instanceof EntityPlayer) {
      ((EntityPlayer) rider).eyeHeight = originalEyeHeight;
    }
    rider.setPosition(rider.posX, rider.posY, rider.posZ);
  }
  super.setDead();
}

代码示例来源:origin: vadis365/TheErebus

@Override
public void updatePassenger(Entity entity) {
  super.updatePassenger(entity);
  if (entity instanceof EntityLivingBase) {
    double a = Math.toRadians(renderYawOffset);
    double offSetX = -Math.sin(a) * 0.75D;
    double offSetZ = Math.cos(a) * 0.75D;
    entity.setPosition(posX - offSetX, posY + 0.8D + entity.getYOffset(), posZ - offSetZ);
  }
}

代码示例来源:origin: vadis365/TheErebus

@Override
public void updatePassenger(Entity entity) {
  super.updatePassenger(entity);
  if (entity instanceof EntityLivingBase) {
    double a = Math.toRadians(renderYawOffset);
    double offSetX = -Math.sin(a) * 0.1D;
    double offSetZ = Math.cos(a) * 0.1D;
    entity.setPosition(posX - offSetX, posY + 1.1D + entity.getYOffset(), posZ - offSetZ);
  }
}

代码示例来源:origin: McJtyMods/ModTutorials

@Override
public void placeInPortal(@Nonnull Entity entity, float rotationYaw) {
  this.worldServer.getBlockState(new BlockPos((int) this.x, (int) this.y, (int) this.z));
  entity.setPosition(this.x, this.y, this.z);
  entity.motionX = 0.0f;
  entity.motionY = 0.0f;
  entity.motionZ = 0.0f;
}

代码示例来源:origin: McJtyMods/LostCities

@Override
public void placeInPortal(@Nonnull Entity entity, float rotationYaw) {
  this.worldServer.getBlockState(new BlockPos((int) this.x, (int) this.y, (int) this.z));
  entity.setPosition(this.x, this.y, this.z);
  entity.motionX = 0.0f;
  entity.motionY = 0.0f;
  entity.motionZ = 0.0f;
}

代码示例来源:origin: TeamWizardry/Wizardry

@Override
  public void placeInPortal(@Nonnull Entity entity, float rotationYaw) {
    worldServer.getBlockState(new BlockPos((int) x, (int) y, (int) z));
    entity.setPosition(x, y, z);
    entity.motionX = 0.0f;
    entity.motionY = 0.0f;
    entity.motionZ = 0.0f;
  }
}

代码示例来源:origin: P3pp3rF1y/AncientWarfare2

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
  //moving passengers to the same position as vehicle on save otherwise they can end up in a different chunk and MC will kill them on load
  getPassengers().forEach(e -> e.setPosition(posX, posY, posZ));
  return super.writeToNBT(compound);
}

代码示例来源:origin: SleepyTrousers/EnderIO

private static boolean isClear(@Nonnull World world, @Nonnull Entity entity, double targetX, double targetY, double targetZ) {
 double origX = entity.posX, origY = entity.posY, origZ = entity.posZ;
 try {
  entity.setPosition(targetX, targetY, targetZ);
  boolean result = world.checkNoEntityCollision(entity.getEntityBoundingBox(), entity)
    && world.getCollisionBoxes(entity, entity.getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(entity.getEntityBoundingBox());
  return result;
 } finally {
  entity.setPosition(origX, origY, origZ);
 }
}

代码示例来源:origin: PenguinSquad/Harvest-Festival

@Override
public void rewardEntity(Quest quest, EntityPlayer player, String entity) {
  if (!player.world.isRemote) {
    Entity theEntity = EntityList.createEntityByIDFromName(entity, player.world);
    if (theEntity != null) {
      theEntity.setPosition(player.posX, player.posY, player.posZ);
      player.world.spawnEntity(theEntity);
    }
  }
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

public void updatePassenger(Entity passenger) {
  super.updatePassenger(passenger);
  if (this.isPassenger(passenger)) {
    renderYawOffset = rotationYaw;
    this.rotationYaw = passenger.rotationYaw;
  }
  double ymod1 = this.onLandProgress * -0.02;
  passenger.setPosition(this.posX, this.posY + 0.6F + ymod1, this.posZ);
}

代码示例来源:origin: PrinceOfAmber/Cyclic

/**
 * Force horizontal centering, so move from 2.9, 6.2 => 2.5,6.5
 * 
 * @param entity
 * @param pos
 */
public static void centerEntityHoriz(Entity entity, BlockPos pos) {
 float fixedX = pos.getX() + 0.5F;//((float) (MathHelper.floor_double(entity.posX) + MathHelper.ceiling_double_int(entity.posX))  )/ 2;
 float fixedZ = pos.getZ() + 0.5F;//((float) (MathHelper.floor_double(entity.posX) + MathHelper.ceiling_double_int(entity.posX))  )/ 2;
 entity.setPosition(fixedX, entity.posY, fixedZ);
}

代码示例来源:origin: vadis365/TheErebus

@Override
public void updatePassenger(Entity entity) {
  super.updatePassenger(entity);
  if (entity instanceof EntityLivingBase) {
    double a = Math.toRadians(renderYawOffset);
    double offSetX = -Math.sin(a) * -0.6D;
    double offSetZ = Math.cos(a) * -0.6D;
    entity.setPosition(posX - offSetX, posY - getYOffset(), posZ - offSetZ);
    if (entity.isSneaking())
      entity.setSneaking(false);
  }
}

代码示例来源:origin: PenguinSquad/Harvest-Festival

@Override
public Entity getEntity(World world, BlockPos pos, Rotation rotation) {
  if (npc == null || npc.equals("")) return null;
  NPC inpc = NPC.REGISTRY.get(new ResourceLocation(npc)); if (inpc == null) return null;
  Entity entity = NPCHelper.getNPCIfExists((WorldServer) world, pos, inpc);
  if (!(entity instanceof EntityNPC)) {
    entity = NPCHelper.getEntityForNPC(world, inpc);
  }
  entity.setPosition(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
  return entity;
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

public void updatePassenger(Entity passenger) {
  super.updatePassenger(passenger);
  if (this.isPassenger(passenger)) {
    renderYawOffset = rotationYaw;
    float radius = 1.05F;
    float angle = (0.01745329251F * this.renderYawOffset);
    double extraX = (double) (radius * MathHelper.sin((float) (Math.PI + angle)));
    double extraZ = (double) (radius * MathHelper.cos(angle));
    passenger.setPosition(this.posX + extraX, this.posY + 0.25F, this.posZ + extraZ);
  }
}

代码示例来源:origin: Alex-the-666/Ice_and_Fire

public void updatePassenger(Entity passenger) {
  super.updatePassenger(passenger);
  if (this.isPassenger(passenger)) {
    renderYawOffset = rotationYaw;
    this.rotationYaw = passenger.rotationYaw;
    float radius = -0.5F * this.getScaleForAge();
    float angle = (0.01745329251F * this.renderYawOffset);
    double extraX = (double) (radius * MathHelper.sin((float) (Math.PI + angle)));
    double extraZ = (double) (radius * MathHelper.cos(angle));
    passenger.setPosition(this.posX + extraX, this.posY + this.getEyeHeight() - 0.55F, this.posZ + extraZ);
  }
}

相关文章

Entity类方法