3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-25 15:50:12 +01:00

23w42a (if the ci manages to find VV)

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-10-19 11:50:31 +10:00
Ursprung 719bb11938
Commit 4cd65dd956
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
64 geänderte Dateien mit 609 neuen und 526 gelöschten Zeilen

Datei anzeigen

@ -26,7 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.EntityPac
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11; import com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets1_11;
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker; import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
@ -60,7 +60,7 @@ public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_
user.put(new ClientWorld(user)); user.put(new ClientWorld(user));
} }
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER)); user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_11.EntityType.PLAYER));
if (!user.has(WindowTracker.class)) { if (!user.has(WindowTracker.class)) {
user.put(new WindowTracker()); user.put(new WindowTracker());

Datei anzeigen

@ -29,7 +29,7 @@ import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.DataItem;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
@ -90,10 +90,10 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
@Override @Override
public void register() { public void register() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.ITEM_ARRAY); // 1 - Window Values map(Type.ITEM1_8_ARRAY); // 1 - Window Values
handler(wrapper -> { handler(wrapper -> {
Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0); Item[] stacks = wrapper.get(Type.ITEM1_8_ARRAY, 0);
for (int i = 0; i < stacks.length; i++) for (int i = 0; i < stacks.length; i++)
stacks[i] = handleItemToClient(stacks[i]); stacks[i] = handleItemToClient(stacks[i]);
@ -108,7 +108,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
stacks[getNewSlotId(storage, i)] = stacks[i]; stacks[getNewSlotId(storage, i)] = stacks[i];
stacks[i] = getNewItem(storage, i, stacks[i]); stacks[i] = getNewItem(storage, i, stacks[i]);
} }
wrapper.set(Type.ITEM_ARRAY, 0, stacks); wrapper.set(Type.ITEM1_8_ARRAY, 0, stacks);
} }
}); });
} }
@ -365,7 +365,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) { if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
EntityTracker entTracker = user.getEntityTracker(Protocol1_10To1_11.class); EntityTracker entTracker = user.getEntityTracker(Protocol1_10To1_11.class);
StoredEntityData entityData = entTracker.entityData(tracker.getEntityId()); StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
return entityData != null && entityData.type().is(Entity1_11Types.EntityType.LIAMA); return entityData != null && entityData.type().is(EntityTypes1_11.EntityType.LIAMA);
} }
return false; return false;
} }

Datei anzeigen

