use of net.minecraft.server.v1_9_R2.Block 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 net.minecraft.server.v1_9_R2.Block in project MechanicsMain by WeaponMechanics.
the class Block_1_9_R2 method getMultiBlockMaskPacket.
private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
net.minecraft.server.v1_9_R2.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 net.minecraft.server.v1_9_R2.Block in project MechanicsMain by WeaponMechanics.
the class Block_1_9_R2 method getBlastResistance.
@Override
public float getBlastResistance(Block block) {
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
net.minecraft.server.v1_9_R2.Block nmsBlock = world.c(pos).getBlock();
return (float) ReflectionUtil.invokeField(durabilityField, nmsBlock) / 5.0f;
}
use of net.minecraft.server.v1_9_R2.Block in project MechanicsMain by WeaponMechanics.
the class Block_1_9_R2 method getMultiBlockMaskPacket.
@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable BlockState mask) {
if (blocks == null || blocks.isEmpty()) {
throw new IllegalArgumentException("No blocks are being changed!");
}
Map<Chunk, List<Block>> sortedBlocks = new HashMap<>();
for (Block block : blocks) {
List<Block> list = sortedBlocks.computeIfAbsent(block.getChunk(), chunk -> new ArrayList<>());
list.add(block);
}
List<Object> packets = new ArrayList<>(sortedBlocks.size());
IBlockData blockData = null;
if (mask != null) {
WorldServer world = ((CraftWorld) mask.getWorld()).getHandle();
BlockPosition pos = new BlockPosition(mask.getX(), mask.getY(), mask.getZ());
blockData = world.c(pos).getBlock().getBlockData();
}
for (List<Block> entry : sortedBlocks.values()) {
packets.add(getMultiBlockMaskPacket(entry, blockData));
}
return packets;
}
use of net.minecraft.server.v1_9_R2.Block in project MechanicsMain by WeaponMechanics.
the class FakeEntity_1_9_R2 method show.
@Override
public void show(@NotNull Player player) {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
if (connections.contains(connection))
throw new IllegalArgumentException();
connection.sendPacket(type.isAlive() ? new PacketPlayOutSpawnEntityLiving((EntityLiving) entity) : new PacketPlayOutSpawnEntity(entity, type == EntityType.FALLING_BLOCK ? Block.getCombinedId(block) : 0));
connection.sendPacket(new PacketPlayOutEntityMetadata(cache, entity.getDataWatcher(), true));
connection.sendPacket(new PacketPlayOutEntityLook(cache, convertYaw(getYaw()), convertPitch(getPitch()), false));
connection.sendPacket(new PacketPlayOutEntityVelocity(cache, motion.getX(), motion.getY(), motion.getZ()));
connection.sendPacket(new PacketPlayOutEntityHeadRotation(entity, convertYaw(getYaw())));
PacketPlayOutEntityEquipment[] equipment = getEquipmentPacket();
if (equipment != null) {
for (PacketPlayOutEntityEquipment packet : equipment) {
connection.sendPacket(packet);
}
}
// Inject the player's packet connection into this listener, so we can
// show the player position/velocity/rotation changes
connections.add(connection);
}
Aggregations