3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

Enforce correct packet types with generics, 1.9 packet constant

Dieser Commit ist enthalten in:
KennyTV 2020-06-06 09:45:43 +02:00
Ursprung 38f845bb7e
Commit 545ab2de79
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
32 geänderte Dateien mit 345 neuen und 355 gelöschten Zeilen

Datei anzeigen

@ -16,14 +16,24 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
public abstract class Protocol { /**
* Abstract protocol class handling packet transformation between two protocol versions.
* Clientbound and serverbount packet types can be set to enforce correct usage of them.
*
* @param <C1> old clientbound packet types
* @param <C2> new clientbound packet types
* @param <S1> old serverbound packet types
* @param <S2> new serverbound packet types
* @see SimpleProtocol for a helper class if you do not want to define any of the types above
*/
public abstract class Protocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType> {
private final Map<Packet, ProtocolPacket> incoming = new HashMap<>(); private final Map<Packet, ProtocolPacket> incoming = new HashMap<>();
private final Map<Packet, ProtocolPacket> outgoing = new HashMap<>(); private final Map<Packet, ProtocolPacket> outgoing = new HashMap<>();
private final Map<Class, Object> storedObjects = new HashMap<>(); // currently only used for MetadataRewriters private final Map<Class, Object> storedObjects = new HashMap<>(); // currently only used for MetadataRewriters
protected final Class<? extends ClientboundPacketType> oldClientboundPacketEnum; protected final Class<C1> oldClientboundPacketEnum;
protected final Class<? extends ClientboundPacketType> newClientboundPacketEnum; protected final Class<C2> newClientboundPacketEnum;
protected final Class<? extends ServerboundPacketType> oldServerboundPacketEnum; protected final Class<S1> oldServerboundPacketEnum;
protected final Class<? extends ServerboundPacketType> newServerboundPacketEnum; protected final Class<S2> newServerboundPacketEnum;
protected final boolean hasMappingDataToLoad; protected final boolean hasMappingDataToLoad;
protected Protocol() { protected Protocol() {
@ -37,8 +47,8 @@ public abstract class Protocol {
/** /**
* Creates a protocol with automated id mapping if the respective enums are not null. * Creates a protocol with automated id mapping if the respective enums are not null.
*/ */
protected Protocol(Class<? extends ClientboundPacketType> oldClientboundPacketEnum, Class<? extends ClientboundPacketType> clientboundPacketEnum, protected Protocol(Class<C1> oldClientboundPacketEnum, Class<C2> clientboundPacketEnum,
Class<? extends ServerboundPacketType> oldServerboundPacketEnum, Class<? extends ServerboundPacketType> serverboundPacketEnum) { Class<S1> oldServerboundPacketEnum, Class<S2> serverboundPacketEnum) {
this(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, false); this(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, false);
} }
@ -47,8 +57,8 @@ public abstract class Protocol {
* *
* @param hasMappingDataToLoad whether an async executor should call the {@Link #loadMappingData} method * @param hasMappingDataToLoad whether an async executor should call the {@Link #loadMappingData} method
*/ */
protected Protocol(Class<? extends ClientboundPacketType> oldClientboundPacketEnum, Class<? extends ClientboundPacketType> clientboundPacketEnum, protected Protocol(Class<C1> oldClientboundPacketEnum, Class<C2> clientboundPacketEnum,
Class<? extends ServerboundPacketType> oldServerboundPacketEnum, Class<? extends ServerboundPacketType> serverboundPacketEnum, boolean hasMappingDataToLoad) { Class<S1> oldServerboundPacketEnum, Class<S2> serverboundPacketEnum, boolean hasMappingDataToLoad) {
this.oldClientboundPacketEnum = oldClientboundPacketEnum; this.oldClientboundPacketEnum = oldClientboundPacketEnum;
this.newClientboundPacketEnum = clientboundPacketEnum; this.newClientboundPacketEnum = clientboundPacketEnum;
this.oldServerboundPacketEnum = oldServerboundPacketEnum; this.oldServerboundPacketEnum = oldServerboundPacketEnum;
@ -139,9 +149,10 @@ public abstract class Protocol {
} }
/** /**
* Register the packets for this protocol. * Register the packets for this protocol. To be overriden.
*/ */
protected abstract void registerPackets(); protected void registerPackets() {
}
/** /**
* Load mapping data for the protocol. * Load mapping data for the protocol.
@ -254,7 +265,6 @@ public abstract class Protocol {
cancelOutgoing(state, oldPacketID, -1); cancelOutgoing(state, oldPacketID, -1);
} }
public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) { public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper); ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
Packet packet = new Packet(state, oldPacketID); Packet packet = new Packet(state, oldPacketID);
@ -265,15 +275,14 @@ public abstract class Protocol {
outgoing.put(packet, protocolPacket); outgoing.put(packet, protocolPacket);
} }
/** /**
* Registers an outgoing protocol and automatically maps it to the new id. * Registers an outgoing protocol and automatically maps it to the new id.
* *
* @param packetType packet type the server sends * @param packetType clientbound packet type the server sends
* @param packetRemapper remapper * @param packetRemapper remapper
*/ */
public void registerOutgoing(ClientboundPacketType packetType, PacketRemapper packetRemapper) { public void registerOutgoing(C1 packetType, PacketRemapper packetRemapper) {
Preconditions.checkArgument(packetType.getClass() == oldClientboundPacketEnum);
ClientboundPacketType mappedPacket = oldClientboundPacketEnum == newClientboundPacketEnum ? packetType ClientboundPacketType mappedPacket = oldClientboundPacketEnum == newClientboundPacketEnum ? packetType
: Arrays.stream(newClientboundPacketEnum.getEnumConstants()).filter(en -> en.name().equals(packetType.name())).findAny().orElse(null); : Arrays.stream(newClientboundPacketEnum.getEnumConstants()).filter(en -> en.name().equals(packetType.name())).findAny().orElse(null);
Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!"); Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!");
@ -286,32 +295,36 @@ public abstract class Protocol {
/** /**
* Registers an outgoing protocol. * Registers an outgoing protocol.
* *
* @param packetType packet type the server initially sends * @param packetType clientbound packet type the server initially sends
* @param mappedPacketType packet type after transforming for the client * @param mappedPacketType clientbound packet type after transforming for the client
* @param packetRemapper remapper * @param packetRemapper remapper
*/ */
public void registerOutgoing(ClientboundPacketType packetType, ClientboundPacketType mappedPacketType, PacketRemapper packetRemapper) { public void registerOutgoing(C1 packetType, C2 mappedPacketType, PacketRemapper packetRemapper) {
Preconditions.checkArgument(packetType.getClass() == oldClientboundPacketEnum);
Preconditions.checkArgument(mappedPacketType == null || mappedPacketType.getClass() == newClientboundPacketEnum);
registerOutgoing(State.PLAY, packetType.ordinal(), mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetRemapper); registerOutgoing(State.PLAY, packetType.ordinal(), mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetRemapper);
} }
public void registerOutgoing(ClientboundPacketType oldPacketType, ClientboundPacketType newPacketType) { /**
registerOutgoing(oldPacketType, newPacketType, null); * Maps a packet type to another packet type without a packet handler.
* Note that this should not be called for simple channel mappings of the same packet; this is already done automatically.
*
* @param packetType clientbound packet type the server initially sends
* @param mappedPacketType clientbound packet type after transforming for the client
*/
public void registerOutgoing(C1 packetType, C2 mappedPacketType) {
registerOutgoing(packetType, mappedPacketType, null);
} }
public void cancelOutgoing(ClientboundPacketType packetType) { public void cancelOutgoing(C1 packetType) {
Preconditions.checkArgument(packetType.getClass() == oldClientboundPacketEnum);
cancelOutgoing(State.PLAY, packetType.ordinal(), packetType.ordinal()); cancelOutgoing(State.PLAY, packetType.ordinal(), packetType.ordinal());
} }
/** /**
* Registers an incoming protocol and automatically maps it to the server's id. * Registers an incoming protocol and automatically maps it to the server's id.
* *
* @param packetType packet type the client sends * @param packetType serverbound packet type the client sends
* @param packetRemapper remapper * @param packetRemapper remapper
*/ */
public void registerIncoming(ServerboundPacketType packetType, PacketRemapper packetRemapper) { public void registerIncoming(S2 packetType, PacketRemapper packetRemapper) {
Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum); Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum);
ServerboundPacketType mappedPacket = oldServerboundPacketEnum == newServerboundPacketEnum ? packetType ServerboundPacketType mappedPacket = oldServerboundPacketEnum == newServerboundPacketEnum ? packetType
@ -326,17 +339,15 @@ public abstract class Protocol {
/** /**
* Registers an incoming protocol. * Registers an incoming protocol.
* *
* @param packetType packet type initially sent by the client * @param packetType serverbound packet type initially sent by the client
* @param mappedPacketType packet type after transforming for the server * @param mappedPacketType serverbound packet type after transforming for the server
* @param packetRemapper remapper * @param packetRemapper remapper
*/ */
public void registerIncoming(ServerboundPacketType packetType, ServerboundPacketType mappedPacketType, PacketRemapper packetRemapper) { public void registerIncoming(S2 packetType, S1 mappedPacketType, PacketRemapper packetRemapper) {
Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum);
Preconditions.checkArgument(mappedPacketType == null || mappedPacketType.getClass() == oldServerboundPacketEnum);
registerIncoming(State.PLAY, mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetType.ordinal(), packetRemapper); registerIncoming(State.PLAY, mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetType.ordinal(), packetRemapper);
} }
public void cancelIncoming(ServerboundPacketType packetType) { public void cancelIncoming(S2 packetType) {
Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum); Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum);
cancelIncoming(State.PLAY, -1, packetType.ordinal()); cancelIncoming(State.PLAY, -1, packetType.ordinal());
} }

Datei anzeigen

@ -0,0 +1,24 @@
package us.myles.ViaVersion.api.protocol;
/**
* Dummy protocol class for when you do not need any of the existing packet type enums
* or automated channel mappings.
*
* @see Protocol
*/
public abstract class SimpleProtocol extends Protocol<SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes, SimpleProtocol.DummyPacketTypes> {
protected SimpleProtocol() {
}
protected SimpleProtocol(boolean hasMappingDataToLoad) {
super(hasMappingDataToLoad);
}
public enum DummyPacketTypes implements ClientboundPacketType, ServerboundPacketType {
}
@Override
protected void registerPackets() {
}
}

Datei anzeigen

@ -7,7 +7,6 @@ import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
// If any of these methods become outdated, just create a new rewriter overriding the methods // If any of these methods become outdated, just create a new rewriter overriding the methods
public class ItemRewriter { public class ItemRewriter {
@ -117,77 +116,6 @@ public class ItemRewriter {
return wrapper -> toServer.rewrite(wrapper.get(type, 0)); return wrapper -> toServer.rewrite(wrapper.get(type, 0));
} }
@Deprecated
public void registerWindowItems(Type<Item[]> type, int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(type); // 1 - Window Values
handler(itemArrayHandler(type));
}
});
}
@Deprecated
public void registerSetSlot(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot ID
map(type); // 2 - Slot Value
handler(itemToClientHandler(type));
}
});
}
@Deprecated
public void registerEntityEquipment(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
map(Type.VAR_INT); // 1 - Slot ID
map(type); // 2 - Item
handler(itemToClientHandler(type));
}
});
}
@Deprecated
public void registerCreativeInvAction(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.SHORT); // 0 - Slot
map(type); // 1 - Clicked Item
handler(itemToServerHandler(type));
}
});
}
@Deprecated
public void registerClickWindow(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot
map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode
map(type); // 5 - Clicked Item
handler(itemToServerHandler(type));
}
});
}
@FunctionalInterface @FunctionalInterface
public interface RewriteFunction { public interface RewriteFunction {

Datei anzeigen

@ -10,7 +10,6 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.storage.EntityTracker; import us.myles.ViaVersion.api.storage.EntityTracker;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.ArrayList; import java.util.ArrayList;
@ -205,78 +204,6 @@ public abstract class MetadataRewriter {
return getTrackerAndRewriter(null); return getTrackerAndRewriter(null);
} }
@Deprecated
public void registerJoinGame(int oldPacketId, int newPacketId, EntityType playerType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Entity ID
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
map(Type.INT); // 2 - Dimension
handler(wrapper -> {
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 1);
clientChunks.setEnvironment(dimensionId);
if (playerType != null) {
wrapper.user().get(entityTrackerClass).addEntity(wrapper.get(Type.INT, 0), playerType);
}
});
}
});
}
@Deprecated
public void registerRespawn(int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT);
handler(wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 0);
clientWorld.setEnvironment(dimensionId);
});
}
});
}
@Deprecated
public void registerEntityDestroy(int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entity ids
handler(wrapper -> {
EntityTracker entityTracker = wrapper.user().get(entityTrackerClass);
for (int entity : wrapper.get(Type.VAR_INT_ARRAY_PRIMITIVE, 0)) {
entityTracker.removeEntity(entity);
}
});
}
});
}
@Deprecated
public void registerMetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
if (oldMetaType != null) {
map(oldMetaType, newMetaType);
} else {
map(newMetaType);
}
handler(wrapper -> {
int entityId = wrapper.get(Type.VAR_INT, 0);
List<Metadata> metadata = wrapper.get(newMetaType, 0);
handleMetadata(entityId, metadata, wrapper.user());
});
}
});
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Sub 1.14.1 methods // Sub 1.14.1 methods

