Java Code Examples for net.minecraft.world.chunk.Chunk#getPos()
The following examples show how to use
net.minecraft.world.chunk.Chunk#getPos() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoonChunkGenerator.java From Galacticraft-Rewoven with MIT License | 6 votes |
public void buildSurface(ChunkRegion region, Chunk chunk) { ChunkPos chunkPos = chunk.getPos(); int i = chunkPos.x; int j = chunkPos.z; ChunkRandom chunkRandom = new ChunkRandom(); chunkRandom.setTerrainSeed(i, j); ChunkPos chunkPos2 = chunk.getPos(); int k = chunkPos2.getStartX(); int l = chunkPos2.getStartZ(); BlockPos.Mutable mutable = new BlockPos.Mutable(); for (int m = 0; m < 16; ++m) { for (int n = 0; n < 16; ++n) { int o = k + m; int p = l + n; int q = chunk.sampleHeightmap(Heightmap.Type.WORLD_SURFACE_WG, m, n) + 1; double e = this.surfaceDepthNoise.sample((double) o * 0.0625D, (double) p * 0.0625D, 0.0625D, (double) m * 0.0625D) * 15.0D; region.getBiome(mutable.set(k + m, q, l + n)).buildSurface(chunkRandom, chunk, o, p, q, e, this.defaultBlock, this.defaultFluid, this.getSeaLevel(), region.getSeed()); } } this.buildBedrock(chunk, chunkRandom); buildCraters(chunk, region); }
Example 2
Source File: MoonChunkGenerator.java From Galacticraft-Rewoven with MIT License | 5 votes |
private void buildCraters(Chunk chunk, ChunkRegion region) { for (int cx = chunk.getPos().x - 2; cx <= chunk.getPos().x + 2; cx++) { for (int cz = chunk.getPos().z - 2; cz <= chunk.getPos().z + 2; cz++) { Biome biome = region.getBiome(new BlockPos(chunk.getPos().x << 4 + 8, 0, chunk.getPos().z << 4)); if (biome instanceof SpaceBiome && ((SpaceBiome) biome).hasCraters()) { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { if (Math.abs(this.randFromPoint(cx << 4 + x, (cz << 4 + z) * 1000)) < this.sampleDepthNoise(x << 4 + x, cz << 4 + z) / (((SpaceBiome) biome).getCraterChance())) { Random random = new Random((cx << 4) + x + ((cz << 4) + z) * 102L); int size; int i = random.nextInt(14 + 8 + 2 + 1); if (i < 1) { size = random.nextInt(30 - 26) + 26; } else if (i < 2) { size = random.nextInt(17 - 13) + 13; } else if (i < 8) { size = random.nextInt(25 - 18) + 18; } else { size = random.nextInt(12 - 8) + 8; } if (((SpaceBiome) biome).forceSmallCraters()) { size = random.nextInt(12 - 8) + 8; } else if (((SpaceBiome) biome).forceMediumCraters()) { size = random.nextInt(25 - 18) + 18; } else if (((SpaceBiome) biome).forceLargeCraters()) { size = random.nextInt(17 - 13) + 13; } this.makeCrater((cx << 4) + x, (cz << 4) + z, chunk.getPos().x << 4, chunk.getPos().z << 4, size, chunk); } } } } } } }
Example 3
Source File: TickableWorldPipeNet.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public void onChunkLoaded(Chunk chunk) { ChunkPos chunkPos = chunk.getPos(); List<T> pipeNetsInThisChunk = this.pipeNetsByChunk.get(chunkPos); for (T pipeNet : pipeNetsInThisChunk) { List<ChunkPos> loadedChunks = getOrCreateChunkListForPipeNet(pipeNet); if (loadedChunks.isEmpty()) { this.tickingPipeNets.add(pipeNet); } loadedChunks.add(chunkPos); } }
Example 4
Source File: TickableWorldPipeNet.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public void onChunkUnloaded(Chunk chunk) { ChunkPos chunkPos = chunk.getPos(); List<T> pipeNetsInThisChunk = this.pipeNetsByChunk.get(chunkPos); for (T pipeNet : pipeNetsInThisChunk) { List<ChunkPos> loadedChunks = this.loadedChunksByPipeNet.get(pipeNet); if (loadedChunks != null && loadedChunks.contains(chunkPos)) { loadedChunks.remove(chunkPos); if (loadedChunks.isEmpty()) { removeFromTicking(pipeNet); } } } }
Example 5
Source File: ClientChunkSize.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onTick(ClientTickEvent event) { if (getWorld() == null || getLocalPlayer() == null || running) { return; } switch (event.phase) { case END: { Chunk chunk = getWorld().getChunkFromBlockCoords(getLocalPlayer().getPosition()); if (chunk.isEmpty()) { return; } ChunkPos pos = chunk.getPos(); if (!pos.equals(current) || (timer.isStarted() && timer.hasTimeElapsed(1000L))) { // chunk changed, don't show diff between different chunks if (current != null && !pos.equals(current)) { size = previousSize = 0L; } current = pos; running = true; // process size calculation on another thread Executors.defaultThreadFactory() .newThread( () -> { try { final NBTTagCompound root = new NBTTagCompound(); NBTTagCompound level = new NBTTagCompound(); root.setTag("Level", level); root.setInteger("DataVersion", 1337); try { // this should be done on the main mc thread but it works 99% of the // time outside it AnvilChunkLoader loader = new AnvilChunkLoader(DUMMY, null); Methods.AnvilChunkLoader_writeChunkToNBT.invoke( loader, chunk, getWorld(), level); } catch (Throwable t) { size = -1L; previousSize = 0L; return; // couldn't save chunk } DataOutputStream compressed = new DataOutputStream( new BufferedOutputStream( new DeflaterOutputStream(new ByteArrayOutputStream(8096)))); try { CompressedStreamTools.write(root, compressed); previousSize = size; size = compressed.size(); } catch (IOException e) { size = -1L; previousSize = 0L; } } finally { timer.start(); running = false; } }) .start(); } break; } default: break; } }