Search in sources :

Example 1 with WatchableObject

use of com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject in project DirtMultiversion by DirtPowered.

the class ProtocolRelease39To29 method registerTranslators.

@Override
public void registerTranslators() {
    // handshake
    addTranslator(0x02, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            // since 1.3 handshake is one-way (client -> server)
            return cancel();
        }
    });
    // handshake
    addTranslator(0x02, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String username = data.read(Type.STRING, 1);
            session.getUserData().setUsername(username);
            PacketData encryptRequest = EncryptionUtils.createEncryptionRequest(session);
            // server -> client
            session.sendPacket(encryptRequest, PacketDirection.TO_CLIENT, getFrom());
            return PacketUtil.createPacket(0x02, new TypeHolder[] { set(Type.STRING, username) });
        }
    });
    // client shared key
    addTranslator(0xFC, PacketDirection.TO_SERVER, new PacketTranslator() {

        @SneakyThrows
        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            PacketData request = session.getUserData().getProxyRequest();
            SecretKey sharedKey = EncryptionUtils.getSecret(data, request);
            // server -> client
            EncryptionUtils.sendEmptyEncryptionResponse(session, getFrom());
            // enable encryption
            EncryptionUtils.setEncryption(session.getChannel(), sharedKey);
            // cancel packet
            return cancel();
        }
    });
    // client command
    addTranslator(0xCD, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            byte command = data.read(Type.BYTE, 0);
            if (command == 0x00) {
                String username = session.getUserData().getUsername();
                return PacketUtil.createPacket(0x01, new TypeHolder[] { // protocol version
                set(Type.INT, 29), set(Type.STRING, username), set(Type.STRING, "default"), set(Type.INT, 0), set(Type.INT, 0), set(Type.BYTE, (byte) 0), set(Type.BYTE, (byte) 0), set(Type.BYTE, (byte) 0) });
            } else {
                return PacketUtil.createPacket(0x09, new TypeHolder[] { set(Type.INT, 0), set(Type.BYTE, (byte) 0), set(Type.BYTE, (byte) 0), set(Type.SHORT, (short) 0), set(Type.STRING, "default") });
            }
        }
    });
    // login
    addTranslator(0x01, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            session.getUserData().setEntityId(data.read(Type.INT, 0));
            return PacketUtil.createPacket(0x01, new TypeHolder[] { data.read(0), data.read(2), set(Type.BYTE, data.read(Type.INT, 3).byteValue()), set(Type.BYTE, data.read(Type.INT, 4).byteValue()), data.read(5), data.read(6), data.read(7) });
        }
    });
    // tab command complete
    addTranslator(0xCB, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return cancel();
        }
    });
    // client settings
    addTranslator(0xCC, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return cancel();
        }
    });
    // spawn position
    addTranslator(0x06, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            EntityTracker tracker = new EntityTracker();
            int x = data.read(Type.INT, 0);
            int y = data.read(Type.INT, 1);
            int z = data.read(Type.INT, 2);
            Location loc = new Location(x, y, z);
            tracker.addEntity(-999, new HumanEntity(-999, loc));
            session.getStorage().set(EntityTracker.class, tracker);
            return data;
        }
    });
    // window click
    addTranslator(0x66, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ItemStack newItem = data.read(Type.V1_3R_ITEM, 5);
            return PacketUtil.createPacket(0x66, new TypeHolder[] { data.read(0), data.read(1), data.read(2), data.read(3), data.read(4), set(Type.V1_0R_ITEM, newItem) });
        }
    });
    // set slot
    addTranslator(0x67, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ItemStack oldItem = data.read(Type.V1_0R_ITEM, 2);
            return PacketUtil.createPacket(0x67, new TypeHolder[] { data.read(0), data.read(1), set(Type.V1_3R_ITEM, oldItem) });
        }
    });
    // window items
    addTranslator(0x68, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ItemStack[] items = data.read(Type.V1_0R_ITEM_ARRAY, 1);
            for (ItemStack item : items) {
                if (item != null && item.getCompoundTag() == null) {
                    // since 1.3 all items contains NBT data
                    item.setCompoundTag(CompoundBinaryTag.empty());
                }
            }
            return PacketUtil.createPacket(0x68, new TypeHolder[] { data.read(0), set(Type.V1_3R_ITEM_ARRAY, items) });
        }
    });
    // entity destroy
    addTranslator(0x1D, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int entityId = data.read(Type.INT, 0);
            EntityTracker tracker = session.getStorage().get(EntityTracker.class);
            tracker.removeEntity(entityId);
            return PacketUtil.createPacket(0x1D, new TypeHolder[] { set(Type.BYTE_INT_ARRAY, new int[] { entityId }) });
        }
    });
    // mob spawn
    addTranslator(0x18, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int entityId = data.read(Type.INT, 0);
            EntityType entityType = EntityType.fromEntityTypeId(data.read(Type.BYTE, 1));
            double x = data.read(Type.INT, 2) / 32.0D;
            double y = data.read(Type.INT, 3) / 32.0D;
            double z = data.read(Type.INT, 4) / 32.0D;
            Location location = new Location(x, y, z);
            Entity entity = new Entity(entityId, location, entityType);
            EntityTracker tracker = session.getStorage().get(EntityTracker.class);
            tracker.addEntity(entityId, entity);
            return PacketUtil.createPacket(0x18, new TypeHolder[] { data.read(0), data.read(1), data.read(2), data.read(3), data.read(4), data.read(5), data.read(6), data.read(7), set(Type.SHORT, (short) 0), set(Type.SHORT, (short) 0), set(Type.SHORT, (short) 0), data.read(8) });
        }
    });
    // entity status
    addTranslator(0x26, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int entityId = data.read(Type.INT, 0);
            byte status = data.read(Type.BYTE, 1);
            if (status == 2) {
                // hurt
                WorldEntityEvent.onDamage(session, entityId);
            }
            if (status == 3) {
                // death
                WorldEntityEvent.onDeath(session, entityId);
            }
            return data;
        }
    });
    // entity teleport
    addTranslator(0x22, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int entityId = data.read(Type.INT, 0);
            int x = data.read(Type.INT, 1);
            int y = data.read(Type.INT, 2);
            int z = data.read(Type.INT, 3);
            updateEntityLocation(session, entityId, x, y, z, false);
            return data;
        }
    });
    // entity relative move
    addTranslator(0x1F, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int entityId = data.read(Type.INT, 0);
            int x = data.read(Type.BYTE, 1);
            int y = data.read(Type.BYTE, 2);
            int z = data.read(Type.BYTE, 3);
            updateEntityLocation(session, entityId, x, y, z, true);
            return data;
        }
    });
    // entity relative look move
    addTranslator(0x21, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int entityId = data.read(Type.INT, 0);
            int x = data.read(Type.BYTE, 1);
            int y = data.read(Type.BYTE, 2);
            int z = data.read(Type.BYTE, 3);
            updateEntityLocation(session, entityId, x, y, z, true);
            return data;
        }
    });
    // vehicle spawn
    addTranslator(0x17, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            Motion motion = data.read(Type.MOTION, 5);
            int throwerId = motion.getThrowerId();
            byte type = data.read(Type.BYTE, 1);
            // sound emulation, entity mount fixes
            EntityTracker tracker = session.getStorage().get(EntityTracker.class);
            int entityId = data.read(Type.INT, 0);
            double x = data.read(Type.INT, 2) / 32.0D;
            double y = data.read(Type.INT, 3) / 32.0D;
            double z = data.read(Type.INT, 4) / 32.0D;
            float pitch;
            Location loc = new Location(x, y, z);
            switch(type) {
                case 1:
                    // cache boats
                    Entity boat = new Entity(entityId, loc, EntityType.BOAT);
                    tracker.addEntity(entityId, boat);
                    break;
                case 10:
                case 11:
                case 12:
                    // cache minecarts
                    Entity minecart = new Entity(entityId, loc, EntityType.MINECART);
                    tracker.addEntity(entityId, minecart);
                    break;
                case 50:
                    // cache primed tnt entity
                    Entity primedTNT = new Entity(entityId, loc, EntityType.PRIMED_TNT);
                    tracker.addEntity(entityId, primedTNT);
                    WorldEntityEvent.onCustomAction(session, entityId);
                    break;
                case 60:
                    // bow sound
                    pitch = 1.0F / (session.getMain().getSharedRandom().nextFloat() * 0.4F + 1.2F) + 0.5F;
                    WorldEntityEvent.playSoundAt(session, loc, WorldSound.RANDOM_BOW, 0.2F, pitch);
                    break;
                // snowball
                case 61:
                // egg
                case 62:
                // fishing rod
                case 90:
                // ender pearl
                case 65:
                // ender eye
                case 72:
                // throwable potion
                case 73:
                case // exp bottle
                75:
                    pitch = 0.4F / (session.getMain().getSharedRandom().nextFloat() * 0.4F + 0.8F);
                    WorldEntityEvent.playSoundAt(session, loc, WorldSound.RANDOM_BOW, 0.5F, pitch);
                    if (type == 90) {
                        Location hookLocation = new Location(x, y, z);
                        AbstractEntity nearest = getNearestEntity(tracker, hookLocation, 2.0D);
                        throwerId = nearest.getEntityId() != -1 ? nearest.getEntityId() : session.getUserData().getEntityId();
                    }
                    break;
            }
            switch(type) {
                case 70:
                    throwerId = 12;
                    break;
                case 71:
                    throwerId = 13;
                    type = 70;
                    break;
                case 74:
                    throwerId = 122;
                    type = 70;
                    break;
            }
            motion.setThrowerId(throwerId);
            return PacketUtil.createPacket(0x17, new TypeHolder[] { data.read(0), set(Type.BYTE, type), data.read(2), data.read(3), data.read(4), set(Type.MOTION, motion) });
        }
    });
    // block place
    addTranslator(0x0F, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ItemStack newItem = data.read(Type.V1_3R_ITEM, 4);
            return PacketUtil.createPacket(0x0F, new TypeHolder[] { data.read(0), data.read(1), data.read(2), data.read(3), set(Type.V1_0R_ITEM, newItem) });
        }
    });
    // creative set slot
    addTranslator(0x6B, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ItemStack newItem = data.read(Type.V1_3R_ITEM, 1);
            boolean notNull = newItem != null;
            if (notNull && !creativeTab.exists(newItem.getItemId())) {
                // replace all unknown items to stone
                newItem.setItemId(1);
                newItem.setData(0);
            }
            return PacketUtil.createPacket(0x6B, new TypeHolder[] { data.read(0), set(Type.V1_0R_ITEM, newItem) });
        }
    });
    // named entity spawn
    addTranslator(0x14, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            EntityTracker tracker = session.getStorage().get(EntityTracker.class);
            int entityId = data.read(Type.INT, 0);
            double x = data.read(Type.INT, 2) / 32.0D;
            double y = data.read(Type.INT, 3) / 32.0D;
            double z = data.read(Type.INT, 4) / 32.0D;
            Location loc = new Location(x, y, z);
            HumanEntity human = new HumanEntity(entityId, loc);
            tracker.addEntity(entityId, human);
            /* default 1.3.x metadata */
            List<WatchableObject> watchableObjects = Arrays.asList(new WatchableObject(MetadataType.BYTE, 0, 0), new WatchableObject(MetadataType.BYTE, 16, 0), new WatchableObject(MetadataType.SHORT, 1, 300), new WatchableObject(MetadataType.BYTE, 17, 0), new WatchableObject(MetadataType.INT, 8, 0));
            return PacketUtil.createPacket(0x14, new TypeHolder[] { // entityId
            data.read(0), // playerName
            data.read(1), // x
            data.read(2), // y
            data.read(3), // z
            data.read(4), // yaw
            data.read(5), // pitch
            data.read(6), // item
            data.read(7), // default metadata
            set(Type.V1_3B_METADATA, watchableObjects.toArray(new WatchableObject[0])) });
        }
    });
    // entity metadata
    addTranslator(0x28, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int entityId = data.read(Type.INT, 0);
            WatchableObject[] watchableObjects = data.read(Type.V1_3B_METADATA, 1);
            EntityTracker tracker = session.getStorage().get(EntityTracker.class);
            for (WatchableObject watchableObject : watchableObjects) {
                int index = watchableObject.getIndex();
                MetadataType type = watchableObject.getType();
                Object value = watchableObject.getValue();
                if (type == MetadataType.BYTE && index == 0 && tracker.isEntityTracked(entityId)) {
                    if (((Byte) value).intValue() == 4) {
                        // entity mount
                        if (tracker.getEntity(entityId).getEntityType() == EntityType.HUMAN) {
                            HumanEntity humanEntity = (HumanEntity) tracker.getEntity(entityId);
                            AbstractEntity nearbyEntity = getNearestEntity(tracker, humanEntity.getLocation(), 1.5D);
                            EntityType eType = nearbyEntity.getEntityType();
                            if (nearbyEntity.getEntityId() != -1) {
                                if (eType == EntityType.MINECART || eType == EntityType.PIG || eType == EntityType.BOAT) {
                                    PacketData entityAttach = PacketUtil.createPacket(0x27, new TypeHolder[] { set(Type.INT, entityId), set(Type.INT, nearbyEntity.getEntityId()) });
                                    humanEntity.setRidingEntity(true);
                                    session.sendPacket(entityAttach, PacketDirection.TO_CLIENT, getFrom());
                                }
                            }
                        }
                    } else if (((Byte) value).intValue() == 0) {
                        // un-mount
                        if (tracker.isEntityTracked(entityId) && tracker.getEntity(entityId) instanceof HumanEntity) {
                            HumanEntity humanEntity = (HumanEntity) tracker.getEntity(entityId);
                            if (humanEntity.isRidingEntity()) {
                                PacketData entityAttach = PacketUtil.createPacket(0x27, new TypeHolder[] { set(Type.INT, entityId), set(Type.INT, -1) });
                                humanEntity.setRidingEntity(false);
                                session.sendPacket(entityAttach, PacketDirection.TO_CLIENT, getFrom());
                            }
                        }
                    }
                }
            }
            return data;
        }
    });
    // explosion
    addTranslator(0x3C, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            double x = data.read(Type.DOUBLE, 0);
            double y = data.read(Type.DOUBLE, 1);
            double z = data.read(Type.DOUBLE, 2);
            Location loc = new Location(x, y, z);
            WorldEntityEvent.playSoundAt(session, loc, WorldSound.RANDOM_EXPLODE);
            return PacketUtil.createPacket(0x3C, new TypeHolder[] { data.read(0), data.read(1), data.read(2), data.read(3), data.read(4), set(Type.FLOAT, 0.0F), set(Type.FLOAT, 0.0F), set(Type.FLOAT, 0.0F) });
        }
    });
    // item collect
    addTranslator(0x16, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            EntityTracker tracker = session.getStorage().get(EntityTracker.class);
            int entityId = data.read(Type.INT, 0);
            AbstractEntity itemPickup = tracker.getEntity(entityId);
            if (itemPickup != null) {
                Random shared = session.getMain().getSharedRandom();
                float pitch = ((shared.nextFloat() - shared.nextFloat()) * 0.7F + 1.0F) * 2.0F;
                WorldEntityEvent.playSoundAt(session, itemPickup.getLocation(), WorldSound.RANDOM_POP, 0.2F, pitch);
            }
            return data;
        }
    });
    // pickup spawn
    addTranslator(0x15, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            EntityTracker tracker = session.getStorage().get(EntityTracker.class);
            int entityId = data.read(Type.INT, 0);
            double x = data.read(Type.INT, 4) / 32.0D;
            double y = data.read(Type.INT, 5) / 32.0D;
            double z = data.read(Type.INT, 6) / 32.0D;
            Location b = new Location(x, y, z);
            Entity itemPickup = new Entity(entityId, b, EntityType.ITEM);
            tracker.addEntity(entityId, itemPickup);
            return data;
        }
    });
    // player abilities
    addTranslator(0xCA, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            byte mask = data.read(Type.BYTE, 0);
            return PacketUtil.createPacket(0xCA, new TypeHolder[] { set(Type.BOOLEAN, ((mask & 1) > 0)), set(Type.BOOLEAN, ((mask & 2) > 0)), set(Type.BOOLEAN, ((mask & 4) > 0)), set(Type.BOOLEAN, ((mask & 8) > 0)) });
        }
    });
    // player abilities
    addTranslator(0xCA, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            boolean invulnerable = data.read(Type.BOOLEAN, 0);
            boolean flying = data.read(Type.BOOLEAN, 1);
            boolean allowFlying = data.read(Type.BOOLEAN, 2);
            boolean instantBreak = data.read(Type.BOOLEAN, 3);
            byte mask = 0;
            if (invulnerable) {
                mask = (byte) (mask | 1);
            }
            if (flying) {
                mask = (byte) (mask | 2);
            }
            if (allowFlying) {
                mask = (byte) (mask | 4);
            }
            if (instantBreak) {
                mask = (byte) (mask | 8);
            }
            return PacketUtil.createPacket(0xCA, new TypeHolder[] { set(Type.BYTE, mask), set(Type.BYTE, (byte) (0.05f * 255)), set(Type.BYTE, (byte) (0.1f * 255)) });
        }
    });
    // player look move
    addTranslator(0x0D, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            double x = data.read(Type.DOUBLE, 0);
            double y = data.read(Type.DOUBLE, 1);
            double z = data.read(Type.DOUBLE, 3);
            EntityTracker tracker = session.getStorage().get(EntityTracker.class);
            AbstractEntity e = tracker.getEntity(-999);
            if (e != null) {
                e.setLocation(new Location(x, y, z));
            }
            return data;
        }
    });
    // update tile entity
    addTranslator(0x84, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int x = data.read(Type.INT, 0);
            short y = data.read(Type.SHORT, 1);
            int z = data.read(Type.INT, 2);
            int entityTypeId = data.read(Type.INT, 4);
            CompoundBinaryTag.Builder builder = CompoundBinaryTag.builder();
            builder.putString("EntityId", EntityIdToTypeString.getEntityTypeString(entityTypeId));
            builder.putShort("Delay", (short) 20);
            builder.putInt("x", x);
            builder.putInt("y", y);
            builder.putInt("z", z);
            CompoundBinaryTag tileTag = builder.build();
            return PacketUtil.createPacket(0x84, new TypeHolder[] { data.read(0), data.read(1), data.read(2), data.read(3), set(Type.COMPOUND_TAG, tileTag) });
        }
    });
    // entity equipment
    addTranslator(0x05, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            short itemId = data.read(Type.SHORT, 2);
            short itemData = data.read(Type.SHORT, 3);
            ItemStack itemStack;
            if (itemId == -1) {
                itemStack = null;
            } else {
                itemStack = new ItemStack(itemId, 0, itemData, null);
            }
            return PacketUtil.createPacket(0x05, new TypeHolder[] { data.read(0), data.read(1), set(Type.V1_3R_ITEM, itemStack) });
        }
    });
}
Also used : AbstractEntity(com.github.dirtpowered.dirtmv.network.versions.Release39To29.entity.model.AbstractEntity) Entity(com.github.dirtpowered.dirtmv.network.versions.Release39To29.entity.Entity) HumanEntity(com.github.dirtpowered.dirtmv.network.versions.Release39To29.entity.HumanEntity) Motion(com.github.dirtpowered.dirtmv.data.protocol.objects.Motion) ServerSession(com.github.dirtpowered.dirtmv.network.server.ServerSession) PacketTranslator(com.github.dirtpowered.dirtmv.data.translator.PacketTranslator) EntityTracker(com.github.dirtpowered.dirtmv.network.versions.Release39To29.entity.EntityTracker) MetadataType(com.github.dirtpowered.dirtmv.data.protocol.objects.MetadataType) SneakyThrows(lombok.SneakyThrows) EntityIdToTypeString(com.github.dirtpowered.dirtmv.network.versions.Release39To29.entity.EntityIdToTypeString) TypeHolder(com.github.dirtpowered.dirtmv.data.protocol.TypeHolder) EntityType(com.github.dirtpowered.dirtmv.data.entity.EntityType) SecretKey(javax.crypto.SecretKey) Random(java.util.Random) AbstractEntity(com.github.dirtpowered.dirtmv.network.versions.Release39To29.entity.model.AbstractEntity) HumanEntity(com.github.dirtpowered.dirtmv.network.versions.Release39To29.entity.HumanEntity) List(java.util.List) WatchableObject(com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject) ItemStack(com.github.dirtpowered.dirtmv.data.protocol.objects.ItemStack) WatchableObject(com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject) CompoundBinaryTag(net.kyori.adventure.nbt.CompoundBinaryTag) PacketData(com.github.dirtpowered.dirtmv.data.protocol.PacketData) Location(com.github.dirtpowered.dirtmv.data.protocol.objects.Location)

