当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayerMP.getServerWorld方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayerMP.getServerWorld方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayerMP.getServerWorld方法的具体用法?Java EntityPlayerMP.getServerWorld怎么用?Java EntityPlayerMP.getServerWorld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayerMP的用法示例。


在下文中一共展示了EntityPlayerMP.getServerWorld方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMessage

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
@Override
public IMessage onMessage(final MessageWorldCraft message, final MessageContext ctx)
{
    if(ctx.side != Side.SERVER)
    {
        System.err.println("MessageWorldCraft received on wrong side:" + ctx.side);
        return null;
    }

    final EntityPlayerMP sendingPlayer = ctx.getServerHandler().player;
    if(sendingPlayer == null)
    {
        System.err.println("MessageWorldCraft received with null player.");
        return null;
    }

    final WorldServer playerWorldServer = sendingPlayer.getServerWorld();
    playerWorldServer.addScheduledTask(() -> processMessage(message, ctx, playerWorldServer));
    return null;
}
 
开发者ID:Lumaceon,项目名称:CraftingParadiseMod,代码行数:21,代码来源:HandlerWorldCraft.java

示例2: teleportPlayerToDimension

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
private static void teleportPlayerToDimension(EntityPlayerMP playerIn, int suggestedDimensionId, double x, double y, double z) {
    WorldServer fromWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(playerIn.dimension);
    WorldServer toWorld = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(suggestedDimensionId);
    playerIn.dimension = toWorld.provider.getDimension();
    ChunkPos pos = new ChunkPos(playerIn.getPosition());
    toWorld.getChunkProvider().loadChunk(pos.x, pos.z);
    final int dimensionId = playerIn.dimension;
    if (fromWorld != toWorld && fromWorld.provider.getDimensionType() == toWorld.provider.getDimensionType()) {
        playerIn.connection.sendPacket(new SPacketRespawn((dimensionId >= 0 ? -1 : 0), toWorld.getDifficulty(), toWorld.getWorldInfo().getTerrainType(), playerIn.interactionManager.getGameType()));
    }
    playerIn.connection.sendPacket(new SPacketRespawn(dimensionId, toWorld.getDifficulty(), toWorld.getWorldInfo().getTerrainType(), playerIn.interactionManager.getGameType()));
    fromWorld.removeEntityDangerously(playerIn);
    playerIn.isDead = false;
    playerIn.connection.setPlayerLocation(x, y, z, playerIn.rotationYaw, playerIn.rotationPitch);
    playerIn.world = toWorld;
    playerIn.setWorld(toWorld);
    toWorld.spawnEntity(playerIn);
    toWorld.updateEntityWithOptionalForce(playerIn, false);
    WorldServer worldserver = playerIn.getServerWorld();
    fromWorld.getPlayerChunkMap().removePlayer(playerIn);
    worldserver.getPlayerChunkMap().addPlayer(playerIn);
    worldserver.getChunkProvider().provideChunk((int)playerIn.posX >> 4, (int)playerIn.posZ >> 4);
    playerIn.connection.setPlayerLocation(playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
    playerIn.interactionManager.setWorld(toWorld);
    WorldBorder worldborder = FMLCommonHandler.instance().getMinecraftServerInstance().worlds[0].getWorldBorder();
    playerIn.connection.sendPacket(new SPacketWorldBorder(worldborder, SPacketWorldBorder.Action.INITIALIZE));
    playerIn.connection.sendPacket(new SPacketTimeUpdate(toWorld.getTotalWorldTime(), toWorld.getWorldTime(), toWorld.getGameRules().getBoolean("doDaylightCycle")));
    if (toWorld.isRaining()) {
        playerIn.connection.sendPacket(new SPacketChangeGameState(1, 0.0F));
        playerIn.connection.sendPacket(new SPacketChangeGameState(7, toWorld.getRainStrength(1.0F)));
        playerIn.connection.sendPacket(new SPacketChangeGameState(8, toWorld.getThunderStrength(1.0F)));
    }
    playerIn.sendContainerToPlayer(playerIn.inventoryContainer);
    playerIn.setPlayerHealthUpdated();
    playerIn.connection.sendPacket(new SPacketHeldItemChange(playerIn.inventory.currentItem));
}
 
开发者ID:TerminatorNL,项目名称:LagGoggles,代码行数:37,代码来源:Teleport.java

示例3: preparePlayer

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
public void preparePlayer(EntityPlayerMP playerIn, WorldServer worldIn)
{
    WorldServer worldserver = playerIn.getServerWorld();

    if (worldIn != null)
    {
        worldIn.getPlayerChunkMap().removePlayer(playerIn);
    }

    worldserver.getPlayerChunkMap().addPlayer(playerIn);
    worldserver.getChunkProvider().provideChunk((int)playerIn.posX >> 4, (int)playerIn.posZ >> 4);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:13,代码来源:PlayerList.java

示例4: playerLoggedOut

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的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}));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:43,代码来源:PlayerList.java

示例5: showWhooshEffect

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
public static void showWhooshEffect(EntityPlayerMP player)
{
    WorldServer world = player.getServerWorld();
    Particles.emitEnder(world, player.posX, player.posY, player.posZ);
    Particles.emitSmoke(world, player.posX, player.posY, player.posZ);
    world.playSound(player, player.getPosition(), SoundEvents.ITEM_FIRECHARGE_USE, SoundCategory.BLOCKS, 1.0F, 1.0f);
}
 
开发者ID:abused,项目名称:World-Border,代码行数:8,代码来源:Particles.java

示例6: playerLoggedOut

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的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}));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:45,代码来源:PlayerList.java


注:本文中的net.minecraft.entity.player.EntityPlayerMP.getServerWorld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。