Datei anzeigen

@ -8,28 +8,24 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Metadata1_9Type;
import us.myles.ViaVersion.api.type.types.version.MetadataList1_9Type;
import us.myles.ViaVersion.api.type.types.version.Types1_9; import us.myles.ViaVersion.api.type.types.version.Types1_9;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.storage.ResourcePackTracker; import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.storage.ResourcePackTracker;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
public class Protocol1_10To1_9_3_4 extends Protocol { public class Protocol1_10To1_9_3_4 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
@Deprecated
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_9Type();
@Deprecated
public static final Type<Metadata> METADATA = new Metadata1_9Type();
public static final ValueTransformer<Short, Float> toNewPitch = new ValueTransformer<Short, Float>(Type.FLOAT) { public static final ValueTransformer<Short, Float> TO_NEW_PITCH = new ValueTransformer<Short, Float>(Type.FLOAT) {
@Override @Override
public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception { public Float transform(PacketWrapper wrapper, Short inputValue) throws Exception {
return inputValue / 63.5F; return inputValue / 63.5F;
} }
}; };
public static final ValueTransformer<List<Metadata>, List<Metadata>> transformMetadata = new ValueTransformer<List<Metadata>, List<Metadata>>(Types1_9.METADATA_LIST) { public static final ValueTransformer<List<Metadata>, List<Metadata>> TRANSFORM_METADATA = new ValueTransformer<List<Metadata>, List<Metadata>>(Types1_9.METADATA_LIST) {
@Override @Override
public List<Metadata> transform(PacketWrapper wrapper, List<Metadata> inputValue) throws Exception { public List<Metadata> transform(PacketWrapper wrapper, List<Metadata> inputValue) throws Exception {
List<Metadata> metaList = new CopyOnWriteArrayList<>(inputValue); List<Metadata> metaList = new CopyOnWriteArrayList<>(inputValue);
@ -41,6 +37,10 @@ public class Protocol1_10To1_9_3_4 extends Protocol {
} }
}; };
public Protocol1_10To1_9_3_4() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// Named sound effect // Named sound effect
@ -53,7 +53,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol {
map(Type.INT); // 3 - y map(Type.INT); // 3 - y
map(Type.INT); // 4 - z map(Type.INT); // 4 - z
map(Type.FLOAT); // 5 - Volume map(Type.FLOAT); // 5 - Volume
map(Type.UNSIGNED_BYTE, toNewPitch); // 6 - Pitch map(Type.UNSIGNED_BYTE, TO_NEW_PITCH); // 6 - Pitch
} }
}); });
@ -67,7 +67,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol {
map(Type.INT); // 3 - y map(Type.INT); // 3 - y
map(Type.INT); // 4 - z map(Type.INT); // 4 - z
map(Type.FLOAT); // 5 - Volume map(Type.FLOAT); // 5 - Volume
map(Type.UNSIGNED_BYTE, toNewPitch); // 6 - Pitch map(Type.UNSIGNED_BYTE, TO_NEW_PITCH); // 6 - Pitch
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
@ -84,7 +84,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
map(Types1_9.METADATA_LIST, transformMetadata); // 1 - Metadata list map(Types1_9.METADATA_LIST, TRANSFORM_METADATA); // 1 - Metadata list
} }
}); });
@ -104,7 +104,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol {
map(Type.SHORT); // 9 - Velocity X map(Type.SHORT); // 9 - Velocity X
map(Type.SHORT); // 10 - Velocity Y map(Type.SHORT); // 10 - Velocity Y
map(Type.SHORT); // 11 - Velocity Z map(Type.SHORT); // 11 - Velocity Z
map(Types1_9.METADATA_LIST, transformMetadata); // 12 - Metadata map(Types1_9.METADATA_LIST, TRANSFORM_METADATA); // 12 - Metadata
} }
}); });
@ -119,7 +119,7 @@ public class Protocol1_10To1_9_3_4 extends Protocol {
map(Type.DOUBLE); // 4 - Z map(Type.DOUBLE); // 4 - Z
map(Type.BYTE); // 5 - Yaw map(Type.BYTE); // 5 - Yaw
map(Type.BYTE); // 6 - Pitch map(Type.BYTE); // 6 - Pitch
map(Types1_9.METADATA_LIST, transformMetadata); // 7 - Metadata list map(Types1_9.METADATA_LIST, TRANSFORM_METADATA); // 7 - Metadata list
} }
}); });