@ -26,8 +26,8 @@ import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_1
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage; import com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
import com.viaversion.viabackwards.utils.Block; import com.viaversion.viabackwards.utils.Block;
import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
@ -84,12 +84,12 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
// Track Entity // Track Entity
handler(getObjectTrackerHandler()); handler(getObjectTrackerHandler());
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null))); handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null)));
// Handle FallingBlock blocks // Handle FallingBlock blocks
handler(wrapper -> { handler(wrapper -> {
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); Optional<EntityTypes1_12.ObjectType> type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) { if (type.isPresent() && type.get() == EntityTypes1_12.ObjectType.FALLING_BLOCK) {
int objectData = wrapper.get(Type.INT, 0); int objectData = wrapper.get(Type.INT, 0);
int objType = objectData & 4095; int objType = objectData & 4095;
int data = objectData >> 12 & 15; int data = objectData >> 12 & 15;
@ -104,8 +104,8 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}); });
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, EntityTypes1_11.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER); registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, EntityTypes1_11.EntityType.WEATHER);
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
@Override @Override
@ -151,8 +151,8 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}); });
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING); registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, EntityTypes1_11.EntityType.PAINTING);
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER); registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, EntityTypes1_11.EntityType.PLAYER);
registerRespawn(ClientboundPackets1_9_3.RESPAWN); registerRespawn(ClientboundPackets1_9_3.RESPAWN);
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() {
@ -167,7 +167,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.BYTE); // 6 - Pitch map(Type.BYTE); // 6 - Pitch
map(Types1_9.METADATA_LIST); // 7 - Metadata list map(Types1_9.METADATA_LIST); // 7 - Metadata list
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER)); handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, EntityTypes1_11.EntityType.PLAYER));
handler(wrapper -> { handler(wrapper -> {
// Sub 1.11 clients will cry if the list is empty // Sub 1.11 clients will cry if the list is empty
List<Metadata> metadata = wrapper.get(Types1_9.METADATA_LIST, 0); List<Metadata> metadata = wrapper.get(Types1_9.METADATA_LIST, 0);
@ -204,37 +204,37 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
// Guardian // Guardian
mapEntityTypeWithData(Entity1_11Types.EntityType.ELDER_GUARDIAN, Entity1_11Types.EntityType.GUARDIAN); mapEntityTypeWithData(EntityTypes1_11.EntityType.ELDER_GUARDIAN, EntityTypes1_11.EntityType.GUARDIAN);
// Skeletons // Skeletons
mapEntityTypeWithData(Entity1_11Types.EntityType.WITHER_SKELETON, Entity1_11Types.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1))); mapEntityTypeWithData(EntityTypes1_11.EntityType.WITHER_SKELETON, EntityTypes1_11.EntityType.SKELETON).spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(1)));
mapEntityTypeWithData(Entity1_11Types.EntityType.STRAY, Entity1_11Types.EntityType.SKELETON).plainName().spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2))); mapEntityTypeWithData(EntityTypes1_11.EntityType.STRAY, EntityTypes1_11.EntityType.SKELETON).plainName().spawnMetadata(storage -> storage.add(getSkeletonTypeMeta(2)));
// Zombies // Zombies
mapEntityTypeWithData(Entity1_11Types.EntityType.HUSK, Entity1_11Types.EntityType.ZOMBIE).plainName().spawnMetadata(storage -> handleZombieType(storage, 6)); mapEntityTypeWithData(EntityTypes1_11.EntityType.HUSK, EntityTypes1_11.EntityType.ZOMBIE).plainName().spawnMetadata(storage -> handleZombieType(storage, 6));
mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_VILLAGER, Entity1_11Types.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1)); mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_VILLAGER, EntityTypes1_11.EntityType.ZOMBIE).spawnMetadata(storage -> handleZombieType(storage, 1));
// Horses // Horses
mapEntityTypeWithData(Entity1_11Types.EntityType.HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent. mapEntityTypeWithData(EntityTypes1_11.EntityType.HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(0))); // Nob able to ride the horse without having the MetaType sent.
mapEntityTypeWithData(Entity1_11Types.EntityType.DONKEY, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1))); mapEntityTypeWithData(EntityTypes1_11.EntityType.DONKEY, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
mapEntityTypeWithData(Entity1_11Types.EntityType.MULE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2))); mapEntityTypeWithData(EntityTypes1_11.EntityType.MULE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(2)));
mapEntityTypeWithData(Entity1_11Types.EntityType.SKELETON_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4))); mapEntityTypeWithData(EntityTypes1_11.EntityType.SKELETON_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
mapEntityTypeWithData(Entity1_11Types.EntityType.ZOMBIE_HORSE, Entity1_11Types.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3))); mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
// New mobs // New mobs
mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_FANGS, Entity1_11Types.EntityType.SHULKER); mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOCATION_FANGS, EntityTypes1_11.EntityType.SHULKER);
mapEntityTypeWithData(Entity1_11Types.EntityType.EVOCATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).plainName(); mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOCATION_ILLAGER, EntityTypes1_11.EntityType.VILLAGER).plainName();
mapEntityTypeWithData(Entity1_11Types.EntityType.VEX, Entity1_11Types.EntityType.BAT).plainName(); mapEntityTypeWithData(EntityTypes1_11.EntityType.VEX, EntityTypes1_11.EntityType.BAT).plainName();
mapEntityTypeWithData(Entity1_11Types.EntityType.VINDICATION_ILLAGER, Entity1_11Types.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession mapEntityTypeWithData(EntityTypes1_11.EntityType.VINDICATION_ILLAGER, EntityTypes1_11.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new Metadata(13, MetaType1_9.VarInt, 4))); // Base Profession
mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA, Entity1_11Types.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1))); mapEntityTypeWithData(EntityTypes1_11.EntityType.LIAMA, EntityTypes1_11.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
mapEntityTypeWithData(Entity1_11Types.EntityType.LIAMA_SPIT, Entity1_11Types.EntityType.SNOWBALL); mapEntityTypeWithData(EntityTypes1_11.EntityType.LIAMA_SPIT, EntityTypes1_11.EntityType.SNOWBALL);
mapObjectType(Entity1_11Types.ObjectType.LIAMA_SPIT, Entity1_11Types.ObjectType.SNOWBALL, -1); mapObjectType(EntityTypes1_11.ObjectType.LIAMA_SPIT, EntityTypes1_11.ObjectType.SNOWBALL, -1);
// Replace with endertorchthingies // Replace with endertorchthingies
mapObjectType(Entity1_11Types.ObjectType.EVOCATION_FANGS, Entity1_11Types.ObjectType.FALLING_BLOCK, 198 | 1 << 12); mapObjectType(EntityTypes1_11.ObjectType.EVOCATION_FANGS, EntityTypes1_11.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
// Handle ElderGuardian & target metadata // Handle ElderGuardian & target metadata
filter().filterFamily(Entity1_11Types.EntityType.GUARDIAN).index(12).handler((event, meta) -> { filter().filterFamily(EntityTypes1_11.EntityType.GUARDIAN).index(12).handler((event, meta) -> {
boolean b = (boolean) meta.getValue(); boolean b = (boolean) meta.getValue();
int bitmask = b ? 0x02 : 0; int bitmask = b ? 0x02 : 0;
if (event.entityType() == Entity1_11Types.EntityType.ELDER_GUARDIAN) { if (event.entityType() == EntityTypes1_11.EntityType.ELDER_GUARDIAN) {
bitmask |= 0x04; bitmask |= 0x04;
} }
@ -242,12 +242,12 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Handle skeleton swing // Handle skeleton swing
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_SKELETON).index(12).toIndex(13); filter().filterFamily(EntityTypes1_11.EntityType.ABSTRACT_SKELETON).index(12).toIndex(13);
/* /*
ZOMBIE CHANGES ZOMBIE CHANGES
*/ */
filter().filterFamily(Entity1_11Types.EntityType.ZOMBIE).handler((event, meta) -> { filter().filterFamily(EntityTypes1_11.EntityType.ZOMBIE).handler((event, meta) -> {
switch (meta.id()) { switch (meta.id()) {
case 13: case 13:
event.cancel(); event.cancel();
@ -267,18 +267,18 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Handle Evocation Illager // Handle Evocation Illager
filter().type(Entity1_11Types.EntityType.EVOCATION_ILLAGER).index(12).handler((event, meta) -> { filter().type(EntityTypes1_11.EntityType.EVOCATION_ILLAGER).index(12).handler((event, meta) -> {
event.setIndex(13); event.setIndex(13);
meta.setTypeAndValue(MetaType1_9.VarInt, ((Byte) meta.getValue()).intValue()); // Change the profession for the states meta.setTypeAndValue(MetaType1_9.VarInt, ((Byte) meta.getValue()).intValue()); // Change the profession for the states
}); });
// Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ): // Handle Vex (Remove this field completely since the position is not updated correctly when idling for bats. Sad ):
filter().type(Entity1_11Types.EntityType.VEX).index(12).handler((event, meta) -> { filter().type(EntityTypes1_11.EntityType.VEX).index(12).handler((event, meta) -> {
meta.setValue((byte) 0x00); meta.setValue((byte) 0x00);
}); });
// Handle VindicationIllager // Handle VindicationIllager
filter().type(Entity1_11Types.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> { filter().type(EntityTypes1_11.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> {
event.setIndex(13); event.setIndex(13);
meta.setTypeAndValue(MetaType1_9.VarInt, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4); meta.setTypeAndValue(MetaType1_9.VarInt, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4);
}); });
@ -288,7 +288,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
*/ */
// Handle horse flags // Handle horse flags
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_HORSE).index(13).handler((event, meta) -> { filter().filterFamily(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(13).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event); StoredEntityData data = storedEntityData(event);
byte b = (byte) meta.getValue(); byte b = (byte) meta.getValue();
if (data.has(ChestedHorseStorage.class) && data.get(ChestedHorseStorage.class).isChested()) { if (data.has(ChestedHorseStorage.class) && data.get(ChestedHorseStorage.class).isChested()) {
@ -298,7 +298,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Create chested horse storage // Create chested horse storage
filter().filterFamily(Entity1_11Types.EntityType.CHESTED_HORSE).handler((event, meta) -> { filter().filterFamily(EntityTypes1_11.EntityType.CHESTED_HORSE).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event); StoredEntityData data = storedEntityData(event);
if (!data.has(ChestedHorseStorage.class)) { if (!data.has(ChestedHorseStorage.class)) {
data.put(new ChestedHorseStorage()); data.put(new ChestedHorseStorage());
@ -306,10 +306,10 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Handle horse armor // Handle horse armor
filter().type(Entity1_11Types.EntityType.HORSE).index(16).toIndex(17); filter().type(EntityTypes1_11.EntityType.HORSE).index(16).toIndex(17);
// Handle chested horse // Handle chested horse
filter().filterFamily(Entity1_11Types.EntityType.CHESTED_HORSE).index(15).handler((event, meta) -> { filter().filterFamily(EntityTypes1_11.EntityType.CHESTED_HORSE).index(15).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event); StoredEntityData data = storedEntityData(event);
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class); ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
boolean b = (boolean) meta.getValue(); boolean b = (boolean) meta.getValue();
@ -318,7 +318,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Get rid of Liama metadata // Get rid of Liama metadata
filter().type(Entity1_11Types.EntityType.LIAMA).handler((event, meta) -> { filter().type(EntityTypes1_11.EntityType.LIAMA).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event); StoredEntityData data = storedEntityData(event);
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class); ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
@ -341,17 +341,17 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Handle Horse (Correct owner) // Handle Horse (Correct owner)
filter().filterFamily(Entity1_11Types.EntityType.ABSTRACT_HORSE).index(14).toIndex(16); filter().filterFamily(EntityTypes1_11.EntityType.ABSTRACT_HORSE).index(14).toIndex(16);
// Handle villager - Change non-existing profession // Handle villager - Change non-existing profession
filter().type(Entity1_11Types.EntityType.VILLAGER).index(13).handler((event, meta) -> { filter().type(EntityTypes1_11.EntityType.VILLAGER).index(13).handler((event, meta) -> {
if ((int) meta.getValue() == 5) { if ((int) meta.getValue() == 5) {
meta.setValue(0); meta.setValue(0);
} }
}); });
// handle new Shulker color meta // handle new Shulker color meta
filter().type(Entity1_11Types.EntityType.SHULKER).cancel(15); filter().type(EntityTypes1_11.EntityType.SHULKER).cancel(15);
} }
/* /*
@ -393,11 +393,11 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_11Types.getTypeFromId(typeId, false); return EntityTypes1_11.getTypeFromId(typeId, false);
} }
@Override @Override
protected EntityType getObjectTypeFromId(int typeId) { protected EntityType getObjectTypeFromId(int typeId) {
return Entity1_11Types.getTypeFromId(typeId, true); return EntityTypes1_11.getTypeFromId(typeId, true);
} }
} }

Datei anzeigen

@ -26,7 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.ChatPac
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12; import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityPackets1_12;
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12; import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonElement;
@ -74,7 +74,7 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_
user.put(new ClientWorld(user)); user.put(new ClientWorld(user));
} }
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_12Types.EntityType.PLAYER)); user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_12.EntityType.PLAYER));
user.put(new ShoulderTracker(user)); user.put(new ShoulderTracker(user));
} }

Datei anzeigen

@ -82,7 +82,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
}); });
registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM); registerSetSlot(ClientboundPackets1_12.SET_SLOT, Type.ITEM);
registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS, Type.ITEM_ARRAY); registerWindowItems(ClientboundPackets1_12.WINDOW_ITEMS, Type.ITEM1_8_ARRAY);
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM); registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM);
// Plugin message Packet -> Trading // Plugin message Packet -> Trading

Datei anzeigen

@ -24,7 +24,7 @@ import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ParrotStor
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker; import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
import com.viaversion.viabackwards.utils.Block; import com.viaversion.viabackwards.utils.Block;
import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
@ -62,12 +62,12 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
// Track Entity // Track Entity
handler(getObjectTrackerHandler()); handler(getObjectTrackerHandler());
handler(getObjectRewriter(id -> Entity1_12Types.ObjectType.findById(id).orElse(null))); handler(getObjectRewriter(id -> EntityTypes1_12.ObjectType.findById(id).orElse(null)));
// Handle FallingBlock blocks // Handle FallingBlock blocks
handler(wrapper -> { handler(wrapper -> {
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); Optional<EntityTypes1_12.ObjectType> type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) { if (type.isPresent() && type.get() == EntityTypes1_12.ObjectType.FALLING_BLOCK) {
int objectData = wrapper.get(Type.INT, 0); int objectData = wrapper.get(Type.INT, 0);
int objType = objectData & 4095; int objType = objectData & 4095;
int data = objectData >> 12 & 15; int data = objectData >> 12 & 15;
@ -83,8 +83,8 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}); });
registerTracker(ClientboundPackets1_12.SPAWN_EXPERIENCE_ORB, Entity1_12Types.EntityType.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_12.SPAWN_EXPERIENCE_ORB, EntityTypes1_12.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_12.SPAWN_GLOBAL_ENTITY, Entity1_12Types.EntityType.WEATHER); registerTracker(ClientboundPackets1_12.SPAWN_GLOBAL_ENTITY, EntityTypes1_12.EntityType.WEATHER);
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_MOB, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_12.SPAWN_MOB, new PacketHandlers() {
@Override @Override
@ -111,7 +111,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}); });
registerTracker(ClientboundPackets1_12.SPAWN_PAINTING, Entity1_12Types.EntityType.PAINTING); registerTracker(ClientboundPackets1_12.SPAWN_PAINTING, EntityTypes1_12.EntityType.PAINTING);
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_PLAYER, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_12.SPAWN_PLAYER, new PacketHandlers() {
@Override @Override
@ -125,7 +125,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.BYTE); // 6 - Pitch map(Type.BYTE); // 6 - Pitch
map(Types1_12.METADATA_LIST); // 7 - Metadata list map(Types1_12.METADATA_LIST); // 7 - Metadata list
handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, Entity1_12Types.EntityType.PLAYER)); handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, EntityTypes1_12.EntityType.PLAYER));
} }
}); });
@ -136,7 +136,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.UNSIGNED_BYTE); // 1 - Gamemode map(Type.UNSIGNED_BYTE); // 1 - Gamemode
map(Type.INT); // 2 - Dimension map(Type.INT); // 2 - Dimension
handler(getTrackerHandler(Entity1_12Types.EntityType.PLAYER, Type.INT)); handler(getTrackerHandler(EntityTypes1_12.EntityType.PLAYER, Type.INT));
handler(getDimensionHandler(1)); handler(getDimensionHandler(1));
@ -204,8 +204,8 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
mapEntityTypeWithData(Entity1_12Types.EntityType.PARROT, Entity1_12Types.EntityType.BAT).plainName().spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00))); mapEntityTypeWithData(EntityTypes1_12.EntityType.PARROT, EntityTypes1_12.EntityType.BAT).plainName().spawnMetadata(storage -> storage.add(new Metadata(12, MetaType1_12.Byte, (byte) 0x00)));
mapEntityTypeWithData(Entity1_12Types.EntityType.ILLUSION_ILLAGER, Entity1_12Types.EntityType.EVOCATION_ILLAGER).plainName(); mapEntityTypeWithData(EntityTypes1_12.EntityType.ILLUSION_ILLAGER, EntityTypes1_12.EntityType.EVOCATION_ILLAGER).plainName();
filter().handler((event, meta) -> { filter().handler((event, meta) -> {
if (meta.metaType() == MetaType1_12.Chat) { if (meta.metaType() == MetaType1_12.Chat) {
@ -214,10 +214,10 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Handle Illager // Handle Illager
filter().filterFamily(Entity1_12Types.EntityType.EVOCATION_ILLAGER).cancel(12); filter().filterFamily(EntityTypes1_12.EntityType.EVOCATION_ILLAGER).cancel(12);
filter().filterFamily(Entity1_12Types.EntityType.EVOCATION_ILLAGER).index(13).toIndex(12); filter().filterFamily(EntityTypes1_12.EntityType.EVOCATION_ILLAGER).index(13).toIndex(12);
filter().type(Entity1_12Types.EntityType.ILLUSION_ILLAGER).index(0).handler((event, meta) -> { filter().type(EntityTypes1_12.EntityType.ILLUSION_ILLAGER).index(0).handler((event, meta) -> {
byte mask = (byte) meta.getValue(); byte mask = (byte) meta.getValue();
if ((mask & 0x20) == 0x20) { if ((mask & 0x20) == 0x20) {
@ -228,15 +228,15 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Create Parrot storage // Create Parrot storage
filter().filterFamily(Entity1_12Types.EntityType.PARROT).handler((event, meta) -> { filter().filterFamily(EntityTypes1_12.EntityType.PARROT).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event); StoredEntityData data = storedEntityData(event);
if (!data.has(ParrotStorage.class)) { if (!data.has(ParrotStorage.class)) {
data.put(new ParrotStorage()); data.put(new ParrotStorage());
} }
}); });
// Parrot remove animal metadata // Parrot remove animal metadata
filter().type(Entity1_12Types.EntityType.PARROT).cancel(12); // Is baby filter().type(EntityTypes1_12.EntityType.PARROT).cancel(12); // Is baby
filter().type(Entity1_12Types.EntityType.PARROT).index(13).handler((event, meta) -> { filter().type(EntityTypes1_12.EntityType.PARROT).index(13).handler((event, meta) -> {
StoredEntityData data = storedEntityData(event); StoredEntityData data = storedEntityData(event);
ParrotStorage storage = data.get(ParrotStorage.class); ParrotStorage storage = data.get(ParrotStorage.class);
boolean isSitting = (((byte) meta.getValue()) & 0x01) == 0x01; boolean isSitting = (((byte) meta.getValue()) & 0x01) == 0x01;
@ -260,11 +260,11 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
event.cancel(); event.cancel();
} }
}); // Flags (Is sitting etc, might be useful in the future }); // Flags (Is sitting etc, might be useful in the future
filter().type(Entity1_12Types.EntityType.PARROT).cancel(14); // Owner filter().type(EntityTypes1_12.EntityType.PARROT).cancel(14); // Owner
filter().type(Entity1_12Types.EntityType.PARROT).cancel(15); // Variant filter().type(EntityTypes1_12.EntityType.PARROT).cancel(15); // Variant
// Left shoulder entity data // Left shoulder entity data
filter().type(Entity1_12Types.EntityType.PLAYER).index(15).handler((event, meta) -> { filter().type(EntityTypes1_12.EntityType.PLAYER).index(15).handler((event, meta) -> {
CompoundTag tag = (CompoundTag) meta.getValue(); CompoundTag tag = (CompoundTag) meta.getValue();
ShoulderTracker tracker = event.user().get(ShoulderTracker.class); ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
@ -283,7 +283,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Right shoulder entity data // Right shoulder entity data
filter().type(Entity1_12Types.EntityType.PLAYER).index(16).handler((event, meta) -> { filter().type(EntityTypes1_12.EntityType.PLAYER).index(16).handler((event, meta) -> {
CompoundTag tag = (CompoundTag) event.meta().getValue(); CompoundTag tag = (CompoundTag) event.meta().getValue();
ShoulderTracker tracker = event.user().get(ShoulderTracker.class); ShoulderTracker tracker = event.user().get(ShoulderTracker.class);
@ -304,11 +304,11 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_12Types.getTypeFromId(typeId, false); return EntityTypes1_12.getTypeFromId(typeId, false);
} }
@Override @Override
protected EntityType getObjectTypeFromId(final int typeId) { protected EntityType getObjectTypeFromId(final int typeId) {
return Entity1_12Types.getTypeFromId(typeId, true); return EntityTypes1_12.getTypeFromId(typeId, true);
} }
} }

Datei anzeigen

@ -22,7 +22,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1; import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets1_11_1;
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets1_11_1; import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets1_11_1;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
@ -50,7 +50,7 @@ public class Protocol1_11To1_11_1 extends BackwardsProtocol<ClientboundPackets1_
user.put(new ClientWorld(user)); user.put(new ClientWorld(user));
} }
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER)); user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_11.EntityType.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.packets;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter; import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1; import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -50,12 +50,12 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
// Track Entity // Track Entity
handler(getObjectTrackerHandler()); handler(getObjectTrackerHandler());
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null))); handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null)));
} }
}); });
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, EntityTypes1_11.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER); registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, EntityTypes1_11.EntityType.WEATHER);
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
@Override @Override
@ -82,8 +82,8 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
} }
}); });
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_11Types.EntityType.PAINTING); registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, EntityTypes1_11.EntityType.PAINTING);
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER); registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, EntityTypes1_11.EntityType.PLAYER);
registerRespawn(ClientboundPackets1_9_3.RESPAWN); registerRespawn(ClientboundPackets1_9_3.RESPAWN);
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() {
@ -98,7 +98,7 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
map(Type.BYTE); // 6 - Pitch map(Type.BYTE); // 6 - Pitch
map(Types1_9.METADATA_LIST); // 7 - Metadata list map(Types1_9.METADATA_LIST); // 7 - Metadata list
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER)); handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, EntityTypes1_11.EntityType.PLAYER));
} }
}); });
@ -109,19 +109,19 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
// Handle non-existing firework metadata (index 7 entity id for boosting) // Handle non-existing firework metadata (index 7 entity id for boosting)
filter().type(Entity1_11Types.EntityType.FIREWORK).cancel(7); filter().type(EntityTypes1_11.EntityType.FIREWORK).cancel(7);
// Handle non-existing pig metadata (index 14 - boost time) // Handle non-existing pig metadata (index 14 - boost time)
filter().type(Entity1_11Types.EntityType.PIG).cancel(14); filter().type(EntityTypes1_11.EntityType.PIG).cancel(14);
} }
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_11Types.getTypeFromId(typeId, false); return EntityTypes1_11.getTypeFromId(typeId, false);
} }
@Override @Override
protected EntityType getObjectTypeFromId(final int typeId) { protected EntityType getObjectTypeFromId(final int typeId) {
return Entity1_11Types.getTypeFromId(typeId, true); return EntityTypes1_11.getTypeFromId(typeId, true);
} }
} }

Datei anzeigen

@ -40,7 +40,7 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
@Override @Override
protected void registerPackets() { protected void registerPackets() {
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM); registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY); registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM1_8_ARRAY);
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM); registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
// Plugin message Packet -> Trading // Plugin message Packet -> Trading

Datei anzeigen

@ -33,7 +33,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerP
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage; import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.gson.JsonObject;
@ -118,7 +118,7 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
user.put(new ClientWorld(user)); user.put(new ClientWorld(user));
} }
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_13Types.EntityType.PLAYER)); user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_13.EntityType.PLAYER));
user.put(new BackwardsBlockStorage()); user.put(new BackwardsBlockStorage());
user.put(new TabCompleteStorage()); user.put(new TabCompleteStorage());

Datei anzeigen

@ -108,7 +108,7 @@ public class ParticleMapping {
rewrite(36, new ParticleHandler() { rewrite(36, new ParticleHandler() {
@Override @Override
public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception { public int[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
return rewrite(protocol, wrapper.read(Type.FLAT_ITEM)); return rewrite(protocol, wrapper.read(Type.ITEM1_13));
} }
@Override @Override

Datei anzeigen

@ -238,9 +238,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
@Override @Override
public void register() { public void register() {
map(Type.UNSIGNED_BYTE); map(Type.UNSIGNED_BYTE);
map(Type.FLAT_ITEM_ARRAY, Type.ITEM_ARRAY); map(Type.ITEM1_13_ARRAY, Type.ITEM1_8_ARRAY);
handler(itemArrayToClientHandler(Type.ITEM_ARRAY)); handler(itemArrayToClientHandler(Type.ITEM1_8_ARRAY));
} }
}); });
@ -249,7 +249,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
public void register() { public void register() {
map(Type.UNSIGNED_BYTE); map(Type.UNSIGNED_BYTE);
map(Type.SHORT); map(Type.SHORT);
map(Type.FLAT_ITEM, Type.ITEM); map(Type.ITEM1_13, Type.ITEM);
handler(itemToClientHandler(Type.ITEM)); handler(itemToClientHandler(Type.ITEM));
} }
@ -421,7 +421,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
public void register() { public void register() {
map(Type.VAR_INT); map(Type.VAR_INT);
map(Type.VAR_INT); map(Type.VAR_INT);
map(Type.FLAT_ITEM, Type.ITEM); map(Type.ITEM1_13, Type.ITEM);
handler(itemToClientHandler(Type.ITEM)); handler(itemToClientHandler(Type.ITEM));
} }
@ -449,9 +449,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
@Override @Override
public void register() { public void register() {
map(Type.SHORT); map(Type.SHORT);
map(Type.ITEM, Type.FLAT_ITEM); map(Type.ITEM, Type.ITEM1_13);
handler(itemToServerHandler(Type.FLAT_ITEM)); handler(itemToServerHandler(Type.ITEM1_13));
} }
}); });
@ -463,9 +463,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
map(Type.BYTE); map(Type.BYTE);
map(Type.SHORT); map(Type.SHORT);
map(Type.VAR_INT); map(Type.VAR_INT);
map(Type.ITEM, Type.FLAT_ITEM); map(Type.ITEM, Type.ITEM1_13);
handler(itemToServerHandler(Type.FLAT_ITEM)); handler(itemToServerHandler(Type.ITEM1_13));
} }
}); });
} }

Datei anzeigen

@ -26,7 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMa
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping; import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage; import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13; import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage.PlayerPositionStorage1_13;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
@ -88,16 +88,16 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
handler(getObjectTrackerHandler()); handler(getObjectTrackerHandler());
handler(wrapper -> { handler(wrapper -> {
Optional<Entity1_13Types.ObjectType> optionalType = Entity1_13Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); Optional<EntityTypes1_13.ObjectType> optionalType = EntityTypes1_13.ObjectType.findById(wrapper.get(Type.BYTE, 0));
if (!optionalType.isPresent()) return; if (!optionalType.isPresent()) return;
Entity1_13Types.ObjectType type = optionalType.get(); EntityTypes1_13.ObjectType type = optionalType.get();
if (type == Entity1_13Types.ObjectType.FALLING_BLOCK) { if (type == EntityTypes1_13.ObjectType.FALLING_BLOCK) {
int blockState = wrapper.get(Type.INT, 0); int blockState = wrapper.get(Type.INT, 0);
int combined = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState); int combined = Protocol1_12_2To1_13.MAPPINGS.getNewBlockStateId(blockState);
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12); combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
wrapper.set(Type.INT, 0, combined); wrapper.set(Type.INT, 0, combined);
} else if (type == Entity1_13Types.ObjectType.ITEM_FRAME) { } else if (type == EntityTypes1_13.ObjectType.ITEM_FRAME) {
int data = wrapper.get(Type.INT, 0); int data = wrapper.get(Type.INT, 0);
switch (data) { switch (data) {
case 3: case 3:
@ -111,15 +111,15 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
break; break;
} }
wrapper.set(Type.INT, 0, data); wrapper.set(Type.INT, 0, data);
} else if (type == Entity1_13Types.ObjectType.TRIDENT) { } else if (type == EntityTypes1_13.ObjectType.TRIDENT) {
wrapper.set(Type.BYTE, 0, (byte) Entity1_13Types.ObjectType.TIPPED_ARROW.getId()); wrapper.set(Type.BYTE, 0, (byte) EntityTypes1_13.ObjectType.TIPPED_ARROW.getId());
} }
}); });
} }
}); });
registerTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, Entity1_13Types.EntityType.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, EntityTypes1_13.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, Entity1_13Types.EntityType.LIGHTNING_BOLT); registerTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, EntityTypes1_13.EntityType.LIGHTNING_BOLT);
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() {
@Override @Override
@ -140,7 +140,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
handler(wrapper -> { handler(wrapper -> {
int type = wrapper.get(Type.VAR_INT, 1); int type = wrapper.get(Type.VAR_INT, 1);
EntityType entityType = Entity1_13Types.getTypeFromId(type, false); EntityType entityType = EntityTypes1_13.getTypeFromId(type, false);
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType); tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType);
int oldId = EntityTypeMapping.getOldId(type); int oldId = EntityTypeMapping.getOldId(type);
@ -170,7 +170,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.BYTE); map(Type.BYTE);
map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST); map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, Entity1_13Types.EntityType.PLAYER)); handler(getTrackerAndMetaHandler(Types1_12.METADATA_LIST, EntityTypes1_13.EntityType.PLAYER));
} }
}); });
@ -180,7 +180,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.VAR_INT); map(Type.VAR_INT);
map(Type.UUID); map(Type.UUID);
handler(getTrackerHandler(Entity1_13Types.EntityType.PAINTING, Type.VAR_INT)); handler(getTrackerHandler(EntityTypes1_13.EntityType.PAINTING, Type.VAR_INT));
handler(wrapper -> { handler(wrapper -> {
int motive = wrapper.read(Type.VAR_INT); int motive = wrapper.read(Type.VAR_INT);
String title = PaintingMapping.getStringId(motive); String title = PaintingMapping.getStringId(motive);
@ -189,7 +189,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}); });
registerJoinGame(ClientboundPackets1_13.JOIN_GAME, Entity1_13Types.EntityType.PLAYER); registerJoinGame(ClientboundPackets1_13.JOIN_GAME, EntityTypes1_13.EntityType.PLAYER);
protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() {
@Override @Override
@ -254,25 +254,25 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
// Rewrite new Entity 'drowned' // Rewrite new Entity 'drowned'
mapEntityTypeWithData(Entity1_13Types.EntityType.DROWNED, Entity1_13Types.EntityType.ZOMBIE_VILLAGER).plainName(); mapEntityTypeWithData(EntityTypes1_13.EntityType.DROWNED, EntityTypes1_13.EntityType.ZOMBIE_VILLAGER).plainName();
// Fishy // Fishy
mapEntityTypeWithData(Entity1_13Types.EntityType.COD, Entity1_13Types.EntityType.SQUID).plainName(); mapEntityTypeWithData(EntityTypes1_13.EntityType.COD, EntityTypes1_13.EntityType.SQUID).plainName();
mapEntityTypeWithData(Entity1_13Types.EntityType.SALMON, Entity1_13Types.EntityType.SQUID).plainName(); mapEntityTypeWithData(EntityTypes1_13.EntityType.SALMON, EntityTypes1_13.EntityType.SQUID).plainName();
mapEntityTypeWithData(Entity1_13Types.EntityType.PUFFERFISH, Entity1_13Types.EntityType.SQUID).plainName(); mapEntityTypeWithData(EntityTypes1_13.EntityType.PUFFERFISH, EntityTypes1_13.EntityType.SQUID).plainName();
mapEntityTypeWithData(Entity1_13Types.EntityType.TROPICAL_FISH, Entity1_13Types.EntityType.SQUID).plainName(); mapEntityTypeWithData(EntityTypes1_13.EntityType.TROPICAL_FISH, EntityTypes1_13.EntityType.SQUID).plainName();
// Phantom // Phantom
mapEntityTypeWithData(Entity1_13Types.EntityType.PHANTOM, Entity1_13Types.EntityType.PARROT).plainName().spawnMetadata(storage -> { mapEntityTypeWithData(EntityTypes1_13.EntityType.PHANTOM, EntityTypes1_13.EntityType.PARROT).plainName().spawnMetadata(storage -> {
// The phantom is grey/blue so let's do yellow/blue // The phantom is grey/blue so let's do yellow/blue
storage.add(new Metadata(15, MetaType1_12.VarInt, 3)); storage.add(new Metadata(15, MetaType1_12.VarInt, 3));
}); });
// Dolphin // Dolphin
mapEntityTypeWithData(Entity1_13Types.EntityType.DOLPHIN, Entity1_13Types.EntityType.SQUID).plainName(); mapEntityTypeWithData(EntityTypes1_13.EntityType.DOLPHIN, EntityTypes1_13.EntityType.SQUID).plainName();
// Turtle // Turtle
mapEntityTypeWithData(Entity1_13Types.EntityType.TURTLE, Entity1_13Types.EntityType.OCELOT).plainName(); mapEntityTypeWithData(EntityTypes1_13.EntityType.TURTLE, EntityTypes1_13.EntityType.OCELOT).plainName();
// Rewrite Meta types // Rewrite Meta types
filter().handler((event, meta) -> { filter().handler((event, meta) -> {
@ -297,36 +297,36 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
}); });
// Handle zombie metadata // Handle zombie metadata
filter().filterFamily(Entity1_13Types.EntityType.ZOMBIE).removeIndex(15); filter().filterFamily(EntityTypes1_13.EntityType.ZOMBIE).removeIndex(15);
// Handle turtle metadata (Remove them all for now) // Handle turtle metadata (Remove them all for now)
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(13); // Home pos filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(13); // Home pos
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(14); // Has egg filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(14); // Has egg
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(15); // Laying egg filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(15); // Laying egg
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(16); // Travel pos filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(16); // Travel pos
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(17); // Going home filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(17); // Going home
filter().type(Entity1_13Types.EntityType.TURTLE).cancel(18); // Traveling filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(18); // Traveling
// Remove additional fish meta // Remove additional fish meta
filter().filterFamily(Entity1_13Types.EntityType.ABSTRACT_FISHES).cancel(12); filter().filterFamily(EntityTypes1_13.EntityType.ABSTRACT_FISHES).cancel(12);
filter().filterFamily(Entity1_13Types.EntityType.ABSTRACT_FISHES).cancel(13); filter().filterFamily(EntityTypes1_13.EntityType.ABSTRACT_FISHES).cancel(13);
// Remove phantom size // Remove phantom size
filter().type(Entity1_13Types.EntityType.PHANTOM).cancel(12); filter().type(EntityTypes1_13.EntityType.PHANTOM).cancel(12);
// Remove boat splash timer // Remove boat splash timer
filter().type(Entity1_13Types.EntityType.BOAT).cancel(12); filter().type(EntityTypes1_13.EntityType.BOAT).cancel(12);
// Remove Trident special loyalty level // Remove Trident special loyalty level
filter().type(Entity1_13Types.EntityType.TRIDENT).cancel(7); filter().type(EntityTypes1_13.EntityType.TRIDENT).cancel(7);
// Handle new wolf colors // Handle new wolf colors
filter().type(Entity1_13Types.EntityType.WOLF).index(17).handler((event, meta) -> { filter().type(EntityTypes1_13.EntityType.WOLF).index(17).handler((event, meta) -> {
meta.setValue(15 - (int) meta.getValue()); meta.setValue(15 - (int) meta.getValue());
}); });
// Rewrite AreaEffectCloud // Rewrite AreaEffectCloud
filter().type(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD).index(9).handler((event, meta) -> { filter().type(EntityTypes1_13.EntityType.AREA_EFFECT_CLOUD).index(9).handler((event, meta) -> {
Particle particle = (Particle) meta.getValue(); Particle particle = (Particle) meta.getValue();
ParticleMapping.ParticleData data = ParticleMapping.getMapping(particle.getId()); ParticleMapping.ParticleData data = ParticleMapping.getMapping(particle.getId());
@ -354,12 +354,12 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_13Types.getTypeFromId(typeId, false); return EntityTypes1_13.getTypeFromId(typeId, false);
} }
@Override @Override
protected EntityType getObjectTypeFromId(final int typeId) { protected EntityType getObjectTypeFromId(final int typeId) {
return Entity1_13Types.getTypeFromId(typeId, true); return EntityTypes1_13.getTypeFromId(typeId, true);
} }
@Override @Override

Datei anzeigen

@ -81,16 +81,16 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
int size = wrapper.passthrough(Type.UNSIGNED_BYTE); int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
//Input Item //Input Item
Item input = wrapper.read(Type.FLAT_ITEM); Item input = wrapper.read(Type.ITEM1_13);
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(input)); wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(input));
//Output Item //Output Item
Item output = wrapper.read(Type.FLAT_ITEM); Item output = wrapper.read(Type.ITEM1_13);
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(output)); wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(output));
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
if (secondItem) { if (secondItem) {
//Second Item //Second Item
Item second = wrapper.read(Type.FLAT_ITEM); Item second = wrapper.read(Type.ITEM1_13);
wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(second)); wrapper.write(Type.ITEM, protocol.getItemRewriter().handleItemToClient(second));
} }
@ -383,7 +383,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
case "MC|BEdit": case "MC|BEdit":
wrapper.setPacketType(ServerboundPackets1_13.EDIT_BOOK); wrapper.setPacketType(ServerboundPackets1_13.EDIT_BOOK);
Item book = wrapper.read(Type.ITEM); Item book = wrapper.read(Type.ITEM);
wrapper.write(Type.FLAT_ITEM, protocol.getItemRewriter().handleItemToServer(book)); wrapper.write(Type.ITEM1_13, protocol.getItemRewriter().handleItemToServer(book));
boolean signing = channel.equals("MC|BSign"); boolean signing = channel.equals("MC|BSign");
wrapper.write(Type.BOOLEAN, signing); wrapper.write(Type.BOOLEAN, signing);
break; break;

Datei anzeigen

@ -42,7 +42,7 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() { registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
@Override @Override
public void register() { public void register() {
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); map(Type.ITEM1_13, Type.FLAT_VAR_INT_ITEM);
} }
}); });
@ -62,7 +62,7 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
wrapper.passthrough(Type.COMPONENT); // Title wrapper.passthrough(Type.COMPONENT); // Title
wrapper.passthrough(Type.COMPONENT); // Description wrapper.passthrough(Type.COMPONENT); // Description
Item icon = wrapper.read(Type.FLAT_VAR_INT_ITEM); Item icon = wrapper.read(Type.FLAT_VAR_INT_ITEM);
wrapper.write(Type.FLAT_ITEM, icon); wrapper.write(Type.ITEM1_13, icon);
wrapper.passthrough(Type.VAR_INT); // Frame type wrapper.passthrough(Type.VAR_INT); // Frame type
int flags = wrapper.passthrough(Type.INT); // Flags int flags = wrapper.passthrough(Type.INT); // Flags
if ((flags & 1) != 0) if ((flags & 1) != 0)

Datei anzeigen

@ -31,7 +31,7 @@ public class InventoryPackets1_13_2 {
public void register() { public void register() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot ID map(Type.SHORT); // 1 - Slot ID
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 2 - Slot Value map(Type.FLAT_VAR_INT_ITEM, Type.ITEM1_13); // 2 - Slot Value
} }
}); });
@ -39,7 +39,7 @@ public class InventoryPackets1_13_2 {
@Override @Override
public void register() { public void register() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.FLAT_VAR_INT_ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values map(Type.FLAT_VAR_INT_ITEM_ARRAY, Type.ITEM1_13_ARRAY); // 1 - Window Values
} }
}); });
@ -55,13 +55,13 @@ public class InventoryPackets1_13_2 {
int size = wrapper.passthrough(Type.UNSIGNED_BYTE); int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
// Input Item // Input Item
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM)); wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM));
// Output Item // Output Item
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM)); wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM));
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem) { if (secondItem) {
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM)); wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM));
} }
wrapper.passthrough(Type.BOOLEAN); // Trade disabled wrapper.passthrough(Type.BOOLEAN); // Trade disabled
@ -78,7 +78,7 @@ public class InventoryPackets1_13_2 {
public void register() { public void register() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
map(Type.VAR_INT); // 1 - Slot ID map(Type.VAR_INT); // 1 - Slot ID
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 2 - Item map(Type.FLAT_VAR_INT_ITEM, Type.ITEM1_13); // 2 - Item
} }
}); });
@ -121,7 +121,7 @@ public class InventoryPackets1_13_2 {
map(Type.BYTE); // 2 - Button map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode map(Type.VAR_INT); // 4 - Mode
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item map(Type.ITEM1_13, Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item
} }
}); });
@ -129,7 +129,7 @@ public class InventoryPackets1_13_2 {
@Override @Override
public void register() { public void register() {
map(Type.SHORT); // 0 - Slot map(Type.SHORT); // 0 - Slot
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item map(Type.ITEM1_13, Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item
} }
}); });
} }

Datei anzeigen

@ -42,7 +42,7 @@ public class WorldPackets1_13_2 {
handler(wrapper -> { handler(wrapper -> {
int id = wrapper.get(Type.INT, 0); int id = wrapper.get(Type.INT, 0);
if (id == 27) { if (id == 27) {
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM)); wrapper.write(Type.ITEM1_13, wrapper.read(Type.FLAT_VAR_INT_ITEM));
} }
}); });
} }

Datei anzeigen

@ -28,7 +28,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPa
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage; import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage; import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
@ -167,7 +167,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
user.put(new ClientWorld(user)); user.put(new ClientWorld(user));
} }
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_14Types.PLAYER)); user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_14.PLAYER));
if (!user.has(ChunkLightStorage.class)) { if (!user.has(ChunkLightStorage.class)) {
user.put(new ChunkLightStorage(user)); user.put(new ChunkLightStorage(user));

Datei anzeigen

@ -30,7 +30,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLight;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLightImpl; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLightImpl;
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
@ -234,7 +234,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
EntityType entityType = wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class).entityType(entityId); EntityType entityType = wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class).entityType(entityId);
if (entityType == null) return; if (entityType == null) return;
if (entityType.isOrHasParent(Entity1_14Types.ABSTRACT_HORSE)) { if (entityType.isOrHasParent(EntityTypes1_14.ABSTRACT_HORSE)) {
wrapper.setPacketType(ClientboundPackets1_13.ENTITY_METADATA); wrapper.setPacketType(ClientboundPackets1_13.ENTITY_METADATA);
wrapper.resetReader(); wrapper.resetReader();
wrapper.passthrough(Type.VAR_INT); wrapper.passthrough(Type.VAR_INT);
@ -443,7 +443,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
map(Type.VAR_INT); map(Type.VAR_INT);
map(Type.BYTE); map(Type.BYTE);
map(Type.BOOLEAN); map(Type.BOOLEAN);
map(Type.BOOLEAN, Type.NOTHING); // Locked read(Type.BOOLEAN); // Locked
} }
}); });

Datei anzeigen

@ -28,8 +28,8 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityP
import com.viaversion.viaversion.api.data.entity.EntityTracker; import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.VillagerData; import com.viaversion.viaversion.api.minecraft.VillagerData;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
@ -57,7 +57,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
super.addTrackedEntity(wrapper, entityId, type); super.addTrackedEntity(wrapper, entityId, type);
// Cache the position for every newly tracked entity // Cache the position for every newly tracked entity
if (type == Entity1_14Types.PAINTING) { if (type == EntityTypes1_14.PAINTING) {
final Position position = wrapper.get(Type.POSITION, 0); final Position position = wrapper.get(Type.POSITION, 0);
positionHandler.cacheEntityPosition(wrapper, position.x(), position.y(), position.z(), true, false); positionHandler.cacheEntityPosition(wrapper, position.x(), position.y(), position.z(), true, false);
} else if (wrapper.getId() != ClientboundPackets1_14.JOIN_GAME.getId()) { // ignore join game } else if (wrapper.getId() != ClientboundPackets1_14.JOIN_GAME.getId()) { // ignore join game
@ -77,7 +77,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
EntityTracker tracker = tracker(wrapper.user()); EntityTracker tracker = tracker(wrapper.user());
EntityType entityType = tracker.entityType(entityId); EntityType entityType = tracker.entityType(entityId);
if (entityType != Entity1_14Types.PLAYER) return; if (entityType != EntityTypes1_14.PLAYER) return;
// Remove equipment, else the client will see ghost items // Remove equipment, else the client will see ghost items
for (int i = 0; i <= 5; i++) { for (int i = 0; i <= 5; i++) {
@ -139,10 +139,10 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
handler(wrapper -> { handler(wrapper -> {
int id = wrapper.get(Type.BYTE, 0); int id = wrapper.get(Type.BYTE, 0);
int mappedId = newEntityId(id); int mappedId = newEntityId(id);
Entity1_13Types.EntityType entityType = Entity1_13Types.getTypeFromId(mappedId, false); EntityTypes1_13.EntityType entityType = EntityTypes1_13.getTypeFromId(mappedId, false);
Entity1_13Types.ObjectType objectType; EntityTypes1_13.ObjectType objectType;
if (entityType.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT)) { if (entityType.isOrHasParent(EntityTypes1_13.EntityType.MINECART_ABSTRACT)) {
objectType = Entity1_13Types.ObjectType.MINECART; objectType = EntityTypes1_13.ObjectType.MINECART;
int data = 0; int data = 0;
switch (entityType) { switch (entityType) {
case CHEST_MINECART: case CHEST_MINECART:
@ -167,7 +167,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
if (data != 0) if (data != 0)
wrapper.set(Type.INT, 0, data); wrapper.set(Type.INT, 0, data);
} else { } else {
objectType = Entity1_13Types.ObjectType.fromEntityType(entityType).orElse(null); objectType = EntityTypes1_13.ObjectType.fromEntityType(entityType).orElse(null);
} }
if (objectType == null) return; if (objectType == null) return;
@ -175,11 +175,11 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
wrapper.set(Type.BYTE, 0, (byte) objectType.getId()); wrapper.set(Type.BYTE, 0, (byte) objectType.getId());
int data = wrapper.get(Type.INT, 0); int data = wrapper.get(Type.INT, 0);
if (objectType == Entity1_13Types.ObjectType.FALLING_BLOCK) { if (objectType == EntityTypes1_13.ObjectType.FALLING_BLOCK) {
int blockState = wrapper.get(Type.INT, 0); int blockState = wrapper.get(Type.INT, 0);
int combined = protocol.getMappingData().getNewBlockStateId(blockState); int combined = protocol.getMappingData().getNewBlockStateId(blockState);
wrapper.set(Type.INT, 0, combined); wrapper.set(Type.INT, 0, combined);
} else if (entityType.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW)) { } else if (entityType.isOrHasParent(EntityTypes1_13.EntityType.ABSTRACT_ARROW)) {
wrapper.set(Type.INT, 0, data + 1); wrapper.set(Type.INT, 0, data + 1);
} }
}); });
@ -205,7 +205,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
handler(wrapper -> { handler(wrapper -> {
int type = wrapper.get(Type.VAR_INT, 1); int type = wrapper.get(Type.VAR_INT, 1);
EntityType entityType = Entity1_14Types.getTypeFromId(type); EntityType entityType = EntityTypes1_14.getTypeFromId(type);
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType); addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
int oldId = newEntityId(type); int oldId = newEntityId(type);
@ -234,7 +234,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.DOUBLE); // Needs to be mapped for the position cache map(Type.DOUBLE); // Needs to be mapped for the position cache
map(Type.DOUBLE); map(Type.DOUBLE);
map(Type.DOUBLE); map(Type.DOUBLE);
handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.EXPERIENCE_ORB)); handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.EXPERIENCE_ORB));
} }
}); });
@ -246,7 +246,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.DOUBLE); // Needs to be mapped for the position cache map(Type.DOUBLE); // Needs to be mapped for the position cache
map(Type.DOUBLE); map(Type.DOUBLE);
map(Type.DOUBLE); map(Type.DOUBLE);
handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.LIGHTNING_BOLT)); handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.LIGHTNING_BOLT));
} }
}); });
@ -260,7 +260,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.BYTE); map(Type.BYTE);
// Track entity // Track entity
handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), Entity1_14Types.PAINTING)); handler(wrapper -> addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), EntityTypes1_14.PAINTING));
} }
}); });
@ -276,7 +276,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.BYTE); // 6 - Pitch map(Type.BYTE); // 6 - Pitch
map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata
handler(getTrackerAndMetaHandler(Types1_13_2.METADATA_LIST, Entity1_14Types.PLAYER)); handler(getTrackerAndMetaHandler(Types1_13_2.METADATA_LIST, EntityTypes1_14.PLAYER));
handler(wrapper -> positionHandler.cacheEntityPosition(wrapper, true, false)); handler(wrapper -> positionHandler.cacheEntityPosition(wrapper, true, false));
} }
}); });
@ -291,7 +291,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.UNSIGNED_BYTE); // 1 - Gamemode map(Type.UNSIGNED_BYTE); // 1 - Gamemode
map(Type.INT); // 2 - Dimension map(Type.INT); // 2 - Dimension
handler(getTrackerHandler(Entity1_14Types.PLAYER, Type.INT)); handler(getTrackerHandler(EntityTypes1_14.PLAYER, Type.INT));
handler(getDimensionHandler(1)); handler(getDimensionHandler(1));
handler(wrapper -> { handler(wrapper -> {
short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty(); short difficulty = wrapper.user().get(DifficultyStorage.class).getDifficulty();
@ -331,15 +331,15 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
mapTypes(Entity1_14Types.values(), Entity1_13Types.EntityType.class); mapTypes(EntityTypes1_14.values(), EntityTypes1_13.EntityType.class);
mapEntityTypeWithData(Entity1_14Types.CAT, Entity1_14Types.OCELOT).jsonName(); mapEntityTypeWithData(EntityTypes1_14.CAT, EntityTypes1_14.OCELOT).jsonName();
mapEntityTypeWithData(Entity1_14Types.TRADER_LLAMA, Entity1_14Types.LLAMA).jsonName(); mapEntityTypeWithData(EntityTypes1_14.TRADER_LLAMA, EntityTypes1_14.LLAMA).jsonName();
mapEntityTypeWithData(Entity1_14Types.FOX, Entity1_14Types.WOLF).jsonName(); mapEntityTypeWithData(EntityTypes1_14.FOX, EntityTypes1_14.WOLF).jsonName();
mapEntityTypeWithData(Entity1_14Types.PANDA, Entity1_14Types.POLAR_BEAR).jsonName(); mapEntityTypeWithData(EntityTypes1_14.PANDA, EntityTypes1_14.POLAR_BEAR).jsonName();
mapEntityTypeWithData(Entity1_14Types.PILLAGER, Entity1_14Types.VILLAGER).jsonName(); mapEntityTypeWithData(EntityTypes1_14.PILLAGER, EntityTypes1_14.VILLAGER).jsonName();
mapEntityTypeWithData(Entity1_14Types.WANDERING_TRADER, Entity1_14Types.VILLAGER).jsonName(); mapEntityTypeWithData(EntityTypes1_14.WANDERING_TRADER, EntityTypes1_14.VILLAGER).jsonName();
mapEntityTypeWithData(Entity1_14Types.RAVAGER, Entity1_14Types.COW).jsonName(); mapEntityTypeWithData(EntityTypes1_14.RAVAGER, EntityTypes1_14.COW).jsonName();
filter().handler((event, meta) -> { filter().handler((event, meta) -> {
int typeId = meta.metaType().typeId(); int typeId = meta.metaType().typeId();
@ -351,28 +351,28 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
registerMetaTypeHandler(Types1_13_2.META_TYPES.itemType, Types1_13_2.META_TYPES.blockStateType, null, null, registerMetaTypeHandler(Types1_13_2.META_TYPES.itemType, Types1_13_2.META_TYPES.blockStateType, null, null,
Types1_13_2.META_TYPES.componentType, Types1_13_2.META_TYPES.optionalComponentType); Types1_13_2.META_TYPES.componentType, Types1_13_2.META_TYPES.optionalComponentType);
filter().type(Entity1_14Types.PILLAGER).cancel(15); filter().type(EntityTypes1_14.PILLAGER).cancel(15);
filter().type(Entity1_14Types.FOX).cancel(15); filter().type(EntityTypes1_14.FOX).cancel(15);
filter().type(Entity1_14Types.FOX).cancel(16); filter().type(EntityTypes1_14.FOX).cancel(16);
filter().type(Entity1_14Types.FOX).cancel(17); filter().type(EntityTypes1_14.FOX).cancel(17);
filter().type(Entity1_14Types.FOX).cancel(18); filter().type(EntityTypes1_14.FOX).cancel(18);
filter().type(Entity1_14Types.PANDA).cancel(15); filter().type(EntityTypes1_14.PANDA).cancel(15);
filter().type(Entity1_14Types.PANDA).cancel(16); filter().type(EntityTypes1_14.PANDA).cancel(16);
filter().type(Entity1_14Types.PANDA).cancel(17); filter().type(EntityTypes1_14.PANDA).cancel(17);
filter().type(Entity1_14Types.PANDA).cancel(18); filter().type(EntityTypes1_14.PANDA).cancel(18);
filter().type(Entity1_14Types.PANDA).cancel(19); filter().type(EntityTypes1_14.PANDA).cancel(19);
filter().type(Entity1_14Types.PANDA).cancel(20); filter().type(EntityTypes1_14.PANDA).cancel(20);
filter().type(Entity1_14Types.CAT).cancel(18); filter().type(EntityTypes1_14.CAT).cancel(18);
filter().type(Entity1_14Types.CAT).cancel(19); filter().type(EntityTypes1_14.CAT).cancel(19);
filter().type(Entity1_14Types.CAT).cancel(20); filter().type(EntityTypes1_14.CAT).cancel(20);
filter().handler((event, meta) -> { filter().handler((event, meta) -> {
EntityType type = event.entityType(); EntityType type = event.entityType();
if (type == null) return; if (type == null) return;
if (type.isOrHasParent(Entity1_14Types.ABSTRACT_ILLAGER_BASE) || type == Entity1_14Types.RAVAGER || type == Entity1_14Types.WITCH) { if (type.isOrHasParent(EntityTypes1_14.ABSTRACT_ILLAGER_BASE) || type == EntityTypes1_14.RAVAGER || type == EntityTypes1_14.WITCH) {
int index = event.index(); int index = event.index();
if (index == 14) { if (index == 14) {
event.cancel(); event.cancel();
@ -382,11 +382,11 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}); });
filter().type(Entity1_14Types.AREA_EFFECT_CLOUD).index(10).handler((event, meta) -> { filter().type(EntityTypes1_14.AREA_EFFECT_CLOUD).index(10).handler((event, meta) -> {
rewriteParticle((Particle) meta.getValue()); rewriteParticle((Particle) meta.getValue());
}); });
filter().type(Entity1_14Types.FIREWORK_ROCKET).index(8).handler((event, meta) -> { filter().type(EntityTypes1_14.FIREWORK_ROCKET).index(8).handler((event, meta) -> {
meta.setMetaType(Types1_13_2.META_TYPES.varIntType); meta.setMetaType(Types1_13_2.META_TYPES.varIntType);
Integer value = (Integer) meta.getValue(); Integer value = (Integer) meta.getValue();
if (value == null) { if (value == null) {
@ -394,9 +394,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}); });
filter().filterFamily(Entity1_14Types.ABSTRACT_ARROW).removeIndex(9); filter().filterFamily(EntityTypes1_14.ABSTRACT_ARROW).removeIndex(9);
filter().type(Entity1_14Types.VILLAGER).cancel(15); // Head shake timer filter().type(EntityTypes1_14.VILLAGER).cancel(15); // Head shake timer
MetaHandler villagerDataHandler = (event, meta) -> { MetaHandler villagerDataHandler = (event, meta) -> {
VillagerData villagerData = (VillagerData) meta.getValue(); VillagerData villagerData = (VillagerData) meta.getValue();
@ -406,27 +406,27 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}; };
filter().type(Entity1_14Types.ZOMBIE_VILLAGER).index(18).handler(villagerDataHandler); filter().type(EntityTypes1_14.ZOMBIE_VILLAGER).index(18).handler(villagerDataHandler);
filter().type(Entity1_14Types.VILLAGER).index(16).handler(villagerDataHandler); filter().type(EntityTypes1_14.VILLAGER).index(16).handler(villagerDataHandler);
// Holding arms up - from bitfield into own boolean // Holding arms up - from bitfield into own boolean
filter().filterFamily(Entity1_14Types.ABSTRACT_SKELETON).index(13).handler((event, meta) -> { filter().filterFamily(EntityTypes1_14.ABSTRACT_SKELETON).index(13).handler((event, meta) -> {
byte value = (byte) meta.getValue(); byte value = (byte) meta.getValue();
if ((value & 4) != 0) { if ((value & 4) != 0) {
event.createExtraMeta(new Metadata(14, Types1_13_2.META_TYPES.booleanType, true)); event.createExtraMeta(new Metadata(14, Types1_13_2.META_TYPES.booleanType, true));
} }
}); });
filter().filterFamily(Entity1_14Types.ZOMBIE).index(13).handler((event, meta) -> { filter().filterFamily(EntityTypes1_14.ZOMBIE).index(13).handler((event, meta) -> {
byte value = (byte) meta.getValue(); byte value = (byte) meta.getValue();
if ((value & 4) != 0) { if ((value & 4) != 0) {
event.createExtraMeta(new Metadata(16, Types1_13_2.META_TYPES.booleanType, true)); event.createExtraMeta(new Metadata(16, Types1_13_2.META_TYPES.booleanType, true));
} }
}); });
filter().filterFamily(Entity1_14Types.ZOMBIE).addIndex(16); filter().filterFamily(EntityTypes1_14.ZOMBIE).addIndex(16);
// Remove bed location // Remove bed location
filter().filterFamily(Entity1_14Types.LIVINGENTITY).handler((event, meta) -> { filter().filterFamily(EntityTypes1_14.LIVINGENTITY).handler((event, meta) -> {
int index = event.index(); int index = event.index();
if (index == 12) { if (index == 12) {
Position position = (Position) meta.getValue(); Position position = (Position) meta.getValue();
@ -452,12 +452,12 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
// Pose // Pose
filter().removeIndex(6); filter().removeIndex(6);
filter().type(Entity1_14Types.OCELOT).index(13).handler((event, meta) -> { filter().type(EntityTypes1_14.OCELOT).index(13).handler((event, meta) -> {
event.setIndex(15); event.setIndex(15);
meta.setTypeAndValue(Types1_13_2.META_TYPES.varIntType, 0); meta.setTypeAndValue(Types1_13_2.META_TYPES.varIntType, 0);
}); });
filter().type(Entity1_14Types.CAT).handler((event, meta) -> { filter().type(EntityTypes1_14.CAT).handler((event, meta) -> {
if (event.index() == 15) { if (event.index() == 15) {
meta.setValue(1); meta.setValue(1);
} else if (event.index() == 13) { } else if (event.index() == 13) {
@ -501,6 +501,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_14Types.getTypeFromId(typeId); return EntityTypes1_14.getTypeFromId(typeId);
} }
} }

Datei anzeigen

@ -38,7 +38,7 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
@Override @Override
public void register() { public void register() {
map(Type.UNSIGNED_BYTE); map(Type.UNSIGNED_BYTE);
map(Type.BOOLEAN, Type.NOTHING); // Locked read(Type.BOOLEAN); // Locked
handler(wrapper -> { handler(wrapper -> {
byte difficulty = wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue(); byte difficulty = wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue();
wrapper.user().get(DifficultyStorage.class).setDifficulty(difficulty); wrapper.user().get(DifficultyStorage.class).setDifficulty(difficulty);

Datei anzeigen

@ -27,7 +27,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.Invento
import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1; import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -88,10 +88,10 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() { registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
@Override @Override
public void register() { public void register() {
map(Type.FLAT_ITEM); map(Type.ITEM1_13);
map(Type.BOOLEAN); map(Type.BOOLEAN);
handler(wrapper -> { handler(wrapper -> {
itemRewriter.handleItemToServer(wrapper.get(Type.FLAT_ITEM, 0)); itemRewriter.handleItemToServer(wrapper.get(Type.ITEM1_13, 0));
wrapper.write(Type.VAR_INT, 0); wrapper.write(Type.VAR_INT, 0);
}); });
} }
@ -182,7 +182,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
if (wrapper.passthrough(Type.BOOLEAN)) { if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.COMPONENT); // Title wrapper.passthrough(Type.COMPONENT); // Title
wrapper.passthrough(Type.COMPONENT); // Description wrapper.passthrough(Type.COMPONENT); // Description
Item icon = wrapper.passthrough(Type.FLAT_ITEM); Item icon = wrapper.passthrough(Type.ITEM1_13);
itemRewriter.handleItemToClient(icon); itemRewriter.handleItemToClient(icon);
wrapper.passthrough(Type.VAR_INT); // Frame type wrapper.passthrough(Type.VAR_INT); // Frame type
int flags = wrapper.passthrough(Type.INT); // Flags int flags = wrapper.passthrough(Type.INT); // Flags
@ -207,7 +207,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
@Override @Override
public void init(UserConnection user) { public void init(UserConnection user) {
user.addEntityTracker(getClass(), new EntityTrackerBase(user, Entity1_13Types.EntityType.PLAYER)); user.addEntityTracker(getClass(), new EntityTrackerBase(user, EntityTypes1_13.EntityType.PLAYER));
if (!user.has(ClientWorld.class)) { if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld(user)); user.put(new ClientWorld(user));

Datei anzeigen

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets;
import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter; import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1; import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
@ -56,14 +56,14 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
handler(wrapper -> { handler(wrapper -> {
int entityId = wrapper.get(Type.VAR_INT, 0); int entityId = wrapper.get(Type.VAR_INT, 0);
byte type = wrapper.get(Type.BYTE, 0); byte type = wrapper.get(Type.BYTE, 0);
Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true); EntityTypes1_13.EntityType entType = EntityTypes1_13.getTypeFromId(type, true);
if (entType == null) { if (entType == null) {
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type); ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
return; return;
} }
// Rewrite falling block // Rewrite falling block
if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) { if (entType.is(EntityTypes1_13.EntityType.FALLING_BLOCK)) {
int data = wrapper.get(Type.INT, 0); int data = wrapper.get(Type.INT, 0);
wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(data)); wrapper.set(Type.INT, 0, protocol.getMappingData().getNewBlockStateId(data));
} }
@ -74,8 +74,8 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
} }
}); });
registerTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, Entity1_13Types.EntityType.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, EntityTypes1_13.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, Entity1_13Types.EntityType.LIGHTNING_BOLT); registerTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, EntityTypes1_13.EntityType.LIGHTNING_BOLT);
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() {
@Override @Override
@ -117,12 +117,12 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
map(Type.BYTE); // 6 - Pitch map(Type.BYTE); // 6 - Pitch
map(Types1_13.METADATA_LIST); // 7 - Metadata map(Types1_13.METADATA_LIST); // 7 - Metadata
handler(getTrackerAndMetaHandler(Types1_13.METADATA_LIST, Entity1_13Types.EntityType.PLAYER)); handler(getTrackerAndMetaHandler(Types1_13.METADATA_LIST, EntityTypes1_13.EntityType.PLAYER));
} }
}); });
registerTracker(ClientboundPackets1_13.SPAWN_PAINTING, Entity1_13Types.EntityType.PAINTING); registerTracker(ClientboundPackets1_13.SPAWN_PAINTING, EntityTypes1_13.EntityType.PAINTING);
registerJoinGame(ClientboundPackets1_13.JOIN_GAME, Entity1_13Types.EntityType.PLAYER); registerJoinGame(ClientboundPackets1_13.JOIN_GAME, EntityTypes1_13.EntityType.PLAYER);
registerRespawn(ClientboundPackets1_13.RESPAWN); registerRespawn(ClientboundPackets1_13.RESPAWN);
registerRemoveEntities(ClientboundPackets1_13.DESTROY_ENTITIES); registerRemoveEntities(ClientboundPackets1_13.DESTROY_ENTITIES);
registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, Types1_13.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, Types1_13.METADATA_LIST);
@ -147,16 +147,16 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
}); });
// Remove shooter UUID // Remove shooter UUID
filter().filterFamily(Entity1_13Types.EntityType.ABSTRACT_ARROW).cancel(7); filter().filterFamily(EntityTypes1_13.EntityType.ABSTRACT_ARROW).cancel(7);
// Move colors to old position // Move colors to old position
filter().type(Entity1_13Types.EntityType.SPECTRAL_ARROW).index(8).toIndex(7); filter().type(EntityTypes1_13.EntityType.SPECTRAL_ARROW).index(8).toIndex(7);
// Move loyalty level to old position // Move loyalty level to old position
filter().type(Entity1_13Types.EntityType.TRIDENT).index(8).toIndex(7); filter().type(EntityTypes1_13.EntityType.TRIDENT).index(8).toIndex(7);
// Rewrite Minecart blocks // Rewrite Minecart blocks
filter().filterFamily(Entity1_13Types.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> { filter().filterFamily(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> {
int data = (int) meta.getValue(); int data = (int) meta.getValue();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
}); });
@ -164,11 +164,11 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_13Types.getTypeFromId(typeId, false); return EntityTypes1_13.getTypeFromId(typeId, false);
} }
@Override @Override
protected EntityType getObjectTypeFromId(final int typeId) { protected EntityType getObjectTypeFromId(final int typeId) {
return Entity1_13Types.getTypeFromId(typeId, true); return EntityTypes1_13.getTypeFromId(typeId, true);
} }
} }

Datei anzeigen

@ -33,8 +33,8 @@ public class InventoryPackets1_13_1 extends ItemRewriter<ClientboundPackets1_13,
@Override @Override
public void registerPackets() { public void registerPackets() {
registerSetCooldown(ClientboundPackets1_13.COOLDOWN); registerSetCooldown(ClientboundPackets1_13.COOLDOWN);
registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY); registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.ITEM1_13_ARRAY);
registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM); registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.ITEM1_13);
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> { protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> {
String channel = wrapper.passthrough(Type.STRING); String channel = wrapper.passthrough(Type.STRING);
@ -44,16 +44,16 @@ public class InventoryPackets1_13_1 extends ItemRewriter<ClientboundPackets1_13,
int size = wrapper.passthrough(Type.UNSIGNED_BYTE); int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
//Input Item //Input Item
Item input = wrapper.passthrough(Type.FLAT_ITEM); Item input = wrapper.passthrough(Type.ITEM1_13);
handleItemToClient(input); handleItemToClient(input);
//Output Item //Output Item
Item output = wrapper.passthrough(Type.FLAT_ITEM); Item output = wrapper.passthrough(Type.ITEM1_13);
handleItemToClient(output); handleItemToClient(output);
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
if (secondItem) { if (secondItem) {
//Second Item //Second Item
Item second = wrapper.passthrough(Type.FLAT_ITEM); Item second = wrapper.passthrough(Type.ITEM1_13);
handleItemToClient(second); handleItemToClient(second);
} }
@ -64,10 +64,10 @@ public class InventoryPackets1_13_1 extends ItemRewriter<ClientboundPackets1_13,
} }
}); });
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM); registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.ITEM1_13);
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_ITEM); registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.ITEM1_13);
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_ITEM); registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.ITEM1_13);
registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, Type.FLAT_ITEM, Type.FLOAT); registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, Type.ITEM1_13, Type.FLOAT);
} }
} }

Datei anzeigen

@ -26,7 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockIt
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15; import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -102,7 +102,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
@Override @Override
public void init(UserConnection user) { public void init(UserConnection user) {
user.put(new ImmediateRespawn()); user.put(new ImmediateRespawn());
user.addEntityTracker(getClass(), new EntityTrackerBase(user, Entity1_15Types.PLAYER)); user.addEntityTracker(getClass(), new EntityTrackerBase(user, EntityTypes1_15.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -17,13 +17,13 @@
*/ */
package com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data; package com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
public class EntityTypeMapping { public class EntityTypeMapping {
// There's only the bee, so not much to do here // There's only the bee, so not much to do here
public static int getOldEntityId(int entityId) { public static int getOldEntityId(int entityId) {
if (entityId == 4) return Entity1_14Types.PUFFERFISH.getId(); // Flying pufferfish! if (entityId == 4) return EntityTypes1_14.PUFFERFISH.getId(); // Flying pufferfish!
return entityId >= 5 ? entityId - 1 : entityId; return entityId >= 5 ? entityId - 1 : entityId;
} }
} }

Datei anzeigen

@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15; import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping; import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn; import com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
@ -64,7 +64,7 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
} }
}); });
registerTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_15Types.FALLING_BLOCK); registerTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, EntityTypes1_15.FALLING_BLOCK);
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_MOB, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_15.SPAWN_MOB, new PacketHandlers() {
@Override @Override
@ -85,7 +85,7 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
handler(wrapper -> { handler(wrapper -> {
int type = wrapper.get(Type.VAR_INT, 1); int type = wrapper.get(Type.VAR_INT, 1);
EntityType entityType = Entity1_15Types.getTypeFromId(type); EntityType entityType = EntityTypes1_15.getTypeFromId(type);
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType); tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType);
wrapper.set(Type.VAR_INT, 1, EntityTypeMapping.getOldEntityId(type)); wrapper.set(Type.VAR_INT, 1, EntityTypeMapping.getOldEntityId(type));
}); });
@ -96,7 +96,7 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
@Override @Override
public void register() { public void register() {
map(Type.INT); map(Type.INT);
map(Type.LONG, Type.NOTHING); // Seed read(Type.LONG); // Seed
} }
}); });
@ -107,14 +107,14 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
map(Type.UNSIGNED_BYTE); // 1 - Gamemode map(Type.UNSIGNED_BYTE); // 1 - Gamemode
map(Type.INT); // 2 - Dimension map(Type.INT); // 2 - Dimension
map(Type.LONG, Type.NOTHING); // Seed read(Type.LONG); // Seed
map(Type.UNSIGNED_BYTE); // 3 - Max Players map(Type.UNSIGNED_BYTE); // 3 - Max Players
map(Type.STRING); // 4 - Level Type map(Type.STRING); // 4 - Level Type
map(Type.VAR_INT); // 5 - View Distance map(Type.VAR_INT); // 5 - View Distance
map(Type.BOOLEAN); // 6 - Reduce Debug Info map(Type.BOOLEAN); // 6 - Reduce Debug Info
handler(getTrackerHandler(Entity1_15Types.PLAYER, Type.INT)); handler(getTrackerHandler(EntityTypes1_15.PLAYER, Type.INT));
handler(wrapper -> { handler(wrapper -> {
boolean immediateRespawn = !wrapper.read(Type.BOOLEAN); // Inverted boolean immediateRespawn = !wrapper.read(Type.BOOLEAN); // Inverted
@ -123,9 +123,9 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
} }
}); });
registerTracker(ClientboundPackets1_15.SPAWN_EXPERIENCE_ORB, Entity1_15Types.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_15.SPAWN_EXPERIENCE_ORB, EntityTypes1_15.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY, Entity1_15Types.LIGHTNING_BOLT); registerTracker(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY, EntityTypes1_15.LIGHTNING_BOLT);
registerTracker(ClientboundPackets1_15.SPAWN_PAINTING, Entity1_15Types.PAINTING); registerTracker(ClientboundPackets1_15.SPAWN_PAINTING, EntityTypes1_15.PAINTING);
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_PLAYER, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_15.SPAWN_PLAYER, new PacketHandlers() {
@Override @Override
@ -139,7 +139,7 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
map(Type.BYTE); // 6 - Pitch map(Type.BYTE); // 6 - Pitch
handler(wrapper -> wrapper.write(Types1_14.METADATA_LIST, new ArrayList<>())); // Metadata is no longer sent in 1.15, so we have to send an empty one handler(wrapper -> wrapper.write(Types1_14.METADATA_LIST, new ArrayList<>())); // Metadata is no longer sent in 1.15, so we have to send an empty one
handler(getTrackerHandler(Entity1_15Types.PLAYER, Type.VAR_INT)); handler(getTrackerHandler(EntityTypes1_15.PLAYER, Type.VAR_INT));
} }
}); });
@ -155,7 +155,7 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
handler(wrapper -> { handler(wrapper -> {
int entityId = wrapper.get(Type.VAR_INT, 0); int entityId = wrapper.get(Type.VAR_INT, 0);
EntityType entityType = tracker(wrapper.user()).entityType(entityId); EntityType entityType = tracker(wrapper.user()).entityType(entityId);
if (entityType != Entity1_15Types.BEE) return; if (entityType != EntityTypes1_15.BEE) return;
int size = wrapper.get(Type.INT, 0); int size = wrapper.get(Type.INT, 0);
int newSize = size; int newSize = size;
@ -195,29 +195,29 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType, registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType,
Types1_14.META_TYPES.componentType, Types1_14.META_TYPES.optionalComponentType); Types1_14.META_TYPES.componentType, Types1_14.META_TYPES.optionalComponentType);
filter().filterFamily(Entity1_15Types.LIVINGENTITY).removeIndex(12); filter().filterFamily(EntityTypes1_15.LIVINGENTITY).removeIndex(12);
filter().type(Entity1_15Types.BEE).cancel(15); filter().type(EntityTypes1_15.BEE).cancel(15);
filter().type(Entity1_15Types.BEE).cancel(16); filter().type(EntityTypes1_15.BEE).cancel(16);
mapEntityTypeWithData(Entity1_15Types.BEE, Entity1_15Types.PUFFERFISH).jsonName().spawnMetadata(storage -> { mapEntityTypeWithData(EntityTypes1_15.BEE, EntityTypes1_15.PUFFERFISH).jsonName().spawnMetadata(storage -> {
storage.add(new Metadata(14, Types1_14.META_TYPES.booleanType, false)); storage.add(new Metadata(14, Types1_14.META_TYPES.booleanType, false));
storage.add(new Metadata(15, Types1_14.META_TYPES.varIntType, 2)); storage.add(new Metadata(15, Types1_14.META_TYPES.varIntType, 2));
}); });
filter().type(Entity1_15Types.ENDERMAN).cancel(16); filter().type(EntityTypes1_15.ENDERMAN).cancel(16);
filter().type(Entity1_15Types.TRIDENT).cancel(10); filter().type(EntityTypes1_15.TRIDENT).cancel(10);
// Redundant health removed in 1.15 // Redundant health removed in 1.15
filter().type(Entity1_15Types.WOLF).addIndex(17); filter().type(EntityTypes1_15.WOLF).addIndex(17);
filter().type(Entity1_15Types.WOLF).index(8).handler((event, meta) -> { filter().type(EntityTypes1_15.WOLF).index(8).handler((event, meta) -> {
event.createExtraMeta(new Metadata(17/*WOLF_HEALTH*/, Types1_14.META_TYPES.floatType, event.meta().value())); event.createExtraMeta(new Metadata(17/*WOLF_HEALTH*/, Types1_14.META_TYPES.floatType, event.meta().value()));
}); });
} }
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_15Types.getTypeFromId(typeId); return EntityTypes1_15.getTypeFromId(typeId);
} }
@Override @Override

