use of net.minecraft.server.v1_9_R1.ChunkSection in project askyblock by tastybento.
the class NMSHandler method setBlockSuperFast.
@SuppressWarnings("deprecation")
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
net.minecraft.server.v1_7_R3.World w = ((CraftWorld) b.getWorld()).getHandle();
net.minecraft.server.v1_7_R3.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
try {
Field f = chunk.getClass().getDeclaredField("sections");
f.setAccessible(true);
ChunkSection[] sections = (ChunkSection[]) f.get(chunk);
ChunkSection chunksection = sections[b.getY() >> 4];
if (chunksection == null) {
chunksection = sections[b.getY() >> 4] = new ChunkSection(b.getY() >> 4 << 4, !chunk.world.worldProvider.f);
}
net.minecraft.server.v1_7_R3.Block mb = net.minecraft.server.v1_7_R3.Block.e(blockId);
chunksection.setTypeId(b.getX() & 15, b.getY() & 15, b.getZ() & 15, mb);
chunksection.setData(b.getX() & 15, b.getY() & 15, b.getZ() & 15, data);
if (applyPhysics) {
w.update(b.getX(), b.getY(), b.getZ(), mb);
}
} catch (Exception e) {
// Bukkit.getLogger().info("Error");
b.setTypeIdAndData(blockId, data, applyPhysics);
}
}
use of net.minecraft.server.v1_9_R1.ChunkSection in project TheAPI by TheDevTec.
the class v1_10_R1 method setBlock.
@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
net.minecraft.server.v1_10_R1.Chunk c = (net.minecraft.server.v1_10_R1.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null) {
c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
}
BlockPosition pos = new BlockPosition(x, y, z);
// REMOVE TILE ENTITY
c.tileEntities.remove(pos);
sc.getBlocks().setBlock(x & 15, y & 15, z & 15, (IBlockData) IblockData);
// ADD TILE ENTITY
if (IblockData instanceof ITileEntity) {
TileEntity ent = ((ITileEntity) IblockData).a(c.world, 0);
c.tileEntities.put(pos, ent);
Object packet = ent.getUpdatePacket();
Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
}
}
use of net.minecraft.server.v1_9_R1.ChunkSection in project TheAPI by TheDevTec.
the class v1_13_R1 method setBlock.
@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
net.minecraft.server.v1_13_R1.Chunk c = (net.minecraft.server.v1_13_R1.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null) {
c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
}
BlockPosition pos = new BlockPosition(x, y, z);
// REMOVE TILE ENTITY
c.tileEntities.remove(pos);
try {
DataBits bits = (DataBits) dataBits.get(sc.getBlocks());
@SuppressWarnings("unchecked") DataPalette<IBlockData> pallete = (DataPalette<IBlockData>) dataPallete.get(sc.getBlocks());
bits.a(b(x & 15, y & 15, z & 15), pallete.a((IBlockData) IblockData));
} catch (Exception er) {
}
// ADD TILE ENTITY
if (IblockData instanceof ITileEntity) {
TileEntity ent = ((ITileEntity) IblockData).a(c);
c.tileEntities.put(pos, ent);
Object packet = ent.getUpdatePacket();
Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
}
}
use of net.minecraft.server.v1_9_R1.ChunkSection in project TheAPI by TheDevTec.
the class v1_13_R2 method setBlock.
@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
net.minecraft.server.v1_13_R2.Chunk c = (net.minecraft.server.v1_13_R2.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null) {
c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
}
BlockPosition pos = new BlockPosition(x, y, z);
// REMOVE TILE ENTITY
c.tileEntities.remove(pos);
try {
DataBits bits = (DataBits) dataBits.get(sc.getBlocks());
@SuppressWarnings("unchecked") DataPalette<IBlockData> pallete = (DataPalette<IBlockData>) dataPallete.get(sc.getBlocks());
bits.a(b(x & 15, y & 15, z & 15), pallete.a((IBlockData) IblockData));
} catch (Exception er) {
}
// ADD TILE ENTITY
if (IblockData instanceof ITileEntity) {
TileEntity ent = ((ITileEntity) IblockData).a(c);
c.tileEntities.put(pos, ent);
Object packet = ent.getUpdatePacket();
Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
}
}
use of net.minecraft.server.v1_9_R1.ChunkSection in project TheAPI by TheDevTec.
the class v1_11_R1 method getBlock.
@Override
public Object getBlock(Object chunk, int x, int y, int z) {
net.minecraft.server.v1_11_R1.Chunk c = (net.minecraft.server.v1_11_R1.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null)
return Blocks.AIR.getBlockData();
return sc.getBlocks().a(x & 15, y & 15, z & 15);
}
Aggregations