Datei anzeigen

@ -1,11 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_11_1to1_11; package us.myles.ViaVersion.protocols.protocol1_11_1to1_11;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
public class Protocol1_11_1To1_11 extends Protocol { public class Protocol1_11_1To1_11 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
@Override
protected void registerPackets() {
// Only had metadata changes, see wiki.vg for full info.
}
} }

Datei anzeigen

@ -15,14 +15,15 @@ import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_9; import us.myles.ViaVersion.api.type.types.version.Types1_9;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.metadata.MetadataRewriter1_11To1_10; import us.myles.ViaVersion.protocols.protocol1_11to1_10.metadata.MetadataRewriter1_11To1_10;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_11to1_10.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.storage.EntityTracker1_11; import us.myles.ViaVersion.protocols.protocol1_11to1_10.storage.EntityTracker1_11;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type; import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_11To1_10 extends Protocol { public class Protocol1_11To1_10 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
private static final ValueTransformer<Float, Short> toOldByte = new ValueTransformer<Float, Short>(Type.UNSIGNED_BYTE) { private static final ValueTransformer<Float, Short> toOldByte = new ValueTransformer<Float, Short>(Type.UNSIGNED_BYTE) {
@Override @Override
public Short transform(PacketWrapper wrapper, Float inputValue) throws Exception { public Short transform(PacketWrapper wrapper, Float inputValue) throws Exception {
@ -30,14 +31,17 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}; };
public Protocol1_11To1_10() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
MetadataRewriter1_11To1_10 metadataRewriter = new MetadataRewriter1_11To1_10(this); MetadataRewriter1_11To1_10 metadataRewriter = new MetadataRewriter1_11To1_10(this);
InventoryPackets.register(this); InventoryPackets.register(this);
// Spawn Object registerOutgoing(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id map(Type.VAR_INT); // 0 - Entity id
@ -49,8 +53,7 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}); });
// Spawn mob packet registerOutgoing(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -87,10 +90,9 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}); });
//new SoundRewriter(this, this::getNewSoundId).registerSound(0x46, 0x46); //TODO _------------------------------------------------------ new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
// Collect item packet registerOutgoing(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x48, 0x48, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Collected entity id map(Type.VAR_INT); // 0 - Collected entity id
@ -105,11 +107,9 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}); });
// Metadata packet metadataRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
metadataRewriter.registerMetadataRewriter(0x39, 0x39, null, Types1_9.METADATA_LIST);
// Entity teleport registerOutgoing(ClientboundPackets1_9_3.ENTITY_TELEPORT, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id map(Type.VAR_INT); // 0 - Entity id
@ -137,11 +137,9 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}); });
// Destroy entities metadataRewriter.registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES);
metadataRewriter.registerEntityDestroy(0x30, 0x30);
// Title packet registerOutgoing(ClientboundPackets1_9_3.TITLE, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x45, 0x45, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Action map(Type.VAR_INT); // 0 - Action
@ -161,8 +159,7 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}); });
// Block action packet registerOutgoing(ClientboundPackets1_9_3.BLOCK_ACTION, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION); // 0 - Position map(Type.POSITION); // 0 - Position
@ -185,8 +182,7 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}); });
// Update Block Entity registerOutgoing(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION); // 0 - Position map(Type.POSITION); // 0 - Position
@ -209,8 +205,7 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}); });
// Chunk Data registerOutgoing(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -240,18 +235,15 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}); });
// Join (save dimension id) metadataRewriter.registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, null);
metadataRewriter.registerJoinGame(0x23, 0x23, null);
// Respawn (save dimension id) metadataRewriter.registerRespawn(ClientboundPackets1_9_3.RESPAWN);
metadataRewriter.registerRespawn(0x33, 0x33);
/* /*
INCOMING PACKETS INCOMING PACKETS
*/ */
// Block placement registerIncoming(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
registerIncoming(State.PLAY, 0x1C, 0x1C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION); // 0 - Location map(Type.POSITION); // 0 - Location
@ -264,8 +256,7 @@ public class Protocol1_11To1_10 extends Protocol {
} }
}); });
// Chat Message Incoming registerIncoming(ServerboundPackets1_9_3.CHAT_MESSAGE, new PacketRemapper() {
registerIncoming(State.PLAY, 0x02, 0x02, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // 0 - Message map(Type.STRING); // 0 - Message

Datei anzeigen

@ -5,7 +5,8 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.rewriters.ItemRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.EntityIdRewriter; import us.myles.ViaVersion.protocols.protocol1_11to1_10.EntityIdRewriter;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10; import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
@ -14,17 +15,12 @@ public class InventoryPackets {
public static void register(Protocol1_11To1_10 protocol) { public static void register(Protocol1_11To1_10 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, EntityIdRewriter::toClientItem, EntityIdRewriter::toServerItem); ItemRewriter itemRewriter = new ItemRewriter(protocol, EntityIdRewriter::toClientItem, EntityIdRewriter::toServerItem);
// Set slot packet itemRewriter.registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
itemRewriter.registerSetSlot(Type.ITEM, 0x16, 0x16); itemRewriter.registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY);
itemRewriter.registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
// Window items packet
itemRewriter.registerWindowItems(Type.ITEM_ARRAY, 0x14, 0x14);
// Entity Equipment Packet
itemRewriter.registerEntityEquipment(Type.ITEM, 0x3C, 0x3C);
// Plugin message Packet -> Trading // Plugin message Packet -> Trading
protocol.registerOutgoing(State.PLAY, 0x18, 0x18, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // 0 - Channel map(Type.STRING); // 0 - Channel
@ -54,11 +50,7 @@ public class InventoryPackets {
} }
}); });
itemRewriter.registerClickWindow(ServerboundPackets1_9_3.CLICK_WINDOW, Type.ITEM);
// Click window packet itemRewriter.registerCreativeInvAction(ServerboundPackets1_9_3.CREATIVE_INVENTORY_ACTION, Type.ITEM);
itemRewriter.registerClickWindow(Type.ITEM, 0x07, 0x07);
// Creative Inventory Action
itemRewriter.registerCreativeInvAction(Type.ITEM, 0x18, 0x18);
} }
} }