Example 2 with WatchableObject

use of com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject in project DirtMultiversion by DirtPowered.

the class V1_7RTo1_8RMetadataTransformer method transformMetadata.

@Override
public WatchableObject[] transformMetadata(SpawnableObject entityType, WatchableObject[] watchableObjects) {
    List<WatchableObject> newMetaData = new ArrayList<>();
    for (WatchableObject watchableObject : watchableObjects) {
        MetadataType type = watchableObject.getType();
        Object value = watchableObject.getValue();
        int index = watchableObject.getIndex();
        if (entityType.isLivingEntity()) {
            if (type == MetadataType.BYTE && index == 11) {
                // nametag visibility
                newMetaData.add(new WatchableObject(MetadataType.BYTE, 3, value));
            } else if (type == MetadataType.INT && index == 12) {
                // ageable entities
                int age = (int) value;
                newMetaData.add(new WatchableObject(MetadataType.BYTE, 12, (byte) (age < 0 ? -1 : 0)));
            } else if (entityType == EntityType.ENDER_MAN && type == MetadataType.BYTE && index == 16) {
                // enderman carried item
                newMetaData.add(new WatchableObject(MetadataType.SHORT, 16, ((Byte) value).shortValue()));
            } else if (entityType == EntityType.HUMAN) {
                if (type == MetadataType.BYTE && index == 16) {
                // TODO: check for metadata changes
                } else {
                    newMetaData.add(watchableObject);
                }
            } else if (type == MetadataType.STRING && index == 10) {
                // custom display name
                newMetaData.add(new WatchableObject(MetadataType.STRING, 2, value));
            } else {
                newMetaData.add(watchableObject);
            }
        } else {
            if (entityType == ObjectType.ITEM_FRAME) {
                if (type == MetadataType.BYTE && index == 3) {
                    newMetaData.add(new WatchableObject(MetadataType.BYTE, 9, value));
                } else if (type == MetadataType.ITEM && index == 2) {
                    newMetaData.add(new WatchableObject(MetadataType.ITEM, 8, value));
                }
            } else {
                newMetaData.add(watchableObject);
            }
        }
    }
    if (newMetaData.isEmpty()) {
        List<WatchableObject> defaultMetadata = Arrays.asList(new WatchableObject(MetadataType.BYTE, 0, (byte) 0), new WatchableObject(MetadataType.SHORT, 1, 300), new WatchableObject(MetadataType.BYTE, 4, (byte) 0));
        newMetaData.addAll(defaultMetadata);
    }
    return newMetaData.toArray(new WatchableObject[0]);
}
Also used : ArrayList(java.util.ArrayList) MetadataType(com.github.dirtpowered.dirtmv.data.protocol.objects.MetadataType) SpawnableObject(com.github.dirtpowered.dirtmv.data.entity.SpawnableObject) WatchableObject(com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject) WatchableObject(com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject)

