net.minecraft.world.World.getEntityByID()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(129)

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

World.getEntityByID介绍

暂无

代码示例

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

public EntityLivingBase getTargetEntity() {
  int id = dataManager.get(TARGET);
  Entity e = world.getEntityByID(id);
  if(e != null && e instanceof EntityLivingBase)
    return (EntityLivingBase) e;
  return null;
}

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

@Override
public boolean receiveClientEvent(int event, int param) {
  if(event == EXPLODE_EFFECT_EVENT) {
    if(getWorld().isRemote && getWorld().getEntityByID(param) instanceof EntityTNTPrimed) {
      Entity e = getWorld().getEntityByID(param);
      for(int i = 0; i < 50; i++)
        Botania.proxy.sparkleFX(e.posX + Math.random() * 4 - 2, e.posY + Math.random() * 4 - 2, e.posZ + Math.random() * 4 - 2, 1F, (float) Math.random() * 0.25F, (float) Math.random() * 0.25F, (float) (Math.random() * 0.65F + 1.25F), 12);
      getWorld().spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, e.posX, e.posY, e.posZ, 1D, 0D, 0D);
    }
    return true;
  } else {
    return super.receiveClientEvent(event, param);
  }
}

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

protected void tickClient(ItemStack stack, EntityPlayer player) {
  if(!Botania.proxy.isTheClientPlayer(player))
    return;
  NBTTagList blocks = ItemNBTHelper.getList(stack, TAG_BLOCK_POSITIONS, Constants.NBT.TAG_LONG, false);
  Botania.proxy.setWispFXDepthTest(false);
  for(int i = 0; i < blocks.tagCount(); i++) {
    BlockPos pos = BlockPos.fromLong(((NBTTagLong) blocks.get(i)).getLong());
    float m = 0.02F;
    Botania.proxy.wispFX(pos.getX() + (float) Math.random(), pos.getY() + (float) Math.random(), pos.getZ() + (float) Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5), m * (float) (Math.random() - 0.5));
  }
  int[] entities = ItemNBTHelper.getIntArray(stack, TAG_ENTITY_POSITIONS);
  for(int i : entities) {
    Entity e =  player.world.getEntityByID(i);
    if(e != null && Math.random() < 0.6) {
      Botania.proxy.setWispFXDepthTest(Math.random() < 0.6);
      Botania.proxy.wispFX(e.posX + (float) (Math.random() * 0.5 - 0.25) * 0.45F, e.posY + e.height, e.posZ + (float) (Math.random() * 0.5 - 0.25) * 0.45F, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), -0.05F - 0.03F * (float) Math.random());
    }
  }
  Botania.proxy.setWispFXDepthTest(true);
}

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

@Override
public boolean receiveClientEvent(int event, int param) {
  if(event == START_BURN_EVENT) {
    Entity e = getWorld().getEntityByID(param);
    if(e != null) {
      e.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, e.posX, e.posY + 0.1, e.posZ, 0.0D, 0.0D, 0.0D);
      e.world.spawnParticle(EnumParticleTypes.FLAME, e.posX, e.posY, e.posZ, 0.0D, 0.0D, 0.0D);
    }
    return true;
  } else {
    return super.receiveClientEvent(event, param);
  }
}

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

