/** * 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; }
/** * 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; }
/** * 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; } } }
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; } }
@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); } }
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; }
/** * 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; } }
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); } }
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; }
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(); }
/** * 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; }
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); } } }
@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 } }
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; }
/** * 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)); } } } }
/** * 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.x) <= 32 && Math.abs(playerMP.chunkCoordZ - chunk.z) <= 32) { playerMP.connection.sendPacket(new SPacketChunkData(chunk, 65535)); } } } }
/** * marks all chunks for unload, ignoring those near the spawn */ public void unloadAllChunks() { for (Chunk chunk : this.loadedChunks) { this.dropChunk(chunk.xPosition, chunk.zPosition); } }
/** * Wraps readChunkFromNBT. Checks the coordinates and several NBT tags. */ protected Chunk checkedReadChunkFromNBT(World worldIn, int x, int z, NBTTagCompound p_75822_4_) { if (!p_75822_4_.hasKey("Level", 10)) { logger.error("Chunk file at " + x + "," + z + " is missing level data, skipping"); return null; } else { NBTTagCompound nbttagcompound = p_75822_4_.getCompoundTag("Level"); if (!nbttagcompound.hasKey("Sections", 9)) { logger.error("Chunk file at " + x + "," + z + " is missing block data, skipping"); return null; } else { Chunk chunk = this.readChunkFromNBT(worldIn, nbttagcompound); if (!chunk.isAtLocation(x, z)) { logger.error("Chunk file at " + x + "," + z + " is in the wrong location; relocating. (Expected " + x + ", " + z + ", got " + chunk.xPosition + ", " + chunk.zPosition + ")"); nbttagcompound.setInteger("xPos", x); nbttagcompound.setInteger("zPos", z); chunk = this.readChunkFromNBT(worldIn, nbttagcompound); } return chunk; } } }
public S21PacketChunkData(Chunk chunkIn, boolean p_i45196_2_, int p_i45196_3_) { this.chunkX = chunkIn.xPosition; this.chunkZ = chunkIn.zPosition; this.field_149279_g = p_i45196_2_; this.extractedData = func_179756_a(chunkIn, p_i45196_2_, !chunkIn.getWorld().provider.getHasNoSky(), p_i45196_3_); }
private void syncWithPlayers(World world) { List<EntityPlayer> players = world.playerEntities; for (Map.Entry<Chunk, Set<EntityPlayer>> entry : syncList.entrySet()) { Chunk chunk = entry.getKey(); Set<EntityPlayer> syncedPlayers = entry.getValue(); int chunkX = chunk.x * 16 - 8; int chunkZ = chunk.z * 16 - 8; for (EntityPlayer player : players) { if (chunk.getWorld() == world) { double dist = PneumaticCraftUtils.distBetween(player.posX, 0, player.posZ, chunkX, 0, chunkZ); if (dist < SYNC_DISTANCE) { if (syncedPlayers.add(player)) { for(List<ISemiBlock> semiBlocks : semiBlocks.get(chunk).values()){ for (ISemiBlock semiBlock : semiBlocks) { if (!semiBlock.isInvalid()) { NetworkHandler.sendTo(new PacketAddSemiBlock(semiBlock), (EntityPlayerMP) player); PacketDescription descPacket = semiBlock.getDescriptionPacket(); if (descPacket != null) NetworkHandler.sendTo(descPacket, (EntityPlayerMP) player); } } } } } else if (dist > SYNC_DISTANCE + 5) { syncedPlayers.remove(player); } } else { syncedPlayers.remove(player); } } } }
@Override public boolean canDoLightning(Chunk chunk) { if(m_realProvider != null) { return m_realProvider.canDoLightning(chunk); } else { return super.canDoLightning(chunk); } }
/** * Updates the specified chunk with the supplied data, marks it for re-rendering and lighting recalculation */ public void handleChunkData(SPacketChunkData packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); if (packetIn.doChunkLoad()) { this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true); } this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15); Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(packetIn.getChunkX(), packetIn.getChunkZ()); chunk.fillChunk(packetIn.getReadBuffer(), packetIn.getExtractedSize(), packetIn.doChunkLoad()); this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15); if (!packetIn.doChunkLoad() || !(this.clientWorldController.provider instanceof WorldProviderSurface)) { chunk.resetRelightChecks(); } for (NBTTagCompound nbttagcompound : packetIn.getTileEntityTags()) { BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z")); TileEntity tileentity = this.clientWorldController.getTileEntity(blockpos); if (tileentity != null) { tileentity.readFromNBT(nbttagcompound); } } }
public static void updateColorAsync(final World worldIn, final BlockPos glassPos) { HttpUtil.field_180193_a.submit(new Runnable() { public void run() { Chunk chunk = worldIn.getChunkFromBlockCoords(glassPos); for (int i = glassPos.getY() - 1; i >= 0; --i) { final BlockPos blockpos = new BlockPos(glassPos.getX(), i, glassPos.getZ()); if (!chunk.canSeeSky(blockpos)) { break; } IBlockState iblockstate = worldIn.getBlockState(blockpos); if (iblockstate.getBlock() == Blocks.beacon) { ((WorldServer)worldIn).addScheduledTask(new Runnable() { public void run() { TileEntity tileentity = worldIn.getTileEntity(blockpos); if (tileentity instanceof TileEntityBeacon) { ((TileEntityBeacon)tileentity).updateBeacon(); worldIn.addBlockEvent(blockpos, Blocks.beacon, 1, 0); } } }); } } } }); }
/** * Get block storage array for y-coordinate * Returns null in case block is outside * @param chunk Target chunk * @param y Block height inside chunk * @return Block storage or null */ private static ExtendedBlockStorage getStorage(Chunk chunk, int y) { ExtendedBlockStorage[] storage = chunk.getBlockStorageArray(); if (y < 0 || y >= 256) { return null; } int i = y >> 4; if (storage[i] == Chunk.NULL_BLOCK_STORAGE) { storage[i] = new ExtendedBlockStorage(i << 4, chunk.getWorld().provider.hasSkyLight()); chunk.generateSkylightMap(); } return storage[i]; }
@Override public int performOperation(Region region, PositionIterator chunk, World world, Chunk c, VectorMap<BlockData> blockMap, MutableVectorMap<IBlockState> hitMap) { return chunk.forEachRemaining((x, y, z) -> { if (!Operation.isHit(x, y, z, hitMap)) { return 0; } BlockPos pos = new BlockPos(x, y, z); IBlockState state = c.getBlockState(pos); world.markAndNotifyBlock(pos, c, state, state, 1); return 1; }); }
/** * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk. */ public boolean unloadQueuedChunks() { if (!this.worldObj.disableLevelSaving) { for (int i = 0; i < 100; ++i) { if (!this.droppedChunksSet.isEmpty()) { Long olong = (Long)this.droppedChunksSet.iterator().next(); Chunk chunk = (Chunk)this.id2ChunkMap.getValueByKey(olong.longValue()); if (chunk != null) { chunk.onChunkUnload(); this.saveChunkData(chunk); this.saveChunkExtraData(chunk); this.id2ChunkMap.remove(olong.longValue()); this.loadedChunks.remove(chunk); } this.droppedChunksSet.remove(olong); } } if (this.chunkLoader != null) { this.chunkLoader.chunkTick(); } } return this.serverChunkGenerator.unloadQueuedChunks(); }
public void removePlayer(EntityPlayerMP player) { if (this.playersWatchingChunk.contains(player)) { Chunk chunk = PlayerManager.this.theWorldServer.getChunkFromChunkCoords(this.chunkCoords.chunkXPos, this.chunkCoords.chunkZPos); if (chunk.isPopulated()) { player.playerNetServerHandler.sendPacket(new S21PacketChunkData(chunk, true, 0)); } this.playersWatchingChunk.remove(player); player.loadedChunks.remove(this.chunkCoords); if (this.playersWatchingChunk.isEmpty()) { long i = (long)this.chunkCoords.chunkXPos + 2147483647L | (long)this.chunkCoords.chunkZPos + 2147483647L << 32; this.increaseInhabitedTime(chunk); PlayerManager.this.playerInstances.remove(i); PlayerManager.this.playerInstanceList.remove(this); if (this.numBlocksToUpdate > 0) { PlayerManager.this.playerInstancesToUpdate.remove(this); } PlayerManager.this.getWorldServer().theChunkProviderServer.dropChunk(this.chunkCoords.chunkXPos, this.chunkCoords.chunkZPos); } } }
/** * Saves all chunks to disk while updating progress bar. */ public void saveAllChunks(boolean p_73044_1_, IProgressUpdate progressCallback) throws MinecraftException { if (this.chunkProvider.canSave()) { if (progressCallback != null) { progressCallback.displaySavingString("Saving level"); } this.saveLevel(); if (progressCallback != null) { progressCallback.displayLoadingString("Saving chunks"); } this.chunkProvider.saveChunks(p_73044_1_, progressCallback); for (Chunk chunk : Lists.newArrayList(this.theChunkProviderServer.func_152380_a())) { if (chunk != null && !this.thePlayerManager.hasPlayerInstance(chunk.xPosition, chunk.zPosition)) { this.theChunkProviderServer.dropChunk(chunk.xPosition, chunk.zPosition); } } } }
/** * Unload chunk from ChunkProviderClient's hashmap. Called in response to a Packet50PreChunk with its mode field set * to false */ public void unloadChunk(int p_73234_1_, int p_73234_2_) { Chunk chunk = this.provideChunk(p_73234_1_, p_73234_2_); if (!chunk.isEmpty()) { chunk.onChunkUnload(); } this.chunkMapping.remove(ChunkCoordIntPair.chunkXZ2Int(p_73234_1_, p_73234_2_)); this.chunkListing.remove(chunk); }
/** * 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) { ChunkPrimer chunkprimer = new ChunkPrimer(); for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) { int k = x * 16 + i; int l = z * 16 + j; chunkprimer.setBlockState(i, 60, j, Blocks.barrier.getDefaultState()); IBlockState iblockstate = func_177461_b(k, l); if (iblockstate != null) { chunkprimer.setBlockState(i, 70, j, iblockstate); } } } Chunk chunk = new Chunk(this.world, chunkprimer, x, z); chunk.generateSkylightMap(); BiomeGenBase[] abiomegenbase = this.world.getWorldChunkManager().loadBlockGeneratorData((BiomeGenBase[])null, x * 16, z * 16, 16, 16); byte[] abyte = chunk.getBiomeArray(); for (int i1 = 0; i1 < abyte.length; ++i1) { abyte[i1] = (byte)abiomegenbase[i1].biomeID; } chunk.generateSkylightMap(); return chunk; }
public boolean saveChunks(boolean p_186027_1_) { int i = 0; List<Chunk> list = Lists.newArrayList(this.id2ChunkMap.values()); for (int j = 0; j < ((List)list).size(); ++j) { Chunk chunk = (Chunk)list.get(j); if (p_186027_1_) { this.saveChunkExtraData(chunk); } if (chunk.needsSaving(p_186027_1_)) { this.saveChunkData(chunk); chunk.setModified(false); ++i; if (i == 24 && !p_186027_1_) { return false; } } } return true; }
protected int calculateChunkSize(Chunk chunkIn, boolean p_189556_2_, int p_189556_3_) { int i = 0; ExtendedBlockStorage[] aextendedblockstorage = chunkIn.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_189556_3_ & 1 << j) != 0) { i = i + extendedblockstorage.getData().getSerializedSize(); i = i + extendedblockstorage.getBlocklightArray().getData().length; if (p_189556_2_) { i += extendedblockstorage.getSkylightArray().getData().length; } } } if (this.doChunkLoad()) { i += chunkIn.getBiomeArray().length; } return i; }
/** * Checks if the entity's current position is a valid location to spawn this entity. */ public boolean getCanSpawnHere() { BlockPos blockpos = new BlockPos(MathHelper.floor(this.posX), 0, MathHelper.floor(this.posZ)); Chunk chunk = this.world.getChunkFromBlockCoords(blockpos); if (this.world.getWorldInfo().getTerrainType() == WorldType.FLAT && this.rand.nextInt(4) != 1) { return false; } else { if (this.world.getDifficulty() != EnumDifficulty.PEACEFUL) { Biome biome = this.world.getBiome(blockpos); if (biome == Biomes.SWAMPLAND && this.posY > 50.0D && this.posY < 70.0D && this.rand.nextFloat() < 0.5F && this.rand.nextFloat() < this.world.getCurrentMoonPhaseFactor() && this.world.getLightFromNeighbors(new BlockPos(this)) <= this.rand.nextInt(8)) { return super.getCanSpawnHere(); } if (this.rand.nextInt(10) == 0 && chunk.getRandomWithSeed(987234911L).nextInt(10) == 0 && this.posY < 40.0D) { return super.getCanSpawnHere(); } } return false; } }
protected void playMoodSoundAndCheckLight(int p_147467_1_, int p_147467_2_, Chunk chunkIn) { this.theProfiler.endStartSection("moodSound"); if (this.ambientTickCountdown == 0 && !this.isRemote) { this.updateLCG = this.updateLCG * 3 + 1013904223; int i = this.updateLCG >> 2; int j = i & 15; int k = i >> 8 & 15; int l = i >> 16 & 255; BlockPos blockpos = new BlockPos(j, l, k); Block block = chunkIn.getBlock(blockpos); j = j + p_147467_1_; k = k + p_147467_2_; if (block.getMaterial() == Material.air && this.getLight(blockpos) <= this.rand.nextInt(8) && this.getLightFor(EnumSkyBlock.SKY, blockpos) <= 0) { EntityPlayer entityplayer = this.getClosestPlayer((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, 8.0D); if (entityplayer != null && entityplayer.getDistanceSq((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D) > 4.0D) { this.playSoundEffect((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, "ambient.cave.cave", 0.7F, 0.8F + this.rand.nextFloat() * 0.2F); this.ambientTickCountdown = this.rand.nextInt(12000) + 6000; } } } this.theProfiler.endStartSection("checkLight"); chunkIn.enqueueRelightChecks(); }
private void saveChunkExtraData(Chunk chunkIn) { try { this.chunkLoader.saveExtraChunkData(this.worldObj, chunkIn); } catch (Exception exception) { LOGGER.error((String)"Couldn\'t save entities", (Throwable)exception); } }
public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_, int p_177460_3_, int p_177460_4_) { if (this.serverChunkGenerator != null && this.serverChunkGenerator.func_177460_a(p_177460_1_, p_177460_2_, p_177460_3_, p_177460_4_)) { Chunk chunk = this.provideChunk(p_177460_3_, p_177460_4_); chunk.setChunkModified(); return true; } else { return false; } }
@Override public boolean canDoLightning(Chunk chunk) { if (m_proxyProvider != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyProvider.canDoLightning(chunk); } else if (m_realProvider != null) { return m_realProvider.canDoLightning(chunk); } else { return super.canDoLightning(chunk); } }
public Chunk provideChunk(int x, int z) { ChunkPrimer chunkprimer = new ChunkPrimer(); for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) { int k = x * 16 + i; int l = z * 16 + j; chunkprimer.setBlockState(i, 60, j, BARRIER); IBlockState iblockstate = getBlockStateFor(k, l); if (iblockstate != null) { chunkprimer.setBlockState(i, 70, j, iblockstate); } } } Chunk chunk = new Chunk(this.world, chunkprimer, x, z); chunk.generateSkylightMap(); Biome[] abiome = this.world.getBiomeProvider().getBiomes((Biome[])null, x * 16, z * 16, 16, 16); byte[] abyte = chunk.getBiomeArray(); for (int i1 = 0; i1 < abyte.length; ++i1) { abyte[i1] = (byte)Biome.getIdForBiome(abiome[i1]); } chunk.generateSkylightMap(); return chunk; }