Datei anzeigen

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_14to1_14_1;
import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.packets.EntityPackets1_14_1; import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.packets.EntityPackets1_14_1;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
@ -40,7 +40,7 @@ public class Protocol1_14To1_14_1 extends BackwardsProtocol<ClientboundPackets1_
@Override @Override
public void init(UserConnection user) { public void init(UserConnection user) {
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_15Types.PLAYER)); user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_15.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -19,7 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.packets;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter; import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1; import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -36,11 +36,11 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<ClientboundPackets
@Override @Override
protected void registerPackets() { protected void registerPackets() {
registerTracker(ClientboundPackets1_14.SPAWN_EXPERIENCE_ORB, Entity1_14Types.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_14.SPAWN_EXPERIENCE_ORB, EntityTypes1_14.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_14.SPAWN_GLOBAL_ENTITY, Entity1_14Types.LIGHTNING_BOLT); registerTracker(ClientboundPackets1_14.SPAWN_GLOBAL_ENTITY, EntityTypes1_14.LIGHTNING_BOLT);
registerTracker(ClientboundPackets1_14.SPAWN_PAINTING, Entity1_14Types.PAINTING); registerTracker(ClientboundPackets1_14.SPAWN_PAINTING, EntityTypes1_14.PAINTING);
registerTracker(ClientboundPackets1_14.SPAWN_PLAYER, Entity1_14Types.PLAYER); registerTracker(ClientboundPackets1_14.SPAWN_PLAYER, EntityTypes1_14.PLAYER);
registerTracker(ClientboundPackets1_14.JOIN_GAME, Entity1_14Types.PLAYER, Type.INT); registerTracker(ClientboundPackets1_14.JOIN_GAME, EntityTypes1_14.PLAYER, Type.INT);
registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES); registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES);
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_ENTITY, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_14.SPAWN_ENTITY, new PacketHandlers() {
@ -76,7 +76,7 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<ClientboundPackets
int type = wrapper.get(Type.VAR_INT, 1); int type = wrapper.get(Type.VAR_INT, 1);
// Register Type ID // Register Type ID
tracker(wrapper.user()).addEntity(entityId, Entity1_14Types.getTypeFromId(type)); tracker(wrapper.user()).addEntity(entityId, EntityTypes1_14.getTypeFromId(type));
List<Metadata> metadata = wrapper.get(Types1_14.METADATA_LIST, 0); List<Metadata> metadata = wrapper.get(Types1_14.METADATA_LIST, 0);
handleMetadata(entityId, metadata, wrapper.user()); handleMetadata(entityId, metadata, wrapper.user());
@ -90,13 +90,13 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<ClientboundPackets
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
filter().type(Entity1_14Types.VILLAGER).cancel(15); filter().type(EntityTypes1_14.VILLAGER).cancel(15);
filter().type(Entity1_14Types.VILLAGER).index(16).toIndex(15); filter().type(EntityTypes1_14.VILLAGER).index(16).toIndex(15);
filter().type(Entity1_14Types.WANDERING_TRADER).cancel(15); filter().type(EntityTypes1_14.WANDERING_TRADER).cancel(15);
} }
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_14Types.getTypeFromId(typeId); return EntityTypes1_14.getTypeFromId(typeId);
} }
} }

