net.minecraft.world.chunk.ChunkSection Java Examples
The following examples show how to use
net.minecraft.world.chunk.ChunkSection.
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: MixinClientChunkManager.java From multiconnect with MIT License | 5 votes |
@Inject(method = "loadChunkFromPacket", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/WorldChunk;getSectionArray()[Lnet/minecraft/world/chunk/ChunkSection;")) private void recalculateHeightmaps(int x, int z, BiomeArray biomeArray, PacketByteBuf buf, CompoundTag tag, int verticalStripMask, boolean bl, CallbackInfoReturnable<WorldChunk> ci) { if (ConnectionInfo.protocolVersion <= Protocols.V1_13_2) { WorldChunk chunk = this.chunk.get(); for (ChunkSection section : chunk.getSectionArray()) { if (section != null) { section.calculateCounts(); } } Heightmap.populateHeightmaps(chunk, CLIENT_HEIGHTMAPS); } this.chunk.set(null); }
Example #2
Source File: ChunkSerializerMixin.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
@Redirect(method = "deserialize", at = @At(value = "NEW", target = "net/minecraft/world/chunk/WorldChunk")) private static WorldChunk newWorldChunk( World newWorld, ChunkPos newChunkPos, Biome[] newBiomes, UpgradeData newUpgradeData, TickScheduler<Block> newTickScheduler, TickScheduler<Fluid> newTickScheduler2, long newL, @Nullable ChunkSection[] newChunkSections, @Nullable Consumer<WorldChunk> newConsumer, ServerWorld serverWorld, StructureManager structureManager, PointOfInterestStorage pointOfInterestStorage, ChunkPos chunkPos, CompoundTag compoundTag) { WorldChunk chunk = new WorldChunk(newWorld, newChunkPos, newBiomes, newUpgradeData, newTickScheduler, newTickScheduler2, newL, newChunkSections, newConsumer); CompoundTag level = compoundTag.getCompound("Level"); if (level.contains("ForgeCaps")) { ((CapabilityProviderHolder) chunk).deserializeCaps(level.getCompound("ForgeCaps")); } return chunk; }
Example #3
Source File: RenderEnqueue.java From XRay-Mod with GNU General Public License v3.0 | 4 votes |
/** * Use Controller.requestBlockFinder() to trigger a scan. */ private void blockFinder() { HashMap<UUID, BlockData> blocks = Controller.getBlockStore().getStore(); if ( blocks.isEmpty() ) { if( !Render.syncRenderList.isEmpty() ) Render.syncRenderList.clear(); return; // no need to scan the region if there's nothing to find } final World world = XRay.mc.world; final PlayerEntity player = XRay.mc.player; if( world == null || player == null ) return; final List<RenderBlockProps> renderQueue = new ArrayList<>(); int lowBoundX, highBoundX, lowBoundY, highBoundY, lowBoundZ, highBoundZ; // Used for cleaning up the searching process BlockState currentState; FluidState currentFluid; ResourceLocation block; Pair<BlockData, UUID> dataWithUUID; // Loop on chunks (x, z) for ( int chunkX = box.minChunkX; chunkX <= box.maxChunkX; chunkX++ ) { // Pre-compute the extend bounds on X int x = chunkX << 4; // lowest x coord of the chunk in block/world coordinates lowBoundX = (x < box.minX) ? box.minX - x : 0; // lower bound for x within the extend highBoundX = (x + 15 > box.maxX) ? box.maxX - x : 15;// and higher bound. Basically, we clamp it to fit the radius. for ( int chunkZ = box.minChunkZ; chunkZ <= box.maxChunkZ; chunkZ++ ) { // Time to getStore the chunk (16x256x16) and split it into 16 vertical extends (16x16x16) if (!world.chunkExists(chunkX, chunkZ)) { continue; // We won't find anything interesting in unloaded chunks } Chunk chunk = world.getChunk( chunkX, chunkZ ); ChunkSection[] extendsList = chunk.getSections(); // Pre-compute the extend bounds on Z int z = chunkZ << 4; lowBoundZ = (z < box.minZ) ? box.minZ - z : 0; highBoundZ = (z + 15 > box.maxZ) ? box.maxZ - z : 15; // Loop on the extends around the player's layer (6 down, 2 up) for ( int curExtend = box.minChunkY; curExtend <= box.maxChunkY; curExtend++ ) { ChunkSection ebs = extendsList[curExtend]; if (ebs == null) // happens quite often! continue; // Pre-compute the extend bounds on Y int y = curExtend << 4; lowBoundY = (y < box.minY) ? box.minY - y : 0; highBoundY = (y + 15 > box.maxY) ? box.maxY - y : 15; // Now that we have an extend, let's check all its blocks for ( int i = lowBoundX; i <= highBoundX; i++ ) { for ( int j = lowBoundY; j <= highBoundY; j++ ) { for ( int k = lowBoundZ; k <= highBoundZ; k++ ) { currentState = ebs.getBlockState(i, j, k); currentFluid = currentState.getFluidState(); if( (currentFluid.getFluid() == Fluids.LAVA || currentFluid.getFluid() == Fluids.FLOWING_LAVA) && Controller.isLavaActive() ) { renderQueue.add(new RenderBlockProps(x + i, y + j, z + k, 0xff0000)); continue; } // Reject blacklisted blocks if( Controller.blackList.contains(currentState.getBlock()) ) continue; block = currentState.getBlock().getRegistryName(); if( block == null ) continue; dataWithUUID = Controller.getBlockStore().getStoreByReference(block.toString()); if( dataWithUUID == null ) continue; if( dataWithUUID.getKey() == null || !dataWithUUID.getKey().isDrawing() ) // fail safe continue; // Push the block to the render queue renderQueue.add(new RenderBlockProps(x + i, y + j, z + k, dataWithUUID.getKey().getColor())); } } } } } } final BlockPos playerPos = player.func_233580_cy_(); // @mcp: func_233580_cy_ = getPosition (blockPos) renderQueue.sort((t, t1) -> Double.compare(t1.distanceSq(playerPos), t.distanceSq(playerPos))); Render.syncRenderList.clear(); Render.syncRenderList.addAll( renderQueue ); // Add all our found blocks to the Render.syncRenderList list. To be use by Render when drawing. }