Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Ensure correct packet types are used on rewriters
Dieser Commit ist enthalten in:
Ursprung
734bc9e88c
Commit
1a5f83619d
@ -20,10 +20,11 @@ package com.viaversion.viaversion.protocols.protocol1_10to1_9_3.packets;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||
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.rewriter.ItemRewriter;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_10To1_9_3_4> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, ServerboundPackets1_9_3, Protocol1_10To1_9_3_4> {
|
||||
|
||||
public InventoryPackets(Protocol1_10To1_9_3_4 protocol) {
|
||||
super(protocol);
|
||||
|
@ -20,10 +20,11 @@ package com.viaversion.viaversion.protocols.protocol1_11_1to1_11.packets;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_11_1to1_11.Protocol1_11_1To1_11;
|
||||
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.rewriter.ItemRewriter;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_11_1To1_11> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, ServerboundPackets1_9_3, Protocol1_11_1To1_11> {
|
||||
|
||||
public InventoryPackets(Protocol1_11_1To1_11 protocol) {
|
||||
super(protocol);
|
||||
|
@ -28,7 +28,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.data.PotionColorMapping;
|
||||
@ -39,7 +38,6 @@ import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1
|
||||
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.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.util.Pair;
|
||||
|
||||
@ -51,8 +49,8 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
||||
}
|
||||
};
|
||||
|
||||
private final EntityRewriter entityRewriter = new MetadataRewriter1_11To1_10(this);
|
||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
||||
private final MetadataRewriter1_11To1_10 entityRewriter = new MetadataRewriter1_11To1_10(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
|
||||
public Protocol1_11To1_10() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||
@ -112,7 +110,7 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
||||
}
|
||||
});
|
||||
|
||||
new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
|
||||
new SoundRewriter<>(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
|
||||
|
||||
registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() {
|
||||
@Override
|
||||
@ -382,12 +380,12 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public MetadataRewriter1_11To1_10 getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class MetadataRewriter1_11To1_10 extends EntityRewriter<Protocol1_11To1_10> {
|
||||
public class MetadataRewriter1_11To1_10 extends EntityRewriter<ClientboundPackets1_9_3, Protocol1_11To1_10> {
|
||||
|
||||
public MetadataRewriter1_11To1_10(Protocol1_11To1_10 protocol) {
|
||||
super(protocol);
|
||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_11To1_10> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, ServerboundPackets1_9_3, Protocol1_11To1_10> {
|
||||
|
||||
public InventoryPackets(Protocol1_11To1_10 protocol) {
|
||||
super(protocol);
|
||||
|
@ -34,7 +34,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
@ -48,13 +47,12 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac
|
||||
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.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
|
||||
public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_12, ServerboundPackets1_9_3, ServerboundPackets1_12> {
|
||||
|
||||
private final EntityRewriter metadataRewriter = new MetadataRewriter1_12To1_11_1(this);
|
||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
||||
private final MetadataRewriter1_12To1_11_1 metadataRewriter = new MetadataRewriter1_12To1_11_1(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
|
||||
public Protocol1_12To1_11_1() {
|
||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_12.class, ServerboundPackets1_9_3.class, ServerboundPackets1_12.class);
|
||||
@ -192,7 +190,7 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
||||
}
|
||||
});
|
||||
|
||||
new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
|
||||
new SoundRewriter<>(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
|
||||
|
||||
|
||||
// New packet at 0x01
|
||||
@ -273,12 +271,12 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public MetadataRewriter1_12To1_11_1 getEntityRewriter() {
|
||||
return metadataRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,12 @@ import com.google.gson.JsonObject;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.data.AchievementTranslationMapping;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
|
||||
public class TranslateRewriter {
|
||||
|
||||
private final static ComponentRewriter achievementTextRewriter = new ComponentRewriter() {
|
||||
private static final ComponentRewriter<ClientboundPackets1_9_3> ACHIEVEMENT_TEXT_REWRITER = new ComponentRewriter<ClientboundPackets1_9_3>() {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject object, String translate) {
|
||||
String text = AchievementTranslationMapping.get(translate);
|
||||
@ -108,7 +109,7 @@ public class TranslateRewriter {
|
||||
JsonElement translate = obj.get("translate");
|
||||
if (translate != null) {
|
||||
if (translate.getAsString().startsWith("chat.type.achievement")) {
|
||||
achievementTextRewriter.processText(obj);
|
||||
ACHIEVEMENT_TEXT_REWRITER.processText(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,12 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter1_12To1_11_1 extends EntityRewriter<Protocol1_12To1_11_1> {
|
||||
public class MetadataRewriter1_12To1_11_1 extends EntityRewriter<ClientboundPackets1_9_3, Protocol1_12To1_11_1> {
|
||||
|
||||
public MetadataRewriter1_12To1_11_1(Protocol1_12To1_11_1 protocol) {
|
||||
super(protocol);
|
||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPac
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_12To1_11_1> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, ServerboundPackets1_12, Protocol1_12To1_11_1> {
|
||||
|
||||
public InventoryPackets(Protocol1_12To1_11_1 protocol) {
|
||||
super(protocol);
|
||||
|
@ -28,8 +28,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13;
|
||||
@ -45,8 +43,8 @@ import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
|
||||
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.13", "1.13.2", true);
|
||||
private final EntityRewriter entityRewriter = new MetadataRewriter1_13_1To1_13(this);
|
||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
||||
private final MetadataRewriter1_13_1To1_13 entityRewriter = new MetadataRewriter1_13_1To1_13(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
|
||||
public Protocol1_13_1To1_13() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
|
||||
@ -144,8 +142,8 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM);
|
||||
new StatisticsRewriter(this).register(ClientboundPackets1_13.STATISTICS);
|
||||
new TagRewriter<>(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_13.STATISTICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,12 +160,12 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public MetadataRewriter1_13_1To1_13 getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,12 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter1_13_1To1_13 extends EntityRewriter<Protocol1_13_1To1_13> {
|
||||
public class MetadataRewriter1_13_1To1_13 extends EntityRewriter<ClientboundPackets1_13, Protocol1_13_1To1_13> {
|
||||
|
||||
public MetadataRewriter1_13_1To1_13(Protocol1_13_1To1_13 protocol) {
|
||||
super(protocol);
|
||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.RecipeRewri
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.rewriter.RecipeRewriter;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_13_1To1_13> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, ServerboundPackets1_13, Protocol1_13_1To1_13> {
|
||||
|
||||
public InventoryPackets(Protocol1_13_1To1_13 protocol) {
|
||||
super(protocol);
|
||||
@ -77,7 +77,7 @@ public class InventoryPackets extends ItemRewriter<Protocol1_13_1To1_13> {
|
||||
|
||||
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
|
||||
|
||||
RecipeRewriter recipeRewriter = new RecipeRewriter1_13_2(protocol);
|
||||
RecipeRewriter<ClientboundPackets1_13> recipeRewriter = new RecipeRewriter1_13_2<>(protocol);
|
||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -19,11 +19,11 @@ package com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
@ -31,8 +31,8 @@ import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
|
||||
public class WorldPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION);
|
||||
public static void register(Protocol1_13_1To1_13 protocol) {
|
||||
BlockRewriter<ClientboundPackets1_13> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -34,8 +34,6 @@ import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
@ -61,11 +59,9 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockCon
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.storage.TabCompleteTracker;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.util.ChatColorUtil;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -78,9 +74,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
// These are arbitrary rewrite values, it just needs an invalid color code character.
|
||||
private static final Map<Character, Character> SCOREBOARD_TEAM_NAME_REWRITE = new HashMap<>();
|
||||
private static final Set<Character> FORMATTING_CODES = Sets.newHashSet('k', 'l', 'm', 'n', 'o', 'r');
|
||||
private final EntityRewriter entityRewriter = new MetadataRewriter1_13To1_12_2(this);
|
||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
||||
private final ComponentRewriter componentRewriter = new ComponentRewriter1_13(this);
|
||||
private final MetadataRewriter1_13To1_12_2 entityRewriter = new MetadataRewriter1_13To1_12_2(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final ComponentRewriter1_13<ClientboundPackets1_12_1> componentRewriter = new ComponentRewriter1_13<>(this);
|
||||
|
||||
static {
|
||||
SCOREBOARD_TEAM_NAME_REWRITE.put('0', 'g');
|
||||
@ -629,7 +625,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
// New 0x4C - Stop Sound
|
||||
|
||||
new SoundRewriter(this).registerSound(ClientboundPackets1_12_1.SOUND);
|
||||
new SoundRewriter<>(this).registerSound(ClientboundPackets1_12_1.SOUND);
|
||||
|
||||
registerClientbound(ClientboundPackets1_12_1.TAB_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
@ -1045,16 +1041,16 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public MetadataRewriter1_13To1_12_2 getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
public ComponentRewriter getComponentRewriter() {
|
||||
public ComponentRewriter1_13 getComponentRewriter() {
|
||||
return componentRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -29,14 +29,15 @@ import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ComponentRewriter1_13 extends ComponentRewriter {
|
||||
public class ComponentRewriter1_13<C extends ClientboundPacketType> extends ComponentRewriter<C> {
|
||||
|
||||
public ComponentRewriter1_13(Protocol protocol) {
|
||||
public ComponentRewriter1_13(Protocol<C, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
|
@ -19,17 +19,17 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.rewriter.RecipeRewriter;
|
||||
|
||||
/**
|
||||
* For 1.13.2, not 1.13 (1.13 reads recipe type and id in swapped order)!
|
||||
*/
|
||||
public class RecipeRewriter1_13_2 extends RecipeRewriter {
|
||||
public class RecipeRewriter1_13_2<C extends ClientboundPacketType> extends RecipeRewriter<C> {
|
||||
|
||||
public RecipeRewriter1_13_2(Protocol protocol) {
|
||||
public RecipeRewriter1_13_2(Protocol<C, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
recipeHandlers.put("crafting_shapeless", this::handleCraftingShapeless);
|
||||
recipeHandlers.put("crafting_shaped", this::handleCraftingShaped);
|
||||
|
@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
||||
@ -33,7 +34,7 @@ import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<Protocol1_13To1_12_2> {
|
||||
public class MetadataRewriter1_13To1_12_2 extends EntityRewriter<ClientboundPackets1_12_1, Protocol1_13To1_12_2> {
|
||||
|
||||
public MetadataRewriter1_13To1_12_2(Protocol1_13To1_12_2 protocol) {
|
||||
super(protocol);
|
||||
|
@ -49,7 +49,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_13To1_12_2> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, ServerboundPackets1_13, Protocol1_13To1_12_2> {
|
||||
private static final String NBT_TAG_NAME = "ViaVersion|" + Protocol1_13To1_12_2.class.getSimpleName();
|
||||
|
||||
public InventoryPackets(Protocol1_13To1_12_2 protocol) {
|
||||
@ -176,12 +176,12 @@ public class InventoryPackets extends ItemRewriter<Protocol1_13To1_12_2> {
|
||||
} else if (channel.equals("minecraft:register") || channel.equals("minecraft:unregister")) {
|
||||
String[] channels = new String(wrapper.read(Type.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0");
|
||||
List<String> rewrittenChannels = new ArrayList<>();
|
||||
for (int i = 0; i < channels.length; i++) {
|
||||
String rewritten = getNewPluginChannelId(channels[i]);
|
||||
for (String s : channels) {
|
||||
String rewritten = getNewPluginChannelId(s);
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + channels[i]);
|
||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in outgoing REGISTER: " + s);
|
||||
}
|
||||
}
|
||||
if (!rewrittenChannels.isEmpty()) {
|
||||
@ -243,12 +243,12 @@ public class InventoryPackets extends ItemRewriter<Protocol1_13To1_12_2> {
|
||||
} else if (channel.equals("REGISTER") || channel.equals("UNREGISTER")) {
|
||||
String[] channels = new String(wrapper.read(Type.REMAINING_BYTES), StandardCharsets.UTF_8).split("\0");
|
||||
List<String> rewrittenChannels = new ArrayList<>();
|
||||
for (int i = 0; i < channels.length; i++) {
|
||||
String rewritten = getOldPluginChannelId(channels[i]);
|
||||
for (String s : channels) {
|
||||
String rewritten = getOldPluginChannelId(s);
|
||||
if (rewritten != null) {
|
||||
rewrittenChannels.add(rewritten);
|
||||
} else if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + channels[i]);
|
||||
Via.getPlatform().getLogger().warning("Ignoring plugin channel in incoming REGISTER: " + s);
|
||||
}
|
||||
}
|
||||
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -22,11 +22,12 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter1_14_1To1_14 extends EntityRewriter<Protocol1_14_1To1_14> {
|
||||
public class MetadataRewriter1_14_1To1_14 extends EntityRewriter<ClientboundPackets1_14, Protocol1_14_1To1_14> {
|
||||
|
||||
public MetadataRewriter1_14_1To1_14(Protocol1_14_1To1_14 protocol) {
|
||||
super(protocol);
|
||||
|
@ -22,8 +22,6 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||
@ -48,8 +46,8 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_13, ClientboundPackets1_14, ServerboundPackets1_13, ServerboundPackets1_14> {
|
||||
|
||||
public static final MappingData MAPPINGS = new MappingData();
|
||||
private final EntityRewriter metadataRewriter = new MetadataRewriter1_14To1_13_2(this);
|
||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
||||
private final MetadataRewriter1_14To1_13_2 metadataRewriter = new MetadataRewriter1_14To1_13_2(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
|
||||
public Protocol1_14To1_13_2() {
|
||||
super(ClientboundPackets1_13.class, ClientboundPackets1_14.class, ServerboundPackets1_13.class, ServerboundPackets1_14.class);
|
||||
@ -64,13 +62,13 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
WorldPackets.register(this);
|
||||
PlayerPackets.register(this);
|
||||
|
||||
new SoundRewriter(this).registerSound(ClientboundPackets1_13.SOUND);
|
||||
new StatisticsRewriter(this).register(ClientboundPackets1_13.STATISTICS);
|
||||
new SoundRewriter<>(this).registerSound(ClientboundPackets1_13.SOUND);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_13.STATISTICS);
|
||||
|
||||
ComponentRewriter componentRewriter = new ComponentRewriter1_14(this);
|
||||
ComponentRewriter<ClientboundPackets1_13> componentRewriter = new ComponentRewriter1_14<>(this);
|
||||
componentRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE);
|
||||
|
||||
CommandRewriter commandRewriter = new CommandRewriter(this) {
|
||||
CommandRewriter<ClientboundPackets1_13> commandRewriter = new CommandRewriter<ClientboundPackets1_13>(this) {
|
||||
@Override
|
||||
public @Nullable String handleArgumentType(String argumentType) {
|
||||
if (argumentType.equals("minecraft:nbt")) {
|
||||
@ -184,12 +182,12 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public MetadataRewriter1_14To1_13_2 getEntityRewriter() {
|
||||
return metadataRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,12 @@ package com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.ComponentRewriter1_13;
|
||||
|
||||
public class ComponentRewriter1_14 extends ComponentRewriter1_13 {
|
||||
public class ComponentRewriter1_14<C extends ClientboundPacketType> extends ComponentRewriter1_13<C> {
|
||||
|
||||
public ComponentRewriter1_14(Protocol protocol) {
|
||||
public ComponentRewriter1_14(Protocol<C, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
|
@ -19,14 +19,14 @@ package com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.RecipeRewriter1_13_2;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
public class RecipeRewriter1_14 extends RecipeRewriter1_13_2 {
|
||||
public class RecipeRewriter1_14<C extends ClientboundPacketType> extends RecipeRewriter1_13_2<C> {
|
||||
|
||||
public RecipeRewriter1_14(Protocol protocol) {
|
||||
public RecipeRewriter1_14(Protocol<C, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
recipeHandlers.put("stonecutting", this::handleStonecutting);
|
||||
|
||||
|
@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
|
||||
@ -37,7 +38,7 @@ import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<Protocol1_14To1_13_2> {
|
||||
public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPackets1_13, Protocol1_14To1_13_2> {
|
||||
|
||||
public MetadataRewriter1_14To1_13_2(Protocol1_14To1_13_2 protocol) {
|
||||
super(protocol);
|
||||
|
@ -45,10 +45,10 @@ import com.viaversion.viaversion.rewriter.RecipeRewriter;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_14To1_13_2> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, ServerboundPackets1_14, Protocol1_14To1_13_2> {
|
||||
private static final String NBT_TAG_NAME = "ViaVersion|" + Protocol1_14To1_13_2.class.getSimpleName();
|
||||
private static final Set<String> REMOVED_RECIPE_TYPES = Sets.newHashSet("crafting_special_banneraddpattern", "crafting_special_repairitem");
|
||||
private static final ComponentRewriter COMPONENT_REWRITER = new ComponentRewriter() {
|
||||
private static final ComponentRewriter<ClientboundPackets1_13> COMPONENT_REWRITER = new ComponentRewriter<ClientboundPackets1_13>() {
|
||||
@Override
|
||||
protected void handleTranslate(JsonObject object, String translate) {
|
||||
super.handleTranslate(object, translate);
|
||||
@ -202,7 +202,7 @@ public class InventoryPackets extends ItemRewriter<Protocol1_14To1_13_2> {
|
||||
|
||||
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
RecipeRewriter recipeRewriter = new RecipeRewriter1_13_2(protocol);
|
||||
RecipeRewriter<ClientboundPackets1_13> recipeRewriter = new RecipeRewriter1_13_2<>(protocol);
|
||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -55,7 +55,7 @@ public class WorldPackets {
|
||||
}
|
||||
|
||||
public static void register(Protocol1_14To1_13_2 protocol) {
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, null);
|
||||
BlockRewriter<ClientboundPackets1_13> blockRewriter = new BlockRewriter<>(protocol, null);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -22,8 +22,6 @@ import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
@ -40,9 +38,9 @@ import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_14, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
|
||||
|
||||
public static final MappingData MAPPINGS = new MappingData();
|
||||
private final EntityRewriter metadataRewriter = new MetadataRewriter1_15To1_14_4(this);
|
||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
||||
private TagRewriter tagRewriter;
|
||||
private final MetadataRewriter1_15To1_14_4 metadataRewriter = new MetadataRewriter1_15To1_14_4(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private TagRewriter<ClientboundPackets1_14> tagRewriter;
|
||||
|
||||
public Protocol1_15To1_14_4() {
|
||||
super(ClientboundPackets1_14.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
|
||||
@ -56,11 +54,11 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
||||
EntityPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
SoundRewriter<ClientboundPackets1_14> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerSound(ClientboundPackets1_14.ENTITY_SOUND); // Entity Sound Effect (added somewhere in 1.14)
|
||||
soundRewriter.registerSound(ClientboundPackets1_14.SOUND);
|
||||
|
||||
new StatisticsRewriter(this).register(ClientboundPackets1_14.STATISTICS);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_14.STATISTICS);
|
||||
|
||||
registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
@ -69,7 +67,7 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
});
|
||||
|
||||
tagRewriter = new TagRewriter(this);
|
||||
tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.register(ClientboundPackets1_14.TAGS, RegistryType.ENTITY);
|
||||
}
|
||||
|
||||
@ -94,12 +92,12 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public MetadataRewriter1_15To1_14_4 getEntityRewriter() {
|
||||
return metadataRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.packets.EntityPackets;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter1_15To1_14_4 extends EntityRewriter<Protocol1_15To1_14_4> {
|
||||
public class MetadataRewriter1_15To1_14_4 extends EntityRewriter<ClientboundPackets1_14, Protocol1_15To1_14_4> {
|
||||
|
||||
public MetadataRewriter1_15To1_14_4(Protocol1_15To1_14_4 protocol) {
|
||||
super(protocol);
|
||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.RecipeRewri
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_15To1_14_4> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_14, ServerboundPackets1_14, Protocol1_15To1_14_4> {
|
||||
|
||||
public InventoryPackets(Protocol1_15To1_14_4 protocol) {
|
||||
super(protocol);
|
||||
@ -39,7 +39,7 @@ public class InventoryPackets extends ItemRewriter<Protocol1_15To1_14_4> {
|
||||
registerEntityEquipment(ClientboundPackets1_14.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||
registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
new RecipeRewriter1_14(protocol).registerDefaultHandler(ClientboundPackets1_14.DECLARE_RECIPES);
|
||||
new RecipeRewriter1_14<>(protocol).registerDefaultHandler(ClientboundPackets1_14.DECLARE_RECIPES);
|
||||
|
||||
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
@ -32,7 +32,7 @@ import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
public class WorldPackets {
|
||||
|
||||
public static void register(Protocol1_15To1_14_4 protocol) {
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
|
||||
BlockRewriter<ClientboundPackets1_14> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
|
||||
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_14.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_14.BLOCK_CHANGE);
|
||||
|
@ -18,11 +18,10 @@
|
||||
package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
||||
@ -32,7 +31,6 @@ import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets.Invent
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets.WorldPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
@ -40,9 +38,9 @@ import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1_16, ClientboundPackets1_16_2, ServerboundPackets1_16, ServerboundPackets1_16_2> {
|
||||
|
||||
public static final MappingData MAPPINGS = new MappingData();
|
||||
private final EntityRewriter metadataRewriter = new MetadataRewriter1_16_2To1_16_1(this);
|
||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
||||
private TagRewriter tagRewriter;
|
||||
private final MetadataRewriter1_16_2To1_16_1 metadataRewriter = new MetadataRewriter1_16_2To1_16_1(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private TagRewriter<ClientboundPackets1_16> tagRewriter;
|
||||
|
||||
public Protocol1_16_2To1_16_1() {
|
||||
super(ClientboundPackets1_16.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16.class, ServerboundPackets1_16_2.class);
|
||||
@ -56,12 +54,12 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
||||
EntityPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
|
||||
tagRewriter = new TagRewriter(this);
|
||||
tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.register(ClientboundPackets1_16.TAGS, RegistryType.ENTITY);
|
||||
|
||||
new StatisticsRewriter(this).register(ClientboundPackets1_16.STATISTICS);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_16.STATISTICS);
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
SoundRewriter<ClientboundPackets1_16> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND);
|
||||
|
||||
@ -125,12 +123,12 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public MetadataRewriter1_16_2To1_16_1 getEntityRewriter() {
|
||||
return metadataRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -26,11 +26,12 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter<Protocol1_16_2To1_16_1> {
|
||||
public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter<ClientboundPackets1_16, Protocol1_16_2To1_16_1> {
|
||||
|
||||
public MetadataRewriter1_16_2To1_16_1(Protocol1_16_2To1_16_1 protocol) {
|
||||
super(protocol);
|
||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_16_2To1_16_1> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_16, ServerboundPackets1_16_2, Protocol1_16_2To1_16_1> {
|
||||
|
||||
public InventoryPackets(Protocol1_16_2To1_16_1 protocol) {
|
||||
super(protocol);
|
||||
@ -58,7 +58,7 @@ public class InventoryPackets extends ItemRewriter<Protocol1_16_2To1_16_1> {
|
||||
}
|
||||
});
|
||||
|
||||
new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_16.DECLARE_RECIPES);
|
||||
new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_16.DECLARE_RECIPES);
|
||||
|
||||
registerClickWindow(ServerboundPackets1_16_2.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
@ -21,7 +21,6 @@ import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_16_2;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
@ -31,7 +30,6 @@ import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_1
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -39,8 +37,8 @@ public class WorldPackets {
|
||||
|
||||
private static final BlockChangeRecord[] EMPTY_RECORDS = new BlockChangeRecord[0];
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
|
||||
public static void register(Protocol1_16_2To1_16_1 protocol) {
|
||||
BlockRewriter<ClientboundPackets1_16> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
|
||||
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE);
|
||||
|
@ -28,8 +28,6 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
@ -43,12 +41,10 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPa
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.InventoryPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.WorldPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.storage.InventoryTracker1_16;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -58,10 +54,10 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
|
||||
private static final UUID ZERO_UUID = new UUID(0, 0);
|
||||
public static final MappingData MAPPINGS = new MappingData();
|
||||
private final EntityRewriter metadataRewriter = new MetadataRewriter1_16To1_15_2(this);
|
||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
||||
private final ComponentRewriter componentRewriter = new TranslationMappings(this);
|
||||
private TagRewriter tagRewriter;
|
||||
private final MetadataRewriter1_16To1_15_2 metadataRewriter = new MetadataRewriter1_16To1_15_2(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final TranslationMappings componentRewriter = new TranslationMappings(this);
|
||||
private TagRewriter<ClientboundPackets1_15> tagRewriter;
|
||||
|
||||
public Protocol1_16To1_15_2() {
|
||||
super(ClientboundPackets1_15.class, ClientboundPackets1_16.class, ServerboundPackets1_14.class, ServerboundPackets1_16.class);
|
||||
@ -75,10 +71,10 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
EntityPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
|
||||
tagRewriter = new TagRewriter(this);
|
||||
tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.register(ClientboundPackets1_15.TAGS, RegistryType.ENTITY);
|
||||
|
||||
new StatisticsRewriter(this).register(ClientboundPackets1_15.STATISTICS);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS);
|
||||
|
||||
// Login Success
|
||||
registerClientbound(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
|
||||
@ -148,7 +144,7 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
componentRewriter.registerTitle(ClientboundPackets1_15.TITLE);
|
||||
componentRewriter.registerCombatEvent(ClientboundPackets1_15.COMBAT_EVENT);
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
SoundRewriter<ClientboundPackets1_15> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
|
||||
|
||||
@ -293,16 +289,16 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public MetadataRewriter1_16To1_15_2 getEntityRewriter() {
|
||||
return metadataRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
|
||||
public ComponentRewriter getComponentRewriter() {
|
||||
public TranslationMappings getComponentRewriter() {
|
||||
return componentRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,14 @@ package com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||
|
||||
public class RecipeRewriter1_16 extends RecipeRewriter1_14 {
|
||||
public class RecipeRewriter1_16<C extends ClientboundPacketType> extends RecipeRewriter1_14<C> {
|
||||
|
||||
public RecipeRewriter1_16(Protocol protocol) {
|
||||
public RecipeRewriter1_16(Protocol<C, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
recipeHandlers.put("smithing", this::handleSmithing);
|
||||
}
|
||||
|
@ -20,16 +20,16 @@ package com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TranslationMappings extends ComponentRewriter {
|
||||
public class TranslationMappings extends ComponentRewriter<ClientboundPackets1_15> {
|
||||
private final Map<String, String> mappings = new HashMap<>();
|
||||
|
||||
public TranslationMappings(Protocol protocol) {
|
||||
public TranslationMappings(Protocol1_16To1_15_2 protocol) {
|
||||
super(protocol);
|
||||
mappings.put("attribute.name.generic.armorToughness", "attribute.name.generic.armor_toughness");
|
||||
mappings.put("attribute.name.generic.attackDamage", "attribute.name.generic.attack_damage");
|
||||
|
@ -25,12 +25,13 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter1_16To1_15_2 extends EntityRewriter<Protocol1_16To1_15_2> {
|
||||
public class MetadataRewriter1_16To1_15_2 extends EntityRewriter<ClientboundPackets1_15, Protocol1_16To1_15_2> {
|
||||
|
||||
public MetadataRewriter1_16To1_15_2(Protocol1_16To1_15_2 protocol) {
|
||||
super(protocol);
|
||||
|
@ -40,7 +40,7 @@ import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class InventoryPackets extends ItemRewriter<Protocol1_16To1_15_2> {
|
||||
public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, ServerboundPackets1_16, Protocol1_16To1_15_2> {
|
||||
|
||||
public InventoryPackets(Protocol1_16To1_15_2 protocol) {
|
||||
super(protocol);
|
||||
@ -126,7 +126,7 @@ public class InventoryPackets extends ItemRewriter<Protocol1_16To1_15_2> {
|
||||
}
|
||||
});
|
||||
|
||||
new RecipeRewriter1_14(protocol).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
new RecipeRewriter1_14<>(protocol).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
|
||||
registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
@ -42,7 +42,7 @@ import java.util.UUID;
|
||||
public class WorldPackets {
|
||||
|
||||
public static void register(Protocol1_16To1_15_2 protocol) {
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
|
||||
BlockRewriter<ClientboundPackets1_15> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
|
||||
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_15.BLOCK_CHANGE);
|
||||
|
@ -26,8 +26,6 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||
@ -46,9 +44,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
public static final MappingData MAPPINGS = new MappingDataBase("1.16.2", "1.17", true);
|
||||
private static final String[] NEW_GAME_EVENT_TAGS = {"minecraft:ignore_vibrations_sneaking", "minecraft:vibrations"};
|
||||
private final EntityRewriter entityRewriter = new EntityPackets(this);
|
||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
||||
private final TagRewriter tagRewriter = new TagRewriter(this);
|
||||
private final EntityPackets entityRewriter = new EntityPackets(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
private final TagRewriter<ClientboundPackets1_16_2> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
public Protocol1_17To1_16_4() {
|
||||
super(ClientboundPackets1_16_2.class, ClientboundPackets1_17.class, ServerboundPackets1_16_2.class, ServerboundPackets1_17.class);
|
||||
@ -91,9 +89,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
}
|
||||
});
|
||||
|
||||
new StatisticsRewriter(this).register(ClientboundPackets1_16_2.STATISTICS);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_16_2.STATISTICS);
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
SoundRewriter<ClientboundPackets1_16_2> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND);
|
||||
|
||||
@ -246,12 +244,12 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public EntityPackets getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
public final class EntityPackets extends EntityRewriter<Protocol1_17To1_16_4> {
|
||||
public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2, Protocol1_17To1_16_4> {
|
||||
|
||||
public EntityPackets(Protocol1_17To1_16_4 protocol) {
|
||||
super(protocol);
|
||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.storage.InventoryAcknowledgements;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
public final class InventoryPackets extends ItemRewriter<Protocol1_17To1_16_4> {
|
||||
public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_16_2, ServerboundPackets1_17, Protocol1_17To1_16_4> {
|
||||
|
||||
public InventoryPackets(Protocol1_17To1_16_4 protocol) {
|
||||
super(protocol);
|
||||
@ -46,7 +46,7 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_17To1_16_4> {
|
||||
registerEntityEquipmentArray(ClientboundPackets1_16_2.ENTITY_EQUIPMENT);
|
||||
registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
|
||||
new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES);
|
||||
new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_16_2.DECLARE_RECIPES);
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
|
@ -39,7 +39,7 @@ import java.util.List;
|
||||
public final class WorldPackets {
|
||||
|
||||
public static void register(Protocol1_17To1_16_4 protocol) {
|
||||
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
|
||||
BlockRewriter<ClientboundPackets1_16_2> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
|
||||
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_16_2.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16_2.BLOCK_CHANGE);
|
||||
|
@ -37,7 +37,7 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
final TagRewriter tagRewriter = new TagRewriter(this);
|
||||
final TagRewriter<ClientboundPackets1_18> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:fall_damage_resetting");
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS);
|
||||
|
||||
|
@ -33,8 +33,6 @@ import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets.EntityPa
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets.InventoryPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets.WorldPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.storage.ChunkLightStorage;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
@ -42,8 +40,8 @@ import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPackets1_17_1, ClientboundPackets1_18, ServerboundPackets1_17, ServerboundPackets1_17> {
|
||||
|
||||
public static final MappingData MAPPINGS = new MappingData();
|
||||
private final EntityRewriter<Protocol1_18To1_17_1> entityRewriter = new EntityPackets(this);
|
||||
private final ItemRewriter<Protocol1_18To1_17_1> itemRewriter = new InventoryPackets(this);
|
||||
private final EntityPackets entityRewriter = new EntityPackets(this);
|
||||
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||
|
||||
public Protocol1_18To1_17_1() {
|
||||
super(ClientboundPackets1_17_1.class, ClientboundPackets1_18.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
|
||||
@ -55,11 +53,11 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
itemRewriter.register();
|
||||
WorldPackets.register(this);
|
||||
|
||||
final SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
final SoundRewriter<ClientboundPackets1_17_1> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerSound(ClientboundPackets1_17_1.SOUND);
|
||||
soundRewriter.registerSound(ClientboundPackets1_17_1.ENTITY_SOUND);
|
||||
|
||||
final TagRewriter tagRewriter = new TagRewriter(this);
|
||||
final TagRewriter<ClientboundPackets1_17_1> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_17_1.TAGS);
|
||||
tagRewriter.addEmptyTags(RegistryType.BLOCK, "minecraft:lava_pool_stone_cannot_replace", "minecraft:big_dripleaf_placeable",
|
||||
"minecraft:wolves_spawnable_on", "minecraft:rabbits_spawnable_on", "minecraft:polar_bears_spawnable_on_in_frozen_ocean", "minecraft:parrots_spawnable_on",
|
||||
@ -67,7 +65,7 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
"minecraft:azalea_grows_on", "minecraft:azalea_root_replaceable", "minecraft:replaceable_plants", "minecraft:terracotta");
|
||||
tagRewriter.addEmptyTags(RegistryType.ITEM, "minecraft:dirt", "minecraft:terracotta");
|
||||
|
||||
new StatisticsRewriter(this).register(ClientboundPackets1_17_1.STATISTICS);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_17_1.STATISTICS);
|
||||
|
||||
registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketRemapper() {
|
||||
@Override
|
||||
@ -108,12 +106,12 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter<Protocol1_18To1_17_1> getEntityRewriter() {
|
||||
public EntityPackets getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter<Protocol1_18To1_17_1> getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.storage.ChunkLightStorage;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
public final class EntityPackets extends EntityRewriter<Protocol1_18To1_17_1> {
|
||||
public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1, Protocol1_18To1_17_1> {
|
||||
|
||||
public EntityPackets(final Protocol1_18To1_17_1 protocol) {
|
||||
super(protocol);
|
||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_17_1;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
public final class InventoryPackets extends ItemRewriter<Protocol1_18To1_17_1> {
|
||||
public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_17_1, ServerboundPackets1_17, Protocol1_18To1_17_1> {
|
||||
|
||||
public InventoryPackets(Protocol1_18To1_17_1 protocol) {
|
||||
super(protocol);
|
||||
@ -97,7 +97,7 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_18To1_17_1> {
|
||||
}
|
||||
});
|
||||
|
||||
new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_17_1.DECLARE_RECIPES);
|
||||
new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_17_1.DECLARE_RECIPES);
|
||||
|
||||
registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW);
|
||||
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
@ -28,8 +28,6 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.BitSetType;
|
||||
import com.viaversion.viaversion.api.type.types.ByteArrayType;
|
||||
@ -48,7 +46,6 @@ import com.viaversion.viaversion.rewriter.CommandRewriter;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPackets1_19_1, ClientboundPackets1_19_3, ServerboundPackets1_19_1, ServerboundPackets1_19_3> {
|
||||
@ -68,7 +65,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
final TagRewriter tagRewriter = new TagRewriter(this);
|
||||
final TagRewriter<ClientboundPackets1_19_1> tagRewriter = new TagRewriter<>(this);
|
||||
|
||||
// Flint and steel was hardcoded before 1.19.3 to ignite a creeper; has been moved to a tag - adding this ensures offhand doesn't trigger as well
|
||||
tagRewriter.addTagRaw(RegistryType.ITEM, "minecraft:creeper_igniters", 733); // 733 = flint_and_steel 1.19.3
|
||||
@ -81,7 +78,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
entityRewriter.register();
|
||||
itemRewriter.register();
|
||||
|
||||
final SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
final SoundRewriter<ClientboundPackets1_19_1> soundRewriter = new SoundRewriter<>(this);
|
||||
registerClientbound(ClientboundPackets1_19_1.ENTITY_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -117,9 +114,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
}
|
||||
});
|
||||
|
||||
new StatisticsRewriter(this).register(ClientboundPackets1_19_1.STATISTICS);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_19_1.STATISTICS);
|
||||
|
||||
final CommandRewriter commandRewriter = new CommandRewriter(this) {
|
||||
final CommandRewriter<ClientboundPackets1_19_1> commandRewriter = new CommandRewriter<ClientboundPackets1_19_1>(this) {
|
||||
@Override
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) throws Exception {
|
||||
switch (argumentType) {
|
||||
@ -248,7 +245,7 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
create(Type.LONG, 0L);
|
||||
handler(wrapper -> {
|
||||
// Remove signature
|
||||
final byte[] signature = wrapper.read(OPTIONAL_MESSAGE_SIGNATURE_BYTES_TYPE);
|
||||
wrapper.read(OPTIONAL_MESSAGE_SIGNATURE_BYTES_TYPE); // Signature
|
||||
wrapper.write(Type.BYTE_ARRAY_PRIMITIVE, EMPTY_BYTES);
|
||||
wrapper.write(Type.BOOLEAN, false); // No signed preview
|
||||
|
||||
@ -315,12 +312,12 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public EntityPackets getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,14 @@ package com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.data;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||
|
||||
public class RecipeRewriter1_19_3 extends RecipeRewriter1_16 {
|
||||
public class RecipeRewriter1_19_3<C extends ClientboundPacketType> extends RecipeRewriter1_16<C> {
|
||||
|
||||
public RecipeRewriter1_19_3(final Protocol protocol) {
|
||||
public RecipeRewriter1_19_3(final Protocol<C, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
recipeHandlers.put("crafting_special_armordye", this::handleSimpleRecipe);
|
||||
recipeHandlers.put("crafting_special_bookcloning", this::handleSimpleRecipe);
|
||||
|
@ -34,7 +34,7 @@ import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import java.util.BitSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class EntityPackets extends EntityRewriter<Protocol1_19_3To1_19_1> {
|
||||
public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1, Protocol1_19_3To1_19_1> {
|
||||
|
||||
private static final BitSetType PROFILE_ACTIONS_ENUM_TYPE = new BitSetType(6);
|
||||
|
||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPac
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
public final class InventoryPackets extends ItemRewriter<Protocol1_19_3To1_19_1> {
|
||||
public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_19_1, ServerboundPackets1_19_3, Protocol1_19_3To1_19_1> {
|
||||
|
||||
private static final int MISC_CRAFTING_BOOK_CATEGORY = 0;
|
||||
|
||||
@ -38,7 +38,7 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_19_3To1_19_1>
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
final BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
|
||||
final BlockRewriter<ClientboundPackets1_19_1> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_19_1.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_19_1.BLOCK_CHANGE);
|
||||
blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_19_1.MULTI_BLOCK_CHANGE);
|
||||
@ -57,7 +57,7 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_19_3To1_19_1>
|
||||
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_1.WINDOW_PROPERTY);
|
||||
registerSpawnParticle1_19(ClientboundPackets1_19_1.SPAWN_PARTICLE);
|
||||
|
||||
final RecipeRewriter1_16 recipeRewriter = new RecipeRewriter1_16(protocol);
|
||||
final RecipeRewriter1_16<ClientboundPackets1_19_1> recipeRewriter = new RecipeRewriter1_16<>(protocol);
|
||||
protocol.registerClientbound(ClientboundPackets1_19_1.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -41,7 +41,7 @@ public final class Protocol1_19_4To1_19_3 extends AbstractProtocol<ClientboundPa
|
||||
protected void registerPackets() {
|
||||
entityRewriter.register();
|
||||
|
||||
final CommandRewriter commandRewriter = new CommandRewriter(this) {
|
||||
final CommandRewriter<ClientboundPackets1_19_3> commandRewriter = new CommandRewriter<ClientboundPackets1_19_3>(this) {
|
||||
@Override
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) throws Exception {
|
||||
if (argumentType.equals("minecraft:time")) {
|
||||
|
@ -31,7 +31,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPac
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.Protocol1_19_4To1_19_3;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
public final class EntityPackets extends EntityRewriter<Protocol1_19_4To1_19_3> {
|
||||
public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3, Protocol1_19_4To1_19_3> {
|
||||
|
||||
public EntityPackets(final Protocol1_19_4To1_19_3 protocol) {
|
||||
super(protocol);
|
||||
|
@ -18,12 +18,13 @@
|
||||
package com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.rewriter.CommandRewriter;
|
||||
|
||||
public class CommandRewriter1_19_3 extends CommandRewriter {
|
||||
public class CommandRewriter1_19_3<C extends ClientboundPacketType> extends CommandRewriter<C> {
|
||||
|
||||
public CommandRewriter1_19_3(Protocol<?, ?, ?, ?> protocol) {
|
||||
public CommandRewriter1_19_3(Protocol<C, ?, ?, ?> protocol) {
|
||||
super(protocol);
|
||||
this.parserHandlers.put("minecraft:time", wrapper -> wrapper.passthrough(Type.INT)); // Minimum
|
||||
}
|
||||
|
@ -26,8 +26,6 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||
@ -51,7 +49,6 @@ import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import com.viaversion.viaversion.util.CipherUtil;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPackets1_18, ClientboundPackets1_19, ServerboundPackets1_17, ServerboundPackets1_19> {
|
||||
@ -70,7 +67,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
final TagRewriter tagRewriter = new TagRewriter(this);
|
||||
final TagRewriter<ClientboundPackets1_18> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS);
|
||||
|
||||
entityRewriter.register();
|
||||
@ -79,7 +76,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
|
||||
cancelClientbound(ClientboundPackets1_18.ADD_VIBRATION_SIGNAL);
|
||||
|
||||
final SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
final SoundRewriter<ClientboundPackets1_18> soundRewriter = new SoundRewriter<>(this);
|
||||
registerClientbound(ClientboundPackets1_18.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -120,7 +117,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
}
|
||||
});
|
||||
|
||||
new StatisticsRewriter(this).register(ClientboundPackets1_18.STATISTICS);
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_18.STATISTICS);
|
||||
|
||||
final PacketHandler titleHandler = wrapper -> {
|
||||
final JsonElement component = wrapper.read(Type.COMPONENT);
|
||||
@ -143,7 +140,7 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
}
|
||||
});
|
||||
|
||||
final CommandRewriter commandRewriter = new CommandRewriter(this);
|
||||
final CommandRewriter<ClientboundPackets1_18> commandRewriter = new CommandRewriter<>(this);
|
||||
registerClientbound(ClientboundPackets1_18.DECLARE_COMMANDS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -320,12 +317,12 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRewriter getEntityRewriter() {
|
||||
public EntityPackets getEntityRewriter() {
|
||||
return entityRewriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter getItemRewriter() {
|
||||
public InventoryPackets getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> {
|
||||
public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18, Protocol1_19To1_18_2> {
|
||||
|
||||
private static final String CHAT_REGISTRY_SNBT = "{\n" +
|
||||
" \"minecraft:chat_type\": {\n" +
|
||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ServerboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.provider.AckSequenceProvider;
|
||||
import com.viaversion.viaversion.rewriter.ItemRewriter;
|
||||
|
||||
public final class InventoryPackets extends ItemRewriter<Protocol1_19To1_18_2> {
|
||||
public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_18, ServerboundPackets1_19, Protocol1_19To1_18_2> {
|
||||
|
||||
public InventoryPackets(Protocol1_19To1_18_2 protocol) {
|
||||
super(protocol);
|
||||
@ -122,7 +122,7 @@ public final class InventoryPackets extends ItemRewriter<Protocol1_19To1_18_2> {
|
||||
}
|
||||
});
|
||||
|
||||
new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_18.DECLARE_RECIPES);
|
||||
new RecipeRewriter1_16<>(protocol).registerDefaultHandler(ClientboundPackets1_18.DECLARE_RECIPES);
|
||||
}
|
||||
|
||||
private PacketHandler sequenceHandler() {
|
||||
|
@ -35,7 +35,7 @@ import com.viaversion.viaversion.util.MathUtil;
|
||||
public final class WorldPackets {
|
||||
|
||||
public static void register(final Protocol1_19To1_18_2 protocol) {
|
||||
final BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
|
||||
final BlockRewriter<ClientboundPackets1_18> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_18.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_18.BLOCK_CHANGE);
|
||||
blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_18.MULTI_BLOCK_CHANGE);
|
||||
|
@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
@ -33,7 +34,7 @@ import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MetadataRewriter1_9To1_8 extends EntityRewriter<Protocol1_9To1_8> {
|
||||
public class MetadataRewriter1_9To1_8 extends EntityRewriter<ClientboundPackets1_8, Protocol1_9To1_8> {
|
||||
|
||||
public MetadataRewriter1_9To1_8(Protocol1_9To1_8 protocol) {
|
||||
super(protocol);
|
||||
@ -99,8 +100,6 @@ public class MetadataRewriter1_9To1_8 extends EntityRewriter<Protocol1_9To1_8> {
|
||||
}
|
||||
break;
|
||||
case Float:
|
||||
metadata.setValue(value);
|
||||
break;
|
||||
case String:
|
||||
metadata.setValue(value);
|
||||
break;
|
||||
|
@ -35,16 +35,16 @@ import com.viaversion.viaversion.util.MathUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockRewriter {
|
||||
private final Protocol protocol;
|
||||
public class BlockRewriter<C extends ClientboundPacketType> {
|
||||
private final Protocol<C, ?, ?, ?> protocol;
|
||||
private final Type<Position> positionType;
|
||||
|
||||
public BlockRewriter(Protocol protocol, Type<Position> positionType) {
|
||||
public BlockRewriter(Protocol<C, ?, ?, ?> protocol, Type<Position> positionType) {
|
||||
this.protocol = protocol;
|
||||
this.positionType = positionType;
|
||||
}
|
||||
|
||||
public void registerBlockAction(ClientboundPacketType packetType) {
|
||||
public void registerBlockAction(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -67,7 +67,7 @@ public class BlockRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerBlockChange(ClientboundPacketType packetType) {
|
||||
public void registerBlockChange(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -78,7 +78,7 @@ public class BlockRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerMultiBlockChange(ClientboundPacketType packetType) {
|
||||
public void registerMultiBlockChange(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -93,7 +93,7 @@ public class BlockRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerVarLongMultiBlockChange(ClientboundPacketType packetType) {
|
||||
public void registerVarLongMultiBlockChange(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -108,12 +108,12 @@ public class BlockRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerAcknowledgePlayerDigging(ClientboundPacketType packetType) {
|
||||
public void registerAcknowledgePlayerDigging(C packetType) {
|
||||
// Same exact handler
|
||||
registerBlockChange(packetType);
|
||||
}
|
||||
|
||||
public void registerEffect(ClientboundPacketType packetType, int playRecordId, int blockBreakId) {
|
||||
public void registerEffect(C packetType, int playRecordId, int blockBreakId) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -133,7 +133,7 @@ public class BlockRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerChunkData1_19(ClientboundPacketType packetType, ChunkTypeSupplier chunkTypeSupplier) {
|
||||
public void registerChunkData1_19(C packetType, ChunkTypeSupplier chunkTypeSupplier) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -166,7 +166,7 @@ public class BlockRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerBlockEntityData(ClientboundPacketType packetType) {
|
||||
public void registerBlockEntityData(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -29,11 +29,11 @@ import java.util.Map;
|
||||
/**
|
||||
* Abstract rewriter for the declare commands packet to handle argument type name and content changes.
|
||||
*/
|
||||
public class CommandRewriter {
|
||||
protected final Protocol protocol;
|
||||
public class CommandRewriter<C extends ClientboundPacketType> {
|
||||
protected final Protocol<C, ?, ?, ?> protocol;
|
||||
protected final Map<String, CommandArgumentConsumer> parserHandlers = new HashMap<>();
|
||||
|
||||
public CommandRewriter(Protocol protocol) {
|
||||
public CommandRewriter(Protocol<C, ?, ?, ?> protocol) {
|
||||
this.protocol = protocol;
|
||||
|
||||
// Register default parsers
|
||||
@ -57,30 +57,16 @@ public class CommandRewriter {
|
||||
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.LONG); // Min Value
|
||||
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.LONG); // Max Value
|
||||
});
|
||||
this.parserHandlers.put("brigadier:string", wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT); // Flags
|
||||
});
|
||||
this.parserHandlers.put("minecraft:entity", wrapper -> {
|
||||
wrapper.passthrough(Type.BYTE); // Flags
|
||||
});
|
||||
this.parserHandlers.put("minecraft:score_holder", wrapper -> {
|
||||
wrapper.passthrough(Type.BYTE); // Flags
|
||||
});
|
||||
this.parserHandlers.put("minecraft:resource", wrapper -> {
|
||||
wrapper.passthrough(Type.STRING); // Resource location
|
||||
});
|
||||
this.parserHandlers.put("minecraft:resource_or_tag", wrapper -> {
|
||||
wrapper.passthrough(Type.STRING); // Resource location/tag
|
||||
});
|
||||
this.parserHandlers.put("minecraft:resource_or_tag_key", wrapper -> {
|
||||
wrapper.passthrough(Type.STRING); // Resource location
|
||||
});
|
||||
this.parserHandlers.put("minecraft:resource_key", wrapper -> {
|
||||
wrapper.passthrough(Type.STRING); // Resource location/tag
|
||||
});
|
||||
this.parserHandlers.put("brigadier:string", wrapper -> wrapper.passthrough(Type.VAR_INT)); // Flags
|
||||
this.parserHandlers.put("minecraft:entity", wrapper -> wrapper.passthrough(Type.BYTE)); // Flags
|
||||
this.parserHandlers.put("minecraft:score_holder", wrapper -> wrapper.passthrough(Type.BYTE)); // Flags
|
||||
this.parserHandlers.put("minecraft:resource", wrapper -> wrapper.passthrough(Type.STRING)); // Resource location
|
||||
this.parserHandlers.put("minecraft:resource_or_tag", wrapper -> wrapper.passthrough(Type.STRING)); // Resource location/tag
|
||||
this.parserHandlers.put("minecraft:resource_or_tag_key", wrapper -> wrapper.passthrough(Type.STRING)); // Resource location
|
||||
this.parserHandlers.put("minecraft:resource_key", wrapper -> wrapper.passthrough(Type.STRING)); // Resource location/tag
|
||||
}
|
||||
|
||||
public void registerDeclareCommands(ClientboundPacketType packetType) {
|
||||
public void registerDeclareCommands(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -120,7 +106,7 @@ public class CommandRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void registerDeclareCommands1_19(ClientboundPacketType packetType) {
|
||||
public void registerDeclareCommands1_19(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -32,10 +32,10 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
* Handles json chat components, containing methods to override certain parts of the handling.
|
||||
* Also contains methods to register a few of the packets using components.
|
||||
*/
|
||||
public class ComponentRewriter {
|
||||
protected final Protocol protocol;
|
||||
public class ComponentRewriter<C extends ClientboundPacketType> {
|
||||
protected final Protocol<C, ?, ?, ?> protocol;
|
||||
|
||||
public ComponentRewriter(Protocol protocol) {
|
||||
public ComponentRewriter(Protocol<C, ?, ?, ?> protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public class ComponentRewriter {
|
||||
*
|
||||
* @param packetType clientbound packet type
|
||||
*/
|
||||
public void registerComponentPacket(ClientboundPacketType packetType) {
|
||||
public void registerComponentPacket(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -62,11 +62,11 @@ public class ComponentRewriter {
|
||||
}
|
||||
|
||||
@Deprecated/*(forRemoval = true)**/
|
||||
public void registerChatMessage(ClientboundPacketType packetType) {
|
||||
public void registerChatMessage(C packetType) {
|
||||
registerComponentPacket(packetType);
|
||||
}
|
||||
|
||||
public void registerBossBar(ClientboundPacketType packetType) {
|
||||
public void registerBossBar(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -85,7 +85,7 @@ public class ComponentRewriter {
|
||||
/**
|
||||
* Handles sub 1.17 combat event components.
|
||||
*/
|
||||
public void registerCombatEvent(ClientboundPacketType packetType) {
|
||||
public void registerCombatEvent(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -103,7 +103,7 @@ public class ComponentRewriter {
|
||||
/**
|
||||
* Handles sub 1.17 title components.
|
||||
*/
|
||||
public void registerTitle(ClientboundPacketType packetType) {
|
||||
public void registerTitle(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -198,7 +198,7 @@ public class ComponentRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends Protocol> T getProtocol() {
|
||||
public <T extends Protocol<C, ?, ?, ?>> T getProtocol() {
|
||||
return (T) protocol;
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,8 @@ import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T> implements com.viaversion.viaversion.api.rewriter.EntityRewriter<T> {
|
||||
public abstract class EntityRewriter<C extends ClientboundPacketType, T extends Protocol<C, ?, ?, ?>>
|
||||
extends RewriterBase<T> implements com.viaversion.viaversion.api.rewriter.EntityRewriter<T> {
|
||||
private static final Metadata[] EMPTY_ARRAY = new Metadata[0];
|
||||
protected final List<MetaFilter> metadataFilters = new ArrayList<>();
|
||||
protected final boolean trackMappedType;
|
||||
@ -245,7 +246,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTracker(ClientboundPacketType packetType) {
|
||||
public void registerTracker(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -257,7 +258,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType) {
|
||||
public void registerTrackerWithData(C packetType, EntityType fallingBlockType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -282,7 +283,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTrackerWithData1_19(ClientboundPacketType packetType, EntityType fallingBlockType) {
|
||||
public void registerTrackerWithData1_19(C packetType, EntityType fallingBlockType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -315,7 +316,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
* @param entityType entity type
|
||||
* @param intType int type of the entity id
|
||||
*/
|
||||
public void registerTracker(ClientboundPacketType packetType, EntityType entityType, Type<Integer> intType) {
|
||||
public void registerTracker(C packetType, EntityType entityType, Type<Integer> intType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -333,7 +334,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
* @param packetType packet type
|
||||
* @param entityType entity type
|
||||
*/
|
||||
public void registerTracker(ClientboundPacketType packetType, EntityType entityType) {
|
||||
public void registerTracker(C packetType, EntityType entityType) {
|
||||
registerTracker(packetType, entityType, Type.VAR_INT);
|
||||
}
|
||||
|
||||
@ -342,7 +343,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
*
|
||||
* @param packetType remove entities packet type
|
||||
*/
|
||||
public void registerRemoveEntities(ClientboundPacketType packetType) {
|
||||
public void registerRemoveEntities(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -362,7 +363,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
*
|
||||
* @param packetType remove entities packet type
|
||||
*/
|
||||
public void registerRemoveEntity(ClientboundPacketType packetType) {
|
||||
public void registerRemoveEntity(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -374,7 +375,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
});
|
||||
}
|
||||
|
||||
public void registerMetadataRewriter(ClientboundPacketType packetType, @Nullable Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
public void registerMetadataRewriter(C packetType, @Nullable Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -393,7 +394,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
});
|
||||
}
|
||||
|
||||
public void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> metaType) {
|
||||
public void registerMetadataRewriter(C packetType, Type<List<Metadata>> metaType) {
|
||||
registerMetadataRewriter(packetType, null, metaType);
|
||||
}
|
||||
|
||||
|
@ -29,14 +29,15 @@ import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> implements com.viaversion.viaversion.api.rewriter.ItemRewriter<T> {
|
||||
public abstract class ItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
T extends Protocol<C, ?, ?, S>> extends RewriterBase<T> implements com.viaversion.viaversion.api.rewriter.ItemRewriter<T> {
|
||||
|
||||
protected ItemRewriter(T protocol) {
|
||||
super(protocol);
|
||||
}
|
||||
|
||||
// These two methods always return the same item instance *for now*
|
||||
// It is made this way so it's easy to handle new instance creation/implementation changes
|
||||
// It is made this way, so it's easy to handle new instance creation/implementation changes
|
||||
@Override
|
||||
public @Nullable Item handleItemToClient(@Nullable Item item) {
|
||||
if (item == null) return null;
|
||||
@ -55,7 +56,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
return item;
|
||||
}
|
||||
|
||||
public void registerWindowItems(ClientboundPacketType packetType, Type<Item[]> type) {
|
||||
public void registerWindowItems(C packetType, Type<Item[]> type) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -66,7 +67,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerWindowItems1_17_1(ClientboundPacketType packetType) {
|
||||
public void registerWindowItems1_17_1(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -84,7 +85,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerSetSlot(ClientboundPacketType packetType, Type<Item> type) {
|
||||
public void registerSetSlot(C packetType, Type<Item> type) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -96,7 +97,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerSetSlot1_17_1(ClientboundPacketType packetType) {
|
||||
public void registerSetSlot1_17_1(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -110,7 +111,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
}
|
||||
|
||||
// Sub 1.16
|
||||
public void registerEntityEquipment(ClientboundPacketType packetType, Type<Item> type) {
|
||||
public void registerEntityEquipment(C packetType, Type<Item> type) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -124,7 +125,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
}
|
||||
|
||||
// 1.16+
|
||||
public void registerEntityEquipmentArray(ClientboundPacketType packetType) {
|
||||
public void registerEntityEquipmentArray(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -142,7 +143,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCreativeInvAction(ServerboundPacketType packetType, Type<Item> type) {
|
||||
public void registerCreativeInvAction(S packetType, Type<Item> type) {
|
||||
protocol.registerServerbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -154,7 +155,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerClickWindow(ServerboundPacketType packetType, Type<Item> type) {
|
||||
public void registerClickWindow(S packetType, Type<Item> type) {
|
||||
protocol.registerServerbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -170,7 +171,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerClickWindow1_17_1(ServerboundPacketType packetType) {
|
||||
public void registerClickWindow1_17_1(S packetType) {
|
||||
protocol.registerServerbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -195,7 +196,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerSetCooldown(ClientboundPacketType packetType) {
|
||||
public void registerSetCooldown(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -208,7 +209,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
}
|
||||
|
||||
// 1.14.4+
|
||||
public void registerTradeList(ClientboundPacketType packetType) {
|
||||
public void registerTradeList(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -238,7 +239,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerTradeList1_19(ClientboundPacketType packetType) {
|
||||
public void registerTradeList1_19(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -264,7 +265,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerAdvancements(ClientboundPacketType packetType, Type<Item> type) {
|
||||
public void registerAdvancements(C packetType, Type<Item> type) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -304,7 +305,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerWindowPropertyEnchantmentHandler(ClientboundPacketType packetType) {
|
||||
public void registerWindowPropertyEnchantmentHandler(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -322,7 +323,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
}
|
||||
|
||||
// Not the very best place for this, but has to stay here until *everything* is abstracted
|
||||
public void registerSpawnParticle(ClientboundPacketType packetType, Type<Item> itemType, Type<?> coordType) {
|
||||
public void registerSpawnParticle(C packetType, Type<Item> itemType, Type<?> coordType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -341,7 +342,7 @@ public abstract class ItemRewriter<T extends Protocol> extends RewriterBase<T> i
|
||||
});
|
||||
}
|
||||
|
||||
public void registerSpawnParticle1_19(ClientboundPacketType packetType) {
|
||||
public void registerSpawnParticle1_19(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -28,12 +28,12 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class RecipeRewriter {
|
||||
public abstract class RecipeRewriter<C extends ClientboundPacketType> {
|
||||
|
||||
protected final Protocol protocol;
|
||||
protected final Protocol<C, ?, ?, ?> protocol;
|
||||
protected final Map<String, RecipeConsumer> recipeHandlers = new HashMap<>();
|
||||
|
||||
protected RecipeRewriter(Protocol protocol) {
|
||||
protected RecipeRewriter(Protocol<C, ?, ?, ?> protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public abstract class RecipeRewriter {
|
||||
}
|
||||
}
|
||||
|
||||
public void registerDefaultHandler(ClientboundPacketType packetType) {
|
||||
public void registerDefaultHandler(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -52,7 +52,7 @@ public abstract class RecipeRewriter {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
String id = wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
handle(wrapper, type);
|
||||
}
|
||||
});
|
||||
|
@ -23,22 +23,22 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public class SoundRewriter {
|
||||
protected final Protocol protocol;
|
||||
public class SoundRewriter<C extends ClientboundPacketType> {
|
||||
protected final Protocol<C, ?, ?, ?> protocol;
|
||||
protected final IdRewriteFunction idRewriter;
|
||||
|
||||
public SoundRewriter(Protocol protocol) {
|
||||
public SoundRewriter(Protocol<C, ?, ?, ?> protocol) {
|
||||
this.protocol = protocol;
|
||||
this.idRewriter = id -> protocol.getMappingData().getSoundMappings().getNewId(id);
|
||||
}
|
||||
|
||||
public SoundRewriter(Protocol protocol, IdRewriteFunction idRewriter) {
|
||||
public SoundRewriter(Protocol<C, ?, ?, ?> protocol, IdRewriteFunction idRewriter) {
|
||||
this.protocol = protocol;
|
||||
this.idRewriter = idRewriter;
|
||||
}
|
||||
|
||||
// The same for entity sound
|
||||
public void registerSound(ClientboundPacketType packetType) {
|
||||
public void registerSound(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -48,7 +48,7 @@ public class SoundRewriter {
|
||||
});
|
||||
}
|
||||
|
||||
public void register1_19_3Sound(ClientboundPacketType packetType) {
|
||||
public void register1_19_3Sound(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -24,15 +24,15 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class StatisticsRewriter {
|
||||
private final Protocol protocol;
|
||||
private final int customStatsCategory = 8; // Make this changeable if it differs in a future version
|
||||
public class StatisticsRewriter<C extends ClientboundPacketType> {
|
||||
private static final int CUSTOM_STATS_CATEGORY = 8; // Make this changeable if it differs in a future version
|
||||
private final Protocol<C, ?, ?, ?> protocol;
|
||||
|
||||
public StatisticsRewriter(Protocol protocol) {
|
||||
public StatisticsRewriter(Protocol<C, ?, ?, ?> protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public void register(ClientboundPacketType packetType) {
|
||||
public void register(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -43,7 +43,7 @@ public class StatisticsRewriter {
|
||||
int categoryId = wrapper.read(Type.VAR_INT);
|
||||
int statisticId = wrapper.read(Type.VAR_INT);
|
||||
int value = wrapper.read(Type.VAR_INT);
|
||||
if (categoryId == customStatsCategory && protocol.getMappingData().getStatisticsMappings() != null) {
|
||||
if (categoryId == CUSTOM_STATS_CATEGORY && protocol.getMappingData().getStatisticsMappings() != null) {
|
||||
// Rewrite custom statistics id
|
||||
statisticId = protocol.getMappingData().getStatisticsMappings().getNewId(statisticId);
|
||||
if (statisticId == -1) {
|
||||
|
@ -39,14 +39,14 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class TagRewriter {
|
||||
public class TagRewriter<C extends ClientboundPacketType> {
|
||||
private static final int[] EMPTY_ARRAY = {};
|
||||
private final Protocol protocol;
|
||||
private final Protocol<C, ?, ?, ?> protocol;
|
||||
private final Map<RegistryType, List<TagData>> newTags = new EnumMap<>(RegistryType.class);
|
||||
private final Map<RegistryType, Map<String, String>> toRename = new EnumMap<>(RegistryType.class);
|
||||
private final Set<String> toRemove = new HashSet<>();
|
||||
|
||||
public TagRewriter(Protocol protocol) {
|
||||
public TagRewriter(Protocol<C, ?, ?, ?> protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ public class TagRewriter {
|
||||
* @param packetType packet type
|
||||
* @param readUntilType read and process the types until (including) the given registry type
|
||||
*/
|
||||
public void register(ClientboundPacketType packetType, @Nullable RegistryType readUntilType) {
|
||||
public void register(C packetType, @Nullable RegistryType readUntilType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -149,7 +149,7 @@ public class TagRewriter {
|
||||
*
|
||||
* @param packetType packet type
|
||||
*/
|
||||
public void registerGeneric(ClientboundPacketType packetType) {
|
||||
public void registerGeneric(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren