Search in sources :

Example 1 with BlockVector3

use of cn.nukkit.math.BlockVector3 in project Nukkit by Nukkit.

the class ContainerOpenPacket method decode.

@Override
public void decode() {
    this.windowId = this.getByte();
    this.type = this.getByte();
    BlockVector3 v = this.getBlockVector3();
    this.x = v.x;
    this.y = v.y;
    this.z = v.z;
    this.entityId = this.getEntityUniqueId();
}
Also used : BlockVector3(cn.nukkit.math.BlockVector3)

Example 2 with BlockVector3

use of cn.nukkit.math.BlockVector3 in project Nukkit by Nukkit.

the class BlockEntityDataPacket method decode.

@Override
public void decode() {
    BlockVector3 v = this.getBlockVector3();
    this.x = v.x;
    this.y = v.y;
    this.z = v.z;
    this.namedTag = this.get();
}
Also used : BlockVector3(cn.nukkit.math.BlockVector3)

Example 3 with BlockVector3

use of cn.nukkit.math.BlockVector3 in project Nukkit by Nukkit.

the class BlockPickRequestPacket method decode.

@Override
public void decode() {
    BlockVector3 v = this.getSignedBlockPosition();
    this.x = v.x;
    this.y = v.y;
    this.z = v.z;
    this.putBoolean(this.addUserData);
    this.selectedSlot = this.getByte();
}
Also used : BlockVector3(cn.nukkit.math.BlockVector3)

Example 4 with BlockVector3

use of cn.nukkit.math.BlockVector3 in project Nukkit by Nukkit.

the class PlayerActionPacket method decode.

@Override
public void decode() {
    this.entityId = this.getEntityRuntimeId();
    this.action = this.getVarInt();
    BlockVector3 v = this.getBlockVector3();
    this.x = v.x;
    this.y = v.y;
    this.z = v.z;
    this.face = this.getVarInt();
}
Also used : BlockVector3(cn.nukkit.math.BlockVector3)

Example 5 with BlockVector3

use of cn.nukkit.math.BlockVector3 in project Nukkit by Nukkit.

the class Binary method readMetadata.

public static EntityMetadata readMetadata(byte[] payload) {
    BinaryStream stream = new BinaryStream();
    stream.setBuffer(payload);
    long count = stream.getUnsignedVarInt();
    EntityMetadata m = new EntityMetadata();
    for (int i = 0; i < count; i++) {
        int key = (int) stream.getUnsignedVarInt();
        int type = (int) stream.getUnsignedVarInt();
        EntityData value = null;
        switch(type) {
            case Entity.DATA_TYPE_BYTE:
                value = new ByteEntityData(key, stream.getByte());
                break;
            case Entity.DATA_TYPE_SHORT:
                value = new ShortEntityData(key, stream.getLShort());
                break;
            case Entity.DATA_TYPE_INT:
                value = new IntEntityData(key, stream.getVarInt());
                break;
            case Entity.DATA_TYPE_FLOAT:
                value = new FloatEntityData(key, stream.getLFloat());
                break;
            case Entity.DATA_TYPE_STRING:
                value = new StringEntityData(key, stream.getString());
                break;
            case Entity.DATA_TYPE_SLOT:
                Item item = stream.getSlot();
                value = new SlotEntityData(key, item.getId(), item.getDamage(), item.getCount());
                break;
            case Entity.DATA_TYPE_POS:
                BlockVector3 v3 = stream.getSignedBlockPosition();
                value = new IntPositionEntityData(key, v3.x, v3.y, v3.z);
                break;
            case Entity.DATA_TYPE_LONG:
                value = new LongEntityData(key, stream.getVarLong());
                break;
            case Entity.DATA_TYPE_VECTOR3F:
                value = new Vector3fEntityData(key, stream.getVector3f());
                break;
        }
        if (value != null)
            m.put(value);
    }
    return m;
}
Also used : BlockVector3(cn.nukkit.math.BlockVector3) Item(cn.nukkit.item.Item)

Aggregations

BlockVector3 (cn.nukkit.math.BlockVector3)9 Item (cn.nukkit.item.Item)1 BlockFace (cn.nukkit.math.BlockFace)1