Package net.glowstone.entity.meta

Examples of net.glowstone.entity.meta.MetadataIndex


        List<MetadataMap.Entry> entries = new ArrayList<>();
        byte item;
        while ((item = buf.readByte()) != 0x7F) {
            MetadataType type = MetadataType.byId(item >> 5);
            int id = item & 0x1f;
            MetadataIndex index = MetadataIndex.getIndex(id, type);

            switch (type) {
                case BYTE:
                    entries.add(new MetadataMap.Entry(index, buf.readByte()));
                    break;
View Full Code Here


     * @param buf The buffer.
     * @param entries The metadata.
     */
    public static void writeMetadata(ByteBuf buf, List<MetadataMap.Entry> entries) throws IOException {
        for (MetadataMap.Entry entry : entries) {
            MetadataIndex index = entry.index;
            Object value = entry.value;

            if (value == null) continue;

            int type = index.getType().getId();
            int id = index.getIndex();
            buf.writeByte((type << 5) | id);

            switch (index.getType()) {
                case BYTE:
                    buf.writeByte((Byte) value);
                    break;
                case SHORT:
                    buf.writeShort((Short) value);
View Full Code Here

TOP

Related Classes of net.glowstone.entity.meta.MetadataIndex

Copyright © 2018 www.massapicom. 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.