public void hidePlayer(Player player) { Validate.notNull(player, "hidden player cannot be null"); if (getHandle().playerNetServerHandler == null) return; if (equals(player)) return; if (hiddenPlayers.contains(player.getUniqueId())) return; hiddenPlayers.add(player.getUniqueId()); //remove this player from the hidden player's EntityTrackerEntry net.minecraft.entity.EntityTracker tracker = ((net.minecraft.world.WorldServer) entity.worldObj).theEntityTracker; net.minecraft.entity.player.EntityPlayerMP other = ((CraftPlayer) player).getHandle(); net.minecraft.entity.EntityTrackerEntry entry = (net.minecraft.entity.EntityTrackerEntry) tracker.trackedEntityIDs.lookup(other.getEntityId()); if (entry != null) { entry.removePlayerFromTracker(getHandle()); } //remove the hidden player from this player user list getHandle().playerNetServerHandler.sendPacket(new net.minecraft.network.play.server.S38PacketPlayerListItem(player.getPlayerListName(), false, 9999)); }
public void showPlayer(Player player) { Validate.notNull(player, "shown player cannot be null"); if (getHandle().playerNetServerHandler == null) return; if (equals(player)) return; if (!hiddenPlayers.contains(player.getUniqueId())) return; hiddenPlayers.remove(player.getUniqueId()); EntityTracker tracker = ((WorldServer) entity.worldObj).theEntityTracker; EntityPlayerMP other = ((CraftPlayer) player).getHandle(); EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntityIDs.lookup(other.getEntityId()); if (entry != null) { entry.removePlayerFromTracker(getHandle()); } getHandle().playerNetServerHandler.sendPacket(new S38PacketPlayerListItem(player.getPlayerListName(), false, 9999)); }
/** * Handles the creation of a nearby player entity, sets the position and held item */ public void handleSpawnPlayer(SPacketSpawnPlayer packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); float f = (float)(packetIn.getYaw() * 360) / 256.0F; float f1 = (float)(packetIn.getPitch() * 360) / 256.0F; EntityOtherPlayerMP entityotherplayermp = new EntityOtherPlayerMP(this.gameController.world, this.getPlayerInfo(packetIn.getUniqueId()).getGameProfile()); entityotherplayermp.prevPosX = d0; entityotherplayermp.lastTickPosX = d0; entityotherplayermp.prevPosY = d1; entityotherplayermp.lastTickPosY = d1; entityotherplayermp.prevPosZ = d2; entityotherplayermp.lastTickPosZ = d2; EntityTracker.updateServerPosition(entityotherplayermp, d0, d1, d2); entityotherplayermp.setPositionAndRotation(d0, d1, d2, f, f1); this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entityotherplayermp); List < EntityDataManager.DataEntry<? >> list = packetIn.getDataManagerEntries(); if (list != null) { entityotherplayermp.getDataManager().setEntryValues(list); } }
public WorldServer(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn) { super(saveHandlerIn, info, net.minecraftforge.common.DimensionManager.createProviderFor(dimensionId), profilerIn, false); this.mcServer = server; this.theEntityTracker = new EntityTracker(this); this.thePlayerManager = new PlayerChunkMap(this); // Guarantee the dimension ID was not reset by the provider int providerDim = this.provider.getDimension(); this.provider.registerWorld(this); this.provider.setDimension(providerDim); this.chunkProvider = this.createChunkProvider(); perWorldStorage = new MapStorage(new net.minecraftforge.common.WorldSpecificSaveHandler((WorldServer)this, saveHandlerIn)); this.worldTeleporter = new Teleporter(this); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.getWorldBorder().setSize(server.getMaxWorldSize()); net.minecraftforge.common.DimensionManager.setWorld(dimensionId, this, mcServer); }
/** * Handles the creation of a nearby player entity, sets the position and held item */ public void handleSpawnPlayer(SPacketSpawnPlayer packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); float f = (float)(packetIn.getYaw() * 360) / 256.0F; float f1 = (float)(packetIn.getPitch() * 360) / 256.0F; EntityOtherPlayerMP entityotherplayermp = new EntityOtherPlayerMP(this.gameController.theWorld, this.getPlayerInfo(packetIn.getUniqueId()).getGameProfile()); entityotherplayermp.prevPosX = d0; entityotherplayermp.lastTickPosX = d0; entityotherplayermp.prevPosY = d1; entityotherplayermp.lastTickPosY = d1; entityotherplayermp.prevPosZ = d2; entityotherplayermp.lastTickPosZ = d2; EntityTracker.updateServerPosition(entityotherplayermp, d0, d1, d2); entityotherplayermp.setPositionAndRotation(d0, d1, d2, f, f1); this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entityotherplayermp); List < EntityDataManager.DataEntry<? >> list = packetIn.getDataManagerEntries(); if (list != null) { entityotherplayermp.getDataManager().setEntryValues(list); } }
public void func_71001_a(Entity p_71001_1_, int p_71001_2_) { if(!p_71001_1_.field_70128_L && !this.field_70170_p.field_72995_K) { EntityTracker var3 = ((WorldServer)this.field_70170_p).func_73039_n(); if(p_71001_1_ instanceof EntityItem) { var3.func_72784_a(p_71001_1_, new Packet22Collect(p_71001_1_.field_70157_k, this.field_70157_k)); } if(p_71001_1_ instanceof EntityArrow) { var3.func_72784_a(p_71001_1_, new Packet22Collect(p_71001_1_.field_70157_k, this.field_70157_k)); } if(p_71001_1_ instanceof EntityXPOrb) { var3.func_72784_a(p_71001_1_, new Packet22Collect(p_71001_1_.field_70157_k, this.field_70157_k)); } } }
public WorldServer(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn) { super(saveHandlerIn, info, WorldProvider.getProviderForDimension(dimensionId), profilerIn, false); this.mcServer = server; this.theEntityTracker = new EntityTracker(this); this.thePlayerManager = new PlayerManager(this); this.provider.registerWorld(this); this.chunkProvider = this.createChunkProvider(); this.worldTeleporter = new Teleporter(this); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.getWorldBorder().setSize(server.getMaxWorldSize()); }
@Override public EntityTracker getEntityTracker() { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.getEntityTracker(); } else if (m_realWorld != null) { return m_realWorld.getEntityTracker(); } else { return super.getEntityTracker(); } }
/** * Spawns an experience orb and sets its value (amount of XP) */ public void handleSpawnExperienceOrb(SPacketSpawnExperienceOrb packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); Entity entity = new EntityXPOrb(this.clientWorldController, d0, d1, d2, packetIn.getXPValue()); EntityTracker.updateServerPosition(entity, d0, d1, d2); entity.rotationYaw = 0.0F; entity.rotationPitch = 0.0F; entity.setEntityId(packetIn.getEntityID()); this.clientWorldController.addEntityToWorld(packetIn.getEntityID(), entity); }
/** * Updates an entity's position and rotation as specified by the packet */ public void handleEntityTeleport(SPacketEntityTeleport packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId()); if (entity != null) { double d0 = packetIn.getX(); double d1 = packetIn.getY(); double d2 = packetIn.getZ(); EntityTracker.updateServerPosition(entity, d0, d1, d2); if (!entity.canPassengerSteer()) { float f = (float)(packetIn.getYaw() * 360) / 256.0F; float f1 = (float)(packetIn.getPitch() * 360) / 256.0F; if (Math.abs(entity.posX - d0) < 0.03125D && Math.abs(entity.posY - d1) < 0.015625D && Math.abs(entity.posZ - d2) < 0.03125D) { entity.setPositionAndRotationDirect(entity.posX, entity.posY, entity.posZ, f, f1, 0, true); } else { entity.setPositionAndRotationDirect(d0, d1, d2, f, f1, 3, true); } entity.onGround = packetIn.getOnGround(); } } }
public WorldServer(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn) { super(saveHandlerIn, info, DimensionType.getById(dimensionId).createDimension(), profilerIn, false); this.mcServer = server; this.theEntityTracker = new EntityTracker(this); this.thePlayerManager = new PlayerChunkMap(this); this.provider.registerWorld(this); this.chunkProvider = this.createChunkProvider(); this.worldTeleporter = new Teleporter(this); this.calculateInitialSkylight(); this.calculateInitialWeather(); this.getWorldBorder().setSize(server.getMaxWorldSize()); }
public boolean tryTrackingEntity(EntityTracker entityTracker, Entity entity) { EntityRegistration er = lookupModSpawn(entity.getClass(), true); if (er != null) { entityTracker.addEntityToTracker(entity, er.getTrackingRange(), er.getUpdateFrequency(), er.sendsVelocityUpdates()); return true; } return false; }
public boolean tryTrackingEntity(EntityTracker entityTracker, Entity entity) { EntityRegistration er = lookupModSpawn(entity.getClass(), true); if (er != null) { entityTracker.func_72785_a(entity, er.getTrackingRange(), er.getUpdateFrequency(), er.sendsVelocityUpdates()); return true; } return false; }
public static void updateTrackers(Entity entity, IMessage message) { EntityTracker et = ((WorldServer) entity.worldObj).getEntityTracker(); for (EntityPlayer player : et.getTrackingPlayers(entity)) { DISPATCHER.sendTo(message, (EntityPlayerMP) player); } }
/** * Send message to players who are tracking given entity */ public static void sendToTracked(Entity entity, IMessage message) { EntityTracker tracker = ((WorldServer) entity.worldObj).getEntityTracker(); for (EntityPlayer player : tracker.getTrackingPlayers(entity)) { DISPATCHER.sendTo(message, (EntityPlayerMP) player); } }