Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-16 04:50:10 +01:00
Update template protocol classes
Dieser Commit ist enthalten in:
Ursprung
9c3255d5a4
Commit
c2b5a5f545
@ -69,7 +69,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public interface ViaBackwardsPlatform {
|
public interface ViaBackwardsPlatform {
|
||||||
|
|
||||||
String MINIMUM_VV_VERSION = "5.0.3";
|
String MINIMUM_VV_VERSION = "5.0.4";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize ViaBackwards.
|
* Initialize ViaBackwards.
|
||||||
|
@ -27,6 +27,7 @@ import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
|||||||
import com.viaversion.viabackwards.api.data.MappedItem;
|
import com.viaversion.viabackwards.api.data.MappedItem;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||||
import com.viaversion.viaversion.api.data.FullMappings;
|
import com.viaversion.viaversion.api.data.FullMappings;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
|
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
|
||||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
|
||||||
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
|
||||||
@ -43,14 +44,23 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||||
T extends BackwardsProtocol<C, ?, ?, S>> extends StructuredItemRewriter<C, S, T> {
|
T extends BackwardsProtocol<C, ?, ?, S>> extends StructuredItemRewriter<C, S, T> {
|
||||||
|
|
||||||
public BackwardsStructuredItemRewriter(final T protocol, final Type<Item> itemType, final Type<Item[]> itemArrayType) {
|
public BackwardsStructuredItemRewriter(
|
||||||
super(protocol, itemType, itemArrayType);
|
T protocol,
|
||||||
|
Type<Item> itemType, Type<Item[]> itemArrayType, Type<Item> mappedItemType, Type<Item[]> mappedItemArrayType,
|
||||||
|
Type<Item> itemCostType, Type<Item> optionalItemCostType, Type<Item> mappedItemCostType, Type<Item> mappedOptionalItemCostType,
|
||||||
|
Type<Particle> particleType, Type<Particle> mappedParticleType
|
||||||
|
) {
|
||||||
|
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType, itemCostType, optionalItemCostType, mappedItemCostType, mappedOptionalItemCostType, particleType, mappedParticleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackwardsStructuredItemRewriter(final T protocol, final Type<Item> itemType, final Type<Item[]> itemArrayType, final Type<Item> mappedItemType, final Type<Item[]> mappedItemArrayType) {
|
public BackwardsStructuredItemRewriter(final T protocol, final Type<Item> itemType, final Type<Item[]> itemArrayType, final Type<Item> mappedItemType, final Type<Item[]> mappedItemArrayType) {
|
||||||
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType);
|
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BackwardsStructuredItemRewriter(final T protocol, final Type<Item> itemType, final Type<Item[]> itemArrayType) {
|
||||||
|
super(protocol, itemType, itemArrayType);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item handleItemToClient(final UserConnection connection, final Item item) {
|
public Item handleItemToClient(final UserConnection connection, final Item item) {
|
||||||
if (item.isEmpty()) {
|
if (item.isEmpty()) {
|
||||||
|
@ -15,51 +15,56 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.template.protocol.rewriter;
|
package com.viaversion.viabackwards.protocol.template;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
|
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
|
||||||
import com.viaversion.viabackwards.template.protocol.Protocol1_98To1_99;
|
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
import com.viaversion.viaversion.api.type.types.version.Types1_21;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.RecipeRewriter1_20_3;
|
import com.viaversion.viaversion.protocols.v1_20_2to1_20_3.rewriter.RecipeRewriter1_20_3;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
|
|
||||||
// To replace if needed:
|
// To replace if needed:
|
||||||
// ChunkType1_20_2
|
// ChunkType1_20_2
|
||||||
// RecipeRewriter1_20_3
|
// RecipeRewriter1_20_3
|
||||||
public final class BlockItemPacketRewriter1_99 extends BackwardsStructuredItemRewriter<ClientboundPacket1_20_5, ServerboundPacket1_20_5, Protocol1_98To1_99> {
|
// Types1_21
|
||||||
|
final class BlockItemPacketRewriter1_99 extends BackwardsStructuredItemRewriter<ClientboundPacket1_21, ServerboundPacket1_20_5, Protocol1_98To1_99> {
|
||||||
|
|
||||||
public BlockItemPacketRewriter1_99(final Protocol1_98To1_99 protocol) {
|
public BlockItemPacketRewriter1_99(final Protocol1_98To1_99 protocol) {
|
||||||
super(protocol, /*old types*/Types1_20_5.ITEM, Types1_20_5.ITEM_ARRAY);
|
super(protocol, Types1_21.ITEM, Types1_21.ITEM_ARRAY);
|
||||||
|
/*super(protocol,
|
||||||
|
Types1_21.ITEM, Types1_21.ITEM_ARRAY, Types1_OLD.ITEM, Types1_OLD.ITEM_ARRAY,
|
||||||
|
Types1_21.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_OLD.ITEM_COST, Types1_OLD.OPTIONAL_ITEM_COST,
|
||||||
|
Types1_21.PARTICLE, Types1_OLD.PARTICLE
|
||||||
|
);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPackets() {
|
public void registerPackets() {
|
||||||
final BlockRewriter<ClientboundPacket1_20_5> blockRewriter = BlockRewriter.for1_20_2(protocol);
|
final BlockRewriter<ClientboundPacket1_21> blockRewriter = BlockRewriter.for1_20_2(protocol);
|
||||||
blockRewriter.registerBlockEvent(ClientboundPackets1_20_5.BLOCK_EVENT);
|
blockRewriter.registerBlockEvent(ClientboundPackets1_21.BLOCK_EVENT);
|
||||||
blockRewriter.registerBlockUpdate(ClientboundPackets1_20_5.BLOCK_UPDATE);
|
blockRewriter.registerBlockUpdate(ClientboundPackets1_21.BLOCK_UPDATE);
|
||||||
blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_20_5.SECTION_BLOCKS_UPDATE);
|
blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_21.SECTION_BLOCKS_UPDATE);
|
||||||
blockRewriter.registerLevelEvent1_21(ClientboundPackets1_20_5.LEVEL_EVENT, 2001);
|
blockRewriter.registerLevelEvent1_21(ClientboundPackets1_21.LEVEL_EVENT, 2001);
|
||||||
blockRewriter.registerLevelChunk1_19(ClientboundPackets1_20_5.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new);
|
blockRewriter.registerLevelChunk1_19(ClientboundPackets1_21.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_20_2::new);
|
||||||
blockRewriter.registerBlockEntityData(ClientboundPackets1_20_5.BLOCK_ENTITY_DATA);
|
blockRewriter.registerBlockEntityData(ClientboundPackets1_21.BLOCK_ENTITY_DATA);
|
||||||
|
|
||||||
// registerOpenWindow(ClientboundPackets1_20_5.OPEN_WINDOW);
|
// registerOpenWindow(ClientboundPackets1_21.OPEN_WINDOW);
|
||||||
registerCooldown(ClientboundPackets1_20_5.COOLDOWN);
|
registerCooldown(ClientboundPackets1_21.COOLDOWN);
|
||||||
registerSetContent1_17_1(ClientboundPackets1_20_5.CONTAINER_SET_CONTENT);
|
registerSetContent1_17_1(ClientboundPackets1_21.CONTAINER_SET_CONTENT);
|
||||||
registerSetSlot1_17_1(ClientboundPackets1_20_5.CONTAINER_SET_SLOT);
|
registerSetSlot1_17_1(ClientboundPackets1_21.CONTAINER_SET_SLOT);
|
||||||
registerAdvancements1_20_3(ClientboundPackets1_20_5.UPDATE_ADVANCEMENTS);
|
registerAdvancements1_20_3(ClientboundPackets1_21.UPDATE_ADVANCEMENTS);
|
||||||
registerSetEquipment(ClientboundPackets1_20_5.SET_EQUIPMENT);
|
registerSetEquipment(ClientboundPackets1_21.SET_EQUIPMENT);
|
||||||
registerContainerClick1_17_1(ServerboundPackets1_20_5.CONTAINER_CLICK);
|
registerContainerClick1_17_1(ServerboundPackets1_20_5.CONTAINER_CLICK);
|
||||||
registerMerchantOffers1_20_5(ClientboundPackets1_20_5.MERCHANT_OFFERS, Types1_20_5.ITEM_COST, Types1_20_5.ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST);
|
registerMerchantOffers1_20_5(ClientboundPackets1_21.MERCHANT_OFFERS);
|
||||||
registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT);
|
registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT);
|
||||||
registerContainerSetData(ClientboundPackets1_20_5.CONTAINER_SET_DATA);
|
registerContainerSetData(ClientboundPackets1_21.CONTAINER_SET_DATA);
|
||||||
registerLevelParticles1_20_5(ClientboundPackets1_20_5.LEVEL_PARTICLES, Types1_20_5.PARTICLE, Types1_20_5.PARTICLE);
|
registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES);
|
||||||
registerExplosion(ClientboundPackets1_20_5.EXPLODE, Types1_20_5.PARTICLE, Types1_20_5.PARTICLE);
|
registerExplosion(ClientboundPackets1_21.EXPLODE);
|
||||||
|
|
||||||
new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.UPDATE_RECIPES);
|
new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_21.UPDATE_RECIPES);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,25 +15,24 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.template.protocol.rewriter;
|
package com.viaversion.viabackwards.protocol.template;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import com.viaversion.viabackwards.template.protocol.Protocol1_98To1_99;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Types;
|
import com.viaversion.viaversion.api.type.Types;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundConfigurationPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
// Replace if needed
|
// Replace if needed
|
||||||
// Types1_OLD
|
// Types1_OLD
|
||||||
// Types1_20_5
|
// Types1_21
|
||||||
public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPacket1_20_5, Protocol1_98To1_99> {
|
final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPacket1_21, Protocol1_98To1_99> {
|
||||||
|
|
||||||
public EntityPacketRewriter1_99(final Protocol1_98To1_99 protocol) {
|
public EntityPacketRewriter1_99(final Protocol1_98To1_99 protocol) {
|
||||||
super(protocol, Types1_20_5.ENTITY_DATA_TYPES.optionalComponentType, Types1_20_5.ENTITY_DATA_TYPES.booleanType);
|
super(protocol, Types1_20_5.ENTITY_DATA_TYPES.optionalComponentType, Types1_20_5.ENTITY_DATA_TYPES.booleanType);
|
||||||
@ -41,18 +40,18 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPackets() {
|
public void registerPackets() {
|
||||||
registerTrackerWithData1_19(ClientboundPackets1_20_5.ADD_ENTITY, EntityTypes1_20_5.FALLING_BLOCK);
|
registerTrackerWithData1_19(ClientboundPackets1_21.ADD_ENTITY, EntityTypes1_20_5.FALLING_BLOCK);
|
||||||
registerSetEntityData(ClientboundPackets1_20_5.SET_ENTITY_DATA, /*Types1_OLD.ENTITY_DATA_LIST, */Types1_20_5.ENTITY_DATA_LIST); // Specify old and new entity data list if changed
|
registerSetEntityData(ClientboundPackets1_21.SET_ENTITY_DATA, /*Types1_OLD.ENTITY_DATA_LIST, */Types1_20_5.ENTITY_DATA_LIST); // Specify old and new entity data list if changed
|
||||||
registerRemoveEntities(ClientboundPackets1_20_5.REMOVE_ENTITIES);
|
registerRemoveEntities(ClientboundPackets1_21.REMOVE_ENTITIES);
|
||||||
|
|
||||||
// TODO Item and sound id changes in registries, probably others as well
|
// TODO Item and sound id changes in registries, probably others as well
|
||||||
protocol.registerClientbound(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA, wrapper -> {
|
protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, wrapper -> {
|
||||||
final String registryKey = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING));
|
final String registryKey = Key.stripMinecraftNamespace(wrapper.passthrough(Types.STRING));
|
||||||
final RegistryEntry[] entries = wrapper.passthrough(Types.REGISTRY_ENTRY_ARRAY);
|
final RegistryEntry[] entries = wrapper.passthrough(Types.REGISTRY_ENTRY_ARRAY);
|
||||||
handleRegistryData1_20_5(wrapper.user(), registryKey, entries); // Caches dimensions to access data like height later and tracks the amount of biomes sent for chunk data
|
handleRegistryData1_20_5(wrapper.user(), registryKey, entries); // Caches dimensions to access data like height later and tracks the amount of biomes sent for chunk data
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_20_5.LOGIN, new PacketHandlers() {
|
protocol.registerClientbound(ClientboundPackets1_21.LOGIN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
map(Types.INT); // Entity id
|
map(Types.INT); // Entity id
|
||||||
@ -70,7 +69,7 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_20_5.RESPAWN, wrapper -> {
|
protocol.registerClientbound(ClientboundPackets1_21.RESPAWN, wrapper -> {
|
||||||
final int dimensionId = wrapper.passthrough(Types.VAR_INT);
|
final int dimensionId = wrapper.passthrough(Types.VAR_INT);
|
||||||
final String world = wrapper.passthrough(Types.STRING);
|
final String world = wrapper.passthrough(Types.STRING);
|
||||||
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world); // Tracks world height and name for chunk data and entity (un)tracking
|
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world); // Tracks world height and name for chunk data and entity (un)tracking
|
||||||
@ -87,7 +86,7 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
|
|||||||
id--;
|
id--;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.setDataType(Types1_20_5.ENTITY_DATA_TYPES.byId(id));
|
data.setDataType(Types1_21.ENTITY_DATA_TYPES.byId(id));
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
registerEntityDataTypeHandler1_20_3(
|
registerEntityDataTypeHandler1_20_3(
|
@ -15,26 +15,24 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.template.protocol;
|
package com.viaversion.viabackwards.protocol.template;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||||
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
|
||||||
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||||
import com.viaversion.viabackwards.template.protocol.rewriter.BlockItemPacketRewriter1_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.EntityTypes1_20_5;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
||||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.Protocol1_20_3To1_20_5;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundConfigurationPackets1_20_5;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5;
|
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPacket1_20_5;
|
||||||
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundPackets1_20_5;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPacket1_21;
|
||||||
|
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundPackets1_21;
|
||||||
import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType;
|
import com.viaversion.viaversion.rewriter.ComponentRewriter.ReadType;
|
||||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
@ -42,53 +40,53 @@ import com.viaversion.viaversion.rewriter.TagRewriter;
|
|||||||
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
|
||||||
|
|
||||||
// Placeholders to replace (in the entire package):
|
// Placeholders to replace (in the entire package):
|
||||||
// Protocol1_98To_99, EntityPacketRewriter1_99, BlockItemPacketRewriter1_99
|
// Protocol1_98To1_99, EntityPacketRewriter1_99, BlockItemPacketRewriter1_99
|
||||||
// Protocol1_20_5To1_20_3 (the ViaVersion protocol class the mappings depend on)
|
// Protocol1_20_5To1_21 (the ViaVersion protocol class the mappings depend on)
|
||||||
// ClientboundPacket1_20_5
|
// ClientboundPacket1_21
|
||||||
// ServerboundPacket1_20_5
|
// ServerboundPacket1_20_5
|
||||||
// ClientboundConfigurationPackets1_20_5
|
// ClientboundConfigurationPackets1_21
|
||||||
// ServerboundConfigurationPackets1_20_5
|
// ServerboundConfigurationPackets1_20_5
|
||||||
// EntityTypes1_20_5 (UNMAPPED type)
|
// EntityTypes1_20_5 (UNMAPPED type)
|
||||||
// 1.99, 1.98
|
// 1.99, 1.98
|
||||||
public final class Protocol1_98To1_99 extends BackwardsProtocol<ClientboundPacket1_20_5, ClientboundPacket1_20_5, ServerboundPacket1_20_5, ServerboundPacket1_20_5> {
|
final class Protocol1_98To1_99 extends BackwardsProtocol<ClientboundPacket1_21, ClientboundPacket1_21, ServerboundPacket1_20_5, ServerboundPacket1_20_5> {
|
||||||
|
|
||||||
// ViaBackwards uses its own mappings and also needs a translatablerewriter for translation mappings
|
// ViaBackwards uses its own mappings and also needs a translatablerewriter for translation mappings
|
||||||
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.99", "1.98", Protocol1_20_3To1_20_5.class);
|
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.99", "1.98", Protocol1_20_5To1_21.class);
|
||||||
private final EntityPacketRewriter1_99 entityRewriter = new EntityPacketRewriter1_99(this);
|
private final EntityPacketRewriter1_99 entityRewriter = new EntityPacketRewriter1_99(this);
|
||||||
private final BlockItemPacketRewriter1_99 itemRewriter = new BlockItemPacketRewriter1_99(this);
|
private final BlockItemPacketRewriter1_99 itemRewriter = new BlockItemPacketRewriter1_99(this);
|
||||||
private final TranslatableRewriter<ClientboundPacket1_20_5> translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT);
|
private final TranslatableRewriter<ClientboundPacket1_21> translatableRewriter = new TranslatableRewriter<>(this, ReadType.NBT);
|
||||||
private final TagRewriter<ClientboundPacket1_20_5> tagRewriter = new TagRewriter<>(this);
|
private final TagRewriter<ClientboundPacket1_21> tagRewriter = new TagRewriter<>(this);
|
||||||
|
|
||||||
public Protocol1_98To1_99() {
|
public Protocol1_98To1_99() {
|
||||||
super(ClientboundPacket1_20_5.class, ClientboundPacket1_20_5.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_5.class);
|
super(ClientboundPacket1_21.class, ClientboundPacket1_21.class, ServerboundPacket1_20_5.class, ServerboundPacket1_20_5.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
super.registerPackets();
|
super.registerPackets();
|
||||||
|
|
||||||
tagRewriter.registerGeneric(ClientboundPackets1_20_5.UPDATE_TAGS);
|
tagRewriter.registerGeneric(ClientboundPackets1_21.UPDATE_TAGS);
|
||||||
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_20_5.UPDATE_TAGS);
|
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_21.UPDATE_TAGS);
|
||||||
|
|
||||||
final SoundRewriter<ClientboundPacket1_20_5> soundRewriter = new SoundRewriter<>(this);
|
final SoundRewriter<ClientboundPacket1_21> soundRewriter = new SoundRewriter<>(this);
|
||||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND);
|
soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND);
|
||||||
soundRewriter.registerSound1_19_3(ClientboundPackets1_20_5.SOUND_ENTITY);
|
soundRewriter.registerSound1_19_3(ClientboundPackets1_21.SOUND_ENTITY);
|
||||||
soundRewriter.registerStopSound(ClientboundPackets1_20_5.STOP_SOUND);
|
soundRewriter.registerStopSound(ClientboundPackets1_21.STOP_SOUND);
|
||||||
|
|
||||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_20_5.AWARD_STATS);
|
new StatisticsRewriter<>(this).register(ClientboundPackets1_21.AWARD_STATS);
|
||||||
//new AttributeRewriter<>(this).register1_21(ClientboundPackets1_20_5.ENTITY_PROPERTIES);
|
//new AttributeRewriter<>(this).register1_21(ClientboundPackets1_21.ENTITY_PROPERTIES);
|
||||||
|
|
||||||
// Registers translatable mappings (missing a whole bunch still)
|
// Registers translatable mappings (missing a whole bunch still)
|
||||||
//translatableRewriter.registerOpenWindow(ClientboundPackets1_20_5.OPEN_WINDOW); // Handled by registerOpenWindow in item rewriters
|
//translatableRewriter.registerOpenWindow(ClientboundPackets1_21.OPEN_WINDOW); // Handled by registerOpenWindow in item rewriters
|
||||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_ACTION_BAR_TEXT);
|
translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_ACTION_BAR_TEXT);
|
||||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_TITLE_TEXT);
|
translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_TITLE_TEXT);
|
||||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SET_SUBTITLE_TEXT);
|
translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SET_SUBTITLE_TEXT);
|
||||||
translatableRewriter.registerBossEvent(ClientboundPackets1_20_5.BOSS_EVENT);
|
translatableRewriter.registerBossEvent(ClientboundPackets1_21.BOSS_EVENT);
|
||||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.DISCONNECT);
|
translatableRewriter.registerComponentPacket(ClientboundPackets1_21.DISCONNECT);
|
||||||
translatableRewriter.registerTabList(ClientboundPackets1_20_5.TAB_LIST);
|
translatableRewriter.registerTabList(ClientboundPackets1_21.TAB_LIST);
|
||||||
translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_20_5.PLAYER_COMBAT_KILL);
|
translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21.PLAYER_COMBAT_KILL);
|
||||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.SYSTEM_CHAT);
|
translatableRewriter.registerComponentPacket(ClientboundPackets1_21.SYSTEM_CHAT);
|
||||||
translatableRewriter.registerComponentPacket(ClientboundPackets1_20_5.DISGUISED_CHAT);
|
translatableRewriter.registerComponentPacket(ClientboundPackets1_21.DISGUISED_CHAT);
|
||||||
translatableRewriter.registerPing();
|
translatableRewriter.registerPing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,20 +111,20 @@ public final class Protocol1_98To1_99 extends BackwardsProtocol<ClientboundPacke
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TranslatableRewriter<ClientboundPacket1_20_5> getComponentRewriter() {
|
public TranslatableRewriter<ClientboundPacket1_21> getComponentRewriter() {
|
||||||
return translatableRewriter;
|
return translatableRewriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TagRewriter<ClientboundPacket1_20_5> getTagRewriter() {
|
public TagRewriter<ClientboundPacket1_21> getTagRewriter() {
|
||||||
return tagRewriter;
|
return tagRewriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PacketTypesProvider<ClientboundPacket1_20_5, ClientboundPacket1_20_5, ServerboundPacket1_20_5, ServerboundPacket1_20_5> createPacketTypesProvider() {
|
protected PacketTypesProvider<ClientboundPacket1_21, ClientboundPacket1_21, ServerboundPacket1_20_5, ServerboundPacket1_20_5> createPacketTypesProvider() {
|
||||||
return new SimplePacketTypesProvider<>(
|
return new SimplePacketTypesProvider<>(
|
||||||
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class),
|
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_21.class, ClientboundConfigurationPackets1_21.class),
|
||||||
packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_20_5.class, ClientboundConfigurationPackets1_20_5.class),
|
packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_21.class, ClientboundConfigurationPackets1_21.class),
|
||||||
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class),
|
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class),
|
||||||
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class)
|
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_20_5.class, ServerboundConfigurationPackets1_20_5.class)
|
||||||
);
|
);
|
@ -395,7 +395,7 @@ public final class BlockItemPacketRewriter1_20_5 extends BackwardsStructuredItem
|
|||||||
// Convert to structured item first
|
// Convert to structured item first
|
||||||
final Item structuredItem = vvProtocol.getItemRewriter().toStructuredItem(connection, item);
|
final Item structuredItem = vvProtocol.getItemRewriter().toStructuredItem(connection, item);
|
||||||
|
|
||||||
if (item.tag() != null && item.tag().remove(nbtTagName()) instanceof final CompoundTag tag) {
|
if (item.tag() != null && item.tag().get(nbtTagName()) instanceof final CompoundTag tag) {
|
||||||
// Set original custom data from backup
|
// Set original custom data from backup
|
||||||
structuredItem.dataContainer().set(StructuredDataKey.CUSTOM_DATA, tag);
|
structuredItem.dataContainer().set(StructuredDataKey.CUSTOM_DATA, tag);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,11 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
|||||||
private final StructuredEnchantmentRewriter enchantmentRewriter = new StructuredEnchantmentRewriter(this);
|
private final StructuredEnchantmentRewriter enchantmentRewriter = new StructuredEnchantmentRewriter(this);
|
||||||
|
|
||||||
public BlockItemPacketRewriter1_21(final Protocol1_21To1_20_5 protocol) {
|
public BlockItemPacketRewriter1_21(final Protocol1_21To1_20_5 protocol) {
|
||||||
super(protocol, Types1_21.ITEM, Types1_21.ITEM_ARRAY, Types1_20_5.ITEM, Types1_20_5.ITEM_ARRAY);
|
super(protocol,
|
||||||
|
Types1_21.ITEM, Types1_21.ITEM_ARRAY, Types1_20_5.ITEM, Types1_20_5.ITEM_ARRAY,
|
||||||
|
Types1_21.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_20_5.ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST,
|
||||||
|
Types1_21.PARTICLE, Types1_20_5.PARTICLE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,10 +83,10 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
|
|||||||
registerAdvancements1_20_3(ClientboundPackets1_21.UPDATE_ADVANCEMENTS);
|
registerAdvancements1_20_3(ClientboundPackets1_21.UPDATE_ADVANCEMENTS);
|
||||||
registerSetEquipment(ClientboundPackets1_21.SET_EQUIPMENT);
|
registerSetEquipment(ClientboundPackets1_21.SET_EQUIPMENT);
|
||||||
registerContainerClick1_17_1(ServerboundPackets1_20_5.CONTAINER_CLICK);
|
registerContainerClick1_17_1(ServerboundPackets1_20_5.CONTAINER_CLICK);
|
||||||
registerMerchantOffers1_20_5(ClientboundPackets1_21.MERCHANT_OFFERS, Types1_21.ITEM_COST, Types1_20_5.ITEM_COST, Types1_21.OPTIONAL_ITEM_COST, Types1_20_5.OPTIONAL_ITEM_COST);
|
registerMerchantOffers1_20_5(ClientboundPackets1_21.MERCHANT_OFFERS);
|
||||||
registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT);
|
registerSetCreativeModeSlot(ServerboundPackets1_20_5.SET_CREATIVE_MODE_SLOT);
|
||||||
registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
|
registerLevelParticles1_20_5(ClientboundPackets1_21.LEVEL_PARTICLES);
|
||||||
registerExplosion(ClientboundPackets1_21.EXPLODE, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
|
registerExplosion(ClientboundPackets1_21.EXPLODE);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_21.OPEN_SCREEN, wrapper -> {
|
protocol.registerClientbound(ClientboundPackets1_21.OPEN_SCREEN, wrapper -> {
|
||||||
wrapper.passthrough(Types.VAR_INT); // Id
|
wrapper.passthrough(Types.VAR_INT); // Id
|
||||||
|
@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
# ViaVersion
|
# ViaVersion
|
||||||
viaver = "5.0.3-SNAPSHOT"
|
viaver = "5.0.4-SNAPSHOT"
|
||||||
|
|
||||||
# Common provided
|
# Common provided
|
||||||
netty = "4.0.20.Final"
|
netty = "4.0.20.Final"
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
dependencies {
|
|
||||||
compileOnlyApi(projects.viabackwardsCommon)
|
|
||||||
}
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren