Add missing tags for client sending, cleanup

This commit is contained in:
KennyTV 2020-04-03 17:29:40 +02:00
parent cae6addf26
commit 95db675de5
2 changed files with 13 additions and 45 deletions

View File

@ -148,7 +148,7 @@ public class Protocol1_14To1_13_2 extends Protocol {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int blockTagsSize = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, blockTagsSize + 5); // block tags
wrapper.write(Type.VAR_INT, blockTagsSize + 6); // block tags
for (int i = 0; i < blockTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
@ -174,6 +174,8 @@ public class Protocol1_14To1_13_2 extends Protocol {
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);
wrapper.write(Type.VAR_INT, itemTagsSize + 2); // item tags
for (int i = 0; i < itemTagsSize; i++) {

View File

@ -6,6 +6,8 @@ import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.TagRewriter;
import us.myles.ViaVersion.api.rewriters.TagType;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
@ -113,50 +115,14 @@ public class Protocol1_15To1_14_4 extends Protocol {
});
// Tags
registerOutgoing(State.PLAY, 0x5B, 0x5C, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
//TODO do the new (flower) tags have to be sent?
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++) {
blockIds[j] = getNewBlockId(blockIds[j]);
}
}
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++) {
itemIds[j] = InventoryPackets.getNewItemId(itemIds[j]);
}
}
int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags
for (int i = 0; i < fluidTagsSize; i++) {
wrapper.passthrough(Type.STRING);
wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
}
int entityTagsSize = wrapper.passthrough(Type.VAR_INT); // entity tags
for (int i = 0; i < entityTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] entitIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < entitIds.length; j++) {
entitIds[j] = EntityPackets.getNewEntityId(entitIds[j]);
}
}
}
});
}
});
TagRewriter tagRewriter = new TagRewriter(this, Protocol1_15To1_14_4::getNewBlockId, InventoryPackets::getNewItemId, EntityPackets::getNewEntityId);
int[] shulkerBoxes = new int[17];
int shulkerBoxOffset = 501;
for (int i = 0; i < 17; i++) {
shulkerBoxes[i] = shulkerBoxOffset + i;
}
tagRewriter.addTag(TagType.BLOCK, "minecraft:shulker_boxes", shulkerBoxes);
tagRewriter.register(0x5B, 0x5C);
registerOutgoing(State.PLAY, 0x08, 0x09);
registerOutgoing(State.PLAY, 0x09, 0x0A);