本文整理汇总了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.
}