use of org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData in project LoliServer by Loli-Server.
the class CraftMinecart method setDisplayBlockData.
@Override
public void setDisplayBlockData(BlockData blockData) {
if (blockData != null) {
BlockState block = ((CraftBlockData) blockData).getState();
this.getHandle().setDisplayBlockState(block);
} else {
// Set block to air (default) and set the flag to not have a display block.
this.getHandle().setDisplayBlockState(Blocks.AIR.defaultBlockState());
this.getHandle().setCustomDisplay(false);
}
}
use of org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelperImpl method setFallingBlockType.
@Override
public void setFallingBlockType(FallingBlock entity, BlockData block) {
BlockState state = ((CraftBlockData) block).getState();
FallingBlockEntity nmsEntity = ((CraftFallingBlock) entity).getHandle();
try {
FALLINGBLOCK_TYPE_SETTER.invoke(nmsEntity, state);
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
use of org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData in project VanillaSource by TheHollowPlanetMC.
the class PacketManager method createBlockChangePacket.
@Nullable
public static Object createBlockChangePacket(ParallelWorld parallelWorld, int blockX, int blockY, int blockZ) {
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange();
BlockData blockData = parallelWorld.getBlockData(blockX, blockY, blockZ);
if (blockData == null)
return null;
try {
BlockChangePacketHandler.a.set(packet, new BlockPosition(blockX, blockY, blockZ));
packet.block = ((CraftBlockData) blockData).getState();
return packet;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData in project VanillaSource by TheHollowPlanetMC.
the class PacketManager method createMultiBlockChangePacket.
public static Set<Object> createMultiBlockChangePacket(ParallelWorld parallelWorld, Set<BlockPosition3i> blocks) {
Map<ChunkPosition, Set<BlockPosition3i>> chunkMap = new HashMap<>();
for (BlockPosition3i bp : blocks) {
chunkMap.computeIfAbsent(new ChunkPosition(bp.getX(), bp.getZ()), cp -> new HashSet<>()).add(bp);
}
Set<Object> packets = new HashSet<>();
for (Map.Entry<ChunkPosition, Set<BlockPosition3i>> entry : chunkMap.entrySet()) {
ChunkPosition chunkPosition = entry.getKey();
Set<BlockPosition3i> bps = entry.getValue();
ParallelChunk parallelChunk = parallelWorld.getChunk(chunkPosition.x, chunkPosition.z);
if (parallelChunk == null)
continue;
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange();
List<PacketPlayOutMultiBlockChange.MultiBlockChangeInfo> infoList = new ArrayList<>();
for (BlockPosition3i bp : bps) {
BlockData blockData = parallelChunk.getBlockData(bp.getX(), bp.getY(), bp.getZ());
if (blockData == null)
continue;
short loc = (short) ((bp.getX() & 0xF) << 12 | (bp.getZ() & 0xF) << 8 | bp.getY());
infoList.add(packet.new MultiBlockChangeInfo(loc, ((CraftBlockData) blockData).getState()));
}
PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] array = infoList.toArray(new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[infoList.size()]);
try {
MultiBlockChangePacketHandler.a.set(packet, new ChunkCoordIntPair(chunkPosition.x, chunkPosition.z));
MultiBlockChangePacketHandler.b.set(packet, array);
packets.add(packet);
} catch (Exception e) {
e.printStackTrace();
}
}
return packets;
}
use of org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData in project VanillaSource by TheHollowPlanetMC.
the class BlockChangePacketHandler method rewrite.
@Override
public Object rewrite(Object packet, EnginePlayer EnginePlayer, boolean cacheSetting) {
ParallelUniverse universe = EnginePlayer.getUniverse();
if (universe == null)
return packet;
String worldName = EnginePlayer.getBukkitPlayer().getWorld().getName();
ParallelWorld parallelWorld = universe.getWorld(worldName);
try {
PacketPlayOutBlockChange blockChange = (PacketPlayOutBlockChange) packet;
BlockPosition bp = (BlockPosition) a.get(blockChange);
BlockData blockData = parallelWorld.getBlockData(bp.getX(), bp.getY(), bp.getZ());
if (blockData == null)
return packet;
PacketPlayOutBlockChange newPacket = new PacketPlayOutBlockChange();
a.set(newPacket, bp);
newPacket.block = ((CraftBlockData) blockData).getState();
return newPacket;
} catch (Exception e) {
e.printStackTrace();
}
return packet;
}
Aggregations