本文整理汇总了Java中net.minecraft.world.chunk.Chunk类的典型用法代码示例。如果您正苦于以下问题:Java Chunk类的具体用法?Java Chunk怎么用?Java Chunk使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Chunk类属于net.minecraft.world.chunk包,在下文中一共展示了Chunk类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unloadQueuedChunks
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
/**
* Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk.
*/
public boolean unloadQueuedChunks()
{
long i = System.currentTimeMillis();
for (Chunk chunk : this.chunkMapping.values())
{
chunk.onTick(System.currentTimeMillis() - i > 5L);
}
if (System.currentTimeMillis() - i > 100L)
{
LOGGER.info("Warning: Clientside chunk ticking took {} ms", new Object[] {Long.valueOf(System.currentTimeMillis() - i)});
}
return false;
}
示例2: getTopSolidOrLiquidBlock
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
/**
* Finds the highest block on the x and z coordinate that is solid or liquid, and returns its y coord.
*/
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos)
{
Chunk chunk = this.getChunkFromBlockCoords(pos);
BlockPos blockpos;
BlockPos blockpos1;
for (blockpos = new BlockPos(pos.getX(), chunk.getTopFilledSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1)
{
blockpos1 = blockpos.down();
Material material = chunk.getBlock(blockpos1).getMaterial();
if (material.blocksMovement() && material != Material.leaves)
{
break;
}
}
return blockpos;
}
示例3: isBlockNormalCube
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
/**
* Checks if a block's material is opaque, and that it takes up a full cube
*/
public boolean isBlockNormalCube(BlockPos pos, boolean _default)
{
if (this.isOutsideBuildHeight(pos))
{
return false;
}
else
{
Chunk chunk = this.chunkProvider.getLoadedChunk(pos.getX() >> 4, pos.getZ() >> 4);
if (chunk != null && !chunk.isEmpty())
{
IBlockState iblockstate = this.getBlockState(pos);
return iblockstate.getBlock().isNormalCube(iblockstate, this, pos);
}
else
{
return _default;
}
}
}
示例4: S26PacketMapChunkBulk
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
public S26PacketMapChunkBulk(List<Chunk> chunks)
{
int i = chunks.size();
this.xPositions = new int[i];
this.zPositions = new int[i];
this.chunksData = new S21PacketChunkData.Extracted[i];
this.isOverworld = !((Chunk)chunks.get(0)).getWorld().provider.getHasNoSky();
for (int j = 0; j < i; ++j)
{
Chunk chunk = (Chunk)chunks.get(j);
S21PacketChunkData.Extracted s21packetchunkdata$extracted = S21PacketChunkData.func_179756_a(chunk, true, this.isOverworld, 65535);
this.xPositions[j] = chunk.xPosition;
this.zPositions[j] = chunk.zPosition;
this.chunksData[j] = s21packetchunkdata$extracted;
}
}
示例5: onLivingUpdate
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
if (!(event.getEntity() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) event.getEntity();
if (player.isDead) {
this.hueManager.adjustColor(new Color(255, 0, 0));
return;
}
BlockPos pos = player.getPosition();
Chunk chunk = this.world.getChunkFromBlockCoords(pos);
Biome biome = chunk.getBiome(pos, this.world.getBiomeProvider());
String color = this.biomeMap.get(biome.getRegistryName().getResourcePath());
if (color != null) {
this.hueManager.adjustColor(color);
}
}
示例6: provideChunk
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
public Chunk provideChunk(int x, int z)
{
this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
ChunkPrimer chunkprimer = new ChunkPrimer();
this.prepareHeights(x, z, chunkprimer);
this.buildSurfaces(x, z, chunkprimer);
this.genNetherCaves.generate(this.world, x, z, chunkprimer);
if (this.generateStructures)
{
this.genNetherBridge.generate(this.world, x, z, chunkprimer);
}
Chunk chunk = new Chunk(this.world, chunkprimer, x, z);
Biome[] abiome = this.world.getBiomeProvider().getBiomes((Biome[])null, x * 16, z * 16, 16, 16);
byte[] abyte = chunk.getBiomeArray();
for (int i = 0; i < abyte.length; ++i)
{
abyte[i] = (byte)Biome.getIdForBiome(abiome[i]);
}
chunk.resetRelightChecks();
return chunk;
}
示例7: getChunksLowestHorizon
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
/**
* Gets the lowest height of the chunk where sunlight directly reaches
*/
public int getChunksLowestHorizon(int x, int z)
{
if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000)
{
if (!this.isChunkLoaded(x >> 4, z >> 4, true))
{
return 0;
}
else
{
Chunk chunk = this.getChunkFromChunkCoords(x >> 4, z >> 4);
return chunk.getLowestHeight();
}
}
else
{
return this.func_181545_F() + 1;
}
}
示例8: saveChunk
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
public void saveChunk(World worldIn, Chunk chunkIn) throws MinecraftException, IOException
{
worldIn.checkSessionLock();
try
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound.setTag("Level", nbttagcompound1);
this.writeChunkToNBT(chunkIn, worldIn, nbttagcompound1);
this.addChunkToPending(chunkIn.getChunkCoordIntPair(), nbttagcompound);
}
catch (Exception exception)
{
logger.error((String)"Failed to save chunk", (Throwable)exception);
}
}
示例9: provideChunk
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
public Chunk provideChunk(int x, int z)
{
this.chunkX = x; this.chunkZ = z;
this.rand.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
ChunkPrimer chunkprimer = new ChunkPrimer();
this.biomesForGeneration = this.worldObj.getBiomeProvider().getBiomes(this.biomesForGeneration, x * 16, z * 16, 16, 16);
this.setBlocksInChunk(x, z, chunkprimer);
this.buildSurfaces(chunkprimer);
if (this.mapFeaturesEnabled)
{
this.endCityGen.generate(this.worldObj, x, z, chunkprimer);
}
Chunk chunk = new Chunk(this.worldObj, chunkprimer, x, z);
byte[] abyte = chunk.getBiomeArray();
for (int i = 0; i < abyte.length; ++i)
{
abyte[i] = (byte)Biome.getIdForBiome(this.biomesForGeneration[i]);
}
chunk.generateSkylightMap();
return chunk;
}
示例10: getBlockState
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
public IBlockState getBlockState(BlockPos pos)
{
if (pos.getY() >= 0 && pos.getY() < 256)
{
int i = (pos.getX() >> 4) - this.chunkX;
int j = (pos.getZ() >> 4) - this.chunkZ;
if (i >= 0 && i < this.chunkArray.length && j >= 0 && j < this.chunkArray[i].length)
{
Chunk chunk = this.chunkArray[i][j];
if (chunk != null)
{
return chunk.getBlockState(pos);
}
}
}
return Blocks.AIR.getDefaultState();
}
示例11: provideChunk
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
/**
* Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the
* specified chunk from the map seed and chunk seed
*/
public Chunk provideChunk(int x, int z)
{
this.endRNG.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
ChunkPrimer chunkprimer = new ChunkPrimer();
this.biomesForGeneration = this.endWorld.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, x * 16, z * 16, 16, 16);
this.func_180520_a(x, z, chunkprimer);
this.func_180519_a(chunkprimer);
Chunk chunk = new Chunk(this.endWorld, chunkprimer, x, z);
byte[] abyte = chunk.getBiomeArray();
for (int i = 0; i < abyte.length; ++i)
{
abyte[i] = (byte)this.biomesForGeneration[i].biomeID;
}
chunk.generateSkylightMap();
return chunk;
}
示例12: SPacketChunkData
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
public SPacketChunkData(Chunk p_i47124_1_, int p_i47124_2_)
{
this.chunkX = p_i47124_1_.xPosition;
this.chunkZ = p_i47124_1_.zPosition;
this.loadChunk = p_i47124_2_ == 65535;
boolean flag = p_i47124_1_.getWorld().provider.func_191066_m();
this.buffer = new byte[this.calculateChunkSize(p_i47124_1_, flag, p_i47124_2_)];
this.availableSections = this.extractChunkData(new PacketBuffer(this.getWriteBuffer()), p_i47124_1_, flag, p_i47124_2_);
this.tileEntityTags = Lists.<NBTTagCompound>newArrayList();
for (Entry<BlockPos, TileEntity> entry : p_i47124_1_.getTileEntityMap().entrySet())
{
BlockPos blockpos = (BlockPos)entry.getKey();
TileEntity tileentity = (TileEntity)entry.getValue();
int i = blockpos.getY() >> 4;
if (this.doChunkLoad() || (p_i47124_2_ & 1 << i) != 0)
{
NBTTagCompound nbttagcompound = tileentity.getUpdateTag();
this.tileEntityTags.add(nbttagcompound);
}
}
}
示例13: onRightClickBlock
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event)
{
if (event.getWorld().isRemote) { return; } // Not doing this on client side
if (!Main.shouldCheckInteraction()) { return; } // Not my business
Main.console("Block at x" + event.getPos().getX() + " y" + event.getPos().getY() + " z" + event.getPos().getZ() + " touched by player " + event.getEntityPlayer().getName() +
" (ID " + event.getEntityPlayer().getGameProfile().getId() + ").");
Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(event.getPos());
if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer().worldObj, event.getEntityPlayer(), chunk)) // Checks out
{
Main.console("Player is allowed to interact with this chunk. Doing nothing.");
}
else
{
Main.console("Player is not allowed to interact with this chunk. Cancelling.");
event.setCanceled(true); // Not having it
}
}
示例14: extractChunkData
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
public int extractChunkData(PacketBuffer p_189555_1_, Chunk p_189555_2_, boolean p_189555_3_, int p_189555_4_)
{
int i = 0;
ExtendedBlockStorage[] aextendedblockstorage = p_189555_2_.getBlockStorageArray();
int j = 0;
for (int k = aextendedblockstorage.length; j < k; ++j)
{
ExtendedBlockStorage extendedblockstorage = aextendedblockstorage[j];
if (extendedblockstorage != Chunk.NULL_BLOCK_STORAGE && (!this.doChunkLoad() || !extendedblockstorage.isEmpty()) && (p_189555_4_ & 1 << j) != 0)
{
i |= 1 << j;
extendedblockstorage.getData().write(p_189555_1_);
p_189555_1_.writeBytes(extendedblockstorage.getBlocklightArray().getData());
if (p_189555_3_)
{
p_189555_1_.writeBytes(extendedblockstorage.getSkylightArray().getData());
}
}
}
if (this.doChunkLoad())
{
p_189555_1_.writeBytes(p_189555_2_.getBiomeArray());
}
return i;
}
示例15: notifyChunk
import net.minecraft.world.chunk.Chunk; //导入依赖的package包/类
/**
* Notify all nearby players about chunk changes
* @param chunk Chunk to notify
*/
public void notifyChunk(Chunk chunk) {
for (EntityPlayer player : world.playerEntities) {
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
if ( Math.abs(playerMP.chunkCoordX - chunk.xPosition) <= 32 &&
Math.abs(playerMP.chunkCoordZ - chunk.zPosition) <= 32) {
playerMP.connection.sendPacket(new SPacketChunkData(chunk, 65535));
}
}
}
}