Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-24 15:20:19 +01:00
Greatly reduce the number of inner classes
Dieser Commit ist enthalten in:
Ursprung
8715c243c9
Commit
82c01c4b2d
@ -18,14 +18,13 @@
|
||||
package com.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viaversion.util.Config;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class ViaBackwardsConfig extends Config implements com.viaversion.viabackwards.api.ViaBackwardsConfig {
|
||||
|
||||
|
@ -55,7 +55,6 @@ import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.update.Version;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -26,10 +26,9 @@ import com.viaversion.viaversion.api.data.Mappings;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class BackwardsMappings extends MappingDataBase {
|
||||
|
||||
|
@ -29,8 +29,6 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.libs.gson.JsonSyntaxException;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@ -38,6 +36,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class VBMappingDataLoader {
|
||||
|
||||
|
@ -20,7 +20,6 @@ package com.viaversion.viabackwards.api.data;
|
||||
import com.viaversion.viaversion.api.data.IntArrayMappings;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class VBMappings extends IntArrayMappings {
|
||||
|
@ -22,9 +22,8 @@ import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class EntityData {
|
||||
private final BackwardsProtocol<?, ?, ?, ?> protocol;
|
||||
|
@ -24,7 +24,6 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class EntityPositionHandler {
|
||||
|
@ -19,9 +19,8 @@
|
||||
package com.viaversion.viabackwards.api.entities.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class WrappedMetadata {
|
||||
private final List<Metadata> metadataList;
|
||||
|
@ -25,7 +25,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
|
||||
@ -40,9 +40,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
|
||||
@Override
|
||||
public void registerTrackerWithData(C packetType, EntityType fallingBlockType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
@ -59,9 +59,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
|
||||
@Override
|
||||
public void registerTrackerWithData1_19(C packetType, EntityType fallingBlockType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
map(Type.UUID); // Entity UUID
|
||||
map(Type.VAR_INT); // Entity type
|
||||
@ -100,9 +100,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
||||
}
|
||||
|
||||
public void registerSpawnTracker(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
|
@ -67,15 +67,15 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
public void handleMetadata(int entityId, List<Metadata> metadataList, UserConnection connection) {
|
||||
final TrackedEntity entity = tracker(connection).entity(entityId);
|
||||
final boolean initialMetadata = !(entity != null && entity.hasSentMetadata());
|
||||
|
||||
super.handleMetadata(entityId, metadataList, connection);
|
||||
|
||||
if (entity == null) {
|
||||
return; // Don't handle untracked entities - basically always the fault of a plugin sending virtual entities through concurrency-unsafe handling
|
||||
}
|
||||
|
||||
final EntityData entityData = entityDataForType(entity.entityType());
|
||||
|
||||
// Set the mapped entity name if there is no custom name set already
|
||||
final EntityData entityData = entityDataForType(entity.entityType());
|
||||
if (entityData != null && entityData.mobName() != null) {
|
||||
final Metadata displayName = getMeta(displayNameIndex, metadataList);
|
||||
if (initialMetadata) {
|
||||
|
@ -22,7 +22,7 @@ import com.viaversion.viabackwards.api.data.MappedItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
@ -122,9 +122,9 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
|
||||
@Override
|
||||
public void registerAdvancements(C packetType, Type<Item> type) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
final int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
@ -42,10 +42,9 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriterBase<C, S, T> {
|
||||
|
@ -25,7 +25,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -30,15 +30,14 @@ import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T extends BackwardsProtocol<C, ?, ?, ?>> extends EntityRewriterBase<C, T> {
|
||||
private final Map<ObjectType, EntityData> objectTypes = new HashMap<>();
|
||||
@ -62,9 +61,9 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
|
||||
}
|
||||
|
||||
protected void registerRespawn(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
@ -75,9 +74,9 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
|
||||
}
|
||||
|
||||
protected void registerJoinGame(C packetType, EntityType playerType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
@ -92,9 +91,9 @@ public abstract class LegacyEntityRewriter<C extends ClientboundPacketType, T ex
|
||||
|
||||
@Override
|
||||
public void registerMetadataRewriter(C packetType, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
if (oldMetaType != null) {
|
||||
map(oldMetaType, newMetaType);
|
||||
|
@ -20,7 +20,7 @@ package com.viaversion.viabackwards.api.rewriters;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
||||
public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversion.viaversion.rewriter.SoundRewriter<C> {
|
||||
@ -33,9 +33,9 @@ public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversi
|
||||
}
|
||||
|
||||
public void registerNamedSound(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Sound identifier
|
||||
handler(getNamedSoundHandler());
|
||||
}
|
||||
@ -43,9 +43,9 @@ public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversi
|
||||
}
|
||||
|
||||
public void registerStopSound(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
handler(getStopSoundHandler());
|
||||
}
|
||||
});
|
||||
|
@ -22,12 +22,11 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.VBMappingDataLoader;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.rewriter.ComponentRewriter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -63,27 +62,17 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
|
||||
}
|
||||
|
||||
public void registerPing() {
|
||||
protocol.registerClientbound(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
protocol.registerClientbound(State.LOGIN, 0x00, 0x00, wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
|
||||
public void registerDisconnect(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
});
|
||||
protocol.registerClientbound(packetType, wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
}
|
||||
|
||||
public void registerLegacyOpenWindow(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window Type
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
@ -92,9 +81,9 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
|
||||
}
|
||||
|
||||
public void registerOpenWindow(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
@ -103,21 +92,16 @@ public class TranslatableRewriter<C extends ClientboundPacketType> extends Compo
|
||||
}
|
||||
|
||||
public void registerTabList(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(packetType, wrapper -> {
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
processText(wrapper.passthrough(Type.COMPONENT));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerCombatKill(C packetType) {
|
||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
|
@ -34,7 +34,7 @@ import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
@ -45,7 +45,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 java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -59,9 +58,9 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SET_SLOT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SET_SLOT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.ITEM); // 2 - Slot Value
|
||||
@ -86,15 +85,13 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.WINDOW_ITEMS, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.WINDOW_ITEMS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.ITEM_ARRAY); // 1 - Window Values
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0);
|
||||
for (int i = 0; i < stacks.length; i++)
|
||||
stacks[i] = handleItemToClient(stacks[i]);
|
||||
@ -112,7 +109,6 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
}
|
||||
wrapper.set(Type.ITEM_ARRAY, 0, stacks);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -120,14 +116,12 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
@ -146,14 +140,13 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
@ -164,9 +157,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
handler(itemToServerHandler(Type.ITEM));
|
||||
|
||||
// Llama slot
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
if (isLlama(wrapper.user())) {
|
||||
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
|
||||
if (!horse.isPresent())
|
||||
@ -177,19 +168,13 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
|
||||
wrapper.set(Type.SHORT, 0, ((Integer) correctSlot).shortValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
||||
@ -207,55 +192,44 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
((StringTag) idTag).setValue("Sign");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.MULTI_BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||
map(Type.NBT); // 2 - NBT
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
// Remove on shulkerbox decleration
|
||||
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 10) {
|
||||
wrapper.cancel();
|
||||
@ -265,22 +239,19 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
CompoundTag tag = wrapper.get(Type.NBT, 0);
|
||||
EntityIdRewriter.toClientSpawner(tag, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.OPEN_WINDOW, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.OPEN_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.STRING); // 1 - Window Type
|
||||
map(Type.COMPONENT); // 2 - Title
|
||||
map(Type.UNSIGNED_BYTE); // 3 - Slots
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int entityId = -1;
|
||||
// Passthrough Entity ID
|
||||
if (wrapper.get(Type.STRING, 0).equals("EntityHorse")) {
|
||||
@ -297,38 +268,31 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
if (isLlama(wrapper.user())) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 1, (short) 17);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CLOSE_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
// Inventory tracking
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
|
||||
windowTracker.setInventory(null);
|
||||
windowTracker.setEntityId(-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLOSE_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLOSE_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
// Inventory tracking
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
|
||||
windowTracker.setInventory(null);
|
||||
windowTracker.setEntityId(-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -31,13 +31,10 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -49,9 +46,9 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.EFFECT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.EFFECT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT);
|
||||
map(Type.POSITION);
|
||||
map(Type.INT);
|
||||
@ -72,9 +69,9 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
@ -90,9 +87,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null)));
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
@ -105,7 +100,6 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -113,9 +107,9 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 2 - Entity Type
|
||||
@ -161,9 +155,9 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
@ -187,15 +181,13 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerRemoveEntities(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.ENTITY_STATUS, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.ENTITY_STATUS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.BYTE); // 1 - Entity Status
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
byte b = wrapper.get(Type.BYTE, 0);
|
||||
|
||||
if (b == 35) {
|
||||
@ -204,7 +196,6 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 10); // Play Elder Guardian animation
|
||||
wrapper.write(Type.FLOAT, 0F);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_10to1_11.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -39,9 +39,9 @@ public class PlayerPackets1_11 {
|
||||
};
|
||||
|
||||
public void register(Protocol1_10To1_11 protocol) {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.TITLE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.TITLE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Action
|
||||
|
||||
handler(wrapper -> {
|
||||
@ -67,9 +67,9 @@ public class PlayerPackets1_11 {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Collected entity id
|
||||
map(Type.VAR_INT); // 1 - Collector entity id
|
||||
|
||||
@ -78,9 +78,9 @@ public class PlayerPackets1_11 {
|
||||
});
|
||||
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Location
|
||||
map(Type.VAR_INT); // 1 - Face
|
||||
map(Type.VAR_INT); // 2 - Hand
|
||||
|
@ -27,7 +27,6 @@ import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.EntityP
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets.SoundPackets1_12;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -60,18 +59,13 @@ public class Protocol1_11_1To1_12 extends BackwardsProtocol<ClientboundPackets1_
|
||||
new SoundPackets1_12(this).register();
|
||||
new ChatPackets1_12(this).register();
|
||||
|
||||
registerClientbound(ClientboundPackets1_12.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_12.TITLE, wrapper -> {
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action >= 0 && action <= 2) {
|
||||
JsonElement component = wrapper.read(Type.COMPONENT);
|
||||
wrapper.write(Type.COMPONENT, Protocol1_9To1_8.fixJson(component.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cancelClientbound(ClientboundPackets1_12.ADVANCEMENTS);
|
||||
cancelClientbound(ClientboundPackets1_12.UNLOCK_RECIPES);
|
||||
|
@ -25,8 +25,7 @@ import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||
@ -37,10 +36,9 @@ import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
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 org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPackets1_12, ServerboundPackets1_9_3, Protocol1_11_1To1_12> {
|
||||
|
||||
@ -50,9 +48,9 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.MAP_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.MAP_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.BYTE);
|
||||
map(Type.BOOLEAN);
|
||||
@ -87,14 +85,12 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
registerEntityEquipment(ClientboundPackets1_12.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
@ -112,14 +108,13 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLICK_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
@ -127,9 +122,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.ITEM); // 5 - Clicked Item
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.VAR_INT, 0) == 1) { // Shift click
|
||||
// https://github.com/ViaVersion/ViaVersion/pull/754
|
||||
// Previously clients grab the item from the clicked slot *before* it has
|
||||
@ -151,78 +144,60 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
}
|
||||
Item item = wrapper.get(Type.ITEM, 0);
|
||||
handleItemToServer(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.9.4 Chunk type since nothing changed.
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.MULTI_BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||
map(Type.NBT); // 2 - NBT
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
// Remove bed color
|
||||
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 11)
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -232,19 +207,16 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
meta.setValue(handleItemToClient((Item) meta.getValue()));
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLIENT_STATUS, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9_3.CLIENT_STATUS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Action ID
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
// Open Inventory
|
||||
if (wrapper.get(Type.VAR_INT, 0) == 2) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -20,7 +20,6 @@ package com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.data.AdvancementTranslations;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -46,14 +45,9 @@ public class ChatPackets1_12 extends RewriterBase<Protocol1_11_1To1_12> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHAT_MESSAGE, wrapper -> {
|
||||
JsonElement element = wrapper.passthrough(Type.COMPONENT);
|
||||
componentRewriter.processText(element);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -29,13 +29,11 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -47,9 +45,9 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
@ -65,9 +63,7 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
handler(getObjectRewriter(id -> Entity1_12Types.ObjectType.findById(id).orElse(null)));
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
@ -81,7 +77,6 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -89,9 +84,9 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_EXPERIENCE_ORB, Entity1_12Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_GLOBAL_ENTITY, Entity1_12Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
@ -116,9 +111,9 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
registerTracker(ClientboundPackets1_12.SPAWN_PAINTING, Entity1_12Types.EntityType.PAINTING);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
@ -132,9 +127,9 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
@ -143,18 +138,13 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
handler(getDimensionHandler(1));
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
ShoulderTracker tracker = wrapper.user().get(ShoulderTracker.class);
|
||||
tracker.setEntityId(wrapper.get(Type.INT, 0));
|
||||
}
|
||||
});
|
||||
|
||||
// Send fake inventory achievement
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
handler(packetWrapper -> {
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9_3.STATISTICS, packetWrapper.user());
|
||||
|
||||
wrapper.write(Type.VAR_INT, 1);
|
||||
@ -162,7 +152,6 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
wrapper.write(Type.VAR_INT, 1);
|
||||
|
||||
wrapper.scheduleSend(Protocol1_11_1To1_12.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -171,9 +160,9 @@ public class EntityPackets1_12 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerRemoveEntities(ClientboundPackets1_12.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_12.ENTITY_METADATA, Types1_12.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.ENTITY_PROPERTIES, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
|
@ -20,9 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacySoundRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
||||
|
||||
@ -34,9 +32,9 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.NAMED_SOUND, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.NAMED_SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // 0 - Sound name
|
||||
map(Type.VAR_INT); // 1 - Sound Category
|
||||
map(Type.INT); // 2 - x
|
||||
@ -47,9 +45,9 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SOUND, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_12.SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Sound name
|
||||
map(Type.VAR_INT); // 1 - Sound Category
|
||||
map(Type.INT); // 2 - x
|
||||
@ -58,9 +56,7 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
map(Type.FLOAT); // 5 - Volume
|
||||
map(Type.FLOAT); // 6 - Pitch
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int oldId = wrapper.get(Type.VAR_INT, 0);
|
||||
int newId = handleSounds(oldId);
|
||||
if (newId == -1) {
|
||||
@ -72,7 +68,6 @@ public class SoundPackets1_12 extends LegacySoundRewriter<Protocol1_11_1To1_12>
|
||||
wrapper.set(Type.FLOAT, 1, handlePitch(oldId));
|
||||
}
|
||||
wrapper.set(Type.VAR_INT, 0, newId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -22,7 +22,7 @@ import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
@ -35,9 +35,9 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
@ -57,9 +57,9 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_11Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_11Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
@ -86,9 +86,9 @@ public class EntityPackets1_11_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_11Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
|
@ -22,9 +22,7 @@ import com.viaversion.viabackwards.api.rewriters.LegacyBlockItemRewriter;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEnchantmentRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
@ -46,14 +44,12 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
// Plugin message Packet -> Trading
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
@ -72,7 +68,6 @@ public class ItemPackets1_11_1 extends LegacyBlockItemRewriter<ClientboundPacket
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -20,9 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_12_1to1_12_2;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
@ -35,26 +33,21 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerClientbound(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
public void register() {
|
||||
handler(packetWrapper -> {
|
||||
Long keepAlive = packetWrapper.read(Type.LONG);
|
||||
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(keepAlive);
|
||||
packetWrapper.write(Type.VAR_INT, keepAlive.hashCode());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
public void register() {
|
||||
handler(packetWrapper -> {
|
||||
int keepAlive = packetWrapper.read(Type.VAR_INT);
|
||||
long realKeepAlive = packetWrapper.user().get(KeepAliveTracker.class).getKeepAlive();
|
||||
if (keepAlive != Long.hashCode(realKeepAlive)) {
|
||||
@ -64,7 +57,6 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets
|
||||
packetWrapper.write(Type.LONG, realKeepAlive);
|
||||
// Reset KeepAliveTracker (to prevent sending same valid value in a row causing a timeout)
|
||||
packetWrapper.user().get(KeepAliveTracker.class).setKeepAlive(Integer.MAX_VALUE);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -29,7 +29,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -20,7 +20,6 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class EntityTypeMapping {
|
||||
|
@ -18,7 +18,6 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -23,7 +23,6 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParticleMapping {
|
||||
|
@ -35,8 +35,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.conversion.ConverterRegistry;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
@ -57,7 +56,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRew
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -91,10 +89,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.COOLDOWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.COOLDOWN, wrapper -> {
|
||||
int itemId = wrapper.read(Type.VAR_INT);
|
||||
int oldId = protocol.getMappingData().getItemMappings().get(itemId);
|
||||
if (oldId == -1) {
|
||||
@ -109,19 +104,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
wrapper.write(Type.VAR_INT, oldId >> 4);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION); // Location
|
||||
map(Type.UNSIGNED_BYTE); // Action Id
|
||||
map(Type.UNSIGNED_BYTE); // Action param
|
||||
map(Type.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int blockId = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
if (blockId == 73)
|
||||
@ -146,21 +137,18 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
blockId = blockId - 483 + 219;
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, blockId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||
map(Type.NBT); // 2 - NBT Data
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
BackwardsBlockEntityProvider provider = Via.getManager().getProviders().get(BackwardsBlockEntityProvider.class);
|
||||
|
||||
// TODO conduit handling
|
||||
@ -174,17 +162,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
wrapper.get(Type.POSITION, 0),
|
||||
wrapper.get(Type.NBT, 0)
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.UNLOAD_CHUNK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.UNLOAD_CHUNK, wrapper -> {
|
||||
int chunkMinX = wrapper.passthrough(Type.INT) << 4;
|
||||
int chunkMinZ = wrapper.passthrough(Type.INT) << 4;
|
||||
int chunkMaxX = chunkMinX + 15;
|
||||
@ -195,20 +177,15 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
return position.x() >= chunkMinX && position.z() >= chunkMinZ
|
||||
&& position.x() <= chunkMaxX && position.z() <= chunkMaxZ;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int blockState = wrapper.read(Type.VAR_INT);
|
||||
Position position = wrapper.get(Type.POSITION, 0);
|
||||
|
||||
@ -220,21 +197,18 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
// Flower pot special treatment
|
||||
flowerPotSpecialTreatment(wrapper.user(), blockState, position);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Multi Block Change
|
||||
protocol.registerClientbound(ClientboundPackets1_13.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.MULTI_BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
BackwardsBlockStorage storage = wrapper.user().get(BackwardsBlockStorage.class);
|
||||
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
@ -255,14 +229,13 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
// Change to old id
|
||||
record.setBlockId(protocol.getMappingData().getNewBlockStateId(block));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_ITEMS, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_ITEMS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.FLAT_ITEM_ARRAY, Type.ITEM_ARRAY);
|
||||
|
||||
@ -270,9 +243,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
@ -281,10 +254,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type_old = new Chunk1_9_3_4Type(clientWorld);
|
||||
@ -395,18 +365,14 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
wrapper.write(type_old, chunk);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Effect Id
|
||||
map(Type.POSITION); // Location
|
||||
map(Type.INT); // Data
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
if (id == 1010) { // Play record
|
||||
@ -417,20 +383,17 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
int blockData = data & 0xF;
|
||||
wrapper.set(Type.INT, 1, (blockId & 0xFFF) | (blockData << 12));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.MAP_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.MAP_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.BYTE);
|
||||
map(Type.BOOLEAN);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int iconCount = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < iconCount; i++) {
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
@ -448,14 +411,13 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
wrapper.write(Type.BYTE, x);
|
||||
wrapper.write(Type.BYTE, z);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.VAR_INT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
@ -464,9 +426,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_PROPERTY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // Window Id
|
||||
map(Type.SHORT); // Property
|
||||
map(Type.SHORT); // Value
|
||||
@ -482,9 +444,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
});
|
||||
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.CREATIVE_INVENTORY_ACTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.SHORT);
|
||||
map(Type.ITEM, Type.FLAT_ITEM);
|
||||
|
||||
@ -492,9 +454,9 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.CLICK_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.CLICK_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.BYTE);
|
||||
|
@ -32,8 +32,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_12;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||
@ -42,7 +41,6 @@ import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_13, Protocol1_12_2To1_13> {
|
||||
@ -53,18 +51,16 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLAYER_POSITION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLAYER_POSITION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.FLOAT);
|
||||
map(Type.FLOAT);
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
if (!ViaBackwards.getConfig().isFix1_13FacePlayer()) return;
|
||||
|
||||
PlayerPositionStorage1_13 playerStorage = wrapper.user().get(PlayerPositionStorage1_13.class);
|
||||
@ -72,19 +68,13 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
playerStorage.setX(toSet(bitField, 0, playerStorage.getX(), wrapper.get(Type.DOUBLE, 0)));
|
||||
playerStorage.setY(toSet(bitField, 1, playerStorage.getY(), wrapper.get(Type.DOUBLE, 1)));
|
||||
playerStorage.setZ(toSet(bitField, 2, playerStorage.getZ(), wrapper.get(Type.DOUBLE, 2)));
|
||||
}
|
||||
|
||||
private double toSet(int field, int bitIndex, double origin, double packetValue) {
|
||||
// If bit is set, coordinate is relative
|
||||
return (field & (1 << bitIndex)) != 0 ? origin + packetValue : packetValue;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
map(Type.BYTE);
|
||||
@ -97,9 +87,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
handler(getObjectTrackerHandler());
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
Optional<Entity1_13Types.ObjectType> optionalType = Entity1_13Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (!optionalType.isPresent()) return;
|
||||
|
||||
@ -126,7 +114,6 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
} else if (type == Entity1_13Types.ObjectType.TRIDENT) {
|
||||
wrapper.set(Type.BYTE, 0, (byte) Entity1_13Types.ObjectType.TIPPED_ARROW.getId());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -134,9 +121,9 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, Entity1_13Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, Entity1_13Types.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
map(Type.VAR_INT);
|
||||
@ -151,9 +138,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.SHORT);
|
||||
map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
EntityType entityType = Entity1_13Types.getTypeFromId(type, false);
|
||||
tracker(wrapper.user()).addEntity(wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
@ -166,7 +151,6 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
} else {
|
||||
wrapper.set(Type.VAR_INT, 1, oldId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
@ -174,9 +158,9 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
map(Type.DOUBLE);
|
||||
@ -190,29 +174,26 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PAINTING, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PAINTING, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
|
||||
handler(getTrackerHandler(Entity1_13Types.EntityType.PAINTING, Type.VAR_INT));
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int motive = wrapper.read(Type.VAR_INT);
|
||||
String title = PaintingMapping.getStringId(motive);
|
||||
wrapper.write(Type.STRING, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerJoinGame(ClientboundPackets1_13.JOIN_GAME, Entity1_13Types.EntityType.PLAYER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
|
||||
handler(getDimensionHandler(0));
|
||||
@ -224,12 +205,7 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||
|
||||
// Face Player (new packet)
|
||||
protocol.registerClientbound(ClientboundPackets1_13.FACE_PLAYER, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.FACE_PLAYER, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
|
||||
if (!ViaBackwards.getConfig().isFix1_13FacePlayer()) return;
|
||||
@ -257,15 +233,12 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
positionAndLook.write(Type.BYTE, (byte) 7); // bitfield, 0=absolute, 1=relative - x,y,z relative, yaw,pitch absolute
|
||||
positionAndLook.write(Type.VAR_INT, -1);
|
||||
positionAndLook.send(Protocol1_12_2To1_13.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (ViaBackwards.getConfig().isFix1_13FacePlayer()) {
|
||||
PacketRemapper movementRemapper = new PacketRemapper() {
|
||||
PacketHandlers movementRemapper = new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
@ -408,4 +381,9 @@ public class EntityPackets1_13 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
public int newEntityId(final int newId) {
|
||||
return EntityTypeMapping.getOldId(newId);
|
||||
}
|
||||
|
||||
private static double toSet(int field, int bitIndex, double origin, double packetValue) {
|
||||
// If bit is set, coordinate is relative
|
||||
return (field & (1 << bitIndex)) != 0 ? origin + packetValue : packetValue;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -40,7 +40,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
||||
import com.viaversion.viaversion.rewriter.CommandRewriter;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -58,12 +57,10 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Login Plugin Request
|
||||
protocol.registerClientbound(State.LOGIN, 0x04, -1, new PacketRemapper() {
|
||||
protocol.registerClientbound(State.LOGIN, 0x04, -1, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
public void register() {
|
||||
handler(packetWrapper -> {
|
||||
packetWrapper.cancel();
|
||||
packetWrapper.create(0x02, new PacketHandler() { // Plugin response
|
||||
@Override
|
||||
@ -72,17 +69,11 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
newWrapper.write(Type.BOOLEAN, false); // Success
|
||||
}
|
||||
}).sendToServer(Protocol1_12_2To1_13.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> {
|
||||
String channel = wrapper.read(Type.STRING);
|
||||
if (channel.equals("minecraft:trader_list")) {
|
||||
wrapper.write(Type.STRING, "MC|TrList");
|
||||
@ -133,14 +124,11 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
wrapper.write(Type.REMAINING_BYTES, Joiner.on('\0').join(rewrittenChannels).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
map(Type.BOOLEAN); // 1 - Long Distance
|
||||
map(Type.FLOAT); // 2 - X
|
||||
@ -151,9 +139,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
map(Type.FLOAT); // 7 - Offset Z
|
||||
map(Type.FLOAT); // 8 - Particle Data
|
||||
map(Type.INT); // 9 - Particle Count
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
ParticleMapping.ParticleData old = ParticleMapping.getMapping(wrapper.get(Type.INT, 0));
|
||||
wrapper.set(Type.INT, 0, old.getHistoryId());
|
||||
|
||||
@ -169,17 +155,14 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
wrapper.write(Type.VAR_INT, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLAYER_INFO, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLAYER_INFO, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||
public void register() {
|
||||
handler(packetWrapper -> {
|
||||
TabCompleteStorage storage = packetWrapper.user().get(TabCompleteStorage.class);
|
||||
int action = packetWrapper.passthrough(Type.VAR_INT);
|
||||
int nPlayers = packetWrapper.passthrough(Type.VAR_INT);
|
||||
@ -207,19 +190,16 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
storage.usernames().remove(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SCOREBOARD_OBJECTIVE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SCOREBOARD_OBJECTIVE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING);
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
byte mode = wrapper.get(Type.BYTE, 0);
|
||||
if (mode == 0 || mode == 2) {
|
||||
String value = wrapper.read(Type.COMPONENT).toString();
|
||||
@ -232,19 +212,16 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.STRING, type == 1 ? "hearts" : "integer");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.TEAMS, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.TEAMS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING);
|
||||
map(Type.BYTE);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
byte action = wrapper.get(Type.BYTE, 0);
|
||||
if (action == 0 || action == 2) {
|
||||
String displayName = wrapper.read(Type.STRING);
|
||||
@ -294,15 +271,11 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
if (action == 0 || action == 3 || action == 4) {
|
||||
wrapper.passthrough(Type.STRING_ARRAY); //Entities
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_COMMANDS, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_COMMANDS, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
@ -341,15 +314,8 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.TAB_COMPLETE, wrapper -> {
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
if (storage.lastRequest() == null) {
|
||||
wrapper.cancel();
|
||||
@ -375,15 +341,9 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
wrapper.read(Type.STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.TAB_COMPLETE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.TAB_COMPLETE, wrapper -> {
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
|
||||
@ -432,13 +392,8 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
storage.setLastAssumeCommand(assumeCommand);
|
||||
storage.setLastRequest(command);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerServerbound(ServerboundPackets1_12_1.PLUGIN_MESSAGE, wrapper -> {
|
||||
String channel = wrapper.read(Type.STRING);
|
||||
switch (channel) {
|
||||
case "MC|BSign":
|
||||
@ -584,16 +539,12 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.STATISTICS, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.STATISTICS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int size = wrapper.get(Type.VAR_INT, 0);
|
||||
int newSize = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
@ -631,7 +582,6 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
if (newSize != size) {
|
||||
wrapper.set(Type.VAR_INT, 0, newSize);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -19,7 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data.NamedSoundMapping;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
@ -34,10 +34,7 @@ public class SoundPackets1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.NAMED_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.NAMED_SOUND, wrapper -> {
|
||||
String sound = wrapper.read(Type.STRING);
|
||||
String mappedSound = NamedSoundMapping.getOldId(sound);
|
||||
if (mappedSound != null || (mappedSound = protocol.getMappingData().getMappedNamedSound(sound)) != null) {
|
||||
@ -46,14 +43,9 @@ public class SoundPackets1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
wrapper.write(Type.STRING, sound);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Stop Sound -> Plugin Message
|
||||
protocol.registerClientbound(ClientboundPackets1_13.STOP_SOUND, ClientboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.STOP_SOUND, ClientboundPackets1_12_1.PLUGIN_MESSAGE, wrapper -> {
|
||||
wrapper.write(Type.STRING, "MC|StopSound");
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
String source;
|
||||
@ -77,12 +69,10 @@ public class SoundPackets1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
wrapper.write(Type.STRING, source);
|
||||
wrapper.write(Type.STRING, sound);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SOUND, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int newSound = wrapper.get(Type.VAR_INT, 0);
|
||||
|
@ -22,7 +22,6 @@ import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntOpenHashSet;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
@ -22,9 +22,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.packets.Entit
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.packets.InventoryPackets1_13_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.packets.WorldPackets1_13_2;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
@ -41,19 +39,14 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
|
||||
WorldPackets1_13_2.register(this);
|
||||
EntityPackets1_13_2.register(this);
|
||||
|
||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM);
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
registerClientbound(ClientboundPackets1_13.ADVANCEMENTS, wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
@ -85,9 +78,6 @@ public class Protocol1_13_1To1_13_2 extends BackwardsProtocol<ClientboundPackets
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,7 @@ package com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||
@ -31,9 +29,9 @@ public class EntityPackets1_13_2 {
|
||||
|
||||
|
||||
public static void register(Protocol1_13_1To1_13_2 protocol) {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
@ -48,20 +46,17 @@ public class EntityPackets1_13_2 {
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_13_2.METADATA_LIST, Types1_13.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) {
|
||||
metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
@ -71,30 +66,24 @@ public class EntityPackets1_13_2 {
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Types1_13_2.METADATA_LIST, Types1_13.METADATA_LIST); // 7 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) {
|
||||
metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_METADATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_METADATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_13_2.METADATA_LIST, Types1_13.METADATA_LIST); // 1 - Metadata list
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) {
|
||||
metadata.setMetaType(Types1_13.META_TYPES.byId(metadata.metaType().typeId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -18,9 +18,7 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
@ -28,30 +26,28 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPacke
|
||||
public class InventoryPackets1_13_2 {
|
||||
|
||||
public static void register(Protocol1_13_1To1_13_2 protocol) {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 2 - Slot Value
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_ITEMS, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_ITEMS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.FLAT_VAR_INT_ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Channel
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
String channel = wrapper.get(Type.STRING, 0);
|
||||
if (channel.equals("minecraft:trader_list") || channel.equals("trader_list")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
@ -73,26 +69,20 @@ public class InventoryPackets1_13_2 {
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.VAR_INT); // 1 - Slot ID
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 2 - Item
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, wrapper -> {
|
||||
int recipesNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < recipesNo; i++) {
|
||||
wrapper.passthrough(Type.STRING); // Id
|
||||
@ -121,14 +111,11 @@ public class InventoryPackets1_13_2 {
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_13.CLICK_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.CLICK_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
@ -138,9 +125,9 @@ public class InventoryPackets1_13_2 {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.SHORT); // 0 - Slot
|
||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item
|
||||
}
|
||||
|
@ -18,18 +18,16 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
public class WorldPackets1_13_2 {
|
||||
|
||||
public static void register(Protocol1_13_1To1_13_2 protocol) {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
map(Type.BOOLEAN); // 1 - Long Distance
|
||||
map(Type.FLOAT); // 2 - X
|
||||
@ -41,14 +39,11 @@ public class WorldPackets1_13_2 {
|
||||
map(Type.FLOAT); // 8 - Particle Data
|
||||
map(Type.INT); // 9 - Particle Count
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 27) {
|
||||
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -29,9 +29,6 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLi
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||
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.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
@ -79,12 +76,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
cancelClientbound(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE);
|
||||
cancelClientbound(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
|
||||
registerClientbound(ClientboundPackets1_14.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
registerClientbound(ClientboundPackets1_14.TAGS, wrapper -> {
|
||||
int blockTagsSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < blockTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
@ -121,17 +113,9 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
wrapper.read(Type.STRING);
|
||||
wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_14.UPDATE_LIGHT, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
registerClientbound(ClientboundPackets1_14.UPDATE_LIGHT, null, wrapper -> {
|
||||
int x = wrapper.read(Type.VAR_INT);
|
||||
int z = wrapper.read(Type.VAR_INT);
|
||||
int skyLightMask = wrapper.read(Type.VAR_INT);
|
||||
@ -173,15 +157,12 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
//TODO Soft memory leak: Don't store light if chunk is already loaded
|
||||
wrapper.user().get(ChunkLightStorage.class).setStoredLight(skyLight, blockLight, x, z);
|
||||
wrapper.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isSet(int mask, int i) {
|
||||
private static boolean isSet(int mask, int i) {
|
||||
return (mask & (1 << i)) != 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
|
@ -34,9 +34,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||
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.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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||
@ -57,7 +55,6 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.types.Chunk1_14T
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.rewriter.RecipeRewriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -72,19 +69,9 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_13.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_WINDOW, wrapper -> {
|
||||
int windowId = wrapper.read(Type.VAR_INT);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) windowId);
|
||||
|
||||
@ -167,18 +154,10 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
wrapper.write(Type.COMPONENT, title);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) slotSize);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Horse window -> Open Window
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_HORSE_WINDOW, ClientboundPackets1_13.OPEN_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_HORSE_WINDOW, ClientboundPackets1_13.OPEN_WINDOW, wrapper -> {
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Window id
|
||||
wrapper.write(Type.STRING, "EntityHorse"); // Type
|
||||
JsonObject object = new JsonObject();
|
||||
@ -186,9 +165,6 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
wrapper.write(Type.COMPONENT, object); // Title
|
||||
wrapper.write(Type.UNSIGNED_BYTE, wrapper.read(Type.VAR_INT).shortValue()); // Number of slots
|
||||
wrapper.passthrough(Type.INT); // Entity id
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
BlockRewriter<ClientboundPackets1_14> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION);
|
||||
@ -199,12 +175,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
registerAdvancements(ClientboundPackets1_14.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
// Trade List -> Plugin Message
|
||||
protocol.registerClientbound(ClientboundPackets1_14.TRADE_LIST, ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.TRADE_LIST, ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> {
|
||||
wrapper.write(Type.STRING, "minecraft:trader_list");
|
||||
|
||||
int windowId = wrapper.read(Type.VAR_INT);
|
||||
@ -242,37 +213,24 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
wrapper.read(Type.VAR_INT);
|
||||
wrapper.read(Type.VAR_INT);
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Open Book -> Plugin Message
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_BOOK, ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_BOOK, ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> {
|
||||
wrapper.write(Type.STRING, "minecraft:book_open");
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_EQUIPMENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.VAR_INT); // 1 - Slot ID
|
||||
map(Type.FLAT_VAR_INT_ITEM); // 2 - Item
|
||||
|
||||
handler(itemToClientHandler(Type.FLAT_VAR_INT_ITEM));
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityType entityType = wrapper.user().getEntityTracker(Protocol1_13_2To1_14.class).entityType(entityId);
|
||||
if (entityType == null) return;
|
||||
@ -292,20 +250,13 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
metadataList.add(new Metadata(16, Types1_13_2.META_TYPES.varIntType, armorType));
|
||||
wrapper.write(Types1_13.METADATA_LIST, metadataList);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
RecipeRewriter<ClientboundPackets1_14> recipeHandler = new RecipeRewriter1_13_2<>(protocol);
|
||||
protocol.registerClientbound(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
private final Set<String> removedTypes = ImmutableSet.of("crafting_special_suspiciousstew", "blasting", "smoking", "campfire_cooking", "stonecutting");
|
||||
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
final Set<String> removedTypes = ImmutableSet.of("crafting_special_suspiciousstew", "blasting", "smoking", "campfire_cooking", "stonecutting");
|
||||
protocol.registerClientbound(ClientboundPackets1_14.DECLARE_RECIPES, wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int deleted = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
@ -336,37 +287,34 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
wrapper.write(Type.STRING, type);
|
||||
|
||||
// Handle the rest of the types
|
||||
recipeHandler.handle(wrapper, type);
|
||||
recipeHandler.handleRecipeType(wrapper, type);
|
||||
}
|
||||
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_BREAK_ANIMATION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_BREAK_ANIMATION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
map(Type.BYTE);
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ACTION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_ACTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION); // Location
|
||||
map(Type.UNSIGNED_BYTE); // Action id
|
||||
map(Type.UNSIGNED_BYTE); // Action param
|
||||
@ -382,34 +330,29 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(id));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_14.MULTI_BLOCK_CHANGE);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.EXPLOSION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.EXPLOSION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.FLOAT); // X
|
||||
map(Type.FLOAT); // Y
|
||||
map(Type.FLOAT); // Z
|
||||
map(Type.FLOAT); // Radius
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
float coord = wrapper.get(Type.FLOAT, i);
|
||||
|
||||
@ -418,17 +361,11 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
wrapper.set(Type.FLOAT, i, coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_14Type());
|
||||
wrapper.write(new Chunk1_13Type(clientWorld), chunk);
|
||||
@ -473,34 +410,21 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
palette.setIdByIndex(j, mappedBlockStateId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.UNLOAD_CHUNK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.UNLOAD_CHUNK, wrapper -> {
|
||||
int x = wrapper.passthrough(Type.INT);
|
||||
int z = wrapper.passthrough(Type.INT);
|
||||
wrapper.user().get(ChunkLightStorage.class).unloadChunk(x, z);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.EFFECT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.EFFECT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Effect Id
|
||||
map(Type.POSITION1_14, Type.POSITION); // Location
|
||||
map(Type.INT); // Data
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
if (id == 1010) { // Play record
|
||||
@ -508,16 +432,15 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(data));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.FLOAT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.MAP_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.MAP_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.BYTE);
|
||||
map(Type.BOOLEAN);
|
||||
@ -525,9 +448,9 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_POSITION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_POSITION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
}
|
||||
});
|
||||
|
@ -35,8 +35,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.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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||
@ -72,10 +71,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
protected void registerPackets() {
|
||||
positionHandler = new EntityPositionHandler(this, EntityPositionStorage1_14.class, EntityPositionStorage1_14::new);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_STATUS, wrapper -> {
|
||||
int entityId = wrapper.passthrough(Type.INT);
|
||||
byte status = wrapper.passthrough(Type.BYTE);
|
||||
// Check for death status
|
||||
@ -94,12 +90,10 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
equipmentPacket.send(Protocol1_13_2To1_14.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_TELEPORT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_TELEPORT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
@ -108,30 +102,27 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
PacketRemapper relativeMoveHandler = new PacketRemapper() {
|
||||
PacketHandlers relativeMoveHandler = new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.SHORT);
|
||||
map(Type.SHORT);
|
||||
map(Type.SHORT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
double x = wrapper.get(Type.SHORT, 0) / EntityPositionHandler.RELATIVE_MOVE_FACTOR;
|
||||
double y = wrapper.get(Type.SHORT, 1) / EntityPositionHandler.RELATIVE_MOVE_FACTOR;
|
||||
double z = wrapper.get(Type.SHORT, 2) / EntityPositionHandler.RELATIVE_MOVE_FACTOR;
|
||||
positionHandler.cacheEntityPosition(wrapper, x, y, z, false, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_POSITION, relativeMoveHandler);
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_POSITION_AND_ROTATION, relativeMoveHandler);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT, Type.BYTE); // 2 - Type
|
||||
@ -147,9 +138,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
handler(getObjectTrackerHandler());
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.BYTE, 0);
|
||||
int mappedId = newEntityId(id);
|
||||
Entity1_13Types.EntityType entityType = Entity1_13Types.getTypeFromId(mappedId, false);
|
||||
@ -195,14 +184,13 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
} else if (entityType.isOrHasParent(Entity1_13Types.EntityType.ABSTRACT_ARROW)) {
|
||||
wrapper.set(Type.INT, 0, data + 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
@ -217,9 +205,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
EntityType entityType = Entity1_14Types.getTypeFromId(type);
|
||||
addTrackedEntity(wrapper, wrapper.get(Type.VAR_INT, 0), entityType);
|
||||
@ -236,7 +222,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
} else {
|
||||
wrapper.set(Type.VAR_INT, 1, oldId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Handle entity type & metadata
|
||||
@ -244,9 +229,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_EXPERIENCE_ORB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_EXPERIENCE_ORB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.DOUBLE); // Needs to be mapped for the position cache
|
||||
map(Type.DOUBLE);
|
||||
@ -255,9 +240,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_GLOBAL_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_GLOBAL_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.BYTE);
|
||||
map(Type.DOUBLE); // Needs to be mapped for the position cache
|
||||
@ -267,9 +252,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PAINTING, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PAINTING, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.UUID);
|
||||
map(Type.VAR_INT);
|
||||
@ -281,9 +266,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
@ -301,9 +286,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_14.ENTITY_METADATA, Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
@ -327,9 +312,9 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.RESPAWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Dimension ID
|
||||
|
||||
handler(wrapper -> {
|
||||
|
@ -20,9 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.packets;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.DifficultyStorage;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
@ -36,9 +34,9 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SERVER_DIFFICULTY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SERVER_DIFFICULTY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.BOOLEAN, Type.NOTHING); // Locked
|
||||
handler(wrapper -> {
|
||||
@ -48,34 +46,32 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_SIGN_EDITOR, new PacketRemapper() { // c
|
||||
protocol.registerClientbound(ClientboundPackets1_14.OPEN_SIGN_EDITOR, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION1_14, Type.POSITION);
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_13.QUERY_BLOCK_NBT, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.QUERY_BLOCK_NBT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_DIGGING, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_DIGGING, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Action
|
||||
map(Type.POSITION, Type.POSITION1_14); // Position
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_13.RECIPE_BOOK_DATA, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.RECIPE_BOOK_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int type = wrapper.get(Type.VAR_INT, 0);
|
||||
if (type == 0) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
@ -91,36 +87,30 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
wrapper.write(Type.BOOLEAN, false);
|
||||
wrapper.write(Type.BOOLEAN, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_SIGN, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.UPDATE_SIGN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION, Type.POSITION1_14);
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerServerbound(ServerboundPackets1_13.PLAYER_BLOCK_PLACEMENT, wrapper -> {
|
||||
Position position = wrapper.read(Type.POSITION);
|
||||
int face = wrapper.read(Type.VAR_INT);
|
||||
int hand = wrapper.read(Type.VAR_INT);
|
||||
@ -135,9 +125,6 @@ public class PlayerPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
wrapper.write(Type.FLOAT, y);
|
||||
wrapper.write(Type.FLOAT, z);
|
||||
wrapper.write(Type.BOOLEAN, false); // Inside block
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2T
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.EntityPositionStorage1_14;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
@ -43,10 +42,7 @@ public class SoundPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_14.STOP_SOUND);
|
||||
|
||||
// Entity Sound Effect
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_SOUND, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.ENTITY_SOUND, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
|
||||
int soundId = wrapper.read(Type.VAR_INT);
|
||||
@ -80,6 +76,4 @@ public class SoundPackets1_14 extends RewriterBase<Protocol1_13_2To1_14> {
|
||||
soundPacket.send(Protocol1_13_2To1_14.class);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ package com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
|
@ -30,8 +30,7 @@ import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
@ -73,9 +72,9 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
new CommandRewriter1_13_1(this).registerDeclareCommands(ClientboundPackets1_13.DECLARE_COMMANDS);
|
||||
|
||||
registerServerbound(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_13.TAB_COMPLETE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {
|
||||
@Override
|
||||
@ -87,24 +86,21 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.FLAT_ITEM);
|
||||
map(Type.BOOLEAN);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
itemRewriter.handleItemToServer(wrapper.get(Type.FLAT_ITEM, 0));
|
||||
wrapper.write(Type.VAR_INT, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_13.OPEN_WINDOW, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_13.OPEN_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // Id
|
||||
map(Type.STRING); // Window Type
|
||||
handler(wrapper -> {
|
||||
@ -127,16 +123,14 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_13.TAB_COMPLETE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Transaction id
|
||||
map(Type.VAR_INT); // Start
|
||||
map(Type.VAR_INT); // Length
|
||||
map(Type.VAR_INT); // Count
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int start = wrapper.get(Type.VAR_INT, 1);
|
||||
wrapper.set(Type.VAR_INT, 1, start - 1); // Offset by +1 to take into account / at beginning
|
||||
// Passthrough suggestions
|
||||
@ -148,19 +142,16 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
wrapper.passthrough(Type.STRING); // JSON Tooltip
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_13.BOSSBAR, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_13.BOSSBAR, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UUID);
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
if (action == 0 || action == 3) {
|
||||
translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT));
|
||||
@ -173,17 +164,11 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
wrapper.write(Type.UNSIGNED_BYTE, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
registerClientbound(ClientboundPackets1_13.ADVANCEMENTS, wrapper -> {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
@ -215,9 +200,6 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol<ClientboundPackets1_
|
||||
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter<>(this).register(ClientboundPackets1_13.TAGS, RegistryType.ITEM);
|
||||
|
@ -24,14 +24,11 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||
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.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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets1_13, Protocol1_13To1_13_1> {
|
||||
@ -42,9 +39,9 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
@ -55,9 +52,7 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - Data
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
byte type = wrapper.get(Type.BYTE, 0);
|
||||
Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true);
|
||||
@ -74,7 +69,6 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
|
||||
// Track Entity
|
||||
tracker(wrapper.user()).addEntity(entityId, entType);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -82,9 +76,9 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_EXPERIENCE_ORB, Entity1_13Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_13.SPAWN_GLOBAL_ENTITY, Entity1_13Types.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
@ -103,19 +97,16 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
handler(getTrackerHandler());
|
||||
|
||||
// Rewrite Metadata
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
List<Metadata> metadata = wrapper.get(Types1_13.METADATA_LIST, 0);
|
||||
handleMetadata(wrapper.get(Type.VAR_INT, 0), metadata, wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
|
@ -19,9 +19,6 @@ package com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
||||
|
||||
import com.viaversion.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
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_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
@ -39,12 +36,7 @@ public class InventoryPackets1_13_1 extends ItemRewriter<ClientboundPackets1_13,
|
||||
registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY);
|
||||
registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, wrapper -> {
|
||||
String channel = wrapper.passthrough(Type.STRING);
|
||||
if (channel.equals("minecraft:trader_list")) {
|
||||
wrapper.passthrough(Type.INT); //Passthrough Window ID
|
||||
@ -70,9 +62,6 @@ public class InventoryPackets1_13_1 extends ItemRewriter<ClientboundPackets1_13,
|
||||
wrapper.passthrough(Type.INT); //Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
|
||||
|
@ -24,10 +24,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
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.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||
@ -39,10 +36,7 @@ public class WorldPackets1_13_1 {
|
||||
public static void register(Protocol1_13To1_13_1 protocol) {
|
||||
BlockRewriter<ClientboundPackets1_13> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.passthrough(new Chunk1_13Type(clientWorld));
|
||||
|
||||
@ -58,15 +52,13 @@ public class WorldPackets1_13_1 {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
|
||||
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Effect Id
|
||||
map(Type.POSITION); // Location
|
||||
map(Type.INT); // Data
|
||||
|
@ -18,9 +18,6 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_14_2to1_14_3;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
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_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
@ -35,12 +32,7 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerClientbound(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
registerClientbound(ClientboundPackets1_14.TRADE_LIST, wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
@ -61,16 +53,10 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
RecipeRewriter<ClientboundPackets1_14> recipeHandler = new RecipeRewriter1_14<>(this);
|
||||
registerClientbound(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_14.DECLARE_RECIPES, wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int deleted = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
@ -86,12 +72,10 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets
|
||||
wrapper.write(Type.STRING, fullType);
|
||||
wrapper.write(Type.STRING, id);
|
||||
|
||||
recipeHandler.handle(wrapper, type);
|
||||
recipeHandler.handleRecipeType(wrapper, type);
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,7 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_14_3to1_14_4;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
@ -34,9 +32,9 @@ public class Protocol1_14_3To1_14_4 extends BackwardsProtocol<ClientboundPackets
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// Acknowledge Player Digging - added in pre4
|
||||
registerClientbound(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING, ClientboundPackets1_14.BLOCK_CHANGE, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING, ClientboundPackets1_14.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION1_14);
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
@ -49,12 +47,7 @@ public class Protocol1_14_3To1_14_4 extends BackwardsProtocol<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
registerClientbound(ClientboundPackets1_14.TRADE_LIST, wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
@ -71,9 +64,6 @@ public class Protocol1_14_3To1_14_4 extends BackwardsProtocol<ClientboundPackets
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.read(Type.INT); // demand value added in pre-5
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
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;
|
||||
@ -72,9 +72,9 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_15.STOP_SOUND);
|
||||
|
||||
// Explosion - manually send an explosion sound
|
||||
registerClientbound(ClientboundPackets1_15.EXPLOSION, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_15.EXPLOSION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.FLOAT); // x
|
||||
map(Type.FLOAT); // y
|
||||
map(Type.FLOAT); // z
|
||||
|
@ -23,9 +23,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||
@ -46,12 +44,7 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
new RecipeRewriter1_14<>(protocol).registerDefaultHandler(ClientboundPackets1_15.DECLARE_RECIPES);
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
|
||||
registerSetCooldown(ClientboundPackets1_15.COOLDOWN);
|
||||
registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
@ -67,12 +60,7 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_15.BLOCK_CHANGE);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, wrapper -> {
|
||||
Chunk chunk = wrapper.read(new Chunk1_15Type());
|
||||
wrapper.write(new Chunk1_14Type(), chunk);
|
||||
|
||||
@ -111,16 +99,13 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
|
||||
palette.setIdByIndex(j, mappedBlockStateId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_15.EFFECT, 1010, 2001);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_PARTICLE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
map(Type.BOOLEAN); // 1 - Long Distance
|
||||
map(Type.DOUBLE, Type.FLOAT); // 2 - X
|
||||
@ -131,9 +116,7 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
|
||||
map(Type.FLOAT); // 7 - Offset Z
|
||||
map(Type.FLOAT); // 8 - Particle Data
|
||||
map(Type.INT); // 9 - Particle Count
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 3 || id == 23) {
|
||||
int data = wrapper.passthrough(Type.VAR_INT);
|
||||
@ -147,7 +130,6 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
|
||||
if (id != mappedId) {
|
||||
wrapper.set(Type.INT, 0, mappedId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -25,12 +25,11 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Protocol1_14_4To1_15> {
|
||||
@ -41,10 +40,7 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.UPDATE_HEALTH, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.UPDATE_HEALTH, wrapper -> {
|
||||
float health = wrapper.passthrough(Type.FLOAT);
|
||||
if (health > 0) return;
|
||||
if (!wrapper.user().get(ImmediateRespawn.class).isImmediateRespawn()) return;
|
||||
@ -54,12 +50,10 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
|
||||
statusPacket.write(Type.VAR_INT, 0);
|
||||
statusPacket.sendToServer(Protocol1_14_4To1_15.class);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_15.GAME_EVENT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.GAME_EVENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.FLOAT);
|
||||
handler(wrapper -> {
|
||||
@ -72,9 +66,9 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
|
||||
|
||||
registerTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_15Types.FALLING_BLOCK);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
@ -98,17 +92,17 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_15.RESPAWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT);
|
||||
map(Type.LONG, Type.NOTHING); // Seed
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_15.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
@ -133,9 +127,9 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
|
||||
registerTracker(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY, Entity1_15Types.LIGHTNING_BOLT);
|
||||
registerTracker(ClientboundPackets1_15.SPAWN_PAINTING, Entity1_15Types.PAINTING);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
@ -153,9 +147,9 @@ public class EntityPackets1_15 extends EntityRewriter<ClientboundPackets1_15, Pr
|
||||
registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
|
||||
// Attributes (get rid of generic.flyingSpeed for the Bee remap)
|
||||
protocol.registerClientbound(ClientboundPackets1_15.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_15.ENTITY_PROPERTIES, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.INT);
|
||||
handler(wrapper -> {
|
||||
|
@ -22,13 +22,10 @@ import com.viaversion.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1
|
||||
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.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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EntityPackets1_14_1 extends LegacyEntityRewriter<ClientboundPackets1_14, Protocol1_14To1_14_1> {
|
||||
@ -46,9 +43,9 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
registerTracker(ClientboundPackets1_14.JOIN_GAME, Entity1_14Types.PLAYER, Type.INT);
|
||||
registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT); // 2 - Type
|
||||
@ -57,9 +54,9 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
@ -74,9 +71,7 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_14.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
int type = wrapper.get(Type.VAR_INT, 1);
|
||||
|
||||
@ -85,7 +80,6 @@ public class EntityPackets1_14_1 extends LegacyEntityRewriter<ClientboundPackets
|
||||
|
||||
List<Metadata> metadata = wrapper.get(Types1_14.METADATA_LIST, 0);
|
||||
handleMetadata(entityId, metadata, wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -44,7 +44,6 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.Client
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
import com.viaversion.viaversion.util.GsonUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_16, ClientboundPackets1_15, ServerboundPackets1_16, ServerboundPackets1_14> {
|
||||
@ -74,10 +73,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
(blockItemPackets = new BlockItemPackets1_16(this)).register();
|
||||
entityRewriter.register();
|
||||
|
||||
registerClientbound(State.STATUS, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(State.STATUS, 0x00, 0x00, wrapper -> {
|
||||
String original = wrapper.passthrough(Type.STRING);
|
||||
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);
|
||||
JsonElement description = object.get("description");
|
||||
@ -86,21 +82,19 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
translatableRewriter.processText(description);
|
||||
wrapper.set(Type.STRING, 0, object.toString());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_16.CHAT_MESSAGE, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_16.CHAT_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
handler(wrapper -> translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
map(Type.BYTE);
|
||||
map(Type.UUID, Type.NOTHING); // Sender
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_16.OPEN_WINDOW, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_16.OPEN_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Window Id
|
||||
map(Type.VAR_INT); // Window Type
|
||||
handler(wrapper -> translatableRewriter.processText(wrapper.passthrough(Type.COMPONENT)));
|
||||
@ -122,25 +116,17 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_16.STOP_SOUND);
|
||||
|
||||
// Login success
|
||||
registerClientbound(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(State.LOGIN, 0x02, 0x02, wrapper -> {
|
||||
// Transform uuid to plain string
|
||||
UUID uuid = wrapper.read(Type.UUID);
|
||||
wrapper.write(Type.STRING, uuid.toString());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter<>(this).register(ClientboundPackets1_16.TAGS, RegistryType.ENTITY);
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_16.STATISTICS);
|
||||
|
||||
registerServerbound(ServerboundPackets1_14.ENTITY_ACTION, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerServerbound(ServerboundPackets1_14.ENTITY_ACTION, wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT); // player id
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action == 0) {
|
||||
@ -149,13 +135,8 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
wrapper.user().get(PlayerSneakStorage.class).setSneaking(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_14.INTERACT_ENTITY, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerServerbound(ServerboundPackets1_14.INTERACT_ENTITY, wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT); // Entity Id
|
||||
int action = wrapper.passthrough(Type.VAR_INT);
|
||||
if (action == 0 || action == 2) {
|
||||
@ -172,13 +153,8 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
// New boolean: Whether the client is sneaking
|
||||
wrapper.write(Type.BOOLEAN, wrapper.user().get(PlayerSneakStorage.class).isSneaking());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_14.PLAYER_ABILITIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerServerbound(ServerboundPackets1_14.PLAYER_ABILITIES, wrapper -> {
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
flags &= 2; // Only take the isFlying value (everything else has been removed and wasn't used anyways)
|
||||
wrapper.write(Type.BYTE, flags);
|
||||
@ -186,8 +162,6 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
wrapper.read(Type.FLOAT);
|
||||
wrapper.read(Type.FLOAT);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cancelServerbound(ServerboundPackets1_14.UPDATE_JIGSAW_BLOCK);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import com.viaversion.viaversion.libs.gson.JsonPrimitive;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -19,7 +19,6 @@ package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -23,14 +23,13 @@ import com.viaversion.viabackwards.api.rewriters.MapColorRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data.MapColorRewrites;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.storage.BiomeStorage;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
|
||||
@ -48,7 +47,6 @@ import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.Inventor
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.util.CompactArrayUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -68,10 +66,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
RecipeRewriter1_14<ClientboundPackets1_16> recipeRewriter = new RecipeRewriter1_14<>(protocol);
|
||||
// Remove new smithing type, only in this handler
|
||||
protocol.registerClientbound(ClientboundPackets1_16.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.DECLARE_RECIPES, wrapper -> {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
int newSize = size;
|
||||
for (int i = 0; i < size; i++) {
|
||||
@ -89,13 +84,11 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
wrapper.write(Type.STRING, originalType);
|
||||
wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||
recipeRewriter.handle(wrapper, type);
|
||||
recipeRewriter.handleRecipeType(wrapper, type);
|
||||
}
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, newSize);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerSetCooldown(ClientboundPackets1_16.COOLDOWN);
|
||||
registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||
@ -108,10 +101,7 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_16.MULTI_BLOCK_CHANGE);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.ENTITY_EQUIPMENT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.ENTITY_EQUIPMENT, wrapper -> {
|
||||
int entityId = wrapper.passthrough(Type.VAR_INT);
|
||||
|
||||
List<EquipmentData> equipmentData = new ArrayList<>();
|
||||
@ -138,22 +128,17 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
||||
equipmentPacket.send(Protocol1_15_2To1_16.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.UPDATE_LIGHT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.UPDATE_LIGHT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // x
|
||||
map(Type.VAR_INT); // y
|
||||
map(Type.BOOLEAN, Type.NOTHING);
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, wrapper -> {
|
||||
Chunk chunk = wrapper.read(new Chunk1_16Type());
|
||||
wrapper.write(new Chunk1_15Type(), chunk);
|
||||
|
||||
@ -210,16 +195,14 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
||||
handleBlockEntity(blockEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001);
|
||||
|
||||
registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.WINDOW_PROPERTY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.WINDOW_PROPERTY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // Window id
|
||||
map(Type.SHORT); // Property
|
||||
map(Type.SHORT); // Value
|
||||
@ -237,9 +220,9 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.MAP_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.MAP_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Map ID
|
||||
map(Type.BYTE); // Scale
|
||||
map(Type.BOOLEAN); // Tracking Position
|
||||
@ -248,27 +231,17 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
Position position = wrapper.passthrough(Type.POSITION1_14);
|
||||
short action = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
protocol.registerClientbound(ClientboundPackets1_16.BLOCK_ENTITY_DATA, wrapper -> {
|
||||
wrapper.passthrough(Type.POSITION1_14); // Position
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Action
|
||||
CompoundTag tag = wrapper.passthrough(Type.NBT);
|
||||
handleBlockEntity(tag);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
|
||||
private void handleBlockEntity(CompoundTag tag) {
|
||||
|
@ -30,7 +30,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.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
@ -65,9 +65,9 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.VAR_INT); // 2 - Entity Type
|
||||
@ -98,9 +98,9 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
|
||||
|
||||
registerSpawnTracker(ClientboundPackets1_16.SPAWN_MOB);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.RESPAWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(dimensionTransformer); // Dimension Type
|
||||
handler(wrapper -> {
|
||||
// Grab the tracker for world names
|
||||
@ -143,9 +143,9 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
map(Type.BYTE, Type.NOTHING); // Previous gamemode
|
||||
@ -184,10 +184,7 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
|
||||
registerRemoveEntities(ClientboundPackets1_16.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_16.METADATA_LIST, Types1_14.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.ENTITY_PROPERTIES, wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
int size = wrapper.passthrough(Type.INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
@ -204,12 +201,10 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.PLAYER_INFO, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16.PLAYER_INFO, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
handler(packetWrapper -> {
|
||||
int action = packetWrapper.passthrough(Type.VAR_INT);
|
||||
int playerCount = packetWrapper.passthrough(Type.VAR_INT);
|
||||
|
@ -29,8 +29,6 @@ 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.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.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -76,10 +74,7 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
soundRewriter.registerNamedSound(ClientboundPackets1_16_2.NAMED_SOUND);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_16_2.STOP_SOUND);
|
||||
|
||||
registerClientbound(ClientboundPackets1_16_2.CHAT_MESSAGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_16_2.CHAT_MESSAGE, wrapper -> {
|
||||
JsonElement message = wrapper.passthrough(Type.COMPONENT);
|
||||
translatableRewriter.processText(message);
|
||||
byte position = wrapper.passthrough(Type.BYTE);
|
||||
@ -90,16 +85,9 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
wrapper.write(Type.COMPONENT, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Recipe book data has been split into 2 separate packets
|
||||
registerServerbound(ServerboundPackets1_16.RECIPE_BOOK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
registerServerbound(ServerboundPackets1_16.RECIPE_BOOK_DATA, wrapper -> {
|
||||
int type = wrapper.read(Type.VAR_INT);
|
||||
if (type == 0) {
|
||||
// Shown, change to its own packet
|
||||
@ -113,9 +101,14 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
sendSeenRecipePacket(i, wrapper);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter<>(this).register(ClientboundPackets1_16_2.TAGS, RegistryType.ENTITY);
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_16_2.STATISTICS);
|
||||
}
|
||||
|
||||
private void sendSeenRecipePacket(int recipeType, PacketWrapper wrapper) throws Exception {
|
||||
private static void sendSeenRecipePacket(int recipeType, PacketWrapper wrapper) throws Exception {
|
||||
boolean open = wrapper.read(Type.BOOLEAN);
|
||||
boolean filter = wrapper.read(Type.BOOLEAN);
|
||||
|
||||
@ -125,14 +118,6 @@ public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets
|
||||
newPacket.write(Type.BOOLEAN, filter);
|
||||
newPacket.sendToServer(Protocol1_16_1To1_16_2.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new TagRewriter<>(this).register(ClientboundPackets1_16_2.TAGS, RegistryType.ENTITY);
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_16_2.STATISTICS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
|
@ -24,7 +24,6 @@ import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class BiomeMappings {
|
||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||
@ -57,10 +57,7 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
registerTradeList(ClientboundPackets1_16_2.TRADE_LIST);
|
||||
registerAdvancements(ClientboundPackets1_16_2.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.UNLOCK_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.UNLOCK_RECIPES, wrapper -> {
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN); // Open
|
||||
wrapper.passthrough(Type.BOOLEAN); // Filter
|
||||
@ -72,17 +69,12 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16_2.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_16_2.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16_2.BLOCK_CHANGE);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, wrapper -> {
|
||||
Chunk chunk = wrapper.read(new Chunk1_16_2Type());
|
||||
wrapper.write(new Chunk1_16Type(), chunk);
|
||||
|
||||
@ -106,12 +98,10 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION1_14);
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
handler(wrapper -> {
|
||||
@ -120,10 +110,7 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.MULTI_BLOCK_CHANGE, wrapper -> {
|
||||
long chunkPosition = wrapper.read(Type.LONG);
|
||||
wrapper.read(Type.BOOLEAN); // Ignore old light data
|
||||
|
||||
@ -142,8 +129,6 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
blockChangeRecord[i] = new BlockChangeRecord1_8(record.getSectionX(), record.getY(chunkY), record.getSectionZ(), blockId);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16_2.EFFECT, 1010, 2001);
|
||||
|
||||
@ -151,12 +136,7 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
|
||||
registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
|
||||
private void handleBlockEntity(CompoundTag tag) {
|
||||
|
@ -25,7 +25,7 @@ import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.storage.Biome
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
@ -36,7 +36,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2, Protocol1_16_1To1_16_2> {
|
||||
@ -58,9 +57,9 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
|
||||
registerRemoveEntities(ClientboundPackets1_16_2.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_16.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Entity ID
|
||||
handler(wrapper -> {
|
||||
boolean hardcore = wrapper.read(Type.BOOLEAN);
|
||||
@ -108,16 +107,11 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.RESPAWN, wrapper -> {
|
||||
CompoundTag dimensionData = wrapper.read(Type.NBT);
|
||||
wrapper.write(Type.STRING, getDimensionFromData(dimensionData));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getDimensionFromData(CompoundTag dimensionData) {
|
||||
// This may technically break other custom dimension settings for 1.16/1.16.1 clients, so those cases are considered semi "unsupported" here
|
||||
|
@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_16_3to1_16_4;
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_3to1_16_4.storage.PlayerHandStorage;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||
@ -33,9 +33,9 @@ public class Protocol1_16_3To1_16_4 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.FLAT_VAR_INT_ITEM);
|
||||
map(Type.BOOLEAN);
|
||||
handler(wrapper -> {
|
||||
@ -49,16 +49,11 @@ public class Protocol1_16_3To1_16_4 extends BackwardsProtocol<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_16_2.HELD_ITEM_CHANGE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerServerbound(ServerboundPackets1_16_2.HELD_ITEM_CHANGE, wrapper -> {
|
||||
short slot = wrapper.passthrough(Type.SHORT);
|
||||
wrapper.user().get(PlayerHandStorage.class).setCurrentHand(slot);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
|
@ -31,7 +31,7 @@ import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.TagData;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntArrayList;
|
||||
@ -84,10 +84,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_17.STOP_SOUND);
|
||||
|
||||
TagRewriter<ClientboundPackets1_17> tagRewriter = new TagRewriter<>(this);
|
||||
registerClientbound(ClientboundPackets1_17.TAGS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_17.TAGS, wrapper -> {
|
||||
Map<String, List<TagData>> tags = new HashMap<>();
|
||||
|
||||
int length = wrapper.read(Type.VAR_INT);
|
||||
@ -138,26 +135,19 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_17.STATISTICS);
|
||||
|
||||
registerClientbound(ClientboundPackets1_17.RESOURCE_PACK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_17.RESOURCE_PACK, wrapper -> {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
wrapper.passthrough(Type.STRING);
|
||||
wrapper.read(Type.BOOLEAN); // Required
|
||||
wrapper.read(Type.OPTIONAL_COMPONENT); // Prompt message
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_17.EXPLOSION, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_17.EXPLOSION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.FLOAT); // X
|
||||
map(Type.FLOAT); // Y
|
||||
map(Type.FLOAT); // Z
|
||||
@ -168,9 +158,9 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_17.SPAWN_POSITION, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_17.SPAWN_POSITION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION1_14);
|
||||
handler(wrapper -> {
|
||||
// Angle (which Mojang just forgot to write to the buffer, lol)
|
||||
@ -179,10 +169,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_17.PING, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_17.PING, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
|
||||
int id = wrapper.read(Type.INT);
|
||||
@ -204,12 +191,10 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
pongPacket.write(Type.INT, id);
|
||||
pongPacket.sendToServer(Protocol1_16_4To1_17.class);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_16_2.CLIENT_SETTINGS, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_16_2.CLIENT_SETTINGS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Locale
|
||||
map(Type.BYTE); // View distance
|
||||
map(Type.VAR_INT); // Chat mode
|
||||
@ -227,18 +212,13 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
mergePacket(ClientboundPackets1_17.TITLE_SUBTITLE, ClientboundPackets1_16_2.TITLE, 1);
|
||||
mergePacket(ClientboundPackets1_17.ACTIONBAR, ClientboundPackets1_16_2.TITLE, 2);
|
||||
mergePacket(ClientboundPackets1_17.TITLE_TIMES, ClientboundPackets1_16_2.TITLE, 3);
|
||||
registerClientbound(ClientboundPackets1_17.CLEAR_TITLES, ClientboundPackets1_16_2.TITLE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_17.CLEAR_TITLES, ClientboundPackets1_16_2.TITLE, wrapper -> {
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.write(Type.VAR_INT, 5); // Reset times
|
||||
} else {
|
||||
wrapper.write(Type.VAR_INT, 4); // Simple clear
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cancelClientbound(ClientboundPackets1_17.ADD_VIBRATION_SIGNAL);
|
||||
}
|
||||
@ -262,14 +242,7 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
|
||||
public void mergePacket(ClientboundPackets1_17 newPacketType, ClientboundPackets1_16_2 oldPacketType, int type) {
|
||||
// A few packets that had different handling based on an initially read enum type were split into different ones
|
||||
registerClientbound(newPacketType, oldPacketType, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
wrapper.write(Type.VAR_INT, type);
|
||||
});
|
||||
}
|
||||
});
|
||||
registerClientbound(newPacketType, oldPacketType, wrapper -> wrapper.write(Type.VAR_INT, type));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,7 +32,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.LongArrayTag;
|
||||
@ -48,7 +48,6 @@ import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17T
|
||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||
import com.viaversion.viaversion.util.CompactArrayUtil;
|
||||
import com.viaversion.viaversion.util.MathUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
@ -78,12 +77,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||
|
||||
// TODO Since the carried and modified items are typically set incorrectly, the server sends unnecessary
|
||||
// set slot packets after practically every window click, since it thinks the client and server
|
||||
@ -92,9 +86,9 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
// and modified items array as appropriate here. That would be a ton of work and replicated vanilla code,
|
||||
// and the hack below mitigates the worst side effects of this issue, which is an incorrect carried item
|
||||
// sent to the client when a right/left click drag is started. It works, at least for now...
|
||||
protocol.registerServerbound(ServerboundPackets1_16_2.CLICK_WINDOW, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_16_2.CLICK_WINDOW, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
handler(wrapper -> {
|
||||
short slot = wrapper.passthrough(Type.SHORT); // Slot
|
||||
@ -142,10 +136,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.SET_SLOT, wrapper -> {
|
||||
short windowId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
short slot = wrapper.passthrough(Type.SHORT);
|
||||
|
||||
@ -163,13 +154,8 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM, handleItemToClient(carried));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_16_2.WINDOW_CONFIRMATION, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerServerbound(ServerboundPackets1_16_2.WINDOW_CONFIRMATION, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
if (!ViaBackwards.getConfig().handlePingsAsInvAcknowledgements()) {
|
||||
return;
|
||||
@ -185,12 +171,10 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
pongPacket.sendToServer(Protocol1_16_4To1_17.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.SPAWN_PARTICLE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Particle id
|
||||
map(Type.BOOLEAN); // Long distance
|
||||
map(Type.DOUBLE); // X
|
||||
@ -232,9 +216,9 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
|
||||
// The Great Shrunkening
|
||||
// Chunk sections *will* be lost ¯\_(ツ)_/¯
|
||||
protocol.registerClientbound(ClientboundPackets1_17.UPDATE_LIGHT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.UPDATE_LIGHT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // X
|
||||
map(Type.VAR_INT); // Z
|
||||
map(Type.BOOLEAN); // Trust edges
|
||||
@ -297,8 +281,9 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
public void registerMap() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.MULTI_BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.LONG); // Chunk pos
|
||||
map(Type.BOOLEAN); // Suppress light updates
|
||||
handler((wrapper) -> {
|
||||
@ -318,8 +303,9 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.BLOCK_CHANGE, new PacketRemapper() {
|
||||
public void registerMap() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.POSITION1_14);
|
||||
map(Type.VAR_INT);
|
||||
handler((wrapper) -> {
|
||||
@ -334,10 +320,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.CHUNK_DATA, wrapper -> {
|
||||
EntityTracker tracker = wrapper.user().getEntityTracker(Protocol1_16_4To1_17.class);
|
||||
int currentWorldSectionHeight = tracker.currentWorldSectionHeight();
|
||||
|
||||
@ -382,24 +365,17 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
return tag != null && (tag.asInt() < 0 || tag.asInt() > 255);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.BLOCK_ENTITY_DATA, wrapper -> {
|
||||
int y = wrapper.passthrough(Type.POSITION1_14).y();
|
||||
if (y < 0 || y > 255) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.BLOCK_BREAK_ANIMATION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.BLOCK_BREAK_ANIMATION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
handler(wrapper -> {
|
||||
int y = wrapper.passthrough(Type.POSITION1_14).y();
|
||||
@ -410,9 +386,9 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.MAP_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.MAP_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Map ID
|
||||
map(Type.BYTE); // Scale
|
||||
handler(wrapper -> wrapper.write(Type.BOOLEAN, true)); // Tracking position
|
||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
@ -54,10 +54,7 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
||||
registerTracker(ClientboundPackets1_17.SPAWN_PLAYER, Entity1_17Types.PLAYER);
|
||||
registerMetadataRewriter(ClientboundPackets1_17.ENTITY_METADATA, Types1_17.METADATA_LIST, Types1_16.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.REMOVE_ENTITY, ClientboundPackets1_16_2.DESTROY_ENTITIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.REMOVE_ENTITY, ClientboundPackets1_16_2.DESTROY_ENTITIES, wrapper -> {
|
||||
int entityId = wrapper.read(Type.VAR_INT);
|
||||
tracker(wrapper.user()).removeEntity(entityId);
|
||||
|
||||
@ -65,12 +62,10 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
||||
int[] array = {entityId};
|
||||
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, array);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Entity ID
|
||||
map(Type.BOOLEAN); // Hardcore
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
@ -111,9 +106,9 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.RESPAWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.NBT); // Dimension data
|
||||
map(Type.STRING); // World
|
||||
handler(worldDataTrackerHandler(0));
|
||||
@ -121,9 +116,9 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.PLAYER_POSITION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.PLAYER_POSITION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
map(Type.DOUBLE);
|
||||
@ -138,9 +133,9 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_17.ENTITY_PROPERTIES, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
handler(wrapper -> {
|
||||
wrapper.write(Type.INT, wrapper.read(Type.VAR_INT)); // Collection length
|
||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||
@ -76,9 +76,9 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
|
||||
tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:lava_pool_stone_replaceables");
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS);
|
||||
|
||||
registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Language
|
||||
map(Type.BYTE); // View distance
|
||||
map(Type.VAR_INT); // Chat visibility
|
||||
@ -90,31 +90,31 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_18.SCOREBOARD_OBJECTIVE, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_18.SCOREBOARD_OBJECTIVE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Name
|
||||
handler(cutName(0, 16));
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_18.DISPLAY_SCOREBOARD, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_18.DISPLAY_SCOREBOARD, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.BYTE); // Slot
|
||||
map(Type.STRING); // Name
|
||||
handler(cutName(0, 16));
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_18.TEAMS, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_18.TEAMS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Name
|
||||
handler(cutName(0, 16));
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_18.UPDATE_SCORE, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_18.UPDATE_SCORE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Owner
|
||||
map(Type.VAR_INT); // Method
|
||||
map(Type.STRING); // Name
|
||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
@ -64,9 +64,9 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
|
||||
registerAdvancements(ClientboundPackets1_18.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||
registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_18.EFFECT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_18.EFFECT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Effect id
|
||||
map(Type.POSITION1_14); // Location
|
||||
map(Type.INT); // Data
|
||||
@ -82,9 +82,9 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PARTICLE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Particle id
|
||||
map(Type.BOOLEAN); // Override limiter
|
||||
map(Type.DOUBLE); // X
|
||||
@ -124,9 +124,9 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_18.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_18.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION1_14);
|
||||
handler(wrapper -> {
|
||||
final int id = wrapper.read(Type.VAR_INT);
|
||||
@ -166,10 +166,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_18.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_18.CHUNK_DATA, wrapper -> {
|
||||
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
||||
final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(),
|
||||
MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()),
|
||||
@ -246,8 +243,6 @@ public final class BlockItemPackets1_18 extends ItemRewriter<ClientboundPackets1
|
||||
|
||||
lightPacket.send(Protocol1_17_1To1_18.class);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.cancelClientbound(ClientboundPackets1_18.SET_SIMULATION_DISTANCE);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1T
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||
@ -44,9 +44,9 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
|
||||
protected void registerPackets() {
|
||||
registerMetadataRewriter(ClientboundPackets1_18.ENTITY_METADATA, Types1_18.METADATA_LIST, Types1_17.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Entity ID
|
||||
map(Type.BOOLEAN); // Hardcore
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
@ -82,9 +82,9 @@ public final class EntityPackets1_18 extends EntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.NBT); // Dimension data
|
||||
map(Type.STRING); // World
|
||||
handler(worldDataTrackerHandler(0));
|
||||
|
@ -23,7 +23,6 @@ import com.viaversion.viabackwards.protocol.protocol1_17to1_17_1.storage.Invento
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
@ -45,10 +44,7 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerClientbound(ClientboundPackets1_17_1.REMOVE_ENTITIES, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_17_1.REMOVE_ENTITIES, null, wrapper -> {
|
||||
int[] entityIds = wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
wrapper.cancel();
|
||||
for (int entityId : entityIds) {
|
||||
@ -58,32 +54,17 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
||||
newPacket.send(Protocol1_17To1_17_1.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_17_1.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_17_1.CLOSE_WINDOW, wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
|
||||
});
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_17_1.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_17_1.SET_SLOT, wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
int stateId = wrapper.read(Type.VAR_INT);
|
||||
wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId);
|
||||
});
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_17_1.WINDOW_ITEMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_17_1.WINDOW_ITEMS, wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
int stateId = wrapper.read(Type.VAR_INT);
|
||||
wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId);
|
||||
@ -104,33 +85,18 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
||||
lastCursorItem.setLastCursorItem(carried);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_17.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerServerbound(ServerboundPackets1_17.CLOSE_WINDOW, wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
|
||||
});
|
||||
}
|
||||
});
|
||||
registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
int stateId = wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
|
||||
wrapper.write(Type.VAR_INT, stateId == Integer.MAX_VALUE ? 0 : stateId);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_17.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerServerbound(ServerboundPackets1_17.EDIT_BOOK, wrapper -> {
|
||||
Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
boolean signing = wrapper.read(Type.BOOLEAN);
|
||||
wrapper.passthrough(Type.VAR_INT); // Slot comes first
|
||||
@ -179,8 +145,6 @@ public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection connection) {
|
||||
|
@ -31,7 +31,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -86,9 +86,9 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
|
||||
final SoundRewriter<ClientboundPackets1_19> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_19.STOP_SOUND);
|
||||
registerClientbound(ClientboundPackets1_19.SOUND, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19.SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Sound id
|
||||
map(Type.VAR_INT); // Source
|
||||
map(Type.INT); // X
|
||||
@ -100,9 +100,9 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
handler(soundRewriter.getSoundHandler());
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_19.ENTITY_SOUND, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19.ENTITY_SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Sound id
|
||||
map(Type.VAR_INT); // Source
|
||||
map(Type.VAR_INT); // Entity id
|
||||
@ -112,9 +112,9 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
handler(soundRewriter.getSoundHandler());
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_19.NAMED_SOUND, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19.NAMED_SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Sound name
|
||||
map(Type.VAR_INT); // Source
|
||||
map(Type.INT); // X
|
||||
@ -141,10 +141,7 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_19.STATISTICS);
|
||||
|
||||
final CommandRewriter<ClientboundPackets1_19> commandRewriter = new CommandRewriter1_19(this);
|
||||
registerClientbound(ClientboundPackets1_19.DECLARE_COMMANDS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_19.DECLARE_COMMANDS, wrapper -> {
|
||||
final int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final byte flags = wrapper.passthrough(Type.BYTE);
|
||||
@ -177,15 +174,13 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT); // Root node index
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cancelClientbound(ClientboundPackets1_19.SERVER_DATA);
|
||||
cancelClientbound(ClientboundPackets1_19.CHAT_PREVIEW);
|
||||
cancelClientbound(ClientboundPackets1_19.SET_DISPLAY_CHAT_PREVIEW);
|
||||
registerClientbound(ClientboundPackets1_19.PLAYER_CHAT, ClientboundPackets1_18.CHAT_MESSAGE, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19.PLAYER_CHAT, ClientboundPackets1_18.CHAT_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
final JsonElement signedContent = wrapper.read(Type.COMPONENT);
|
||||
final JsonElement unsignedContent = wrapper.read(Type.OPTIONAL_COMPONENT);
|
||||
@ -212,9 +207,9 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_19.SYSTEM_CHAT, ClientboundPackets1_18.CHAT_MESSAGE, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19.SYSTEM_CHAT, ClientboundPackets1_18.CHAT_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
final JsonElement content = wrapper.passthrough(Type.COMPONENT);
|
||||
translatableRewriter.processText(content);
|
||||
@ -227,9 +222,9 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_17.CHAT_MESSAGE, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_17.CHAT_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Message
|
||||
handler(wrapper -> wrapper.write(Type.LONG, Instant.now().toEpochMilli())); // Timestamp
|
||||
create(Type.LONG, 0L); // Salt
|
||||
@ -248,9 +243,9 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
});
|
||||
|
||||
// Login changes
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketRemapper() {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.UUID); // UUID
|
||||
map(Type.STRING); // Name
|
||||
handler(wrapper -> {
|
||||
@ -266,18 +261,18 @@ public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Name
|
||||
// Write empty profile key - requires the enforce-secure-profiles option to be disabled on the server
|
||||
create(Type.OPTIONAL_PROFILE_KEY, null);
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Keys
|
||||
create(Type.BOOLEAN, true); // Is nonce
|
||||
}
|
||||
|
@ -29,9 +29,8 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class BackwardsMappings extends com.viaversion.viabackwards.api.data.BackwardsMappings {
|
||||
|
||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
||||
@ -62,9 +62,9 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
|
||||
|
||||
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19.TRADE_LIST, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19.TRADE_LIST, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Container id
|
||||
handler(wrapper -> {
|
||||
final int size = wrapper.read(Type.VAR_INT);
|
||||
@ -96,17 +96,17 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
|
||||
|
||||
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19.WINDOW_PROPERTY);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19.BLOCK_CHANGED_ACK, null, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19.BLOCK_CHANGED_ACK, null, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
read(Type.VAR_INT); // Sequence
|
||||
handler(PacketWrapper::cancel); // This is fine:tm:
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19.SPAWN_PARTICLE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT, Type.INT); // Particle id
|
||||
map(Type.BOOLEAN); // Override limiter
|
||||
map(Type.DOUBLE); // X
|
||||
@ -139,10 +139,7 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
|
||||
});
|
||||
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_19.CHUNK_DATA, wrapper -> {
|
||||
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
||||
final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(),
|
||||
MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()),
|
||||
@ -156,22 +153,20 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// The server does nothing but track the sequence, so we can just set it as 0
|
||||
protocol.registerServerbound(ServerboundPackets1_17.PLAYER_DIGGING, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_17.PLAYER_DIGGING, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Action
|
||||
map(Type.POSITION1_14); // Block position
|
||||
map(Type.UNSIGNED_BYTE); // Direction
|
||||
create(Type.VAR_INT, 0); // Sequence
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_17.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_17.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Hand
|
||||
map(Type.POSITION1_14); // Block position
|
||||
map(Type.VAR_INT); // Direction
|
||||
@ -182,18 +177,15 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
|
||||
create(Type.VAR_INT, 0); // Sequence
|
||||
}
|
||||
});
|
||||
protocol.registerServerbound(ServerboundPackets1_17.USE_ITEM, new PacketRemapper() {
|
||||
protocol.registerServerbound(ServerboundPackets1_17.USE_ITEM, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Hand
|
||||
create(Type.VAR_INT, 0); // Sequence
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_17.SET_BEACON_EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerServerbound(ServerboundPackets1_17.SET_BEACON_EFFECT, wrapper -> {
|
||||
final int primaryEffect = wrapper.read(Type.VAR_INT);
|
||||
if (primaryEffect != -1) {
|
||||
wrapper.write(Type.BOOLEAN, true);
|
||||
@ -211,6 +203,4 @@ public final class BlockItemPackets1_19 extends ItemRewriter<ClientboundPackets1
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
||||
@ -54,9 +54,9 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
||||
registerMetadataRewriter(ClientboundPackets1_19.ENTITY_METADATA, Types1_19.METADATA_LIST, Types1_18.METADATA_LIST);
|
||||
registerRemoveEntities(ClientboundPackets1_19.REMOVE_ENTITIES);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
map(Type.UUID); // Entity UUID
|
||||
map(Type.VAR_INT); // Entity Type
|
||||
@ -98,9 +98,9 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19.ENTITY_EFFECT, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19.ENTITY_EFFECT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
map(Type.VAR_INT); // Effect id
|
||||
map(Type.BYTE); // Amplifier
|
||||
@ -115,9 +115,9 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Entity ID
|
||||
map(Type.BOOLEAN); // Hardcore
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
@ -180,9 +180,9 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19.RESPAWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
handler(wrapper -> {
|
||||
final String dimensionKey = wrapper.read(Type.STRING);
|
||||
final CompoundTag dimension = wrapper.user().get(DimensionRegistryStorage.class).dimension(dimensionKey);
|
||||
@ -204,10 +204,7 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19.PLAYER_INFO, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_19.PLAYER_INFO, wrapper -> {
|
||||
final int action = wrapper.passthrough(Type.VAR_INT);
|
||||
final int entries = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < entries; i++) {
|
||||
@ -236,8 +233,6 @@ public final class EntityPackets1_19 extends EntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
|
@ -22,10 +22,9 @@ import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class DimensionRegistryStorage implements StorableObject {
|
||||
|
||||
|
@ -19,7 +19,6 @@ package com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class StoredPainting implements StorableObject {
|
||||
|
@ -22,7 +22,7 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_18to1_18_2.data.CommandRewriter1_18_2;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
@ -53,25 +53,25 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol<ClientboundPac
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) id);
|
||||
};
|
||||
registerClientbound(ClientboundPackets1_18.ENTITY_EFFECT, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_18.ENTITY_EFFECT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
handler(entityEffectIdHandler);
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_18.REMOVE_ENTITY_EFFECT, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_18.REMOVE_ENTITY_EFFECT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
handler(entityEffectIdHandler);
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Entity ID
|
||||
map(Type.BOOLEAN); // Hardcore
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
@ -92,12 +92,7 @@ public final class Protocol1_18To1_18_2 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> removeTagPrefix(wrapper.passthrough(Type.NBT)));
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_18.RESPAWN, wrapper -> removeTagPrefix(wrapper.passthrough(Type.NBT)));
|
||||
}
|
||||
|
||||
private void removeTagPrefix(CompoundTag tag) {
|
||||
|
@ -33,7 +33,7 @@ import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.BitSetType;
|
||||
import com.viaversion.viaversion.api.type.types.ByteArrayType;
|
||||
@ -90,10 +90,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
|
||||
final SoundRewriter<ClientboundPackets1_19_3> soundRewriter = new SoundRewriter<>(this);
|
||||
soundRewriter.registerStopSound(ClientboundPackets1_19_3.STOP_SOUND);
|
||||
registerClientbound(ClientboundPackets1_19_3.SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_19_3.SOUND, wrapper -> {
|
||||
final int soundId = wrapper.read(Type.VAR_INT) - 1; // Normalize the id
|
||||
if (soundId != -1) {
|
||||
final int mappedId = MAPPINGS.getSoundMappings().getNewId(soundId);
|
||||
@ -121,12 +118,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
wrapper.write(Type.STRING, soundIdentifier);
|
||||
wrapper.setPacketType(ClientboundPackets1_19_1.NAMED_SOUND);
|
||||
});
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_19_3.ENTITY_SOUND, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_19_3.ENTITY_SOUND, wrapper -> {
|
||||
final int soundId = wrapper.read(Type.VAR_INT) - 1; // Normalize the id
|
||||
if (soundId != -1) {
|
||||
final int mappedId = MAPPINGS.getSoundMappings().getNewId(soundId);
|
||||
@ -159,8 +151,6 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
|
||||
wrapper.write(Type.VAR_INT, mappedId);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
final TagRewriter<ClientboundPackets1_19_3> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:non_flammable_wood");
|
||||
@ -170,10 +160,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_19_3.STATISTICS);
|
||||
|
||||
final CommandRewriter<ClientboundPackets1_19_3> commandRewriter = new CommandRewriter<>(this);
|
||||
registerClientbound(ClientboundPackets1_19_3.DECLARE_COMMANDS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_19_3.DECLARE_COMMANDS, wrapper -> {
|
||||
final int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final byte flags = wrapper.passthrough(Type.BYTE);
|
||||
@ -207,12 +194,10 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT); // Root node index
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_3.SERVER_DATA, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19_3.SERVER_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.OPTIONAL_COMPONENT); // Motd
|
||||
map(Type.OPTIONAL_STRING); // Encoded icon
|
||||
create(Type.BOOLEAN, false); // Previews chat
|
||||
@ -220,9 +205,9 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
});
|
||||
|
||||
// Remove the key once again
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Name
|
||||
handler(wrapper -> {
|
||||
final ProfileKey profileKey = wrapper.read(Type.OPTIONAL_PROFILE_KEY);
|
||||
@ -232,9 +217,9 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
});
|
||||
}
|
||||
});
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Server id
|
||||
handler(wrapper -> {
|
||||
if (wrapper.user().has(NonceStorage.class)) {
|
||||
@ -246,9 +231,9 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
});
|
||||
}
|
||||
});
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Keys
|
||||
handler(wrapper -> {
|
||||
final NonceStorage nonceStorage = wrapper.user().remove(NonceStorage.class);
|
||||
@ -262,9 +247,9 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_19_1.CHAT_MESSAGE, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_19_1.CHAT_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Message
|
||||
map(Type.LONG); // Timestamp
|
||||
map(Type.LONG); // Salt
|
||||
@ -282,9 +267,9 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
});
|
||||
}
|
||||
});
|
||||
registerServerbound(ServerboundPackets1_19_1.CHAT_COMMAND, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_19_1.CHAT_COMMAND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Command
|
||||
map(Type.LONG); // Timestamp
|
||||
map(Type.LONG); // Salt
|
||||
@ -306,9 +291,9 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
read(Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE); // Last received message
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_19_3.PLAYER_CHAT, ClientboundPackets1_19_1.SYSTEM_CHAT, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19_3.PLAYER_CHAT, ClientboundPackets1_19_1.SYSTEM_CHAT, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
read(Type.UUID); // Sender
|
||||
read(Type.VAR_INT); // Index
|
||||
read(OPTIONAL_SIGNATURE_BYTES_TYPE); // Signature
|
||||
@ -346,10 +331,7 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
});
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_19_3.DISGUISED_CHAT, ClientboundPackets1_19_1.SYSTEM_CHAT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_19_3.DISGUISED_CHAT, ClientboundPackets1_19_1.SYSTEM_CHAT, wrapper -> {
|
||||
final JsonElement content = wrapper.read(Type.COMPONENT);
|
||||
translatableRewriter.processText(content);
|
||||
final int chatTypeId = wrapper.read(Type.VAR_INT);
|
||||
@ -364,8 +346,6 @@ public final class Protocol1_19_1To1_19_3 extends BackwardsProtocol<ClientboundP
|
||||
wrapper.write(Type.COMPONENT, result);
|
||||
wrapper.write(Type.BOOLEAN, false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
cancelClientbound(ClientboundPackets1_19_3.UPDATE_ENABLED_FEATURES);
|
||||
cancelServerbound(ServerboundPackets1_19_1.CHAT_PREVIEW);
|
||||
|
@ -20,7 +20,7 @@ package com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.packets;
|
||||
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.Protocol1_19_1To1_19_3;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
||||
@ -55,9 +55,9 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter<ClientboundPacket
|
||||
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_19_3.WINDOW_PROPERTY);
|
||||
registerSpawnParticle1_19(ClientboundPackets1_19_3.SPAWN_PARTICLE);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.EXPLOSION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.EXPLOSION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.DOUBLE, Type.FLOAT); // X
|
||||
map(Type.DOUBLE, Type.FLOAT); // Y
|
||||
map(Type.DOUBLE, Type.FLOAT); // Z
|
||||
@ -65,10 +65,7 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter<ClientboundPacket
|
||||
});
|
||||
|
||||
final RecipeRewriter1_16<ClientboundPackets1_19_3> recipeRewriter = new RecipeRewriter1_16<>(protocol);
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.DECLARE_RECIPES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.DECLARE_RECIPES, wrapper -> {
|
||||
final int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
final String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
@ -130,12 +127,10 @@ public final class BlockItemPackets1_19_3 extends ItemRewriter<ClientboundPacket
|
||||
wrapper.read(Type.VAR_INT); // Crafting book category
|
||||
break;
|
||||
default:
|
||||
recipeRewriter.handle(wrapper, type);
|
||||
recipeRewriter.handleRecipeType(wrapper, type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.BitSetType;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||
@ -37,10 +37,9 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPackets1_19_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.UUID;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets1_19_3, Protocol1_19_1To1_19_3> {
|
||||
|
||||
@ -63,9 +62,9 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
||||
registerRemoveEntities(ClientboundPackets1_19_3.REMOVE_ENTITIES);
|
||||
registerTrackerWithData1_19(ClientboundPackets1_19_3.SPAWN_ENTITY, Entity1_19_3Types.FALLING_BLOCK);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Entity id
|
||||
map(Type.BOOLEAN); // Hardcore
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
@ -91,9 +90,9 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.RESPAWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Dimension
|
||||
map(Type.STRING); // World
|
||||
map(Type.LONG); // Seed
|
||||
@ -110,10 +109,7 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.PLAYER_INFO_UPDATE, ClientboundPackets1_19_1.PLAYER_INFO, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.PLAYER_INFO_UPDATE, ClientboundPackets1_19_1.PLAYER_INFO, wrapper -> {
|
||||
wrapper.cancel();
|
||||
final BitSet actions = wrapper.read(PROFILE_ACTIONS_ENUM_TYPE);
|
||||
final int entries = wrapper.read(Type.VAR_INT);
|
||||
@ -195,12 +191,7 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
||||
sendPlayerProfileUpdate(wrapper.user(), 3, updates);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.PLAYER_INFO_REMOVE, ClientboundPackets1_19_1.PLAYER_INFO, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
protocol.registerClientbound(ClientboundPackets1_19_3.PLAYER_INFO_REMOVE, ClientboundPackets1_19_1.PLAYER_INFO, wrapper -> {
|
||||
final UUID[] uuids = wrapper.read(Type.UUID_ARRAY);
|
||||
wrapper.write(Type.VAR_INT, 4); // Remove player
|
||||
wrapper.write(Type.VAR_INT, uuids.length);
|
||||
@ -209,8 +200,6 @@ public final class EntityPackets1_19_3 extends EntityRewriter<ClientboundPackets
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendPlayerProfileUpdate(final UserConnection connection, final int action, final PlayerProfileUpdate[] updates) throws Exception {
|
||||
final PacketWrapper playerInfoPacket = PacketWrapper.create(ClientboundPackets1_19_1.PLAYER_INFO, connection);
|
||||
|
@ -18,7 +18,6 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_19_1to1_19_3.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChatSessionStorage implements StorableObject {
|
||||
|
@ -24,7 +24,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets.Entit
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
||||
@ -77,9 +77,9 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
|
||||
|
||||
cancelClientbound(ClientboundPackets1_19_4.BUNDLE);
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_4.DAMAGE_EVENT, ClientboundPackets1_19_3.ENTITY_STATUS, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19_4.DAMAGE_EVENT, ClientboundPackets1_19_3.ENTITY_STATUS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT, Type.INT); // Entity id
|
||||
read(Type.VAR_INT); // Damage type
|
||||
read(Type.VAR_INT); // Cause entity
|
||||
|
@ -23,7 +23,7 @@ import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_3;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
||||
@ -47,9 +47,9 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
||||
registerRemoveEntities(ClientboundPackets1_19_4.REMOVE_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_19_4.ENTITY_METADATA, Types1_19_4.METADATA_LIST, Types1_19_3.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.JOIN_GAME, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Entity id
|
||||
map(Type.BOOLEAN); // Hardcore
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
@ -78,18 +78,18 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.HIT_ANIMATION, ClientboundPackets1_19_3.ENTITY_ANIMATION, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.HIT_ANIMATION, ClientboundPackets1_19_3.ENTITY_ANIMATION, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Entity id
|
||||
read(Type.FLOAT); // Yaw
|
||||
create(Type.UNSIGNED_BYTE, (short) 1); // Hit
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.RESPAWN, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Dimension
|
||||
map(Type.STRING); // World
|
||||
handler(worldDataTrackerHandlerByKey());
|
||||
|
@ -32,7 +32,7 @@ import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types;
|
||||
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.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@ -88,9 +88,9 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
|
||||
entityRewriter.register();
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_1.JOIN_GAME, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19_1.JOIN_GAME, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // Entity ID
|
||||
map(Type.BOOLEAN); // Hardcore
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
@ -119,10 +119,7 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_1.PLAYER_CHAT, ClientboundPackets1_19.SYSTEM_CHAT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_19_1.PLAYER_CHAT, ClientboundPackets1_19.SYSTEM_CHAT, wrapper -> {
|
||||
wrapper.read(Type.OPTIONAL_BYTE_ARRAY_PRIMITIVE); // Previous signature
|
||||
|
||||
final PlayerMessageSignature signature = wrapper.read(Type.PLAYER_MESSAGE_SIGNATURE);
|
||||
@ -181,25 +178,18 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
wrapper.write(Type.COMPONENT, decoratedMessage);
|
||||
wrapper.write(Type.VAR_INT, SYSTEM_CHAT_ID);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_1.SYSTEM_CHAT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
registerClientbound(ClientboundPackets1_19_1.SYSTEM_CHAT, wrapper -> {
|
||||
final JsonElement content = wrapper.passthrough(Type.COMPONENT);
|
||||
translatableRewriter.processText(content);
|
||||
|
||||
final boolean overlay = wrapper.read(Type.BOOLEAN);
|
||||
wrapper.write(Type.VAR_INT, overlay ? GAME_INFO_ID : SYSTEM_CHAT_ID);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_19.CHAT_MESSAGE, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_19.CHAT_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Message
|
||||
map(Type.LONG); // Timestamp
|
||||
map(Type.LONG); // Salt
|
||||
@ -216,9 +206,9 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_19.CHAT_COMMAND, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_19.CHAT_COMMAND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Command
|
||||
map(Type.LONG); // Timestamp
|
||||
map(Type.LONG); // Salt
|
||||
@ -242,9 +232,9 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_1.SERVER_DATA, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_19_1.SERVER_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.OPTIONAL_COMPONENT); // Motd
|
||||
map(Type.OPTIONAL_STRING); // Encoded icon
|
||||
map(Type.BOOLEAN); // Previews chat
|
||||
@ -252,9 +242,9 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Name
|
||||
handler(wrapper -> {
|
||||
final ProfileKey profileKey = wrapper.read(Type.OPTIONAL_PROFILE_KEY);
|
||||
@ -268,9 +258,9 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // Server id
|
||||
handler(wrapper -> {
|
||||
if (wrapper.user().get(NonceStorage.class) != null) {
|
||||
@ -285,9 +275,9 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
|
||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Key
|
||||
handler(wrapper -> {
|
||||
final NonceStorage nonceStorage = wrapper.user().remove(NonceStorage.class);
|
||||
@ -310,9 +300,9 @@ public final class Protocol1_19To1_19_1 extends BackwardsProtocol<ClientboundPac
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY.getId(), ClientboundLoginPackets.CUSTOM_QUERY.getId(), new PacketRemapper() {
|
||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY.getId(), ClientboundLoginPackets.CUSTOM_QUERY.getId(), new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT);
|
||||
map(Type.STRING);
|
||||
handler(wrapper -> {
|
||||
|
@ -19,7 +19,6 @@ package com.viaversion.viabackwards.protocol.protocol1_19to1_19_1.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class ReceivedMessagesStorage implements StorableObject {
|
||||
|
@ -26,7 +26,7 @@ import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.packets.EntityPa
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
@ -54,9 +54,9 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9
|
||||
blockItemPackets.register();
|
||||
|
||||
SoundRewriter<ClientboundPackets1_9_3> soundRewriter = new SoundRewriter<>(this);
|
||||
registerClientbound(ClientboundPackets1_9_3.NAMED_SOUND, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_9_3.NAMED_SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // 0 - Sound name
|
||||
map(Type.VAR_INT); // 1 - Sound Category
|
||||
map(Type.INT); // 2 - x
|
||||
@ -67,9 +67,9 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9
|
||||
handler(soundRewriter.getNamedSoundHandler());
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_9_3.SOUND, new PacketRemapper() {
|
||||
registerClientbound(ClientboundPackets1_9_3.SOUND, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Sound name
|
||||
map(Type.VAR_INT); // 1 - Sound Category
|
||||
map(Type.INT); // 2 - x
|
||||
@ -81,9 +81,9 @@ public class Protocol1_9_4To1_10 extends BackwardsProtocol<ClientboundPackets1_9
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_9_3.RESOURCE_PACK_STATUS, new PacketRemapper() {
|
||||
registerServerbound(ServerboundPackets1_9_3.RESOURCE_PACK_STATUS, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING, Type.NOTHING); // 0 - Hash
|
||||
map(Type.VAR_INT); // 1 - Result
|
||||
}
|
||||
|
@ -23,9 +23,7 @@ import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
@ -46,14 +44,12 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
// Entity Equipment Packet
|
||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.STRING); // 0 - Channel
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
@ -72,7 +68,6 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -80,55 +75,41 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM);
|
||||
registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change Packet
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.POSITION); // 0 - Block Position
|
||||
map(Type.VAR_INT); // 1 - Block
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int idx = wrapper.get(Type.VAR_INT, 0);
|
||||
wrapper.set(Type.VAR_INT, 0, handleBlockID(idx));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Multi Block Change Packet
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.MULTI_BLOCK_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -140,9 +121,9 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
});
|
||||
|
||||
// Particle
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PARTICLE, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PARTICLE, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.INT);
|
||||
map(Type.BOOLEAN);
|
||||
map(Type.FLOAT);
|
||||
@ -154,14 +135,11 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
map(Type.FLOAT);
|
||||
map(Type.INT);
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 46) { // new falling_dust
|
||||
wrapper.set(Type.INT, 0, 38); // -> block_dust
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -29,13 +29,10 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||
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.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -47,9 +44,9 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.BYTE); // 2 - Type
|
||||
@ -65,9 +62,7 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
handler(getObjectRewriter(id -> Entity1_11Types.ObjectType.findById(id).orElse(null)));
|
||||
|
||||
// Handle FallingBlock blocks
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
Optional<Entity1_12Types.ObjectType> type = Entity1_12Types.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == Entity1_12Types.ObjectType.FALLING_BLOCK) {
|
||||
int objectData = wrapper.get(Type.INT, 0);
|
||||
@ -80,7 +75,6 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
wrapper.set(Type.INT, 0, block.getId() | block.getData() << 12);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -88,9 +82,9 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_EXPERIENCE_ORB, Entity1_10Types.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.SPAWN_GLOBAL_ENTITY, Entity1_10Types.EntityType.WEATHER);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.UNSIGNED_BYTE); // 2 - Entity Type
|
||||
@ -109,9 +103,7 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
handler(getTrackerHandler(Type.UNSIGNED_BYTE, 0));
|
||||
|
||||
// Rewrite entity type / metadata
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityType type = tracker(wrapper.user()).entityType(entityId);
|
||||
|
||||
@ -125,7 +117,6 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
if (entityData.hasBaseMeta())
|
||||
entityData.defaultMeta().createMeta(storage);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@ -135,9 +126,9 @@ public class EntityPackets1_10 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, Entity1_10Types.EntityType.PLAYER);
|
||||
registerRespawn(ClientboundPackets1_9_3.RESPAWN);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Player UUID
|
||||
map(Type.DOUBLE); // 2 - X
|
||||
|
@ -20,12 +20,11 @@ package com.viaversion.viabackwards;
|
||||
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viabackwards.fabric.util.LoggerWrapper;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Logger;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable {
|
||||
private final Logger logger = new LoggerWrapper(LogManager.getLogger("ViaBackwards"));
|
||||
|
@ -22,15 +22,14 @@ import com.google.inject.Inject;
|
||||
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.sponge.util.LoggerWrapper;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Logger;
|
||||
import org.spongepowered.api.config.ConfigDir;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.lifecycle.ConstructPluginEvent;
|
||||
import org.spongepowered.plugin.builtin.jvm.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Plugin("viabackwards")
|
||||
public class SpongePlugin implements ViaBackwardsPlatform {
|
||||
@SuppressWarnings("SpongeLogging")
|
||||
|
@ -29,7 +29,6 @@ import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
|
||||
import com.viaversion.viabackwards.utils.VersionInfo;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.velocity.util.LoggerWrapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Logger;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren