use of net.minecraft.world.chunk.ChunkSection in project Magma-1.16.x by magmafoundation.
the class CraftChunk method contains.
@Override
public boolean contains(BlockData block) {
Preconditions.checkArgument(block != null, "Block cannot be null");
Predicate<net.minecraft.block.BlockState> nms = Predicates.equalTo(((CraftBlockData) block).getState());
for (ChunkSection section : getHandle().getSections()) {
if (section != null && section.getStates().maybeHas(nms)) {
return true;
}
}
return false;
}
use of net.minecraft.world.chunk.ChunkSection in project LoliServer by Loli-Server.
the class CraftChunkData method setBlock.
private void setBlock(int x, int y, int z, net.minecraft.block.BlockState type) {
if (x != (x & 0xf) || y < 0 || y >= maxHeight || z != (z & 0xf)) {
return;
}
ChunkSection section = getChunkSection(y, true);
section.setBlockState(x, y & 0xf, z, type);
if (type.getBlock().hasTileEntity(type.getBlock().defaultBlockState())) {
if (tiles == null) {
tiles = new HashSet<>();
}
tiles.add(new BlockPos(x, y, z));
}
}
use of net.minecraft.world.chunk.ChunkSection in project TheAPI by TheDevTec.
the class v1_16_R3_Mohist method setBlock.
@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
net.minecraft.world.chunk.Chunk c = (net.minecraft.world.chunk.Chunk) chunk;
ChunkSection sc = c.func_76587_i()[y >> 4];
if (sc == null) {
c.func_76587_i()[y >> 4] = sc = new ChunkSection(y >> 4 << 4);
}
BlockPos pos = new BlockPos(x, y, z);
// REMOVE TILE ENTITY
c.func_177434_r().remove(pos);
sc.func_186049_g().func_222639_b(x & 15, y & 15, z & 15, (net.minecraft.block.BlockState) IblockData);
// ADD TILE ENTITY
if (((net.minecraft.block.BlockState) IblockData).func_177230_c() instanceof ITileEntityProvider) {
TileEntity ent = ((ITileEntityProvider) ((net.minecraft.block.BlockState) IblockData).func_177230_c()).func_196283_a_(c.func_177412_p());
c.func_177434_r().put(pos, ent);
Object packet = ent.func_189518_D_();
Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
}
}
use of net.minecraft.world.chunk.ChunkSection in project TheAPI by TheDevTec.
the class v1_16_R3_Mohist method getBlock.
@Override
public Object getBlock(Object chunk, int x, int y, int z) {
net.minecraft.world.chunk.Chunk c = (net.minecraft.world.chunk.Chunk) chunk;
ChunkSection sc = c.func_76587_i()[y >> 4];
if (sc == null)
return Blocks.field_150350_a.func_176223_P();
return sc.func_186049_g().func_186016_a(x & 15, y & 15, z & 15);
}
use of net.minecraft.world.chunk.ChunkSection in project lithium-fabric by CaffeineMC.
the class WorldChunkMixin method getBlockState.
/**
* @reason Reduce method size to help the JVM inline
* @author JellySquid
*/
@Overwrite
public BlockState getBlockState(BlockPos pos) {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
int chunkY = this.getSectionIndex(y);
ChunkSection[] sectionArray = this.getSectionArray();
if (chunkY >= 0 && chunkY < sectionArray.length) {
ChunkSection section = sectionArray[chunkY];
// Chunk Sections that only contain air and cave_air are treated as empty
if (!section.isEmpty()) {
return section.getBlockState(x & 15, y & 15, z & 15);
}
}
return DEFAULT_BLOCK_STATE;
}
Aggregations