Search in sources :

Example 11 with BlockStorage

use of com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage in project ViaVersion by ViaVersion.

the class Protocol1_13To1_12_2 method init.

@Override
public void init(UserConnection userConnection) {
    userConnection.addEntityTracker(this.getClass(), new EntityTrackerBase(userConnection, Entity1_13Types.EntityType.PLAYER));
    userConnection.put(new TabCompleteTracker());
    if (!userConnection.has(ClientWorld.class))
        userConnection.put(new ClientWorld(userConnection));
    userConnection.put(new BlockStorage());
    if (Via.getConfig().isServersideBlockConnections()) {
        if (Via.getManager().getProviders().get(BlockConnectionProvider.class) instanceof PacketBlockConnectionProvider) {
            userConnection.put(new BlockConnectionStorage());
        }
    }
}
Also used : BlockStorage(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage) PacketBlockConnectionProvider(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider) BlockConnectionProvider(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider) PacketBlockConnectionProvider(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider) TabCompleteTracker(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.TabCompleteTracker) ClientWorld(com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld) EntityTrackerBase(com.viaversion.viaversion.data.entity.EntityTrackerBase) BlockConnectionStorage(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockConnectionStorage)

Example 12 with BlockStorage

use of com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage in project Geyser by GeyserMC.

the class GeyserSpigot1_12WorldManager method getBlockNetworkId.

@Override
@SuppressWarnings("deprecation")
public int getBlockNetworkId(Player player, Block block, int x, int y, int z) {
    // Get block entity storage
    BlockStorage storage = Via.getManager().getConnectionManager().getConnectedClient(player.getUniqueId()).get(BlockStorage.class);
    // Black magic that gets the old block state ID
    int oldBlockId = (block.getType().getId() << 4) | (block.getData() & 0xF);
    return getLegacyBlock(storage, oldBlockId, x, y, z);
}
Also used : BlockStorage(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage)

Example 13 with BlockStorage

use of com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage in project ViaVersion by ViaVersion.

the class BannerHandler method transform.

@Override
public int transform(UserConnection user, CompoundTag tag) {
    BlockStorage storage = user.get(BlockStorage.class);
    Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
    if (!storage.contains(position)) {
        Via.getPlatform().getLogger().warning("Received an banner color update packet, but there is no banner! O_o " + tag);
        return -1;
    }
    int blockId = storage.get(position).getOriginal();
    Tag base = tag.get("Base");
    int color = 0;
    if (base != null) {
        color = ((NumberTag) tag.get("Base")).asInt();
    }
    // Standing banner
    if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
        blockId += ((15 - color) * 16);
    // Wall banner
    } else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP) {
        blockId += ((15 - color) * 4);
    } else {
        Via.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
    }
    if (tag.get("Patterns") instanceof ListTag) {
        for (Tag pattern : (ListTag) tag.get("Patterns")) {
            if (pattern instanceof CompoundTag) {
                Tag c = ((CompoundTag) pattern).get("Color");
                if (c instanceof IntTag) {
                    // Invert color id
                    ((IntTag) c).setValue(15 - (int) c.getValue());
                }
            }
        }
    }
    Tag name = tag.get("CustomName");
    if (name instanceof StringTag) {
        ((StringTag) name).setValue(ChatRewriter.legacyTextToJsonString(((StringTag) name).getValue()));
    }
    return blockId;
}
Also used : StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) BlockStorage(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage) Position(com.viaversion.viaversion.api.minecraft.Position) StringTag(com.github.steveice10.opennbt.tag.builtin.StringTag) Tag(com.github.steveice10.opennbt.tag.builtin.Tag) ListTag(com.github.steveice10.opennbt.tag.builtin.ListTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) NumberTag(com.github.steveice10.opennbt.tag.builtin.NumberTag) IntTag(com.github.steveice10.opennbt.tag.builtin.IntTag) ListTag(com.github.steveice10.opennbt.tag.builtin.ListTag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) IntTag(com.github.steveice10.opennbt.tag.builtin.IntTag)

Example 14 with BlockStorage

