use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project MechanicsMain by WeaponMechanics.
the class Block_1_11_R1 method getMultiBlockMaskPacket.
private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
net.minecraft.server.v1_11_R1.Chunk chunk = ((CraftChunk) blocks.get(0).getChunk()).getHandle();
// Setup default information
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(0, new short[0], chunk);
PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] changes = new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[blocks.size()];
for (int i = 0; i < blocks.size(); i++) {
Block block = blocks.get(i);
// Where the block is relative to the chunk it is in
int x = block.getX() & 0xF;
int y = block.getY();
int z = block.getZ() & 0xF;
// Setting the (x, y, z) location into VarInt format
short location = (short) (x << 12 | y | z << 8);
// If mask is null, then undo the mask. Otherwise set the mask
if (mask == null) {
changes[i] = packet.new MultiBlockChangeInfo(location, chunk);
} else {
changes[i] = packet.new MultiBlockChangeInfo(location, mask);
}
}
assert multiBlockChangeB != null;
ReflectionUtil.setField(multiBlockChangeB, packet, changes);
return packet;
}
use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project MechanicsMain by WeaponMechanics.
the class Block_1_12_R1 method getMultiBlockMaskPacket.
private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
net.minecraft.server.v1_12_R1.Chunk chunk = ((CraftChunk) blocks.get(0).getChunk()).getHandle();
// Setup default information
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(0, new short[0], chunk);
PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] changes = new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[blocks.size()];
for (int i = 0; i < blocks.size(); i++) {
Block block = blocks.get(i);
// Where the block is relative to the chunk it is in
int x = block.getX() & 0xF;
int y = block.getY();
int z = block.getZ() & 0xF;
// Setting the (x, y, z) location into VarInt format
short location = (short) (x << 12 | y | z << 8);
// If mask is null, then undo the mask. Otherwise set the mask
if (mask == null) {
changes[i] = packet.new MultiBlockChangeInfo(location, chunk);
} else {
changes[i] = packet.new MultiBlockChangeInfo(location, mask);
}
}
ReflectionUtil.setField(multiBlockChangeB, packet, changes);
return packet;
}
use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project MechanicsMain by WeaponMechanics.
the class Block_1_15_R1 method getMultiBlockMaskPacket.
private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
Chunk chunk = ((CraftChunk) blocks.get(0).getChunk()).getHandle();
// Setup default information
PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(0, new short[0], chunk);
PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] changes = new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[blocks.size()];
for (int i = 0; i < blocks.size(); i++) {
Block block = blocks.get(i);
// Where the block is relative to the chunk it is in
int x = block.getX() & 0xF;
int y = block.getY();
int z = block.getZ() & 0xF;
// Setting the (x, y, z) location into VarInt format
short location = (short) (x << 12 | y | z << 8);
// If mask is null, then undo the mask. Otherwise set the mask
if (mask == null) {
changes[i] = packet.new MultiBlockChangeInfo(location, chunk);
} else {
changes[i] = packet.new MultiBlockChangeInfo(location, mask);
}
}
ReflectionUtil.setField(multiBlockChangeB, packet, changes);
return packet;
}
use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project Denizen-For-Bukkit by DenizenScript.
the class ChunkHelperImpl method getHeightMap.
@Override
public int[] getHeightMap(Chunk chunk) {
Heightmap map = ((CraftChunk) chunk).getHandle().heightmaps.get(Heightmap.Types.MOTION_BLOCKING);
int[] outputMap = new int[256];
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
outputMap[x * 16 + y] = map.getFirstAvailable(x, y);
}
}
return outputMap;
}
use of org.bukkit.craftbukkit.v1_7_R4.CraftChunk in project Denizen-For-Bukkit by DenizenScript.
the class BlockHelperImpl method doRandomTick.
@Override
public void doRandomTick(Location location) {
BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
LevelChunk nmsChunk = ((CraftChunk) location.getChunk()).getHandle();
net.minecraft.world.level.block.state.BlockState nmsBlock = nmsChunk.getBlockState(pos);
ServerLevel nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
if (nmsBlock.isRandomlyTicking()) {
nmsBlock.randomTick(nmsWorld, pos, nmsWorld.random);
}
try {
// FluidState fluid = nmsBlock.getFluidState();
// if (fluid.isRandomlyTicking()) {
// fluid.animateTick(nmsWorld, pos, nmsWorld.random);
// }
Object fluid = BLOCKSTATEBASE_GETFLUIDSTATE.invoke(nmsBlock);
if ((boolean) FLUIDSTATE_ISRANDOMLYTICKING.invoke(fluid)) {
FLUIDSTATE_ANIMATETICK.invoke(fluid, nmsWorld, pos, nmsWorld.random);
}
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
Aggregations