本文整理汇总了Java中net.minecraft.network.play.server.SPacketPlayerListItem类的典型用法代码示例。如果您正苦于以下问题:Java SPacketPlayerListItem类的具体用法?Java SPacketPlayerListItem怎么用?Java SPacketPlayerListItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SPacketPlayerListItem类属于net.minecraft.network.play.server包,在下文中一共展示了SPacketPlayerListItem类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playerLoggedIn
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
/**
* Called when a player successfully logs in. Reads player data from disk and inserts the player into the world.
*/
public void playerLoggedIn(EntityPlayerMP playerIn)
{
this.playerEntityList.add(playerIn);
this.uuidToPlayerMap.put(playerIn.getUniqueID(), playerIn);
this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {playerIn}));
WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);
for (int i = 0; i < this.playerEntityList.size(); ++i)
{
playerIn.connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {(EntityPlayerMP)this.playerEntityList.get(i)}));
}
worldserver.spawnEntityInWorld(playerIn);
this.preparePlayer(playerIn, (WorldServer)null);
}
示例2: playerLoggedIn
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
/**
* Called when a player successfully logs in. Reads player data from disk and inserts the player into the world.
*/
public void playerLoggedIn(EntityPlayerMP playerIn)
{
this.playerEntityList.add(playerIn);
this.uuidToPlayerMap.put(playerIn.getUniqueID(), playerIn);
this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {playerIn}));
WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);
for (int i = 0; i < this.playerEntityList.size(); ++i)
{
playerIn.connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {(EntityPlayerMP)this.playerEntityList.get(i)}));
}
net.minecraftforge.common.chunkio.ChunkIOExecutor.adjustPoolSize(this.getCurrentPlayerCount());
worldserver.spawnEntityInWorld(playerIn);
this.preparePlayer(playerIn, (WorldServer)null);
}
示例3: fireEvents
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
private void fireEvents(SPacketPlayerListItem.Action action, PlayerInfo info, GameProfile profile) {
switch (action) {
case ADD_PLAYER: {
MinecraftForge.EVENT_BUS.post(new PlayerConnectEvent.Join(info, profile));
break;
}
case REMOVE_PLAYER: {
MinecraftForge.EVENT_BUS.post(new PlayerConnectEvent.Leave(info, profile));
break;
}
}
}
示例4: onScoreboardEvent
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
@SubscribeEvent
public void onScoreboardEvent(PacketEvent.Incoming.Pre event) {
if(event.getPacket() instanceof SPacketPlayerListItem
&& getWorld() != null
&& System.currentTimeMillis() > waitTime) {
final SPacketPlayerListItem packet = (SPacketPlayerListItem) event.getPacket();
packet.getEntries().stream()
.filter(Objects::nonNull)
.filter(data -> data.getProfile() != null)
.filter(data -> !Strings.isNullOrEmpty(data.getProfile().getName()))
.forEach(data -> {
final String name = data.getProfile().getName();
PlayerInfoHelper.invokeEfficiently(name, new FutureCallback<PlayerInfo>() {
@Override
public void onSuccess(@Nullable PlayerInfo result) {
if(result != null) fireEvents(packet.getAction(), result, data.getProfile());
}
@Override
public void onFailure(Throwable t) {
}
});
});
}
}
示例5: NetworkPlayerInfo
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
public NetworkPlayerInfo(SPacketPlayerListItem.AddPlayerData entry)
{
this.gameProfile = entry.getProfile();
this.gameType = entry.getGameMode();
this.responseTime = entry.getPing();
this.displayName = entry.getDisplayName();
}
示例6: playerLoggedOut
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
/**
* Called when a player disconnects from the game. Writes player data to disk and removes them from the world.
*/
public void playerLoggedOut(EntityPlayerMP playerIn)
{
WorldServer worldserver = playerIn.getServerWorld();
playerIn.addStat(StatList.LEAVE_GAME);
this.writePlayerData(playerIn);
if (playerIn.isRiding())
{
Entity entity = playerIn.getLowestRidingEntity();
if (entity.getRecursivePassengersByType(EntityPlayerMP.class).size() == 1)
{
LOG.debug("Removing player mount");
playerIn.dismountRidingEntity();
worldserver.removeEntityDangerously(entity);
for (Entity entity1 : entity.getRecursivePassengers())
{
worldserver.removeEntityDangerously(entity1);
}
worldserver.getChunkFromChunkCoords(playerIn.chunkCoordX, playerIn.chunkCoordZ).setChunkModified();
}
}
worldserver.removeEntity(playerIn);
worldserver.getPlayerChunkMap().removePlayer(playerIn);
this.playerEntityList.remove(playerIn);
UUID uuid = playerIn.getUniqueID();
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.uuidToPlayerMap.get(uuid);
if (entityplayermp == playerIn)
{
this.uuidToPlayerMap.remove(uuid);
this.playerStatFiles.remove(uuid);
}
this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.REMOVE_PLAYER, new EntityPlayerMP[] {playerIn}));
}
示例7: onTick
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
/**
* self explanitory
*/
public void onTick()
{
if (++this.playerPingIndex > 600)
{
this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.UPDATE_LATENCY, this.playerEntityList));
this.playerPingIndex = 0;
}
}
示例8: setGameType
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
public void setGameType(GameType type)
{
this.gameType = type;
type.configurePlayerCapabilities(this.thisPlayerMP.capabilities);
this.thisPlayerMP.sendPlayerAbilities();
this.thisPlayerMP.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.UPDATE_GAME_MODE, new EntityPlayerMP[] {this.thisPlayerMP}));
this.theWorld.updateAllPlayersSleepingFlag();
}
示例9: hide
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
@Override
public void hide(org.fountainmc.api.entity.Entity fountainToHide) {
Entity toHide = ((WetEntity) checkNotNull(fountainToHide, "Null entity")).getHandle();
checkArgument(!toHide.equals(getHandle()), "Cant hide player %s from itself!", this);
if (isConnected() && hiddenEntities.add(toHide) && getHandle().worldObj.equals(toHide.worldObj)) {
EntityTrackerEntry trackerEntry = ((WorldServer) getHandle().worldObj).theEntityTracker.getTrackerEntry(toHide);
if (trackerEntry != null) {
trackerEntry.removeTrackedPlayerSymmetric(this.getHandle());
if (toHide instanceof Player) {
((EntityPlayerMP) toHide).connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.a.REMOVE_PLAYER, (EntityPlayerMP) toHide));
}
}
}
}
示例10: handlePlayerListItem
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
@SuppressWarnings("incomplete-switch")
public void handlePlayerListItem(SPacketPlayerListItem packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
for (SPacketPlayerListItem.AddPlayerData spacketplayerlistitem$addplayerdata : packetIn.getEntries())
{
if (packetIn.getAction() == SPacketPlayerListItem.Action.REMOVE_PLAYER)
{
this.playerInfoMap.remove(spacketplayerlistitem$addplayerdata.getProfile().getId());
}
else
{
NetworkPlayerInfo networkplayerinfo = (NetworkPlayerInfo)this.playerInfoMap.get(spacketplayerlistitem$addplayerdata.getProfile().getId());
if (packetIn.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER)
{
networkplayerinfo = new NetworkPlayerInfo(spacketplayerlistitem$addplayerdata);
this.playerInfoMap.put(networkplayerinfo.getGameProfile().getId(), networkplayerinfo);
}
if (networkplayerinfo != null)
{
switch (packetIn.getAction())
{
case ADD_PLAYER:
networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
break;
case UPDATE_GAME_MODE:
networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
break;
case UPDATE_LATENCY:
networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
break;
case UPDATE_DISPLAY_NAME:
networkplayerinfo.setDisplayName(spacketplayerlistitem$addplayerdata.getDisplayName());
}
}
}
}
}
示例11: handlePlayerListItem
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
@SuppressWarnings("incomplete-switch")
public void handlePlayerListItem(SPacketPlayerListItem packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
for (SPacketPlayerListItem.AddPlayerData spacketplayerlistitem$addplayerdata : packetIn.getEntries())
{
if (packetIn.getAction() == SPacketPlayerListItem.Action.REMOVE_PLAYER)
{
this.playerInfoMap.remove(spacketplayerlistitem$addplayerdata.getProfile().getId());
}
else
{
NetworkPlayerInfo networkplayerinfo = (NetworkPlayerInfo)this.playerInfoMap.get(spacketplayerlistitem$addplayerdata.getProfile().getId());
if (packetIn.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER)
{
networkplayerinfo = new NetworkPlayerInfo(spacketplayerlistitem$addplayerdata);
this.playerInfoMap.put(networkplayerinfo.getGameProfile().getId(), networkplayerinfo);
}
if (networkplayerinfo != null)
{
switch (packetIn.getAction())
{
case ADD_PLAYER:
networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
break;
case UPDATE_GAME_MODE:
networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
break;
case UPDATE_LATENCY:
networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
break;
case UPDATE_DISPLAY_NAME:
networkplayerinfo.setDisplayName(spacketplayerlistitem$addplayerdata.getDisplayName());
}
}
}
}
}
示例12: playerLoggedOut
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
/**
* Called when a player disconnects from the game. Writes player data to disk and removes them from the world.
*/
public void playerLoggedOut(EntityPlayerMP playerIn)
{
net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerLoggedOut(playerIn);
WorldServer worldserver = playerIn.getServerWorld();
playerIn.addStat(StatList.LEAVE_GAME);
this.writePlayerData(playerIn);
if (playerIn.isRiding())
{
Entity entity = playerIn.getLowestRidingEntity();
if (entity.getRecursivePassengersByType(EntityPlayerMP.class).size() == 1)
{
LOG.debug("Removing player mount");
playerIn.dismountRidingEntity();
worldserver.removeEntityDangerously(entity);
for (Entity entity1 : entity.getRecursivePassengers())
{
worldserver.removeEntityDangerously(entity1);
}
worldserver.getChunkFromChunkCoords(playerIn.chunkCoordX, playerIn.chunkCoordZ).setChunkModified();
}
}
worldserver.removeEntity(playerIn);
worldserver.getPlayerChunkMap().removePlayer(playerIn);
this.playerEntityList.remove(playerIn);
UUID uuid = playerIn.getUniqueID();
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.uuidToPlayerMap.get(uuid);
if (entityplayermp == playerIn)
{
this.uuidToPlayerMap.remove(uuid);
this.playerStatFiles.remove(uuid);
}
net.minecraftforge.common.chunkio.ChunkIOExecutor.adjustPoolSize(this.getCurrentPlayerCount());
this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.REMOVE_PLAYER, new EntityPlayerMP[] {playerIn}));
}
示例13: createState
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
public boolean createState(WorldServer world, double x, double y, double z)
{
if(state == null || state.ent == null)
{
try
{
EntityPlayerMP playerDummy = new FakePlayer(world, EntityHelper.getDummyGameProfile());
NBTTagCompound tag = CompressedStreamTools.readCompressed(new ByteArrayInputStream(this.nbtToRead));
playerDummy.readFromNBT(tag);
playerDummy.setLocationAndAngles(x, y, z, playerDummy.rotationYaw, playerDummy.rotationPitch);
playerDummy.writeToNBT(tag);
this.state = new EntityState(playerDummy);
if(this.entityType.startsWith("player::"))
{
this.state.ent = new FakePlayer(world, EntityHelper.getGameProfile(this.entityType.substring("player::".length())));
this.state.ent.readFromNBT(tag);
new FakeNetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.CLIENTBOUND), (FakePlayer)this.state.ent);
FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, (FakePlayer)this.state.ent));
state.ent.getDataWatcher().updateObject(10, (byte)127);
}
else
{
this.state.ent = (EntityLivingBase)Class.forName(this.entityType).getConstructor(World.class).newInstance(world);
this.state.ent.setSprinting(playerDummy.isSprinting());
this.state.ent.setSneaking(playerDummy.isSneaking());
for(int i = 0; i < state.ent.getInventory().length; i++)
{
this.state.ent.setCurrentItemOrArmor(i, playerDummy.getEquipmentInSlot(i));
}
}
if(state.ent instanceof EntityLiving)
{
((EntityLiving)state.ent).setNoAI(true);
((EntityLiving)state.ent).tasks.taskEntries.clear();
((EntityLiving)state.ent).targetTasks.taskEntries.clear();
}
return true;
}
catch(Exception e)
{
e.printStackTrace();
}
}
return false;
}
示例14: handlePlayerListItem
import net.minecraft.network.play.server.SPacketPlayerListItem; //导入依赖的package包/类
void handlePlayerListItem(SPacketPlayerListItem packetIn);