Datei anzeigen

@ -28,7 +28,7 @@ import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityP
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage.PlayerSneakStorage; import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage.PlayerSneakStorage;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -85,7 +85,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
public void register() { public void register() {
handler(wrapper -> translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT))); handler(wrapper -> translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT)));
map(Type.BYTE); map(Type.BYTE);
map(Type.UUID, Type.NOTHING); // Sender read(Type.UUID); // Sender
} }
}); });
@ -171,7 +171,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
user.put(new PlayerSneakStorage()); user.put(new PlayerSneakStorage());
user.put(new WorldNameTracker()); user.put(new WorldNameTracker());
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_16Types.PLAYER)); user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_16.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -137,7 +137,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
public void register() { public void register() {
map(Type.VAR_INT); // x map(Type.VAR_INT); // x
map(Type.VAR_INT); // y map(Type.VAR_INT); // y
map(Type.BOOLEAN, Type.NOTHING); read(Type.BOOLEAN);
} }
}); });

Datei anzeigen

@ -23,8 +23,8 @@ import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data.WorldNameT
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage.WolfDataMaskStorage; import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage.WolfDataMaskStorage;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
@ -80,7 +80,7 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
map(Type.INT); // 8 - Data map(Type.INT); // 8 - Data
handler(wrapper -> { handler(wrapper -> {
EntityType entityType = typeFromId(wrapper.get(Type.VAR_INT, 1)); EntityType entityType = typeFromId(wrapper.get(Type.VAR_INT, 1));
if (entityType == Entity1_16Types.LIGHTNING_BOLT) { if (entityType == EntityTypes1_16.LIGHTNING_BOLT) {
// Map to old weather entity packet // Map to old weather entity packet
wrapper.cancel(); wrapper.cancel();
@ -93,7 +93,7 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
spawnLightningPacket.send(Protocol1_15_2To1_16.class); spawnLightningPacket.send(Protocol1_15_2To1_16.class);
} }
}); });
handler(getSpawnTrackerWithDataHandler(Entity1_16Types.FALLING_BLOCK)); handler(getSpawnTrackerWithDataHandler(EntityTypes1_16.FALLING_BLOCK));
} }
}); });
@ -149,9 +149,9 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
public void register() { public void register() {
map(Type.INT); // Entity ID map(Type.INT); // Entity ID
map(Type.UNSIGNED_BYTE); // Gamemode map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE, Type.NOTHING); // Previous gamemode read(Type.BYTE); // Previous gamemode
map(Type.STRING_ARRAY, Type.NOTHING); // World list read(Type.STRING_ARRAY); // World list
map(Type.NAMED_COMPOUND_TAG, Type.NOTHING); // whatever this is read(Type.NAMED_COMPOUND_TAG); // whatever this is
map(dimensionTransformer); // Dimension Type map(dimensionTransformer); // Dimension Type
handler(wrapper -> { handler(wrapper -> {
WorldNameTracker worldNameTracker = wrapper.user().get(WorldNameTracker.class); WorldNameTracker worldNameTracker = wrapper.user().get(WorldNameTracker.class);
@ -162,7 +162,7 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
handler(wrapper -> { handler(wrapper -> {
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class); ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
clientChunks.setEnvironment(wrapper.get(Type.INT, 1)); clientChunks.setEnvironment(wrapper.get(Type.INT, 1));
tracker(wrapper.user()).addEntity(wrapper.get(Type.INT, 0), Entity1_16Types.PLAYER); tracker(wrapper.user()).addEntity(wrapper.get(Type.INT, 0), EntityTypes1_16.PLAYER);
wrapper.write(Type.STRING, "default"); // Level type wrapper.write(Type.STRING, "default"); // Level type
@ -178,10 +178,10 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
} }
}); });
registerTracker(ClientboundPackets1_16.SPAWN_EXPERIENCE_ORB, Entity1_16Types.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_16.SPAWN_EXPERIENCE_ORB, EntityTypes1_16.EXPERIENCE_ORB);
// F Spawn Global Object, it is no longer with us :( // F Spawn Global Object, it is no longer with us :(
registerTracker(ClientboundPackets1_16.SPAWN_PAINTING, Entity1_16Types.PAINTING); registerTracker(ClientboundPackets1_16.SPAWN_PAINTING, EntityTypes1_16.PAINTING);
registerTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16Types.PLAYER); registerTracker(ClientboundPackets1_16.SPAWN_PLAYER, EntityTypes1_16.PLAYER);
registerRemoveEntities(ClientboundPackets1_16.DESTROY_ENTITIES); registerRemoveEntities(ClientboundPackets1_16.DESTROY_ENTITIES);
registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_16.METADATA_LIST, Types1_14.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_16.METADATA_LIST, Types1_14.METADATA_LIST);
@ -257,45 +257,45 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
} }
}); });
mapEntityType(Entity1_16Types.ZOMBIFIED_PIGLIN, Entity1_15Types.ZOMBIE_PIGMAN); mapEntityType(EntityTypes1_16.ZOMBIFIED_PIGLIN, EntityTypes1_15.ZOMBIE_PIGMAN);
mapTypes(Entity1_16Types.values(), Entity1_15Types.class); mapTypes(EntityTypes1_16.values(), EntityTypes1_15.class);
mapEntityTypeWithData(Entity1_16Types.HOGLIN, Entity1_16Types.COW).jsonName(); mapEntityTypeWithData(EntityTypes1_16.HOGLIN, EntityTypes1_16.COW).jsonName();
mapEntityTypeWithData(Entity1_16Types.ZOGLIN, Entity1_16Types.COW).jsonName(); mapEntityTypeWithData(EntityTypes1_16.ZOGLIN, EntityTypes1_16.COW).jsonName();
mapEntityTypeWithData(Entity1_16Types.PIGLIN, Entity1_16Types.ZOMBIFIED_PIGLIN).jsonName(); mapEntityTypeWithData(EntityTypes1_16.PIGLIN, EntityTypes1_16.ZOMBIFIED_PIGLIN).jsonName();
mapEntityTypeWithData(Entity1_16Types.STRIDER, Entity1_16Types.MAGMA_CUBE).jsonName(); mapEntityTypeWithData(EntityTypes1_16.STRIDER, EntityTypes1_16.MAGMA_CUBE).jsonName();
filter().type(Entity1_16Types.ZOGLIN).cancel(16); filter().type(EntityTypes1_16.ZOGLIN).cancel(16);
filter().type(Entity1_16Types.HOGLIN).cancel(15); filter().type(EntityTypes1_16.HOGLIN).cancel(15);
filter().type(Entity1_16Types.PIGLIN).cancel(16); filter().type(EntityTypes1_16.PIGLIN).cancel(16);
filter().type(Entity1_16Types.PIGLIN).cancel(17); filter().type(EntityTypes1_16.PIGLIN).cancel(17);
filter().type(Entity1_16Types.PIGLIN).cancel(18); filter().type(EntityTypes1_16.PIGLIN).cancel(18);
filter().type(Entity1_16Types.STRIDER).index(15).handler((event, meta) -> { filter().type(EntityTypes1_16.STRIDER).index(15).handler((event, meta) -> {
boolean baby = meta.value(); boolean baby = meta.value();
meta.setTypeAndValue(Types1_14.META_TYPES.varIntType, baby ? 1 : 3); meta.setTypeAndValue(Types1_14.META_TYPES.varIntType, baby ? 1 : 3);
}); });
filter().type(Entity1_16Types.STRIDER).cancel(16); filter().type(EntityTypes1_16.STRIDER).cancel(16);
filter().type(Entity1_16Types.STRIDER).cancel(17); filter().type(EntityTypes1_16.STRIDER).cancel(17);
filter().type(Entity1_16Types.STRIDER).cancel(18); filter().type(EntityTypes1_16.STRIDER).cancel(18);
filter().type(Entity1_16Types.FISHING_BOBBER).cancel(8); filter().type(EntityTypes1_16.FISHING_BOBBER).cancel(8);
filter().filterFamily(Entity1_16Types.ABSTRACT_ARROW).cancel(8); filter().filterFamily(EntityTypes1_16.ABSTRACT_ARROW).cancel(8);
filter().filterFamily(Entity1_16Types.ABSTRACT_ARROW).handler((event, meta) -> { filter().filterFamily(EntityTypes1_16.ABSTRACT_ARROW).handler((event, meta) -> {
if (event.index() >= 8) { if (event.index() >= 8) {
event.setIndex(event.index() + 1); event.setIndex(event.index() + 1);
} }
}); });
filter().type(Entity1_16Types.WOLF).index(16).handler((event, meta) -> { filter().type(EntityTypes1_16.WOLF).index(16).handler((event, meta) -> {
byte mask = meta.value(); byte mask = meta.value();
StoredEntityData data = tracker(event.user()).entityData(event.entityId()); StoredEntityData data = tracker(event.user()).entityData(event.entityId());
data.put(new WolfDataMaskStorage(mask)); data.put(new WolfDataMaskStorage(mask));
}); });
filter().type(Entity1_16Types.WOLF).index(20).handler((event, meta) -> { filter().type(EntityTypes1_16.WOLF).index(20).handler((event, meta) -> {
StoredEntityData data = tracker(event.user()).entityDataIfPresent(event.entityId()); StoredEntityData data = tracker(event.user()).entityDataIfPresent(event.entityId());
byte previousMask = 0; byte previousMask = 0;
if (data != null) { if (data != null) {
@ -314,6 +314,6 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_16Types.getTypeFromId(typeId); return EntityTypes1_16.getTypeFromId(typeId);
} }
} }

Datei anzeigen

@ -27,7 +27,7 @@ import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.packets.Entit
import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.storage.BiomeStorage; import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.storage.BiomeStorage;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
@ -120,7 +120,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
@Override @Override
public void init(UserConnection user) { public void init(UserConnection user) {
user.put(new BiomeStorage()); user.put(new BiomeStorage());
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_16_2Types.PLAYER)); user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_16_2.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -22,8 +22,8 @@ import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2; import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.storage.BiomeStorage; import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.storage.BiomeStorage;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
@ -49,11 +49,11 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
@Override @Override
protected void registerPackets() { protected void registerPackets() {
registerTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, Entity1_16_2Types.FALLING_BLOCK); registerTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, EntityTypes1_16_2.FALLING_BLOCK);
registerSpawnTracker(ClientboundPackets1_16_2.SPAWN_MOB); registerSpawnTracker(ClientboundPackets1_16_2.SPAWN_MOB);
registerTracker(ClientboundPackets1_16_2.SPAWN_EXPERIENCE_ORB, Entity1_16_2Types.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_16_2.SPAWN_EXPERIENCE_ORB, EntityTypes1_16_2.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_16_2.SPAWN_PAINTING, Entity1_16_2Types.PAINTING); registerTracker(ClientboundPackets1_16_2.SPAWN_PAINTING, EntityTypes1_16_2.PAINTING);
registerTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_16_2Types.PLAYER); registerTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, EntityTypes1_16_2.PLAYER);
registerRemoveEntities(ClientboundPackets1_16_2.DESTROY_ENTITIES); registerRemoveEntities(ClientboundPackets1_16_2.DESTROY_ENTITIES);
registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_16.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_16.METADATA_LIST);
@ -103,7 +103,7 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
wrapper.write(Type.UNSIGNED_BYTE, (short) Math.min(maxPlayers, 255)); wrapper.write(Type.UNSIGNED_BYTE, (short) Math.min(maxPlayers, 255));
}); });
// ... // ...
handler(getTrackerHandler(Entity1_16_2Types.PLAYER, Type.INT)); handler(getTrackerHandler(EntityTypes1_16_2.PLAYER, Type.INT));
} }
}); });
@ -125,15 +125,15 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null,
Types1_16.META_TYPES.particleType, Types1_16.META_TYPES.componentType, Types1_16.META_TYPES.optionalComponentType); Types1_16.META_TYPES.particleType, Types1_16.META_TYPES.componentType, Types1_16.META_TYPES.optionalComponentType);
mapTypes(Entity1_16_2Types.values(), Entity1_16Types.class); mapTypes(EntityTypes1_16_2.values(), EntityTypes1_16.class);
mapEntityTypeWithData(Entity1_16_2Types.PIGLIN_BRUTE, Entity1_16_2Types.PIGLIN).jsonName(); mapEntityTypeWithData(EntityTypes1_16_2.PIGLIN_BRUTE, EntityTypes1_16_2.PIGLIN).jsonName();
filter().filterFamily(Entity1_16_2Types.ABSTRACT_PIGLIN).index(15).toIndex(16); filter().filterFamily(EntityTypes1_16_2.ABSTRACT_PIGLIN).index(15).toIndex(16);
filter().filterFamily(Entity1_16_2Types.ABSTRACT_PIGLIN).index(16).toIndex(15); filter().filterFamily(EntityTypes1_16_2.ABSTRACT_PIGLIN).index(16).toIndex(15);
} }
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_16_2Types.getTypeFromId(typeId); return EntityTypes1_16_2.getTypeFromId(typeId);
} }
} }