Entity item = world.getEntityByID(message.args[0]);
if (item == null) return;
Entity e1 = world.getEntityByID(message.args[0]);
Entity e2 = world.getEntityByID(message.args[1]);
Entity e1 = world.getEntityByID(message.args[0]);
Entity e2 = world.getEntityByID(message.args[1]);
Entity entity = world.getEntityByID(message.args[0]);
if(entity != null) {
  for(int i = 0; i < 15; i++) {

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

if(targetID != -1 && player.world.getEntityByID(targetID) != null) {
  Entity taritem = player.world.getEntityByID(targetID);
    item = player.world.getEntityByID(targetID);

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

Entity item;
if(targetID != -1 && player.world.getEntityByID(targetID) != null) {
  Entity taritem = player.world.getEntityByID(targetID);
    item = player.world.getEntityByID(targetID);
    ItemNBTHelper.setInt(stack, TAG_TARGET, -1);
    ItemNBTHelper.setDouble(stack, TAG_DIST, -1);

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

@Override
@Nullable
public Entity getEntityByID(int id) {
 return wrapped.getEntityByID(id);
}

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

@Nullable
private VehicleBase getVehicle(World world) {
  Entity vehicle = world.getEntityByID(entityID);
  return vehicle instanceof VehicleBase ? (VehicleBase) vehicle : null;
}

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

@Nullable
public Entity readEntityById(World world) {
  int entityId = readVarInt();
  return world.getEntityByID(entityId);
}

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

@Override
protected void execute(EntityPlayer player) {
  Entity e = player.world.getEntityByID(entityId);
  if (e instanceof IEntityPacketHandler) {
    ((IEntityPacketHandler) e).handlePacketData(packetData);
  }
}

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

@Override
@SuppressWarnings("unchecked")
public void handlePacket(EntityPlayer player) {
  EntityNPC npc = (EntityNPC) player.world.getEntityByID(npcID);
  if (npc != null) {
    handleGifting(player, npc);
  }
}

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

@Override
  public Entity deserialize(World world, NBTTagInt object) {
    return world.getEntityByID(object.getInt());
  }
}

代码示例来源:origin: Azanor/Baubles

Minecraft.getMinecraft().addScheduledTask(new Runnable(){ public void run() {
  World world = Baubles.proxy.getClientWorld();
  if (world==null) return;
  Entity p = world.getEntityByID(message.playerId);
  if (p !=null && p instanceof EntityPlayer) {
    IBaublesItemHandler baubles = BaublesApi.getBaublesHandler((EntityPlayer) p);
    baubles.setStackInSlot(message.slot, message.bauble);
  }
}});
return null;

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

@Override
  @SuppressWarnings("unchecked")
  public void handlePacket(EntityPlayer player) {
    EntityNPC npc = (EntityNPC) player.world.getEntityByID(npcID);
    if (npc != null) {
      if(npc.getNPC().onClickedInfoButton(player)) {
        player.openGui(HarvestFestival.instance, GuiHandler.NPC_INFO, player.world, npcID, -1, -1);
      }
    }
  }
}

代码示例来源:origin: Ellpeck/ActuallyAdditions

@Override
  public void handleData(NBTTagCompound compound, MessageContext context){
    World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
    Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
    if(entity instanceof EntityPlayer){
      Container container = ((EntityPlayer)entity).openContainer;
      if(container instanceof IButtonReactor){
        ((IButtonReactor)container).onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
      }
    }
  }
};

代码示例来源:origin: Esteemed-Innovation/Esteemed-Innovation

@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
  super.onDataPacket(net, pkt);
  NBTTagCompound access = pkt.getNbtCompound();
  descending = access.getBoolean("IsDescending");
  target = access.hasKey("TargetEntity") ? (EntityLivingBase) world.getEntityByID(access.getInteger("TargetEntity")) : null;
  markForResync();
}

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

private static void doCitizenInventory(final OpenInventoryMessage message, final EntityPlayerMP player)
{
  @Nullable final EntityCitizen citizen = (EntityCitizen) CompatibilityUtils.getWorld(player).getEntityByID(message.entityID);
  if (citizen != null && checkPermissions(citizen.getCitizenColonyHandler().getColony(), player))
  {
    if (!StringUtils.isNullOrEmpty(message.name))
    {
      citizen.getInventoryCitizen().setCustomName(message.name);
    }
    player.openGui(MineColonies.instance, GuiHandler.ID.CITIZEN_INVENTORY.ordinal(), player.world, citizen.getCitizenColonyHandler().getColony().getID(), citizen.getCitizenData().getId(), 0);
  }
}

代码示例来源:origin: Ellpeck/ActuallyAdditions

@Override
  public void handleData(NBTTagCompound compound, MessageContext context){
    World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
    TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
    if(tile instanceof INumberReactor){
      INumberReactor reactor = (INumberReactor)tile;
      reactor.onNumberReceived(compound.getDouble("Number"), compound.getInteger("NumberID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID")));
    }
  }
};

代码示例来源:origin: Ellpeck/ActuallyAdditions

@Override
  public void handleData(NBTTagCompound compound, MessageContext context){
    World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
    TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
    if(tile instanceof IStringReactor){
      IStringReactor reactor = (IStringReactor)tile;
      reactor.onTextReceived(compound.getString("Text"), compound.getInteger("TextID"), (EntityPlayer)world.getEntityByID(compound.getInteger("PlayerID")));
    }
  }
};

相关文章

微信公众号

最新文章

更多

World类方法