Datei anzeigen

@ -4,7 +4,7 @@ import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
public class Protocol1_12_1To1_12 extends Protocol { public class Protocol1_12_1To1_12 extends Protocol<ClientboundPackets1_12, ClientboundPackets1_12_1, ServerboundPackets1_12, ServerboundPackets1_12_1> {
public Protocol1_12_1To1_12() { public Protocol1_12_1To1_12() {
super(ClientboundPackets1_12.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12.class, ServerboundPackets1_12_1.class); super(ClientboundPackets1_12.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12.class, ServerboundPackets1_12_1.class);

Datei anzeigen

@ -16,8 +16,8 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.SoundRewriter; import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_12; import us.myles.ViaVersion.api.type.types.version.Types1_12;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.ClientboundPackets1_11; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.ServerboundPackets1_11; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.metadata.MetadataRewriter1_12To1_11_1; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.metadata.MetadataRewriter1_12To1_11_1;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQuickMoveProvider; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQuickMoveProvider;
@ -27,10 +27,10 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.util.GsonUtil;
public class Protocol1_12To1_11_1 extends Protocol { public class Protocol1_12To1_11_1 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_12, ServerboundPackets1_9_3, ServerboundPackets1_12> {
public Protocol1_12To1_11_1() { public Protocol1_12To1_11_1() {
super(ClientboundPackets1_11.class, ClientboundPackets1_12.class, ServerboundPackets1_11.class, ServerboundPackets1_12.class); super(ClientboundPackets1_9_3.class, ClientboundPackets1_12.class, ServerboundPackets1_9_3.class, ServerboundPackets1_12.class);
} }
@Override @Override
@ -39,7 +39,7 @@ public class Protocol1_12To1_11_1 extends Protocol {
InventoryPackets.register(this); InventoryPackets.register(this);
registerOutgoing(ClientboundPackets1_11.SPAWN_ENTITY, new PacketRemapper() { registerOutgoing(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id map(Type.VAR_INT); // 0 - Entity id
@ -51,7 +51,7 @@ public class Protocol1_12To1_11_1 extends Protocol {
} }
}); });
registerOutgoing(ClientboundPackets1_11.SPAWN_MOB, new PacketRemapper() { registerOutgoing(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -73,7 +73,7 @@ public class Protocol1_12To1_11_1 extends Protocol {
} }
}); });
registerOutgoing(ClientboundPackets1_11.CHAT_MESSAGE, new PacketRemapper() { registerOutgoing(ClientboundPackets1_9_3.CHAT_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Chat Message (json) map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Chat Message (json)
@ -99,7 +99,7 @@ public class Protocol1_12To1_11_1 extends Protocol {
} }
}); });
registerOutgoing(ClientboundPackets1_11.CHUNK_DATA, new PacketRemapper() { registerOutgoing(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -142,12 +142,12 @@ public class Protocol1_12To1_11_1 extends Protocol {
} }
}); });
metadataRewriter.registerJoinGame(ClientboundPackets1_11.JOIN_GAME, null); metadataRewriter.registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, null);
metadataRewriter.registerEntityDestroy(ClientboundPackets1_11.DESTROY_ENTITIES); metadataRewriter.registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES);
metadataRewriter.registerRespawn(ClientboundPackets1_11.RESPAWN); metadataRewriter.registerRespawn(ClientboundPackets1_9_3.RESPAWN);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_11.ENTITY_METADATA, Types1_12.METADATA_LIST); metadataRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_12.METADATA_LIST);
new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_11.SOUND); new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
// New packet at 0x01 // New packet at 0x01

