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());
}
}
}
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);
}
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;
}
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;
}
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());
}
Aggregations