Datei anzeigen

@ -29,7 +29,7 @@ import com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.storage.PlayerL
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.TagData; import com.viaversion.viaversion.api.minecraft.TagData;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -220,7 +220,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
@Override @Override
public void init(UserConnection user) { public void init(UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, Entity1_17Types.PLAYER)); addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_17.PLAYER));
user.put(new PingRequests()); user.put(new PingRequests());
user.put(new PlayerLastCursorItem()); user.put(new PlayerLastCursorItem());
} }

Datei anzeigen

@ -20,8 +20,8 @@ package com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.packets;
import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17; import com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -47,11 +47,11 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
@Override @Override
protected void registerPackets() { protected void registerPackets() {
registerTrackerWithData(ClientboundPackets1_17.SPAWN_ENTITY, Entity1_17Types.FALLING_BLOCK); registerTrackerWithData(ClientboundPackets1_17.SPAWN_ENTITY, EntityTypes1_17.FALLING_BLOCK);
registerSpawnTracker(ClientboundPackets1_17.SPAWN_MOB); registerSpawnTracker(ClientboundPackets1_17.SPAWN_MOB);
registerTracker(ClientboundPackets1_17.SPAWN_EXPERIENCE_ORB, Entity1_17Types.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_17.SPAWN_EXPERIENCE_ORB, EntityTypes1_17.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_17.SPAWN_PAINTING, Entity1_17Types.PAINTING); registerTracker(ClientboundPackets1_17.SPAWN_PAINTING, EntityTypes1_17.PAINTING);
registerTracker(ClientboundPackets1_17.SPAWN_PLAYER, Entity1_17Types.PLAYER); registerTracker(ClientboundPackets1_17.SPAWN_PLAYER, EntityTypes1_17.PLAYER);
registerMetadataRewriter(ClientboundPackets1_17.ENTITY_METADATA, Types1_17.METADATA_LIST, Types1_16.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_17.ENTITY_METADATA, Types1_17.METADATA_LIST, Types1_16.METADATA_LIST);
protocol.registerClientbound(ClientboundPackets1_17.REMOVE_ENTITY, ClientboundPackets1_16_2.DESTROY_ENTITIES, wrapper -> { protocol.registerClientbound(ClientboundPackets1_17.REMOVE_ENTITY, ClientboundPackets1_16_2.DESTROY_ENTITIES, wrapper -> {
@ -80,7 +80,7 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
wrapper.set(Type.BYTE, 0, (byte) 0); wrapper.set(Type.BYTE, 0, (byte) 0);
} }
}); });
handler(getTrackerHandler(Entity1_17Types.PLAYER, Type.INT)); handler(getTrackerHandler(EntityTypes1_17.PLAYER, Type.INT));
handler(worldDataTrackerHandler(1)); handler(worldDataTrackerHandler(1));
handler(wrapper -> { handler(wrapper -> {
CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0); CompoundTag registry = wrapper.get(Type.NAMED_COMPOUND_TAG, 0);
@ -183,29 +183,29 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, null, registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, null,
Types1_16.META_TYPES.componentType, Types1_16.META_TYPES.optionalComponentType); Types1_16.META_TYPES.componentType, Types1_16.META_TYPES.optionalComponentType);
mapTypes(Entity1_17Types.values(), Entity1_16_2Types.class); mapTypes(EntityTypes1_17.values(), EntityTypes1_16_2.class);
filter().type(Entity1_17Types.AXOLOTL).cancel(17); filter().type(EntityTypes1_17.AXOLOTL).cancel(17);
filter().type(Entity1_17Types.AXOLOTL).cancel(18); filter().type(EntityTypes1_17.AXOLOTL).cancel(18);
filter().type(Entity1_17Types.AXOLOTL).cancel(19); filter().type(EntityTypes1_17.AXOLOTL).cancel(19);
filter().type(Entity1_17Types.GLOW_SQUID).cancel(16); filter().type(EntityTypes1_17.GLOW_SQUID).cancel(16);
filter().type(Entity1_17Types.GOAT).cancel(17); filter().type(EntityTypes1_17.GOAT).cancel(17);
mapEntityTypeWithData(Entity1_17Types.AXOLOTL, Entity1_17Types.TROPICAL_FISH).jsonName(); mapEntityTypeWithData(EntityTypes1_17.AXOLOTL, EntityTypes1_17.TROPICAL_FISH).jsonName();
mapEntityTypeWithData(Entity1_17Types.GOAT, Entity1_17Types.SHEEP).jsonName(); mapEntityTypeWithData(EntityTypes1_17.GOAT, EntityTypes1_17.SHEEP).jsonName();
mapEntityTypeWithData(Entity1_17Types.GLOW_SQUID, Entity1_17Types.SQUID).jsonName(); mapEntityTypeWithData(EntityTypes1_17.GLOW_SQUID, EntityTypes1_17.SQUID).jsonName();
mapEntityTypeWithData(Entity1_17Types.GLOW_ITEM_FRAME, Entity1_17Types.ITEM_FRAME); mapEntityTypeWithData(EntityTypes1_17.GLOW_ITEM_FRAME, EntityTypes1_17.ITEM_FRAME);
filter().type(Entity1_17Types.SHULKER).addIndex(17); // TODO Handle attachment pos? filter().type(EntityTypes1_17.SHULKER).addIndex(17); // TODO Handle attachment pos?
filter().removeIndex(7); // Ticks frozen filter().removeIndex(7); // Ticks frozen
} }
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_17Types.getTypeFromId(typeId); return EntityTypes1_17.getTypeFromId(typeId);
} }
private void reduceExtendedHeight(CompoundTag tag, boolean warn) { private void reduceExtendedHeight(CompoundTag tag, boolean warn) {

Datei anzeigen

@ -25,7 +25,7 @@ import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.packets.BlockIt
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.packets.EntityPackets1_18; import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.packets.EntityPackets1_18;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -132,7 +132,7 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
@Override @Override
public void init(final UserConnection connection) { public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, Entity1_17Types.PLAYER)); addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_17.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -19,7 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.packets;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18; import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -123,6 +123,6 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
@Override @Override
public EntityType typeFromId(final int typeId) { public EntityType typeFromId(final int typeId) {
return Entity1_17Types.getTypeFromId(typeId); return EntityTypes1_17.getTypeFromId(typeId);
} }
} }