Datei anzeigen

@ -7,7 +7,7 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.ItemRewriter; import us.myles.ViaVersion.api.rewriters.ItemRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.ClientboundPackets1_11; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.BedRewriter; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.BedRewriter;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
@ -18,12 +18,12 @@ public class InventoryPackets {
public static void register(Protocol1_12To1_11_1 protocol) { public static void register(Protocol1_12To1_11_1 protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, BedRewriter::toClientItem, BedRewriter::toServerItem); ItemRewriter itemRewriter = new ItemRewriter(protocol, BedRewriter::toClientItem, BedRewriter::toServerItem);
itemRewriter.registerSetSlot(ClientboundPackets1_11.SET_SLOT, Type.ITEM); itemRewriter.registerSetSlot(ClientboundPackets1_9_3.SET_SLOT, Type.ITEM);
itemRewriter.registerWindowItems(ClientboundPackets1_11.WINDOW_ITEMS, Type.ITEM_ARRAY); itemRewriter.registerWindowItems(ClientboundPackets1_9_3.WINDOW_ITEMS, Type.ITEM_ARRAY);
itemRewriter.registerEntityEquipment(ClientboundPackets1_11.ENTITY_EQUIPMENT, Type.ITEM); itemRewriter.registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
// Plugin message Packet -> Trading // Plugin message Packet -> Trading
protocol.registerOutgoing(ClientboundPackets1_11.PLUGIN_MESSAGE, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // 0 - Channel map(Type.STRING); // 0 - Channel

Datei anzeigen

@ -17,7 +17,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1_13; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1_13;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_13_1To1_13 extends Protocol { public class Protocol1_13_1To1_13 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
public Protocol1_13_1To1_13() { public Protocol1_13_1To1_13() {
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);

Datei anzeigen

@ -12,7 +12,7 @@ import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.WorldPackets
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
public class Protocol1_13_2To1_13_1 extends Protocol { public class Protocol1_13_2To1_13_1 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_13, ServerboundPackets1_13, ServerboundPackets1_13> {
public Protocol1_13_2To1_13_1() { public Protocol1_13_2To1_13_1() {
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class); super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);

Datei anzeigen

@ -43,7 +43,7 @@ import us.myles.ViaVersion.util.GsonUtil;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.Map; import java.util.Map;
public class Protocol1_13To1_12_2 extends Protocol { public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, ClientboundPackets1_13, ServerboundPackets1_12_1, ServerboundPackets1_13> {
public Protocol1_13To1_12_2() { public Protocol1_13To1_12_2() {
super(ClientboundPackets1_12_1.class, ClientboundPackets1_13.class, ServerboundPackets1_12_1.class, ServerboundPackets1_13.class, true); super(ClientboundPackets1_12_1.class, ClientboundPackets1_13.class, ServerboundPackets1_12_1.class, ServerboundPackets1_13.class, true);

Datei anzeigen

@ -8,7 +8,7 @@ import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
public class Protocol1_14_1To1_14 extends Protocol { public class Protocol1_14_1To1_14 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
public Protocol1_14_1To1_14() { public Protocol1_14_1To1_14() {
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class); super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);

Datei anzeigen

@ -1,10 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_14_2to1_14_1; package us.myles.ViaVersion.protocols.protocol1_14_2to1_14_1;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
public class Protocol1_14_2To1_14_1 extends Protocol { public class Protocol1_14_2To1_14_1 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
@Override
protected void registerPackets() {
}
} }

Datei anzeigen

@ -5,14 +5,18 @@ import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
public class Protocol1_14_3To1_14_2 extends Protocol { public class Protocol1_14_3To1_14_2 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
public Protocol1_14_3To1_14_2() {
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, null, null);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// Trade list registerOutgoing(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x27, 0x27, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {

Datei anzeigen

@ -5,14 +5,18 @@ import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
public class Protocol1_14_4To1_14_3 extends Protocol { public class Protocol1_14_4To1_14_3 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
public Protocol1_14_4To1_14_3() {
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, null, null);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// trade list registerOutgoing(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x27, 0x27, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {

Datei anzeigen

@ -19,7 +19,7 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_14To1_13_2 extends Protocol { public class Protocol1_14To1_13_2 extends Protocol<ClientboundPackets1_13, ClientboundPackets1_14, ServerboundPackets1_13, ServerboundPackets1_14> {
public Protocol1_14To1_13_2() { public Protocol1_14To1_13_2() {
super(ClientboundPackets1_13.class, ClientboundPackets1_14.class, ServerboundPackets1_13.class, ServerboundPackets1_14.class, true); super(ClientboundPackets1_13.class, ClientboundPackets1_14.class, ServerboundPackets1_13.class, ServerboundPackets1_14.class, true);

Datei anzeigen

@ -1,10 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_15_1to1_15; package us.myles.ViaVersion.protocols.protocol1_15_1to1_15;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
public class Protocol1_15_1To1_15 extends Protocol { public class Protocol1_15_1To1_15 extends Protocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
@Override
protected void registerPackets() {
}
} }

Datei anzeigen

@ -1,10 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_15_2to1_15_1; package us.myles.ViaVersion.protocols.protocol1_15_2to1_15_1;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
public class Protocol1_15_2To1_15_1 extends Protocol { public class Protocol1_15_2To1_15_1 extends Protocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
@Override
protected void registerPackets() {
}
} }

Datei anzeigen

@ -21,7 +21,7 @@ import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.WorldPackets;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_15To1_14_4 extends Protocol { public class Protocol1_15To1_14_4 extends Protocol<ClientboundPackets1_14, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
private TagRewriter tagRewriter; private TagRewriter tagRewriter;

Datei anzeigen

@ -21,7 +21,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.UUID; import java.util.UUID;
public class Protocol1_16To1_15_2 extends Protocol { public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, ClientboundPackets1_16, ServerboundPackets1_14, ServerboundPackets1_16> {
public static final UUID ZERO_UUID = new UUID(0, 0); public static final UUID ZERO_UUID = new UUID(0, 0);
private TagRewriter tagRewriter; private TagRewriter tagRewriter;

Datei anzeigen

@ -9,27 +9,25 @@ import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.BlockEntity; import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.BlockEntity;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type; import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
public class Protocol1_9_1_2To1_9_3_4 extends Protocol { // Goes BACKWARDS from 1.9.3/4 to 1.9.1/2
public class Protocol1_9_1_2To1_9_3_4 extends Protocol<ClientboundPackets1_9_3, ClientboundPackets1_9, ServerboundPackets1_9_3, ServerboundPackets1_9> {
public Protocol1_9_1_2To1_9_3_4() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
registerOutgoing(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {
//Unchanged packet structure
registerOutgoing(State.PLAY, 0x46, 0x47); //Sound effect
registerOutgoing(State.PLAY, 0x47, 0x48); //Player list header and footer
registerOutgoing(State.PLAY, 0x48, 0x49); //Collect item
registerOutgoing(State.PLAY, 0x49, 0x4A); //Entity teleport
registerOutgoing(State.PLAY, 0x4A, 0x4B); //Entity properties
registerOutgoing(State.PLAY, 0x4B, 0x4C); //Entity effect
//Update block entity
registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION); //Position map(Type.POSITION); //Position
@ -54,8 +52,7 @@ public class Protocol1_9_1_2To1_9_3_4 extends Protocol {
} }
}); });
// Chunk Packet registerOutgoing(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -74,8 +71,7 @@ public class Protocol1_9_1_2To1_9_3_4 extends Protocol {
} }
}); });
// Join (save dimension id) registerOutgoing(ClientboundPackets1_9_3.JOIN_GAME, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Entity ID map(Type.INT); // 0 - Entity ID
@ -94,8 +90,7 @@ public class Protocol1_9_1_2To1_9_3_4 extends Protocol {
} }
}); });
// Respawn (save dimension id) registerOutgoing(ClientboundPackets1_9_3.RESPAWN, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Dimension ID map(Type.INT); // 0 - Dimension ID
@ -115,7 +110,8 @@ public class Protocol1_9_1_2To1_9_3_4 extends Protocol {
@Override @Override
public void init(UserConnection userConnection) { public void init(UserConnection userConnection) {
if (!userConnection.has(ClientWorld.class)) if (!userConnection.has(ClientWorld.class)) {
userConnection.put(new ClientWorld(userConnection)); userConnection.put(new ClientWorld(userConnection));
} }
} }
}

Datei anzeigen

@ -5,15 +5,20 @@ import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
public class Protocol1_9_1To1_9 extends Protocol { public class Protocol1_9_1To1_9 extends Protocol<ClientboundPackets1_9, ClientboundPackets1_9, ServerboundPackets1_9, ServerboundPackets1_9> {
public Protocol1_9_1To1_9() {
super(ClientboundPackets1_9.class, ClientboundPackets1_9.class, ServerboundPackets1_9.class, ServerboundPackets1_9.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// Currently supports 1.9.1 and 1.9.2 // Currently supports 1.9.1 and 1.9.2
// Join Game Packet
registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() { registerOutgoing(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Player ID map(Type.INT); // 0 - Player ID
@ -27,8 +32,7 @@ public class Protocol1_9_1To1_9 extends Protocol {
} }
}); });
// Sound Effect Packet registerOutgoing(ClientboundPackets1_9.SOUND, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x47, 0x47, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Sound ID map(Type.VAR_INT); // 0 - Sound ID

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_11to1_10; package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType; import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_11 implements ClientboundPacketType { public enum ClientboundPackets1_9_3 implements ClientboundPacketType {
SPAWN_ENTITY, // 0x00 SPAWN_ENTITY, // 0x00
SPAWN_EXPERIENCE_ORB, // 0x01 SPAWN_EXPERIENCE_ORB, // 0x01
@ -78,6 +78,6 @@ public enum ClientboundPackets1_11 implements ClientboundPacketType {
TAB_LIST, // 0x49 TAB_LIST, // 0x49
COLLECT_ITEM, // 0x4A COLLECT_ITEM, // 0x4A
ENTITY_TELEPORT, // 0x4B ENTITY_TELEPORT, // 0x4B
ENTITY_PROPERTIES, // 0x4D ENTITY_PROPERTIES, // 0x4C
ENTITY_EFFECT, // 0x4E ENTITY_EFFECT, // 0x4D
} }

Datei anzeigen

@ -12,31 +12,26 @@ import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.chunks.FakeTileEntity; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.chunks.FakeTileEntity;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Type;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
import java.util.List; import java.util.List;
public class Protocol1_9_3To1_9_1_2 extends Protocol { public class Protocol1_9_3To1_9_1_2 extends Protocol<ClientboundPackets1_9, ClientboundPackets1_9_3, ServerboundPackets1_9, ServerboundPackets1_9_3> {
public Protocol1_9_3To1_9_1_2() {
super(ClientboundPackets1_9.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9.class, ServerboundPackets1_9_3.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
//Unchanged packet structure
registerOutgoing(State.PLAY, 0x47, 0x46); //Sound effect
registerOutgoing(State.PLAY, 0x48, 0x47); //Player list header and footer
registerOutgoing(State.PLAY, 0x49, 0x48); //Collect item
registerOutgoing(State.PLAY, 0x4A, 0x49); //Entity teleport
registerOutgoing(State.PLAY, 0x4B, 0x4A); //Entity properties
registerOutgoing(State.PLAY, 0x4C, 0x4B); //Entity effect
// Sign update packet // Sign update packet
registerOutgoing(State.PLAY, 0x46, -1, new PacketRemapper() { registerOutgoing(ClientboundPackets1_9.UPDATE_SIGN, null, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
@ -68,8 +63,7 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol {
} }
}); });
// Chunk packet registerOutgoing(ClientboundPackets1_9.CHUNK_DATA, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x20, 0x20, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -105,8 +99,7 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol {
} }
}); });
// Join (save dimension id) registerOutgoing(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Entity ID map(Type.INT); // 0 - Entity ID
@ -124,8 +117,7 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol {
} }
}); });
// Respawn (save dimension id) registerOutgoing(ClientboundPackets1_9.RESPAWN, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x33, 0x33, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Dimension ID map(Type.INT); // 0 - Dimension ID
@ -143,7 +135,8 @@ public class Protocol1_9_3To1_9_1_2 extends Protocol {
@Override @Override
public void init(UserConnection user) { public void init(UserConnection user) {
if (!user.has(ClientWorld.class)) if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld(user)); user.put(new ClientWorld(user));
} }
} }
}

Datei anzeigen

@ -0,0 +1,37 @@
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2;
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
public enum ServerboundPackets1_9_3 implements ServerboundPacketType {
TELEPORT_CONFIRM, // 0x00
TAB_COMPLETE, // 0x01
CHAT_MESSAGE, // 0x02
CLIENT_STATUS, // 0x03
CLIENT_SETTINGS, // 0x04
WINDOW_CONFIRMATION, // 0x05
CLICK_WINDOW_BUTTON, // 0x06
CLICK_WINDOW, // 0x07
CLOSE_WINDOW, // 0x08
PLUGIN_MESSAGE, // 0x09
INTERACT_ENTITY, // 0x0A
KEEP_ALIVE, // 0x0B
PLAYER_POSITION, // 0x0C
PLAYER_POSITION_AND_ROTATION, // 0x0D
PLAYER_ROTATION, // 0x0E
PLAYER_MOVEMENT, // 0x0F
VEHICLE_MOVE, // 0x10
STEER_BOAT, // 0x11
PLAYER_ABILITIES, // 0x12
PLAYER_DIGGING, // 0x13
ENTITY_ACTION, // 0x14
STEER_VEHICLE, // 0x15
RESOURCE_PACK_STATUS, // 0x16
HELD_ITEM_CHANGE, // 0x17
CREATIVE_INVENTORY_ACTION, // 0x18
UPDATE_SIGN, // 0x19
ANIMATION, // 0x1A
SPECTATE, // 0x1B
PLAYER_BLOCK_PLACEMENT, // 0x1C
USE_ITEM, // 0x1D
}

