diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_13.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_13.java index 7295201fe..d3594150f 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_13.java @@ -4,7 +4,7 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import us.myles.ViaVersion.api.minecraft.metadata.MetaType; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; +import us.myles.ViaVersion.api.type.types.version.Types1_13; @RequiredArgsConstructor @Getter @@ -24,7 +24,7 @@ public enum MetaType1_13 implements MetaType { OptUUID(12, Type.OPTIONAL_UUID), BlockID(13, Type.VAR_INT), NBTTag(14, Type.NBT), - PARTICLE(15, Protocol1_13To1_12_2.PARTICLE_TYPE), + PARTICLE(15, Types1_13.PARTICLE), Discontinued(99, null); private final int typeID; diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_13_2.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_13_2.java index a9646a8d0..e1b9fefa4 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_13_2.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_13_2.java @@ -4,7 +4,7 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import us.myles.ViaVersion.api.minecraft.metadata.MetaType; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1; +import us.myles.ViaVersion.api.type.types.version.Types1_13_2; @RequiredArgsConstructor @Getter @@ -24,7 +24,7 @@ public enum MetaType1_13_2 implements MetaType { OptUUID(12, Type.OPTIONAL_UUID), BlockID(13, Type.VAR_INT), NBTTag(14, Type.NBT), - PARTICLE(15, Protocol1_13_2To1_13_1.PARTICLE_TYPE), + PARTICLE(15, Types1_13_2.PARTICLE), Discontinued(99, null); private final int typeID; diff --git a/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_14.java b/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_14.java index 86a6418bb..e268c6555 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_14.java +++ b/common/src/main/java/us/myles/ViaVersion/api/minecraft/metadata/types/MetaType1_14.java @@ -4,7 +4,7 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import us.myles.ViaVersion.api.minecraft.metadata.MetaType; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1; +import us.myles.ViaVersion.api.type.types.version.Types1_14; @RequiredArgsConstructor @Getter @@ -24,7 +24,7 @@ public enum MetaType1_14 implements MetaType { OptUUID(12, Type.OPTIONAL_UUID), BlockID(13, Type.VAR_INT), NBTTag(14, Type.NBT), - PARTICLE(15, Protocol1_13_2To1_13_1.PARTICLE_TYPE), + PARTICLE(15, Types1_14.PARTICLE), VillagerData(16, Type.VILLAGER_DATA), OptVarInt(17, Type.OPTIONAL_VAR_INT), Pose(18, Type.VAR_INT), diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index 0cf8bef8b..c50c6ed0f 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -77,7 +77,7 @@ public class ProtocolVersion { register(v1_14_2 = new ProtocolVersion(485, "1.14.2")); register(v1_14_3 = new ProtocolVersion(490, "1.14.3")); register(v1_14_4 = new ProtocolVersion(498, "1.14.4")); - register(v1_15 = new ProtocolVersion(564, "1.15")); + register(v1_15 = new ProtocolVersion(565, "1.15")); register(unknown = new ProtocolVersion(-1, "UNKNOWN")); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/Particle.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/Particle.java similarity index 87% rename from common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/Particle.java rename to common/src/main/java/us/myles/ViaVersion/api/type/types/Particle.java index b6e786120..5a5013935 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/Particle.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/Particle.java @@ -1,4 +1,4 @@ -package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data; +package us.myles.ViaVersion.api.type.types; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Particle1_14Type.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Particle1_14Type.java new file mode 100644 index 000000000..1510dd0fa --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/Particle1_14Type.java @@ -0,0 +1,46 @@ +package us.myles.ViaVersion.api.type.types.minecraft; + +import io.netty.buffer.ByteBuf; +import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.api.type.types.Particle; + +public class Particle1_14Type extends Type { + + public Particle1_14Type() { + super("Particle", Particle.class); + } + + @Override + public void write(ByteBuf buffer, Particle object) throws Exception { + Type.VAR_INT.write(buffer, object.getId()); + for (Particle.ParticleData data : object.getArguments()) + data.getType().write(buffer, data.getValue()); + } + + @Override + public Particle read(ByteBuf buffer) throws Exception { + int type = Type.VAR_INT.read(buffer); + Particle particle = new Particle(type); + + switch (type) { + // Block / Falling Dust / + case 3: + case 23: + particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, Type.VAR_INT.read(buffer))); // Flat Block + break; + // Dust + case 14: + particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.read(buffer))); // Red 0 - 1 + particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.read(buffer))); // Green 0 - 1 + particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.read(buffer))); // Blue 0 - 1 + particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, Type.FLOAT.read(buffer)));// Scale 0.01 - 4 + break; + // Item + case 32: + particle.getArguments().add(new Particle.ParticleData(Type.FLAT_VAR_INT_ITEM, Type.FLAT_VAR_INT_ITEM.read(buffer))); // Flat item + break; + } + return particle; + } +} + diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13.java index f8781f751..4bd78bbbf 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13.java @@ -3,6 +3,8 @@ package us.myles.ViaVersion.api.type.types.version; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.api.type.types.Particle; +import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Particle1_13Type; import java.util.List; @@ -18,4 +20,9 @@ public class Types1_13 { public static final Type METADATA = new Metadata1_13Type(); public static final Type CHUNK_SECTION = new ChunkSectionType1_13(); + + /** + * Particle type for 1.13 + */ + public static Type PARTICLE = new Particle1_13Type(); } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13_2.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13_2.java index 643f2efb2..912ac6c95 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13_2.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_13_2.java @@ -2,6 +2,8 @@ package us.myles.ViaVersion.api.type.types.version; import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.api.type.types.Particle; +import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.types.Particle1_13_2Type; import java.util.List; @@ -15,4 +17,9 @@ public class Types1_13_2 { * Metadata type for 1.13 */ public static final Type METADATA = new Metadata1_13_2Type(); + + /** + * Particle type for 1.13.2 + */ + public static Type PARTICLE = new Particle1_13_2Type(); } diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_14.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_14.java index 161e78c9e..9c091596c 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_14.java +++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/version/Types1_14.java @@ -2,6 +2,8 @@ package us.myles.ViaVersion.api.type.types.version; import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.api.type.types.Particle; +import us.myles.ViaVersion.api.type.types.minecraft.Particle1_14Type; import java.util.List; @@ -15,4 +17,9 @@ public class Types1_14 { * Metadata type for 1.14 */ public static final Type METADATA = new Metadata1_14Type(); + + /** + * Particle type for 1.14 + */ + public static final Type PARTICLE = new Particle1_14Type(); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java index b036dee34..166c3becf 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/Protocol1_13_2To1_13_1.java @@ -11,10 +11,8 @@ import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.WorldPackets; -import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.types.Particle1_13_2Type; public class Protocol1_13_2To1_13_1 extends Protocol { - public static final Particle1_13_2Type PARTICLE_TYPE = new Particle1_13_2Type(); @Override protected void registerPackets() { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/types/Particle1_13_2Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/types/Particle1_13_2Type.java index 7f53c1b28..7cba75adf 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/types/Particle1_13_2Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13_2to1_13_1/types/Particle1_13_2Type.java @@ -2,7 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.types; import io.netty.buffer.ByteBuf; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle; +import us.myles.ViaVersion.api.type.types.Particle; public class Particle1_13_2Type extends Type { public Particle1_13_2Type() { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index 61c8eae58..7dd9fe30e 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -33,7 +33,6 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockConnectio import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1_13; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.TabCompleteTracker; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Particle1_13Type; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.util.GsonUtil; @@ -41,7 +40,6 @@ import java.util.EnumMap; import java.util.Map; public class Protocol1_13To1_12_2 extends Protocol { - public static final Particle1_13Type PARTICLE_TYPE = new Particle1_13Type(); public static final PacketHandler POS_TO_3_INT = new PacketHandler() { @Override diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java index 4ec271722..e371d7019 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java @@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.type.Type; +import us.myles.ViaVersion.api.type.types.Particle; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java index e48420fca..4ccfb2a0a 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/metadata/MetadataRewriter1_13To1_12_2.java @@ -7,10 +7,10 @@ import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13; import us.myles.ViaVersion.api.rewriters.MetadataRewriter; +import us.myles.ViaVersion.api.type.types.Particle; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.ParticleRewriter; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java index 06cb00462..05ed27854 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/WorldPackets.java @@ -18,7 +18,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.Conne import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionHandler; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle; +import us.myles.ViaVersion.api.type.types.Particle; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.ParticleRewriter; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.PaintingProvider; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Particle1_13Type.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Particle1_13Type.java index 0002e4859..989474674 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Particle1_13Type.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/types/Particle1_13Type.java @@ -2,7 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types; import io.netty.buffer.ByteBuf; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle; +import us.myles.ViaVersion.api.type.types.Particle; // TODO make future proof public class Particle1_13Type extends Type { diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java index 77a078cdb..d7264a6eb 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java @@ -11,7 +11,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14; import us.myles.ViaVersion.api.rewriters.MetadataRewriter; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle; +import us.myles.ViaVersion.api.type.types.Particle; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.EntityTypeRewriter; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.InventoryPackets;