use of net.minecraft.server.v1_13_R1.IBlockData in project TheAPI by TheDevTec.
the class v1_13_R1 method packetBlockChange.
@Override
public Object packetBlockChange(World world, int x, int y, int z) {
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange();
packet.block = (IBlockData) getBlock(getChunk(world, x >> 4, z >> 4), x, y, z);
try {
pos.set(packet, new BlockPosition(x, y, z));
} catch (Exception e) {
}
return packet;
}
use of net.minecraft.server.v1_13_R1.IBlockData 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_13_R1.IBlockData 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_13_R1.IBlockData in project PaperDev by Kamillaova.
the class CraftBlockState method update.
public boolean update(boolean force, boolean applyPhysics) {
if (!isPlaced()) {
return true;
}
Block block = getBlock();
if (block.getType() != getType()) {
if (!force) {
return false;
}
}
BlockPosition pos = new BlockPosition(x, y, z);
IBlockData newBlock = CraftMagicNumbers.getBlock(getType()).fromLegacyData(getRawData());
block.setTypeIdAndData(getTypeId(), getRawData(), applyPhysics);
world.getHandle().notify(pos, CraftMagicNumbers.getBlock(block).fromLegacyData(block.getData()), newBlock, 3);
// Update levers etc
if (applyPhysics && getData() instanceof Attachable) {
world.getHandle().applyPhysics(pos.shift(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock(), false);
}
return true;
}
use of net.minecraft.server.v1_13_R1.IBlockData in project acidisland by tastybento.
the class NMSHandler method setBlockSuperFast.
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
net.minecraft.server.v1_9_R1.World w = ((CraftWorld) b.getWorld()).getHandle();
net.minecraft.server.v1_9_R1.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
BlockPosition bp = new BlockPosition(b.getX(), b.getY(), b.getZ());
int combined = blockId + (data << 12);
IBlockData ibd = net.minecraft.server.v1_9_R1.Block.getByCombinedId(combined);
if (applyPhysics) {
w.setTypeAndData(bp, ibd, 3);
} else {
w.setTypeAndData(bp, ibd, 2);
}
chunk.a(bp, ibd);
}
Aggregations