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

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

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

Entity.getPosition介绍

暂无

代码示例

代码示例来源:origin: SquidDev-CC/plethora

@Nonnull
@Override
public BlockPos getPosition() {
  return entity.getPosition();
}

代码示例来源:origin: ldtteam/minecolonies

@Override
public boolean tryMoveToEntityLiving(@NotNull final Entity e, final double speed)
{
  return tryMoveToBlockPos(e.getPosition(), speed);
}

代码示例来源:origin: SquidDev-CC/plethora

@Nonnull
@Override
public BlockPos getPos() {
  return pocket.getEntity().getPosition();
}

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

for(Entity e : mc.world.loadedEntityList)
  if(e instanceof EntityMagicLandmine) {
    BlockPos bpos = e.getPosition();
    AxisAlignedBB aabb = new AxisAlignedBB(bpos).offset(0, offY, 0).grow(2.5, 0, 2.5);

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

public BlockPos getClosestEntranceBottomToEntity(Entity entity, Random random){
  Map.Entry<BlockPos, EnumFacing> closest = null;
  for (Map.Entry<BlockPos, EnumFacing> entry : this.entranceBottoms.entrySet()) {
    if(closest == null || closest.getKey().distanceSq(entity.posX, entity.posY, entity.posZ) > entry.getKey().distanceSq(entity.posX, entity.posY, entity.posZ)){
      closest = entry;
    }
  }
  return closest != null ? closest.getKey() : entity.getPosition();
}

代码示例来源:origin: TeamLapen/Vampirism

/**
 * @return The nearest village the entity is in or next to.
 */
public static @Nullable
VampirismVillage getNearestVillage(Entity e) {
  return getNearestVillage(e.getEntityWorld(), e.getPosition(), 10);
}

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

@Override
public boolean apply(@Nullable Entity entity) {
 return entity instanceof IShearable && !entity.isDead && ((IShearable) entity).isShearable(Prep.getEmpty(), entity.world, entity.getPosition());
}

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

public BlockPos getClosestEntranceToEntity(Entity entity, Random random, boolean randomize){
  Map.Entry<BlockPos, EnumFacing> closest = getClosestEntrance(entity);
  if(closest != null) {
    if (randomize) {
      BlockPos pos = closest.getKey().offset(closest.getValue(), random.nextInt(7) + 7).up(4);
      return pos.add(10 - random.nextInt(20), 0, 10 - random.nextInt(20));
    } else {
      return closest.getKey().offset(closest.getValue(), 3);
    }
  }
  return entity.getPosition();
}

代码示例来源:origin: TeamLapen/Vampirism

/**
 * Call {@link EntityLiving#onInitialSpawn(DifficultyInstance, IEntityLivingData)} if applicable
 */
private static void onInitialSpawn(Entity e) {
  if (e instanceof EntityLiving) {
    ((EntityLiving) e).onInitialSpawn(e.getEntityWorld().getDifficultyForLocation(e.getPosition()), null);
  }
}

代码示例来源:origin: ldtteam/minecolonies

@Override
public void onUpdate(final ItemStack stack, final World worldIn, final Entity entityIn, final int itemSlot, final boolean isSelected)
{
  super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
  final Colony colony = ColonyManager.getClosestColony(worldIn, entityIn.getPosition());
  raidWillHappen = colony != null && colony.hasWillRaidTonight();
}

代码示例来源:origin: ldtteam/minecolonies

@SubscribeEvent
  public void onEntityJoinWorld(final EntityJoinWorldEvent event)
  {
    if (event.getEntity() instanceof EntityBarbarian)
    {
      Log.getLogger().warn("Spawning barbarian at: " + event.getEntity().getPosition());
    }
  }
}

代码示例来源:origin: WayofTime/BloodMagic

protected void onImpact(Entity mop) {
  if (mop instanceof EntityLivingBase) {
    doDamage(100, mop);
  }
  generateMeteor(mop.getPosition());
  // spawnHitParticles("magicCrit", 8);
  this.setDead();
}