Datei anzeigen

@ -29,7 +29,7 @@ import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.storage.Dimensi
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1; import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -276,7 +276,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
@Override @Override
public void init(final UserConnection user) { public void init(final UserConnection user) {
user.put(new DimensionRegistryStorage()); user.put(new DimensionRegistryStorage());
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19Types.PLAYER)); addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_19.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -24,7 +24,7 @@ import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.storage.StoredP
import com.viaversion.viaversion.api.data.ParticleMappings; import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
@ -49,8 +49,8 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
@Override @Override
protected void registerPackets() { protected void registerPackets() {
registerTracker(ClientboundPackets1_19.SPAWN_EXPERIENCE_ORB, Entity1_19Types.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_19.SPAWN_EXPERIENCE_ORB, EntityTypes1_19.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_19.SPAWN_PLAYER, Entity1_19Types.PLAYER); registerTracker(ClientboundPackets1_19.SPAWN_PLAYER, EntityTypes1_19.PLAYER);
registerMetadataRewriter(ClientboundPackets1_19.ENTITY_METADATA, Types1_19.METADATA_LIST, Types1_18.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_19.ENTITY_METADATA, Types1_19.METADATA_LIST, Types1_18.METADATA_LIST);
registerRemoveEntities(ClientboundPackets1_19.REMOVE_ENTITIES); registerRemoveEntities(ClientboundPackets1_19.REMOVE_ENTITIES);
@ -69,7 +69,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
final byte headYaw = wrapper.read(Type.BYTE); final byte headYaw = wrapper.read(Type.BYTE);
int data = wrapper.read(Type.VAR_INT); int data = wrapper.read(Type.VAR_INT);
final EntityType entityType = trackAndMapEntity(wrapper); final EntityType entityType = trackAndMapEntity(wrapper);
if (entityType.isOrHasParent(Entity1_19Types.LIVINGENTITY)) { if (entityType.isOrHasParent(EntityTypes1_19.LIVINGENTITY)) {
wrapper.write(Type.BYTE, headYaw); wrapper.write(Type.BYTE, headYaw);
// Switch pitch and yaw position // Switch pitch and yaw position
@ -80,7 +80,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
wrapper.setPacketType(ClientboundPackets1_18.SPAWN_MOB); wrapper.setPacketType(ClientboundPackets1_18.SPAWN_MOB);
return; return;
} else if (entityType == Entity1_19Types.PAINTING) { } else if (entityType == EntityTypes1_19.PAINTING) {
wrapper.cancel(); wrapper.cancel();
// The entity has been tracked, now we wait for the metadata packet // The entity has been tracked, now we wait for the metadata packet
final int entityId = wrapper.get(Type.VAR_INT, 0); final int entityId = wrapper.get(Type.VAR_INT, 0);
@ -90,7 +90,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
return; return;
} }
if (entityType == Entity1_19Types.FALLING_BLOCK) { if (entityType == EntityTypes1_19.FALLING_BLOCK) {
data = protocol.getMappingData().getNewBlockStateId(data); data = protocol.getMappingData().getNewBlockStateId(data);
} }
wrapper.write(Type.INT, data); wrapper.write(Type.INT, data);
@ -272,12 +272,12 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, Types1_18.META_TYPES.blockStateType, null, null, registerMetaTypeHandler(Types1_18.META_TYPES.itemType, Types1_18.META_TYPES.blockStateType, null, null,
Types1_18.META_TYPES.componentType, Types1_18.META_TYPES.optionalComponentType); Types1_18.META_TYPES.componentType, Types1_18.META_TYPES.optionalComponentType);
filter().filterFamily(Entity1_19Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int data = (int) meta.getValue(); final int data = (int) meta.getValue();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
}); });
filter().type(Entity1_19Types.PAINTING).index(8).handler((event, meta) -> { filter().type(EntityTypes1_19.PAINTING).index(8).handler((event, meta) -> {
event.cancel(); event.cancel();
final StoredEntityData entityData = tracker(event.user()).entityDataIfPresent(event.entityId()); final StoredEntityData entityData = tracker(event.user()).entityDataIfPresent(event.entityId());
@ -298,30 +298,30 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
} }
}); });
filter().type(Entity1_19Types.CAT).index(19).handler((event, meta) -> meta.setMetaType(Types1_18.META_TYPES.varIntType)); filter().type(EntityTypes1_19.CAT).index(19).handler((event, meta) -> meta.setMetaType(Types1_18.META_TYPES.varIntType));
filter().type(Entity1_19Types.FROG).cancel(16); // Age filter().type(EntityTypes1_19.FROG).cancel(16); // Age
filter().type(Entity1_19Types.FROG).cancel(17); // Variant filter().type(EntityTypes1_19.FROG).cancel(17); // Variant
filter().type(Entity1_19Types.FROG).cancel(18); // Tongue target filter().type(EntityTypes1_19.FROG).cancel(18); // Tongue target
filter().type(Entity1_19Types.WARDEN).cancel(16); // Anger filter().type(EntityTypes1_19.WARDEN).cancel(16); // Anger
filter().type(Entity1_19Types.GOAT).cancel(18); filter().type(EntityTypes1_19.GOAT).cancel(18);
filter().type(Entity1_19Types.GOAT).cancel(19); filter().type(EntityTypes1_19.GOAT).cancel(19);
} }
@Override @Override
public void onMappingDataLoaded() { public void onMappingDataLoaded() {
mapTypes(); mapTypes();
mapEntityTypeWithData(Entity1_19Types.FROG, Entity1_19Types.RABBIT).jsonName(); mapEntityTypeWithData(EntityTypes1_19.FROG, EntityTypes1_19.RABBIT).jsonName();
mapEntityTypeWithData(Entity1_19Types.TADPOLE, Entity1_19Types.PUFFERFISH).jsonName(); mapEntityTypeWithData(EntityTypes1_19.TADPOLE, EntityTypes1_19.PUFFERFISH).jsonName();
mapEntityTypeWithData(Entity1_19Types.CHEST_BOAT, Entity1_19Types.BOAT); mapEntityTypeWithData(EntityTypes1_19.CHEST_BOAT, EntityTypes1_19.BOAT);
mapEntityTypeWithData(Entity1_19Types.WARDEN, Entity1_19Types.IRON_GOLEM).jsonName(); mapEntityTypeWithData(EntityTypes1_19.WARDEN, EntityTypes1_19.IRON_GOLEM).jsonName();
mapEntityTypeWithData(Entity1_19Types.ALLAY, Entity1_19Types.VEX).jsonName(); mapEntityTypeWithData(EntityTypes1_19.ALLAY, EntityTypes1_19.VEX).jsonName();
} }
@Override @Override
public EntityType typeFromId(final int typeId) { public EntityType typeFromId(final int typeId) {
return Entity1_19Types.getTypeFromId(typeId); return EntityTypes1_19.getTypeFromId(typeId);
} }
} }

Datei anzeigen

@ -31,7 +31,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.minecraft.ProfileKey;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_3;
import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -351,7 +351,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
public void init(final UserConnection user) { public void init(final UserConnection user) {
user.put(new ChatSessionStorage()); user.put(new ChatSessionStorage());
user.put(new ChatTypeStorage1_19_3()); user.put(new ChatTypeStorage1_19_3());
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19_3Types.PLAYER)); addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_19_3.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -22,7 +22,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.Protocol1_19_
import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.storage.ChatTypeStorage1_19_3; import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.storage.ChatTypeStorage1_19_3;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.minecraft.ProfileKey;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_3;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -60,7 +60,7 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
protected void registerPackets() { protected void registerPackets() {
registerMetadataRewriter(ClientboundPackets1_19_3.ENTITY_METADATA, Types1_19_3.METADATA_LIST, Types1_19.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_19_3.ENTITY_METADATA, Types1_19_3.METADATA_LIST, Types1_19.METADATA_LIST);
registerRemoveEntities(ClientboundPackets1_19_3.REMOVE_ENTITIES); registerRemoveEntities(ClientboundPackets1_19_3.REMOVE_ENTITIES);
registerTrackerWithData1_19(ClientboundPackets1_19_3.SPAWN_ENTITY, Entity1_19_3Types.FALLING_BLOCK); registerTrackerWithData1_19(ClientboundPackets1_19_3.SPAWN_ENTITY, EntityTypes1_19_3.FALLING_BLOCK);
protocol.registerClientbound(ClientboundPackets1_19_3.JOIN_GAME, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_19_3.JOIN_GAME, new PacketHandlers() {
@Override @Override
@ -242,24 +242,24 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
meta.setValue(pose - 1); meta.setValue(pose - 1);
} }
}); });
filter().filterFamily(Entity1_19_3Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19_3.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int data = (int) meta.getValue(); final int data = (int) meta.getValue();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data)); meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
}); });
filter().type(Entity1_19_3Types.CAMEL).cancel(19); // Dashing filter().type(EntityTypes1_19_3.CAMEL).cancel(19); // Dashing
filter().type(Entity1_19_3Types.CAMEL).cancel(20); // Last pose change time filter().type(EntityTypes1_19_3.CAMEL).cancel(20); // Last pose change time
} }
@Override @Override
public void onMappingDataLoaded() { public void onMappingDataLoaded() {
mapTypes(); mapTypes();
mapEntityTypeWithData(Entity1_19_3Types.CAMEL, Entity1_19_3Types.DONKEY).jsonName(); mapEntityTypeWithData(EntityTypes1_19_3.CAMEL, EntityTypes1_19_3.DONKEY).jsonName();
} }
@Override @Override
public EntityType typeFromId(final int typeId) { public EntityType typeFromId(final int typeId) {
return Entity1_19_3Types.getTypeFromId(typeId); return EntityTypes1_19_3.getTypeFromId(typeId);
} }
private static final class PlayerProfileUpdate { private static final class PlayerProfileUpdate {

Datei anzeigen

@ -24,7 +24,7 @@ import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets.BlockItemPackets1_19_4; import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets.BlockItemPackets1_19_4;
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets.EntityPackets1_19_4; import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets.EntityPackets1_19_4;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
@ -117,7 +117,7 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
@Override @Override
public void init(final UserConnection user) { public void init(final UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19_4Types.PLAYER)); addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_19_4.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets;
import com.viaversion.viabackwards.api.entities.storage.EntityData; import com.viaversion.viabackwards.api.entities.storage.EntityData;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_3To1_19_4; import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_3To1_19_4;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -40,7 +40,7 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
@Override @Override
public void registerPackets() { public void registerPackets() {
registerTrackerWithData1_19(ClientboundPackets1_19_4.SPAWN_ENTITY, Entity1_19_4Types.FALLING_BLOCK); registerTrackerWithData1_19(ClientboundPackets1_19_4.SPAWN_ENTITY, EntityTypes1_19_4.FALLING_BLOCK);
registerRemoveEntities(ClientboundPackets1_19_4.REMOVE_ENTITIES); registerRemoveEntities(ClientboundPackets1_19_4.REMOVE_ENTITIES);
registerMetadataRewriter(ClientboundPackets1_19_4.ENTITY_METADATA, Types1_19_4.METADATA_LIST, Types1_19_3.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_19_4.ENTITY_METADATA, Types1_19_4.METADATA_LIST, Types1_19_3.METADATA_LIST);
@ -142,19 +142,19 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, null, Types1_19_3.META_TYPES.particleType, registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, null, Types1_19_3.META_TYPES.particleType,
Types1_19_3.META_TYPES.componentType, Types1_19_3.META_TYPES.optionalComponentType); Types1_19_3.META_TYPES.componentType, Types1_19_3.META_TYPES.optionalComponentType);
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value(); final int blockState = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
}); });
filter().filterFamily(Entity1_19_4Types.BOAT).index(11).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19_4.BOAT).index(11).handler((event, meta) -> {
final int boatType = meta.value(); final int boatType = meta.value();
if (boatType > 4) { // Cherry if (boatType > 4) { // Cherry
meta.setValue(boatType - 1); meta.setValue(boatType - 1);
} }
}); });
filter().type(Entity1_19_4Types.TEXT_DISPLAY).index(22).handler(((event, meta) -> { filter().type(EntityTypes1_19_4.TEXT_DISPLAY).index(22).handler(((event, meta) -> {
// Send as custom display name // Send as custom display name
event.setIndex(2); event.setIndex(2);
meta.setMetaType(Types1_19_3.META_TYPES.optionalComponentType); meta.setMetaType(Types1_19_3.META_TYPES.optionalComponentType);
@ -163,7 +163,7 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
final JsonElement element = meta.value(); final JsonElement element = meta.value();
protocol.getTranslatableRewriter().processText(element); protocol.getTranslatableRewriter().processText(element);
})); }));
filter().filterFamily(Entity1_19_4Types.DISPLAY).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19_4.DISPLAY).handler((event, meta) -> {
// TODO Maybe spawn an extra entity to ride the armor stand for blocks and items // TODO Maybe spawn an extra entity to ride the armor stand for blocks and items
// Remove a large heap of display metadata // Remove a large heap of display metadata
if (event.index() > 7) { if (event.index() > 7) {
@ -171,14 +171,14 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
} }
}); });
filter().type(Entity1_19_4Types.INTERACTION).removeIndex(8); // Width filter().type(EntityTypes1_19_4.INTERACTION).removeIndex(8); // Width
filter().type(Entity1_19_4Types.INTERACTION).removeIndex(9); // Height filter().type(EntityTypes1_19_4.INTERACTION).removeIndex(9); // Height
filter().type(Entity1_19_4Types.INTERACTION).removeIndex(10); // Response filter().type(EntityTypes1_19_4.INTERACTION).removeIndex(10); // Response
filter().type(Entity1_19_4Types.SNIFFER).removeIndex(17); // State filter().type(EntityTypes1_19_4.SNIFFER).removeIndex(17); // State
filter().type(Entity1_19_4Types.SNIFFER).removeIndex(18); // Drop seed at tick filter().type(EntityTypes1_19_4.SNIFFER).removeIndex(18); // Drop seed at tick
filter().filterFamily(Entity1_19_4Types.ABSTRACT_HORSE).addIndex(18); // Owner UUID filter().filterFamily(EntityTypes1_19_4.ABSTRACT_HORSE).addIndex(18); // Owner UUID
} }
@Override @Override
@ -190,17 +190,17 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
storage.add(new Metadata(5, Types1_19_3.META_TYPES.booleanType, true)); // No gravity storage.add(new Metadata(5, Types1_19_3.META_TYPES.booleanType, true)); // No gravity
storage.add(new Metadata(15, Types1_19_3.META_TYPES.byteType, (byte) (0x01 | 0x10))); // Small marker storage.add(new Metadata(15, Types1_19_3.META_TYPES.byteType, (byte) (0x01 | 0x10))); // Small marker
}; };
mapEntityTypeWithData(Entity1_19_4Types.TEXT_DISPLAY, Entity1_19_4Types.ARMOR_STAND).spawnMetadata(displayMetaCreator); mapEntityTypeWithData(EntityTypes1_19_4.TEXT_DISPLAY, EntityTypes1_19_4.ARMOR_STAND).spawnMetadata(displayMetaCreator);
mapEntityTypeWithData(Entity1_19_4Types.ITEM_DISPLAY, Entity1_19_4Types.ARMOR_STAND).spawnMetadata(displayMetaCreator); mapEntityTypeWithData(EntityTypes1_19_4.ITEM_DISPLAY, EntityTypes1_19_4.ARMOR_STAND).spawnMetadata(displayMetaCreator);
mapEntityTypeWithData(Entity1_19_4Types.BLOCK_DISPLAY, Entity1_19_4Types.ARMOR_STAND).spawnMetadata(displayMetaCreator); mapEntityTypeWithData(EntityTypes1_19_4.BLOCK_DISPLAY, EntityTypes1_19_4.ARMOR_STAND).spawnMetadata(displayMetaCreator);
mapEntityTypeWithData(Entity1_19_4Types.INTERACTION, Entity1_19_4Types.ARMOR_STAND).spawnMetadata(displayMetaCreator); // Not much we can do about this one mapEntityTypeWithData(EntityTypes1_19_4.INTERACTION, EntityTypes1_19_4.ARMOR_STAND).spawnMetadata(displayMetaCreator); // Not much we can do about this one
mapEntityTypeWithData(Entity1_19_4Types.SNIFFER, Entity1_19_4Types.RAVAGER).jsonName(); mapEntityTypeWithData(EntityTypes1_19_4.SNIFFER, EntityTypes1_19_4.RAVAGER).jsonName();
} }
@Override @Override
public EntityType typeFromId(final int type) { public EntityType typeFromId(final int type) {
return Entity1_19_4Types.getTypeFromId(type); return EntityTypes1_19_4.getTypeFromId(type);
} }
} }

