use of com.viaversion.viaversion.rewriter.TagRewriter in project ViaVersion by ViaVersion.
the class Protocol1_18To1_17_1 method registerPackets.
@Override
protected void registerPackets() {
entityRewriter.register();
itemRewriter.register();
WorldPackets.register(this);
final SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerSound(ClientboundPackets1_17_1.SOUND);
soundRewriter.registerSound(ClientboundPackets1_17_1.ENTITY_SOUND);
final TagRewriter tagRewriter = new TagRewriter(this);
tagRewriter.registerGeneric(ClientboundPackets1_17_1.TAGS);
tagRewriter.addEmptyTags(RegistryType.BLOCK, "minecraft:lava_pool_stone_cannot_replace", "minecraft:big_dripleaf_placeable", "minecraft:wolves_spawnable_on", "minecraft:rabbits_spawnable_on", "minecraft:polar_bears_spawnable_on_in_frozen_ocean", "minecraft:parrots_spawnable_on", "minecraft:mooshrooms_spawnable_on", "minecraft:goats_spawnable_on", "minecraft:foxes_spawnable_on", "minecraft:axolotls_spawnable_on", "minecraft:animals_spawnable_on", "minecraft:azalea_grows_on", "minecraft:azalea_root_replaceable", "minecraft:replaceable_plants", "minecraft:terracotta");
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:dirt", "minecraft:terracotta");
new StatisticsRewriter(this).register(ClientboundPackets1_17_1.STATISTICS);
registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketRemapper() {
@Override
public void registerMap() {
// Language
map(Type.STRING);
// View distance
map(Type.BYTE);
// Chat visibility
map(Type.VAR_INT);
// Chat colors
map(Type.BOOLEAN);
// Model customization
map(Type.UNSIGNED_BYTE);
// Main hand
map(Type.VAR_INT);
// Text filtering enabled
map(Type.BOOLEAN);
// Allow listing in server list preview
read(Type.BOOLEAN);
}
});
}
use of com.viaversion.viaversion.rewriter.TagRewriter in project ViaVersion by ViaVersion.
the class Protocol1_13_1To1_13 method registerPackets.
@Override
protected void registerPackets() {
entityRewriter.register();
itemRewriter.register();
EntityPackets.register(this);
WorldPackets.register(this);
registerServerbound(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {
@Override
public String transform(PacketWrapper wrapper, String inputValue) {
// 1.13 starts sending slash at start, so we remove it for compatibility
return inputValue.startsWith("/") ? inputValue.substring(1) : inputValue;
}
});
}
});
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.FLAT_ITEM);
map(Type.BOOLEAN);
handler(wrapper -> {
Item item = wrapper.get(Type.FLAT_ITEM, 0);
itemRewriter.handleItemToServer(item);
});
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int hand = wrapper.read(Type.VAR_INT);
if (hand == 1) {
wrapper.cancel();
}
}
});
}
});
registerClientbound(ClientboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
@Override
public void registerMap() {
// Transaction id
map(Type.VAR_INT);
// Start
map(Type.VAR_INT);
// Length
map(Type.VAR_INT);
// Count
map(Type.VAR_INT);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int start = wrapper.get(Type.VAR_INT, 1);
// Offset by +1 to take into account / at beginning
wrapper.set(Type.VAR_INT, 1, start + 1);
// Passthrough suggestions
int count = wrapper.get(Type.VAR_INT, 3);
for (int i = 0; i < count; i++) {
wrapper.passthrough(Type.STRING);
boolean hasTooltip = wrapper.passthrough(Type.BOOLEAN);
if (hasTooltip) {
// JSON Tooltip
wrapper.passthrough(Type.STRING);
}
}
}
});
}
});
registerClientbound(ClientboundPackets1_13.BOSSBAR, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UUID);
map(Type.VAR_INT);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int action = wrapper.get(Type.VAR_INT, 0);
if (action == 0) {
wrapper.passthrough(Type.COMPONENT);
wrapper.passthrough(Type.FLOAT);
wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.VAR_INT);
short flags = wrapper.read(Type.BYTE);
if ((flags & 0x02) != 0)
flags |= 0x04;
wrapper.write(Type.UNSIGNED_BYTE, flags);
}
}
});
}
});
new TagRewriter(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM);
new StatisticsRewriter(this).register(ClientboundPackets1_13.STATISTICS);
}
Aggregations