use of com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.data.CommandRewriter1_14 in project ViaBackwards by ViaVersion.
the class Protocol1_13_2To1_14 method registerPackets.
@Override
protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_14To1_13_2.class, MAPPINGS::load);
translatableRewriter.registerBossBar(ClientboundPackets1_14.BOSSBAR);
translatableRewriter.registerChatMessage(ClientboundPackets1_14.CHAT_MESSAGE);
translatableRewriter.registerCombatEvent(ClientboundPackets1_14.COMBAT_EVENT);
translatableRewriter.registerDisconnect(ClientboundPackets1_14.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_14.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_14.TITLE);
translatableRewriter.registerPing();
new CommandRewriter1_14(this).registerDeclareCommands(ClientboundPackets1_14.DECLARE_COMMANDS);
blockItemPackets = new BlockItemPackets1_14(this);
blockItemPackets.register();
entityRewriter.register();
new PlayerPackets1_14(this).register();
new SoundPackets1_14(this).register();
new StatisticsRewriter(this).register(ClientboundPackets1_14.STATISTICS);
cancelClientbound(ClientboundPackets1_14.UPDATE_VIEW_POSITION);
cancelClientbound(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE);
cancelClientbound(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
registerClientbound(ClientboundPackets1_14.TAGS, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int blockTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < blockTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < blockIds.length; j++) {
int id = blockIds[j];
// Ignore new blocktags
int blockId = getMappingData().getNewBlockId(id);
blockIds[j] = blockId;
}
}
int itemTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < itemTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < itemIds.length; j++) {
int itemId = itemIds[j];
// Ignore new itemtags
int oldId = getMappingData().getItemMappings().get(itemId);
itemIds[j] = oldId;
}
}
// fluid tags
int fluidTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < fluidTagsSize; i++) {
wrapper.passthrough(Type.STRING);
wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
}
// Eat entity tags
int entityTagsSize = wrapper.read(Type.VAR_INT);
for (int i = 0; i < entityTagsSize; i++) {
wrapper.read(Type.STRING);
wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE);
}
}
});
}
});
registerClientbound(ClientboundPackets1_14.UPDATE_LIGHT, null, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int x = wrapper.read(Type.VAR_INT);
int z = wrapper.read(Type.VAR_INT);
int skyLightMask = wrapper.read(Type.VAR_INT);
int blockLightMask = wrapper.read(Type.VAR_INT);
int emptySkyLightMask = wrapper.read(Type.VAR_INT);
int emptyBlockLightMask = wrapper.read(Type.VAR_INT);
byte[][] skyLight = new byte[16][];
// we don't need void and +256 light
if (isSet(skyLightMask, 0)) {
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
}
for (int i = 0; i < 16; i++) {
if (isSet(skyLightMask, i + 1)) {
skyLight[i] = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
} else if (isSet(emptySkyLightMask, i + 1)) {
skyLight[i] = ChunkLightStorage.EMPTY_LIGHT;
}
}
if (isSet(skyLightMask, 17)) {
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
}
byte[][] blockLight = new byte[16][];
if (isSet(blockLightMask, 0)) {
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
}
for (int i = 0; i < 16; i++) {
if (isSet(blockLightMask, i + 1)) {
blockLight[i] = wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
} else if (isSet(emptyBlockLightMask, i + 1)) {
blockLight[i] = ChunkLightStorage.EMPTY_LIGHT;
}
}
if (isSet(blockLightMask, 17)) {
wrapper.read(Type.BYTE_ARRAY_PRIMITIVE);
}
// TODO Soft memory leak: Don't store light if chunk is already loaded
wrapper.user().get(ChunkLightStorage.class).setStoredLight(skyLight, blockLight, x, z);
wrapper.cancel();
}
private boolean isSet(int mask, int i) {
return (mask & (1 << i)) != 0;
}
});
}
});
}
use of com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.data.CommandRewriter1_14 in project ViaVersion by ViaVersion.
the class Protocol1_14To1_13_2 method registerPackets.
@Override
protected void registerPackets() {
metadataRewriter.register();
itemRewriter.register();
EntityPackets.register(this);
WorldPackets.register(this);
PlayerPackets.register(this);
new SoundRewriter(this).registerSound(ClientboundPackets1_13.SOUND);
new StatisticsRewriter(this).register(ClientboundPackets1_13.STATISTICS);
ComponentRewriter componentRewriter = new ComponentRewriter1_14(this);
componentRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE);
CommandRewriter1_14 commandRewriter = new CommandRewriter1_14(this);
commandRewriter.registerDeclareCommands(ClientboundPackets1_13.DECLARE_COMMANDS);
registerClientbound(ClientboundPackets1_13.TAGS, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int blockTagsSize = wrapper.read(Type.VAR_INT);
// block tags
wrapper.write(Type.VAR_INT, blockTagsSize + 6);
for (int i = 0; i < blockTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < blockIds.length; j++) {
blockIds[j] = getMappingData().getNewBlockId(blockIds[j]);
}
}
// Minecraft crashes if we not send signs tags
wrapper.write(Type.STRING, "minecraft:signs");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] { getMappingData().getNewBlockId(150), getMappingData().getNewBlockId(155) });
wrapper.write(Type.STRING, "minecraft:wall_signs");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] { getMappingData().getNewBlockId(155) });
wrapper.write(Type.STRING, "minecraft:standing_signs");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] { getMappingData().getNewBlockId(150) });
// Fences and walls tags - used for block connections
wrapper.write(Type.STRING, "minecraft:fences");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] { 189, 248, 472, 473, 474, 475 });
wrapper.write(Type.STRING, "minecraft:walls");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] { 271, 272 });
wrapper.write(Type.STRING, "minecraft:wooden_fences");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] { 189, 472, 473, 474, 475 });
int itemTagsSize = wrapper.read(Type.VAR_INT);
// item tags
wrapper.write(Type.VAR_INT, itemTagsSize + 2);
for (int i = 0; i < itemTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < itemIds.length; j++) {
itemIds[j] = getMappingData().getNewItemId(itemIds[j]);
}
}
// Should fix fuel shift clicking
wrapper.write(Type.STRING, "minecraft:signs");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] { getMappingData().getNewItemId(541) });
// Arrows tag (used by bow)
wrapper.write(Type.STRING, "minecraft:arrows");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] { 526, 825, 826 });
// fluid tags
int fluidTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < fluidTagsSize; i++) {
wrapper.passthrough(Type.STRING);
wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
}
// new entity tags - do we need to send this?
wrapper.write(Type.VAR_INT, 0);
}
});
}
});
// Set Difficulty packet added in 19w11a
cancelServerbound(ServerboundPackets1_14.SET_DIFFICULTY);
// Lock Difficulty packet added in 19w11a
cancelServerbound(ServerboundPackets1_14.LOCK_DIFFICULTY);
// Unknown packet added in 19w13a
cancelServerbound(ServerboundPackets1_14.UPDATE_JIGSAW_BLOCK);
}
Aggregations