Example 3 with WatchableObject

use of com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject in project DirtMultiversion by DirtPowered.

the class ProtocolRelease4To78 method registerTranslators.

@Override
public void registerTranslators() {
    // server info request
    addTranslator(0x00, ProtocolState.STATUS, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String address = "localhost";
            int port = 25565;
            return PacketUtil.createPacket(0xFE, new TypeHolder[] { set(Type.UNSIGNED_BYTE, (short) 1), set(Type.UNSIGNED_BYTE, (short) 0xFA), set(Type.STRING, "MC|PingHost"), set(Type.SHORT, (short) (3 + 2 * address.length() + 4)), set(Type.BYTE, (byte) 78), set(Type.STRING, address), set(Type.INT, port) });
        }
    });
    // ping
    addTranslator(0x01, ProtocolState.STATUS, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            PacketData response = PacketUtil.createPacket(0x01, new TypeHolder[] { data.read(0) });
            session.sendPacket(response, PacketDirection.TO_CLIENT, getFrom());
            return cancel();
        }
    });
    // kick disconnect
    addTranslator(0xFF, ProtocolState.STATUS, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ServerMotd motd = ServerMotd.deserialize(data.read(Type.STRING, 0));
            ServerPing serverPing = new ServerPing();
            ServerPing.Version version = new ServerPing.Version();
            ServerPing.Players players = new ServerPing.Players();
            serverPing.setDescription(motd.getMotd());
            serverPing.setVersion(version);
            version.setName("1.7.2");
            version.setProtocol(4);
            players.setMax(motd.getMax());
            players.setOnline(motd.getOnline());
            List<ServerPing.Player> playerList = new ArrayList<>();
            for (UserData userData : session.getServer().getAllConnections()) {
                if (userData.getUsername() != null) {
                    ServerPing.Player player = new ServerPing.Player();
                    player.setId(getOfflineUuid(userData.getUsername()));
                    player.setName(userData.getUsername());
                    playerList.add(player);
                }
            }
            List<ServerPing.Player> list = new ArrayList<>();
            long limit = 10;
            for (ServerPing.Player player : playerList) {
                if (limit-- == 0)
                    break;
                list.add(player);
            }
            playerList = list;
            if (!playerList.isEmpty()) {
                players.setSample(playerList);
            }
            serverPing.setPlayers(players);
            String serverIcon = session.getServer().getServerIcon();
            if (serverIcon != null && !serverIcon.isEmpty()) {
                serverPing.setFavicon(serverIcon);
            }
            return PacketUtil.createPacket(0x00, new TypeHolder[] { set(Type.V1_7_STRING, serverPing.toString()) });
        }
    });
    // login start
    addTranslator(0x00, ProtocolState.LOGIN, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            if (data.getObjects().length > 1)
                return cancel();
            UserData userData = session.getUserData();
            String username = data.read(Type.V1_7_STRING, 0);
            // handshake
            PacketData handshake = PacketUtil.createPacket(0x02, new TypeHolder[] { // protocol version
            set(Type.BYTE, (byte) 78), set(Type.STRING, username), set(Type.STRING, userData.getAddress()), set(Type.INT, userData.getPort()) });
            PacketData clientCommand = PacketUtil.createPacket(0xCD, new TypeHolder[] { set(Type.BYTE, (byte) 0) });
            userData.setUsername(username);
            session.sendPacket(handshake, PacketDirection.TO_SERVER, null);
            // client command
            session.sendPacket(clientCommand, PacketDirection.TO_SERVER, null);
            return cancel();
        }
    });
    // encryption
    addTranslator(0xFD, ProtocolState.LOGIN, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            UserData userData = session.getUserData();
            String username = userData.getUsername();
            PacketData loginSuccess = PacketUtil.createPacket(0x02, new TypeHolder[] { set(Type.V1_7_STRING, getOfflineUuid(username)), set(Type.V1_7_STRING, username) });
            session.sendPacket(loginSuccess, PacketDirection.TO_CLIENT, getFrom());
            userData.setProtocolState(ProtocolState.PLAY);
            return cancel();
        }
    });
    // login kick disconnect
    addTranslator(0xFF, ProtocolState.LOGIN, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String message = data.read(Type.STRING, 0);
            return PacketUtil.createPacket(0x00, new TypeHolder[] { set(Type.V1_7_STRING, ChatUtils.legacyToJsonString(message)) });
        }
    });
    // pre-netty login
    addTranslator(0x01, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x01, new TypeHolder[] { // entity id
            data.read(0), // game type
            data.read(2), // dimension
            data.read(3), // difficulty
            data.read(4), // max players
            data.read(6), set(Type.V1_7_STRING, data.read(Type.STRING, 1)) });
        }
    });
    // 0x03 SC 0x02 (chat)
    addTranslator(0x03, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String translationComponent = ChatUtils.fixTranslationComponent(data.read(Type.STRING, 0));
            String message = ChatUtils.jsonToNewChatComponent(translationComponent);
            return PacketUtil.createPacket(0x02, new TypeHolder[] { set(Type.V1_7_STRING, message) });
        }
    });
    // 0x05 SC 0x04 (entity equipment)
    addTranslator(0x05, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ItemStack originalItem = data.read(Type.V1_3R_ITEM, 2);
            if (originalItem != null) {
                originalItem = itemRemapper.replaceItem(originalItem);
            }
            return PacketUtil.createPacket(0x04, new TypeHolder[] { data.read(0), data.read(1), set(Type.V1_3R_ITEM, originalItem) });
        }
    });
    // 0xFF SC 0x40 (kick disconnect)
    addTranslator(0xFF, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String legacyDisconnect = data.read(Type.STRING, 0);
            return PacketUtil.createPacket(0x40, new TypeHolder[] { set(Type.V1_7_STRING, ChatUtils.legacyToJsonString(legacyDisconnect)) });
        }
    });
    // 0x35 SC 0x23 (block change)
    addTranslator(0x35, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x23, new TypeHolder[] { // x
            data.read(0), // y
            set(Type.UNSIGNED_BYTE, data.read(Type.BYTE, 1).shortValue()), // z
            data.read(2), // type
            set(Type.VAR_INT, data.read(Type.SHORT, 3).intValue()), // data
            set(Type.UNSIGNED_BYTE, data.read(Type.BYTE, 4).shortValue()) });
        }
    });
    // 0x18 SC 0x0F (spawn mob)
    addTranslator(0x18, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x0F, new TypeHolder[] { // entity id
            set(Type.VAR_INT, data.read(Type.INT, 0)), // type
            data.read(1), // x
            data.read(2), // y
            data.read(3), // z
            data.read(4), data.read(5), data.read(6), data.read(7), data.read(8), data.read(9), data.read(10), set(Type.V1_7R_METADATA, data.read(Type.V1_4R_METADATA, 11)) });
        }
    });
    // 0xC9 SC 0x38 (player tab entry)
    addTranslator(0xC9, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x38, new TypeHolder[] { set(Type.V1_7_STRING, data.read(Type.STRING, 0)), set(Type.BOOLEAN, data.read(Type.BYTE, 1) == 1), data.read(2) });
        }
    });
    // 0x09 SC 0x07 (respawn)
    addTranslator(0x09, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x07, new TypeHolder[] { data.read(0), data.read(1), data.read(2), set(Type.V1_7_STRING, data.read(Type.STRING, 4)) });
        }
    });
    // 0x0D SC 0x08 (player pos look)
    addTranslator(0x0D, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x08, new TypeHolder[] { data.read(0), data.read(1), data.read(3), data.read(4), data.read(5), data.read(6) });
        }
    });
    // 0x47 SC 0x2C (spawn global entity)
    addTranslator(0x47, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x2C, new TypeHolder[] { set(Type.VAR_INT, data.read(Type.INT, 0)), data.read(1), data.read(2), data.read(3), data.read(4) });
        }
    });
    // 0x17 SC 0x0E (spawn vehicle -> spawn object)
    addTranslator(0x17, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x0E, new TypeHolder[] { set(Type.VAR_INT, data.read(Type.INT, 0)), data.read(1), data.read(2), data.read(3), data.read(4), data.read(5), data.read(6), data.read(7) });
        }
    });
    // 0x36 SC 0x24 (play note block -> block action)
    addTranslator(0x36, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x24, new TypeHolder[] { data.read(0), data.read(1), data.read(2), data.read(3), data.read(4), set(Type.VAR_INT, data.read(Type.SHORT, 5).intValue()) });
        }
    });
    // 0x28 SC 0x1C (entity metadata)
    addTranslator(0x28, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            WatchableObject[] metadataArray = data.read(Type.V1_4R_METADATA, 1);
            for (int i = 0; i < metadataArray.length; i++) {
                WatchableObject watchableObject = metadataArray[i];
                if (watchableObject.getType() == MetadataType.ITEM) {
                    ItemStack obj = (ItemStack) watchableObject.getValue();
                    if (obj != null) {
                        obj = itemRemapper.replaceItem(obj);
                    }
                    metadataArray[i] = new WatchableObject(MetadataType.ITEM, watchableObject.getIndex(), obj);
                }
            }
            return PacketUtil.createPacket(0x1C, new TypeHolder[] { data.read(0), set(Type.V1_7R_METADATA, metadataArray) });
        // return cancel();
        }
    });
    // 0x46 SC 0x2B (game event)
    addTranslator(0x46, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int reason = data.read(Type.BYTE, 0);
            if (reason == 1) {
                reason = 2;
            } else if (reason == 2) {
                reason = 1;
            }
            return PacketUtil.createPacket(0x2B, new TypeHolder[] { set(Type.UNSIGNED_BYTE, (short) reason), set(Type.FLOAT, data.read(Type.BYTE, 1).floatValue()) });
        }
    });
    // 0x64 SC 0x2D (open window) // TODO: optional horse data
    addTranslator(0x64, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x2D, new TypeHolder[] { set(Type.UNSIGNED_BYTE, data.read(Type.BYTE, 0).shortValue()), set(Type.UNSIGNED_BYTE, data.read(Type.BYTE, 1).shortValue()), set(Type.V1_7_STRING, data.read(Type.STRING, 2)), set(Type.UNSIGNED_BYTE, data.read(Type.BYTE, 3).shortValue()), data.read(4) });
        }
    });
    // 0x3C SC 0x27 (explosion)
    addTranslator(0x3C, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x27, new TypeHolder[] { set(Type.FLOAT, data.read(Type.DOUBLE, 0).floatValue()), set(Type.FLOAT, data.read(Type.DOUBLE, 1).floatValue()), set(Type.FLOAT, data.read(Type.DOUBLE, 2).floatValue()), data.read(3), data.read(4), data.read(5), data.read(6), data.read(7) });
        }
    });
    // 0x3E SC 0x29 (level sound)
    addTranslator(0x3E, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String soundName = data.read(Type.STRING, 0);
            String newSoundName = soundRemapper.getNewSoundName(soundName);
            if (newSoundName.isEmpty())
                return cancel();
            return PacketUtil.createPacket(0x29, new TypeHolder[] { set(Type.V1_7_STRING, soundName), data.read(1), data.read(2), data.read(3), data.read(4), data.read(5) });
        }
    });
    // 0x14 CS 0x0C (named entity spawn)
    addTranslator(0x14, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String username = data.read(Type.STRING, 1);
            return PacketUtil.createPacket(0x0C, new TypeHolder[] { // entity id
            set(Type.VAR_INT, data.read(Type.INT, 0)), // player UUID,
            set(Type.V1_7_STRING, getOfflineUuid(username)), // player name
            set(Type.V1_7_STRING, username), data.read(2), data.read(3), data.read(4), data.read(5), data.read(6), data.read(7), set(Type.V1_7R_METADATA, data.read(Type.V1_4R_METADATA, 8)) });
        }
    });
    // 0x82 CS 0x33 (update sign)
    addTranslator(0x82, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x33, new TypeHolder[] { data.read(0), data.read(1), data.read(2), set(Type.V1_7_STRING, data.read(Type.STRING, 3)), set(Type.V1_7_STRING, data.read(Type.STRING, 4)), set(Type.V1_7_STRING, data.read(Type.STRING, 5)), set(Type.V1_7_STRING, data.read(Type.STRING, 6)) });
        }
    });
    // 0x1A SC 0x11 (spawn experience orb)
    addTranslator(0x1A, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x11, new TypeHolder[] { set(Type.VAR_INT, data.read(Type.INT, 0)), data.read(1), data.read(2), data.read(3), data.read(4) });
        }
    });
    // 0x19 SC 0x10 (spawn painting)
    addTranslator(0x19, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x10, new TypeHolder[] { set(Type.VAR_INT, data.read(Type.INT, 0)), set(Type.V1_7_STRING, data.read(Type.STRING, 1)), data.read(2), data.read(3), data.read(4), data.read(5) });
        }
    });
    // 0x10 SC 0x09 (held slot change)
    addTranslator(0x10, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x09, new TypeHolder[] { set(Type.BYTE, data.read(Type.SHORT, 0).byteValue()) });
        }
    });
    // 0xCB SC 0x3A (tab complete)
    addTranslator(0xCB, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String arr = data.read(Type.STRING, 0);
            String[] commands = arr.split("\0");
            return PacketUtil.createPacket(0x3A, new TypeHolder[] { set(Type.STRING_ARRAY, commands) });
        }
    });
    // 0x37 SC 0x25 (block break animation)
    addTranslator(0x37, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x25, new TypeHolder[] { set(Type.VAR_INT, data.read(Type.INT, 0)), data.read(1), data.read(2), data.read(3), data.read(4) });
        }
    });
    // 0xCE SC 0x3B (set objective)
    addTranslator(0xCE, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x3B, new TypeHolder[] { set(Type.V1_7_STRING, data.read(Type.STRING, 0)), set(Type.V1_7_STRING, data.read(Type.STRING, 1)), data.read(2) });
        }
    });
    // 0xCF SC 0x3C (update score)
    addTranslator(0xCF, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String itemName = data.read(Type.STRING, 0);
            int action = data.read(Type.BYTE, 1);
            TypeHolder<?>[] types = new TypeHolder[action != 1 ? 4 : 2];
            types[0] = set(Type.V1_7_STRING, itemName);
            types[1] = set(Type.BYTE, (byte) action);
            if (action != 1) {
                types[2] = set(Type.V1_7_STRING, data.read(Type.STRING, 2));
                types[3] = data.read(3);
            }
            return PacketUtil.createPacket(0x3C, types);
        }
    });
    // 0xD0 SC 0x3D (set display objective)
    addTranslator(0xD0, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x3D, new TypeHolder[] { data.read(0), set(Type.V1_7_STRING, data.read(Type.STRING, 1)) });
        }
    });
    // 0x3F SC 0x2A (world particles)
    addTranslator(0x3F, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x2A, new TypeHolder[] { set(Type.V1_7_STRING, data.read(Type.STRING, 0)), data.read(1), data.read(2), data.read(3), data.read(4), data.read(5), data.read(6), data.read(7), data.read(8) });
        }
    });
    // 0x85 SC 0x36 (open sign editor)
    addTranslator(0x85, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x36, new TypeHolder[] { data.read(1), data.read(2), data.read(3) });
        }
    });
    // 0x11 SC 0x0A (use bed)
    addTranslator(0x11, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x0A, new TypeHolder[] { data.read(0), data.read(2), data.read(3), data.read(4) });
        }
    });
    // 0x12 SC 0x0B (entity animation)
    addTranslator(0x12, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int animationType = data.read(Type.BYTE, 1);
            switch(animationType) {
                case 1:
                    animationType = 0;
                    break;
                case 2:
                    animationType = 1;
                    break;
                case 3:
                    animationType = 2;
                    break;
                case 5:
                    animationType = 3;
                    break;
                case 6:
                    animationType = 4;
                    break;
                case 7:
                    animationType = 5;
                    break;
            }
            return PacketUtil.createPacket(0x0B, new TypeHolder[] { set(Type.VAR_INT, data.read(Type.INT, 0)), set(Type.UNSIGNED_BYTE, (short) animationType) });
        }
    });
    // 0xFA SC 0x3F (custom payload)
    addTranslator(0xFA, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x3F, new TypeHolder[] { set(Type.V1_7_STRING, data.read(Type.STRING, 0)), data.read(1) });
        }
    });
    // 0x83 SC 0x34 (map data)
    addTranslator(0x83, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x34, new TypeHolder[] { set(Type.VAR_INT, data.read(Type.SHORT, 1).intValue()), data.read(2) });
        }
    });
    // 0xD1 SC 0x3E (set team) // TODO: translate
    addTranslator(0xD1, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return cancel();
        }
    });
    // 0x2C SC 0x20 (entity attributes)
    addTranslator(0x2C, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x20, new TypeHolder[] { data.read(0), set(Type.V1_7_ENTITY_ATTRIBUTES, data.read(Type.V1_6_2_ENTITY_ATTRIBUTES, 1)) });
        }
    });
    // 0x67 SC 0x2F (inventory set slot)
    addTranslator(0x67, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ItemStack originalItem = data.read(Type.V1_3R_ITEM, 2);
            if (originalItem == null) {
                return PacketUtil.createPacket(0x2F, new TypeHolder[] { set(Type.UNSIGNED_BYTE, data.read(Type.BYTE, 0).shortValue()), data.read(1), data.read(2) });
            }
            ItemStack itemStack = itemRemapper.replaceItem(originalItem);
            return PacketUtil.createPacket(0x2F, new TypeHolder[] { set(Type.UNSIGNED_BYTE, data.read(Type.BYTE, 0).shortValue()), data.read(1), set(Type.V1_3R_ITEM, itemStack) });
        }
    });
    // 0x68 SC 0x30 (inventory window items)
    addTranslator(0x68, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ItemStack[] itemArray = data.read(Type.V1_3R_ITEM_ARRAY, 1);
            for (int i = 0; i < itemArray.length; i++) {
                ItemStack originalItem = itemArray[i];
                ItemStack item = originalItem;
                if (originalItem != null) {
                    item = itemRemapper.replaceItem(originalItem);
                }
                itemArray[i] = item;
            }
            return PacketUtil.createPacket(0x30, new TypeHolder[] { set(Type.UNSIGNED_BYTE, data.read(Type.BYTE, 0).shortValue()), set(Type.V1_3R_ITEM_ARRAY, itemArray) });
        }
    });
    // 0x3D SC 0x28 (door change -> effect)
    addTranslator(0x3D, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x28, new TypeHolder[] { data.read(0), data.read(1), set(Type.BYTE, data.read(Type.SHORT, 2).byteValue()), data.read(3), data.read(4), data.read(5) });
        }
    });
    // 0x84 SC 0x35 (update tile entity)
    addTranslator(0x84, ProtocolState.PLAY, PacketDirection.TO_CLIENT, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            final CompoundBinaryTag binaryTag = data.read(Type.COMPOUND_TAG, 4);
            @NotNull String value = binaryTag.getString("ExtraType");
            PacketData packet = PacketUtil.createPacket(0x35, new TypeHolder[] { data.read(0), data.read(1), data.read(2), set(Type.UNSIGNED_BYTE, data.read(Type.BYTE, 3).shortValue()), set(Type.COMPOUND_TAG, binaryTag) });
            if (!value.isEmpty()) {
                HeadConversion.convert(session, packet, value, getFrom());
                return cancel();
            }
            return packet;
        }
    });
    // 0xC8 SC 0x37 -> cancel (statistics)
    addTranslator(0xC8, -1, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x27 SC 0x1B (entity attach)
    addTranslator(0x27, 0x1B, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x69 SC 0x31 (update progress bar -> window property)
    addTranslator(0x69, 0x31, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x65 SC 0x2E (window close)
    addTranslator(0x65, 0x2E, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x29 SC 0x1D (entity effect)
    addTranslator(0x29, 0x1D, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x2A SC 0x1E (clear entity effect)
    addTranslator(0x2A, 0x1E, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x6A SC 0x32 (inventory transaction)
    addTranslator(0x6A, 0x32, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0xCA SC 0x39 (player abilities)
    addTranslator(0xCA, 0x39, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x2B SC 0x1F (set experience)
    addTranslator(0x2B, 0x1F, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x38 SC 0x26 (chunk bulk)
    addTranslator(0x38, 0x26, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x26 SC 0x1A (entity status)
    addTranslator(0x26, 0x1A, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x23 SC 0x19 (entity head look)
    addTranslator(0x23, 0x19, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x21 SC 0x17 (entity relative move look)
    addTranslator(0x21, 0x17, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x1E SC 0x14 (entity ground state)
    addTranslator(0x1E, 0x14, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x08 SC 0x06 (health update)
    addTranslator(0x08, 0x06, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x04 SC 0x03 (update time)
    addTranslator(0x04, 0x03, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x06 SC 0x05 (spawn position)
    addTranslator(0x06, 0x05, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x33 SC 0x21 (chunk data)
    addTranslator(0x33, 0x21, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x34 SC 0x22 (multi block change)
    addTranslator(0x34, 0x22, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x1F SC 0x15 (entity relative move)
    addTranslator(0x1F, 0x15, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x1C SC 0x12 (entity velocity)
    addTranslator(0x1C, 0x12, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x1D SC 0x13 (entity destroy)
    addTranslator(0x1D, 0x13, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x20 SC 0x16 (entity look)
    addTranslator(0x20, 0x16, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x22 SC 0x18 (entity teleport)
    addTranslator(0x22, 0x18, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x16 SC 0x0D (item collect)
    addTranslator(0x16, 0x0D, ProtocolState.PLAY, PacketDirection.TO_CLIENT);
    // 0x17 CS 0xFA (custom payload)
    addTranslator(0x17, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            String channel = data.read(Type.V1_7_STRING, 0);
            if (channel.equals("MC|AdvCmd")) {
                // TODO: fix command blocks
                return cancel();
            }
            return PacketUtil.createPacket(0xFA, new TypeHolder[] { set(Type.STRING, channel), data.read(1) });
        }
    });
    // 0x01 CS 0x03 (chat)
    addTranslator(0x01, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x03, new TypeHolder[] { set(Type.STRING, data.read(Type.V1_7_STRING, 0)) });
        }
    });
    // 0x16 CS 0xCD (client command)
    addTranslator(0x16, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            int status = data.read(Type.BYTE, 0);
            if (status == 0) {
                return PacketUtil.createPacket(0xCD, new TypeHolder[] { // perform respawn
                set(Type.BYTE, (byte) 1) });
            } else {
                return cancel();
            }
        }
    });
    // 0x02 SC 0x07 (use entity)
    addTranslator(0x02, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x07, new TypeHolder[] { set(Type.INT, 0), data.read(0), data.read(1) });
        }
    });
    // 0x14 CS 0xCB (tab complete)
    addTranslator(0x14, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0xCB, new TypeHolder[] { set(Type.STRING, data.read(Type.V1_7_STRING, 0)) });
        }
    });
    // 0x15 CS 0xCC (player settings)
    addTranslator(0x15, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0xCC, new TypeHolder[] { set(Type.STRING, data.read(Type.V1_7_STRING, 0)), data.read(1), data.read(2), data.read(4), data.read(5) });
        }
    });
    // 0x12 CS 0x82 (set sign text)
    addTranslator(0x12, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x82, new TypeHolder[] { data.read(0), data.read(1), data.read(2), set(Type.STRING, data.read(Type.V1_7_STRING, 3)), set(Type.STRING, data.read(Type.V1_7_STRING, 4)), set(Type.STRING, data.read(Type.V1_7_STRING, 5)), set(Type.STRING, data.read(Type.V1_7_STRING, 6)) });
        }
    });
    // 0x08 CS 0x0F (block placement)
    addTranslator(0x08, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x0F, new TypeHolder[] { data.read(0), data.read(1), data.read(2), set(Type.BYTE, data.read(Type.UNSIGNED_BYTE, 3).byteValue()), data.read(4), data.read(5), data.read(6), data.read(7) });
        }
    });
    // 0x07 CS 0x0E (block digging)
    addTranslator(0x07, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            return PacketUtil.createPacket(0x0E, new TypeHolder[] { set(Type.BYTE, data.read(Type.UNSIGNED_BYTE, 0).byteValue()), data.read(1), set(Type.BYTE, data.read(Type.UNSIGNED_BYTE, 2).byteValue()), data.read(3), set(Type.BYTE, data.read(Type.UNSIGNED_BYTE, 4).byteValue()) });
        }
    });
    // creative item get
    addTranslator(0x10, ProtocolState.PLAY, PacketDirection.TO_SERVER, new PacketTranslator() {

        @Override
        public PacketData translate(ServerSession session, PacketData data) {
            ItemStack item = data.read(Type.V1_3R_ITEM, 1);
            boolean notNull = item != null;
            if (notNull && !creativeTab.exists(item.getItemId())) {
                // replace all unknown items to stone
                item.setItemId(1);
                item.setData(0);
            }
            return PacketUtil.createPacket(0x6B, new TypeHolder[] { data.read(0), set(Type.V1_3R_ITEM, item) });
        }
    });
    // 0x0F CS 0x6A (confirm transaction)
    addTranslator(0x0F, 0x6A, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x0C CS 0x1B (steer vehicle / player input)
    addTranslator(0x0C, 0x1B, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x13 CS 0xCA (player abilities)
    addTranslator(0x13, 0xCA, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x11 CS 0x6C (enchant slot selection)
    addTranslator(0x11, 0x6C, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x09 CS 0x10 (held slot change)
    addTranslator(0x09, 0x10, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x03 CS 0x0A (player ground state)
    addTranslator(0x03, 0x0A, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x04 CS 0x0B (player position)
    addTranslator(0x04, 0x0B, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x05 CS 0x0C (player look)
    addTranslator(0x05, 0x0C, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x06 CS 0x0D (player position look)
    addTranslator(0x06, 0x0D, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x0A CS 0x12 (player animation)
    addTranslator(0x0A, 0x12, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x0D CS 0x65 (window close)
    addTranslator(0x0D, 0x65, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x0E CS 0x66 (click window)
    addTranslator(0x0E, 0x66, ProtocolState.PLAY, PacketDirection.TO_SERVER);
    // 0x0B CS 0x13 (entity action)
    addTranslator(0x0B, 0x13, ProtocolState.PLAY, PacketDirection.TO_SERVER);
}
Also used : ServerSession(com.github.dirtpowered.dirtmv.network.server.ServerSession) PacketTranslator(com.github.dirtpowered.dirtmv.data.translator.PacketTranslator) UserData(com.github.dirtpowered.dirtmv.data.user.UserData) ServerMotd(com.github.dirtpowered.dirtmv.network.versions.Release73To61.ping.ServerMotd) ServerPing(com.github.dirtpowered.dirtmv.network.versions.Release4To78.ping.ServerPing) TypeHolder(com.github.dirtpowered.dirtmv.data.protocol.TypeHolder) MinecraftVersion(com.github.dirtpowered.dirtmv.data.MinecraftVersion) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(com.github.dirtpowered.dirtmv.data.protocol.objects.ItemStack) WatchableObject(com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject) CompoundBinaryTag(net.kyori.adventure.nbt.CompoundBinaryTag) PacketData(com.github.dirtpowered.dirtmv.data.protocol.PacketData)

Example 4 with WatchableObject

use of com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject in project DirtMultiversion by DirtPowered.

the class V1_5RTo1_6RMetadataTransformer method transformMetadata.

@Override
public WatchableObject[] transformMetadata(SpawnableObject entityType, WatchableObject[] watchableObjects) {
    List<WatchableObject> newMetaData = new ArrayList<>();
    for (WatchableObject watchableObject : watchableObjects) {
        MetadataType type = watchableObject.getType();
        Object value = watchableObject.getValue();
        int index = watchableObject.getIndex();
        if (entityType.isLivingEntity()) {
            if (index == 8) {
                // potion color
                newMetaData.add(new WatchableObject(type, 7, value));
            } else if (index == 9) {
                // potion ambient
                newMetaData.add(new WatchableObject(type, 8, value));
            } else if (index == 10) {
                // arrow count in entity
                newMetaData.add(new WatchableObject(type, 9, value));
            } else if (index == 5) {
                // name tag
                newMetaData.add(new WatchableObject(type, 10, value));
            } else if (index == 6) {
                // name tag visibility
                newMetaData.add(new WatchableObject(type, 11, value));
            } else if (entityType == EntityType.WITHER | entityType == EntityType.ENDER_DRAGON) {
                if (index == 16) {
                    newMetaData.add(new WatchableObject(MetadataType.FLOAT, 6, ((Integer) value).floatValue()));
                } else {
                    newMetaData.add(watchableObject);
                }
            } else if (entityType == EntityType.WOLF) {
                if (index == 18) {
                    newMetaData.add(new WatchableObject(MetadataType.FLOAT, 18, ((Integer) value).floatValue()));
                } else {
                    newMetaData.add(watchableObject);
                }
            } else if (entityType == EntityType.HUMAN) {
                if (index == 17) {
                    // absorption amount
                    if (value instanceof Byte) {
                        newMetaData.add(new WatchableObject(MetadataType.FLOAT, 17, ((Byte) value).floatValue()));
                    } else if (value instanceof Integer) {
                        newMetaData.add(new WatchableObject(MetadataType.FLOAT, 17, ((Integer) value).floatValue()));
                    }
                } else {
                    newMetaData.add(watchableObject);
                }
            } else {
                newMetaData.add(watchableObject);
            }
        } else {
            newMetaData.add(watchableObject);
        }
    }
    if (newMetaData.isEmpty()) {
        List<WatchableObject> defaultMetadata = Arrays.asList(new WatchableObject(MetadataType.BYTE, 0, 0), new WatchableObject(MetadataType.SHORT, 1, 300));
        newMetaData.addAll(defaultMetadata);
    }
    return newMetaData.toArray(new WatchableObject[0]);
}
Also used : ArrayList(java.util.ArrayList) MetadataType(com.github.dirtpowered.dirtmv.data.protocol.objects.MetadataType) SpawnableObject(com.github.dirtpowered.dirtmv.data.entity.SpawnableObject) WatchableObject(com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject) WatchableObject(com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject)

Example 5 with WatchableObject

use of com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject in project DirtMultiversion by DirtPowered.

the class MetadataDataType method read.

@Override
public WatchableObject[] read(PacketInput packetInput) throws IOException {
    ArrayList<WatchableObject> dataMap = new ArrayList<>();
    for (byte b = packetInput.readByte(); b != 127; b = packetInput.readByte()) {
        MetadataType type = MetadataType.fromType((b & 224) >> 5);
        int index = b & 31;
        WatchableObject value = null;
        switch(type) {
            case BYTE:
                value = new WatchableObject(type, index, BaseProtocol.BYTE.read(packetInput));
                break;
            case SHORT:
                value = new WatchableObject(type, index, BaseProtocol.SHORT.read(packetInput));
                break;
            case INT:
                value = new WatchableObject(type, index, BaseProtocol.INT.read(packetInput));
                break;
            case FLOAT:
                value = new WatchableObject(type, index, BaseProtocol.FLOAT.read(packetInput));
                break;
            case STRING:
                if (getType() == Type.V1_7R_METADATA || getType() == Type.V1_8R_METADATA) {
                    value = new WatchableObject(type, index, V1_7_2RProtocol.STRING.read(packetInput));
                } else {
                    value = new WatchableObject(type, index, BaseProtocol.STRING.read(packetInput));
                }
                break;
            case ITEM:
                ItemStack itemStack;
                if (getType() == Type.V1_4R_METADATA || getType() == Type.V1_7R_METADATA) {
                    itemStack = V1_3_1RProtocol.ITEM.read(packetInput);
                } else if (getType() == Type.V1_8R_METADATA) {
                    itemStack = V1_8RProtocol.ITEM.read(packetInput);
                } else {
                    itemStack = V1_3BProtocol.ITEM.read(packetInput);
                }
                value = new WatchableObject(type, index, itemStack);
                break;
            case POSITION:
                int x = packetInput.readInt();
                int y = packetInput.readInt();
                int z = packetInput.readInt();
                value = new WatchableObject(type, index, new BlockLocation(x, y, z));
                break;
            case ROTATION:
                float rX = packetInput.readFloat();
                float rY = packetInput.readFloat();
                float rZ = packetInput.readFloat();
                value = new WatchableObject(type, index, new Rotation(rX, rY, rZ));
                break;
        }
        dataMap.add(value);
    }
    return dataMap.toArray(new WatchableObject[0]);
}
Also used : ArrayList(java.util.ArrayList) MetadataType(com.github.dirtpowered.dirtmv.data.protocol.objects.MetadataType) ItemStack(com.github.dirtpowered.dirtmv.data.protocol.objects.ItemStack) BlockLocation(com.github.dirtpowered.dirtmv.data.protocol.objects.BlockLocation) WatchableObject(com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject) Rotation(com.github.dirtpowered.dirtmv.data.protocol.objects.Rotation)

Aggregations

WatchableObject (com.github.dirtpowered.dirtmv.data.protocol.objects.WatchableObject)8 TypeHolder (com.github.dirtpowered.dirtmv.data.protocol.TypeHolder)5 ItemStack (com.github.dirtpowered.dirtmv.data.protocol.objects.ItemStack)5 PacketData (com.github.dirtpowered.dirtmv.data.protocol.PacketData)4 MetadataType (com.github.dirtpowered.dirtmv.data.protocol.objects.MetadataType)4 PacketTranslator (com.github.dirtpowered.dirtmv.data.translator.PacketTranslator)4 ServerSession (com.github.dirtpowered.dirtmv.network.server.ServerSession)4 ArrayList (java.util.ArrayList)4 SpawnableObject (com.github.dirtpowered.dirtmv.data.entity.SpawnableObject)3 Motion (com.github.dirtpowered.dirtmv.data.protocol.objects.Motion)3 List (java.util.List)3 SneakyThrows (lombok.SneakyThrows)3 EntityType (com.github.dirtpowered.dirtmv.data.entity.EntityType)2 BlockLocation (com.github.dirtpowered.dirtmv.data.protocol.objects.BlockLocation)2 Location (com.github.dirtpowered.dirtmv.data.protocol.objects.Location)2 Rotation (com.github.dirtpowered.dirtmv.data.protocol.objects.Rotation)2 ProtocolStorage (com.github.dirtpowered.dirtmv.data.user.ProtocolStorage)2 CompoundBinaryTag (net.kyori.adventure.nbt.CompoundBinaryTag)2 Configuration (com.github.dirtpowered.dirtmv.api.Configuration)1 MinecraftVersion (com.github.dirtpowered.dirtmv.data.MinecraftVersion)1