Datei anzeigen

@ -0,0 +1,84 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_9 implements ClientboundPacketType {
SPAWN_ENTITY, // 0x00
SPAWN_EXPERIENCE_ORB, // 0x01
SPAWN_GLOBAL_ENTITY, // 0x02
SPAWN_MOB, // 0x03
SPAWN_PAINTING, // 0x04
SPAWN_PLAYER, // 0x05
ENTITY_ANIMATION, // 0x06
STATISTICS, // 0x07
BLOCK_BREAK_ANIMATION, // 0x08
BLOCK_ENTITY_DATA, // 0x09
BLOCK_ACTION, // 0x0A
BLOCK_CHANGE, // 0x0B
BOSSBAR, // 0x0C
SERVER_DIFFICULTY, // 0x0D
TAB_COMPLETE, // 0x0E
CHAT_MESSAGE, // 0x0F
MULTI_BLOCK_CHANGE, // 0x10
WINDOW_CONFIRMATION, // 0x11
CLOSE_WINDOW, // 0x12
OPEN_WINDOW, // 0x13
WINDOW_ITEMS, // 0x14
WINDOW_PROPERTY, // 0x15
SET_SLOT, // 0x16
COOLDOWN, // 0x17
PLUGIN_MESSAGE, // 0x18
NAMED_SOUND, // 0x19
DISCONNECT, // 0x1A
ENTITY_STATUS, // 0x1B
EXPLOSION, // 0x1C
UNLOAD_CHUNK, // 0x1D
GAME_EVENT, // 0x1E
KEEP_ALIVE, // 0x1F
CHUNK_DATA, // 0x20
EFFECT, // 0x21
SPAWN_PARTICLE, // 0x22
JOIN_GAME, // 0x23
MAP_DATA, // 0x24
ENTITY_POSITION, // 0x26
ENTITY_POSITION_AND_ROTATION, // 0x27
ENTITY_ROTATION, // 0x28
ENTITY_MOVEMENT, // 0x25
VEHICLE_MOVE, // 0x29
OPEN_SIGN_EDITOR, // 0x2A
PLAYER_ABILITIES, // 0x2B
COMBAT_EVENT, // 0x2C
PLAYER_INFO, // 0x2D
PLAYER_POSITION, // 0x2E
USE_BED, // 0x2F
DESTROY_ENTITIES, // 0x31
REMOVE_ENTITY_EFFECT, // 0x32
RESOURCE_PACK, // 0x33
RESPAWN, // 0x34
ENTITY_HEAD_LOOK, // 0x35
WORLD_BORDER, // 0x37
CAMERA, // 0x38
HELD_ITEM_CHANGE, // 0x39
DISPLAY_SCOREBOARD, // 0x3A
ENTITY_METADATA, // 0x3B
ATTACH_ENTITY, // 0x3C
ENTITY_VELOCITY, // 0x3D
ENTITY_EQUIPMENT, // 0x3E
SET_EXPERIENCE, // 0x3F
UPDATE_HEALTH, // 0x40
SCOREBOARD_OBJECTIVE, // 0x41
SET_PASSENGERS, // 0x42
TEAMS, // 0x43
UPDATE_SCORE, // 0x44
SPAWN_POSITION, // 0x45
TIME_UPDATE, // 0x46
TITLE, // 0x47
UPDATE_SIGN, // 0x48
SOUND, // 0x49
TAB_LIST, // 0x4A
COLLECT_ITEM, // 0x4B
ENTITY_TELEPORT, // 0x4C
ENTITY_PROPERTIES, // 0x4D
ENTITY_EFFECT, // 0x4E
}