Datei anzeigen

@ -25,7 +25,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.packets.BlockIt
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.packets.EntityPackets1_20; import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.packets.EntityPackets1_20;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.RegistryType; import com.viaversion.viaversion.api.minecraft.RegistryType;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4; import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
@ -93,7 +93,7 @@ public final class Protocol1_19_4To1_20 extends BackwardsProtocol<ClientboundPac
@Override @Override
public void init(final UserConnection user) { public void init(final UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19_4Types.PLAYER)); addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_19_4.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -21,7 +21,7 @@ import com.google.common.collect.Sets;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.Protocol1_19_4To1_20; import com.viaversion.viabackwards.protocol.protocol1_19_4to1_20.Protocol1_19_4To1_20;
import com.viaversion.viaversion.api.minecraft.Quaternion; import com.viaversion.viaversion.api.minecraft.Quaternion;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -49,7 +49,7 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
@Override @Override
public void registerPackets() { public void registerPackets() {
registerTrackerWithData1_19(ClientboundPackets1_19_4.SPAWN_ENTITY, Entity1_19_4Types.FALLING_BLOCK); registerTrackerWithData1_19(ClientboundPackets1_19_4.SPAWN_ENTITY, EntityTypes1_19_4.FALLING_BLOCK);
registerMetadataRewriter(ClientboundPackets1_19_4.ENTITY_METADATA, Types1_20.METADATA_LIST, Types1_19_4.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_19_4.ENTITY_METADATA, Types1_20.METADATA_LIST, Types1_19_4.METADATA_LIST);
registerRemoveEntities(ClientboundPackets1_19_4.REMOVE_ENTITIES); registerRemoveEntities(ClientboundPackets1_19_4.REMOVE_ENTITIES);
@ -126,13 +126,13 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType, Types1_19_4.META_TYPES.optionalBlockStateType, registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType, Types1_19_4.META_TYPES.optionalBlockStateType,
Types1_19_4.META_TYPES.particleType, Types1_19_4.META_TYPES.componentType, Types1_19_4.META_TYPES.optionalComponentType); Types1_19_4.META_TYPES.particleType, Types1_19_4.META_TYPES.componentType, Types1_19_4.META_TYPES.optionalComponentType);
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value(); final int blockState = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
}); });
// Rotate item display by 180 degrees around the Y axis // Rotate item display by 180 degrees around the Y axis
filter().filterFamily(Entity1_19_4Types.ITEM_DISPLAY).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19_4.ITEM_DISPLAY).handler((event, meta) -> {
if (event.trackedEntity().hasSentMetadata() || event.hasExtraMeta()) { if (event.trackedEntity().hasSentMetadata() || event.hasExtraMeta()) {
return; return;
} }
@ -141,7 +141,7 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
event.createExtraMeta(new Metadata(12, Types1_19_4.META_TYPES.quaternionType, Y_FLIPPED_ROTATION)); event.createExtraMeta(new Metadata(12, Types1_19_4.META_TYPES.quaternionType, Y_FLIPPED_ROTATION));
} }
}); });
filter().filterFamily(Entity1_19_4Types.ITEM_DISPLAY).index(12).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19_4.ITEM_DISPLAY).index(12).handler((event, meta) -> {
final Quaternion quaternion = meta.value(); final Quaternion quaternion = meta.value();
meta.setValue(rotateY180(quaternion)); meta.setValue(rotateY180(quaternion));
}); });
@ -149,7 +149,7 @@ public final class EntityPackets1_20 extends EntityRewriter<ClientboundPackets1_
@Override @Override
public EntityType typeFromId(final int type) { public EntityType typeFromId(final int type) {
return Entity1_19_4Types.getTypeFromId(type); return EntityTypes1_19_4.getTypeFromId(type);
} }
private Quaternion rotateY180(final Quaternion quaternion) { private Quaternion rotateY180(final Quaternion quaternion) {

Datei anzeigen

@ -29,7 +29,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.storage.Receive
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature; import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.minecraft.ProfileKey;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -340,7 +340,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
public void init(final UserConnection user) { public void init(final UserConnection user) {
user.put(new ChatRegistryStorage1_19_1()); user.put(new ChatRegistryStorage1_19_1());
user.put(new ReceivedMessagesStorage()); user.put(new ReceivedMessagesStorage());
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19Types.PLAYER)); addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_19.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -19,7 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.packets;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1; import com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.Protocol1_19To1_19_1;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.type.types.version.Types1_19; import com.viaversion.viaversion.api.type.types.version.Types1_19;
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1; import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
@ -39,13 +39,13 @@ public final class EntityPackets1_19_1 extends EntityRewriter<ClientboundPackets
@Override @Override
public void registerRewrites() { public void registerRewrites() {
filter().type(Entity1_19Types.ALLAY).cancel(16); // Dancing filter().type(EntityTypes1_19.ALLAY).cancel(16); // Dancing
filter().type(Entity1_19Types.ALLAY).cancel(17); // Can duplicate filter().type(EntityTypes1_19.ALLAY).cancel(17); // Can duplicate
} }
@Override @Override
public EntityType typeFromId(final int typeId) { public EntityType typeFromId(final int typeId) {
return Entity1_19Types.getTypeFromId(typeId); return EntityTypes1_19.getTypeFromId(typeId);
} }
} }

Datei anzeigen

@ -21,9 +21,9 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappings; import com.viaversion.viabackwards.api.data.BackwardsMappings;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter; import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter.EntityPacketRewriter1_20_3; import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter.EntityPacketRewriter1_20_3;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter.ItemPacketRewriter1_20_3; import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter.BlockItemPacketRewriter1_20_3;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -38,16 +38,17 @@ import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.Clientbou
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundConfigurationPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ServerboundPackets1_20_3;
import java.util.BitSet; import java.util.BitSet;
public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol<ClientboundPackets1_20_2, ClientboundPackets1_20_2, ServerboundPackets1_20_2, ServerboundPackets1_20_2> { public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol<ClientboundPackets1_20_2, ClientboundPackets1_20_2, ServerboundPackets1_20_3, ServerboundPackets1_20_2> {
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.20.3", "1.20.2", Protocol1_20_3To1_20_2.class); public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.20.3", "1.20.2", Protocol1_20_3To1_20_2.class);
private final EntityPacketRewriter1_20_3 entityRewriter = new EntityPacketRewriter1_20_3(this); private final EntityPacketRewriter1_20_3 entityRewriter = new EntityPacketRewriter1_20_3(this);
private final ItemPacketRewriter1_20_3 itemRewriter = new ItemPacketRewriter1_20_3(this); private final BlockItemPacketRewriter1_20_3 itemRewriter = new BlockItemPacketRewriter1_20_3(this);
public Protocol1_20_2To1_20_3() { public Protocol1_20_2To1_20_3() {
super(ClientboundPackets1_20_2.class, ClientboundPackets1_20_2.class, ServerboundPackets1_20_2.class, ServerboundPackets1_20_2.class); super(ClientboundPackets1_20_2.class, ClientboundPackets1_20_2.class, ServerboundPackets1_20_3.class, ServerboundPackets1_20_2.class);
} }
@Override @Override
@ -75,7 +76,7 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol<ClientboundP
if (wrapper.passthrough(Type.BOOLEAN)) { if (wrapper.passthrough(Type.BOOLEAN)) {
convertComponent(wrapper); // Title convertComponent(wrapper); // Title
convertComponent(wrapper); // Description convertComponent(wrapper); // Description
wrapper.passthrough(Type.ITEM1_20_2); // Icon itemRewriter.handleItemToClient(wrapper.passthrough(Type.ITEM1_20_2)); // Icon
wrapper.passthrough(Type.VAR_INT); // Frame type wrapper.passthrough(Type.VAR_INT); // Frame type
final int flags = wrapper.passthrough(Type.INT); final int flags = wrapper.passthrough(Type.INT);
if ((flags & 1) != 0) { if ((flags & 1) != 0) {
@ -185,13 +186,19 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol<ClientboundP
registerClientbound(ClientboundPackets1_20_2.TITLE_SUBTITLE, this::convertComponent); registerClientbound(ClientboundPackets1_20_2.TITLE_SUBTITLE, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.DISGUISED_CHAT, this::convertComponent); registerClientbound(ClientboundPackets1_20_2.DISGUISED_CHAT, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.SYSTEM_CHAT, this::convertComponent); registerClientbound(ClientboundPackets1_20_2.SYSTEM_CHAT, this::convertComponent);
registerClientbound(ClientboundPackets1_20_2.OPEN_WINDOW, new PacketHandlers() { registerClientbound(ClientboundPackets1_20_2.OPEN_WINDOW, wrapper -> {
@Override wrapper.passthrough(Type.VAR_INT); // Container id
public void register() {
map(Type.VAR_INT); // Id final int containerTypeId = wrapper.read(Type.VAR_INT);
map(Type.VAR_INT); // Window Type final int mappedContainerTypeId = MAPPINGS.getMenuMappings().getNewId(containerTypeId);
handler(wrapper -> convertComponent(wrapper)); if (mappedContainerTypeId == -1) {
wrapper.cancel();
return;
} }
wrapper.write(Type.VAR_INT, mappedContainerTypeId);
convertComponent(wrapper);
}); });
registerClientbound(ClientboundPackets1_20_2.TAB_LIST, wrapper -> { registerClientbound(ClientboundPackets1_20_2.TAB_LIST, wrapper -> {
convertComponent(wrapper); convertComponent(wrapper);
@ -261,7 +268,7 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol<ClientboundP
@Override @Override
public void init(final UserConnection connection) { public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, Entity1_19_4Types.PLAYER)); addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_19_4.PLAYER));
} }
@Override @Override
@ -280,7 +287,7 @@ public final class Protocol1_20_2To1_20_3 extends BackwardsProtocol<ClientboundP
} }
@Override @Override
public ItemPacketRewriter1_20_3 getItemRewriter() { public BlockItemPacketRewriter1_20_3 getItemRewriter() {
return itemRewriter; return itemRewriter;
} }

Datei anzeigen

@ -0,0 +1,57 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2023 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter;
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2;
import com.viaversion.viaversion.rewriter.BlockRewriter;
public final class BlockItemPacketRewriter1_20_3 extends ItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_20_2, Protocol1_20_2To1_20_3> {
public BlockItemPacketRewriter1_20_3(final Protocol1_20_2To1_20_3 protocol) {
super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY);
}
@Override
public void registerPackets() {
final BlockRewriter<ClientboundPackets1_20_2> blockRewriter = BlockRewriter.for1_20_2(protocol);
blockRewriter.registerBlockAction(ClientboundPackets1_20_2.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_20_2.BLOCK_CHANGE);
blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_2.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_20_2.EFFECT, 1010, 2001);
blockRewriter.registerChunkData1_19(ClientboundPackets1_20_2.CHUNK_DATA, ChunkType1_20_2::new);
blockRewriter.registerBlockEntityData(ClientboundPackets1_20_2.BLOCK_ENTITY_DATA);
registerSetCooldown(ClientboundPackets1_20_2.COOLDOWN);
registerWindowItems1_17_1(ClientboundPackets1_20_2.WINDOW_ITEMS);
registerSetSlot1_17_1(ClientboundPackets1_20_2.SET_SLOT);
registerEntityEquipmentArray(ClientboundPackets1_20_2.ENTITY_EQUIPMENT);
registerClickWindow1_17_1(ServerboundPackets1_20_2.CLICK_WINDOW);
registerTradeList1_19(ClientboundPackets1_20_2.TRADE_LIST);
registerCreativeInvAction(ServerboundPackets1_20_2.CREATIVE_INVENTORY_ACTION);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_2.WINDOW_PROPERTY);
registerSpawnParticle1_19(ClientboundPackets1_20_2.SPAWN_PARTICLE);
new RecipeRewriter1_20_2<>(protocol).register(ClientboundPackets1_20_2.DECLARE_RECIPES);
}
}

Datei anzeigen

@ -19,11 +19,15 @@ package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3; import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_20_2; import com.viaversion.viaversion.api.type.types.version.Types1_20_2;
import com.viaversion.viaversion.api.type.types.version.Types1_20_3; import com.viaversion.viaversion.api.type.types.version.Types1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundConfigurationPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.Protocol1_20_3To1_20_2;
@ -38,6 +42,42 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter<Clientbound
registerSpawnTracker(ClientboundPackets1_20_2.SPAWN_ENTITY); registerSpawnTracker(ClientboundPackets1_20_2.SPAWN_ENTITY);
registerMetadataRewriter(ClientboundPackets1_20_2.ENTITY_METADATA, Types1_20_3.METADATA_LIST, Types1_20_2.METADATA_LIST); registerMetadataRewriter(ClientboundPackets1_20_2.ENTITY_METADATA, Types1_20_3.METADATA_LIST, Types1_20_2.METADATA_LIST);
registerRemoveEntities(ClientboundPackets1_20_2.REMOVE_ENTITIES); registerRemoveEntities(ClientboundPackets1_20_2.REMOVE_ENTITIES);
protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.REGISTRY_DATA, new PacketHandlers() {
@Override
protected void register() {
map(Type.COMPOUND_TAG); // Registry data
handler(configurationDimensionDataHandler());
handler(configurationBiomeSizeTracker());
}
});
protocol.registerClientbound(ClientboundPackets1_20_2.JOIN_GAME, new PacketHandlers() {
@Override
public void register() {
map(Type.INT); // Entity id
map(Type.BOOLEAN); // Hardcore
map(Type.STRING_ARRAY); // World List
map(Type.VAR_INT); // Max players
map(Type.VAR_INT); // View distance
map(Type.VAR_INT); // Simulation distance
map(Type.BOOLEAN); // Reduced debug info
map(Type.BOOLEAN); // Show death screen
map(Type.BOOLEAN); // Limited crafting
map(Type.STRING); // Dimension key
map(Type.STRING); // World
handler(worldDataTrackerHandlerByKey());
}
});
protocol.registerClientbound(ClientboundPackets1_20_2.RESPAWN, new PacketHandlers() {
@Override
public void register() {
map(Type.STRING); // Dimension
map(Type.STRING); // World
handler(worldDataTrackerHandlerByKey());
}
});
} }
@Override @Override
@ -53,11 +93,25 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter<Clientbound
} }
}); });
registerMetaTypeHandler(null, null, null, Types1_20_2.META_TYPES.particleType); registerMetaTypeHandler(
Types1_20_2.META_TYPES.itemType,
Types1_20_2.META_TYPES.blockStateType,
Types1_20_2.META_TYPES.optionalBlockStateType,
Types1_20_2.META_TYPES.particleType,
Types1_20_2.META_TYPES.componentType,
Types1_20_2.META_TYPES.optionalComponentType
);
filter().filterFamily(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
});
filter().type(EntityTypes1_19_4.TNT).removeIndex(9); // Block state
} }
@Override @Override
public EntityType typeFromId(final int type) { public EntityType typeFromId(final int type) {
return Entity1_19_4Types.getTypeFromId(type); return EntityTypes1_19_4.getTypeFromId(type);
} }
} }

Datei anzeigen

@ -1,36 +0,0 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2023 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.rewriter;
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.Protocol1_20_2To1_20_3;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
public final class ItemPacketRewriter1_20_3 extends ItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_20_2, Protocol1_20_2To1_20_3> {
public ItemPacketRewriter1_20_3(final Protocol1_20_2To1_20_3 protocol) {
super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_VAR_INT_ARRAY);
}
@Override
public void registerPackets() {
registerSpawnParticle1_19(ClientboundPackets1_20_2.SPAWN_PARTICLE);
}
}

Datei anzeigen

