Search in sources :

Example 26 with Position

use of com.viaversion.viaversion.api.minecraft.Position in project ViaVersion by ViaVersion.

the class RedstoneConnectionHandler method connects.

private int connects(UserConnection user, Position position, BlockFace side) {
    final Position relative = position.getRelative(side);
    int blockState = getBlockData(user, relative);
    if (connects(side, blockState)) {
        // side
        return 1;
    }
    int up = getBlockData(user, relative.getRelative(BlockFace.TOP));
    if (redstone.contains(up) && !ConnectionData.occludingStates.contains(getBlockData(user, position.getRelative(BlockFace.TOP)))) {
        // "up"
        return 2;
    }
    int down = getBlockData(user, relative.getRelative(BlockFace.BOTTOM));
    if (redstone.contains(down) && !ConnectionData.occludingStates.contains(getBlockData(user, relative))) {
        // side
        return 1;
    }
    // none
    return 0;
}
Also used : Position(com.viaversion.viaversion.api.minecraft.Position)

Example 27 with Position

use of com.viaversion.viaversion.api.minecraft.Position in project ViaVersion by ViaVersion.

the class BlockListener method placeBlock.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void placeBlock(BlockPlaceEvent e) {
    if (isOnPipe(e.getPlayer())) {
        Block b = e.getBlockPlaced();
        EntityTracker1_9 tracker = getUserConnection(e.getPlayer()).getEntityTracker(Protocol1_9To1_8.class);
        tracker.addBlockInteraction(new Position(b.getX(), (short) b.getY(), b.getZ()));
    }
}
Also used : EntityTracker1_9(com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9) Position(com.viaversion.viaversion.api.minecraft.Position) Block(org.bukkit.block.Block) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Position (com.viaversion.viaversion.api.minecraft.Position)27 PacketWrapper (com.viaversion.viaversion.api.protocol.packet.PacketWrapper)16 PacketRemapper (com.viaversion.viaversion.api.protocol.remapper.PacketRemapper)15 PacketHandler (com.viaversion.viaversion.api.protocol.remapper.PacketHandler)12 CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)11 Type (com.viaversion.viaversion.api.type.Type)10 Chunk (com.viaversion.viaversion.api.minecraft.chunks.Chunk)8 ChunkSection (com.viaversion.viaversion.api.minecraft.chunks.ChunkSection)8 Item (com.viaversion.viaversion.api.minecraft.item.Item)8 ClientWorld (com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld)8 StringTag (com.github.steveice10.opennbt.tag.builtin.StringTag)6 Tag (com.github.steveice10.opennbt.tag.builtin.Tag)6 NumberTag (com.github.steveice10.opennbt.tag.builtin.NumberTag)5 BlockStorage (com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage)5 ArrayList (java.util.ArrayList)5 ViaBackwards (com.viaversion.viabackwards.ViaBackwards)4 ClientboundPackets1_13 (com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13)4 Chunk1_9_3_4Type (com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type)4 List (java.util.List)4 Via (com.viaversion.viaversion.api.Via)3