use of com.viaversion.viaversion.api.type.types.version.Types1_18 in project ViaBackwards by ViaVersion.
the class EntityPackets1_18 method registerPackets.
@Override
protected void registerPackets() {
registerMetadataRewriter(ClientboundPackets1_18.ENTITY_METADATA, Types1_18.METADATA_LIST, Types1_17.METADATA_LIST);
protocol.registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {
// Entity ID
map(Type.INT);
// Hardcore
map(Type.BOOLEAN);
// Gamemode
map(Type.UNSIGNED_BYTE);
// Previous Gamemode
map(Type.BYTE);
// Worlds
map(Type.STRING_ARRAY);
// Dimension registry
map(Type.NBT);
// Current dimension data
map(Type.NBT);
// World
map(Type.STRING);
// Seed
map(Type.LONG);
// Max players
map(Type.VAR_INT);
// Chunk radius
map(Type.VAR_INT);
// Read simulation distance
read(Type.VAR_INT);
handler(worldDataTrackerHandler(1));
handler(wrapper -> {
final CompoundTag registry = wrapper.get(Type.NBT, 0);
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
final ListTag biomes = biomeRegistry.get("value");
for (final Tag biome : biomes.getValue()) {
final CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
final StringTag category = biomeCompound.get("category");
if (category.getValue().equals("mountain")) {
category.setValue("extreme_hills");
}
// The client just needs something
biomeCompound.put("depth", new FloatTag(0.125F));
biomeCompound.put("scale", new FloatTag(0.05F));
}
// Track amount of biomes sent
tracker(wrapper.user()).setBiomesSent(biomes.size());
});
}
});
protocol.registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketRemapper() {
@Override
public void registerMap() {
// Dimension data
map(Type.NBT);
// World
map(Type.STRING);
handler(worldDataTrackerHandler(0));
}
});
}
use of com.viaversion.viaversion.api.type.types.version.Types1_18 in project ViaVersion by ViaVersion.
the class EntityPackets method registerPackets.
@Override
public void registerPackets() {
registerMetadataRewriter(ClientboundPackets1_17_1.ENTITY_METADATA, Types1_17.METADATA_LIST, Types1_18.METADATA_LIST);
protocol.registerClientbound(ClientboundPackets1_17_1.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {
// Entity ID
map(Type.INT);
// Hardcore
map(Type.BOOLEAN);
// Gamemode
map(Type.UNSIGNED_BYTE);
// Previous Gamemode
map(Type.BYTE);
// World List
map(Type.STRING_ARRAY);
// Registry
map(Type.NBT);
// Current dimension data
map(Type.NBT);
// World
map(Type.STRING);
// Seed
map(Type.LONG);
// Max players
map(Type.VAR_INT);
handler(wrapper -> {
int chunkRadius = wrapper.passthrough(Type.VAR_INT);
// Simulation distance
wrapper.write(Type.VAR_INT, chunkRadius);
});
handler(worldDataTrackerHandler(1));
handler(biomeSizeTracker());
}
});
protocol.registerClientbound(ClientboundPackets1_17_1.RESPAWN, new PacketRemapper() {
@Override
public void registerMap() {
// Current dimension data
map(Type.NBT);
// World
map(Type.STRING);
handler(wrapper -> {
final String world = wrapper.get(Type.STRING, 0);
final EntityTracker tracker = tracker(wrapper.user());
if (!world.equals(tracker.currentWorld())) {
wrapper.user().get(ChunkLightStorage.class).clear();
}
});
handler(worldDataTrackerHandler(0));
}
});
}
Aggregations