Examples of BlockVector


Examples of org.bukkit.util.BlockVector

import java.io.IOException;

public final class BlockChangeCodec implements Codec<BlockChangeMessage> {
    @Override
    public BlockChangeMessage decode(ByteBuf buffer) throws IOException {
        BlockVector pos = GlowBufUtils.readBlockPosition(buffer);
        int type = ByteBufUtils.readVarInt(buffer);
        return new BlockChangeMessage(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), type);
    }
View Full Code Here

Examples of org.bukkit.util.BlockVector

    @Override
    public TabCompleteMessage decode(ByteBuf buf) throws IOException {
        String text = ByteBufUtils.readUTF8(buf);

        boolean hasLocation = buf.readBoolean();
        BlockVector location = null;
        if (hasLocation) {
            location = GlowBufUtils.readBlockPosition(buf);
        }
        return new TabCompleteMessage(text, location);
    }
View Full Code Here

Examples of org.bukkit.util.BlockVector

    }

    @Override
    public ByteBuf encode(ByteBuf buf, TabCompleteMessage message) throws IOException {
        ByteBufUtils.writeUTF8(buf, message.getText());
        final BlockVector location = message.getLocation();
        if (location != null) {
            buf.writeBoolean(true);
            GlowBufUtils.writeBlockPosition(buf, location);
        } else {
            buf.writeBoolean(false);
View Full Code Here

Examples of org.bukkit.util.BlockVector

public final class DiggingCodec implements Codec<DiggingMessage> {
    @Override
    public DiggingMessage decode(ByteBuf buf) throws IOException {
        int state = buf.readByte();
        BlockVector pos = GlowBufUtils.readBlockPosition(buf);
        int face = buf.readByte();
        return new DiggingMessage(state, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), face);
    }
View Full Code Here

Examples of org.bukkit.util.BlockVector

            Map<BlockVector, BlockChangeMessage> map = chunks.get(key);
            if (map == null) {
                map = new HashMap<>();
                chunks.put(key, map);
            }
            map.put(new BlockVector(message.getX(), message.getY(), message.getZ()), message);
        }

        // send away
        for (Map.Entry<GlowChunk.Key, Map<BlockVector, BlockChangeMessage>> entry : chunks.entrySet()) {
            GlowChunk.Key key = entry.getKey();
View Full Code Here

Examples of org.bukkit.util.BlockVector

public final class UpdateBlockEntityCodec implements Codec<UpdateBlockEntityMessage> {

    @Override
    public UpdateBlockEntityMessage decode(ByteBuf buffer) throws IOException {
        BlockVector pos = GlowBufUtils.readBlockPosition(buffer);
        int action = buffer.readByte();
        CompoundTag nbt = GlowBufUtils.readCompound(buffer);
        return new UpdateBlockEntityMessage(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), action, nbt);
    }
View Full Code Here

Examples of org.bukkit.util.BlockVector

import java.io.IOException;

public final class UpdateSignCodec implements Codec<UpdateSignMessage> {
    @Override
    public UpdateSignMessage decode(ByteBuf buf) throws IOException {
        BlockVector pos = GlowBufUtils.readBlockPosition(buf);
        TextMessage[] message = new TextMessage[4];
        for (int i = 0; i < message.length; ++i) {
            message[i] = GlowBufUtils.readChat(buf);
        }
        return new UpdateSignMessage(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), message);
    }
View Full Code Here

Examples of org.bukkit.util.BlockVector

import java.io.IOException;

public final class BlockPlacementCodec implements Codec<BlockPlacementMessage> {
    @Override
    public BlockPlacementMessage decode(ByteBuf buf) throws IOException {
        BlockVector pos = GlowBufUtils.readBlockPosition(buf);
        int direction = buf.readByte();
        ItemStack heldItem = GlowBufUtils.readSlot(buf);
        int cursorX = buf.readByte();
        int cursorY = buf.readByte();
        int cursorZ = buf.readByte();
        return new BlockPlacementMessage(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), direction, heldItem, cursorX, cursorY, cursorZ);
    }
View Full Code Here

Examples of org.bukkit.util.BlockVector

    lightSourceZOffset[quad] = z;
    return this;
  }

  public BlockVector getLightSource(int quad, int x, int y, int z) {
    BlockVector blockVector = new BlockVector(x + lightSourceXOffset[quad], y + lightSourceYOffset[quad], z + lightSourceZOffset[quad]);
    return blockVector;
  }
View Full Code Here

Examples of org.bukkit.util.BlockVector

  public GenericBlockDesign calculateLightSources() {
    lightSourceXOffset = new int[xPos.length];
    lightSourceYOffset = new int[xPos.length];
    lightSourceZOffset = new int[xPos.length];
    for (int quad = 0; quad < xPos.length; quad++) {
      BlockVector normal = new BlockVector();

      normal.setX(((yPos[quad][0] - yPos[quad][1]) * (zPos[quad][1] - zPos[quad][2])) - ((zPos[quad][0] - zPos[quad][1]) * (yPos[quad][1] - yPos[quad][2])));
      normal.setY(((zPos[quad][0] - zPos[quad][1]) * (xPos[quad][1] - xPos[quad][2])) - ((xPos[quad][0] - xPos[quad][1]) * (zPos[quad][1] - zPos[quad][2])));
      normal.setZ(((xPos[quad][0] - xPos[quad][1]) * (yPos[quad][1] - yPos[quad][2])) - ((yPos[quad][0] - yPos[quad][1]) * (xPos[quad][1] - xPos[quad][2])));

      Double length = Math.sqrt((normal.getX() * normal.getX()) + (normal.getY() * normal.getY()) + (normal.getZ() * normal.getZ()));

      this.setLightSource(quad, (int) Math.round(normal.getX() / length), (int) Math.round(normal.getY() / length), (int) Math.round(normal.getZ() / length));
    }

    return this;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.