diff --git a/build.gradle b/build.gradle index 90b0507..0213bdb 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ repositories { } dependencies { - compileOnly "com.viaversion:viaversion:4.9.0-23w40a-SNAPSHOT" + compileOnly "com.viaversion:viaversion:4.9.0-23w42a-SNAPSHOT" compileOnly "org.yaml:snakeyaml:2.2" compileOnly "com.google.guava:guava:32.1.3-jre" compileOnly "io.netty:netty-handler:4.1.100.Final" diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/Protocolb1_2_0_2tob1_1_2.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/Protocolb1_2_0_2tob1_1_2.java index 16d7f30..06cdc79 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/Protocolb1_2_0_2tob1_1_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_2_0_2tob1_1_2/Protocolb1_2_0_2tob1_1_2.java @@ -19,12 +19,12 @@ import com.google.common.collect.Lists; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import net.raphimc.vialegacy.api.model.IdAndData; import net.raphimc.vialegacy.api.protocol.StatelessProtocol; import net.raphimc.vialegacy.api.splitter.PreNettySplitter; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/types/MetadataType.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/types/MetadataType.java index b6da215..3e3c38e 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/types/MetadataType.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/types/MetadataType.java @@ -18,7 +18,7 @@ package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; -import com.viaversion.viaversion.api.type.types.minecraft.OldMetaType; +import com.viaversion.viaversion.api.type.types.metadata.OldMetaType; public class MetadataType extends OldMetaType { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/types/Typesb1_2.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/types/Typesb1_2.java index 0910655..0fdf795 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/types/Typesb1_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_3_0_1tob1_2_0_2/types/Typesb1_2.java @@ -19,7 +19,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.minecraft.MetaListType; +import com.viaversion.viaversion.api.type.types.metadata.MetaListType; import java.util.List; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/types/MetadataType.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/types/MetadataType.java index 09f8865..abfe0dc 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/types/MetadataType.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/types/MetadataType.java @@ -18,7 +18,7 @@ package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; -import com.viaversion.viaversion.api.type.types.minecraft.OldMetaType; +import com.viaversion.viaversion.api.type.types.metadata.OldMetaType; public class MetadataType extends OldMetaType { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/types/Typesb1_4.java b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/types/Typesb1_4.java index 5b9db0e..dead9ed 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/types/Typesb1_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/beta/protocolb1_5_0_2tob1_4_0_1/types/Typesb1_4.java @@ -19,7 +19,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.minecraft.MetaListType; +import com.viaversion.viaversion.api.type.types.metadata.MetaListType; import java.util.List; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/Chunk1_1Type.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/ChunkType1_1.java similarity index 98% rename from src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/Chunk1_1Type.java rename to src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/ChunkType1_1.java index b523fdc..9c35631 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/Chunk1_1Type.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/ChunkType1_1.java @@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.*; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.CustomByteType; -import com.viaversion.viaversion.api.type.types.minecraft.BaseChunkType; +import com.viaversion.viaversion.api.type.types.chunk.BaseChunkType; import io.netty.buffer.ByteBuf; import net.raphimc.vialegacy.api.model.IdAndData; import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.chunks.NibbleArray1_1; @@ -32,9 +32,9 @@ import java.util.zip.DataFormatException; import java.util.zip.Inflater; -public class Chunk1_1Type extends Type { +public class ChunkType1_1 extends Type { - public Chunk1_1Type() { + public ChunkType1_1() { super(Chunk.class); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/Types1_1.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/Types1_1.java index 737fa7e..401ba80 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/Types1_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_2_1_3to1_1/types/Types1_1.java @@ -24,6 +24,6 @@ public class Types1_1 { public static Type BLOCK_CHANGE_RECORD_ARRAY = new BlockChangeRecordArrayType(); - public static Type CHUNK = new Chunk1_1Type(); + public static Type CHUNK = new ChunkType1_1(); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/Protocol1_3_1_2to1_2_4_5.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/Protocol1_3_1_2to1_2_4_5.java index 57ef9e3..6f334b3 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/Protocol1_3_1_2to1_2_4_5.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/Protocol1_3_1_2to1_2_4_5.java @@ -21,10 +21,11 @@ import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.*; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.platform.providers.ViaProviders; @@ -36,7 +37,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import net.raphimc.vialegacy.ViaLegacy; import net.raphimc.vialegacy.api.LegacyProtocolVersion; import net.raphimc.vialegacy.api.data.BlockList1_6; @@ -67,7 +67,7 @@ import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Chunk1_7_6Type; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6; import java.util.ArrayList; @@ -145,7 +145,7 @@ public void register() { wrapper.user().get(DimensionTracker.class).setDimension(wrapper.get(Type.BYTE, 1)); final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); entityTracker.setPlayerID(wrapper.get(Type.INT, 0)); - entityTracker.getTrackedEntities().put(entityTracker.getPlayerID(), new TrackedLivingEntity(entityTracker.getPlayerID(), new Location(8, 64, 8), Entity1_10Types.EntityType.PLAYER)); + entityTracker.getTrackedEntities().put(entityTracker.getPlayerID(), new TrackedLivingEntity(entityTracker.getPlayerID(), new Location(8, 64, 8), EntityTypes1_10.EntityType.PLAYER)); }); } }); @@ -178,7 +178,7 @@ public void register() { wrapper.user().get(ChestStateTracker.class).clear(); final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); entityTracker.getTrackedEntities().clear(); - entityTracker.getTrackedEntities().put(entityTracker.getPlayerID(), new TrackedLivingEntity(entityTracker.getPlayerID(), new Location(8, 64, 8), Entity1_10Types.EntityType.PLAYER)); + entityTracker.getTrackedEntities().put(entityTracker.getPlayerID(), new TrackedLivingEntity(entityTracker.getPlayerID(), new Location(8, 64, 8), EntityTypes1_10.EntityType.PLAYER)); } }); } @@ -201,7 +201,7 @@ public void register() { final double y = wrapper.get(Type.INT, 2) / 32.0D; final double z = wrapper.get(Type.INT, 3) / 32.0D; final EntityTracker tracker = wrapper.user().get(EntityTracker.class); - tracker.getTrackedEntities().put(entityId, new TrackedLivingEntity(entityId, new Location(x, y, z), Entity1_10Types.EntityType.PLAYER)); + tracker.getTrackedEntities().put(entityId, new TrackedLivingEntity(entityId, new Location(x, y, z), EntityTypes1_10.EntityType.PLAYER)); }); } }); @@ -222,7 +222,7 @@ public void register() { final double x = wrapper.get(Type.INT, 1) / 32.0D; final double y = wrapper.get(Type.INT, 2) / 32.0D; final double z = wrapper.get(Type.INT, 3) / 32.0D; - tracker.getTrackedEntities().put(entityId, new TrackedEntity(entityId, new Location(x, y, z), Entity1_10Types.ObjectType.ITEM.getType())); + tracker.getTrackedEntities().put(entityId, new TrackedEntity(entityId, new Location(x, y, z), EntityTypes1_10.ObjectType.ITEM.getType())); }); } }); @@ -249,14 +249,14 @@ public void register() { final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); final int entityId = wrapper.get(Type.INT, 0); final byte typeId = wrapper.get(Type.BYTE, 0); - final Entity1_10Types.EntityType type; + final EntityTypes1_10.EntityType type; if (typeId == 70 || typeId == 71 || typeId == 74) { - type = Entity1_10Types.ObjectType.FALLING_BLOCK.getType(); - wrapper.set(Type.BYTE, 0, (byte) Entity1_10Types.ObjectType.FALLING_BLOCK.getId()); + type = EntityTypes1_10.ObjectType.FALLING_BLOCK.getType(); + wrapper.set(Type.BYTE, 0, (byte) EntityTypes1_10.ObjectType.FALLING_BLOCK.getId()); } else if (typeId == 10 || typeId == 11 || typeId == 12) { - type = Entity1_10Types.ObjectType.MINECART.getType(); + type = EntityTypes1_10.ObjectType.MINECART.getType(); } else { - type = Entity1_10Types.getTypeFromId(typeId, true); + type = EntityTypes1_10.getTypeFromId(typeId, true); } final double x = wrapper.get(Type.INT, 1) / 32.0D; final double y = wrapper.get(Type.INT, 2) / 32.0D; @@ -274,8 +274,8 @@ public void register() { if (typeId == 70) throwerEntityId = 12; // sand if (typeId == 71) throwerEntityId = 13; // gravel if (typeId == 74) throwerEntityId = 122; // dragon egg - if (typeId == Entity1_10Types.ObjectType.FISHIHNG_HOOK.getId()) { - final Optional nearestEntity = entityTracker.getNearestEntity(location, 2.0D, e -> e.getEntityType().isOrHasParent(Entity1_10Types.EntityType.PLAYER)); + if (typeId == EntityTypes1_10.ObjectType.FISHIHNG_HOOK.getId()) { + final Optional nearestEntity = entityTracker.getNearestEntity(location, 2.0D, e -> e.getEntityType().isOrHasParent(EntityTypes1_10.EntityType.PLAYER)); throwerEntityId = nearestEntity.map(AbstractTrackedEntity::getEntityId).orElseGet(entityTracker::getPlayerID); } wrapper.set(Type.INT, 4, throwerEntityId); @@ -286,7 +286,7 @@ public void register() { } entityTracker.getTrackedEntities().put(entityId, new TrackedEntity(entityId, location, type)); - final Entity1_10Types.ObjectType objectType = Entity1_10Types.ObjectType.findById(typeId).orElse(null); + final EntityTypes1_10.ObjectType objectType = EntityTypes1_10.ObjectType.findById(typeId).orElse(null); if (objectType == null) return; float pitch; @@ -334,7 +334,7 @@ public void register() { final double y = wrapper.get(Type.INT, 2) / 32.0D; final double z = wrapper.get(Type.INT, 3) / 32.0D; final List metadataList = wrapper.get(Types1_3_1.METADATA_LIST, 0); - final Entity1_10Types.EntityType entityType = Entity1_10Types.getTypeFromId(type, false); + final EntityTypes1_10.EntityType entityType = EntityTypes1_10.getTypeFromId(type, false); final EntityTracker tracker = wrapper.user().get(EntityTracker.class); tracker.getTrackedEntities().put(entityId, new TrackedLivingEntity(entityId, new Location(x, y, z), entityType)); tracker.updateEntityMetadata(entityId, metadataList); @@ -459,7 +459,7 @@ public void register() { if (!load) { final Chunk chunk = new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], null, new ArrayList<>()); - wrapper.write(new Chunk1_7_6Type(wrapper.user().get(ClientWorld.class)), chunk); + wrapper.write(new ChunkType1_7_6(wrapper.user().get(ClientWorld.class)), chunk); } else { wrapper.cancel(); } @@ -496,7 +496,7 @@ public void register() { } } } - wrapper.write(new Chunk1_7_6Type(clientWorld), chunk); + wrapper.write(new ChunkType1_7_6(clientWorld), chunk); }); } }); @@ -807,7 +807,7 @@ private void handleEntityMetadata(final int entityId, final List metad if (index == MetaIndex1_8to1_7_6.ENTITY_FLAGS) { if ((metadata.value() & 4) != 0) { // entity mount final Optional oNearbyEntity = tracker.getNearestEntity(entity.getLocation(), 1.0D, e -> { - return e.getEntityType().isOrHasParent(Entity1_10Types.EntityType.MINECART_RIDEABLE) || e.getEntityType().isOrHasParent(Entity1_10Types.EntityType.PIG) || e.getEntityType().isOrHasParent(Entity1_10Types.EntityType.BOAT); + return e.getEntityType().isOrHasParent(EntityTypes1_10.EntityType.MINECART_RIDEABLE) || e.getEntityType().isOrHasParent(EntityTypes1_10.EntityType.PIG) || e.getEntityType().isOrHasParent(EntityTypes1_10.EntityType.BOAT); }); if (oNearbyEntity.isPresent()) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/AbstractTrackedEntity.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/AbstractTrackedEntity.java index c13f9db..11ac507 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/AbstractTrackedEntity.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/AbstractTrackedEntity.java @@ -17,18 +17,18 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.model; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import net.raphimc.vialegacy.api.model.Location; public abstract class AbstractTrackedEntity { private int entityId; private Location location; - private Entity1_10Types.EntityType entityType; + private EntityTypes1_10.EntityType entityType; private boolean isRiding; - public AbstractTrackedEntity(final int entityId, final Location location, final Entity1_10Types.EntityType entityType) { + public AbstractTrackedEntity(final int entityId, final Location location, final EntityTypes1_10.EntityType entityType) { this.entityId = entityId; this.location = location; this.entityType = entityType; @@ -50,11 +50,11 @@ public void setLocation(Location location) { this.location = location; } - public Entity1_10Types.EntityType getEntityType() { + public EntityTypes1_10.EntityType getEntityType() { return this.entityType; } - public void setEntityType(Entity1_10Types.EntityType entityType) { + public void setEntityType(EntityTypes1_10.EntityType entityType) { this.entityType = entityType; } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/TrackedEntity.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/TrackedEntity.java index 699bdad..7dbdb66 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/TrackedEntity.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/TrackedEntity.java @@ -17,12 +17,12 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.model; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import net.raphimc.vialegacy.api.model.Location; public class TrackedEntity extends AbstractTrackedEntity { - public TrackedEntity(int entityId, Location location, Entity1_10Types.EntityType entityType) { + public TrackedEntity(int entityId, Location location, EntityTypes1_10.EntityType entityType) { super(entityId, location, entityType); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/TrackedLivingEntity.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/TrackedLivingEntity.java index 02a51c4..0bae7c1 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/TrackedLivingEntity.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/model/TrackedLivingEntity.java @@ -17,7 +17,7 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.model; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import net.raphimc.vialegacy.api.model.Location; import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.sound.SoundEmulation; @@ -42,7 +42,7 @@ public class TrackedLivingEntity extends AbstractTrackedEntity { public int wolfHealth; public boolean wolfIsAngry; - public TrackedLivingEntity(int entityId, Location location, Entity1_10Types.EntityType entityType) { + public TrackedLivingEntity(int entityId, Location location, EntityTypes1_10.EntityType entityType) { super(entityId, location, entityType); } @@ -53,7 +53,7 @@ public void tick(EntityTracker tracker) { tracker.playSound(this.getEntityId(), SoundType.IDLE); } - if (this.getEntityType().isOrHasParent(Entity1_10Types.EntityType.ENTITY_AGEABLE)) { + if (this.getEntityType().isOrHasParent(EntityTypes1_10.EntityType.ENTITY_AGEABLE)) { if (this.growingAge < 0) { this.growingAge++; } else if (this.growingAge > 0) { @@ -84,7 +84,7 @@ public void updateMetadata(List metadataList) { public void applyPitch(EntityTracker tracker, ConfiguredSound sound) { float pitch; - if (this.getEntityType().isOrHasParent(Entity1_10Types.EntityType.ENTITY_AGEABLE) && this.growingAge < 0) { + if (this.getEntityType().isOrHasParent(EntityTypes1_10.EntityType.ENTITY_AGEABLE) && this.growingAge < 0) { pitch = (tracker.RND.nextFloat() - tracker.RND.nextFloat()) * 0.2F + 1.5F; } else { pitch = (tracker.RND.nextFloat() - tracker.RND.nextFloat()) * 0.2F + 1.0F; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/sound/SoundEmulation.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/sound/SoundEmulation.java index ad9363b..b4f55fd 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/sound/SoundEmulation.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/sound/SoundEmulation.java @@ -17,7 +17,7 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.sound; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.model.ConfiguredSound; public class SoundEmulation { @@ -32,157 +32,157 @@ public class SoundEmulation { Sound.MOB_HUMAN_HURT, Sound.MOB_HUMAN_HURT }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.CREEPER.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.CREEPER.getId()] = new Sound[]{ Sound.NO_SOUND, Sound.MOB_CREEPER, Sound.MOB_CREEPER_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.SKELETON.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.SKELETON.getId()] = new Sound[]{ Sound.MOB_SKELETON, Sound.MOB_SKELETON_HURT, Sound.MOB_SKELETON_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.SPIDER.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.SPIDER.getId()] = new Sound[]{ Sound.MOB_SPIDER, Sound.MOB_SPIDER, Sound.MOB_SPIDER_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.GIANT.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.GIANT.getId()] = new Sound[]{ Sound.NO_SOUND, Sound.MOB_HUMAN_HURT, Sound.MOB_HUMAN_HURT }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.ZOMBIE.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.ZOMBIE.getId()] = new Sound[]{ Sound.MOB_ZOMBIE, Sound.MOB_ZOMBIE_HURT, Sound.MOB_ZOMBIE_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.SLIME.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.SLIME.getId()] = new Sound[]{ Sound.MOB_SLIME, Sound.MOB_SLIME, Sound.MOB_SLIME }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.GHAST.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.GHAST.getId()] = new Sound[]{ Sound.MOB_GHAST, Sound.MOB_GHAST_HURT, Sound.MOB_GHAST_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.PIG_ZOMBIE.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.PIG_ZOMBIE.getId()] = new Sound[]{ Sound.MOB_PIG_ZOMBIE, Sound.MOB_PIG_ZOMBIE_HURT, Sound.MOB_PIG_ZOMBIE_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.ENDERMAN.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.ENDERMAN.getId()] = new Sound[]{ Sound.MOB_ENDERMEN, Sound.MOB_ENDERMEN_HURT, Sound.MOB_ENDERMEN_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.CAVE_SPIDER.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.CAVE_SPIDER.getId()] = new Sound[]{ Sound.MOB_SPIDER, Sound.MOB_SPIDER, Sound.MOB_SPIDER_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.SILVERFISH.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.SILVERFISH.getId()] = new Sound[]{ Sound.MOB_SILVERFISH, Sound.MOB_SILVERFISH_HURT, Sound.MOB_SILVERFISH_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.BLAZE.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.BLAZE.getId()] = new Sound[]{ Sound.MOB_BLAZE, Sound.MOB_BLAZE_HURT, Sound.MOB_BLAZE_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.MAGMA_CUBE.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.MAGMA_CUBE.getId()] = new Sound[]{ Sound.MOB_MAGMACUBE_SMALL, Sound.MOB_SLIME, Sound.MOB_SLIME }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.ENDER_DRAGON.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.ENDER_DRAGON.getId()] = new Sound[]{ Sound.NO_SOUND, Sound.MOB_HUMAN_HURT, Sound.MOB_HUMAN_HURT }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.PIG.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.PIG.getId()] = new Sound[]{ Sound.MOB_PIG, Sound.MOB_PIG, Sound.MOB_PIG_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.SHEEP.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.SHEEP.getId()] = new Sound[]{ Sound.MOB_SHEEP, Sound.MOB_SHEEP, Sound.MOB_SHEEP }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.COW.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.COW.getId()] = new Sound[]{ Sound.MOB_COW, Sound.MOB_COW_HURT, Sound.MOB_COW_HURT }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.CHICKEN.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.CHICKEN.getId()] = new Sound[]{ Sound.MOB_CHICKEN, Sound.MOB_CHICKEN_HURT, Sound.MOB_CHICKEN_HURT }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.SQUID.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.SQUID.getId()] = new Sound[]{ Sound.NO_SOUND, Sound.NO_SOUND, Sound.NO_SOUND }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.WOLF.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.WOLF.getId()] = new Sound[]{ Sound.MOB_WOLF, Sound.MOB_WOLF_HURT, Sound.MOB_WOLF_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.MUSHROOM_COW.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.MUSHROOM_COW.getId()] = new Sound[]{ Sound.MOB_COW, Sound.MOB_COW_HURT, Sound.MOB_COW_HURT }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.SNOWMAN.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.SNOWMAN.getId()] = new Sound[]{ Sound.NO_SOUND, Sound.NO_SOUND, Sound.NO_SOUND }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.OCELOT.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.OCELOT.getId()] = new Sound[]{ Sound.NO_SOUND, Sound.MOB_CAT_HURT, Sound.MOB_CAT_HURT }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.IRON_GOLEM.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.IRON_GOLEM.getId()] = new Sound[]{ Sound.NO_SOUND, Sound.MOB_IRON_GOLEM_HURT, Sound.MOB_IRON_GOLEM_DEATH }; - ENTITY_SOUNDS[Entity1_10Types.EntityType.VILLAGER.getId()] = new Sound[]{ + ENTITY_SOUNDS[EntityTypes1_10.EntityType.VILLAGER.getId()] = new Sound[]{ Sound.MOB_VILLAGER, Sound.MOB_VILLAGER_HURT, Sound.MOB_VILLAGER_DEATH }; - VOL_ADJUST[Entity1_10Types.EntityType.SLIME.getId()] = 1.6F; - VOL_ADJUST[Entity1_10Types.EntityType.MAGMA_CUBE.getId()] = 1.6F; - VOL_ADJUST[Entity1_10Types.EntityType.GHAST.getId()] = 10.0F; - VOL_ADJUST[Entity1_10Types.EntityType.COW.getId()] = 0.4F; - VOL_ADJUST[Entity1_10Types.EntityType.WOLF.getId()] = 0.4F; - VOL_ADJUST[Entity1_10Types.EntityType.SQUID.getId()] = 0.4F; - VOL_ADJUST[Entity1_10Types.EntityType.MUSHROOM_COW.getId()] = 0.4F; - VOL_ADJUST[Entity1_10Types.EntityType.OCELOT.getId()] = 0.4F; + VOL_ADJUST[EntityTypes1_10.EntityType.SLIME.getId()] = 1.6F; + VOL_ADJUST[EntityTypes1_10.EntityType.MAGMA_CUBE.getId()] = 1.6F; + VOL_ADJUST[EntityTypes1_10.EntityType.GHAST.getId()] = 10.0F; + VOL_ADJUST[EntityTypes1_10.EntityType.COW.getId()] = 0.4F; + VOL_ADJUST[EntityTypes1_10.EntityType.WOLF.getId()] = 0.4F; + VOL_ADJUST[EntityTypes1_10.EntityType.SQUID.getId()] = 0.4F; + VOL_ADJUST[EntityTypes1_10.EntityType.MUSHROOM_COW.getId()] = 0.4F; + VOL_ADJUST[EntityTypes1_10.EntityType.OCELOT.getId()] = 0.4F; - INTERVAL_ADJUST[Entity1_10Types.EntityType.PIG.getId()] = 120; - INTERVAL_ADJUST[Entity1_10Types.EntityType.SHEEP.getId()] = 120; - INTERVAL_ADJUST[Entity1_10Types.EntityType.WOLF.getId()] = 120; - INTERVAL_ADJUST[Entity1_10Types.EntityType.SNOWMAN.getId()] = 120; - INTERVAL_ADJUST[Entity1_10Types.EntityType.IRON_GOLEM.getId()] = 120; - INTERVAL_ADJUST[Entity1_10Types.EntityType.MUSHROOM_COW.getId()] = 120; - INTERVAL_ADJUST[Entity1_10Types.EntityType.COW.getId()] = 120; - INTERVAL_ADJUST[Entity1_10Types.EntityType.CHICKEN.getId()] = 120; - INTERVAL_ADJUST[Entity1_10Types.EntityType.SQUID.getId()] = 120; - INTERVAL_ADJUST[Entity1_10Types.EntityType.OCELOT.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.PIG.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.SHEEP.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.WOLF.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.SNOWMAN.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.IRON_GOLEM.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.MUSHROOM_COW.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.COW.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.CHICKEN.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.SQUID.getId()] = 120; + INTERVAL_ADJUST[EntityTypes1_10.EntityType.OCELOT.getId()] = 120; } - public static ConfiguredSound getEntitySound(Entity1_10Types.EntityType entityType, SoundType soundType) { + public static ConfiguredSound getEntitySound(EntityTypes1_10.EntityType entityType, SoundType soundType) { ConfiguredSound sound = new ConfiguredSound(Sound.NO_SOUND, 0.0F, 1.0F); int entityTypeID = entityType.getId(); - if (entityType.isOrHasParent(Entity1_10Types.EntityType.PLAYER)) entityTypeID = 48; + if (entityType.isOrHasParent(EntityTypes1_10.EntityType.PLAYER)) entityTypeID = 48; final Sound[] entitySounds = ENTITY_SOUNDS[entityTypeID]; if (entitySounds == null) { @@ -209,9 +209,9 @@ public static ConfiguredSound getEntitySound(Entity1_10Types.EntityType entityTy return sound; } - public static int getSoundDelayTime(Entity1_10Types.EntityType entityType) { + public static int getSoundDelayTime(EntityTypes1_10.EntityType entityType) { int entityTypeID = entityType.getId(); - if (entityType.isOrHasParent(Entity1_10Types.EntityType.PLAYER)) entityTypeID = 48; + if (entityType.isOrHasParent(EntityTypes1_10.EntityType.PLAYER)) entityTypeID = 48; int soundTime = -80; final int ajustedSoundTime = SoundEmulation.INTERVAL_ADJUST[entityTypeID]; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/EntityTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/EntityTracker.java index fd75c74..2d38c10 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/EntityTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/storage/EntityTracker.java @@ -19,7 +19,7 @@ import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; @@ -121,13 +121,13 @@ public void playSound(int entityId, SoundType type) { final TrackedLivingEntity livingEntity = (TrackedLivingEntity) entity; livingEntity.applyPitch(this, sound); - if (entity.getEntityType().isOrHasParent(Entity1_10Types.EntityType.WOLF)) { + if (entity.getEntityType().isOrHasParent(EntityTypes1_10.EntityType.WOLF)) { if (livingEntity.wolfIsAngry) { sound.setSound(Sound.MOB_WOLF_GROWL); } else if (RND.nextInt(3) == 0) { sound.setSound(livingEntity.isTamed && livingEntity.wolfHealth < 10 ? Sound.MOB_WOLF_WHINE : Sound.MOB_WOLF_PANTING); } - } else if (entity.getEntityType().isOrHasParent(Entity1_10Types.EntityType.OCELOT)) { + } else if (entity.getEntityType().isOrHasParent(EntityTypes1_10.EntityType.OCELOT)) { if (livingEntity.isTamed) { sound.setSound(RND.nextInt(4) == 0 ? Sound.MOB_CAT_PURREOW : Sound.MOB_CAT_MEOW); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Chunk1_2_4Type.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/ChunkType1_2_4.java similarity index 91% rename from src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Chunk1_2_4Type.java rename to src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/ChunkType1_2_4.java index 6f8dddb..82774eb 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Chunk1_2_4Type.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/ChunkType1_2_4.java @@ -17,14 +17,14 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.types; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import io.netty.buffer.ByteBuf; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Chunk1_7_6Type; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6; -public class Chunk1_2_4Type extends Chunk1_7_6Type { +public class ChunkType1_2_4 extends ChunkType1_7_6 { private static final ClientWorld OVERWORLD = new ClientWorld(null); @@ -32,7 +32,7 @@ public class Chunk1_2_4Type extends Chunk1_7_6Type { OVERWORLD.setEnvironment(Environment.NORMAL.id()); } - public Chunk1_2_4Type() { + public ChunkType1_2_4() { super(OVERWORLD); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Types1_2_4.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Types1_2_4.java index 7623d22..957fca2 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Types1_2_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_3_1_2to1_2_4_5/types/Types1_2_4.java @@ -30,6 +30,6 @@ public class Types1_2_4 { public static final Type ITEM_ARRAY = new ItemArrayType<>(ITEM); public static final Type COMPRESSED_NBT_ITEM_ARRAY = new ItemArrayType<>(COMPRESSED_NBT_ITEM); - public static final Type CHUNK = new Chunk1_2_4Type(); + public static final Type CHUNK = new ChunkType1_2_4(); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/Protocol1_4_2to1_3_1_2.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/Protocol1_4_2to1_3_1_2.java index 9d2c763..8afb8ab 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/Protocol1_4_2to1_3_1_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/Protocol1_4_2to1_3_1_2.java @@ -20,7 +20,7 @@ import com.google.common.collect.Lists; import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; @@ -184,9 +184,9 @@ public void register() { handler(wrapper -> { final int entityId = wrapper.get(Type.INT, 0); final short typeId = wrapper.get(Type.UNSIGNED_BYTE, 0); - if (typeId == Entity1_10Types.EntityType.SKELETON.getId()) { + if (typeId == EntityTypes1_10.EntityType.SKELETON.getId()) { setMobHandItem(entityId, new DataItem(ItemList1_6.bow.itemID, (byte) 1, (short) 0, null), wrapper); - } else if (typeId == Entity1_10Types.EntityType.PIG_ZOMBIE.getId()) { + } else if (typeId == EntityTypes1_10.EntityType.PIG_ZOMBIE.getId()) { setMobHandItem(entityId, new DataItem(ItemList1_6.swordGold.itemID, (byte) 1, (short) 0, null), wrapper); } }); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/MetadataType.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/MetadataType.java index 3d672e9..27e4237 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/MetadataType.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/MetadataType.java @@ -18,7 +18,7 @@ package net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; -import com.viaversion.viaversion.api.type.types.minecraft.OldMetaType; +import com.viaversion.viaversion.api.type.types.metadata.OldMetaType; public class MetadataType extends OldMetaType { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/Types1_3_1.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/Types1_3_1.java index 122a0ee..78bc4b8 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/Types1_3_1.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_2to1_3_1_2/types/Types1_3_1.java @@ -20,7 +20,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.minecraft.MetaListType; +import com.viaversion.viaversion.api.type.types.metadata.MetaListType; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ItemArrayType; import java.util.List; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/types/MetadataType.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/types/MetadataType.java index 3d489e4..d522690 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/types/MetadataType.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/types/MetadataType.java @@ -18,7 +18,7 @@ package net.raphimc.vialegacy.protocols.release.protocol1_4_4_5to1_4_2.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; -import com.viaversion.viaversion.api.type.types.minecraft.OldMetaType; +import com.viaversion.viaversion.api.type.types.metadata.OldMetaType; public class MetadataType extends OldMetaType { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/types/Types1_4_2.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/types/Types1_4_2.java index 58150c5..503b3f7 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/types/Types1_4_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_4_5to1_4_2/types/Types1_4_2.java @@ -20,7 +20,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.minecraft.MetaListType; +import com.viaversion.viaversion.api.type.types.metadata.MetaListType; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ItemArrayType; import java.util.List; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/Protocol1_4_6_7to1_4_4_5.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/Protocol1_4_6_7to1_4_4_5.java index 7ef219b..2c7a121 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/Protocol1_4_6_7to1_4_4_5.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/Protocol1_4_6_7to1_4_4_5.java @@ -19,24 +19,24 @@ import com.google.common.collect.Lists; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.ClientWorld; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import net.raphimc.vialegacy.api.protocol.StatelessProtocol; import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter; import net.raphimc.vialegacy.api.splitter.PreNettySplitter; import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.rewriter.ItemRewriter; -import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.types.ChunkBulk1_4_4Type; +import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.types.ChunkBulkType1_4_4; import net.raphimc.vialegacy.protocols.release.protocol1_5_0_1to1_4_6_7.ClientboundPackets1_4_6; import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.MetaType1_6_4; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulk1_7_6Type; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulkType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6; public class Protocol1_4_6_7to1_4_4_5 extends StatelessProtocol { @@ -89,7 +89,7 @@ public void register() { final int motionZ = wrapper.read(Type.BYTE); // velocity z wrapper.write(Type.INT, entityId); // entity id - wrapper.write(Type.BYTE, (byte) Entity1_10Types.ObjectType.ITEM.getId()); // type id + wrapper.write(Type.BYTE, (byte) EntityTypes1_10.ObjectType.ITEM.getId()); // type id wrapper.write(Type.INT, x); // x wrapper.write(Type.INT, y); // y wrapper.write(Type.INT, z); // z @@ -129,7 +129,7 @@ public void register() { public void register() { handler(wrapper -> { final ClientWorld clientWorld = wrapper.user().get(ClientWorld.class); - wrapper.write(new ChunkBulk1_7_6Type(clientWorld), wrapper.read(new ChunkBulk1_4_4Type(clientWorld))); + wrapper.write(new ChunkBulkType1_7_6(clientWorld), wrapper.read(new ChunkBulkType1_4_4(clientWorld))); }); } }); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/ChunkBulk1_4_4Type.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/ChunkBulkType1_4_4.java similarity index 84% rename from src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/ChunkBulk1_4_4Type.java rename to src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/ChunkBulkType1_4_4.java index 8d8d7f1..ea3f068 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/ChunkBulk1_4_4Type.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_4_6_7to1_4_4_5/types/ChunkBulkType1_4_4.java @@ -17,13 +17,13 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.types; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import io.netty.buffer.ByteBuf; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulk1_7_6Type; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulkType1_7_6; -public class ChunkBulk1_4_4Type extends ChunkBulk1_7_6Type { +public class ChunkBulkType1_4_4 extends ChunkBulkType1_7_6 { - public ChunkBulk1_4_4Type(ClientWorld clientWorld) { + public ChunkBulkType1_4_4(ClientWorld clientWorld) { super(clientWorld); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/Protocol1_5_0_1to1_4_6_7.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/Protocol1_5_0_1to1_4_6_7.java index 7ba6340..a5d6467 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/Protocol1_5_0_1to1_4_6_7.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_5_0_1to1_4_6_7/Protocol1_5_0_1to1_4_6_7.java @@ -18,7 +18,7 @@ package net.raphimc.vialegacy.protocols.release.protocol1_5_0_1to1_4_6_7; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; @@ -58,7 +58,7 @@ public void register() { handler(wrapper -> { final byte typeId = wrapper.get(Type.BYTE, 0); if (typeId == 10 || typeId == 11 || typeId == 12) { - wrapper.set(Type.BYTE, 0, (byte) Entity1_10Types.ObjectType.MINECART.getId()); + wrapper.set(Type.BYTE, 0, (byte) EntityTypes1_10.ObjectType.MINECART.getId()); } int throwerEntityId = wrapper.get(Type.INT, 4); short speedX = 0; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/Protocol1_6_1to1_5_2.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/Protocol1_6_1to1_5_2.java index 153ea4c..dead7a5 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/Protocol1_6_1to1_5_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/Protocol1_6_1to1_5_2.java @@ -18,7 +18,7 @@ package net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; @@ -67,7 +67,7 @@ public void register() { handler(wrapper -> { final int entityId = wrapper.get(Type.INT, 0); final EntityTracker tracker = wrapper.user().get(EntityTracker.class); - tracker.getTrackedEntities().put(entityId, Entity1_10Types.EntityType.PLAYER); + tracker.getTrackedEntities().put(entityId, EntityTypes1_10.EntityType.PLAYER); tracker.setPlayerID(entityId); }); } @@ -98,10 +98,10 @@ public void register() { map(Type.BYTE); // pitch map(Type.UNSIGNED_SHORT); // item map(Types1_6_4.METADATA_LIST); // metadata - handler(wrapper -> MetadataRewriter.transform(Entity1_10Types.EntityType.PLAYER, wrapper.get(Types1_6_4.METADATA_LIST, 0))); + handler(wrapper -> MetadataRewriter.transform(EntityTypes1_10.EntityType.PLAYER, wrapper.get(Types1_6_4.METADATA_LIST, 0))); handler(wrapper -> { final int entityId = wrapper.get(Type.INT, 0); - wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityId, Entity1_10Types.EntityType.PLAYER); + wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityId, EntityTypes1_10.EntityType.PLAYER); }); } }); @@ -130,7 +130,7 @@ public void register() { handler(wrapper -> { final int entityID = wrapper.get(Type.INT, 0); final int typeID = wrapper.get(Type.BYTE, 0); - wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, Entity1_10Types.getTypeFromId(typeID, true)); + wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, EntityTypes1_10.getTypeFromId(typeID, true)); }); } }); @@ -152,12 +152,12 @@ public void register() { handler(wrapper -> { final int entityID = wrapper.get(Type.INT, 0); final int typeID = wrapper.get(Type.UNSIGNED_BYTE, 0); - final Entity1_10Types.EntityType entityType = Entity1_10Types.getTypeFromId(typeID, false); + final EntityTypes1_10.EntityType entityType = EntityTypes1_10.getTypeFromId(typeID, false); final List metadataList = wrapper.get(Types1_6_4.METADATA_LIST, 0); wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, entityType); MetadataRewriter.transform(entityType, metadataList); - if (entityType.isOrHasParent(Entity1_10Types.EntityType.WOLF)) { + if (entityType.isOrHasParent(EntityTypes1_10.EntityType.WOLF)) { handleWolfMetadata(entityID, metadataList, wrapper); } }); @@ -172,7 +172,7 @@ public void register() { map(Type.INT); // rotation handler(wrapper -> { final int entityID = wrapper.get(Type.INT, 0); - wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, Entity1_10Types.EntityType.PAINTING); + wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, EntityTypes1_10.EntityType.PAINTING); }); } }); @@ -186,7 +186,7 @@ public void register() { map(Type.SHORT); // count handler(wrapper -> { final int entityID = wrapper.get(Type.INT, 0); - wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, Entity1_10Types.EntityType.EXPERIENCE_ORB); + wrapper.user().get(EntityTracker.class).getTrackedEntities().put(entityID, EntityTypes1_10.EntityType.EXPERIENCE_ORB); }); } }); @@ -228,12 +228,12 @@ public void register() { final EntityTracker tracker = wrapper.user().get(EntityTracker.class); final List metadataList = wrapper.get(Types1_6_4.METADATA_LIST, 0); final int entityID = wrapper.get(Type.INT, 0); - final Entity1_10Types.EntityType entityType = tracker.getTrackedEntities().get(entityID); + final EntityTypes1_10.EntityType entityType = tracker.getTrackedEntities().get(entityID); if (tracker.getTrackedEntities().containsKey(entityID)) { MetadataRewriter.transform(entityType, metadataList); if (metadataList.isEmpty()) wrapper.cancel(); - if (entityType.isOrHasParent(Entity1_10Types.EntityType.WOLF)) { + if (entityType.isOrHasParent(EntityTypes1_10.EntityType.WOLF)) { handleWolfMetadata(entityID, metadataList, wrapper); } } else { @@ -352,7 +352,7 @@ public void register() { private void handleWolfMetadata(final int entityId, final List metadataList, final PacketWrapper wrapper) throws Exception { for (Metadata metadata : metadataList) { - final MetaIndex1_8to1_7_6 index = MetaIndex1_8to1_7_6.searchIndex(Entity1_10Types.EntityType.WOLF, metadata.id()); + final MetaIndex1_8to1_7_6 index = MetaIndex1_8to1_7_6.searchIndex(EntityTypes1_10.EntityType.WOLF, metadata.id()); if (index == MetaIndex1_8to1_7_6.TAMEABLE_FLAGS) { if ((metadata.value() & 4) != 0) { // is tamed diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/metadata/MetaIndex1_6_1to1_5_2.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/metadata/MetaIndex1_6_1to1_5_2.java index 68730d8..695157a 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/metadata/MetaIndex1_6_1to1_5_2.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/metadata/MetaIndex1_6_1to1_5_2.java @@ -17,7 +17,7 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.metadata; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.util.Pair; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.MetaType1_6_4; @@ -26,20 +26,20 @@ public enum MetaIndex1_6_1to1_5_2 { - ENTITY_LIVING_POTION_EFFECT_COLOR(Entity1_10Types.EntityType.ENTITY_LIVING, 8, MetaType1_6_4.Int, 7, MetaType1_6_4.Int), - ENTITY_LIVING_IS_POTION_EFFECT_AMBIENT(Entity1_10Types.EntityType.ENTITY_LIVING, 9, MetaType1_6_4.Byte, 8, MetaType1_6_4.Byte), - ENTITY_LIVING_ARROWS(Entity1_10Types.EntityType.ENTITY_LIVING, 10, MetaType1_6_4.Byte, 9, MetaType1_6_4.Byte), - ENTITY_LIVING_NAME_TAG(Entity1_10Types.EntityType.ENTITY_LIVING, 5, MetaType1_6_4.String, 10, MetaType1_6_4.String), - ENTITY_LIVING_NAME_TAG_VISIBILITY(Entity1_10Types.EntityType.ENTITY_LIVING, 6, MetaType1_6_4.Byte, 11, MetaType1_6_4.Byte), - HUMAN_ABSORPTION_HEARTS(Entity1_10Types.EntityType.ENTITY_HUMAN, 17, MetaType1_6_4.Byte, MetaType1_6_4.Float), - BOAT_DAMAGE_TAKEN(Entity1_10Types.EntityType.BOAT, 19, MetaType1_6_4.Int, MetaType1_6_4.Float), - MINECART_DAMAGE_TAKEN(Entity1_10Types.EntityType.MINECART_ABSTRACT, 19, MetaType1_6_4.Int, MetaType1_6_4.Float), - WITHER_HEALTH(Entity1_10Types.EntityType.WITHER, 16, MetaType1_6_4.Int, 6, MetaType1_6_4.Float), - ENDER_DRAGON_HEALTH(Entity1_10Types.EntityType.ENDER_DRAGON, 16, MetaType1_6_4.Int, 6, MetaType1_6_4.Float), - WOLF_HEALTH(Entity1_10Types.EntityType.WOLF, 18, MetaType1_6_4.Int, MetaType1_6_4.Float), + ENTITY_LIVING_POTION_EFFECT_COLOR(EntityTypes1_10.EntityType.ENTITY_LIVING, 8, MetaType1_6_4.Int, 7, MetaType1_6_4.Int), + ENTITY_LIVING_IS_POTION_EFFECT_AMBIENT(EntityTypes1_10.EntityType.ENTITY_LIVING, 9, MetaType1_6_4.Byte, 8, MetaType1_6_4.Byte), + ENTITY_LIVING_ARROWS(EntityTypes1_10.EntityType.ENTITY_LIVING, 10, MetaType1_6_4.Byte, 9, MetaType1_6_4.Byte), + ENTITY_LIVING_NAME_TAG(EntityTypes1_10.EntityType.ENTITY_LIVING, 5, MetaType1_6_4.String, 10, MetaType1_6_4.String), + ENTITY_LIVING_NAME_TAG_VISIBILITY(EntityTypes1_10.EntityType.ENTITY_LIVING, 6, MetaType1_6_4.Byte, 11, MetaType1_6_4.Byte), + HUMAN_ABSORPTION_HEARTS(EntityTypes1_10.EntityType.ENTITY_HUMAN, 17, MetaType1_6_4.Byte, MetaType1_6_4.Float), + BOAT_DAMAGE_TAKEN(EntityTypes1_10.EntityType.BOAT, 19, MetaType1_6_4.Int, MetaType1_6_4.Float), + MINECART_DAMAGE_TAKEN(EntityTypes1_10.EntityType.MINECART_ABSTRACT, 19, MetaType1_6_4.Int, MetaType1_6_4.Float), + WITHER_HEALTH(EntityTypes1_10.EntityType.WITHER, 16, MetaType1_6_4.Int, 6, MetaType1_6_4.Float), + ENDER_DRAGON_HEALTH(EntityTypes1_10.EntityType.ENDER_DRAGON, 16, MetaType1_6_4.Int, 6, MetaType1_6_4.Float), + WOLF_HEALTH(EntityTypes1_10.EntityType.WOLF, 18, MetaType1_6_4.Int, MetaType1_6_4.Float), ; - private static final HashMap, MetaIndex1_6_1to1_5_2> metadataRewrites = new HashMap<>(); + private static final HashMap, MetaIndex1_6_1to1_5_2> metadataRewrites = new HashMap<>(); static { for (MetaIndex1_6_1to1_5_2 index : MetaIndex1_6_1to1_5_2.values()) { @@ -47,13 +47,13 @@ public enum MetaIndex1_6_1to1_5_2 { } } - private final Entity1_10Types.EntityType entityType; + private final EntityTypes1_10.EntityType entityType; private final int oldIndex; private final int newIndex; private final MetaType1_6_4 oldType; private final MetaType1_6_4 newType; - MetaIndex1_6_1to1_5_2(Entity1_10Types.EntityType entityType, int oldIndex, MetaType1_6_4 oldType, MetaType1_6_4 newType) { + MetaIndex1_6_1to1_5_2(EntityTypes1_10.EntityType entityType, int oldIndex, MetaType1_6_4 oldType, MetaType1_6_4 newType) { this.entityType = entityType; this.oldIndex = oldIndex; this.newIndex = oldIndex; @@ -61,7 +61,7 @@ public enum MetaIndex1_6_1to1_5_2 { this.newType = newType; } - MetaIndex1_6_1to1_5_2(Entity1_10Types.EntityType entityType, int oldIndex, MetaType1_6_4 oldType, int newIndex, MetaType1_6_4 newType) { + MetaIndex1_6_1to1_5_2(EntityTypes1_10.EntityType entityType, int oldIndex, MetaType1_6_4 oldType, int newIndex, MetaType1_6_4 newType) { this.entityType = entityType; this.oldIndex = oldIndex; this.oldType = oldType; @@ -69,7 +69,7 @@ public enum MetaIndex1_6_1to1_5_2 { this.newType = newType; } - public Entity1_10Types.EntityType getEntityType() { + public EntityTypes1_10.EntityType getEntityType() { return this.entityType; } @@ -89,13 +89,13 @@ public MetaType1_6_4 getNewType() { return this.newType; } - private static Optional getIndex(Entity1_10Types.EntityType type, int index) { - final Pair pair = new Pair<>(type, index); + private static Optional getIndex(EntityTypes1_10.EntityType type, int index) { + final Pair pair = new Pair<>(type, index); return Optional.ofNullable(metadataRewrites.get(pair)); } - public static MetaIndex1_6_1to1_5_2 searchIndex(Entity1_10Types.EntityType type, int index) { - Entity1_10Types.EntityType currentType = type; + public static MetaIndex1_6_1to1_5_2 searchIndex(EntityTypes1_10.EntityType type, int index) { + EntityTypes1_10.EntityType currentType = type; do { Optional optMeta = getIndex(currentType, index); if (optMeta.isPresent()) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/metadata/MetadataRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/metadata/MetadataRewriter.java index 1818067..a9e4ac9 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/metadata/MetadataRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/metadata/MetadataRewriter.java @@ -17,7 +17,7 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.metadata; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import net.raphimc.vialegacy.ViaLegacy; @@ -27,7 +27,7 @@ public class MetadataRewriter { - public static void transform(Entity1_10Types.EntityType type, List list) { + public static void transform(EntityTypes1_10.EntityType type, List list) { for (Metadata entry : new ArrayList<>(list)) { final MetaIndex1_6_1to1_5_2 metaIndex = MetaIndex1_6_1to1_5_2.searchIndex(type, entry.id()); try { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/EntityTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/EntityTracker.java index 9bc62ae..48d1b64 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/EntityTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_6_1to1_5_2/storage/EntityTracker.java @@ -19,14 +19,14 @@ import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class EntityTracker extends StoredObject { - private final Map entityMap = new ConcurrentHashMap<>(); + private final Map entityMap = new ConcurrentHashMap<>(); private int playerID; @@ -46,7 +46,7 @@ public void removeEntity(int entityId) { this.entityMap.remove(entityId); } - public Map getTrackedEntities() { + public Map getTrackedEntities() { return this.entityMap; } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/Protocol1_7_2_5to1_6_4.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/Protocol1_7_2_5to1_6_4.java index 5229f83..785137e 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/Protocol1_7_2_5to1_6_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/Protocol1_7_2_5to1_6_4.java @@ -22,9 +22,10 @@ import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; @@ -44,7 +45,6 @@ import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets; import com.viaversion.viaversion.protocols.base.ServerboundStatusPackets; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; @@ -66,8 +66,8 @@ import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.Protocol1_8to1_7_6_10; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.model.GameProfile; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Chunk1_7_6Type; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulk1_7_6Type; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulkType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.MetaType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6; @@ -342,7 +342,7 @@ public void register() { map(Type.INT); // data handler(wrapper -> { int data = wrapper.get(Type.INT, 3); - if (Entity1_10Types.getTypeFromId(wrapper.get(Type.BYTE, 0), true) == Entity1_10Types.ObjectType.FALLING_BLOCK.getType()) { + if (EntityTypes1_10.getTypeFromId(wrapper.get(Type.BYTE, 0), true) == EntityTypes1_10.ObjectType.FALLING_BLOCK.getType()) { final int id = data & 0xFFFF; final int metadata = data >> 16; final IdAndData block = new IdAndData(id, metadata); @@ -421,7 +421,7 @@ public void register() { @Override public void register() { handler(wrapper -> { - final Chunk chunk = wrapper.passthrough(new Chunk1_7_6Type(wrapper.user().get(ClientWorld.class))); + final Chunk chunk = wrapper.passthrough(new ChunkType1_7_6(wrapper.user().get(ClientWorld.class))); wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk); }); } @@ -486,7 +486,7 @@ public void register() { @Override public void register() { handler(wrapper -> { - final Chunk[] chunks = wrapper.passthrough(new ChunkBulk1_7_6Type(wrapper.user().get(ClientWorld.class))); + final Chunk[] chunks = wrapper.passthrough(new ChunkBulkType1_7_6(wrapper.user().get(ClientWorld.class))); for (Chunk chunk : chunks) { wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/rewriter/TranslationRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/rewriter/TranslationRewriter.java index 46b8d84..6d9f6bc 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/rewriter/TranslationRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/rewriter/TranslationRewriter.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.libs.fastutil.objects.Object2ObjectOpenHashMap; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.ClientboundPackets1_6_4; public class TranslationRewriter { @@ -66,7 +67,7 @@ public class TranslationRewriter { TRANSLATIONS.put("mco.configure.world.restore.question.line1", "Your realm will be restored to a previous version"); } - private static final ComponentRewriter REWRITER = new ComponentRewriter() { + private static final ComponentRewriter REWRITER = new ComponentRewriter(null, ComponentRewriter.ReadType.JSON) { @Override protected void handleTranslate(JsonObject object, String translate) { final String text = TRANSLATIONS.get(translate); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/MetadataType.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/MetadataType.java index 77ffd05..0e2b820 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/MetadataType.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/MetadataType.java @@ -18,7 +18,7 @@ package net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; -import com.viaversion.viaversion.api.type.types.minecraft.OldMetaType; +import com.viaversion.viaversion.api.type.types.metadata.OldMetaType; public class MetadataType extends OldMetaType { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/Types1_6_4.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/Types1_6_4.java index 3e9f9f6..0b1330b 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/Types1_6_4.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_2_5to1_6_4/types/Types1_6_4.java @@ -19,7 +19,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.minecraft.MetaListType; +import com.viaversion.viaversion.api.type.types.metadata.MetaListType; import java.util.List; diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_6_10to1_7_2_5/rewriter/TranslationRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_6_10to1_7_2_5/rewriter/TranslationRewriter.java index 48feaa0..ffb1e1e 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_6_10to1_7_2_5/rewriter/TranslationRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_7_6_10to1_7_2_5/rewriter/TranslationRewriter.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.libs.fastutil.objects.Object2ObjectOpenHashMap; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import net.raphimc.vialegacy.protocols.release.protocol1_7_6_10to1_7_2_5.ClientboundPackets1_7_2; public class TranslationRewriter { @@ -115,7 +116,7 @@ public class TranslationRewriter { TRANSLATIONS.put("mco.invites.nopending", "No pending invitations!"); } - private static final ComponentRewriter REWRITER = new ComponentRewriter() { + private static final ComponentRewriter REWRITER = new ComponentRewriter(null, ComponentRewriter.ReadType.JSON) { @Override protected void handleTranslate(JsonObject object, String translate) { final String text = TRANSLATIONS.get(translate); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/Protocol1_8to1_7_6_10.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/Protocol1_8to1_7_6_10.java index 5fce4d7..4d46f21 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/Protocol1_8to1_7_6_10.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/Protocol1_8to1_7_6_10.java @@ -22,9 +22,10 @@ import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; @@ -34,6 +35,9 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.type.Type; +import com.viaversion.viaversion.api.type.types.chunk.BulkChunkType1_8; +import com.viaversion.viaversion.api.type.types.chunk.ChunkSectionType1_8; +import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_8; import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; @@ -41,9 +45,6 @@ import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.types.Chunk1_8Type; -import com.viaversion.viaversion.protocols.protocol1_9to1_8.types.ChunkBulk1_8Type; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import net.lenni0451.mcstructs.text.serializer.TextComponentSerializer; @@ -63,8 +64,8 @@ import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.rewriter.ItemRewriter; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.rewriter.TranslationRewriter; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage.*; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Chunk1_7_6Type; -import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulk1_7_6Type; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6; +import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulkType1_7_6; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6; import java.nio.charset.StandardCharsets; @@ -135,7 +136,7 @@ public void register() { final int entityId = wrapper.get(Type.INT, 0); final byte dimensionId = wrapper.get(Type.BYTE, 0); final EntityTracker tracker = wrapper.user().get(EntityTracker.class); - tracker.trackEntity(entityId, Entity1_10Types.EntityType.PLAYER); + tracker.trackEntity(entityId, EntityTypes1_10.EntityType.PLAYER); tracker.setPlayerID(entityId); wrapper.user().get(DimensionTracker.class).setDimension(dimensionId); wrapper.user().get(ClientWorld.class).setEnvironment(dimensionId); @@ -154,14 +155,14 @@ public void register() { public void register() { map(Type.INT, Type.VAR_INT); // entity id map(Type.SHORT); // slot - map(Types1_7_6.COMPRESSED_ITEM, Type.ITEM); // item - handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Type.ITEM, 0))); + map(Types1_7_6.COMPRESSED_ITEM, Type.ITEM1_8); // item + handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Type.ITEM1_8, 0))); } }); this.registerClientbound(ClientboundPackets1_7_2.SPAWN_POSITION, new PacketHandlers() { @Override public void register() { - map(Types1_7_6.POSITION_INT, Type.POSITION); // position + map(Types1_7_6.POSITION_INT, Type.POSITION1_8); // position } }); this.registerClientbound(ClientboundPackets1_7_2.UPDATE_HEALTH, new PacketHandlers() { @@ -212,7 +213,7 @@ public void register() { @Override public void register() { map(Type.INT, Type.VAR_INT); // entity id - map(Types1_7_6.POSITION_BYTE, Type.POSITION); // position + map(Types1_7_6.POSITION_BYTE, Type.POSITION1_8); // position } }); this.registerClientbound(ClientboundPackets1_7_2.SPAWN_PLAYER, new PacketHandlers() { @@ -247,14 +248,14 @@ public void register() { wrapper.write(Type.SHORT, (short) currentItem.identifier()); final List metadata = wrapper.read(Types1_7_6.METADATA_LIST); // metadata - metadataRewriter.transform(Entity1_10Types.EntityType.PLAYER, metadata); + metadataRewriter.transform(EntityTypes1_10.EntityType.PLAYER, metadata); wrapper.write(Types1_8.METADATA_LIST, metadata); tablistStorage.sendTempEntry(tempTabEntry); }); handler(wrapper -> { final int entityID = wrapper.get(Type.VAR_INT, 0); - wrapper.user().get(EntityTracker.class).trackEntity(entityID, Entity1_10Types.EntityType.PLAYER); + wrapper.user().get(EntityTracker.class).trackEntity(entityID, EntityTypes1_10.EntityType.PLAYER); }); } }); @@ -286,18 +287,18 @@ public void register() { final int x = wrapper.get(Type.INT, 0); final int y = wrapper.get(Type.INT, 1); final int z = wrapper.get(Type.INT, 2); - tracker.trackEntity(entityID, Entity1_10Types.getTypeFromId(typeID, true)); + tracker.trackEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, true)); tracker.updateEntityLocation(entityID, x, y, z, false); }); handler(wrapper -> { - final Entity1_10Types.EntityType type = Entity1_10Types.getTypeFromId(wrapper.get(Type.BYTE, 0), true); + final EntityTypes1_10.EntityType type = EntityTypes1_10.getTypeFromId(wrapper.get(Type.BYTE, 0), true); int x = wrapper.get(Type.INT, 0); int y = wrapper.get(Type.INT, 1); int z = wrapper.get(Type.INT, 2); byte yaw = wrapper.get(Type.BYTE, 2); int data = wrapper.get(Type.INT, 3); - if (type == Entity1_10Types.ObjectType.ITEM_FRAME.getType()) { + if (type == EntityTypes1_10.ObjectType.ITEM_FRAME.getType()) { switch (data) { case 0: z += 32; @@ -316,7 +317,7 @@ public void register() { yaw = -64; break; } - } else if (type == Entity1_10Types.ObjectType.FALLING_BLOCK.getType()) { + } else if (type == EntityTypes1_10.ObjectType.FALLING_BLOCK.getType()) { final int id = data & 0xffff; final int metadata = data >> 16; final IdAndData block = new IdAndData(id, metadata); @@ -357,7 +358,7 @@ public void register() { final int y = wrapper.get(Type.INT, 1); final int z = wrapper.get(Type.INT, 2); final List metadataList = wrapper.get(Types1_8.METADATA_LIST, 0); - final Entity1_10Types.EntityType entityType = Entity1_10Types.getTypeFromId(typeID, false); + final EntityTypes1_10.EntityType entityType = EntityTypes1_10.getTypeFromId(typeID, false); tracker.trackEntity(entityID, entityType); tracker.updateEntityLocation(entityID, x, y, z, false); tracker.updateEntityMetadata(entityID, metadataList); @@ -371,11 +372,11 @@ public void register() { public void register() { map(Type.VAR_INT); // entity id map(Type.STRING); // motive - map(Types1_7_6.POSITION_INT, Type.POSITION); // position + map(Types1_7_6.POSITION_INT, Type.POSITION1_8); // position map(Type.INT, Type.BYTE); // rotation handler(wrapper -> { final short rotation = wrapper.get(Type.BYTE, 0); - final Position pos = wrapper.get(Type.POSITION, 0); + final Position pos = wrapper.get(Type.POSITION1_8, 0); int modX = 0; int modZ = 0; switch (rotation) { @@ -392,11 +393,11 @@ public void register() { modX = 1; break; } - wrapper.set(Type.POSITION, 0, new Position(pos.x() + modX, pos.y(), pos.z() + modZ)); + wrapper.set(Type.POSITION1_8, 0, new Position(pos.x() + modX, pos.y(), pos.z() + modZ)); }); handler(wrapper -> { final int entityID = wrapper.get(Type.VAR_INT, 0); - wrapper.user().get(EntityTracker.class).trackEntity(entityID, Entity1_10Types.EntityType.PAINTING); + wrapper.user().get(EntityTracker.class).trackEntity(entityID, EntityTypes1_10.EntityType.PAINTING); }); } }); @@ -410,9 +411,9 @@ public void register() { map(Type.SHORT); // count handler(wrapper -> { final int entityID = wrapper.get(Type.VAR_INT, 0); - wrapper.user().get(EntityTracker.class).trackEntity(entityID, Entity1_10Types.EntityType.EXPERIENCE_ORB); + wrapper.user().get(EntityTracker.class).trackEntity(entityID, EntityTypes1_10.EntityType.EXPERIENCE_ORB); - wrapper.set(Type.INT, 1, realignEntityY(Entity1_10Types.EntityType.EXPERIENCE_ORB, wrapper.get(Type.INT, 1))); + wrapper.set(Type.INT, 1, realignEntityY(EntityTypes1_10.EntityType.EXPERIENCE_ORB, wrapper.get(Type.INT, 1))); }); } }); @@ -535,7 +536,7 @@ public void register() { }); handler(wrapper -> { final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); - final Entity1_10Types.EntityType type = entityTracker.getTrackedEntities().get(wrapper.get(Type.VAR_INT, 0)); + final EntityTypes1_10.EntityType type = entityTracker.getTrackedEntities().get(wrapper.get(Type.VAR_INT, 0)); wrapper.set(Type.INT, 1, realignEntityY(type, wrapper.get(Type.INT, 1))); }); @@ -633,9 +634,9 @@ public void register() { @Override public void register() { handler(wrapper -> { - final Chunk chunk = wrapper.read(new Chunk1_7_6Type(wrapper.user().get(ClientWorld.class))); + final Chunk chunk = wrapper.read(new ChunkType1_7_6(wrapper.user().get(ClientWorld.class))); wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk); - wrapper.write(new Chunk1_8Type(wrapper.user().get(ClientWorld.class)), chunk); + wrapper.write(new ChunkType1_8(wrapper.user().get(ClientWorld.class)), chunk); }); } }); @@ -664,11 +665,11 @@ public void register() { this.registerClientbound(ClientboundPackets1_7_2.BLOCK_CHANGE, new PacketHandlers() { @Override public void register() { - map(Types1_7_6.POSITION_UBYTE, Type.POSITION); // position + map(Types1_7_6.POSITION_UBYTE, Type.POSITION1_8); // position handler(wrapper -> { final int blockId = wrapper.read(Type.VAR_INT); // block id final int data = wrapper.read(Type.UNSIGNED_BYTE); // block data - final Position pos = wrapper.get(Type.POSITION, 0); // position + final Position pos = wrapper.get(Type.POSITION1_8, 0); // position final IdAndData block = new IdAndData(blockId, data); wrapper.user().get(ChunkTracker.class).trackAndRemap(pos, block); wrapper.write(Type.VAR_INT, block.toCompressedData()); @@ -678,7 +679,7 @@ public void register() { this.registerClientbound(ClientboundPackets1_7_2.BLOCK_ACTION, new PacketHandlers() { @Override public void register() { - map(Types1_7_6.POSITION_SHORT, Type.POSITION); // position + map(Types1_7_6.POSITION_SHORT, Type.POSITION1_8); // position map(Type.UNSIGNED_BYTE); // type map(Type.UNSIGNED_BYTE); // data map(Type.VAR_INT); // block id @@ -688,7 +689,7 @@ public void register() { @Override public void register() { map(Type.VAR_INT); // entity id - map(Types1_7_6.POSITION_INT, Type.POSITION); // position + map(Types1_7_6.POSITION_INT, Type.POSITION1_8); // position map(Type.BYTE); // progress } }); @@ -696,11 +697,11 @@ public void register() { @Override public void register() { handler(wrapper -> { - final Chunk[] chunks = wrapper.read(new ChunkBulk1_7_6Type(wrapper.user().get(ClientWorld.class))); + final Chunk[] chunks = wrapper.read(new ChunkBulkType1_7_6(wrapper.user().get(ClientWorld.class))); for (Chunk chunk : chunks) { wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk); } - wrapper.write(new ChunkBulk1_8Type(wrapper.user().get(ClientWorld.class)), chunks); + wrapper.write(new BulkChunkType1_8(wrapper.user().get(ClientWorld.class)), chunks); }); } }); @@ -782,7 +783,7 @@ public void register() { } wrapper.write(Type.INT, effectId); - wrapper.write(Type.POSITION, pos); + wrapper.write(Type.POSITION1_8, pos); wrapper.write(Type.INT, data); wrapper.write(Type.BOOLEAN, disableRelativeVolume); } @@ -931,8 +932,8 @@ public void register() { if (windowType == 4/*enchanting_table*/ && slot >= 1) slot += 1; wrapper.write(Type.SHORT, slot); }); - map(Types1_7_6.COMPRESSED_ITEM, Type.ITEM); // item - handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Type.ITEM, 0))); + map(Types1_7_6.COMPRESSED_ITEM, Type.ITEM1_8); // item + handler(wrapper -> itemRewriter.handleItemToClient(wrapper.get(Type.ITEM1_8, 0))); } }); this.registerClientbound(ClientboundPackets1_7_2.WINDOW_ITEMS, new PacketHandlers() { @@ -952,7 +953,7 @@ public void register() { for (Item item : items) { itemRewriter.handleItemToClient(item); } - wrapper.write(Type.ITEM_ARRAY, items); + wrapper.write(Type.ITEM1_8_ARRAY, items); }); } }); @@ -994,7 +995,7 @@ public void register() { this.registerClientbound(ClientboundPackets1_7_2.UPDATE_SIGN, new PacketHandlers() { @Override public void register() { - map(Types1_7_6.POSITION_SHORT, Type.POSITION); // position + map(Types1_7_6.POSITION_SHORT, Type.POSITION1_8); // position map(LEGACY_TO_JSON); // line 1 map(LEGACY_TO_JSON); // line 2 map(LEGACY_TO_JSON); // line 3 @@ -1052,7 +1053,7 @@ public void register() { this.registerClientbound(ClientboundPackets1_7_2.BLOCK_ENTITY_DATA, new PacketHandlers() { @Override public void register() { - map(Types1_7_6.POSITION_SHORT, Type.POSITION); // position + map(Types1_7_6.POSITION_SHORT, Type.POSITION1_8); // position map(Type.UNSIGNED_BYTE); // type map(Types1_7_6.COMPRESSED_NBT, Type.NAMED_COMPOUND_TAG); // data } @@ -1060,7 +1061,7 @@ public void register() { this.registerClientbound(ClientboundPackets1_7_2.OPEN_SIGN_EDITOR, new PacketHandlers() { @Override public void register() { - map(Types1_7_6.POSITION_INT, Type.POSITION); // position + map(Types1_7_6.POSITION_INT, Type.POSITION1_8); // position } }); this.registerClientbound(ClientboundPackets1_7_2.PLAYER_INFO, new PacketHandlers() { @@ -1177,17 +1178,17 @@ public void register() { for (int i = 0; i < count; i++) { Item item = wrapper.read(Types1_7_6.COMPRESSED_ITEM); itemRewriter.handleItemToClient(item); - wrapper.write(Type.ITEM, item); // item 1 + wrapper.write(Type.ITEM1_8, item); // item 1 item = wrapper.read(Types1_7_6.COMPRESSED_ITEM); itemRewriter.handleItemToClient(item); - wrapper.write(Type.ITEM, item); // item 3 + wrapper.write(Type.ITEM1_8, item); // item 3 final boolean has3Items = wrapper.passthrough(Type.BOOLEAN); // has 3 items if (has3Items) { item = wrapper.read(Types1_7_6.COMPRESSED_ITEM); itemRewriter.handleItemToClient(item); - wrapper.write(Type.ITEM, item); // item 2 + wrapper.write(Type.ITEM1_8, item); // item 2 } wrapper.passthrough(Type.BOOLEAN); // unavailable @@ -1234,8 +1235,8 @@ public void register() { wrapper.read(Type.FLOAT); // offsetY wrapper.read(Type.FLOAT); // offsetZ final EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); - final Entity1_10Types.EntityType entityType = entityTracker.getTrackedEntities().get(wrapper.get(Type.INT, 0)); - if (entityType == null || !entityType.isOrHasParent(Entity1_10Types.EntityType.ARMOR_STAND)) { + final EntityTypes1_10.EntityType entityType = entityTracker.getTrackedEntities().get(wrapper.get(Type.INT, 0)); + if (entityType == null || !entityType.isOrHasParent(EntityTypes1_10.EntityType.ARMOR_STAND)) { wrapper.cancel(); } } else { @@ -1270,16 +1271,16 @@ public void register() { @Override public void register() { map(Type.VAR_INT, Type.UNSIGNED_BYTE); // status - map(Type.POSITION, Types1_7_6.POSITION_UBYTE); // position + map(Type.POSITION1_8, Types1_7_6.POSITION_UBYTE); // position map(Type.UNSIGNED_BYTE); // direction } }); this.registerServerbound(ServerboundPackets1_8.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() { @Override public void register() { - map(Type.POSITION, Types1_7_6.POSITION_UBYTE); // position + map(Type.POSITION1_8, Types1_7_6.POSITION_UBYTE); // position map(Type.UNSIGNED_BYTE); // direction - map(Type.ITEM, Types1_7_6.COMPRESSED_ITEM); // item + map(Type.ITEM1_8, Types1_7_6.COMPRESSED_ITEM); // item map(Type.UNSIGNED_BYTE); // offset x map(Type.UNSIGNED_BYTE); // offset y map(Type.UNSIGNED_BYTE); // offset z @@ -1342,12 +1343,12 @@ public void register() { final PacketWrapper resetHandItem = PacketWrapper.create(ClientboundPackets1_8.SET_SLOT, wrapper.user()); resetHandItem.write(Type.UNSIGNED_BYTE, (short) -1); // window id resetHandItem.write(Type.SHORT, (short) 0); // slot - resetHandItem.write(Type.ITEM, new DataItem(-1, (byte) 0, (short) 0, null)); + resetHandItem.write(Type.ITEM1_8, new DataItem(-1, (byte) 0, (short) 0, null)); resetHandItem.send(Protocol1_8to1_7_6_10.class); final PacketWrapper setLapisSlot = PacketWrapper.create(ClientboundPackets1_8.SET_SLOT, wrapper.user()); setLapisSlot.write(Type.UNSIGNED_BYTE, windowId); setLapisSlot.write(Type.SHORT, slot); - setLapisSlot.write(Type.ITEM, new DataItem(351/*lapis_lazuli*/, (byte) 3, (short) 4, null)); + setLapisSlot.write(Type.ITEM1_8, new DataItem(351/*lapis_lazuli*/, (byte) 3, (short) 4, null)); setLapisSlot.send(Protocol1_8to1_7_6_10.class); wrapper.cancel(); } else if (slot > 1) { @@ -1358,7 +1359,7 @@ public void register() { map(Type.BYTE); // button map(Type.SHORT); // transaction id map(Type.BYTE); // action - map(Type.ITEM, Types1_7_6.COMPRESSED_ITEM); // item + map(Type.ITEM1_8, Types1_7_6.COMPRESSED_ITEM); // item handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0))); } }); @@ -1366,14 +1367,14 @@ public void register() { @Override public void register() { map(Type.SHORT); // slot - map(Type.ITEM, Types1_7_6.COMPRESSED_ITEM); // item + map(Type.ITEM1_8, Types1_7_6.COMPRESSED_ITEM); // item handler(wrapper -> itemRewriter.handleItemToServer(wrapper.get(Types1_7_6.COMPRESSED_ITEM, 0))); } }); this.registerServerbound(ServerboundPackets1_8.UPDATE_SIGN, new PacketHandlers() { @Override public void register() { - map(Type.POSITION, Types1_7_6.POSITION_SHORT); // position + map(Type.POSITION1_8, Types1_7_6.POSITION_SHORT); // position handler(wrapper -> { for (int i = 0; i < 4; i++) { final JsonElement component = wrapper.read(Type.COMPONENT); // line @@ -1426,7 +1427,7 @@ public void register() { switch (channel) { case "MC|BEdit": case "MC|BSign": - final Item item = wrapper.read(Type.ITEM); // book + final Item item = wrapper.read(Type.ITEM1_8); // book itemRewriter.handleItemToServer(item); lengthPacketWrapper.write(Types1_7_6.COMPRESSED_ITEM, item); @@ -1555,24 +1556,24 @@ private float randomFloatClamp(Random rnd, float min, float max) { return min >= max ? min : rnd.nextFloat() * (max - min) + min; } - private int realignEntityY(final Entity1_10Types.EntityType type, final int y) { + private int realignEntityY(final EntityTypes1_10.EntityType type, final int y) { float yPos = y / 32F; float yOffset = 0F; - if (type == Entity1_10Types.ObjectType.FALLING_BLOCK.getType()) + if (type == EntityTypes1_10.ObjectType.FALLING_BLOCK.getType()) yOffset = 0.98F / 2F; - if (type == Entity1_10Types.ObjectType.TNT_PRIMED.getType()) + if (type == EntityTypes1_10.ObjectType.TNT_PRIMED.getType()) yOffset = 0.98F / 2F; - if (type == Entity1_10Types.ObjectType.ENDER_CRYSTAL.getType()) + if (type == EntityTypes1_10.ObjectType.ENDER_CRYSTAL.getType()) yOffset = 1F; - else if (type == Entity1_10Types.ObjectType.MINECART.getType()) + else if (type == EntityTypes1_10.ObjectType.MINECART.getType()) yOffset = 0.7F / 2F; - else if (type == Entity1_10Types.ObjectType.BOAT.getType()) + else if (type == EntityTypes1_10.ObjectType.BOAT.getType()) yOffset = 0.6F / 2F; - else if (type == Entity1_10Types.ObjectType.ITEM.getType()) + else if (type == EntityTypes1_10.ObjectType.ITEM.getType()) yOffset = 0.25F / 2F; - else if (type == Entity1_10Types.ObjectType.LEASH.getType()) + else if (type == EntityTypes1_10.ObjectType.LEASH.getType()) yOffset = 0.5F; - else if (type == Entity1_10Types.EntityType.EXPERIENCE_ORB) + else if (type == EntityTypes1_10.EntityType.EXPERIENCE_ORB) yOffset = 0.5F / 2F; return (int) Math.floor((yPos - yOffset) * 32F); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/metadata/MetaIndex1_8to1_7_6.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/metadata/MetaIndex1_8to1_7_6.java index 8cc28a1..238fbe6 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/metadata/MetaIndex1_8to1_7_6.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/metadata/MetaIndex1_8to1_7_6.java @@ -17,7 +17,7 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.metadata; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8; import com.viaversion.viaversion.util.Pair; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.MetaType1_7_6; @@ -27,89 +27,89 @@ public enum MetaIndex1_8to1_7_6 { - ENTITY_FLAGS(Entity1_10Types.EntityType.ENTITY, 0, MetaType1_7_6.Byte, MetaType1_8.Byte), - ENTITY_AIR(Entity1_10Types.EntityType.ENTITY, 1, MetaType1_7_6.Short, MetaType1_8.Short), - ENTITY_NAME_TAG(Entity1_10Types.EntityType.ENTITY, -1, null, 2, MetaType1_8.String), - ENTITY_NAME_TAG_VISIBILITY(Entity1_10Types.EntityType.ENTITY, -1, null, 3, MetaType1_8.Byte), - ENTITY_SILENT(Entity1_10Types.EntityType.ENTITY, -1, null, 4, MetaType1_8.Byte), - ENTITY_LIVING_HEALTH(Entity1_10Types.EntityType.ENTITY_LIVING, 6, MetaType1_7_6.Float, MetaType1_8.Float), - ENTITY_LIVING_POTION_EFFECT_COLOR(Entity1_10Types.EntityType.ENTITY_LIVING, 7, MetaType1_7_6.Int, MetaType1_8.Int), - ENTITY_LIVING_IS_POTION_EFFECT_AMBIENT(Entity1_10Types.EntityType.ENTITY_LIVING, 8, MetaType1_7_6.Byte, MetaType1_8.Byte), - ENTITY_LIVING_ARROWS(Entity1_10Types.EntityType.ENTITY_LIVING, 9, MetaType1_7_6.Byte, MetaType1_8.Byte), - ENTITY_LIVING_NAME_TAG(Entity1_10Types.EntityType.ENTITY_LIVING, 10, MetaType1_7_6.String, 2, MetaType1_8.String), - ENTITY_LIVING_NAME_TAG_VISIBILITY(Entity1_10Types.EntityType.ENTITY_LIVING, 11, MetaType1_7_6.Byte, 3, MetaType1_8.Byte), - ENTITY_LIVING_AI(Entity1_10Types.EntityType.ENTITY_LIVING, -1, null, 15, MetaType1_8.Byte), - ENTITY_AGEABLE_AGE(Entity1_10Types.EntityType.ENTITY_AGEABLE, 12, MetaType1_7_6.Int, MetaType1_8.Byte), - ARMOR_STAND_FLAGS(Entity1_10Types.EntityType.ARMOR_STAND, -1, null, 10, MetaType1_8.Byte), - ARMOR_STAND_HEAD_POSITION(Entity1_10Types.EntityType.ARMOR_STAND, -1, null, 11, MetaType1_8.Rotation), - ARMOR_STAND_BODY_POSITION(Entity1_10Types.EntityType.ARMOR_STAND, -1, null, 12, MetaType1_8.Rotation), - ARMOR_STAND_LEFT_ARM_POSITION(Entity1_10Types.EntityType.ARMOR_STAND, -1, null, 13, MetaType1_8.Rotation), - ARMOR_STAND_RIGHT_ARM_POSITION(Entity1_10Types.EntityType.ARMOR_STAND, -1, null, 14, MetaType1_8.Rotation), - ARMOR_STAND_LEFT_LEG_POSITION(Entity1_10Types.EntityType.ARMOR_STAND, -1, null, 15, MetaType1_8.Rotation), - ARMOR_STAND_RIGHT_LEG_POSITION(Entity1_10Types.EntityType.ARMOR_STAND, -1, null, 16, MetaType1_8.Rotation), - HUMAN_SKIN_FLAGS(Entity1_10Types.EntityType.ENTITY_HUMAN, 16, MetaType1_7_6.Byte, 10, MetaType1_8.Byte), - HUMAN_UNUSED(Entity1_10Types.EntityType.ENTITY_HUMAN, -1, null, 16, MetaType1_8.Byte), - HUMAN_ABSORPTION_HEATS(Entity1_10Types.EntityType.ENTITY_HUMAN, 17, MetaType1_7_6.Float, MetaType1_8.Float), - HUMAN_SCORE(Entity1_10Types.EntityType.ENTITY_HUMAN, 18, MetaType1_7_6.Int, MetaType1_8.Int), - HORSE_FLAGS(Entity1_10Types.EntityType.HORSE, 16, MetaType1_7_6.Int, MetaType1_8.Int), - HORSE_TYPE(Entity1_10Types.EntityType.HORSE, 19, MetaType1_7_6.Byte, MetaType1_8.Byte), - HORSE_COLOR(Entity1_10Types.EntityType.HORSE, 20, MetaType1_7_6.Int, MetaType1_8.Int), - HORSE_OWNER(Entity1_10Types.EntityType.HORSE, 21, MetaType1_7_6.String, MetaType1_8.String), - HORSE_ARMOR(Entity1_10Types.EntityType.HORSE, 22, MetaType1_7_6.Int, MetaType1_8.Int), - BAT_HANGING(Entity1_10Types.EntityType.BAT, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - TAMEABLE_FLAGS(Entity1_10Types.EntityType.ENTITY_TAMEABLE_ANIMAL, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - TAMEABLE_OWNER(Entity1_10Types.EntityType.ENTITY_TAMEABLE_ANIMAL, 17, MetaType1_7_6.String, MetaType1_8.String), - OCELOT_TYPE(Entity1_10Types.EntityType.OCELOT, 18, MetaType1_7_6.Byte, MetaType1_8.Byte), - WOLF_HEALTH(Entity1_10Types.EntityType.WOLF, 18, MetaType1_7_6.Float, MetaType1_8.Float), - WOLF_BEGGING(Entity1_10Types.EntityType.WOLF, 19, MetaType1_7_6.Byte, MetaType1_8.Byte), - WOLF_COLLAR_COLOR(Entity1_10Types.EntityType.WOLF, 20, MetaType1_7_6.Byte, MetaType1_8.Byte), - PIG_SADDLE(Entity1_10Types.EntityType.PIG, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - SHEEP_COLOR_OR_SHEARED(Entity1_10Types.EntityType.SHEEP, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - VILLAGER_TYPE(Entity1_10Types.EntityType.VILLAGER, 16, MetaType1_7_6.Int, MetaType1_8.Int), - ENDERMAN_CARRIED_BLOCK(Entity1_10Types.EntityType.ENDERMAN, 16, MetaType1_7_6.Byte, MetaType1_8.Short), // merged with ENDERMAN_CARRIED_BLOCK_DATA - ENDERMAN_CARRIED_BLOCK_DATA(Entity1_10Types.EntityType.ENDERMAN, 17, MetaType1_7_6.Byte, MetaType1_8.Byte), // merged to ENDERMAN_CARRIED_BLOCK - ENDERMAN_IS_SCREAMING(Entity1_10Types.EntityType.ENDERMAN, 18, MetaType1_7_6.Byte, MetaType1_8.Byte), - ZOMBIE_CHILD(Entity1_10Types.EntityType.ZOMBIE, 12, MetaType1_7_6.Byte, MetaType1_8.Byte), - ZOMBIE_VILLAGER(Entity1_10Types.EntityType.ZOMBIE, 13, MetaType1_7_6.Byte, MetaType1_8.Byte), - ZOMBIE_CONVERTING(Entity1_10Types.EntityType.ZOMBIE, 14, MetaType1_7_6.Byte, MetaType1_8.Byte), - BLAZE_ON_FIRE(Entity1_10Types.EntityType.BLAZE, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - SPIDER_CLIMBING(Entity1_10Types.EntityType.SPIDER, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - CREEPER_STATE(Entity1_10Types.EntityType.CREEPER, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - CREEPER_POWERED(Entity1_10Types.EntityType.CREEPER, 17, MetaType1_7_6.Byte, MetaType1_8.Byte), - CREEPER_ISIGNITED(Entity1_10Types.EntityType.CREEPER, 18, MetaType1_7_6.Byte, MetaType1_8.Byte), - GHAST_STATE(Entity1_10Types.EntityType.GHAST, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - GHAST_IS_POWERED(Entity1_10Types.EntityType.GHAST, 17, null, MetaType1_8.Byte), - SLIME_SIZE(Entity1_10Types.EntityType.SLIME, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - SKELETON_TYPE(Entity1_10Types.EntityType.SKELETON, 13, MetaType1_7_6.Byte, MetaType1_8.Byte), - WITCH_AGRESSIVE(Entity1_10Types.EntityType.WITCH, 21, MetaType1_7_6.Byte, MetaType1_8.Byte), - IRON_GOLEM_IS_PLAYER_CREATED(Entity1_10Types.EntityType.IRON_GOLEM, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - WITHER_WATCHED_TAGRET_1(Entity1_10Types.EntityType.WITHER, 17, MetaType1_7_6.Int, MetaType1_8.Int), - WITHER_WATCHED_TAGRET_2(Entity1_10Types.EntityType.WITHER, 18, MetaType1_7_6.Int, MetaType1_8.Int), - WITHER_WATCHED_TAGRET_3(Entity1_10Types.EntityType.WITHER, 19, MetaType1_7_6.Int, MetaType1_8.Int), - WITHER_INVULNERABLE_TIME(Entity1_10Types.EntityType.WITHER, 20, MetaType1_7_6.Int, MetaType1_8.Int), - WITHER_SKULL_ISINVULNERABLE(Entity1_10Types.EntityType.WITHER_SKULL, 10, MetaType1_7_6.Byte, MetaType1_8.Byte), - GUARDIAN_FLAGS(Entity1_10Types.EntityType.GUARDIAN, 16, null, MetaType1_8.Byte), - GUARDIAN_TARGET(Entity1_10Types.EntityType.GUARDIAN, 17, null, MetaType1_8.Int), - BOAT_TIME_SINCE_HIT(Entity1_10Types.EntityType.BOAT, 17, MetaType1_7_6.Int, MetaType1_8.Int), - BOAT_FORWARD_DIRECTION(Entity1_10Types.EntityType.BOAT, 18, MetaType1_7_6.Int, MetaType1_8.Int), - BOAT_DAMAGE_TAKEN(Entity1_10Types.EntityType.BOAT, 19, MetaType1_7_6.Float, MetaType1_8.Float), - MINECART_SHAKING_POWER(Entity1_10Types.EntityType.MINECART_ABSTRACT, 17, MetaType1_7_6.Int, MetaType1_8.Int), - MINECART_SHAKING_DIRECTION(Entity1_10Types.EntityType.MINECART_ABSTRACT, 18, MetaType1_7_6.Int, MetaType1_8.Int), - MINECART_DAMAGE_TAKEN(Entity1_10Types.EntityType.MINECART_ABSTRACT, 19, MetaType1_7_6.Float, MetaType1_8.Float), - MINECART_BLOCK_INSIDE(Entity1_10Types.EntityType.MINECART_ABSTRACT, 20, MetaType1_7_6.Int, MetaType1_8.Int), - MINECART_BLOCK_Y(Entity1_10Types.EntityType.MINECART_ABSTRACT, 21, MetaType1_7_6.Int, MetaType1_8.Int), - MINECART_SHOW_BLOCK(Entity1_10Types.EntityType.MINECART_ABSTRACT, 22, MetaType1_7_6.Byte, MetaType1_8.Byte), - FURNACE_MINECART_IS_POWERED(Entity1_10Types.EntityType.MINECART_ABSTRACT, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - ITEM_ITEM(Entity1_10Types.EntityType.DROPPED_ITEM, 10, MetaType1_7_6.Slot, MetaType1_8.Slot), - ARROW_IS_CRITICAL(Entity1_10Types.EntityType.ARROW, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), - FIREWORK_INFO(Entity1_10Types.EntityType.FIREWORK, 8, MetaType1_7_6.Slot, MetaType1_8.Slot), - ITEM_FRAME_ITEM(Entity1_10Types.EntityType.ITEM_FRAME, 2, MetaType1_7_6.Slot, 8, MetaType1_8.Slot), - ITEM_FRAME_ROTATION(Entity1_10Types.EntityType.ITEM_FRAME, 3, MetaType1_7_6.Byte, 9, MetaType1_8.Byte), - ENDER_CRYSTAL_HEALTH(Entity1_10Types.EntityType.ENDER_CRYSTAL, 8, MetaType1_7_6.Int, 8, MetaType1_8.Int), - RABBIT_TYPE(Entity1_10Types.EntityType.RABBIT, -1, null, 18, MetaType1_8.Byte), + ENTITY_FLAGS(EntityTypes1_10.EntityType.ENTITY, 0, MetaType1_7_6.Byte, MetaType1_8.Byte), + ENTITY_AIR(EntityTypes1_10.EntityType.ENTITY, 1, MetaType1_7_6.Short, MetaType1_8.Short), + ENTITY_NAME_TAG(EntityTypes1_10.EntityType.ENTITY, -1, null, 2, MetaType1_8.String), + ENTITY_NAME_TAG_VISIBILITY(EntityTypes1_10.EntityType.ENTITY, -1, null, 3, MetaType1_8.Byte), + ENTITY_SILENT(EntityTypes1_10.EntityType.ENTITY, -1, null, 4, MetaType1_8.Byte), + ENTITY_LIVING_HEALTH(EntityTypes1_10.EntityType.ENTITY_LIVING, 6, MetaType1_7_6.Float, MetaType1_8.Float), + ENTITY_LIVING_POTION_EFFECT_COLOR(EntityTypes1_10.EntityType.ENTITY_LIVING, 7, MetaType1_7_6.Int, MetaType1_8.Int), + ENTITY_LIVING_IS_POTION_EFFECT_AMBIENT(EntityTypes1_10.EntityType.ENTITY_LIVING, 8, MetaType1_7_6.Byte, MetaType1_8.Byte), + ENTITY_LIVING_ARROWS(EntityTypes1_10.EntityType.ENTITY_LIVING, 9, MetaType1_7_6.Byte, MetaType1_8.Byte), + ENTITY_LIVING_NAME_TAG(EntityTypes1_10.EntityType.ENTITY_LIVING, 10, MetaType1_7_6.String, 2, MetaType1_8.String), + ENTITY_LIVING_NAME_TAG_VISIBILITY(EntityTypes1_10.EntityType.ENTITY_LIVING, 11, MetaType1_7_6.Byte, 3, MetaType1_8.Byte), + ENTITY_LIVING_AI(EntityTypes1_10.EntityType.ENTITY_LIVING, -1, null, 15, MetaType1_8.Byte), + ENTITY_AGEABLE_AGE(EntityTypes1_10.EntityType.ENTITY_AGEABLE, 12, MetaType1_7_6.Int, MetaType1_8.Byte), + ARMOR_STAND_FLAGS(EntityTypes1_10.EntityType.ARMOR_STAND, -1, null, 10, MetaType1_8.Byte), + ARMOR_STAND_HEAD_POSITION(EntityTypes1_10.EntityType.ARMOR_STAND, -1, null, 11, MetaType1_8.Rotation), + ARMOR_STAND_BODY_POSITION(EntityTypes1_10.EntityType.ARMOR_STAND, -1, null, 12, MetaType1_8.Rotation), + ARMOR_STAND_LEFT_ARM_POSITION(EntityTypes1_10.EntityType.ARMOR_STAND, -1, null, 13, MetaType1_8.Rotation), + ARMOR_STAND_RIGHT_ARM_POSITION(EntityTypes1_10.EntityType.ARMOR_STAND, -1, null, 14, MetaType1_8.Rotation), + ARMOR_STAND_LEFT_LEG_POSITION(EntityTypes1_10.EntityType.ARMOR_STAND, -1, null, 15, MetaType1_8.Rotation), + ARMOR_STAND_RIGHT_LEG_POSITION(EntityTypes1_10.EntityType.ARMOR_STAND, -1, null, 16, MetaType1_8.Rotation), + HUMAN_SKIN_FLAGS(EntityTypes1_10.EntityType.ENTITY_HUMAN, 16, MetaType1_7_6.Byte, 10, MetaType1_8.Byte), + HUMAN_UNUSED(EntityTypes1_10.EntityType.ENTITY_HUMAN, -1, null, 16, MetaType1_8.Byte), + HUMAN_ABSORPTION_HEATS(EntityTypes1_10.EntityType.ENTITY_HUMAN, 17, MetaType1_7_6.Float, MetaType1_8.Float), + HUMAN_SCORE(EntityTypes1_10.EntityType.ENTITY_HUMAN, 18, MetaType1_7_6.Int, MetaType1_8.Int), + HORSE_FLAGS(EntityTypes1_10.EntityType.HORSE, 16, MetaType1_7_6.Int, MetaType1_8.Int), + HORSE_TYPE(EntityTypes1_10.EntityType.HORSE, 19, MetaType1_7_6.Byte, MetaType1_8.Byte), + HORSE_COLOR(EntityTypes1_10.EntityType.HORSE, 20, MetaType1_7_6.Int, MetaType1_8.Int), + HORSE_OWNER(EntityTypes1_10.EntityType.HORSE, 21, MetaType1_7_6.String, MetaType1_8.String), + HORSE_ARMOR(EntityTypes1_10.EntityType.HORSE, 22, MetaType1_7_6.Int, MetaType1_8.Int), + BAT_HANGING(EntityTypes1_10.EntityType.BAT, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + TAMEABLE_FLAGS(EntityTypes1_10.EntityType.ENTITY_TAMEABLE_ANIMAL, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + TAMEABLE_OWNER(EntityTypes1_10.EntityType.ENTITY_TAMEABLE_ANIMAL, 17, MetaType1_7_6.String, MetaType1_8.String), + OCELOT_TYPE(EntityTypes1_10.EntityType.OCELOT, 18, MetaType1_7_6.Byte, MetaType1_8.Byte), + WOLF_HEALTH(EntityTypes1_10.EntityType.WOLF, 18, MetaType1_7_6.Float, MetaType1_8.Float), + WOLF_BEGGING(EntityTypes1_10.EntityType.WOLF, 19, MetaType1_7_6.Byte, MetaType1_8.Byte), + WOLF_COLLAR_COLOR(EntityTypes1_10.EntityType.WOLF, 20, MetaType1_7_6.Byte, MetaType1_8.Byte), + PIG_SADDLE(EntityTypes1_10.EntityType.PIG, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + SHEEP_COLOR_OR_SHEARED(EntityTypes1_10.EntityType.SHEEP, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + VILLAGER_TYPE(EntityTypes1_10.EntityType.VILLAGER, 16, MetaType1_7_6.Int, MetaType1_8.Int), + ENDERMAN_CARRIED_BLOCK(EntityTypes1_10.EntityType.ENDERMAN, 16, MetaType1_7_6.Byte, MetaType1_8.Short), // merged with ENDERMAN_CARRIED_BLOCK_DATA + ENDERMAN_CARRIED_BLOCK_DATA(EntityTypes1_10.EntityType.ENDERMAN, 17, MetaType1_7_6.Byte, MetaType1_8.Byte), // merged to ENDERMAN_CARRIED_BLOCK + ENDERMAN_IS_SCREAMING(EntityTypes1_10.EntityType.ENDERMAN, 18, MetaType1_7_6.Byte, MetaType1_8.Byte), + ZOMBIE_CHILD(EntityTypes1_10.EntityType.ZOMBIE, 12, MetaType1_7_6.Byte, MetaType1_8.Byte), + ZOMBIE_VILLAGER(EntityTypes1_10.EntityType.ZOMBIE, 13, MetaType1_7_6.Byte, MetaType1_8.Byte), + ZOMBIE_CONVERTING(EntityTypes1_10.EntityType.ZOMBIE, 14, MetaType1_7_6.Byte, MetaType1_8.Byte), + BLAZE_ON_FIRE(EntityTypes1_10.EntityType.BLAZE, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + SPIDER_CLIMBING(EntityTypes1_10.EntityType.SPIDER, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + CREEPER_STATE(EntityTypes1_10.EntityType.CREEPER, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + CREEPER_POWERED(EntityTypes1_10.EntityType.CREEPER, 17, MetaType1_7_6.Byte, MetaType1_8.Byte), + CREEPER_ISIGNITED(EntityTypes1_10.EntityType.CREEPER, 18, MetaType1_7_6.Byte, MetaType1_8.Byte), + GHAST_STATE(EntityTypes1_10.EntityType.GHAST, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + GHAST_IS_POWERED(EntityTypes1_10.EntityType.GHAST, 17, null, MetaType1_8.Byte), + SLIME_SIZE(EntityTypes1_10.EntityType.SLIME, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + SKELETON_TYPE(EntityTypes1_10.EntityType.SKELETON, 13, MetaType1_7_6.Byte, MetaType1_8.Byte), + WITCH_AGRESSIVE(EntityTypes1_10.EntityType.WITCH, 21, MetaType1_7_6.Byte, MetaType1_8.Byte), + IRON_GOLEM_IS_PLAYER_CREATED(EntityTypes1_10.EntityType.IRON_GOLEM, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + WITHER_WATCHED_TAGRET_1(EntityTypes1_10.EntityType.WITHER, 17, MetaType1_7_6.Int, MetaType1_8.Int), + WITHER_WATCHED_TAGRET_2(EntityTypes1_10.EntityType.WITHER, 18, MetaType1_7_6.Int, MetaType1_8.Int), + WITHER_WATCHED_TAGRET_3(EntityTypes1_10.EntityType.WITHER, 19, MetaType1_7_6.Int, MetaType1_8.Int), + WITHER_INVULNERABLE_TIME(EntityTypes1_10.EntityType.WITHER, 20, MetaType1_7_6.Int, MetaType1_8.Int), + WITHER_SKULL_ISINVULNERABLE(EntityTypes1_10.EntityType.WITHER_SKULL, 10, MetaType1_7_6.Byte, MetaType1_8.Byte), + GUARDIAN_FLAGS(EntityTypes1_10.EntityType.GUARDIAN, 16, null, MetaType1_8.Byte), + GUARDIAN_TARGET(EntityTypes1_10.EntityType.GUARDIAN, 17, null, MetaType1_8.Int), + BOAT_TIME_SINCE_HIT(EntityTypes1_10.EntityType.BOAT, 17, MetaType1_7_6.Int, MetaType1_8.Int), + BOAT_FORWARD_DIRECTION(EntityTypes1_10.EntityType.BOAT, 18, MetaType1_7_6.Int, MetaType1_8.Int), + BOAT_DAMAGE_TAKEN(EntityTypes1_10.EntityType.BOAT, 19, MetaType1_7_6.Float, MetaType1_8.Float), + MINECART_SHAKING_POWER(EntityTypes1_10.EntityType.MINECART_ABSTRACT, 17, MetaType1_7_6.Int, MetaType1_8.Int), + MINECART_SHAKING_DIRECTION(EntityTypes1_10.EntityType.MINECART_ABSTRACT, 18, MetaType1_7_6.Int, MetaType1_8.Int), + MINECART_DAMAGE_TAKEN(EntityTypes1_10.EntityType.MINECART_ABSTRACT, 19, MetaType1_7_6.Float, MetaType1_8.Float), + MINECART_BLOCK_INSIDE(EntityTypes1_10.EntityType.MINECART_ABSTRACT, 20, MetaType1_7_6.Int, MetaType1_8.Int), + MINECART_BLOCK_Y(EntityTypes1_10.EntityType.MINECART_ABSTRACT, 21, MetaType1_7_6.Int, MetaType1_8.Int), + MINECART_SHOW_BLOCK(EntityTypes1_10.EntityType.MINECART_ABSTRACT, 22, MetaType1_7_6.Byte, MetaType1_8.Byte), + FURNACE_MINECART_IS_POWERED(EntityTypes1_10.EntityType.MINECART_ABSTRACT, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + ITEM_ITEM(EntityTypes1_10.EntityType.DROPPED_ITEM, 10, MetaType1_7_6.Slot, MetaType1_8.Slot), + ARROW_IS_CRITICAL(EntityTypes1_10.EntityType.ARROW, 16, MetaType1_7_6.Byte, MetaType1_8.Byte), + FIREWORK_INFO(EntityTypes1_10.EntityType.FIREWORK, 8, MetaType1_7_6.Slot, MetaType1_8.Slot), + ITEM_FRAME_ITEM(EntityTypes1_10.EntityType.ITEM_FRAME, 2, MetaType1_7_6.Slot, 8, MetaType1_8.Slot), + ITEM_FRAME_ROTATION(EntityTypes1_10.EntityType.ITEM_FRAME, 3, MetaType1_7_6.Byte, 9, MetaType1_8.Byte), + ENDER_CRYSTAL_HEALTH(EntityTypes1_10.EntityType.ENDER_CRYSTAL, 8, MetaType1_7_6.Int, 8, MetaType1_8.Int), + RABBIT_TYPE(EntityTypes1_10.EntityType.RABBIT, -1, null, 18, MetaType1_8.Byte), ; - private static final HashMap, MetaIndex1_8to1_7_6> metadataRewrites = new HashMap<>(); + private static final HashMap, MetaIndex1_8to1_7_6> metadataRewrites = new HashMap<>(); static { for (MetaIndex1_8to1_7_6 index : MetaIndex1_8to1_7_6.values()) { @@ -117,13 +117,13 @@ public enum MetaIndex1_8to1_7_6 { } } - private final Entity1_10Types.EntityType entityType; + private final EntityTypes1_10.EntityType entityType; private final int oldIndex; private final int newIndex; private final MetaType1_7_6 oldType; private final MetaType1_8 newType; - MetaIndex1_8to1_7_6(Entity1_10Types.EntityType entityType, int oldIndex, MetaType1_7_6 oldType, MetaType1_8 newType) { + MetaIndex1_8to1_7_6(EntityTypes1_10.EntityType entityType, int oldIndex, MetaType1_7_6 oldType, MetaType1_8 newType) { this.entityType = entityType; this.oldIndex = oldIndex; this.newIndex = oldIndex; @@ -131,7 +131,7 @@ public enum MetaIndex1_8to1_7_6 { this.newType = newType; } - MetaIndex1_8to1_7_6(Entity1_10Types.EntityType entityType, int oldIndex, MetaType1_7_6 oldType, int newIndex, MetaType1_8 newType) { + MetaIndex1_8to1_7_6(EntityTypes1_10.EntityType entityType, int oldIndex, MetaType1_7_6 oldType, int newIndex, MetaType1_8 newType) { this.entityType = entityType; this.oldIndex = oldIndex; this.oldType = oldType; @@ -139,7 +139,7 @@ public enum MetaIndex1_8to1_7_6 { this.newType = newType; } - public Entity1_10Types.EntityType getEntityType() { + public EntityTypes1_10.EntityType getEntityType() { return this.entityType; } @@ -159,13 +159,13 @@ public MetaType1_8 getNewType() { return this.newType; } - private static Optional getIndex(Entity1_10Types.EntityType type, int index) { - final Pair pair = new Pair<>(type, index); + private static Optional getIndex(EntityTypes1_10.EntityType type, int index) { + final Pair pair = new Pair<>(type, index); return Optional.ofNullable(metadataRewrites.get(pair)); } - public static MetaIndex1_8to1_7_6 searchIndex(Entity1_10Types.EntityType type, int index) { - Entity1_10Types.EntityType currentType = type; + public static MetaIndex1_8to1_7_6 searchIndex(EntityTypes1_10.EntityType type, int index) { + EntityTypes1_10.EntityType currentType = type; do { Optional optMeta = getIndex(currentType, index); if (optMeta.isPresent()) { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/metadata/MetadataRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/metadata/MetadataRewriter.java index f4baaa8..c352d7e 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/metadata/MetadataRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/metadata/MetadataRewriter.java @@ -17,7 +17,7 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.metadata; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import net.raphimc.vialegacy.ViaLegacy; @@ -35,7 +35,7 @@ public MetadataRewriter(final Protocol1_8to1_7_6_10 protocol) { this.protocol = protocol; } - public void transform(Entity1_10Types.EntityType type, List list) { + public void transform(EntityTypes1_10.EntityType type, List list) { for (Metadata entry : new ArrayList<>(list)) { final MetaIndex1_8to1_7_6 metaIndex = MetaIndex1_8to1_7_6.searchIndex(type, entry.id()); try { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/model/HologramPartEntity.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/model/HologramPartEntity.java index 1fc4718..42b7b36 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/model/HologramPartEntity.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/model/HologramPartEntity.java @@ -18,7 +18,7 @@ package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.model; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; @@ -40,7 +40,7 @@ public class HologramPartEntity { private final EntityTracker entityTracker; private final int entityId; - private final Entity1_10Types.EntityType entityType; + private final EntityTypes1_10.EntityType entityType; private HologramPartEntity riderEntity; private HologramPartEntity vehicleEntity; private Location location; @@ -48,7 +48,7 @@ public class HologramPartEntity { private Integer mappedEntityId; - public HologramPartEntity(final UserConnection user, final int entityId, final Entity1_10Types.EntityType entityType) { + public HologramPartEntity(final UserConnection user, final int entityId, final EntityTypes1_10.EntityType entityType) { this.user = user; this.entityTracker = this.user.get(EntityTracker.class); @@ -56,7 +56,7 @@ public HologramPartEntity(final UserConnection user, final int entityId, final E this.entityType = entityType; this.location = new Location(Float.NaN, Float.NaN, Float.NaN); - if (entityType == Entity1_10Types.EntityType.HORSE) { + if (entityType == EntityTypes1_10.EntityType.HORSE) { this.metadata.put(MetaIndex1_8to1_7_6.ENTITY_FLAGS, (byte) 0); this.metadata.put(MetaIndex1_8to1_7_6.ENTITY_LIVING_NAME_TAG_VISIBILITY, (byte) 0); this.metadata.put(MetaIndex1_8to1_7_6.ENTITY_LIVING_NAME_TAG, ""); @@ -123,7 +123,7 @@ private void spawnHologramPartEntities() throws Exception { spawnMob.send(Protocol1_8to1_7_6_10.class); } if (this.vehicleEntity != null) { - final int objectId = Arrays.stream(Entity1_10Types.ObjectType.values()).filter(o -> o.getType() == this.vehicleEntity.entityType).map(Entity1_10Types.ObjectType::getId).findFirst().orElse(-1); + final int objectId = Arrays.stream(EntityTypes1_10.ObjectType.values()).filter(o -> o.getType() == this.vehicleEntity.entityType).map(EntityTypes1_10.ObjectType::getId).findFirst().orElse(-1); if (objectId == -1) { throw new IllegalStateException("Could not find object id for entity type " + this.vehicleEntity.entityType); } @@ -161,7 +161,7 @@ private void destroyHologramPartEntities() throws Exception { private void spawnArmorStand() throws Exception { final PacketWrapper spawnMob = PacketWrapper.create(ClientboundPackets1_8.SPAWN_MOB, this.user); spawnMob.write(Type.VAR_INT, this.mappedEntityId); // entity id - spawnMob.write(Type.UNSIGNED_BYTE, (short) Entity1_10Types.EntityType.ARMOR_STAND.getId()); // type id + spawnMob.write(Type.UNSIGNED_BYTE, (short) EntityTypes1_10.EntityType.ARMOR_STAND.getId()); // type id spawnMob.write(Type.INT, (int) (this.location.getX() * 32F)); // x spawnMob.write(Type.INT, (int) ((this.location.getY() + this.getHeight()) * 32F)); // y spawnMob.write(Type.INT, (int) (this.location.getZ() * 32F)); // z @@ -203,7 +203,7 @@ private void updateArmorStand() throws Exception { } private boolean isHologram() { - if (this.entityType != Entity1_10Types.EntityType.HORSE) return false; + if (this.entityType != EntityTypes1_10.EntityType.HORSE) return false; if (this.vehicleEntity == null) return false; if (this.riderEntity != null) return false; if (this.vehicleEntity.riderEntity != this) return false; @@ -213,14 +213,14 @@ private boolean isHologram() { } private boolean wouldBeInvisible() { - if (this.entityType != Entity1_10Types.EntityType.HORSE) return false; + if (this.entityType != EntityTypes1_10.EntityType.HORSE) return false; final int age = (int) this.getMetadata(MetaIndex1_8to1_7_6.ENTITY_AGEABLE_AGE); return age >= -50_000; } private float getHeight() { - if (this.entityType == Entity1_10Types.EntityType.HORSE) { + if (this.entityType == EntityTypes1_10.EntityType.HORSE) { final int age = (int) this.getMetadata(MetaIndex1_8to1_7_6.ENTITY_AGEABLE_AGE); final float size = age >= 0 ? 1F : (0.5F + (-24_000F - age) / -24_000F * 0.5F); return HORSE_HEIGHT * size; @@ -242,7 +242,7 @@ public int getEntityId() { return this.entityId; } - public Entity1_10Types.EntityType getEntityType() { + public EntityTypes1_10.EntityType getEntityType() { return this.entityType; } @@ -250,7 +250,7 @@ public void setVehicleEntity(final HologramPartEntity vehicleEntity) throws Exce if (vehicleEntity == null) { if (this.vehicleEntity != null) { this.location = this.vehicleEntity.location; - this.location = new Location(this.location.getX(), this.location.getY() + (this.vehicleEntity.entityType == Entity1_10Types.EntityType.HORSE ? HORSE_HEIGHT : WITHER_SKULL_HEIGHT), this.location.getZ()); + this.location = new Location(this.location.getX(), this.location.getY() + (this.vehicleEntity.entityType == EntityTypes1_10.EntityType.HORSE ? HORSE_HEIGHT : WITHER_SKULL_HEIGHT), this.location.getZ()); this.vehicleEntity.riderEntity = null; this.vehicleEntity.onChange(); } @@ -311,7 +311,7 @@ private List get1_8Metadata() { private List getArmorStandMetadata() { final List metadataList = new ArrayList<>(); - if (this.entityType == Entity1_10Types.EntityType.HORSE) { + if (this.entityType == EntityTypes1_10.EntityType.HORSE) { metadataList.add(new Metadata(MetaIndex1_8to1_7_6.ENTITY_LIVING_NAME_TAG_VISIBILITY.getNewIndex(), MetaIndex1_8to1_7_6.ENTITY_LIVING_NAME_TAG_VISIBILITY.getNewType(), this.getMetadata(MetaIndex1_8to1_7_6.ENTITY_LIVING_NAME_TAG_VISIBILITY))); metadataList.add(new Metadata(MetaIndex1_8to1_7_6.ENTITY_LIVING_NAME_TAG.getNewIndex(), MetaIndex1_8to1_7_6.ENTITY_LIVING_NAME_TAG.getNewType(), this.getMetadata(MetaIndex1_8to1_7_6.ENTITY_LIVING_NAME_TAG))); metadataList.add(new Metadata(MetaIndex1_8to1_7_6.ENTITY_FLAGS.getNewIndex(), MetaIndex1_8to1_7_6.ENTITY_FLAGS.getNewType(), (byte) (1 << 5))); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/rewriter/ChatItemRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/rewriter/ChatItemRewriter.java index 13bc3a6..88ee0bc 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/rewriter/ChatItemRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/rewriter/ChatItemRewriter.java @@ -31,6 +31,7 @@ import net.lenni0451.mcstructs.snbt.SNbtSerializer; import net.lenni0451.mcstructs.snbt.exceptions.SNbtSerializeException; import net.raphimc.vialegacy.ViaLegacy; +import net.raphimc.vialegacy.protocols.release.protocol1_7_6_10to1_7_2_5.ClientboundPackets1_7_2; import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.Protocol1_8to1_7_6_10; import net.raphimc.vialegacy.util.NbtConverter; @@ -358,10 +359,10 @@ public class ChatItemRewriter { ID_TO_NAME.put(2267, "record_wait"); } - private final ComponentRewriter SHOW_ITEM; + private final ComponentRewriter SHOW_ITEM; public ChatItemRewriter(final Protocol1_8to1_7_6_10 protocol) { - this.SHOW_ITEM = new ComponentRewriter(protocol) { + this.SHOW_ITEM = new ComponentRewriter(protocol) { @Override protected void handleHoverEvent(JsonObject hoverEvent) { super.handleHoverEvent(hoverEvent); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/rewriter/TranslationRewriter.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/rewriter/TranslationRewriter.java index b6d5839..1536c8b 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/rewriter/TranslationRewriter.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/rewriter/TranslationRewriter.java @@ -21,6 +21,7 @@ import com.viaversion.viaversion.libs.fastutil.objects.Object2ObjectOpenHashMap; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.rewriter.ComponentRewriter; +import net.raphimc.vialegacy.protocols.release.protocol1_7_6_10to1_7_2_5.ClientboundPackets1_7_2; public class TranslationRewriter { @@ -88,7 +89,7 @@ public class TranslationRewriter { TRANSLATIONS.put("commands.achievement.usage", "/achievement give [player]"); } - private static final ComponentRewriter REWRITER = new ComponentRewriter() { + private static final ComponentRewriter REWRITER = new ComponentRewriter(null, ComponentRewriter.ReadType.JSON) { @Override protected void handleTranslate(JsonObject object, String translate) { final String text = TRANSLATIONS.get(translate); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/EntityTracker.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/EntityTracker.java index 74da141..a014a52 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/EntityTracker.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/storage/EntityTracker.java @@ -19,7 +19,7 @@ import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap; @@ -34,7 +34,7 @@ public class EntityTracker extends StoredObject { - private final Map entityMap = new ConcurrentHashMap<>(); + private final Map entityMap = new ConcurrentHashMap<>(); private final Map groundMap = new ConcurrentHashMap<>(); private final Int2ObjectMap hologramParts = new Int2ObjectOpenHashMap<>(); private final Int2ObjectMap virtualHolograms = new Int2ObjectOpenHashMap<>(); @@ -53,7 +53,7 @@ public void setPlayerID(final int playerID) { this.playerID = playerID; } - public Map getTrackedEntities() { + public Map getTrackedEntities() { return this.entityMap; } @@ -65,7 +65,7 @@ public Int2ObjectMap getVirtualHolograms() { return this.virtualHolograms; } - public void trackEntity(final int entityId, final Entity1_10Types.EntityType entityType) throws Exception { + public void trackEntity(final int entityId, final EntityTypes1_10.EntityType entityType) throws Exception { if (this.virtualHolograms.containsKey(entityId)) { final int newMappedEntityId = this.getNextMappedEntityId(); final HologramPartEntity hologramPartEntity = this.virtualHolograms.remove(entityId); @@ -78,7 +78,7 @@ public void trackEntity(final int entityId, final Entity1_10Types.EntityType ent this.entityMap.put(entityId, entityType); - if (entityType == Entity1_10Types.EntityType.HORSE || entityType == Entity1_10Types.EntityType.WITHER_SKULL) { + if (entityType == EntityTypes1_10.EntityType.HORSE || entityType == EntityTypes1_10.EntityType.WITHER_SKULL) { this.hologramParts.put(entityId, new HologramPartEntity(this.getUser(), entityId, entityType)); } } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkBulk1_7_6Type.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkBulkType1_7_6.java similarity index 91% rename from src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkBulk1_7_6Type.java rename to src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkBulkType1_7_6.java index 8ca5355..d7af4fd 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkBulk1_7_6Type.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkBulkType1_7_6.java @@ -17,12 +17,12 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.type.PartialType; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.CustomByteType; -import com.viaversion.viaversion.api.type.types.minecraft.BaseChunkBulkType; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; +import com.viaversion.viaversion.api.type.types.chunk.BaseChunkBulkType; import com.viaversion.viaversion.util.Pair; import io.netty.buffer.ByteBuf; @@ -32,9 +32,9 @@ import java.util.zip.Deflater; import java.util.zip.Inflater; -public class ChunkBulk1_7_6Type extends PartialType { +public class ChunkBulkType1_7_6 extends PartialType { - public ChunkBulk1_7_6Type(final ClientWorld clientWorld) { + public ChunkBulkType1_7_6(final ClientWorld clientWorld) { super(clientWorld, Chunk[].class); } @@ -82,7 +82,7 @@ public Chunk[] read(ByteBuf byteBuf, ClientWorld clientWorld) throws Exception { additionalBitMask[i] = byteBuf.readShort(); } - final byte[] uncompressedData = new byte[Chunk1_7_6Type.getSize((short) 0xFFFF, (short) 0xFFFF, true, hasSkyLight) * chunkCount]; + final byte[] uncompressedData = new byte[ChunkType1_7_6.getSize((short) 0xFFFF, (short) 0xFFFF, true, hasSkyLight) * chunkCount]; final Inflater inflater = new Inflater(); try { inflater.setInput(data, 0, compressedSize); @@ -96,9 +96,9 @@ public Chunk[] read(ByteBuf byteBuf, ClientWorld clientWorld) throws Exception { final Chunk[] chunks = new Chunk[chunkCount]; int dataPosition = 0; for (int i = 0; i < chunkCount; i++) { - final byte[] chunkData = new byte[Chunk1_7_6Type.getSize(primaryBitMask[i], additionalBitMask[i], true, hasSkyLight)]; + final byte[] chunkData = new byte[ChunkType1_7_6.getSize(primaryBitMask[i], additionalBitMask[i], true, hasSkyLight)]; System.arraycopy(uncompressedData, dataPosition, chunkData, 0, chunkData.length); - chunks[i] = Chunk1_7_6Type.deserialize(chunkX[i], chunkZ[i], true, hasSkyLight, primaryBitMask[i], additionalBitMask[i], chunkData); + chunks[i] = ChunkType1_7_6.deserialize(chunkX[i], chunkZ[i], true, hasSkyLight, primaryBitMask[i], additionalBitMask[i], chunkData); dataPosition += chunkData.length; } @@ -116,7 +116,7 @@ public void write(ByteBuf byteBuf, ClientWorld clientWorld, Chunk[] chunks) thro for (int i = 0; i < chunkCount; i++) { final Chunk chunk = chunks[i]; - final Pair chunkData = Chunk1_7_6Type.serialize(chunk); + final Pair chunkData = ChunkType1_7_6.serialize(chunk); output.write(chunkData.key()); chunkX[i] = chunk.getX(); chunkZ[i] = chunk.getZ(); diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Chunk1_7_6Type.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkType1_7_6.java similarity index 97% rename from src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Chunk1_7_6Type.java rename to src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkType1_7_6.java index 0ce945b..3c51410 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Chunk1_7_6Type.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/ChunkType1_7_6.java @@ -17,13 +17,13 @@ */ package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types; +import com.viaversion.viaversion.api.minecraft.ClientWorld; import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.chunks.*; import com.viaversion.viaversion.api.type.PartialType; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.CustomByteType; -import com.viaversion.viaversion.api.type.types.minecraft.BaseChunkType; -import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; +import com.viaversion.viaversion.api.type.types.chunk.BaseChunkType; import com.viaversion.viaversion.util.Pair; import io.netty.buffer.ByteBuf; import net.raphimc.vialegacy.api.model.IdAndData; @@ -36,9 +36,9 @@ import java.util.zip.Deflater; import java.util.zip.Inflater; -public class Chunk1_7_6Type extends PartialType { +public class ChunkType1_7_6 extends PartialType { - public Chunk1_7_6Type(final ClientWorld clientWorld) { + public ChunkType1_7_6(final ClientWorld clientWorld) { super(clientWorld, Chunk.class); } diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/MetadataType.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/MetadataType.java index 91a8618..10edf0b 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/MetadataType.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/MetadataType.java @@ -18,7 +18,7 @@ package net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types; import com.viaversion.viaversion.api.minecraft.metadata.MetaType; -import com.viaversion.viaversion.api.type.types.minecraft.OldMetaType; +import com.viaversion.viaversion.api.type.types.metadata.OldMetaType; public class MetadataType extends OldMetaType { diff --git a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Types1_7_6.java b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Types1_7_6.java index 963150b..a8df5c1 100644 --- a/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Types1_7_6.java +++ b/src/main/java/net/raphimc/vialegacy/protocols/release/protocol1_8to1_7_6_10/types/Types1_7_6.java @@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viaversion.api.type.types.minecraft.MetaListType; +import com.viaversion.viaversion.api.type.types.metadata.MetaListType; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import java.util.List;