use of com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage in project ViaVersion by ViaVersion.

the class SkullHandler method transform.

@Override
public int transform(UserConnection user, CompoundTag tag) {
    BlockStorage storage = user.get(BlockStorage.class);
    Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));
    if (!storage.contains(position)) {
        Via.getPlatform().getLogger().warning("Received an head update packet, but there is no head! O_o " + tag);
        return -1;
    }
    int id = storage.get(position).getOriginal();
    if (id >= SKULL_WALL_START && id <= SKULL_END) {
        Tag skullType = tag.get("SkullType");
        if (skullType != null) {
            id += ((NumberTag) tag.get("SkullType")).asInt() * 20;
        }
        if (tag.contains("Rot")) {
            id += ((NumberTag) tag.get("Rot")).asInt();
        }
    } else {
        Via.getPlatform().getLogger().warning("Why does this block have the skull block entity? " + tag);
        return -1;
    }
    return id;
}
Also used : BlockStorage(com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage) Position(com.viaversion.viaversion.api.minecraft.Position) NumberTag(com.github.steveice10.opennbt.tag.builtin.NumberTag) Tag(com.github.steveice10.opennbt.tag.builtin.Tag) CompoundTag(com.github.steveice10.opennbt.tag.builtin.CompoundTag) NumberTag(com.github.steveice10.opennbt.tag.builtin.NumberTag)

Example 15 with BlockStorage

use of com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage in project DirtMultiversion by DirtPowered.

the class ProtocolBeta17to14 method onConnect.

@Override
public void onConnect(ServerSession session) {
    ProtocolStorage storage = session.getStorage();
    storage.set(BlockStorage.class, new BlockStorage(MinecraftVersion.B1_7_3));
    storage.set(PlayerTabListCache.class, new PlayerTabListCache());
    storage.set(KeepAliveTask.class, new KeepAliveTask(session));
    storage.set(PlayerHealthTracker.class, new PlayerHealthTracker());
    session.broadcastPacket(createTabEntryPacket(session.getUserData().getUsername(), true), getFrom());
}
Also used : BlockStorage(com.github.dirtpowered.dirtmv.network.versions.Beta17To14.storage.BlockStorage) ProtocolStorage(com.github.dirtpowered.dirtmv.data.user.ProtocolStorage) KeepAliveTask(com.github.dirtpowered.dirtmv.network.versions.Beta17To14.other.KeepAliveTask) PlayerHealthTracker(com.github.dirtpowered.dirtmv.network.versions.Beta17To14.other.PlayerHealthTracker)

Aggregations

BlockStorage (com.github.dirtpowered.dirtmv.network.versions.Beta17To14.storage.BlockStorage)9 BlockStorage (com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage)7 ProtocolStorage (com.github.dirtpowered.dirtmv.data.user.ProtocolStorage)6 Position (com.viaversion.viaversion.api.minecraft.Position)5 ArrayList (java.util.ArrayList)5 PacketData (com.github.dirtpowered.dirtmv.data.protocol.PacketData)4 BlockLocation (com.github.dirtpowered.dirtmv.data.protocol.objects.BlockLocation)4 PacketTranslator (com.github.dirtpowered.dirtmv.data.translator.PacketTranslator)4 ServerSession (com.github.dirtpowered.dirtmv.network.server.ServerSession)4 CompoundTag (com.github.steveice10.opennbt.tag.builtin.CompoundTag)4 NumberTag (com.github.steveice10.opennbt.tag.builtin.NumberTag)4 Tag (com.github.steveice10.opennbt.tag.builtin.Tag)4 List (java.util.List)4 TypeHolder (com.github.dirtpowered.dirtmv.data.protocol.TypeHolder)3 V1_2Chunk (com.github.dirtpowered.dirtmv.data.protocol.objects.V1_2Chunk)3 V1_2MultiBlockArray (com.github.dirtpowered.dirtmv.data.protocol.objects.V1_2MultiBlockArray)3 ClientWorld (com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 DataInput (java.io.DataInput)3 DataInputStream (java.io.DataInputStream)3