代码示例来源:origin: Darkhax-Minecraft/Bookshelf

/**
 * Pushes an entity towards a specific direction.
 *
 * @param entityToMove The entity that you want to push.
 * @param direction The direction to push the entity.
 * @param force The amount of force to push the entity with.
 */
public static void pushTowards (Entity entityToMove, EnumFacing direction, double force) {
  
  pushTowards(entityToMove, entityToMove.getPosition().offset(direction.getOpposite(), 1), force);
}

代码示例来源:origin: SquidDev-CC/plethora

@Nonnull
@Override
public IWorldLocation safeGet() throws LuaException {
  Entity entity = pocket.getEntity();
  if (entity == null) {
    throw new LuaException("Entity is not there");
  } else {
    return new WorldLocation(entity.getEntityWorld(), entity.getPosition());
  }
}

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

@Override
public boolean run(ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
  World world = spell.world;
  Entity targetEntity = spell.getVictim();
  double time = spellRing.getAttributeValue(AttributeRegistry.DURATION, spell);
  if (!spellRing.taxCaster(spell, true)) return false;
  if (targetEntity != null) {
    targetEntity.setFire((int) time);
    world.playSound(null, targetEntity.getPosition(), ModSounds.FIRE, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.35f, 0.75f), RandUtil.nextFloat(0.35f, 1.5f));
  }
  return true;
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public void syncToClient() {
  World world = housing.getWorldObj();
  if (world != null && !world.isRemote) {
    if (housing instanceof Entity) {
      Entity housingEntity = (Entity) this.housing;
      NetworkUtil.sendNetworkPacket(new PacketBeeLogicActiveEntity(this.housing, housingEntity), housingEntity.getPosition(), world);
    } else {
      NetworkUtil.sendNetworkPacket(new PacketBeeLogicActive(housing), housing.getCoordinates(), world);
    }
  }
}

代码示例来源:origin: TeamLapen/Vampirism

public static boolean isEntityInVampireBiome(Entity e) {
  if (e == null) return false;
  try {
    return ModBiomes.vampireForest.getRegistryName().equals(e.getEntityWorld().getBiome(e.getPosition()).getRegistryName());
  } catch (NullPointerException e1) {
    //http://openeye.openmods.info/crashes/8cef4d710e41adf9be8362e57ad70d28
    VampirismMod.log.e("Helper", e1, "Nullpointer when checking biome. This is strange and should not happen");
    return false;
  }
}

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

@SubscribeEvent
public void onSpawnCheck(LivingSpawnEvent.CheckSpawn event) {
  Entity e = event.getEntity();
  World world = event.getWorld();
  BlockPos pos = e.getPosition();
  
  if(world.getBlockState(pos).getBlock() == black_ash || world.getBlockState(pos.down(2)).getBlock() == black_ash)
    event.setResult(Result.DENY);
}

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

@SuppressWarnings("ConstantConditions")
private void setRespawnData(Entity e) {
  if (e.hasCapability(CapabilityRespawnData.RESPAWN_DATA_CAPABILITY, null)) {
    IRespawnData respawnData = e.getCapability(CapabilityRespawnData.RESPAWN_DATA_CAPABILITY, null);
    respawnData.setRespawnPos(e.getPosition());
    respawnData.setSpawnerSettings(getParentSettings().getParentSettings().writeToNBT(new NBTTagCompound()));
    respawnData.setSpawnTime(e.world.getTotalWorldTime());
  }
}

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

@SubscribeEvent
public void onEntityInteractEvent(EntityInteract event) {
 if (event.getTarget() instanceof EntityVillager && event.getEntityPlayer().getHeldItem(event.getHand()).getItem() == this) {
  BlockPos p = event.getTarget().getPosition();
  event.getEntityPlayer().openGui(ModCyclic.instance, ForgeGuiHandler.GUI_INDEX_VILLAGER, event.getWorld(),
    p.getX(), p.getY(), p.getZ());
  //      event.setCanceled(true);
 }
}

相关文章

Entity类方法