use of org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock in project Denizen by DenizenScript.
the class BlockHelperImpl method ringBell.
@Override
public void ringBell(Bell block) {
org.bukkit.block.data.type.Bell bellData = (org.bukkit.block.data.type.Bell) block.getBlockData();
Direction face = Direction.byName(bellData.getFacing().name());
Direction dir = Direction.NORTH;
switch(bellData.getAttachment()) {
case DOUBLE_WALL:
case SINGLE_WALL:
switch(face) {
case NORTH:
case SOUTH:
dir = Direction.EAST;
break;
}
break;
case FLOOR:
dir = face;
break;
}
CraftBlock craftBlock = (CraftBlock) block.getBlock();
((BellBlock) Blocks.BELL).attemptToRing(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition(), dir);
}
use of org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock in project MechanicsMain by WeaponMechanics.
the class Block_1_17_R1 method getMultiBlockMaskPacket.
private ClientboundSectionBlocksUpdatePacket getMultiBlockMaskPacket(List<Block> blocks, @Nullable BlockState mask) {
BlockPos position = ((CraftBlock) blocks.get(0)).getPosition();
// Setup default information
short[] locations = new short[blocks.size()];
BlockState[] data = new BlockState[blocks.size()];
for (int i = 0; i < locations.length; i++) {
Block block = blocks.get(i);
int x = block.getX() & 0xF;
int y = block.getY() & 0xF;
int z = block.getZ() & 0xF;
short shortLocation = (short) (x << 8 | z << 4 | y);
locations[i] = shortLocation;
data[i] = mask;
}
ClientboundSectionBlocksUpdatePacket packet = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(position), new ShortArraySet(0), null, false);
ReflectionUtil.setField(multiBlockChangeB, packet, locations);
ReflectionUtil.setField(multiBlockChangeC, packet, data);
return packet;
}
use of org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock in project MechanicsMain by WeaponMechanics.
the class Block_1_18_R1 method getMultiBlockMaskPacket.
private ClientboundSectionBlocksUpdatePacket getMultiBlockMaskPacket(List<Block> blocks, @Nullable BlockState mask) {
BlockPos position = ((CraftBlock) blocks.get(0)).getPosition();
// Setup default information
short[] locations = new short[blocks.size()];
BlockState[] data = new BlockState[blocks.size()];
for (int i = 0; i < locations.length; i++) {
Block block = blocks.get(i);
int x = block.getX() & 0xF;
int y = block.getY() & 0xF;
int z = block.getZ() & 0xF;
short shortLocation = (short) (x << 8 | z << 4 | y);
locations[i] = shortLocation;
data[i] = mask;
}
ClientboundSectionBlocksUpdatePacket packet = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(position), new ShortArraySet(0), null, false);
ReflectionUtil.setField(multiBlockChangeB, packet, locations);
ReflectionUtil.setField(multiBlockChangeC, packet, data);
return packet;
}
use of org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock in project MechanicsMain by WeaponMechanics.
the class Block_1_18_R2 method getMultiBlockMaskPacket.
private ClientboundSectionBlocksUpdatePacket getMultiBlockMaskPacket(List<Block> blocks, @Nullable BlockState mask) {
BlockPos position = ((CraftBlock) blocks.get(0)).getPosition();
// Setup default information
short[] locations = new short[blocks.size()];
BlockState[] data = new BlockState[blocks.size()];
for (int i = 0; i < locations.length; i++) {
Block block = blocks.get(i);
int x = block.getX() & 0xF;
int y = block.getY() & 0xF;
int z = block.getZ() & 0xF;
short shortLocation = (short) (x << 8 | z << 4 | y);
locations[i] = shortLocation;
data[i] = mask;
}
ClientboundSectionBlocksUpdatePacket packet = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(position), new ShortArraySet(0), null, false);
ReflectionUtil.setField(multiBlockChangeB, packet, locations);
ReflectionUtil.setField(multiBlockChangeC, packet, data);
return packet;
}
use of org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock in project MechanicsMain by WeaponMechanics.
the class v1_13_R2 method getHitBox.
@Override
public HitBox getHitBox(Block block) {
if (block.isEmpty() || block.isLiquid() || block.isPassable())
return null;
BoundingBox boundingBox = block.getBoundingBox();
HitBox hitBox = new HitBox(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
hitBox.setBlockHitBox(block);
if (WeaponMechanics.getBasicConfigurations().getBool("Check_Accurate_Hitboxes", true)) {
CraftBlock craftBlock = (CraftBlock) block;
List<AxisAlignedBB> voxelShape = craftBlock.getNMS().getCollisionShape(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition()).d();
if (voxelShape.size() > 1) {
int x = block.getX();
int y = block.getY();
int z = block.getZ();
for (AxisAlignedBB boxPart : voxelShape) {
hitBox.addVoxelShapePart(new HitBox(x + boxPart.minX, y + boxPart.minY, z + boxPart.minZ, x + boxPart.maxX, y + boxPart.maxY, z + boxPart.maxZ));
}
}
}
return hitBox;
}
Aggregations