Datei anzeigen

@ -6,7 +6,7 @@ import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.platform.providers.ViaProviders; import us.myles.ViaVersion.api.platform.providers.ViaProviders;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.SimpleProtocol;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
@ -19,7 +19,7 @@ import us.myles.ViaVersion.util.GsonUtil;
import java.util.List; import java.util.List;
public class Protocol1_9To1_8 extends Protocol { public class Protocol1_9To1_8 extends SimpleProtocol {
public static final ValueTransformer<String, String> FIX_JSON = new ValueTransformer<String, String>(Type.STRING) { public static final ValueTransformer<String, String> FIX_JSON = new ValueTransformer<String, String>(Type.STRING) {
@Override @Override
public String transform(PacketWrapper wrapper, String line) { public String transform(PacketWrapper wrapper, String line) {

Datei anzeigen

@ -1,8 +1,8 @@
package us.myles.ViaVersion.protocols.protocol1_11to1_10; package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import us.myles.ViaVersion.api.protocol.ServerboundPacketType; import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
public enum ServerboundPackets1_11 implements ServerboundPacketType { public enum ServerboundPackets1_9 implements ServerboundPacketType {
TELEPORT_CONFIRM, // 0x00 TELEPORT_CONFIRM, // 0x00
TAB_COMPLETE, // 0x01 TAB_COMPLETE, // 0x01

Datei anzeigen

@ -5,15 +5,20 @@ import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
public class Protocol1_9To1_9_1 extends Protocol { public class Protocol1_9To1_9_1 extends Protocol<ClientboundPackets1_9, ClientboundPackets1_9, ServerboundPackets1_9, ServerboundPackets1_9> {
public Protocol1_9To1_9_1() {
super(ClientboundPackets1_9.class, ClientboundPackets1_9.class, ServerboundPackets1_9.class, ServerboundPackets1_9.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// Currently supports 1.9.1 and 1.9.2 // Currently supports 1.9.1 and 1.9.2
// Join Game Packet
registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() { registerOutgoing(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Player ID map(Type.INT); // 0 - Player ID
@ -27,8 +32,7 @@ public class Protocol1_9To1_9_1 extends Protocol {
} }
}); });
// Sound Effect Packet registerOutgoing(ClientboundPackets1_9.SOUND, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x47, 0x47, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Sound ID map(Type.VAR_INT); // 0 - Sound ID