From 4a60f0f9033453165bc84f3d221d46f117867219 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Wed, 26 May 2021 12:57:48 +0200 Subject: [PATCH] Update VV usage --- build.gradle.kts | 1 + .../packets/EntityPackets1_11.java | 9 +++------ .../packets/EntityPackets1_13.java | 16 +++++----------- .../packets/EntityPackets1_14.java | 10 +++++----- .../packets/EntityPackets1_16.java | 3 +-- .../packets/EntityPackets1_10.java | 3 +-- 6 files changed, 16 insertions(+), 26 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b0d47828..2c0d88c2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,6 +27,7 @@ subprojects { } withType { options.encoding = Charsets.UTF_8.name() + (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet") } withType { options.encoding = Charsets.UTF_8.name() diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java index 3249deee..1fa524e3 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/packets/EntityPackets1_11.java @@ -238,8 +238,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter bitmask |= 0x04; } - meta.setMetaType(MetaType1_9.Byte); - meta.setValue((byte) bitmask); + meta.setTypeAndValue(MetaType1_9.Byte, (byte) bitmask); }); // Handle skeleton swing @@ -270,8 +269,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter // Handle Evocation Illager filter().type(Entity1_11Types.EntityType.EVOCATION_ILLAGER).index(12).handler((event, meta) -> { event.setIndex(13); - meta.setMetaType(MetaType1_9.VarInt); - meta.setValue(((Byte) meta.getValue()).intValue()); // Change the profession for the states + meta.setTypeAndValue(MetaType1_9.VarInt, ((Byte) meta.getValue()).intValue()); // Change the profession for the states }); // Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ): @@ -282,8 +280,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter // Handle VindicationIllager filter().type(Entity1_11Types.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> { event.setIndex(13); - meta.setMetaType(MetaType1_9.VarInt); - meta.setValue(((Number) meta.getValue()).intValue() == 1 ? 2 : 4); + meta.setTypeAndValue(MetaType1_9.VarInt, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4); }); /* diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java index d732231d..1948eeac 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/packets/EntityPackets1_13.java @@ -304,25 +304,21 @@ public class EntityPackets1_13 extends LegacyEntityRewriter { int typeId = meta.metaType().typeId(); - // Rewrite optional chat to chat + // Rewrite optional chat to string if (typeId == 5) { - meta.setMetaType(MetaType1_12.String); - - if (meta.getValue() == null) { - meta.setValue(""); - } + // Json -> Legacy is done below + meta.setTypeAndValue(MetaType1_12.String, meta.getValue() != null ? meta.getValue().toString() : ""); } // Rewrite items else if (typeId == 6) { - meta.setMetaType(MetaType1_12.Slot); Item item = (Item) meta.getValue(); - meta.setValue(protocol.getBlockItemPackets().handleItemToClient(item)); + meta.setTypeAndValue(MetaType1_12.Slot, protocol.getBlockItemPackets().handleItemToClient(item)); } // Discontinue particles else if (typeId == 15) { - meta.setMetaType(MetaType1_12.Discontinued); + event.cancel(); } // Rewrite to 1.12 ids @@ -368,9 +364,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter { - meta.setValue(15 - (int) meta.getValue()); - }); // Rewrite AreaEffectCloud diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java index cfd50a83..932ec9d9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java @@ -410,7 +410,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { meta.setMetaType(MetaType1_13_2.VarInt); Integer value = (Integer) meta.getValue(); - if (value == null) meta.setValue(0); + if (value == null) { + meta.setValue(0); + } }); filter().filterFamily(Entity1_14Types.ABSTRACT_ARROW).removeIndex(9); @@ -419,8 +421,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { VillagerData villagerData = (VillagerData) meta.getValue(); - meta.setValue(villagerDataToProfession(villagerData)); - meta.setMetaType(MetaType1_13_2.VarInt); + meta.setTypeAndValue(MetaType1_13_2.VarInt, villagerDataToProfession(villagerData)); if (meta.id() == 16) { event.setIndex(15); // decreased by 2 again in one of the following handlers } @@ -481,8 +482,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter { event.setIndex(15); - meta.setMetaType(MetaType1_13_2.VarInt); - meta.setValue(0); + meta.setTypeAndValue(MetaType1_13_2.VarInt, 0); }); filter().type(Entity1_14Types.CAT).handler((event, meta) -> { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java index d45eda99..c92f5c05 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/packets/EntityPackets1_16.java @@ -276,8 +276,7 @@ public class EntityPackets1_16 extends EntityRewriter { filter().type(Entity1_16Types.STRIDER).index(15).handler((event, meta) -> { boolean baby = meta.value(); - meta.setValue(baby ? 1 : 3); - meta.setMetaType(MetaType1_14.VarInt); + meta.setTypeAndValue(MetaType1_14.VarInt, baby ? 1 : 3); }); filter().type(Entity1_16Types.STRIDER).cancel(16); filter().type(Entity1_16Types.STRIDER).cancel(17); diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/EntityPackets1_10.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/EntityPackets1_10.java index 25f7481b..6b1061c0 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/EntityPackets1_10.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_9_4to1_10/packets/EntityPackets1_10.java @@ -163,8 +163,7 @@ public class EntityPackets1_10 extends LegacyEntityRewriter filter().type(Entity1_10Types.EntityType.POLAR_BEAR).index(13).handler((event, meta) -> { boolean b = (boolean) meta.getValue(); - meta.setMetaType(MetaType1_9.Byte); - meta.setValue(b ? (byte) (14 & 0x0F) : (byte) (0)); + meta.setTypeAndValue(MetaType1_9.Byte, b ? (byte) (14 & 0x0F) : (byte) (0)); });