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

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

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

World.getEntityByID介绍

暂无

代码示例

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

  1. public EntityLivingBase getTargetEntity() {
  2. int id = dataManager.get(TARGET);
  3. Entity e = world.getEntityByID(id);
  4. if(e != null && e instanceof EntityLivingBase)
  5. return (EntityLivingBase) e;
  6. return null;
  7. }

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

  1. @Override
  2. public boolean receiveClientEvent(int event, int param) {
  3. if(event == EXPLODE_EFFECT_EVENT) {
  4. if(getWorld().isRemote && getWorld().getEntityByID(param) instanceof EntityTNTPrimed) {
  5. Entity e = getWorld().getEntityByID(param);
  6. for(int i = 0; i < 50; i++)
  7. 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);
  8. getWorld().spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, e.posX, e.posY, e.posZ, 1D, 0D, 0D);
  9. }
  10. return true;
  11. } else {
  12. return super.receiveClientEvent(event, param);
  13. }
  14. }

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

  1. protected void tickClient(ItemStack stack, EntityPlayer player) {
  2. if(!Botania.proxy.isTheClientPlayer(player))
  3. return;
  4. NBTTagList blocks = ItemNBTHelper.getList(stack, TAG_BLOCK_POSITIONS, Constants.NBT.TAG_LONG, false);
  5. Botania.proxy.setWispFXDepthTest(false);
  6. for(int i = 0; i < blocks.tagCount(); i++) {
  7. BlockPos pos = BlockPos.fromLong(((NBTTagLong) blocks.get(i)).getLong());
  8. float m = 0.02F;
  9. 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));
  10. }
  11. int[] entities = ItemNBTHelper.getIntArray(stack, TAG_ENTITY_POSITIONS);
  12. for(int i : entities) {
  13. Entity e = player.world.getEntityByID(i);
  14. if(e != null && Math.random() < 0.6) {
  15. Botania.proxy.setWispFXDepthTest(Math.random() < 0.6);
  16. 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());
  17. }
  18. }
  19. Botania.proxy.setWispFXDepthTest(true);
  20. }

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

  1. @Override
  2. public boolean receiveClientEvent(int event, int param) {
  3. if(event == START_BURN_EVENT) {
  4. Entity e = getWorld().getEntityByID(param);
  5. if(e != null) {
  6. e.world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, e.posX, e.posY + 0.1, e.posZ, 0.0D, 0.0D, 0.0D);
  7. e.world.spawnParticle(EnumParticleTypes.FLAME, e.posX, e.posY, e.posZ, 0.0D, 0.0D, 0.0D);
  8. }
  9. return true;
  10. } else {
  11. return super.receiveClientEvent(event, param);
  12. }
  13. }

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

  1. Entity item = world.getEntityByID(message.args[0]);
  2. if (item == null) return;
  3. Entity e1 = world.getEntityByID(message.args[0]);
  4. Entity e2 = world.getEntityByID(message.args[1]);
  5. Entity e1 = world.getEntityByID(message.args[0]);
  6. Entity e2 = world.getEntityByID(message.args[1]);
  7. Entity entity = world.getEntityByID(message.args[0]);
  8. if(entity != null) {
  9. for(int i = 0; i < 15; i++) {

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

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

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

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

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

  1. @Override
  2. @Nullable
  3. public Entity getEntityByID(int id) {
  4. return wrapped.getEntityByID(id);
  5. }

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

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

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

  1. @Nullable
  2. public Entity readEntityById(World world) {
  3. int entityId = readVarInt();
  4. return world.getEntityByID(entityId);
  5. }

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

  1. @Override
  2. protected void execute(EntityPlayer player) {
  3. Entity e = player.world.getEntityByID(entityId);
  4. if (e instanceof IEntityPacketHandler) {
  5. ((IEntityPacketHandler) e).handlePacketData(packetData);
  6. }
  7. }

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

  1. @Override
  2. @SuppressWarnings("unchecked")
  3. public void handlePacket(EntityPlayer player) {
  4. EntityNPC npc = (EntityNPC) player.world.getEntityByID(npcID);
  5. if (npc != null) {
  6. handleGifting(player, npc);
  7. }
  8. }

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

  1. @Override
  2. public Entity deserialize(World world, NBTTagInt object) {
  3. return world.getEntityByID(object.getInt());
  4. }
  5. }

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

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

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

  1. @Override
  2. @SuppressWarnings("unchecked")
  3. public void handlePacket(EntityPlayer player) {
  4. EntityNPC npc = (EntityNPC) player.world.getEntityByID(npcID);
  5. if (npc != null) {
  6. if(npc.getNPC().onClickedInfoButton(player)) {
  7. player.openGui(HarvestFestival.instance, GuiHandler.NPC_INFO, player.world, npcID, -1, -1);
  8. }
  9. }
  10. }
  11. }

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

  1. @Override
  2. public void handleData(NBTTagCompound compound, MessageContext context){
  3. World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
  4. Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
  5. if(entity instanceof EntityPlayer){
  6. Container container = ((EntityPlayer)entity).openContainer;
  7. if(container instanceof IButtonReactor){
  8. ((IButtonReactor)container).onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
  9. }
  10. }
  11. }
  12. };

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

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

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

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

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

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

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

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

相关文章

World类方法