use of org.bukkit.craftbukkit.v1_16_R1.CraftChunk in project InteractionVisualizer by LOOHP.
the class V1_16 method getTileEntities.
@Override
public NMSTileEntitySet<?, ?> getTileEntities(ChunkPosition chunk, boolean load) {
if (!chunk.isLoaded() && !load) {
return null;
}
World world = chunk.getWorld();
return new NMSTileEntitySet<net.minecraft.server.v1_16_R1.BlockPosition, net.minecraft.server.v1_16_R1.TileEntity>(((CraftChunk) chunk.getChunk()).getHandle().tileEntities, entry -> {
net.minecraft.server.v1_16_R1.BlockPosition pos = entry.getKey();
Material type = CraftMagicNumbers.getMaterial(entry.getValue().getBlock().getBlock());
TileEntityType tileEntityType = TileEntity.getTileEntityType(type);
if (tileEntityType != null) {
return new TileEntity(world, pos.getX(), pos.getY(), pos.getZ(), tileEntityType);
} else {
return null;
}
});
}
use of org.bukkit.craftbukkit.v1_16_R1.CraftChunk in project InteractionVisualizer by LOOHP.
the class V1_16_2 method getTileEntities.
@Override
public NMSTileEntitySet<?, ?> getTileEntities(ChunkPosition chunk, boolean load) {
if (!chunk.isLoaded() && !load) {
return null;
}
World world = chunk.getWorld();
return new NMSTileEntitySet<net.minecraft.server.v1_16_R2.BlockPosition, net.minecraft.server.v1_16_R2.TileEntity>(((CraftChunk) chunk.getChunk()).getHandle().tileEntities, entry -> {
net.minecraft.server.v1_16_R2.BlockPosition pos = entry.getKey();
Material type = CraftMagicNumbers.getMaterial(entry.getValue().getBlock().getBlock());
TileEntityType tileEntityType = TileEntity.getTileEntityType(type);
if (tileEntityType != null) {
return new TileEntity(world, pos.getX(), pos.getY(), pos.getZ(), tileEntityType);
} else {
return null;
}
});
}
use of org.bukkit.craftbukkit.v1_16_R1.CraftChunk in project InteractionVisualizer by LOOHP.
the class V1_18 method getTileEntities.
@Override
public NMSTileEntitySet<?, ?> getTileEntities(ChunkPosition chunk, boolean load) {
if (!chunk.isLoaded() && !load) {
return null;
}
World world = chunk.getWorld();
return new NMSTileEntitySet<net.minecraft.core.BlockPosition, net.minecraft.world.level.block.entity.TileEntity>(((CraftChunk) chunk.getChunk()).getHandle().E(), entry -> {
net.minecraft.core.BlockPosition pos = entry.getKey();
Material type = CraftMagicNumbers.getMaterial(entry.getValue().q().b());
TileEntityType tileEntityType = TileEntity.getTileEntityType(type);
if (tileEntityType != null) {
return new TileEntity(world, pos.u(), pos.v(), pos.w(), tileEntityType);
} else {
return null;
}
});
}
use of org.bukkit.craftbukkit.v1_16_R1.CraftChunk in project InteractionVisualizer by LOOHP.
the class V1_18_2 method getTileEntities.
@Override
public NMSTileEntitySet<?, ?> getTileEntities(ChunkPosition chunk, boolean load) {
if (!chunk.isLoaded() && !load) {
return null;
}
World world = chunk.getWorld();
return new NMSTileEntitySet<net.minecraft.core.BlockPosition, net.minecraft.world.level.block.entity.TileEntity>(((CraftChunk) chunk.getChunk()).getHandle().E(), entry -> {
net.minecraft.core.BlockPosition pos = entry.getKey();
Material type = CraftMagicNumbers.getMaterial(entry.getValue().q().b());
TileEntityType tileEntityType = TileEntity.getTileEntityType(type);
if (tileEntityType != null) {
return new TileEntity(world, pos.u(), pos.v(), pos.w(), tileEntityType);
} else {
return null;
}
});
}
use of org.bukkit.craftbukkit.v1_16_R1.CraftChunk in project THP-Engine by TheHollowPlanetMC.
the class PacketManager method sendClearChunkMultiBlockChangePacketAtPrimaryThread.
public static void sendClearChunkMultiBlockChangePacketAtPrimaryThread(Player player, ParallelChunk parallelChunk, NMSHandler nmsHandler) {
if (!Bukkit.isPrimaryThread())
throw new IllegalStateException("DO NOT CALL FROM ASYNC THREAD!");
org.bukkit.World world = Bukkit.getWorld(parallelChunk.getWorld().getName());
if (world == null)
return;
if (player.getWorld() != world)
return;
org.bukkit.Chunk chunk = world.getChunkAt(parallelChunk.getChunkX(), parallelChunk.getChunkZ());
net.minecraft.server.v1_16_R3.Chunk nmsChunk = ((CraftChunk) chunk).getHandle();
for (int sectionIndex = 0; sectionIndex < 16; sectionIndex++) {
SectionTypeArray sectionTypeArray = parallelChunk.getSectionTypeArray(sectionIndex);
if (sectionTypeArray == null)
continue;
ChunkSection chunkSection = nmsChunk.getSections()[sectionIndex];
if (chunkSection == null)
continue;
List<Short> coordList = new ArrayList<>();
List<IBlockData> dataList = new ArrayList<>();
boolean notEmpty = sectionTypeArray.threadsafeIteration((x, y, z, iBlockData) -> {
coordList.add((short) (x << 8 | z << 4 | y));
IBlockData chunkData = chunkSection.getType(x, y, z);
if (chunkData == null)
chunkData = ((CraftBlockData) org.bukkit.Material.AIR.createBlockData()).getState();
dataList.add(chunkData);
});
if (!notEmpty)
continue;
short[] coordArray = new short[coordList.size()];
IBlockData[] dataArray = new IBlockData[dataList.size()];
for (int i = 0; i < coordList.size(); i++) {
coordArray[i] = coordList.get(i);
dataArray[i] = dataList.get(i);
}
try {
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange();
MultiBlockChangePacketHandler.a.set(packet, SectionPosition.a(parallelChunk.getChunkX(), sectionIndex, parallelChunk.getChunkZ()));
MultiBlockChangePacketHandler.b.set(packet, coordArray);
MultiBlockChangePacketHandler.c.set(packet, dataArray);
MultiBlockChangePacketHandler.d.setBoolean(packet, true);
nmsHandler.sendPacket(player, packet);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations