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


Java IChunkProvider.provideChunk方法代码示例

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


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

示例1: isChunkReady

import net.minecraft.world.chunk.IChunkProvider; //导入方法依赖的package包/类
private boolean isChunkReady()
{
    // First, find the starting position we ought to have:
    List<AgentSection> agents = currentMissionInit().getMission().getAgentSection();
    if (agents == null || agents.size() <= currentMissionInit().getClientRole())
        return true;    // This should never happen.
    AgentSection as = agents.get(currentMissionInit().getClientRole());
    if (as.getAgentStart() != null && as.getAgentStart().getPlacement() != null)
    {
        PosAndDirection pos = as.getAgentStart().getPlacement();
        int x = MathHelper.floor_double(pos.getX().doubleValue()) >> 4;
        int z = MathHelper.floor_double(pos.getZ().doubleValue()) >> 4;
        // Now get the chunk we should be starting in:
        IChunkProvider chunkprov = Minecraft.getMinecraft().theWorld.getChunkProvider();
        EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
        if (player.addedToChunk)
        {
            // Our player is already added to a chunk - is it the right one?
            Chunk actualChunk = chunkprov.provideChunk(player.chunkCoordX, player.chunkCoordZ);
            Chunk requestedChunk = chunkprov.provideChunk(x,  z);
            if (actualChunk == requestedChunk && actualChunk != null && !actualChunk.isEmpty())
            {
                // We're in the right chunk, and it's not an empty chunk.
                // We're ready to proceed, but first set our client positions to where we ought to be.
                // The server should be doing this too, but there's no harm (probably) in doing it ourselves.
                player.posX = pos.getX().doubleValue();
                player.posY = pos.getY().doubleValue();
                player.posZ = pos.getZ().doubleValue();
                return true;
            }
        }
        return false;   // Our starting position has been specified, but it's not yet ready.
    }
    return true;    // No starting position specified, so doesn't matter where we start.
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:36,代码来源:ClientStateMachine.java


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