@ -24,7 +24,7 @@ import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.rewriter.BlockI
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.rewriter.EntityPacketRewriter1_20_2; import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.rewriter.EntityPacketRewriter1_20_2;
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.storage.ConfigurationPacketStorage; import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.storage.ConfigurationPacketStorage;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.protocol.packet.Direction; import com.viaversion.viaversion.api.protocol.packet.Direction;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.State;
@ -191,7 +191,7 @@ public final class Protocol1_20To1_20_2 extends BackwardsProtocol<ClientboundPac
@Override @Override
public void init(final UserConnection connection) { public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, Entity1_19_4Types.PLAYER)); addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_19_4.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -49,7 +49,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_19_4, Protocol1_20To1_20_2> { public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_19_4, Protocol1_20To1_20_2> {
public BlockItemPacketRewriter1_20_2(final Protocol1_20To1_20_2 protocol) { public BlockItemPacketRewriter1_20_2(final Protocol1_20To1_20_2 protocol) {
super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_VAR_INT_ARRAY); super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY);
} }
@Override @Override
@ -128,7 +128,7 @@ public final class BlockItemPacketRewriter1_20_2 extends ItemRewriter<Clientboun
map(Type.UNSIGNED_BYTE); // Window id map(Type.UNSIGNED_BYTE); // Window id
map(Type.VAR_INT); // State id map(Type.VAR_INT); // State id
handler(wrapper -> { handler(wrapper -> {
final Item[] items = wrapper.read(Type.ITEM1_20_2_VAR_INT_ARRAY); final Item[] items = wrapper.read(Type.ITEM1_20_2_ARRAY);
for (final Item item : items) { for (final Item item : items) {
handleItemToClient(item); handleItemToClient(item);
} }

Datei anzeigen

@ -21,7 +21,7 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2; import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.Protocol1_20To1_20_2;
import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.storage.ConfigurationPacketStorage; import com.viaversion.viabackwards.protocol.protocol1_20to1_20_2.storage.ConfigurationPacketStorage;
import com.viaversion.viaversion.api.minecraft.GlobalPosition; import com.viaversion.viaversion.api.minecraft.GlobalPosition;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -53,10 +53,10 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
final int entityType = wrapper.read(Type.VAR_INT); final int entityType = wrapper.read(Type.VAR_INT);
tracker(wrapper.user()).addEntity(entityId, typeFromId(entityType)); tracker(wrapper.user()).addEntity(entityId, typeFromId(entityType));
if (entityType != Entity1_19_4Types.PLAYER.getId()) { if (entityType != EntityTypes1_19_4.PLAYER.getId()) {
wrapper.write(Type.VAR_INT, entityType); wrapper.write(Type.VAR_INT, entityType);
if (entityType == Entity1_19_4Types.FALLING_BLOCK.getId()) { if (entityType == EntityTypes1_19_4.FALLING_BLOCK.getId()) {
wrapper.passthrough(Type.DOUBLE); // X wrapper.passthrough(Type.DOUBLE); // X
wrapper.passthrough(Type.DOUBLE); // Y wrapper.passthrough(Type.DOUBLE); // Y
wrapper.passthrough(Type.DOUBLE); // Z wrapper.passthrough(Type.DOUBLE); // Z
@ -198,9 +198,9 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
filter().handler((event, meta) -> meta.setMetaType(Types1_20.META_TYPES.byId(meta.metaType().typeId()))); filter().handler((event, meta) -> meta.setMetaType(Types1_20.META_TYPES.byId(meta.metaType().typeId())));
registerMetaTypeHandler(Types1_20.META_TYPES.itemType, Types1_20.META_TYPES.blockStateType, Types1_20.META_TYPES.optionalBlockStateType, Types1_20.META_TYPES.particleType, null, null); registerMetaTypeHandler(Types1_20.META_TYPES.itemType, Types1_20.META_TYPES.blockStateType, Types1_20.META_TYPES.optionalBlockStateType, Types1_20.META_TYPES.particleType, null, null);
filter().filterFamily(Entity1_19_4Types.DISPLAY).removeIndex(10); filter().filterFamily(EntityTypes1_19_4.DISPLAY).removeIndex(10);
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value(); final int blockState = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
}); });
@ -208,6 +208,6 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
@Override @Override
public EntityType typeFromId(final int type) { public EntityType typeFromId(final int type) {
return Entity1_19_4Types.getTypeFromId(type); return EntityTypes1_19_4.getTypeFromId(type);
} }
} }

Datei anzeigen

@ -24,7 +24,7 @@ import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets1_10; import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets.BlockItemPackets1_10;
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPackets1_10; import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPackets1_10;
import com.viaversion.viaversion.api.connection.UserConnection; 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.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
@ -84,7 +84,7 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9
registerServerbound(ServerboundPackets1_9_3.RESOURCE_PACK_STATUS, new PacketHandlers() { registerServerbound(ServerboundPackets1_9_3.RESOURCE_PACK_STATUS, new PacketHandlers() {
@Override @Override
public void register() { public void register() {
map(Type.STRING, Type.NOTHING); // 0 - Hash read(Type.STRING); // 0 - Hash
map(Type.VAR_INT); // 1 - Result map(Type.VAR_INT); // 1 - Result
} }
}); });
@ -96,7 +96,7 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9
user.put(new ClientWorld(user)); user.put(new ClientWorld(user));
} }
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_10Types.EntityType.PLAYER)); user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_10.EntityType.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -39,7 +39,7 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
@Override @Override
protected void registerPackets() { protected void registerPackets() {
registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM); registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY); registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM1_8_ARRAY);
// Entity Equipment Packet // Entity Equipment Packet
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM); registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);

Datei anzeigen

@ -23,9 +23,9 @@ import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter; import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10; import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
import com.viaversion.viabackwards.utils.Block; import com.viaversion.viabackwards.utils.Block;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_10;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_11;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_12;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
@ -59,12 +59,12 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
// Track Entity // Track Entity
handler(getObjectTrackerHandler()); handler(getObjectTrackerHandler());
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null))); handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null)));
// Handle FallingBlock blocks // Handle FallingBlock blocks
handler(wrapper -> { handler(wrapper -> {
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0)); Optional<EntityTypes1_12.ObjectType> type = EntityTypes1_12.ObjectType.findById(wrapper.get(Type.BYTE, 0));
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) { if (type.isPresent() && type.get() == EntityTypes1_12.ObjectType.FALLING_BLOCK) {
int objectData = wrapper.get(Type.INT, 0); int objectData = wrapper.get(Type.INT, 0);
int objType = objectData & 4095; int objType = objectData & 4095;
int data = objectData >> 12 & 15; int data = objectData >> 12 & 15;
@ -79,8 +79,8 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}); });
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_10Types.EntityType.EXPERIENCE_ORB); registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, EntityTypes1_10.EntityType.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_10Types.EntityType.WEATHER); registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, EntityTypes1_10.EntityType.WEATHER);
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
@Override @Override
@ -122,8 +122,8 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
} }
}); });
registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, Entity1_10Types.EntityType.PAINTING); registerTracker(ClientboundPackets1_9_3.SPAWN_PAINTING, EntityTypes1_10.EntityType.PAINTING);
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_10Types.EntityType.PLAYER); registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, EntityTypes1_10.EntityType.PLAYER);
registerRespawn(ClientboundPackets1_9_3.RESPAWN); registerRespawn(ClientboundPackets1_9_3.RESPAWN);
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() {
@ -138,7 +138,7 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
map(Type.BYTE); // 6 - Pitch map(Type.BYTE); // 6 - Pitch
map(Types1_9.METADATA_LIST); // 7 - Metadata list map(Types1_9.METADATA_LIST); // 7 - Metadata list
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER)); handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, EntityTypes1_11.EntityType.PLAYER));
} }
}); });
@ -148,10 +148,10 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
mapEntityTypeWithData(Entity1_10Types.EntityType.POLAR_BEAR, Entity1_10Types.EntityType.SHEEP).plainName(); mapEntityTypeWithData(EntityTypes1_10.EntityType.POLAR_BEAR, EntityTypes1_10.EntityType.SHEEP).plainName();
// Change the sheep color when the polar bear is standing up (index 13 -> Standing up) // Change the sheep color when the polar bear is standing up (index 13 -> Standing up)
filter().type(Entity1_10Types.EntityType.POLAR_BEAR).index(13).handler((event, meta) -> { filter().type(EntityTypes1_10.EntityType.POLAR_BEAR).index(13).handler((event, meta) -> {
boolean b = (boolean) meta.getValue(); boolean b = (boolean) meta.getValue();
meta.setTypeAndValue(MetaType1_9.Byte, b ? (byte) (14 & 0x0F) : (byte) (0)); meta.setTypeAndValue(MetaType1_9.Byte, b ? (byte) (14 & 0x0F) : (byte) (0));
@ -159,14 +159,14 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
// Handle husk (index 13 -> Zombie Type) // Handle husk (index 13 -> Zombie Type)
filter().type(Entity1_10Types.EntityType.ZOMBIE).index(13).handler((event, meta) -> { filter().type(EntityTypes1_10.EntityType.ZOMBIE).index(13).handler((event, meta) -> {
if ((int) meta.getValue() == 6) { // Is type Husk if ((int) meta.getValue() == 6) { // Is type Husk
meta.setValue(0); meta.setValue(0);
} }
}); });
// Handle Stray (index 12 -> Skeleton Type) // Handle Stray (index 12 -> Skeleton Type)
filter().type(Entity1_10Types.EntityType.SKELETON).index(12).handler((event, meta) -> { filter().type(EntityTypes1_10.EntityType.SKELETON).index(12).handler((event, meta) -> {
if ((int) meta.getValue() == 2) { if ((int) meta.getValue() == 2) {
meta.setValue(0); // Change to default skeleton meta.setValue(0); // Change to default skeleton
} }
@ -178,11 +178,11 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
@Override @Override
public EntityType typeFromId(int typeId) { public EntityType typeFromId(int typeId) {
return Entity1_10Types.getTypeFromId(typeId, false); return EntityTypes1_10.getTypeFromId(typeId, false);
} }
@Override @Override
protected EntityType getObjectTypeFromId(int typeId) { protected EntityType getObjectTypeFromId(int typeId) {
return Entity1_10Types.getTypeFromId(typeId, true); return EntityTypes1_10.getTypeFromId(typeId, true);
} }
} }

Datei anzeigen

@ -1,4 +1,4 @@
projectVersion=4.9.0-23w41a-SNAPSHOT projectVersion=4.9.0-23w42a-SNAPSHOT
# Smile emoji # Smile emoji
mcVersions=1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10 mcVersions=1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10

Datei anzeigen

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions] [versions]
# ViaVersion # ViaVersion
viaver = "4.9.0-23w41a-SNAPSHOT" viaver = "4.9.0-23w42a-SNAPSHOT"
# Common provided # Common provided
netty = "4.0.20.Final" netty = "4.0.20.Final"

Datei anzeigen

@ -1,5 +1,5 @@
/* /*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2023 ViaVersion and contributors * Copyright (C) 2023 ViaVersion and contributors
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -24,7 +24,7 @@ import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.template.protocol.rewriter.BlockItemPacketRewriter1_99; import com.viaversion.viabackwards.template.protocol.rewriter.BlockItemPacketRewriter1_99;
import com.viaversion.viabackwards.template.protocol.rewriter.EntityPacketRewriter1_99; import com.viaversion.viabackwards.template.protocol.rewriter.EntityPacketRewriter1_99;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.data.entity.EntityTrackerBase;
@ -45,7 +45,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
// ServerboundPackets1_20_2 // ServerboundPackets1_20_2
// ClientboundConfigurationPackets1_20_2 // ClientboundConfigurationPackets1_20_2
// ServerboundConfigurationPackets1_20_2 // ServerboundConfigurationPackets1_20_2
// Entity1_19_4Types (UNMAPPED type) // EntityTypes1_19_4 (UNMAPPED type)
// 1.99, 1.98 // 1.99, 1.98
public final class Protocol1_98To_99 extends BackwardsProtocol<ClientboundPackets1_20_2, ClientboundPackets1_20_2, ServerboundPackets1_20_2, ServerboundPackets1_20_2> { public final class Protocol1_98To_99 extends BackwardsProtocol<ClientboundPackets1_20_2, ClientboundPackets1_20_2, ServerboundPackets1_20_2, ServerboundPackets1_20_2> {
@ -89,7 +89,7 @@ public final class Protocol1_98To_99 extends BackwardsProtocol<ClientboundPacket
@Override @Override
public void init(final UserConnection user) { public void init(final UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19_4Types.PLAYER)); addEntityTracker(user, new EntityTrackerBase(user, EntityTypes1_19_4.PLAYER));
} }
@Override @Override

Datei anzeigen

@ -1,5 +1,5 @@
/* /*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2023 ViaVersion and contributors * Copyright (C) 2023 ViaVersion and contributors
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -20,31 +20,32 @@ package com.viaversion.viabackwards.template.protocol.rewriter;
import com.viaversion.viabackwards.api.rewriters.ItemRewriter; import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99; import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ClientboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.packet.ServerboundPackets1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2; import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter.RecipeRewriter1_20_2;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.type.ChunkType1_20_2;
import com.viaversion.viaversion.rewriter.BlockRewriter; import com.viaversion.viaversion.rewriter.BlockRewriter;
// To replace if needed: // To replace if needed:
// Chunk1_18Type // ChunkType1_20_2
// RecipeRewriter1_20_2 // RecipeRewriter1_20_2
public final class BlockItemPacketRewriter1_99 extends ItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_20_2, Protocol1_98To_99> { public final class BlockItemPacketRewriter1_99 extends ItemRewriter<ClientboundPackets1_20_2, ServerboundPackets1_20_2, Protocol1_98To_99> {
public BlockItemPacketRewriter1_99(final Protocol1_98To_99 protocol) { public BlockItemPacketRewriter1_99(final Protocol1_98To_99 protocol) {
super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_VAR_INT_ARRAY); super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY);
} }
@Override @Override
public void registerPackets() { public void registerPackets() {
final BlockRewriter<ClientboundPackets1_20_2> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); final BlockRewriter<ClientboundPackets1_20_2> blockRewriter = BlockRewriter.for1_20_2(protocol);
blockRewriter.registerBlockAction(ClientboundPackets1_20_2.BLOCK_ACTION); blockRewriter.registerBlockAction(ClientboundPackets1_20_2.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_20_2.BLOCK_CHANGE); blockRewriter.registerBlockChange(ClientboundPackets1_20_2.BLOCK_CHANGE);
blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_2.MULTI_BLOCK_CHANGE); blockRewriter.registerVarLongMultiBlockChange1_20(ClientboundPackets1_20_2.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_20_2.EFFECT, 1010, 2001); blockRewriter.registerEffect(ClientboundPackets1_20_2.EFFECT, 1010, 2001);
blockRewriter.registerChunkData1_19(ClientboundPackets1_20_2.CHUNK_DATA, Chunk1_18Type::new); blockRewriter.registerChunkData1_19(ClientboundPackets1_20_2.CHUNK_DATA, ChunkType1_20_2::new);
blockRewriter.registerBlockEntityData(ClientboundPackets1_20_2.BLOCK_ENTITY_DATA); blockRewriter.registerBlockEntityData(ClientboundPackets1_20_2.BLOCK_ENTITY_DATA);
// registerOpenWindow(ClientboundPackets1_20_2.OPEN_WINDOW);
registerSetCooldown(ClientboundPackets1_20_2.COOLDOWN); registerSetCooldown(ClientboundPackets1_20_2.COOLDOWN);
registerWindowItems1_17_1(ClientboundPackets1_20_2.WINDOW_ITEMS); registerWindowItems1_17_1(ClientboundPackets1_20_2.WINDOW_ITEMS);
registerSetSlot1_17_1(ClientboundPackets1_20_2.SET_SLOT); registerSetSlot1_17_1(ClientboundPackets1_20_2.SET_SLOT);
@ -52,7 +53,7 @@ public final class BlockItemPacketRewriter1_99 extends ItemRewriter<ClientboundP
registerEntityEquipmentArray(ClientboundPackets1_20_2.ENTITY_EQUIPMENT); registerEntityEquipmentArray(ClientboundPackets1_20_2.ENTITY_EQUIPMENT);
registerClickWindow1_17_1(ServerboundPackets1_20_2.CLICK_WINDOW); registerClickWindow1_17_1(ServerboundPackets1_20_2.CLICK_WINDOW);
registerTradeList1_19(ClientboundPackets1_20_2.TRADE_LIST); registerTradeList1_19(ClientboundPackets1_20_2.TRADE_LIST);
registerCreativeInvAction(ServerboundPackets1_20_2.CREATIVE_INVENTORY_ACTION, Type.ITEM1_20_2); registerCreativeInvAction(ServerboundPackets1_20_2.CREATIVE_INVENTORY_ACTION);
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_2.WINDOW_PROPERTY); registerWindowPropertyEnchantmentHandler(ClientboundPackets1_20_2.WINDOW_PROPERTY);
registerSpawnParticle1_19(ClientboundPackets1_20_2.SPAWN_PARTICLE); registerSpawnParticle1_19(ClientboundPackets1_20_2.SPAWN_PARTICLE);

Datei anzeigen

@ -1,5 +1,5 @@
/* /*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2023 ViaVersion and contributors * Copyright (C) 2023 ViaVersion and contributors
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -19,7 +19,7 @@ package com.viaversion.viabackwards.template.protocol.rewriter;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99; import com.viaversion.viabackwards.template.protocol.Protocol1_98To_99;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -39,16 +39,16 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
@Override @Override
public void registerPackets() { public void registerPackets() {
registerTrackerWithData1_19(ClientboundPackets1_20_2.SPAWN_ENTITY, Entity1_19_4Types.FALLING_BLOCK); registerTrackerWithData1_19(ClientboundPackets1_20_2.SPAWN_ENTITY, EntityTypes1_19_4.FALLING_BLOCK);
registerMetadataRewriter(ClientboundPackets1_20_2.ENTITY_METADATA, /*Types1_OLD.METADATA_LIST, */Types1_20_3.METADATA_LIST); // Specify old and new metadata list if changed registerMetadataRewriter(ClientboundPackets1_20_2.ENTITY_METADATA, /*Types1_OLD.METADATA_LIST, */Types1_20_3.METADATA_LIST); // Specify old and new metadata list if changed
registerRemoveEntities(ClientboundPackets1_20_2.REMOVE_ENTITIES); registerRemoveEntities(ClientboundPackets1_20_2.REMOVE_ENTITIES);
protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.REGISTRY_DATA, new PacketHandlers() { protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_2.REGISTRY_DATA, new PacketHandlers() {
@Override @Override
protected void register() { protected void register() {
map(Type.NAMED_COMPOUND_TAG); // Registry data map(Type.COMPOUND_TAG); // Registry data
handler(dimensionDataHandler()); // Caches dimensions to access data like height later handler(configurationDimensionDataHandler()); // Caches dimensions to access data like height later
handler(biomeSizeTracker()); // Tracks the amount of biomes sent for chunk data handler(configurationBiomeSizeTracker()); // Tracks the amount of biomes sent for chunk data
} }
}); });
@ -102,7 +102,7 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
Types1_20_3.META_TYPES.optionalComponentType Types1_20_3.META_TYPES.optionalComponentType
); );
filter().filterFamily(Entity1_19_4Types.MINECART_ABSTRACT).index(11).handler((event, meta) -> { filter().filterFamily(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value(); final int blockState = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState)); meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
}); });
@ -116,11 +116,11 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
// If types changed, uncomment to map them // If types changed, uncomment to map them
// mapTypes(); // mapTypes();
// mapEntityTypeWithData(Entity1_19_4Types.SNIFFER, Entity1_19_4Types.RAVAGER).jsonName(); // mapEntityTypeWithData(EntityTypes1_19_4.SNIFFER, EntityTypes1_19_4.RAVAGER).jsonName();
} }
@Override @Override
public EntityType typeFromId(final int type) { public EntityType typeFromId(final int type) {
return Entity1_19_4Types.getTypeFromId(type); return EntityTypes1_19_4.getTypeFromId(type);
} }
} }