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

Merge pull request #1795 from KennyTV/packetids

Packet type constants and auto channel mapping
Dieser Commit ist enthalten in:
Myles 2020-06-06 11:00:06 +01:00 committet von GitHub
Commit 137050be16
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
110 geänderte Dateien mit 2244 neuen und 1613 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion; package us.myles.ViaVersion;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Via; 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.platform.TaskId; import us.myles.ViaVersion.api.platform.TaskId;
@ -207,6 +208,7 @@ public class ViaManager {
/** /**
* @see ViaConnectionManager#getConnectedClient(UUID) * @see ViaConnectionManager#getConnectedClient(UUID)
*/ */
@Nullable
public UserConnection getConnection(UUID playerUUID) { public UserConnection getConnection(UUID playerUUID) {
return platform.getConnectionManager().getConnectedClient(playerUUID); return platform.getConnectionManager().getConnectedClient(playerUUID);
} }

Datei anzeigen

@ -16,7 +16,11 @@ import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.util.PipelineUtil; import us.myles.ViaVersion.util.PipelineUtil;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
public class PacketWrapper { public class PacketWrapper {
public static final int PASSTHROUGH_ID = 1000; public static final int PASSTHROUGH_ID = 1000;
@ -249,8 +253,9 @@ public class PacketWrapper {
* Clear the input buffer / readable objects * Clear the input buffer / readable objects
*/ */
public void clearInputBuffer() { public void clearInputBuffer() {
if (inputBuffer != null) if (inputBuffer != null) {
inputBuffer.clear(); inputBuffer.clear();
}
readableObjects.clear(); // :( readableObjects.clear(); // :(
} }

Datei anzeigen

@ -1,12 +1,14 @@
package us.myles.ViaVersion.api; package us.myles.ViaVersion.api;
import org.jetbrains.annotations.Nullable;
import java.util.Objects; import java.util.Objects;
public class Pair<X, Y> { public class Pair<X, Y> {
private final X key; private final X key;
private Y value; private Y value;
public Pair(X key, Y value) { public Pair(@Nullable X key, @Nullable Y value) {
this.key = key; this.key = key;
this.value = value; this.value = value;
} }
@ -19,7 +21,7 @@ public class Pair<X, Y> {
return value; return value;
} }
public void setValue(Y value) { public void setValue(@Nullable Y value) {
this.value = value; this.value = value;
} }

Datei anzeigen

@ -1,5 +1,7 @@
package us.myles.ViaVersion.api; package us.myles.ViaVersion.api;
import org.jetbrains.annotations.Nullable;
import java.util.Objects; import java.util.Objects;
public class Triple<A, B, C> { public class Triple<A, B, C> {
@ -7,20 +9,23 @@ public class Triple<A, B, C> {
private final B second; private final B second;
private final C third; private final C third;
public Triple(A first, B second, C third) { public Triple(@Nullable A first, @Nullable B second, @Nullable C third) {
this.first = first; this.first = first;
this.second = second; this.second = second;
this.third = third; this.third = third;
} }
@Nullable
public A getFirst() { public A getFirst() {
return first; return first;
} }
@Nullable
public B getSecond() { public B getSecond() {
return second; return second;
} }
@Nullable
public C getThird() { public C getThird() {
return third; return third;
} }

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.api; package us.myles.ViaVersion.api;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
@ -20,6 +21,7 @@ public abstract class ViaListener {
* @param uuid UUID object * @param uuid UUID object
* @return The UserConnection * @return The UserConnection
*/ */
@Nullable
protected UserConnection getUserConnection(UUID uuid) { protected UserConnection getUserConnection(UUID uuid) {
return Via.getManager().getConnection(uuid); return Via.getManager().getConnection(uuid);
} }

Datei anzeigen

@ -1,6 +1,7 @@
package us.myles.ViaVersion.api.boss; package us.myles.ViaVersion.api.boss;
public enum BossColor { public enum BossColor {
PINK(0), PINK(0),
BLUE(1), BLUE(1),
RED(2), RED(2),

Datei anzeigen

@ -1,6 +1,7 @@
package us.myles.ViaVersion.api.boss; package us.myles.ViaVersion.api.boss;
public enum BossFlag { public enum BossFlag {
DARKEN_SKY(1), DARKEN_SKY(1),
PLAY_BOSS_MUSIC(2); PLAY_BOSS_MUSIC(2);

Datei anzeigen

@ -1,6 +1,7 @@
package us.myles.ViaVersion.api.boss; package us.myles.ViaVersion.api.boss;
public enum BossStyle { public enum BossStyle {
SOLID(0), SOLID(0),
SEGMENTED_6(1), SEGMENTED_6(1),
SEGMENTED_10(2), SEGMENTED_10(2),

Datei anzeigen

@ -1,5 +1,7 @@
package us.myles.ViaVersion.api.command; package us.myles.ViaVersion.api.command;
import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
public interface ViaVersionCommand { public interface ViaVersionCommand {
@ -25,6 +27,7 @@ public interface ViaVersionCommand {
* @param name subcommand name * @param name subcommand name
* @return ViaSubCommand instance * @return ViaSubCommand instance
*/ */
@Nullable
ViaSubCommand getSubCommand(String name); ViaSubCommand getSubCommand(String name);
/** /**

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.api.data; package us.myles.ViaVersion.api.data;
public interface ExternalJoinGameListener { public interface ExternalJoinGameListener {
void onExternalJoinGame(int playerEntityId); void onExternalJoinGame(int playerEntityId);
} }

Datei anzeigen

@ -5,6 +5,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonIOException; import com.google.gson.JsonIOException;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.util.GsonUtil;
@ -127,6 +128,7 @@ public class MappingDataLoader {
} }
} }
@Nullable
private static Map.Entry<String, JsonElement> mapIdentifierEntry(Map.Entry<String, JsonElement> entry, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) { private static Map.Entry<String, JsonElement> mapIdentifierEntry(Map.Entry<String, JsonElement> entry, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString()); Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) { if (value == null) {
@ -181,6 +183,7 @@ public class MappingDataLoader {
} }
} }
@Nullable
public static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) { public static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
for (Map.Entry<String, JsonElement> entry : object.entrySet()) { for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
String value = entry.getValue().getAsString(); String value = entry.getValue().getAsString();
@ -191,6 +194,7 @@ public class MappingDataLoader {
return null; return null;
} }
@Nullable
public static Integer findIndex(JsonArray array, String value) { public static Integer findIndex(JsonArray array, String value) {
for (int i = 0; i < array.size(); i++) { for (int i = 0; i < array.size(); i++) {
JsonElement v = array.get(i); JsonElement v = array.get(i);

Datei anzeigen

@ -6,6 +6,7 @@ import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.ViaVersionConfig; import us.myles.ViaVersion.api.ViaVersionConfig;
@ -36,7 +37,7 @@ public class UserConnection {
private int secondsObserved; private int secondsObserved;
private int warnings; private int warnings;
public UserConnection(Channel channel) { public UserConnection(@Nullable Channel channel) {
this.channel = channel; this.channel = channel;
} }
@ -47,6 +48,7 @@ public class UserConnection {
* @param <T> The type of the class you want to get. * @param <T> The type of the class you want to get.
* @return The requested object * @return The requested object
*/ */
@Nullable
public <T extends StoredObject> T get(Class<T> objectClass) { public <T extends StoredObject> T get(Class<T> objectClass) {
return (T) storedObjects.get(objectClass); return (T) storedObjects.get(objectClass);
} }
@ -84,8 +86,8 @@ public class UserConnection {
* @param packet The raw packet to send * @param packet The raw packet to send
* @param currentThread Should it run in the same thread * @param currentThread Should it run in the same thread
*/ */
public void sendRawPacket(final ByteBuf packet, boolean currentThread) { public void sendRawPacket(ByteBuf packet, boolean currentThread) {
final ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName()); ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName());
if (currentThread) { if (currentThread) {
channel.pipeline().context(handler).writeAndFlush(packet); channel.pipeline().context(handler).writeAndFlush(packet);
} else { } else {
@ -99,8 +101,8 @@ public class UserConnection {
* @param packet The raw packet to send * @param packet The raw packet to send
* @return ChannelFuture of the packet being sent * @return ChannelFuture of the packet being sent
*/ */
public ChannelFuture sendRawPacketFuture(final ByteBuf packet) { public ChannelFuture sendRawPacketFuture(ByteBuf packet) {
final ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName()); ChannelHandler handler = channel.pipeline().get(Via.getManager().getInjector().getEncoderName());
return channel.pipeline().context(handler).writeAndFlush(packet); return channel.pipeline().context(handler).writeAndFlush(packet);
} }
@ -109,7 +111,7 @@ public class UserConnection {
* *
* @param packet The packet to send * @param packet The packet to send
*/ */
public void sendRawPacket(final ByteBuf packet) { public void sendRawPacket(ByteBuf packet) {
sendRawPacket(packet, false); sendRawPacket(packet, false);
} }
@ -177,12 +179,12 @@ public class UserConnection {
* *
* @param reason The reason to use, not used if player is not active. * @param reason The reason to use, not used if player is not active.
*/ */
public void disconnect(final String reason) { public void disconnect(String reason) {
if (!channel.isOpen()) return; if (!channel.isOpen()) return;
if (pendingDisconnect) return; if (pendingDisconnect) return;
pendingDisconnect = true; pendingDisconnect = true;
if (get(ProtocolInfo.class).getUuid() != null) { if (get(ProtocolInfo.class).getUuid() != null) {
final UUID uuid = get(ProtocolInfo.class).getUuid(); UUID uuid = get(ProtocolInfo.class).getUuid();
Via.getPlatform().runSync(() -> { Via.getPlatform().runSync(() -> {
if (!Via.getPlatform().kickPlayer(uuid, ChatColor.translateAlternateColorCodes('&', reason))) { if (!Via.getPlatform().kickPlayer(uuid, ChatColor.translateAlternateColorCodes('&', reason))) {
channel.close(); // =) channel.close(); // =)
@ -197,8 +199,8 @@ public class UserConnection {
* @param packet Raw packet to be sent * @param packet Raw packet to be sent
* @param currentThread If {@code true} executes immediately, {@code false} submits a task to EventLoop * @param currentThread If {@code true} executes immediately, {@code false} submits a task to EventLoop
*/ */
public void sendRawPacketToServer(final ByteBuf packet, boolean currentThread) { public void sendRawPacketToServer(ByteBuf packet, boolean currentThread) {
final ByteBuf buf = packet.alloc().buffer(); ByteBuf buf = packet.alloc().buffer();
try { try {
try { try {
Type.VAR_INT.write(buf, PacketWrapper.PASSTHROUGH_ID); Type.VAR_INT.write(buf, PacketWrapper.PASSTHROUGH_ID);
@ -207,7 +209,7 @@ public class UserConnection {
Via.getPlatform().getLogger().warning("Type.VAR_INT.write thrown an exception: " + e); Via.getPlatform().getLogger().warning("Type.VAR_INT.write thrown an exception: " + e);
} }
buf.writeBytes(packet); buf.writeBytes(packet);
final ChannelHandlerContext context = PipelineUtil ChannelHandlerContext context = PipelineUtil
.getPreviousContext(Via.getManager().getInjector().getDecoderName(), channel.pipeline()); .getPreviousContext(Via.getManager().getInjector().getDecoderName(), channel.pipeline());
if (currentThread) { if (currentThread) {
if (context != null) { if (context != null) {
@ -248,6 +250,7 @@ public class UserConnection {
return id; return id;
} }
@Nullable
public Channel getChannel() { public Channel getChannel() {
return channel; return channel;
} }
@ -272,11 +275,12 @@ public class UserConnection {
this.pendingDisconnect = pendingDisconnect; this.pendingDisconnect = pendingDisconnect;
} }
@Nullable
public Object getLastPacket() { public Object getLastPacket() {
return lastPacket; return lastPacket;
} }
public void setLastPacket(Object lastPacket) { public void setLastPacket(@Nullable Object lastPacket) {
this.lastPacket = lastPacket; this.lastPacket = lastPacket;
} }

Datei anzeigen

@ -1,9 +1,12 @@
package us.myles.ViaVersion.api.entities; package us.myles.ViaVersion.api.entities;
import org.jetbrains.annotations.Nullable;
public interface EntityType { public interface EntityType {
int getId(); int getId();
@Nullable
EntityType getParent(); EntityType getParent();
String name(); String name();

Datei anzeigen

@ -1,6 +1,7 @@
package us.myles.ViaVersion.api.minecraft.chunks; package us.myles.ViaVersion.api.minecraft.chunks;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -145,7 +146,7 @@ public class ChunkSection {
* *
* @param data The value to set the block light to * @param data The value to set the block light to
*/ */
public void setBlockLight(byte[] data) { public void setBlockLight(@Nullable byte[] data) {
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH); if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
if (this.blockLight == null) { if (this.blockLight == null) {
this.blockLight = new NibbleArray(data); this.blockLight = new NibbleArray(data);
@ -159,7 +160,7 @@ public class ChunkSection {
* *
* @param data The value to set the sky light to * @param data The value to set the sky light to
*/ */
public void setSkyLight(byte[] data) { public void setSkyLight(@Nullable byte[] data) {
if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH); if (data.length != LIGHT_LENGTH) throw new IllegalArgumentException("Data length != " + LIGHT_LENGTH);
if (this.skyLight == null) { if (this.skyLight == null) {
this.skyLight = new NibbleArray(data); this.skyLight = new NibbleArray(data);
@ -168,18 +169,22 @@ public class ChunkSection {
} }
} }
@Nullable
public byte[] getBlockLight() { public byte[] getBlockLight() {
return blockLight == null ? null : blockLight.getHandle(); return blockLight == null ? null : blockLight.getHandle();
} }
@Nullable
public NibbleArray getBlockLightNibbleArray() { public NibbleArray getBlockLightNibbleArray() {
return blockLight; return blockLight;
} }
@Nullable
public byte[] getSkyLight() { public byte[] getSkyLight() {
return skyLight == null ? null : skyLight.getHandle(); return skyLight == null ? null : skyLight.getHandle();
} }
@Nullable
public NibbleArray getSkyLightNibbleArray() { public NibbleArray getSkyLightNibbleArray() {
return skyLight; return skyLight;
} }

Datei anzeigen

@ -2,6 +2,9 @@ package us.myles.ViaVersion.api.minecraft.item;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public class Item { public class Item {
@SerializedName(value = "identifier", alternate = "id") @SerializedName(value = "identifier", alternate = "id")
@ -13,7 +16,7 @@ public class Item {
public Item() { public Item() {
} }
public Item(int identifier, byte amount, short data, CompoundTag tag) { public Item(int identifier, byte amount, short data, @Nullable CompoundTag tag) {
this.identifier = identifier; this.identifier = identifier;
this.amount = amount; this.amount = amount;
this.data = data; this.data = data;
@ -48,11 +51,12 @@ public class Item {
this.data = data; this.data = data;
} }
@Nullable
public CompoundTag getTag() { public CompoundTag getTag() {
return tag; return tag;
} }
public void setTag(CompoundTag tag) { public void setTag(@Nullable CompoundTag tag) {
this.tag = tag; this.tag = tag;
} }
@ -64,7 +68,7 @@ public class Item {
if (identifier != item.identifier) return false; if (identifier != item.identifier) return false;
if (amount != item.amount) return false; if (amount != item.amount) return false;
if (data != item.data) return false; if (data != item.data) return false;
return tag != null ? tag.equals(item.tag) : item.tag == null; return Objects.equals(tag, item.tag);
} }
@Override @Override

Datei anzeigen

@ -1,6 +1,7 @@
package us.myles.ViaVersion.api.platform; package us.myles.ViaVersion.api.platform;
import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
@ -51,6 +52,7 @@ public class ViaConnectionManager {
* Note that connections are removed as soon as their channel is closed, * Note that connections are removed as soon as their channel is closed,
* so avoid using this method during player quits for example. * so avoid using this method during player quits for example.
*/ */
@Nullable
public UserConnection getConnectedClient(UUID clientIdentifier) { public UserConnection getConnectedClient(UUID clientIdentifier) {
return clients.get(clientIdentifier); return clients.get(clientIdentifier);
} }

Datei anzeigen

@ -1,5 +1,7 @@
package us.myles.ViaVersion.api.platform.providers; package us.myles.ViaVersion.api.platform.providers;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -22,6 +24,7 @@ public class ViaProviders {
providers.put(provider, value); providers.put(provider, value);
} }
@Nullable
public <T extends Provider> T get(Class<T> provider) { public <T extends Provider> T get(Class<T> provider) {
Provider rawProvider = providers.get(provider); Provider rawProvider = providers.get(provider);
if (rawProvider != null) { if (rawProvider != null) {

Datei anzeigen

@ -0,0 +1,18 @@
package us.myles.ViaVersion.api.protocol;
/**
* Interface to be implemented by server outgoing packet type enums,
* representing PLAY state packets, ordered by their packet id.
*/
public interface ClientboundPacketType {
/**
* @return name of the packet, to be consistent over multiple versions
*/
String name();
/**
* @return ordinal, being the packet id for the implemented protocol
*/
int ordinal();
}

Datei anzeigen

@ -1,5 +1,7 @@
package us.myles.ViaVersion.api.protocol; package us.myles.ViaVersion.api.protocol;
import com.google.common.base.Preconditions;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
@ -9,24 +11,119 @@ import us.myles.ViaVersion.exception.CancelException;
import us.myles.ViaVersion.packets.Direction; import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; 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
private final boolean hasMappingDataToLoad; protected final Class<C1> oldClientboundPacketEnum;
protected final Class<C2> newClientboundPacketEnum;
protected final Class<S1> oldServerboundPacketEnum;
protected final Class<S2> newServerboundPacketEnum;
protected final boolean hasMappingDataToLoad;
public Protocol() { protected Protocol() {
this(false); this(null, null, null, null, false);
} }
public Protocol(boolean hasMappingDataToLoad) { protected Protocol(boolean hasMappingDataToLoad) {
this(null, null, null, null, hasMappingDataToLoad);
}
/**
* Creates a protocol with automated id mapping if the respective enums are not null.
*/
protected Protocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
this(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum, false);
}
/**
* Creates a protocol with automated id mapping if the respective enums are not null.
*
* @param hasMappingDataToLoad whether an async executor should call the {@Link #loadMappingData} method
*/
protected Protocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum, boolean hasMappingDataToLoad) {
this.oldClientboundPacketEnum = oldClientboundPacketEnum;
this.newClientboundPacketEnum = clientboundPacketEnum;
this.oldServerboundPacketEnum = oldServerboundPacketEnum;
this.newServerboundPacketEnum = serverboundPacketEnum;
this.hasMappingDataToLoad = hasMappingDataToLoad; this.hasMappingDataToLoad = hasMappingDataToLoad;
registerPackets(); registerPackets();
// Register the rest of the ids with no handlers if necessary
if (oldClientboundPacketEnum != null && clientboundPacketEnum != null
&& oldClientboundPacketEnum != clientboundPacketEnum) {
registerOutgoingChannelIdChanges();
}
if (oldServerboundPacketEnum != null && serverboundPacketEnum != null
&& oldServerboundPacketEnum != serverboundPacketEnum) {
registerIncomingChannelIdChanges();
}
}
protected void registerOutgoingChannelIdChanges() {
ClientboundPacketType[] newConstants = newClientboundPacketEnum.getEnumConstants();
Map<String, ClientboundPacketType> newClientboundPackets = new HashMap<>(newConstants.length);
for (ClientboundPacketType newConstant : newConstants) {
newClientboundPackets.put(newConstant.name(), newConstant);
}
for (ClientboundPacketType packet : oldClientboundPacketEnum.getEnumConstants()) {
ClientboundPacketType mappedPacket = newClientboundPackets.get(packet.name());
int oldId = packet.ordinal();
if (mappedPacket == null) {
// Packet doesn't exist on new client
Preconditions.checkArgument(hasRegisteredOutgoing(State.PLAY, oldId),
"Packet " + mappedPacket + " in " + getClass().getSimpleName() + " has no mapping - it needs to be manually cancelled or remapped!");
continue;
}
int newId = mappedPacket.ordinal();
if (!hasRegisteredOutgoing(State.PLAY, oldId)) {
registerOutgoing(State.PLAY, oldId, newId);
}
}
}
protected void registerIncomingChannelIdChanges() {
ServerboundPacketType[] oldConstants = oldServerboundPacketEnum.getEnumConstants();
Map<String, ServerboundPacketType> oldServerboundConstants = new HashMap<>(oldConstants.length);
for (ServerboundPacketType oldConstant : oldConstants) {
oldServerboundConstants.put(oldConstant.name(), oldConstant);
}
for (ServerboundPacketType packet : newServerboundPacketEnum.getEnumConstants()) {
ServerboundPacketType mappedPacket = oldServerboundConstants.get(packet.name());
int newId = packet.ordinal();
if (mappedPacket == null) {
// Packet doesn't exist on old server
Preconditions.checkArgument(hasRegisteredIncoming(State.PLAY, newId),
"Packet " + mappedPacket + " in " + getClass().getSimpleName() + " has no mapping - it needs to be manually cancelled or remapped!");
continue;
}
int oldId = mappedPacket.ordinal();
if (!hasRegisteredIncoming(State.PLAY, newId)) {
registerIncoming(State.PLAY, oldId, newId);
}
}
} }
/** /**
@ -53,9 +150,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.
@ -155,16 +253,6 @@ public abstract class Protocol {
registerOutgoing(state, oldPacketID, newPacketID, packetRemapper, false); registerOutgoing(state, oldPacketID, newPacketID, packetRemapper, false);
} }
public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
Packet packet = new Packet(state, oldPacketID);
if (!override && outgoing.containsKey(packet)) {
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
" If override is intentional, set override to true. Stacktrace: ", new Exception());
}
outgoing.put(packet, protocolPacket);
}
public void cancelOutgoing(State state, int oldPacketID, int newPacketID) { public void cancelOutgoing(State state, int oldPacketID, int newPacketID) {
registerOutgoing(state, oldPacketID, newPacketID, new PacketRemapper() { registerOutgoing(state, oldPacketID, newPacketID, new PacketRemapper() {
@Override @Override
@ -178,6 +266,118 @@ 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) {
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
Packet packet = new Packet(state, oldPacketID);
if (!override && outgoing.containsKey(packet)) {
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
" If override is intentional, set override to true. Stacktrace: ", new Exception());
}
outgoing.put(packet, protocolPacket);
}
/**
* Registers an outgoing protocol and automatically maps it to the new id.
*
* @param packetType clientbound packet type the server sends
* @param packetRemapper remapper
*/
public void registerOutgoing(C1 packetType, @Nullable PacketRemapper packetRemapper) {
ClientboundPacketType mappedPacket = oldClientboundPacketEnum == newClientboundPacketEnum ? packetType
: 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!");
int oldId = packetType.ordinal();
int newId = mappedPacket.ordinal();
registerOutgoing(State.PLAY, oldId, newId, packetRemapper);
}
/**
* Registers an outgoing protocol.
*
* @param packetType clientbound packet type the server initially sends
* @param mappedPacketType clientbound packet type after transforming for the client
* @param packetRemapper remapper
*/
public void registerOutgoing(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
registerOutgoing(State.PLAY, packetType.ordinal(), mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetRemapper);
}
/**
* 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, @Nullable C2 mappedPacketType) {
registerOutgoing(packetType, mappedPacketType, null);
}
public void cancelOutgoing(C1 packetType) {
cancelOutgoing(State.PLAY, packetType.ordinal(), packetType.ordinal());
}
/**
* Registers an incoming protocol and automatically maps it to the server's id.
*
* @param packetType serverbound packet type the client sends
* @param packetRemapper remapper
*/
public void registerIncoming(S2 packetType, @Nullable PacketRemapper packetRemapper) {
Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum);
ServerboundPacketType mappedPacket = oldServerboundPacketEnum == newServerboundPacketEnum ? packetType
: Arrays.stream(oldServerboundPacketEnum.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!");
int oldId = mappedPacket.ordinal();
int newId = packetType.ordinal();
registerIncoming(State.PLAY, oldId, newId, packetRemapper);
}
/**
* Registers an incoming protocol.
*
* @param packetType serverbound packet type initially sent by the client
* @param mappedPacketType serverbound packet type after transforming for the server
* @param packetRemapper remapper
*/
public void registerIncoming(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
registerIncoming(State.PLAY, mappedPacketType != null ? mappedPacketType.ordinal() : -1, packetType.ordinal(), packetRemapper);
}
public void cancelIncoming(S2 packetType) {
Preconditions.checkArgument(packetType.getClass() == newServerboundPacketEnum);
cancelIncoming(State.PLAY, -1, packetType.ordinal());
}
/**
* Checks if an outgoing packet has already been registered.
*
* @param state state which the packet is sent in
* @param oldPacketID old packet ID
* @return true if already registered
*/
public boolean hasRegisteredOutgoing(State state, int oldPacketID) {
Packet packet = new Packet(state, oldPacketID);
return outgoing.containsKey(packet);
}
/**
* Checks if an incoming packet has already been registered.
*
* @param state state which the packet is sent in
* @param newPacketId packet ID
* @return true if already registered
*/
public boolean hasRegisteredIncoming(State state, int newPacketId) {
Packet packet = new Packet(state, newPacketId);
return incoming.containsKey(packet);
}
public boolean hasMappingDataToLoad() { public boolean hasMappingDataToLoad() {
return hasMappingDataToLoad; return hasMappingDataToLoad;
} }
@ -210,7 +410,7 @@ public abstract class Protocol {
} }
} }
public <T> T get(Class<T> objectClass) { public @Nullable <T> T get(Class<T> objectClass) {
return (T) storedObjects.get(objectClass); return (T) storedObjects.get(objectClass);
} }
@ -267,7 +467,7 @@ public abstract class Protocol {
private final int newID; private final int newID;
private final PacketRemapper remapper; private final PacketRemapper remapper;
public ProtocolPacket(State state, int oldID, int newID, PacketRemapper remapper) { public ProtocolPacket(State state, int oldID, int newID, @Nullable PacketRemapper remapper) {
this.state = state; this.state = state;
this.oldID = oldID; this.oldID = oldID;
this.newID = newID; this.newID = newID;
@ -286,6 +486,7 @@ public abstract class Protocol {
return newID; return newID;
} }
@Nullable
public PacketRemapper getRemapper() { public PacketRemapper getRemapper() {
return remapper; return remapper;
} }

Datei anzeigen

@ -14,7 +14,7 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level; import java.util.logging.Level;
public class ProtocolPipeline extends Protocol { public class ProtocolPipeline extends SimpleProtocol {
private List<Protocol> protocolList; private List<Protocol> protocolList;
private UserConnection userConnection; private UserConnection userConnection;

Datei anzeigen

@ -2,6 +2,7 @@ package us.myles.ViaVersion.api.protocol;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Pair; import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.MappingDataLoader; import us.myles.ViaVersion.api.data.MappingDataLoader;
@ -224,6 +225,7 @@ public class ProtocolRegistry {
* @param serverVersion The desired output version * @param serverVersion The desired output version
* @return The path which has been generated, null if failed. * @return The path which has been generated, null if failed.
*/ */
@Nullable
private static List<Pair<Integer, Protocol>> getProtocolPath(List<Pair<Integer, Protocol>> current, int clientVersion, int serverVersion) { private static List<Pair<Integer, Protocol>> getProtocolPath(List<Pair<Integer, Protocol>> current, int clientVersion, int serverVersion) {
if (clientVersion == serverVersion) return null; // We're already there if (clientVersion == serverVersion) return null; // We're already there
if (current.size() > 50) return null; // Fail safe, protocol too complicated. if (current.size() > 50) return null; // Fail safe, protocol too complicated.
@ -273,6 +275,7 @@ public class ProtocolRegistry {
* @param serverVersion The desired output server version * @param serverVersion The desired output server version
* @return The path it generated, null if it failed. * @return The path it generated, null if it failed.
*/ */
@Nullable
public static List<Pair<Integer, Protocol>> getProtocolPath(int clientVersion, int serverVersion) { public static List<Pair<Integer, Protocol>> getProtocolPath(int clientVersion, int serverVersion) {
Pair<Integer, Integer> protocolKey = new Pair<>(clientVersion, serverVersion); Pair<Integer, Integer> protocolKey = new Pair<>(clientVersion, serverVersion);
// Check cache // Check cache
@ -367,6 +370,7 @@ public class ProtocolRegistry {
} }
} }
@Nullable
public static CompletableFuture<Void> getMappingLoaderFuture(Class<? extends Protocol> protocolClass) { public static CompletableFuture<Void> getMappingLoaderFuture(Class<? extends Protocol> protocolClass) {
synchronized (MAPPING_LOADER_LOCK) { synchronized (MAPPING_LOADER_LOCK) {
if (mappingsLoaded) return null; if (mappingsLoaded) return null;

Datei anzeigen

@ -0,0 +1,18 @@
package us.myles.ViaVersion.api.protocol;
/**
* Interface to be implemented by server incoming packet type enums,
* representing PLAY state packets, ordered by their packet id.
*/
public interface ServerboundPacketType {
/**
* @return name of the packet, to be consistent over multiple versions
*/
String name();
/**
* @return ordinal, being the packet id for the implemented protocol
*/
int ordinal();
}

Datei anzeigen

@ -0,0 +1,20 @@
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 {
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.api.remapper; package us.myles.ViaVersion.api.remapper;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.exception.InformativeException; import us.myles.ViaVersion.exception.InformativeException;
@ -8,7 +9,7 @@ public abstract class ValueTransformer<T1, T2> implements ValueWriter<T1> {
private final Type<T1> inputType; private final Type<T1> inputType;
private final Type<T2> outputType; private final Type<T2> outputType;
public ValueTransformer(Type<T1> inputType, Type<T2> outputType) { public ValueTransformer(@Nullable Type<T1> inputType, Type<T2> outputType) {
this.inputType = inputType; this.inputType = inputType;
this.outputType = outputType; this.outputType = outputType;
} }
@ -37,6 +38,7 @@ public abstract class ValueTransformer<T1, T2> implements ValueWriter<T1> {
} }
} }
@Nullable
public Type<T1> getInputType() { public Type<T1> getInputType() {
return inputType; return inputType;
} }

Datei anzeigen

@ -1,12 +1,13 @@
package us.myles.ViaVersion.api.rewriters; package us.myles.ViaVersion.api.rewriters;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord; import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
import us.myles.ViaVersion.api.minecraft.Position; import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
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 BlockRewriter { public class BlockRewriter {
@ -22,8 +23,8 @@ public class BlockRewriter {
this.blockRewriter = blockRewriter; this.blockRewriter = blockRewriter;
} }
public void registerBlockAction(int oldPacketId, int newPacketId) { public void registerBlockAction(ClientboundPacketType packetType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(positionType); // Location map(positionType); // Location
@ -35,8 +36,8 @@ public class BlockRewriter {
}); });
} }
public void registerBlockChange(int oldPacketId, int newPacketId) { public void registerBlockChange(ClientboundPacketType packetType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(positionType); map(positionType);
@ -46,8 +47,8 @@ public class BlockRewriter {
}); });
} }
public void registerMultiBlockChange(int oldPacketId, int newPacketId) { public void registerMultiBlockChange(ClientboundPacketType packetType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Chunk X map(Type.INT); // 0 - Chunk X
@ -62,13 +63,13 @@ public class BlockRewriter {
}); });
} }
public void registerAcknowledgePlayerDigging(int oldPacketId, int newPacketId) { public void registerAcknowledgePlayerDigging(ClientboundPacketType packetType) {
// Same exact handler // Same exact handler
registerBlockChange(oldPacketId, newPacketId); registerBlockChange(packetType);
} }
public void registerEffect(int oldPacketId, int newPacketId, int playRecordId, int blockBreakId, IdRewriteFunction itemIdRewriteFunction) { public void registerEffect(ClientboundPacketType packetType, int playRecordId, int blockBreakId, IdRewriteFunction itemIdRewriteFunction) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // Effect Id map(Type.INT); // Effect Id
@ -87,14 +88,14 @@ public class BlockRewriter {
}); });
} }
public void registerSpawnParticle(Type<?> coordType, int oldPacketId, int newPacketId, int blockId, int fallingDustId, int itemId, public void registerSpawnParticle(ClientboundPacketType packetType, int blockId, int fallingDustId, int itemId,
ItemRewriter.RewriteFunction itemRewriteFunction, Type<Item> itemType) { ItemRewriter.RewriteFunction itemRewriteFunction, Type<Item> itemType, Type<?> coordType) {
registerSpawnParticle(coordType, oldPacketId, newPacketId, blockId, fallingDustId, itemId, null, itemRewriteFunction, itemType); registerSpawnParticle(packetType, blockId, fallingDustId, itemId, null, itemRewriteFunction, itemType, coordType);
} }
public void registerSpawnParticle(Type<?> coordType, int oldPacketId, int newPacketId, int blockId, int fallingDustId, int itemId, public void registerSpawnParticle(ClientboundPacketType packetType, int blockId, int fallingDustId, int itemId,
IdRewriteFunction particleRewriteFunction, ItemRewriter.RewriteFunction itemRewriteFunction, Type<Item> itemType) { @Nullable IdRewriteFunction particleRewriteFunction, ItemRewriter.RewriteFunction itemRewriteFunction, Type<Item> itemType, Type<?> coordType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Particle ID map(Type.INT); // 0 - Particle ID

Datei anzeigen

@ -1,11 +1,12 @@
package us.myles.ViaVersion.api.rewriters; package us.myles.ViaVersion.api.rewriters;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
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 {
@ -19,8 +20,8 @@ public class ItemRewriter {
this.toServer = toServer; this.toServer = toServer;
} }
public void registerWindowItems(Type<Item[]> type, int oldPacketId, int newPacketId) { public void registerWindowItems(ClientboundPacketType packetType, Type<Item[]> type) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -31,8 +32,8 @@ public class ItemRewriter {
}); });
} }
public void registerSetSlot(Type<Item> type, int oldPacketId, int newPacketId) { public void registerSetSlot(ClientboundPacketType packetType, Type<Item> type) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.BYTE); // 0 - Window ID map(Type.BYTE); // 0 - Window ID
@ -44,8 +45,8 @@ public class ItemRewriter {
}); });
} }
public void registerEntityEquipment(Type<Item> type, int oldPacketId, int newPacketId) { public void registerEntityEquipment(ClientboundPacketType packetType, Type<Item> type) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -57,8 +58,8 @@ public class ItemRewriter {
}); });
} }
public void registerCreativeInvAction(Type<Item> type, int oldPacketId, int newPacketId) { public void registerCreativeInvAction(ServerboundPacketType packetType, Type<Item> type) {
protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerIncoming(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.SHORT); // 0 - Slot map(Type.SHORT); // 0 - Slot
@ -69,8 +70,8 @@ public class ItemRewriter {
}); });
} }
public void registerClickWindow(Type<Item> type, int oldPacketId, int newPacketId) { public void registerClickWindow(ServerboundPacketType packetType, Type<Item> type) {
protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerIncoming(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -85,8 +86,8 @@ public class ItemRewriter {
}); });
} }
public void registerSetCooldown(int oldPacketId, int newPacketId, IdRewriteFunction itemIDRewriteFunction) { public void registerSetCooldown(ClientboundPacketType packetType, IdRewriteFunction itemIDRewriteFunction) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {

Datei anzeigen

@ -1,18 +1,23 @@
package us.myles.ViaVersion.api.rewriters; package us.myles.ViaVersion.api.rewriters;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.Via; 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.entities.EntityType; import us.myles.ViaVersion.api.entities.EntityType;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol; 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.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.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
public abstract class MetadataRewriter { public abstract class MetadataRewriter {
@ -54,8 +59,8 @@ public abstract class MetadataRewriter {
} }
} }
public void registerJoinGame(int oldPacketId, int newPacketId, EntityType playerType) { public void registerJoinGame(ClientboundPacketType packetType, @Nullable EntityType playerType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Entity ID map(Type.INT); // 0 - Entity ID
@ -74,8 +79,8 @@ public abstract class MetadataRewriter {
}); });
} }
public void registerRespawn(int oldPacketId, int newPacketId) { public void registerRespawn(ClientboundPacketType packetType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); map(Type.INT);
@ -88,8 +93,8 @@ public abstract class MetadataRewriter {
}); });
} }
public void registerTracker(int oldPacketId, int newPacketId) { public void registerTracker(ClientboundPacketType packetType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -100,8 +105,8 @@ public abstract class MetadataRewriter {
}); });
} }
public void registerSpawnTrackerWithData(int oldPacketId, int newPacketId, EntityType fallingBlockType, IdRewriteFunction itemRewriter) { public void registerSpawnTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType, IdRewriteFunction itemRewriter) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id map(Type.VAR_INT); // 0 - Entity id
@ -125,8 +130,8 @@ public abstract class MetadataRewriter {
}); });
} }
public void registerTracker(int oldPacketId, int newPacketId, EntityType entityType) { public void registerTracker(ClientboundPacketType packetType, EntityType entityType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -138,8 +143,8 @@ public abstract class MetadataRewriter {
}); });
} }
public void registerEntityDestroy(int oldPacketId, int newPacketId) { public void registerEntityDestroy(ClientboundPacketType packetType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entity ids map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entity ids
@ -153,8 +158,8 @@ public abstract class MetadataRewriter {
}); });
} }
public void registerMetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) { public void registerMetadataRewriter(ClientboundPacketType packetType, @Nullable Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -172,8 +177,8 @@ public abstract class MetadataRewriter {
}); });
} }
public void registerMetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> metaType) { public void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> metaType) {
registerMetadataRewriter(oldPacketId, newPacketId, null, metaType); registerMetadataRewriter(packetType, null, metaType);
} }
public <T extends Enum<T> & EntityType> void mapTypes(EntityType[] oldTypes, Class<T> newTypeClass) { public <T extends Enum<T> & EntityType> void mapTypes(EntityType[] oldTypes, Class<T> newTypeClass) {
@ -209,7 +214,7 @@ public abstract class MetadataRewriter {
* @param metaType type of the metadata list * @param metaType type of the metadata list
* @return handler for tracking and rewriting entities * @return handler for tracking and rewriting entities
*/ */
public PacketHandler getTrackerAndRewriter(Type<List<Metadata>> metaType) { public PacketHandler getTrackerAndRewriter(@Nullable Type<List<Metadata>> metaType) {
return wrapper -> { return wrapper -> {
int entityId = wrapper.get(Type.VAR_INT, 0); int entityId = wrapper.get(Type.VAR_INT, 0);
int type = wrapper.get(Type.VAR_INT, 1); int type = wrapper.get(Type.VAR_INT, 1);
@ -229,7 +234,7 @@ public abstract class MetadataRewriter {
}; };
} }
public PacketHandler getTrackerAndRewriter(Type<List<Metadata>> metaType, EntityType entityType) { public PacketHandler getTrackerAndRewriter(@Nullable Type<List<Metadata>> metaType, EntityType entityType) {
return wrapper -> { return wrapper -> {
int entityId = wrapper.get(Type.VAR_INT, 0); int entityId = wrapper.get(Type.VAR_INT, 0);
// Register Type ID // Register Type ID

Datei anzeigen

@ -1,9 +1,9 @@
package us.myles.ViaVersion.api.rewriters; package us.myles.ViaVersion.api.rewriters;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
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;
public class SoundRewriter { public class SoundRewriter {
protected final Protocol protocol; protected final Protocol protocol;
@ -15,9 +15,9 @@ public class SoundRewriter {
this.idRewriter = idRewriter; this.idRewriter = idRewriter;
} }
// The same for entity sound effect // The same for entity sound
public void registerSound(int oldId, int newId) { public void registerSound(ClientboundPacketType packetType) {
protocol.registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // Sound Id map(Type.VAR_INT); // Sound Id

Datei anzeigen

@ -1,10 +1,10 @@
package us.myles.ViaVersion.api.rewriters; package us.myles.ViaVersion.api.rewriters;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
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 java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -40,8 +40,8 @@ public class TagRewriter {
newTags.add(new TagData(id, oldIds)); newTags.add(new TagData(id, oldIds));
} }
public void register(int oldId, int newId) { public void register(ClientboundPacketType packetType) {
protocol.registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() { protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.api.storage; package us.myles.ViaVersion.api.storage;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.data.ExternalJoinGameListener; import us.myles.ViaVersion.api.data.ExternalJoinGameListener;
import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
@ -30,6 +31,7 @@ public abstract class EntityTracker extends StoredObject implements ExternalJoin
return clientEntityTypes.containsKey(entityId); return clientEntityTypes.containsKey(entityId);
} }
@Nullable
public EntityType getEntity(int entityId) { public EntityType getEntity(int entityId) {
return clientEntityTypes.get(entityId); return clientEntityTypes.get(entityId);
} }

Datei anzeigen

@ -247,6 +247,7 @@ public abstract class CommonBoss<T> extends BossBar<T> {
} }
private enum UpdateAction { private enum UpdateAction {
ADD(0), ADD(0),
REMOVE(1), REMOVE(1),
UPDATE_HEALTH(2), UPDATE_HEALTH(2),

Datei anzeigen

@ -1,6 +1,13 @@
package us.myles.ViaVersion.packets; package us.myles.ViaVersion.packets;
public enum Direction { public enum Direction {
/**
* Outgoing server packets sent to the client.
*/
OUTGOING, OUTGOING,
/**
* Incoming server packets send by the client to the server.
*/
INCOMING INCOMING
} }

Datei anzeigen

@ -1,6 +1,7 @@
package us.myles.ViaVersion.packets; package us.myles.ViaVersion.packets;
public enum State { public enum State {
HANDSHAKE, HANDSHAKE,
STATUS, STATUS,
LOGIN, LOGIN,

Datei anzeigen

@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.platform.providers.ViaProviders;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.protocol.ProtocolPipeline; import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
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;
@ -16,7 +17,7 @@ import us.myles.ViaVersion.packets.State;
import java.util.List; import java.util.List;
public class BaseProtocol extends Protocol { public class BaseProtocol extends SimpleProtocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {

Datei anzeigen

@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import us.myles.ViaVersion.api.protocol.SimpleProtocol;
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;
@ -23,7 +24,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
public class BaseProtocol1_7 extends Protocol { public class BaseProtocol1_7 extends SimpleProtocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {

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,10 +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); 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, 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

@ -0,0 +1,87 @@
package us.myles.ViaVersion.protocols.protocol1_12_1to1_12;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_12_1 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_MOVEMENT, // 0x25
ENTITY_POSITION, // 0x26
ENTITY_POSITION_AND_ROTATION, // 0x27
ENTITY_ROTATION, // 0x28
VEHICLE_MOVE, // 0x29
OPEN_SIGN_EDITOR, // 0x2A
CRAFT_RECIPE_RESPONSE, // 0x2B
PLAYER_ABILITIES, // 0x2C
COMBAT_EVENT, // 0x2D
PLAYER_INFO, // 0x2E
PLAYER_POSITION, // 0x2F
USE_BED, // 0x30
UNLOCK_RECIPES, // 0x31
DESTROY_ENTITIES, // 0x32
REMOVE_ENTITY_EFFECT, // 0x33
RESOURCE_PACK, // 0x34
RESPAWN, // 0x35
ENTITY_HEAD_LOOK, // 0x36
SELECT_ADVANCEMENTS_TAB, // 0x37
WORLD_BORDER, // 0x38
CAMERA, // 0x39
HELD_ITEM_CHANGE, // 0x3A
DISPLAY_SCOREBOARD, // 0x3B
ENTITY_METADATA, // 0x3C
ATTACH_ENTITY, // 0x3D
ENTITY_VELOCITY, // 0x3E
ENTITY_EQUIPMENT, // 0x3F
SET_EXPERIENCE, // 0x40
UPDATE_HEALTH, // 0x41
SCOREBOARD_OBJECTIVE, // 0x42
SET_PASSENGERS, // 0x43
TEAMS, // 0x44
UPDATE_SCORE, // 0x45
SPAWN_POSITION, // 0x46
TIME_UPDATE, // 0x47
TITLE, // 0x48
SOUND, // 0x49
TAB_LIST, // 0x4A
COLLECT_ITEM, // 0x4B
ENTITY_TELEPORT, // 0x4C
ADVANCEMENTS, // 0x4D
ENTITY_PROPERTIES, // 0x4E
ENTITY_EFFECT, // 0x4F
}

Datei anzeigen

@ -1,89 +1,17 @@
package us.myles.ViaVersion.protocols.protocol1_12_1to1_12; package us.myles.ViaVersion.protocols.protocol1_12_1to1_12;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; public class Protocol1_12_1To1_12 extends Protocol<ClientboundPackets1_12, ClientboundPackets1_12_1, ServerboundPackets1_12, ServerboundPackets1_12_1> {
public Protocol1_12_1To1_12() {
super(ClientboundPackets1_12.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12.class, ServerboundPackets1_12_1.class);
}
public class Protocol1_12_1To1_12 extends Protocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
registerOutgoing(State.PLAY, -1, 0x2B); // TODO new packet? cancelIncoming(ServerboundPackets1_12_1.CRAFT_RECIPE_REQUEST);
registerOutgoing(State.PLAY, 0x2b, 0x2c); // Player Abilities (clientbound)
registerOutgoing(State.PLAY, 0x2c, 0x2d); // Combat Event
registerOutgoing(State.PLAY, 0x2d, 0x2e); // Player List Item
registerOutgoing(State.PLAY, 0x2e, 0x2f); // Player Position And Look (clientbound)
registerOutgoing(State.PLAY, 0x2f, 0x30); // Use Bed
registerOutgoing(State.PLAY, 0x30, 0x31); // Unlock Recipes
registerOutgoing(State.PLAY, 0x31, 0x32); // Destroy Entities
registerOutgoing(State.PLAY, 0x32, 0x33); // Remove Entity Effect
registerOutgoing(State.PLAY, 0x33, 0x34); // Resource Pack Send
registerOutgoing(State.PLAY, 0x34, 0x35); // Respawn
registerOutgoing(State.PLAY, 0x35, 0x36); // Entity Head Look
registerOutgoing(State.PLAY, 0x36, 0x37); // Select Advancement Tab
registerOutgoing(State.PLAY, 0x37, 0x38); // World Border
registerOutgoing(State.PLAY, 0x38, 0x39); // Camera
registerOutgoing(State.PLAY, 0x39, 0x3a); // Held Item Change (clientbound)
registerOutgoing(State.PLAY, 0x3a, 0x3b); // Display Scoreboard
registerOutgoing(State.PLAY, 0x3b, 0x3c); // Entity Metadata
registerOutgoing(State.PLAY, 0x3c, 0x3d); // Attach Entity
registerOutgoing(State.PLAY, 0x3d, 0x3e); // Entity Velocity
registerOutgoing(State.PLAY, 0x3e, 0x3f); // Entity Equipment
registerOutgoing(State.PLAY, 0x3f, 0x40); // Set Experience
registerOutgoing(State.PLAY, 0x40, 0x41); // Update Health
registerOutgoing(State.PLAY, 0x41, 0x42); // Scoreboard Objective
registerOutgoing(State.PLAY, 0x42, 0x43); // Set Passengers
registerOutgoing(State.PLAY, 0x43, 0x44); // Teams
registerOutgoing(State.PLAY, 0x44, 0x45); // Update Sc
registerOutgoing(State.PLAY, 0x45, 0x46); // Spawn Position
registerOutgoing(State.PLAY, 0x46, 0x47); // Time Update
registerOutgoing(State.PLAY, 0x47, 0x48); // Title
registerOutgoing(State.PLAY, 0x48, 0x49); // Sound Effect
registerOutgoing(State.PLAY, 0x49, 0x4a); // Player List Header And Footer
registerOutgoing(State.PLAY, 0x4a, 0x4b); // Collect Item
registerOutgoing(State.PLAY, 0x4b, 0x4c); // Entity Teleport
registerOutgoing(State.PLAY, 0x4c, 0x4d); // Advancements
registerOutgoing(State.PLAY, 0x4d, 0x4e); // Entity Properties
registerOutgoing(State.PLAY, 0x4e, 0x4f); // Entity Effect
// TODO Where did the Prepare Crafting Grid packet go to?
registerIncoming(State.PLAY, 0x01, -1); // Prepare Crafting Grid (removed)
registerIncoming(State.PLAY, 0x02, 0x01); // Tab-Complete (serverbound)
registerIncoming(State.PLAY, 0x03, 0x02); // Chat Message (serverbound)
registerIncoming(State.PLAY, 0x04, 0x03); // Client Status
registerIncoming(State.PLAY, 0x05, 0x04); // Client Settings
registerIncoming(State.PLAY, 0x06, 0x05); // Confirm Transaction (serverbound)
registerIncoming(State.PLAY, 0x07, 0x06); // Enchant Item
registerIncoming(State.PLAY, 0x08, 0x07); // Click Window
registerIncoming(State.PLAY, 0x09, 0x08); // Close Window (serverbound)
registerIncoming(State.PLAY, 0x0a, 0x09); // Plugin Message (serverbound)
registerIncoming(State.PLAY, 0x0b, 0x0a); // Use Entity
registerIncoming(State.PLAY, 0x0c, 0x0b); // Keep Alive (serverbound)
registerIncoming(State.PLAY, 0x0d, 0x0c); // Player
registerIncoming(State.PLAY, 0x0e, 0x0d); // Player Position
registerIncoming(State.PLAY, 0x0f, 0x0e); // Player Position And Look (serverbound)
registerIncoming(State.PLAY, 0x10, 0x0f); // Player Look
registerIncoming(State.PLAY, 0x11, 0x10); // Vehicle Move (serverbound)
registerIncoming(State.PLAY, 0x12, 0x11); // Steer Boat
// TODO hello new packet
registerIncoming(State.PLAY, -1, 0x12, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.BYTE); // 0 - Unknown
map(Type.VAR_INT); // 1 - Unknown
map(Type.BOOLEAN); // 2 - Unknown
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.cancel();
}
});
}
});
} }
} }

Datei anzeigen

@ -0,0 +1,40 @@
package us.myles.ViaVersion.protocols.protocol1_12_1to1_12;
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
public enum ServerboundPackets1_12_1 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_MOVEMENT, // 0x0C
PLAYER_POSITION, // 0x0D
PLAYER_POSITION_AND_ROTATION, // 0x0E
PLAYER_ROTATION, // 0x0F
VEHICLE_MOVE, // 0x10
STEER_BOAT, // 0x11
CRAFT_RECIPE_REQUEST, // 0x12
PLAYER_ABILITIES, // 0x13
PLAYER_DIGGING, // 0x14
ENTITY_ACTION, // 0x15
STEER_VEHICLE, // 0x16
RECIPE_BOOK_DATA, // 0x17
RESOURCE_PACK_STATUS, // 0x18
ADVANCEMENT_TAB, // 0x19
HELD_ITEM_CHANGE, // 0x1A
CREATIVE_INVENTORY_ACTION, // 0x1B
UPDATE_SIGN, // 0x1C
ANIMATION, // 0x1D
SPECTATE, // 0x1E
PLAYER_BLOCK_PLACEMENT, // 0x1F
USE_ITEM, // 0x20
}

Datei anzeigen

@ -3,22 +3,25 @@ package us.myles.ViaVersion.protocols.protocol1_12_2to1_12_1;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
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_12_1to1_12.ClientboundPackets1_12_1;
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
public class Protocol1_12_2To1_12_1 extends Protocol { public class Protocol1_12_2To1_12_1 extends Protocol {
public Protocol1_12_2To1_12_1() {
super(ClientboundPackets1_12_1.class, ClientboundPackets1_12_1.class, ServerboundPackets1_12_1.class, ServerboundPackets1_12_1.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
// Outgoing registerOutgoing(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
// 0x1f - Keep alive
registerOutgoing(State.PLAY, 0x1f, 0x1f, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT, Type.LONG); map(Type.VAR_INT, Type.LONG);
} }
}); // Keep alive });
// Incoming
// 0xb - Keep alive registerIncoming(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
registerIncoming(State.PLAY, 0xb, 0xb, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.LONG, Type.VAR_INT); map(Type.LONG, Type.VAR_INT);

Datei anzeigen

@ -0,0 +1,86 @@
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_12 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_MOVEMENT, // 0x25
ENTITY_POSITION, // 0x26
ENTITY_POSITION_AND_ROTATION, // 0x27
ENTITY_ROTATION, // 0x28
VEHICLE_MOVE, // 0x29
OPEN_SIGN_EDITOR, // 0x2A
PLAYER_ABILITIES, // 0x2B
COMBAT_EVENT, // 0x2C
PLAYER_INFO, // 0x2D
PLAYER_POSITION, // 0x2E
USE_BED, // 0x2F
UNLOCK_RECIPES, // 0x30
DESTROY_ENTITIES, // 0x31
REMOVE_ENTITY_EFFECT, // 0x32
RESOURCE_PACK, // 0x33
RESPAWN, // 0x34
ENTITY_HEAD_LOOK, // 0x35
SELECT_ADVANCEMENTS_TAB, // 0x36
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
SOUND, // 0x48
TAB_LIST, // 0x49
COLLECT_ITEM, // 0x4A
ENTITY_TELEPORT, // 0x4B
ADVANCEMENTS, // 0x4C
ENTITY_PROPERTIES, // 0x4D
ENTITY_EFFECT, // 0x4E
}

Datei anzeigen

@ -16,7 +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.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_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;
@ -26,16 +27,19 @@ 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() {
super(ClientboundPackets1_9_3.class, ClientboundPackets1_12.class, ServerboundPackets1_9_3.class, ServerboundPackets1_12.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
MetadataRewriter1_12To1_11_1 metadataRewriter = new MetadataRewriter1_12To1_11_1(this); MetadataRewriter1_12To1_11_1 metadataRewriter = new MetadataRewriter1_12To1_11_1(this);
InventoryPackets.register(this); InventoryPackets.register(this);
// Outgoing
// 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
@ -47,8 +51,7 @@ public class Protocol1_12To1_11_1 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
@ -70,8 +73,7 @@ public class Protocol1_12To1_11_1 extends Protocol {
} }
}); });
// Chat message packet registerOutgoing(ClientboundPackets1_9_3.CHAT_MESSAGE, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x0F, 0x0F, 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)
@ -97,8 +99,7 @@ public class Protocol1_12To1_11_1 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() {
@ -141,66 +142,19 @@ public class Protocol1_12To1_11_1 extends Protocol {
} }
}); });
// Join Packet metadataRewriter.registerJoinGame(ClientboundPackets1_9_3.JOIN_GAME, null);
metadataRewriter.registerJoinGame(0x23, 0x23, null); metadataRewriter.registerEntityDestroy(ClientboundPackets1_9_3.DESTROY_ENTITIES);
metadataRewriter.registerRespawn(ClientboundPackets1_9_3.RESPAWN);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_12.METADATA_LIST);
// 0x28 moved to 0x25 new SoundRewriter(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
registerOutgoing(State.PLAY, 0x28, 0x25);
registerOutgoing(State.PLAY, 0x25, 0x26);
registerOutgoing(State.PLAY, 0x26, 0x27);
registerOutgoing(State.PLAY, 0x27, 0x28);
// New packet at 0x30
// Destroy entities
metadataRewriter.registerEntityDestroy(0x30, 0x31);
registerOutgoing(State.PLAY, 0x31, 0x32);
registerOutgoing(State.PLAY, 0x32, 0x33);
// Respawn Packet
metadataRewriter.registerRespawn(0x33, 0x34);
registerOutgoing(State.PLAY, 0x34, 0x35);
// New packet at 0x36
registerOutgoing(State.PLAY, 0x35, 0x37);
registerOutgoing(State.PLAY, 0x36, 0x38);
registerOutgoing(State.PLAY, 0x37, 0x39);
registerOutgoing(State.PLAY, 0x38, 0x3a);
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x39, 0x3b, Types1_12.METADATA_LIST);
registerOutgoing(State.PLAY, 0x3a, 0x3c);
registerOutgoing(State.PLAY, 0x3b, 0x3d);
// registerOutgoing(State.PLAY, 0x3c, 0x3e); - Handled in InventoryPackets
registerOutgoing(State.PLAY, 0x3d, 0x3f);
registerOutgoing(State.PLAY, 0x3e, 0x40);
registerOutgoing(State.PLAY, 0x3f, 0x41);
registerOutgoing(State.PLAY, 0x40, 0x42);
registerOutgoing(State.PLAY, 0x41, 0x43);
registerOutgoing(State.PLAY, 0x42, 0x44);
registerOutgoing(State.PLAY, 0x43, 0x45);
registerOutgoing(State.PLAY, 0x44, 0x46);
registerOutgoing(State.PLAY, 0x45, 0x47);
new SoundRewriter(this, this::getNewSoundId).registerSound(0x46, 0x48);
registerOutgoing(State.PLAY, 0x47, 0x49);
registerOutgoing(State.PLAY, 0x48, 0x4a);
registerOutgoing(State.PLAY, 0x49, 0x4b);
// New packet at 0x4c
registerOutgoing(State.PLAY, 0x4a, 0x4d);
registerOutgoing(State.PLAY, 0x4b, 0x4e);
// Incoming
// New packet at 0x01 // New packet at 0x01
cancelIncoming(State.PLAY, 0x01, 0x01); cancelIncoming(ServerboundPackets1_12.PREPARE_CRAFTING_GRID);
registerIncoming(State.PLAY, 0x01, 0x02);
registerIncoming(State.PLAY, 0x02, 0x03);
registerIncoming(State.PLAY, 0x03, 0x04);
// Client Settings (max length changed) // Client Settings (max length changed)
registerIncoming(State.PLAY, 0x04, 0x05, new PacketRemapper() { registerIncoming(ServerboundPackets1_12.CLIENT_SETTINGS, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // 0 - Locale map(Type.STRING); // 0 - Locale
@ -229,41 +183,12 @@ public class Protocol1_12To1_11_1 extends Protocol {
}); });
} }
}); });
registerIncoming(State.PLAY, 0x05, 0x06);
registerIncoming(State.PLAY, 0x06, 0x07);
// registerIncoming(State.PLAY, 0x07, 0x08); - Handled in InventoryPackets
registerIncoming(State.PLAY, 0x08, 0x09);
registerIncoming(State.PLAY, 0x09, 0x0a);
registerIncoming(State.PLAY, 0x0a, 0x0b);
registerIncoming(State.PLAY, 0x0b, 0x0c);
// Mojang swapped 0x0F to 0x0D
registerIncoming(State.PLAY, 0x0f, 0x0d);
registerIncoming(State.PLAY, 0x0c, 0x0e);
// Mojang swapped 0x0F to 0x0D
registerIncoming(State.PLAY, 0x0d, 0x0f);
registerIncoming(State.PLAY, 0x0e, 0x10);
registerIncoming(State.PLAY, 0x10, 0x11);
registerIncoming(State.PLAY, 0x11, 0x12);
registerIncoming(State.PLAY, 0x12, 0x13);
registerIncoming(State.PLAY, 0x13, 0x14);
registerIncoming(State.PLAY, 0x14, 0x15);
registerIncoming(State.PLAY, 0x15, 0x16);
// New packet at 0x17 // New packet at 0x17
cancelIncoming(State.PLAY, 0x17, 0x17); cancelIncoming(ServerboundPackets1_12.RECIPE_BOOK_DATA);
registerIncoming(State.PLAY, 0x16, 0x18);
// New packet 0x19 // New packet 0x19
cancelIncoming(State.PLAY, 0x19, 0x19); cancelIncoming(ServerboundPackets1_12.ADVANCEMENT_TAB);
registerIncoming(State.PLAY, 0x17, 0x1a);
// registerIncoming(State.PLAY, 0x18, 0x1b); - Handled in InventoryPackets
registerIncoming(State.PLAY, 0x19, 0x1c);
registerIncoming(State.PLAY, 0x1a, 0x1d);
registerIncoming(State.PLAY, 0x1b, 0x1e);
registerIncoming(State.PLAY, 0x1c, 0x1f);
registerIncoming(State.PLAY, 0x1d, 0x20);
} }
private int getNewSoundId(int id) { //TODO Make it better, suggestions are welcome. It's ugly and hardcoded now. private int getNewSoundId(int id) { //TODO Make it better, suggestions are welcome. It's ugly and hardcoded now.

Datei anzeigen

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

Datei anzeigen

@ -5,13 +5,13 @@ import com.google.gson.JsonObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
public class TranslateRewriter { public class TranslateRewriter {
public static boolean toClient(JsonElement element, UserConnection user) { public static boolean toClient(JsonElement element, UserConnection user) {
if (element instanceof JsonObject) { if (element instanceof JsonObject) {
JsonObject obj = (JsonObject) element; JsonObject obj = (JsonObject) element;
if (obj.has("translate")) { JsonElement translate = obj.get("translate");
if (obj.get("translate").getAsString().equals("chat.type.achievement")) { if (translate != null) {
return false; return !translate.getAsString().equals("chat.type.achievement");
}
} }
} }
return true; return true;

Datei anzeigen

@ -7,9 +7,10 @@ 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_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.providers.InventoryQuickMoveProvider; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.providers.InventoryQuickMoveProvider;
public class InventoryPackets { public class InventoryPackets {
@ -17,17 +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);
// 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, 0x3E);
// 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
@ -44,8 +40,9 @@ public class InventoryPackets {
BedRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Output Item BedRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Output Item
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem) if (secondItem) {
BedRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Second Item BedRewriter.toClientItem(wrapper.passthrough(Type.ITEM)); // Second Item
}
wrapper.passthrough(Type.BOOLEAN); // Trade disabled wrapper.passthrough(Type.BOOLEAN); // Trade disabled
wrapper.passthrough(Type.INT); // Number of tools uses wrapper.passthrough(Type.INT); // Number of tools uses
@ -58,8 +55,7 @@ public class InventoryPackets {
}); });
// Click window packet protocol.registerIncoming(ServerboundPackets1_12.CLICK_WINDOW, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x07, 0x08, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -100,6 +96,6 @@ public class InventoryPackets {
); );
// Creative Inventory Action // Creative Inventory Action
itemRewriter.registerCreativeInvAction(Type.ITEM, 0x18, 0x1b); itemRewriter.registerCreativeInvAction(ServerboundPackets1_12.CREATIVE_INVENTORY_ACTION, Type.ITEM);
} }
} }

Datei anzeigen

@ -8,15 +8,20 @@ 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.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.packets.WorldPackets; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.packets.WorldPackets;
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.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() {
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
@ -26,8 +31,7 @@ public class Protocol1_13_1To1_13 extends Protocol {
InventoryPackets.register(this); InventoryPackets.register(this);
WorldPackets.register(this); WorldPackets.register(this);
//Tab complete registerIncoming(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
registerIncoming(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -41,8 +45,7 @@ public class Protocol1_13_1To1_13 extends Protocol {
} }
}); });
//Edit Book registerIncoming(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.FLAT_ITEM); map(Type.FLAT_ITEM);
@ -66,8 +69,7 @@ public class Protocol1_13_1To1_13 extends Protocol {
} }
}); });
// Tab complete registerOutgoing(ClientboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x10, 0x10, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // Transaction id map(Type.VAR_INT); // Transaction id
@ -93,8 +95,7 @@ public class Protocol1_13_1To1_13 extends Protocol {
} }
}); });
// Boss bar registerOutgoing(ClientboundPackets1_13.BOSSBAR, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UUID); map(Type.UUID);
@ -117,8 +118,7 @@ public class Protocol1_13_1To1_13 extends Protocol {
} }
}); });
// Advancements registerOutgoing(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -160,9 +160,7 @@ public class Protocol1_13_1To1_13 extends Protocol {
} }
}); });
registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
//Tags
registerOutgoing(State.PLAY, 0x55, 0x55, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -193,9 +191,10 @@ public class Protocol1_13_1To1_13 extends Protocol {
@Override @Override
public void init(UserConnection userConnection) { public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker1_13(userConnection)); userConnection.put(new EntityTracker1_13(userConnection));
if (!userConnection.has(ClientWorld.class)) if (!userConnection.has(ClientWorld.class)) {
userConnection.put(new ClientWorld(userConnection)); userConnection.put(new ClientWorld(userConnection));
} }
}
public static int getNewBlockStateId(int blockId) { public static int getNewBlockStateId(int blockId) {

Datei anzeigen

@ -2,23 +2,21 @@ package us.myles.ViaVersion.protocols.protocol1_13_1to1_13.packets;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.entities.Entity1_13Types; import us.myles.ViaVersion.api.entities.Entity1_13Types;
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.api.type.types.version.Types1_13; import us.myles.ViaVersion.api.type.types.version.Types1_13;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.metadata.MetadataRewriter1_13_1To1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_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;
public class EntityPackets { public class EntityPackets {
public static void register(final Protocol protocol) { public static void register(Protocol1_13_1To1_13 protocol) {
MetadataRewriter1_13_1To1_13 metadataRewriter = protocol.get(MetadataRewriter1_13_1To1_13.class); MetadataRewriter1_13_1To1_13 metadataRewriter = protocol.get(MetadataRewriter1_13_1To1_13.class);
//spawn entity protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id map(Type.VAR_INT); // 0 - Entity id
@ -52,8 +50,7 @@ public class EntityPackets {
} }
}); });
// Spawn mob packet protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -74,8 +71,7 @@ public class EntityPackets {
} }
}); });
// Spawn player packet protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -91,10 +87,7 @@ public class EntityPackets {
} }
}); });
// Destroy entities metadataRewriter.registerEntityDestroy(ClientboundPackets1_13.DESTROY_ENTITIES);
metadataRewriter.registerEntityDestroy(0x35, 0x35); metadataRewriter.registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, Types1_13.METADATA_LIST);
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x3F, 0x3F, Types1_13.METADATA_LIST);
} }
} }

Datei anzeigen

@ -7,24 +7,19 @@ 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_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
public class InventoryPackets { public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
// Set cooldown itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets::getNewItemId);
itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets::getNewItemId); itemRewriter.registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_ITEM);
itemRewriter.registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_ITEM_ARRAY);
// Set slot packet protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
itemRewriter.registerSetSlot(Type.FLAT_ITEM, 0x17, 0x17);
// Window items packet
itemRewriter.registerWindowItems(Type.FLAT_ITEM_ARRAY, 0x15, 0x15);
// Plugin message
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // Channel map(Type.STRING); // Channel
@ -58,11 +53,9 @@ public class InventoryPackets {
} }
}); });
// Entity Equipment Packet itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
itemRewriter.registerEntityEquipment(Type.FLAT_ITEM, 0x42, 0x42);
// Declare Recipes protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -77,8 +70,8 @@ public class InventoryPackets {
int ingredientsNo = wrapper.passthrough(Type.VAR_INT); int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
for (int i1 = 0; i1 < ingredientsNo; i1++) { for (int i1 = 0; i1 < ingredientsNo; i1++) {
Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT); Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT);
for (int i2 = 0; i2 < items.length; i2++) { for (Item item : items) {
InventoryPackets.toClient(items[i2]); InventoryPackets.toClient(item);
} }
} }
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM)); // Result InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM)); // Result
@ -87,8 +80,8 @@ public class InventoryPackets {
wrapper.passthrough(Type.STRING); // Group wrapper.passthrough(Type.STRING); // Group
for (int i1 = 0; i1 < ingredientsNo; i1++) { for (int i1 = 0; i1 < ingredientsNo; i1++) {
Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT); Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT);
for (int i2 = 0; i2 < items.length; i2++) { for (Item item : items) {
InventoryPackets.toClient(items[i2]); InventoryPackets.toClient(item);
} }
} }
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM)); // Result InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM)); // Result
@ -96,8 +89,8 @@ public class InventoryPackets {
wrapper.passthrough(Type.STRING); // Group wrapper.passthrough(Type.STRING); // Group
// Ingredient start // Ingredient start
Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT); Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT);
for (int i2 = 0; i2 < items.length; i2++) { for (Item item : items) {
InventoryPackets.toClient(items[i2]); InventoryPackets.toClient(item);
} }
// Ingredient end // Ingredient end
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM)); InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM));
@ -110,12 +103,8 @@ public class InventoryPackets {
} }
}); });
itemRewriter.registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_ITEM);
// Click window packet itemRewriter.registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_ITEM);
itemRewriter.registerClickWindow(Type.FLAT_ITEM, 0x08, 0x08);
// Creative Inventory Action
itemRewriter.registerCreativeInvAction(Type.FLAT_ITEM, 0x24, 0x24);
} }
public static void toClient(Item item) { public static void toClient(Item item) {

Datei anzeigen

@ -8,8 +8,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.BlockRewriter; import us.myles.ViaVersion.api.rewriters.BlockRewriter;
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_13_1to1_13.Protocol1_13_1To1_13; import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
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;
@ -18,8 +18,7 @@ public class WorldPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13_1To1_13::getNewBlockStateId, Protocol1_13_1To1_13::getNewBlockId); BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13_1To1_13::getNewBlockStateId, Protocol1_13_1To1_13::getNewBlockId);
//Chunk protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x22, 0x22, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -39,20 +38,12 @@ public class WorldPackets {
} }
}); });
// Block action blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION);
blockRewriter.registerBlockAction(0x0A, 0x0A); blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001, InventoryPackets::getNewItemId);
// Block Change protocol.registerOutgoing(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
blockRewriter.registerBlockChange(0xB, 0xB);
// Multi Block Change
blockRewriter.registerMultiBlockChange(0xF, 0xF);
// Effect packet
blockRewriter.registerEffect(0x23, 0x23, 1010, 2001, InventoryPackets::getNewItemId);
//join game
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Entity ID map(Type.INT); // 0 - Entity ID
@ -71,8 +62,7 @@ public class WorldPackets {
} }
}); });
//respawn protocol.registerOutgoing(ClientboundPackets1_13.RESPAWN, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x38, 0x38, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Dimension ID map(Type.INT); // 0 - Dimension ID
@ -87,7 +77,6 @@ public class WorldPackets {
} }
}); });
//spawn particle blockRewriter.registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, 3, 20, 27, InventoryPackets::toClient, Type.FLAT_ITEM, Type.FLOAT);
blockRewriter.registerSpawnParticle(Type.FLOAT, 0x24, 0x24, 3, 20, 27, InventoryPackets::toClient, Type.FLAT_ITEM);
} }
} }

Datei anzeigen

@ -6,12 +6,17 @@ 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_13_2to1_13_1.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.InventoryPackets;
import us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets.WorldPackets; 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.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() {
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {
@ -19,16 +24,14 @@ public class Protocol1_13_2To1_13_1 extends Protocol {
WorldPackets.register(this); WorldPackets.register(this);
EntityPackets.register(this); EntityPackets.register(this);
//Edit Book registerIncoming(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM);
} }
}); });
// Advancements registerOutgoing(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {

Datei anzeigen

@ -1,6 +1,5 @@
package us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets; package us.myles.ViaVersion.protocols.protocol1_13_2to1_13_1.packets;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
@ -9,22 +8,18 @@ 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.api.type.types.version.Types1_13; import us.myles.ViaVersion.api.type.types.version.Types1_13;
import us.myles.ViaVersion.api.type.types.version.Types1_13_2; import us.myles.ViaVersion.api.type.types.version.Types1_13_2;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
public class EntityPackets { public class EntityPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
final PacketHandler metaTypeHandler = new PacketHandler() { final PacketHandler metaTypeHandler = wrapper -> {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) { for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
metadata.setMetaType(MetaType1_13_2.byId(metadata.getMetaType().getTypeID())); metadata.setMetaType(MetaType1_13_2.byId(metadata.getMetaType().getTypeID()));
} }
}
}; };
// Spawn mob packet protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -45,8 +40,7 @@ public class EntityPackets {
} }
}); });
// Spawn player packet protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -62,9 +56,7 @@ public class EntityPackets {
} }
}); });
protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_METADATA, new PacketRemapper() {
// Metadata packet
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -74,5 +66,4 @@ public class EntityPackets {
} }
}); });
} }
} }

Datei anzeigen

@ -5,13 +5,13 @@ 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_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
public class InventoryPackets { public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
// Set slot packet protocol.registerOutgoing(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.BYTE); // 0 - Window ID map(Type.BYTE); // 0 - Window ID
@ -19,9 +19,7 @@ public class InventoryPackets {
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value
} }
}); });
protocol.registerOutgoing(ClientboundPackets1_13.WINDOW_ITEMS, new PacketRemapper() {
// Window items packet
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -29,8 +27,7 @@ public class InventoryPackets {
} }
}); });
// Plugin message protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // Channel map(Type.STRING); // Channel
@ -63,8 +60,7 @@ public class InventoryPackets {
} }
}); });
// Entity Equipment Packet protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, 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,8 +69,7 @@ public class InventoryPackets {
} }
}); });
// Declare Recipes protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -113,8 +108,7 @@ public class InventoryPackets {
} }
}); });
// Click window packet protocol.registerIncoming(ServerboundPackets1_13.CLICK_WINDOW, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -124,17 +118,13 @@ public class InventoryPackets {
map(Type.VAR_INT); // 4 - Mode map(Type.VAR_INT); // 4 - Mode
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item
} }
} });
); protocol.registerIncoming(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
// Creative Inventory Action
protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.SHORT); // 0 - Slot map(Type.SHORT); // 0 - Slot
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item
} }
} });
);
} }
} }

Datei anzeigen

@ -5,13 +5,12 @@ 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_13to1_12_2.ClientboundPackets1_13;
public class WorldPackets { public class WorldPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
//spawn particle protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Particle ID map(Type.INT); // 0 - Particle ID

Datei anzeigen

@ -0,0 +1,93 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_13 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
CHAT_MESSAGE, // 0x0E
MULTI_BLOCK_CHANGE, // 0x0F
TAB_COMPLETE, // 0x10
DECLARE_COMMANDS, // 0x11
WINDOW_CONFIRMATION, // 0x12
CLOSE_WINDOW, // 0x13
OPEN_WINDOW, // 0x14
WINDOW_ITEMS, // 0x15
WINDOW_PROPERTY, // 0x16
SET_SLOT, // 0x17
COOLDOWN, // 0x18
PLUGIN_MESSAGE, // 0x19
NAMED_SOUND, // 0x1A
DISCONNECT, // 0x1B
ENTITY_STATUS, // 0x1C
NBT_QUERY, // 0x1D
EXPLOSION, // 0x1E
UNLOAD_CHUNK, // 0x1F
GAME_EVENT, // 0x20
KEEP_ALIVE, // 0x21
CHUNK_DATA, // 0x22
EFFECT, // 0x23
SPAWN_PARTICLE, // 0x24
JOIN_GAME, // 0x25
MAP_DATA, // 0x26
ENTITY_MOVEMENT, // 0x27
ENTITY_POSITION, // 0x28
ENTITY_POSITION_AND_ROTATION, // 0x29
ENTITY_ROTATION, // 0x2A
VEHICLE_MOVE, // 0x2B
OPEN_SIGN_EDITOR, // 0x2C
CRAFT_RECIPE_RESPONSE, // 0x2D
PLAYER_ABILITIES, // 0x2E
COMBAT_EVENT, // 0x2F
PLAYER_INFO, // 0x30
FACE_PLAYER, // 0x31
PLAYER_POSITION, // 0x32
USE_BED, // 0x33
UNLOCK_RECIPES, // 0x34
DESTROY_ENTITIES, // 0x35
REMOVE_ENTITY_EFFECT, // 0x36
RESOURCE_PACK, // 0x37
RESPAWN, // 0x38
ENTITY_HEAD_LOOK, // 0x39
SELECT_ADVANCEMENTS_TAB, // 0x3A
WORLD_BORDER, // 0x3B
CAMERA, // 0x3C
HELD_ITEM_CHANGE, // 0x3D
DISPLAY_SCOREBOARD, // 0x3E
ENTITY_METADATA, // 0x3F
ATTACH_ENTITY, // 0x40
ENTITY_VELOCITY, // 0x41
ENTITY_EQUIPMENT, // 0x42
SET_EXPERIENCE, // 0x43
UPDATE_HEALTH, // 0x44
SCOREBOARD_OBJECTIVE, // 0x45
SET_PASSENGERS, // 0x46
TEAMS, // 0x47
UPDATE_SCORE, // 0x48
SPAWN_POSITION, // 0x49
TIME_UPDATE, // 0x4A
TITLE, // 0x4B
STOP_SOUND, // 0x4D
SOUND, // 0x4C
TAB_LIST, // 0x4E
COLLECT_ITEM, // 0x4F
ENTITY_TELEPORT, // 0x50
ADVANCEMENTS, // 0x51
ENTITY_PROPERTIES, // 0x52
ENTITY_EFFECT, // 0x53
DECLARE_RECIPES, // 0x54
TAGS, // 0x55
}

Datei anzeigen

@ -18,6 +18,8 @@ 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.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.BlockConnectionProvider;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.providers.PacketBlockConnectionProvider;
@ -41,10 +43,10 @@ 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(true); super(ClientboundPackets1_12_1.class, ClientboundPackets1_13.class, ServerboundPackets1_12_1.class, ServerboundPackets1_13.class, true);
} }
public static final PacketHandler POS_TO_3_INT = wrapper -> { public static final PacketHandler POS_TO_3_INT = wrapper -> {
@ -145,8 +147,6 @@ public class Protocol1_13To1_12_2 extends Protocol {
WorldPackets.register(this); WorldPackets.register(this);
InventoryPackets.register(this); InventoryPackets.register(this);
// Outgoing packets
registerOutgoing(State.LOGIN, 0x0, 0x0, new PacketRemapper() { registerOutgoing(State.LOGIN, 0x0, 0x0, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -185,7 +185,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
// New packet 0x04 - Login Plugin Message // New packet 0x04 - Login Plugin Message
// Statistics // Statistics
registerOutgoing(State.PLAY, 0x07, 0x07, new PacketRemapper() { registerOutgoing(ClientboundPackets1_12_1.STATISTICS, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -244,8 +244,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
// Boss bar registerOutgoing(ClientboundPackets1_12_1.BOSSBAR, new PacketRemapper() {
registerOutgoing(State.PLAY, 0xC, 0xC, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UUID); map(Type.UUID);
@ -261,8 +260,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
// Chat message registerOutgoing(ClientboundPackets1_12_1.CHAT_MESSAGE, new PacketRemapper() {
registerOutgoing(State.PLAY, 0xF, 0xE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); map(Type.STRING);
@ -274,10 +272,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
// WorldPackets 0x10 -> 0x0F registerOutgoing(ClientboundPackets1_12_1.TAB_COMPLETE, new PacketRemapper() {
// Tab-Complete
registerOutgoing(State.PLAY, 0xE, 0x10, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
create(new ValueCreator() { create(new ValueCreator() {
@ -318,31 +313,17 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
// New packet 0x11, declare commands registerOutgoing(ClientboundPackets1_12_1.OPEN_WINDOW, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x11, 0x12);
registerOutgoing(State.PLAY, 0x12, 0x13);
// Open window
registerOutgoing(State.PLAY, 0x13, 0x14, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // Id map(Type.UNSIGNED_BYTE); // Id
map(Type.STRING); // Window type map(Type.STRING); // Window type
map(Type.STRING); // Title map(Type.STRING); // Title
handler(new PacketHandler() { handler(wrapper -> wrapper.set(Type.STRING, 1, ChatRewriter.processTranslate(wrapper.get(Type.STRING, 1))));
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.set(Type.STRING, 1, ChatRewriter.processTranslate(wrapper.get(Type.STRING, 1)));
}
});
} }
}); });
// InventoryPackets 0x14 -> 0x15 registerOutgoing(ClientboundPackets1_12_1.COOLDOWN, new PacketRemapper() {
// InventoryPackets 0x15 -> 0x16
// InventoryPackets 0x16 -> 0x17
// Set cooldown
registerOutgoing(State.PLAY, 0x17, 0x18, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -380,29 +361,16 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
// WorldPackets 0x18 -> 0x19
// Disconnect registerOutgoing(ClientboundPackets1_12_1.DISCONNECT, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x1A, 0x1B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); map(Type.STRING);
handler(new PacketHandler() { handler(wrapper -> wrapper.set(Type.STRING, 0, ChatRewriter.processTranslate(wrapper.get(Type.STRING, 0))));
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.set(Type.STRING, 0, ChatRewriter.processTranslate(wrapper.get(Type.STRING, 0)));
} }
}); });
}
});
registerOutgoing(State.PLAY, 0x1B, 0x1C);
// New packet 0x1D - NBT Query
// WorldPackets 0x1C -> 0x1E
registerOutgoing(State.PLAY, 0x1E, 0x20);
registerOutgoing(State.PLAY, 0x1F, 0x21);
// WorldPackets 0x20 -> 0x22
// Effect packet registerOutgoing(ClientboundPackets1_12_1.EFFECT, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x21, 0x23, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // Effect Id map(Type.INT); // Effect Id
@ -425,9 +393,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
// WorldPackets 0x22 -> 0x24 registerOutgoing(ClientboundPackets1_12_1.JOIN_GAME, new PacketRemapper() {
// Join (save dimension id)
registerOutgoing(State.PLAY, 0x23, 0x25, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Entity ID map(Type.INT); // 0 - Entity ID
@ -450,8 +416,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
// Map packet registerOutgoing(ClientboundPackets1_12_1.MAP_DATA, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x24, 0x26, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Map id map(Type.VAR_INT); // 0 - Map id
@ -475,28 +440,15 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
registerOutgoing(State.PLAY, 0x25, 0x27);
registerOutgoing(State.PLAY, 0x26, 0x28); registerOutgoing(ClientboundPackets1_12_1.CRAFT_RECIPE_RESPONSE, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x27, 0x29);
registerOutgoing(State.PLAY, 0x28, 0x2A);
registerOutgoing(State.PLAY, 0x29, 0x2B);
registerOutgoing(State.PLAY, 0x2A, 0x2C);
// Craft recipe response
registerOutgoing(State.PLAY, 0x2B, 0x2D, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.BYTE); map(Type.BYTE);
handler(new PacketHandler() { handler(wrapper -> wrapper.write(Type.STRING, "viaversion:legacy/" + wrapper.read(Type.VAR_INT)));
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.STRING, "viaversion:legacy/" + wrapper.read(Type.VAR_INT));
} }
}); });
} registerOutgoing(ClientboundPackets1_12_1.COMBAT_EVENT, new PacketRemapper() {
});
registerOutgoing(State.PLAY, 0x2C, 0x2E);
// Combat event
registerOutgoing(State.PLAY, 0x2D, 0x2F, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // Event map(Type.VAR_INT); // Event
@ -512,12 +464,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
registerOutgoing(State.PLAY, 0x2E, 0x30); registerOutgoing(ClientboundPackets1_12_1.UNLOCK_RECIPES, new PacketRemapper() {
// New 0x31 - Face Player
registerOutgoing(State.PLAY, 0x2F, 0x32);
registerOutgoing(State.PLAY, 0x30, 0x33);
// Unlock recipes
registerOutgoing(State.PLAY, 0x31, 0x34, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // action map(Type.VAR_INT); // action
@ -603,12 +550,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
// EntityPackets 0x32 -> 0x35 registerOutgoing(ClientboundPackets1_12_1.RESPAWN, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x33, 0x36);
registerOutgoing(State.PLAY, 0x34, 0x37);
// Respawn (save dimension id)
registerOutgoing(State.PLAY, 0x35, 0x38, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Dimension ID map(Type.INT); // 0 - Dimension ID
@ -628,20 +570,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
registerOutgoing(State.PLAY, 0x36, 0x39); registerOutgoing(ClientboundPackets1_12_1.SCOREBOARD_OBJECTIVE, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x37, 0x3A);
registerOutgoing(State.PLAY, 0x38, 0x3B);
registerOutgoing(State.PLAY, 0x39, 0x3C);
registerOutgoing(State.PLAY, 0x3A, 0x3D);
registerOutgoing(State.PLAY, 0x3B, 0x3E);
// EntityPackets 0x3C -> 0x3F
registerOutgoing(State.PLAY, 0x3D, 0x40);
registerOutgoing(State.PLAY, 0x3E, 0x41);
// InventoryPackets 0x3F -> 0x42
registerOutgoing(State.PLAY, 0x40, 0x43);
registerOutgoing(State.PLAY, 0x41, 0x44);
// Scoreboard Objective
registerOutgoing(State.PLAY, 0x42, 0x45, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // 0 - Objective name map(Type.STRING); // 0 - Objective name
@ -665,9 +594,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
registerOutgoing(State.PLAY, 0x43, 0x46); registerOutgoing(ClientboundPackets1_12_1.TEAMS, new PacketRemapper() {
// Team packet
registerOutgoing(State.PLAY, 0x44, 0x47, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // 0 - Team Name map(Type.STRING); // 0 - Team Name
@ -720,7 +647,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
registerOutgoing(State.PLAY, 0x45, 0x48, new PacketRemapper() { registerOutgoing(ClientboundPackets1_12_1.UPDATE_SCORE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -740,10 +667,8 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
registerOutgoing(State.PLAY, 0x46, 0x49);
registerOutgoing(State.PLAY, 0x47, 0x4A); registerOutgoing(ClientboundPackets1_12_1.TITLE, new PacketRemapper() {
// Title
registerOutgoing(State.PLAY, 0x48, 0x4B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // Action map(Type.VAR_INT); // Action
@ -760,10 +685,9 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
// New 0x4C - Stop Sound // New 0x4C - Stop Sound
new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)).registerSound(0x49, 0x4D); new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)).registerSound(ClientboundPackets1_12_1.SOUND);
// Player list header and footer registerOutgoing(ClientboundPackets1_12_1.TAB_LIST, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x4A, 0x4E, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); map(Type.STRING);
@ -777,10 +701,8 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
registerOutgoing(State.PLAY, 0x4B, 0x4F);
registerOutgoing(State.PLAY, 0x4C, 0x50); registerOutgoing(ClientboundPackets1_12_1.ADVANCEMENTS, new PacketRemapper() {
// Advancements
registerOutgoing(State.PLAY, 0x4D, 0x51, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -822,21 +744,17 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
registerOutgoing(State.PLAY, 0x4E, 0x52);
registerOutgoing(State.PLAY, 0x4F, 0x53);
// New packet 0x54 - Declare Recipes
// New packet 0x55 - Tags
// Incoming packets // Incoming packets
// New packet 0x02 - Login Plugin Message // New packet 0x02 - Login Plugin Message
cancelIncoming(State.LOGIN, 0x02); cancelIncoming(State.LOGIN, 0x02);
// New 0x01 - Query Block NBT // New 0x01 - Query Block NBT
cancelIncoming(State.PLAY, 0x01); cancelIncoming(ServerboundPackets1_13.QUERY_BLOCK_NBT);
// Tab-Complete // Tab-Complete
registerIncoming(State.PLAY, 0x1, 0x5, new PacketRemapper() { registerIncoming(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -868,7 +786,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
if (!wrapper.isCancelled() && Via.getConfig().get1_13TabCompleteDelay() > 0) { if (!wrapper.isCancelled() && Via.getConfig().get1_13TabCompleteDelay() > 0) {
TabCompleteTracker tracker = wrapper.user().get(TabCompleteTracker.class); TabCompleteTracker tracker = wrapper.user().get(TabCompleteTracker.class);
wrapper.cancel(); wrapper.cancel();
tracker.setTimeToSend(System.currentTimeMillis() + Via.getConfig().get1_13TabCompleteDelay() * 50); tracker.setTimeToSend(System.currentTimeMillis() + Via.getConfig().get1_13TabCompleteDelay() * 50L);
tracker.setLastTabComplete(wrapper.get(Type.STRING, 0)); tracker.setLastTabComplete(wrapper.get(Type.STRING, 0));
} }
} }
@ -876,14 +794,8 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
registerIncoming(State.PLAY, 0x05, 0x06);
registerIncoming(State.PLAY, 0x06, 0x07);
// InventoryPackets 0x07, 0x08
registerIncoming(State.PLAY, 0x08, 0x09);
// InventoryPackets 0x09 -> 0x0A
// New 0x0A - Edit book -> Plugin Message // New 0x0A - Edit book -> Plugin Message
registerIncoming(State.PLAY, 0x09, 0x0B, new PacketRemapper() { registerIncoming(ServerboundPackets1_13.EDIT_BOOK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -900,19 +812,12 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
// New 0x0C - Query Entity NBT
cancelIncoming(State.PLAY, 0x0C);
registerIncoming(State.PLAY, 0x0A, 0x0D); // New 0x0C - Query Entity NBT
registerIncoming(State.PLAY, 0x0B, 0x0E); cancelIncoming(ServerboundPackets1_13.ENTITY_NBT_REQUEST);
registerIncoming(State.PLAY, 0x0C, 0x0F);
registerIncoming(State.PLAY, 0x0D, 0x10);
registerIncoming(State.PLAY, 0x0E, 0x11);
registerIncoming(State.PLAY, 0x0F, 0x12);
registerIncoming(State.PLAY, 0x10, 0x13);
registerIncoming(State.PLAY, 0x11, 0x14);
// New 0x15 - Pick Item -> Plugin Message // New 0x15 - Pick Item -> Plugin Message
registerIncoming(State.PLAY, 0x09, 0x15, new PacketRemapper() { registerIncoming(ServerboundPackets1_13.PICK_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
create(new ValueCreator() { create(new ValueCreator() {
@ -924,26 +829,15 @@ public class Protocol1_13To1_12_2 extends Protocol {
} }
}); });
// Craft recipe request registerIncoming(ServerboundPackets1_13.CRAFT_RECIPE_REQUEST, new PacketRemapper() {
registerIncoming(State.PLAY, 0x12, 0x16, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.BYTE); // Window id map(Type.BYTE); // Window id
handler(new PacketHandler() { handler(wrapper -> wrapper.write(Type.VAR_INT, Integer.parseInt(wrapper.read(Type.STRING).substring(18))));
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.VAR_INT, Integer.parseInt(wrapper.read(Type.STRING).substring(18)));
}
});
} }
}); });
registerIncoming(State.PLAY, 0x13, 0x17); registerIncoming(ServerboundPackets1_13.RECIPE_BOOK_DATA, new PacketRemapper() {
registerIncoming(State.PLAY, 0x14, 0x18);
registerIncoming(State.PLAY, 0x15, 0x19);
registerIncoming(State.PLAY, 0x16, 0x1A);
// Recipe Book Data
registerIncoming(State.PLAY, 0x17, 0x1B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Type map(Type.VAR_INT); // 0 - Type
@ -968,53 +862,40 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
// New 0x1C - Name Item -> Plugin Message // New 0x1C - Name Item -> Plugin Message
registerIncoming(State.PLAY, 0x09, 0x1C, new PacketRemapper() { registerIncoming(ServerboundPackets1_13.RENAME_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
create(new ValueCreator() { create(wrapper -> {
@Override
public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.STRING, "MC|ItemName"); // Channel wrapper.write(Type.STRING, "MC|ItemName"); // Channel
}
}); });
} }
}); });
registerIncoming(State.PLAY, 0x18, 0x1D);
registerIncoming(State.PLAY, 0x19, 0x1E);
// New 0x1F - Select Trade -> Plugin Message // New 0x1F - Select Trade -> Plugin Message
registerIncoming(State.PLAY, 0x09, 0x1F, new PacketRemapper() { registerIncoming(ServerboundPackets1_13.SELECT_TRADE, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
create(new ValueCreator() { create(wrapper -> {
@Override
public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.STRING, "MC|TrSel"); // Channel wrapper.write(Type.STRING, "MC|TrSel"); // Channel
}
}); });
map(Type.VAR_INT, Type.INT); // Slot map(Type.VAR_INT, Type.INT); // Slot
} }
}); });
// New 0x20 - Set Beacon Effect -> Plugin Message // New 0x20 - Set Beacon Effect -> Plugin Message
registerIncoming(State.PLAY, 0x09, 0x20, new PacketRemapper() { registerIncoming(ServerboundPackets1_13.SET_BEACON_EFFECT, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
create(new ValueCreator() { create(wrapper -> {
@Override
public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.STRING, "MC|Beacon"); // Channel wrapper.write(Type.STRING, "MC|Beacon"); // Channel
}
}); });
map(Type.VAR_INT, Type.INT); // Primary Effect map(Type.VAR_INT, Type.INT); // Primary Effect
map(Type.VAR_INT, Type.INT); // Secondary Effect map(Type.VAR_INT, Type.INT); // Secondary Effect
} }
}); });
registerIncoming(State.PLAY, 0x1A, 0x21);
// New 0x22 - Update Command Block -> Plugin Message // New 0x22 - Update Command Block -> Plugin Message
registerIncoming(State.PLAY, 0x09, 0x22, new PacketRemapper() { registerIncoming(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
create(new ValueCreator() { create(new ValueCreator() {
@ -1043,8 +924,9 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
// New 0x23 - Update Command Block Minecart -> Plugin Message // New 0x23 - Update Command Block Minecart -> Plugin Message
registerIncoming(State.PLAY, 0x09, 0x23, new PacketRemapper() { registerIncoming(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK_MINECART, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
create(new ValueCreator() { create(new ValueCreator() {
@ -1061,14 +943,11 @@ public class Protocol1_13To1_12_2 extends Protocol {
// 0x1B -> 0x24 in InventoryPackets // 0x1B -> 0x24 in InventoryPackets
// New 0x25 - Update Structure Block -> Message Channel // New 0x25 - Update Structure Block -> Message Channel
registerIncoming(State.PLAY, 0x09, 0x25, new PacketRemapper() { registerIncoming(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
create(new ValueCreator() { create(wrapper -> {
@Override
public void write(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.STRING, "MC|Struct"); // Channel wrapper.write(Type.STRING, "MC|Struct"); // Channel
}
}); });
handler(POS_TO_3_INT); handler(POS_TO_3_INT);
map(Type.VAR_INT, new ValueTransformer<Integer, Byte>(Type.BYTE) { // Action map(Type.VAR_INT, new ValueTransformer<Integer, Byte>(Type.BYTE) { // Action
@ -1127,12 +1006,6 @@ public class Protocol1_13To1_12_2 extends Protocol {
}); });
} }
}); });
registerIncoming(State.PLAY, 0x1C, 0x26);
registerIncoming(State.PLAY, 0x1D, 0x27);
registerIncoming(State.PLAY, 0x1E, 0x28);
registerIncoming(State.PLAY, 0x1F, 0x29);
registerIncoming(State.PLAY, 0x20, 0x2A);
} }
@Override @Override

Datei anzeigen

@ -0,0 +1,50 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2;
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
public enum ServerboundPackets1_13 implements ServerboundPacketType {
TELEPORT_CONFIRM, // 0x00
QUERY_BLOCK_NBT, // 0x01
CHAT_MESSAGE, // 0x02
CLIENT_STATUS, // 0x03
CLIENT_SETTINGS, // 0x04
TAB_COMPLETE, // 0x05
WINDOW_CONFIRMATION, // 0x06
CLICK_WINDOW_BUTTON, // 0x07
CLICK_WINDOW, // 0x08
CLOSE_WINDOW, // 0x09
PLUGIN_MESSAGE, // 0x0A
EDIT_BOOK, // 0x0B
ENTITY_NBT_REQUEST, // 0x0C
INTERACT_ENTITY, // 0x0D
KEEP_ALIVE, // 0x0E
PLAYER_MOVEMENT, // 0x12
PLAYER_POSITION, // 0x0F
PLAYER_POSITION_AND_ROTATION, // 0x10
PLAYER_ROTATION, // 0x11
VEHICLE_MOVE, // 0x13
STEER_BOAT, // 0x14
PICK_ITEM, // 0x15
CRAFT_RECIPE_REQUEST, // 0x16
PLAYER_ABILITIES, // 0x17
PLAYER_DIGGING, // 0x18
ENTITY_ACTION, // 0x19
STEER_VEHICLE, // 0x1A
RECIPE_BOOK_DATA, // 0x1B
RENAME_ITEM, // 0x1C
RESOURCE_PACK_STATUS, // 0x1D
ADVANCEMENT_TAB, // 0x1E
SELECT_TRADE, // 0x1F
SET_BEACON_EFFECT, // 0x20
HELD_ITEM_CHANGE, // 0x21
UPDATE_COMMAND_BLOCK, // 0x22
UPDATE_COMMAND_BLOCK_MINECART, // 0x23
CREATIVE_INVENTORY_ACTION, // 0x24
UPDATE_STRUCTURE_BLOCK, // 0x25
UPDATE_SIGN, // 0x26
ANIMATION, // 0x27
SPECTATE, // 0x28
PLAYER_BLOCK_PLACEMENT, // 0x29
USE_ITEM, // 0x2A
}

Datei anzeigen

@ -2,22 +2,22 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.entities.Entity1_13Types; import us.myles.ViaVersion.api.entities.Entity1_13Types;
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.api.type.types.version.Types1_12; import us.myles.ViaVersion.api.type.types.version.Types1_12;
import us.myles.ViaVersion.api.type.types.version.Types1_13; import us.myles.ViaVersion.api.type.types.version.Types1_13;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1_13; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker1_13;
public class EntityPackets { public class EntityPackets {
public static void register(final Protocol protocol) {
public static void register(Protocol1_13To1_12_2 protocol) {
MetadataRewriter1_13To1_12_2 metadataRewriter = protocol.get(MetadataRewriter1_13To1_12_2.class); MetadataRewriter1_13To1_12_2 metadataRewriter = protocol.get(MetadataRewriter1_13To1_12_2.class);
// Spawn Object protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_ENTITY, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id map(Type.VAR_INT); // 0 - Entity id
@ -76,8 +76,7 @@ public class EntityPackets {
} }
}); });
// Spawn mob packet protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_MOB, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -98,8 +97,7 @@ public class EntityPackets {
} }
}); });
// Spawn player packet protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_PLAYER, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -115,10 +113,7 @@ public class EntityPackets {
} }
}); });
// Destroy entities metadataRewriter.registerEntityDestroy(ClientboundPackets1_12_1.DESTROY_ENTITIES);
metadataRewriter.registerEntityDestroy(0x32, 0x35); metadataRewriter.registerMetadataRewriter(ClientboundPackets1_12_1.ENTITY_METADATA, Types1_12.METADATA_LIST, Types1_13.METADATA_LIST);
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x3C, 0x3F, Types1_12.METADATA_LIST, Types1_13.METADATA_LIST);
} }
} }

Datei anzeigen

@ -1,7 +1,12 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets; package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets;
import com.github.steveice10.opennbt.conversion.ConverterRegistry; import com.github.steveice10.opennbt.conversion.ConverterRegistry;
import com.github.steveice10.opennbt.tag.builtin.*; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.ShortTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
@ -12,9 +17,10 @@ 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_12_1to1_12.ClientboundPackets1_12_1;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.BlockIdData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.BlockIdData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SoundSource; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SoundSource;
@ -32,8 +38,7 @@ public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
// Set slot packet protocol.registerOutgoing(ClientboundPackets1_12_1.SET_SLOT, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x16, 0x17, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.BYTE); // 0 - Window ID map(Type.BYTE); // 0 - Window ID
@ -43,9 +48,7 @@ public class InventoryPackets {
handler(itemRewriter.itemToClientHandler(Type.FLAT_ITEM)); handler(itemRewriter.itemToClientHandler(Type.FLAT_ITEM));
} }
}); });
protocol.registerOutgoing(ClientboundPackets1_12_1.WINDOW_ITEMS, new PacketRemapper() {
// Window items packet
protocol.registerOutgoing(State.PLAY, 0x14, 0x15, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -54,9 +57,7 @@ public class InventoryPackets {
handler(itemRewriter.itemArrayHandler(Type.FLAT_ITEM_ARRAY)); handler(itemRewriter.itemArrayHandler(Type.FLAT_ITEM_ARRAY));
} }
}); });
protocol.registerOutgoing(ClientboundPackets1_12_1.WINDOW_PROPERTY, new PacketRemapper() {
// Window property
protocol.registerOutgoing(State.PLAY, 0x15, 0x16, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // Window id map(Type.UNSIGNED_BYTE); // Window id
@ -76,7 +77,7 @@ public class InventoryPackets {
}); });
// Plugin message Packet -> Trading // Plugin message Packet -> Trading
protocol.registerOutgoing(State.PLAY, 0x18, 0x19, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // 0 - Channel map(Type.STRING); // 0 - Channel
@ -178,8 +179,7 @@ public class InventoryPackets {
} }
}); });
// Entity Equipment Packet protocol.registerOutgoing(ClientboundPackets1_12_1.ENTITY_EQUIPMENT, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x3F, 0x42, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -191,8 +191,7 @@ public class InventoryPackets {
}); });
// Click window packet protocol.registerIncoming(ServerboundPackets1_13.CLICK_WINDOW, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x07, 0x08, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -206,8 +205,7 @@ public class InventoryPackets {
} }
}); });
// Plugin message protocol.registerIncoming(ServerboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x09, 0x0A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // Channel map(Type.STRING); // Channel
@ -242,8 +240,7 @@ public class InventoryPackets {
} }
}); });
// Creative Inventory Action protocol.registerIncoming(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x1B, 0x24, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.SHORT); // 0 - Slot map(Type.SHORT); // 0 - Slot

Datei anzeigen

@ -13,7 +13,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.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle; import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionHandler; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections.ConnectionHandler;
@ -57,9 +57,7 @@ public class WorldPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
// Outgoing packets // Outgoing packets
protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_PAINTING, new PacketRemapper() {
// Spawn Painting
protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -82,8 +80,7 @@ public class WorldPackets {
} }
}); });
// Update Block Entity protocol.registerOutgoing(ClientboundPackets1_12_1.BLOCK_ENTITY_DATA, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION); // 0 - Location map(Type.POSITION); // 0 - Location
@ -113,8 +110,7 @@ public class WorldPackets {
} }
}); });
// Block action protocol.registerOutgoing(ClientboundPackets1_12_1.BLOCK_ACTION, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0xA, 0xA, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION); // Location map(Type.POSITION); // Location
@ -162,8 +158,7 @@ public class WorldPackets {
} }
}); });
// Block Change protocol.registerOutgoing(ClientboundPackets1_12_1.BLOCK_CHANGE, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION); map(Type.POSITION);
@ -193,8 +188,7 @@ public class WorldPackets {
} }
}); });
// Multi Block Change protocol.registerOutgoing(ClientboundPackets1_12_1.MULTI_BLOCK_CHANGE, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x10, 0xF, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Chunk X map(Type.INT); // 0 - Chunk X
@ -254,8 +248,7 @@ public class WorldPackets {
} }
}); });
// Explosion protocol.registerOutgoing(ClientboundPackets1_12_1.EXPLOSION, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x1C, 0x1E, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
if (!Via.getConfig().isServersideBlockConnections()) if (!Via.getConfig().isServersideBlockConnections())
@ -300,8 +293,7 @@ public class WorldPackets {
} }
}); });
// Unload Chunk protocol.registerOutgoing(ClientboundPackets1_12_1.UNLOAD_CHUNK, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x1D, 0x1F, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
if (Via.getConfig().isServersideBlockConnections()) { if (Via.getConfig().isServersideBlockConnections()) {
@ -317,8 +309,7 @@ public class WorldPackets {
} }
}); });
// Named Sound Effect TODO String -> Identifier? Check if identifier is present? protocol.registerOutgoing(ClientboundPackets1_12_1.NAMED_SOUND, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x19, 0x1A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); map(Type.STRING);
@ -332,8 +323,7 @@ public class WorldPackets {
} }
}); });
// Chunk Data protocol.registerOutgoing(ClientboundPackets1_12_1.CHUNK_DATA, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x20, 0x22, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -464,8 +454,7 @@ public class WorldPackets {
} }
}); });
// Particle protocol.registerOutgoing(ClientboundPackets1_12_1.SPAWN_PARTICLE, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x22, 0x24, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Particle ID map(Type.INT); // 0 - Particle ID

Datei anzeigen

@ -5,8 +5,14 @@ import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14;
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.packets.EntityPackets;
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.storage.EntityTracker1_14_1;
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_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() {
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
}
@Override @Override
protected void registerPackets() { protected void registerPackets() {

Datei anzeigen

@ -1,20 +1,19 @@
package us.myles.ViaVersion.protocols.protocol1_14_1to1_14.packets; package us.myles.ViaVersion.protocols.protocol1_14_1to1_14.packets;
import us.myles.ViaVersion.api.entities.Entity1_14Types; import us.myles.ViaVersion.api.entities.Entity1_14Types;
import us.myles.ViaVersion.api.protocol.Protocol;
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.api.type.types.version.Types1_14; import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14;
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14; import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.metadata.MetadataRewriter1_14_1To1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
public class EntityPackets { public class EntityPackets {
public static void register(final Protocol protocol) { public static void register(Protocol1_14_1To1_14 protocol) {
MetadataRewriter1_14_1To1_14 metadataRewriter = protocol.get(MetadataRewriter1_14_1To1_14.class); MetadataRewriter1_14_1To1_14 metadataRewriter = protocol.get(MetadataRewriter1_14_1To1_14.class);
// Spawn Mob protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
protocol.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
@ -35,11 +34,9 @@ public class EntityPackets {
} }
}); });
// Destroy entities metadataRewriter.registerEntityDestroy(ClientboundPackets1_14.DESTROY_ENTITIES);
metadataRewriter.registerEntityDestroy(0x37, 0x37);
// Spawn Player protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -55,7 +52,6 @@ public class EntityPackets {
} }
}); });
// Entity Metadata metadataRewriter.registerMetadataRewriter(ClientboundPackets1_14.ENTITY_METADATA, Types1_14.METADATA_LIST);
metadataRewriter.registerMetadataRewriter(0x43, 0x43, Types1_14.METADATA_LIST);
} }
} }

Datei anzeigen

@ -1,17 +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.data.UserConnection;
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() {
}
@Override
public void init(UserConnection userConnection) {
}
} }

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

@ -0,0 +1,100 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_14 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
CHAT_MESSAGE, // 0x0E
MULTI_BLOCK_CHANGE, // 0x0F
TAB_COMPLETE, // 0x10
DECLARE_COMMANDS, // 0x11
WINDOW_CONFIRMATION, // 0x12
CLOSE_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
OPEN_HORSE_WINDOW, // 0x1F
KEEP_ALIVE, // 0x20
CHUNK_DATA, // 0x21
EFFECT, // 0x22
SPAWN_PARTICLE, // 0x23
UPDATE_LIGHT, // 0x24
JOIN_GAME, // 0x25
MAP_DATA, // 0x26
TRADE_LIST, // 0x27
ENTITY_POSITION, // 0x28
ENTITY_POSITION_AND_ROTATION, // 0x29
ENTITY_ROTATION, // 0x2A
ENTITY_MOVEMENT, // 0x2B
VEHICLE_MOVE, // 0x2C
OPEN_BOOK, // 0x2D
OPEN_WINDOW, // 0x2E
OPEN_SIGN_EDITOR, // 0x2F
CRAFT_RECIPE_RESPONSE, // 0x30
PLAYER_ABILITIES, // 0x31
COMBAT_EVENT, // 0x32
PLAYER_INFO, // 0x33
FACE_PLAYER, // 0x34
PLAYER_POSITION, // 0x35
UNLOCK_RECIPES, // 0x36
DESTROY_ENTITIES, // 0x37
REMOVE_ENTITY_EFFECT, // 0x38
RESOURCE_PACK, // 0x39
RESPAWN, // 0x3A
ENTITY_HEAD_LOOK, // 0x3B
SELECT_ADVANCEMENTS_TAB, // 0x3C
WORLD_BORDER, // 0x3D
CAMERA, // 0x3E
HELD_ITEM_CHANGE, // 0x3F
UPDATE_VIEW_POSITION, // 0x40
UPDATE_VIEW_DISTANCE, // 0x41
DISPLAY_SCOREBOARD, // 0x42
ENTITY_METADATA, // 0x43
ATTACH_ENTITY, // 0x44
ENTITY_VELOCITY, // 0x45
ENTITY_EQUIPMENT, // 0x46
SET_EXPERIENCE, // 0x47
UPDATE_HEALTH, // 0x48
SCOREBOARD_OBJECTIVE, // 0x49
SET_PASSENGERS, // 0x4A
TEAMS, // 0x4B
UPDATE_SCORE, // 0x4C
SPAWN_POSITION, // 0x4D
TIME_UPDATE, // 0x4E
TITLE, // 0x4F
ENTITY_SOUND, // 0x50
SOUND, // 0x51
STOP_SOUND, // 0x52
TAB_LIST, // 0x53
NBT_QUERY, // 0x54
COLLECT_ITEM, // 0x55
ENTITY_TELEPORT, // 0x56
ADVANCEMENTS, // 0x57
ENTITY_PROPERTIES, // 0x58
ENTITY_EFFECT, // 0x59
DECLARE_RECIPES, // 0x5A
TAGS, // 0x5B
ACKNOWLEDGE_PLAYER_DIGGING, // 0x5C
}

Datei anzeigen

@ -8,7 +8,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.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.packets.State; 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_14to1_13_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.metadata.MetadataRewriter1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.metadata.MetadataRewriter1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.EntityPackets;
@ -18,10 +19,10 @@ 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(true); super(ClientboundPackets1_13.class, ClientboundPackets1_14.class, ServerboundPackets1_13.class, ServerboundPackets1_14.class, true);
} }
@Override @Override
@ -33,61 +34,9 @@ public class Protocol1_14To1_13_2 extends Protocol {
WorldPackets.register(this); WorldPackets.register(this);
PlayerPackets.register(this); PlayerPackets.register(this);
registerOutgoing(State.PLAY, 0x16, 0x15); new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)).registerSound(ClientboundPackets1_13.SOUND);
registerOutgoing(State.PLAY, 0x1A, 0x19); registerOutgoing(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x1B, 0x1A);
registerOutgoing(State.PLAY, 0x1C, 0x1B);
registerOutgoing(State.PLAY, 0x1D, 0x54);
registerOutgoing(State.PLAY, 0x1F, 0x1D);
registerOutgoing(State.PLAY, 0x20, 0x1E);
registerOutgoing(State.PLAY, 0x21, 0x20);
registerOutgoing(State.PLAY, 0x27, 0x2B);
registerOutgoing(State.PLAY, 0x2B, 0x2C);
registerOutgoing(State.PLAY, 0x2D, 0x30);
registerOutgoing(State.PLAY, 0x2E, 0x31);
registerOutgoing(State.PLAY, 0x2F, 0x32);
registerOutgoing(State.PLAY, 0x30, 0x33);
registerOutgoing(State.PLAY, 0x31, 0x34);
// Position and look
registerOutgoing(State.PLAY, 0x32, 0x35);
registerOutgoing(State.PLAY, 0x34, 0x36);
registerOutgoing(State.PLAY, 0x36, 0x38);
registerOutgoing(State.PLAY, 0x37, 0x39);
registerOutgoing(State.PLAY, 0x39, 0x3B);
registerOutgoing(State.PLAY, 0x3A, 0x3C);
registerOutgoing(State.PLAY, 0x3B, 0x3D);
registerOutgoing(State.PLAY, 0x3C, 0x3E);
registerOutgoing(State.PLAY, 0x3D, 0x3F);
registerOutgoing(State.PLAY, 0x3E, 0x42);
registerOutgoing(State.PLAY, 0x40, 0x44);
registerOutgoing(State.PLAY, 0x41, 0x45);
registerOutgoing(State.PLAY, 0x43, 0x47);
registerOutgoing(State.PLAY, 0x44, 0x48);
registerOutgoing(State.PLAY, 0x45, 0x49);
registerOutgoing(State.PLAY, 0x46, 0x4A);
registerOutgoing(State.PLAY, 0x47, 0x4B);
registerOutgoing(State.PLAY, 0x48, 0x4C);
registerOutgoing(State.PLAY, 0x4A, 0x4E);
registerOutgoing(State.PLAY, 0x4B, 0x4F);
registerOutgoing(State.PLAY, 0x4C, 0x52);
new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)).registerSound(0x4D, 0x51);
registerOutgoing(State.PLAY, 0x4E, 0x53);
registerOutgoing(State.PLAY, 0x4F, 0x55);
registerOutgoing(State.PLAY, 0x50, 0x56);
registerOutgoing(State.PLAY, 0x51, 0x57, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -128,10 +77,7 @@ public class Protocol1_14To1_13_2 extends Protocol {
} }
}); });
registerOutgoing(State.PLAY, 0x52, 0x58); registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x53, 0x59);
registerOutgoing(State.PLAY, 0x55, 0x5B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -195,53 +141,11 @@ public class Protocol1_14To1_13_2 extends Protocol {
}); });
// Set Difficulty packet added in 19w11a // Set Difficulty packet added in 19w11a
cancelIncoming(State.PLAY, 0x02); cancelIncoming(ServerboundPackets1_14.SET_DIFFICULTY);
registerIncoming(State.PLAY, 0x02, 0x03);
registerIncoming(State.PLAY, 0x03, 0x04);
registerIncoming(State.PLAY, 0x04, 0x05);
registerIncoming(State.PLAY, 0x05, 0x06);
registerIncoming(State.PLAY, 0x06, 0x07);
registerIncoming(State.PLAY, 0x07, 0x08);
registerIncoming(State.PLAY, 0x09, 0x0A);
registerIncoming(State.PLAY, 0x0A, 0x0B);
registerIncoming(State.PLAY, 0x0C, 0x0D);
registerIncoming(State.PLAY, 0x0D, 0x0E);
// Lock Difficulty packet added in 19w11a // Lock Difficulty packet added in 19w11a
cancelIncoming(State.PLAY, 0x10); cancelIncoming(ServerboundPackets1_14.LOCK_DIFFICULTY);
registerIncoming(State.PLAY, 0x0E, 0x0F);
registerIncoming(State.PLAY, 0x0F, 0x14);
registerIncoming(State.PLAY, 0x10, 0x11);
registerIncoming(State.PLAY, 0x11, 0x12);
registerIncoming(State.PLAY, 0x12, 0x13);
registerIncoming(State.PLAY, 0x13, 0x15);
registerIncoming(State.PLAY, 0x14, 0x16);
registerIncoming(State.PLAY, 0x15, 0x17);
registerIncoming(State.PLAY, 0x16, 0x18);
registerIncoming(State.PLAY, 0x17, 0x19);
registerIncoming(State.PLAY, 0x19, 0x1B);
registerIncoming(State.PLAY, 0x1A, 0x1C);
registerIncoming(State.PLAY, 0x1C, 0x1E);
registerIncoming(State.PLAY, 0x1D, 0x1F);
registerIncoming(State.PLAY, 0x1E, 0x20);
registerIncoming(State.PLAY, 0x20, 0x22);
registerIncoming(State.PLAY, 0x21, 0x23);
registerIncoming(State.PLAY, 0x23, 0x25);
// Unknown packet added in 19w13a // Unknown packet added in 19w13a
cancelIncoming(State.PLAY, 0x27); cancelIncoming(ServerboundPackets1_14.UPDATE_JIGSAW_BLOCK);
registerIncoming(State.PLAY, 0x27, 0x2A);
registerIncoming(State.PLAY, 0x28, 0x2B);
registerIncoming(State.PLAY, 0x2A, 0x2D);
} }
@Override @Override

Datei anzeigen

@ -0,0 +1,53 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2;
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
public enum ServerboundPackets1_14 implements ServerboundPacketType {
TELEPORT_CONFIRM, // 0x00
QUERY_BLOCK_NBT, // 0x01
SET_DIFFICULTY, // 0x02
CHAT_MESSAGE, // 0x03
CLIENT_STATUS, // 0x04
CLIENT_SETTINGS, // 0x05
TAB_COMPLETE, // 0x06
WINDOW_CONFIRMATION, // 0x07
CLICK_WINDOW_BUTTON, // 0x08
CLICK_WINDOW, // 0x09
CLOSE_WINDOW, // 0x0A
PLUGIN_MESSAGE, // 0x0B
EDIT_BOOK, // 0x0C
ENTITY_NBT_REQUEST, // 0x0D
INTERACT_ENTITY, // 0x0E
KEEP_ALIVE, // 0x0F
LOCK_DIFFICULTY, // 0x10
PLAYER_POSITION, // 0x11
PLAYER_POSITION_AND_ROTATION, // 0x12
PLAYER_ROTATION, // 0x13
PLAYER_MOVEMENT, // 0x14
VEHICLE_MOVE, // 0x15
STEER_BOAT, // 0x16
PICK_ITEM, // 0x17
CRAFT_RECIPE_REQUEST, // 0x18
PLAYER_ABILITIES, // 0x19
PLAYER_DIGGING, // 0x1A
ENTITY_ACTION, // 0x1B
STEER_VEHICLE, // 0x1C
RECIPE_BOOK_DATA, // 0x1D
RENAME_ITEM, // 0x1E
RESOURCE_PACK_STATUS, // 0x1F
ADVANCEMENT_TAB, // 0x20
SELECT_TRADE, // 0x21
SET_BEACON_EFFECT, // 0x22
HELD_ITEM_CHANGE, // 0x23
UPDATE_COMMAND_BLOCK, // 0x24
UPDATE_COMMAND_BLOCK_MINECART, // 0x25
CREATIVE_INVENTORY_ACTION, // 0x26
UPDATE_JIGSAW_BLOCK, // 0x27
UPDATE_STRUCTURE_BLOCK, // 0x28
UPDATE_SIGN, // 0x29
ANIMATION, // 0x2A
SPECTATE, // 0x2B
PLAYER_BLOCK_PLACEMENT, // 0x2C
USE_ITEM, // 0x2D
}

Datei anzeigen

@ -6,13 +6,13 @@ import us.myles.ViaVersion.api.entities.Entity1_14Types;
import us.myles.ViaVersion.api.minecraft.Position; import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
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.api.type.types.version.Types1_13_2; import us.myles.ViaVersion.api.type.types.version.Types1_13_2;
import us.myles.ViaVersion.api.type.types.version.Types1_14; import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.EntityTypeRewriter; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.EntityTypeRewriter;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.metadata.MetadataRewriter1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.metadata.MetadataRewriter1_14To1_13_2;
@ -23,11 +23,10 @@ import java.util.List;
public class EntityPackets { public class EntityPackets {
public static void register(final Protocol protocol) { public static void register(Protocol1_14To1_13_2 protocol) {
MetadataRewriter1_14To1_13_2 metadataRewriter = protocol.get(MetadataRewriter1_14To1_13_2.class); MetadataRewriter1_14To1_13_2 metadataRewriter = protocol.get(MetadataRewriter1_14To1_13_2.class);
// Spawn entity protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
protocol.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
@ -104,8 +103,7 @@ public class EntityPackets {
} }
}); });
// Spawn mob packet protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
protocol.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
@ -126,8 +124,7 @@ public class EntityPackets {
} }
}); });
// Spawn painting protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PAINTING, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -138,8 +135,7 @@ public class EntityPackets {
} }
}); });
// Spawn player packet protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -155,8 +151,7 @@ public class EntityPackets {
} }
}); });
// Animation protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_ANIMATION, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x06, 0x06, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -184,8 +179,7 @@ public class EntityPackets {
} }
}); });
// Use bed protocol.registerOutgoing(ClientboundPackets1_13.USE_BED, ClientboundPackets1_14.ENTITY_METADATA, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x33, 0x43, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -208,10 +202,7 @@ public class EntityPackets {
} }
}); });
// Destroy entities metadataRewriter.registerEntityDestroy(ClientboundPackets1_13.DESTROY_ENTITIES);
metadataRewriter.registerEntityDestroy(0x35, 0x37); metadataRewriter.registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, Types1_13_2.METADATA_LIST, Types1_14.METADATA_LIST);
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x3F, 0x43, Types1_13_2.METADATA_LIST, Types1_14.METADATA_LIST);
} }
} }

Datei anzeigen

@ -1,7 +1,11 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets; package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets;
import com.github.steveice10.opennbt.conversion.ConverterRegistry; import com.github.steveice10.opennbt.conversion.ConverterRegistry;
import com.github.steveice10.opennbt.tag.builtin.*; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.DoubleTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
@ -11,10 +15,11 @@ 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_13to1_12_2.ChatRewriter; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.InventoryNameRewriter; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.InventoryNameRewriter;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
@ -28,11 +33,9 @@ public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
// Set cooldown itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets::getNewItemId);
itemRewriter.registerSetCooldown(0x18, 0x17, InventoryPackets::getNewItemId);
// Open Inventory protocol.registerOutgoing(ClientboundPackets1_13.OPEN_WINDOW, null, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x14, -1, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -105,14 +108,10 @@ public class InventoryPackets {
} }
}); });
// Window items packet itemRewriter.registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x14); itemRewriter.registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
// Set slot packet protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x17, 0x16);
// Plugin message
protocol.registerOutgoing(State.PLAY, 0x19, 0x18, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); // Channel map(Type.STRING); // Channel
@ -164,11 +163,9 @@ public class InventoryPackets {
} }
}); });
// Entity Equipment Packet itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x42, 0x46);
// Declare Recipes protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x54, 0x5A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -218,11 +215,9 @@ public class InventoryPackets {
}); });
// Click window packet itemRewriter.registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x08, 0x09);
// Select trade protocol.registerIncoming(ServerboundPackets1_14.SELECT_TRADE, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x1F, 0x21, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -244,11 +239,9 @@ public class InventoryPackets {
} }
}); });
// Creative Inventory Action itemRewriter.registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x24, 0x26);
} }
public static void toClient(Item item) { public static void toClient(Item item) {
if (item == null) return; if (item == null) return;
item.setIdentifier(getNewItemId(item.getIdentifier())); item.setIdentifier(getNewItemId(item.getIdentifier()));

Datei anzeigen

@ -11,22 +11,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_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
public class PlayerPackets { public class PlayerPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
protocol.registerOutgoing(ClientboundPackets1_13.OPEN_SIGN_EDITOR, new PacketRemapper() {
// Open Sign Editor
protocol.registerOutgoing(State.PLAY, 0x2C, 0x2F, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION, Type.POSITION1_14); map(Type.POSITION, Type.POSITION1_14);
} }
}); });
// Query Block NBT protocol.registerIncoming(ServerboundPackets1_14.QUERY_BLOCK_NBT, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x01, 0x01, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -34,14 +32,13 @@ public class PlayerPackets {
} }
}); });
// Edit Book protocol.registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x0B, 0x0C, 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 {
final Item item = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); Item item = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
InventoryPackets.toServer(item); InventoryPackets.toServer(item);
// Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit // Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit
@ -63,8 +60,7 @@ public class PlayerPackets {
} }
}); });
// Player Digging protocol.registerIncoming(ServerboundPackets1_14.PLAYER_DIGGING, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x18, 0x1A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -73,8 +69,7 @@ public class PlayerPackets {
} }
}); });
// Recipe Book Data protocol.registerIncoming(ServerboundPackets1_14.RECIPE_BOOK_DATA, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x1B, 0x1D, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -101,32 +96,26 @@ public class PlayerPackets {
} }
}); });
// Update Command Block protocol.registerIncoming(ServerboundPackets1_14.UPDATE_COMMAND_BLOCK, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x22, 0x24, new PacketRemapper() { @Override
public void registerMap() {
map(Type.POSITION1_14, Type.POSITION);
}
});
protocol.registerIncoming(ServerboundPackets1_14.UPDATE_STRUCTURE_BLOCK, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION1_14, Type.POSITION);
}
});
protocol.registerIncoming(ServerboundPackets1_14.UPDATE_SIGN, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION1_14, Type.POSITION); map(Type.POSITION1_14, Type.POSITION);
} }
}); });
// Update Structure Block protocol.registerIncoming(ServerboundPackets1_14.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x25, 0x28, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION1_14, Type.POSITION);
}
});
// Update Sign
protocol.registerIncoming(State.PLAY, 0x26, 0x29, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION1_14, Type.POSITION);
}
});
// Player Block Placement
protocol.registerIncoming(State.PLAY, 0x29, 0x2C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {

Datei anzeigen

@ -15,7 +15,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueCreator; import us.myles.ViaVersion.api.remapper.ValueCreator;
import us.myles.ViaVersion.api.rewriters.BlockRewriter; import us.myles.ViaVersion.api.rewriters.BlockRewriter;
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_13to1_12_2.ClientboundPackets1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
@ -41,8 +41,7 @@ public class WorldPackets {
public static void register(final Protocol protocol) { public static void register(final Protocol protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, null, Protocol1_14To1_13_2::getNewBlockStateId, Protocol1_14To1_13_2::getNewBlockId); BlockRewriter blockRewriter = new BlockRewriter(protocol, null, Protocol1_14To1_13_2::getNewBlockStateId, Protocol1_14To1_13_2::getNewBlockId);
// Block Break Animation protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x08, 0x08, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -50,17 +49,13 @@ public class WorldPackets {
map(Type.BYTE); map(Type.BYTE);
} }
}); });
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketRemapper() {
// Update Block Entity
protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION, Type.POSITION1_14); map(Type.POSITION, Type.POSITION1_14);
} }
}); });
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_ACTION, new PacketRemapper() {
// Block Action
protocol.registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION, Type.POSITION1_14); // Location map(Type.POSITION, Type.POSITION1_14); // Location
@ -75,9 +70,7 @@ public class WorldPackets {
}); });
} }
}); });
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_CHANGE, new PacketRemapper() {
// Block Change
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION, Type.POSITION1_14); map(Type.POSITION, Type.POSITION1_14);
@ -93,8 +86,7 @@ public class WorldPackets {
} }
}); });
// Server Difficulty protocol.registerOutgoing(ClientboundPackets1_13.SERVER_DIFFICULTY, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x0D, 0x0D, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); map(Type.UNSIGNED_BYTE);
@ -107,11 +99,9 @@ public class WorldPackets {
} }
}); });
// Multi Block Change blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(0x0F, 0x0F);
// Explosion protocol.registerOutgoing(ClientboundPackets1_13.EXPLOSION, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x1E, 0x1C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.FLOAT); // X map(Type.FLOAT); // X
@ -134,8 +124,7 @@ public class WorldPackets {
} }
}); });
// Chunk protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x22, 0x21, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -264,8 +253,7 @@ public class WorldPackets {
} }
}); });
// Effect protocol.registerOutgoing(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x23, 0x22, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // Effect Id map(Type.INT); // Effect Id
@ -286,12 +274,10 @@ public class WorldPackets {
} }
}); });
// Spawn particle blockRewriter.registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, 3, 20, 27,
blockRewriter.registerSpawnParticle(Type.FLOAT, 0x24, 0x23, 3, 20, 27, MetadataRewriter1_14To1_13_2::getNewParticleId, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM, Type.FLOAT);
MetadataRewriter1_14To1_13_2::getNewParticleId, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM);
// Join Game protocol.registerOutgoing(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Entity ID map(Type.INT); // 0 - Entity ID
@ -334,8 +320,7 @@ public class WorldPackets {
} }
}); });
// Map Data protocol.registerOutgoing(ClientboundPackets1_13.MAP_DATA, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x26, 0x26, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -350,8 +335,7 @@ public class WorldPackets {
} }
}); });
// Respawn protocol.registerOutgoing(ClientboundPackets1_13.RESPAWN, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x38, 0x3A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Dimension ID map(Type.INT); // 0 - Dimension ID
@ -379,8 +363,7 @@ public class WorldPackets {
} }
}); });
// Spawn Position protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_POSITION, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x49, 0x4D, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION, Type.POSITION1_14); map(Type.POSITION, Type.POSITION1_14);

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

@ -0,0 +1,100 @@
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_15 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
ACKNOWLEDGE_PLAYER_DIGGING, // 0x08
BLOCK_BREAK_ANIMATION, // 0x09
BLOCK_ENTITY_DATA, // 0x0A
BLOCK_ACTION, // 0x0B
BLOCK_CHANGE, // 0x0C
BOSSBAR, // 0x0D
SERVER_DIFFICULTY, // 0x0E
CHAT_MESSAGE, // 0x0F
MULTI_BLOCK_CHANGE, // 0x10
TAB_COMPLETE, // 0x11
DECLARE_COMMANDS, // 0x12
WINDOW_CONFIRMATION, // 0x13
CLOSE_WINDOW, // 0x14
WINDOW_ITEMS, // 0x15
WINDOW_PROPERTY, // 0x16
SET_SLOT, // 0x17
COOLDOWN, // 0x18
PLUGIN_MESSAGE, // 0x19
NAMED_SOUND, // 0x1A
DISCONNECT, // 0x1B
ENTITY_STATUS, // 0x1C
EXPLOSION, // 0x1D
UNLOAD_CHUNK, // 0x1E
GAME_EVENT, // 0x1F
OPEN_HORSE_WINDOW, // 0x20
KEEP_ALIVE, // 0x21
CHUNK_DATA, // 0x22
EFFECT, // 0x23
SPAWN_PARTICLE, // 0x24
UPDATE_LIGHT, // 0x25
JOIN_GAME, // 0x26
MAP_DATA, // 0x27
TRADE_LIST, // 0x28
ENTITY_POSITION, // 0x29
ENTITY_POSITION_AND_ROTATION, // 0x2A
ENTITY_ROTATION, // 0x2B
ENTITY_MOVEMENT, // 0x2C
VEHICLE_MOVE, // 0x2D
OPEN_BOOK, // 0x2E
OPEN_WINDOW, // 0x2F
OPEN_SIGN_EDITOR, // 0x30
CRAFT_RECIPE_RESPONSE, // 0x31
PLAYER_ABILITIES, // 0x32
COMBAT_EVENT, // 0x33
PLAYER_INFO, // 0x34
FACE_PLAYER, // 0x35
PLAYER_POSITION, // 0x36
UNLOCK_RECIPES, // 0x37
DESTROY_ENTITIES, // 0x38
REMOVE_ENTITY_EFFECT, // 0x39
RESOURCE_PACK, // 0x3A
RESPAWN, // 0x3B
ENTITY_HEAD_LOOK, // 0x3C
SELECT_ADVANCEMENTS_TAB, // 0x3D
WORLD_BORDER, // 0x3E
CAMERA, // 0x3F
HELD_ITEM_CHANGE, // 0x40
UPDATE_VIEW_POSITION, // 0x41
UPDATE_VIEW_DISTANCE, // 0x42
DISPLAY_SCOREBOARD, // 0x43
ENTITY_METADATA, // 0x44
ATTACH_ENTITY, // 0x45
ENTITY_VELOCITY, // 0x46
ENTITY_EQUIPMENT, // 0x47
SET_EXPERIENCE, // 0x48
UPDATE_HEALTH, // 0x49
SCOREBOARD_OBJECTIVE, // 0x4A
SET_PASSENGERS, // 0x4B
TEAMS, // 0x4C
UPDATE_SCORE, // 0x4D
SPAWN_POSITION, // 0x4E
TIME_UPDATE, // 0x4F
TITLE, // 0x50
ENTITY_SOUND, // 0x51
SOUND, // 0x52
STOP_SOUND, // 0x53
TAB_LIST, // 0x54
NBT_QUERY, // 0x55
COLLECT_ITEM, // 0x56
ENTITY_TELEPORT, // 0x57
ADVANCEMENTS, // 0x58
ENTITY_PROPERTIES, // 0x59
ENTITY_EFFECT, // 0x5A
DECLARE_RECIPES, // 0x5B
TAGS, // 0x5C
}

Datei anzeigen

@ -10,7 +10,8 @@ import us.myles.ViaVersion.api.rewriters.SoundRewriter;
import us.myles.ViaVersion.api.rewriters.TagRewriter; import us.myles.ViaVersion.api.rewriters.TagRewriter;
import us.myles.ViaVersion.api.rewriters.TagType; import us.myles.ViaVersion.api.rewriters.TagType;
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;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.metadata.MetadataRewriter1_15To1_14_4; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.metadata.MetadataRewriter1_15To1_14_4;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.EntityPackets;
@ -20,12 +21,12 @@ 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;
public Protocol1_15To1_14_4() { public Protocol1_15To1_14_4() {
super(true); super(ClientboundPackets1_14.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class, true);
} }
@Override @Override
@ -38,24 +39,17 @@ public class Protocol1_15To1_14_4 extends Protocol {
InventoryPackets.register(this); InventoryPackets.register(this);
SoundRewriter soundRewriter = new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)); SoundRewriter soundRewriter = new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id));
soundRewriter.registerSound(0x50, 0x51); // Entity Sound Effect (added somewhere in 1.14) soundRewriter.registerSound(ClientboundPackets1_14.ENTITY_SOUND); // Entity Sound Effect (added somewhere in 1.14)
soundRewriter.registerSound(0x51, 0x52); soundRewriter.registerSound(ClientboundPackets1_14.SOUND);
// Edit Book registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
registerIncoming(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(wrapper -> InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
@Override
public void handle(PacketWrapper wrapper) throws Exception {
InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
}
});
} }
}); });
// Advancements registerOutgoing(ClientboundPackets1_14.ADVANCEMENTS, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x57, 0x58, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -96,87 +90,8 @@ public class Protocol1_15To1_14_4 extends Protocol {
} }
}); });
// Tags
tagRewriter = new TagRewriter(this, Protocol1_15To1_14_4::getNewBlockId, InventoryPackets::getNewItemId, EntityPackets::getNewEntityId); tagRewriter = new TagRewriter(this, Protocol1_15To1_14_4::getNewBlockId, InventoryPackets::getNewItemId, EntityPackets::getNewEntityId);
tagRewriter.register(0x5B, 0x5C); tagRewriter.register(ClientboundPackets1_14.TAGS);
registerOutgoing(State.PLAY, 0x08, 0x09);
registerOutgoing(State.PLAY, 0x09, 0x0A);
registerOutgoing(State.PLAY, 0x0C, 0x0D);
registerOutgoing(State.PLAY, 0x0D, 0x0E);
registerOutgoing(State.PLAY, 0x0E, 0x0F);
registerOutgoing(State.PLAY, 0x10, 0x11);
registerOutgoing(State.PLAY, 0x11, 0x12);
registerOutgoing(State.PLAY, 0x12, 0x13);
registerOutgoing(State.PLAY, 0x13, 0x14);
registerOutgoing(State.PLAY, 0x15, 0x16);
registerOutgoing(State.PLAY, 0x18, 0x19);
registerOutgoing(State.PLAY, 0x19, 0x1A);
registerOutgoing(State.PLAY, 0x1A, 0x1B);
registerOutgoing(State.PLAY, 0x1B, 0x1C);
registerOutgoing(State.PLAY, 0x1C, 0x1D);
registerOutgoing(State.PLAY, 0x1D, 0x1E);
registerOutgoing(State.PLAY, 0x1E, 0x1F);
registerOutgoing(State.PLAY, 0x1F, 0x20);
registerOutgoing(State.PLAY, 0x20, 0x21);
registerOutgoing(State.PLAY, 0x24, 0x25);
registerOutgoing(State.PLAY, 0x26, 0x27);
registerOutgoing(State.PLAY, 0x28, 0x29);
registerOutgoing(State.PLAY, 0x29, 0x2A);
registerOutgoing(State.PLAY, 0x2A, 0x2B);
registerOutgoing(State.PLAY, 0x2B, 0x2C);
registerOutgoing(State.PLAY, 0x2C, 0x2D);
registerOutgoing(State.PLAY, 0x2D, 0x2E);
registerOutgoing(State.PLAY, 0x2E, 0x2F);
registerOutgoing(State.PLAY, 0x2F, 0x30);
registerOutgoing(State.PLAY, 0x30, 0x31);
registerOutgoing(State.PLAY, 0x31, 0x32);
registerOutgoing(State.PLAY, 0x32, 0x33);
registerOutgoing(State.PLAY, 0x33, 0x34);
registerOutgoing(State.PLAY, 0x34, 0x35);
registerOutgoing(State.PLAY, 0x35, 0x36);
registerOutgoing(State.PLAY, 0x36, 0x37);
registerOutgoing(State.PLAY, 0x38, 0x39);
registerOutgoing(State.PLAY, 0x39, 0x3A);
registerOutgoing(State.PLAY, 0x3B, 0x3C);
registerOutgoing(State.PLAY, 0x3C, 0x3D);
registerOutgoing(State.PLAY, 0x3D, 0x3E);
registerOutgoing(State.PLAY, 0x3E, 0x3F);
registerOutgoing(State.PLAY, 0x3F, 0x40);
registerOutgoing(State.PLAY, 0x40, 0x41);
registerOutgoing(State.PLAY, 0x41, 0x42);
registerOutgoing(State.PLAY, 0x42, 0x43);
registerOutgoing(State.PLAY, 0x44, 0x45);
registerOutgoing(State.PLAY, 0x45, 0x46);
registerOutgoing(State.PLAY, 0x47, 0x48);
registerOutgoing(State.PLAY, 0x48, 0x49);
registerOutgoing(State.PLAY, 0x49, 0x4A);
registerOutgoing(State.PLAY, 0x4A, 0x4B);
registerOutgoing(State.PLAY, 0x4B, 0x4C);
registerOutgoing(State.PLAY, 0x4C, 0x4D);
registerOutgoing(State.PLAY, 0x4D, 0x4E);
registerOutgoing(State.PLAY, 0x4E, 0x4F);
registerOutgoing(State.PLAY, 0x4F, 0x50);
registerOutgoing(State.PLAY, 0x52, 0x53);
registerOutgoing(State.PLAY, 0x53, 0x54);
registerOutgoing(State.PLAY, 0x54, 0x55);
registerOutgoing(State.PLAY, 0x55, 0x56);
registerOutgoing(State.PLAY, 0x56, 0x57);
registerOutgoing(State.PLAY, 0x58, 0x59);
registerOutgoing(State.PLAY, 0x59, 0x5A);
} }
@Override @Override

Datei anzeigen

@ -3,11 +3,10 @@ package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.entities.Entity1_15Types; import us.myles.ViaVersion.api.entities.Entity1_15Types;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.protocol.Protocol;
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.api.type.types.version.Types1_14; import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.metadata.MetadataRewriter1_15To1_14_4; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.metadata.MetadataRewriter1_15To1_14_4;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15;
@ -16,14 +15,12 @@ import java.util.List;
public class EntityPackets { public class EntityPackets {
public static void register(Protocol protocol) { public static void register(Protocol1_15To1_14_4 protocol) {
MetadataRewriter1_15To1_14_4 metadataRewriter = protocol.get(MetadataRewriter1_15To1_14_4.class); MetadataRewriter1_15To1_14_4 metadataRewriter = protocol.get(MetadataRewriter1_15To1_14_4.class);
// Spawn entity metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_14.SPAWN_ENTITY, Entity1_15Types.EntityType.FALLING_BLOCK, Protocol1_15To1_14_4::getNewBlockStateId);
metadataRewriter.registerSpawnTrackerWithData(0x00, 0x00, Entity1_15Types.EntityType.FALLING_BLOCK, Protocol1_15To1_14_4::getNewBlockStateId);
// Spawn mob packet protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
protocol.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
@ -52,8 +49,7 @@ public class EntityPackets {
} }
}); });
// Spawn player packet protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -79,10 +75,8 @@ public class EntityPackets {
} }
}); });
// Metadata packet metadataRewriter.registerMetadataRewriter(ClientboundPackets1_14.ENTITY_METADATA, Types1_14.METADATA_LIST);
metadataRewriter.registerMetadataRewriter(0x43, 0x44, Types1_14.METADATA_LIST); metadataRewriter.registerEntityDestroy(ClientboundPackets1_14.DESTROY_ENTITIES);
metadataRewriter.registerEntityDestroy(0x37, 0x38);
} }
public static int getNewEntityId(int oldId) { public static int getNewEntityId(int oldId) {

Datei anzeigen

@ -8,7 +8,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_14to1_13_2.ClientboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
public class InventoryPackets { public class InventoryPackets {
@ -16,14 +17,10 @@ public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
// Set cooldown itemRewriter.registerSetCooldown(ClientboundPackets1_14.COOLDOWN, InventoryPackets::getNewItemId);
itemRewriter.registerSetCooldown(0x17, 0x18, InventoryPackets::getNewItemId); itemRewriter.registerWindowItems(ClientboundPackets1_14.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
// Window items packet protocol.registerOutgoing(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x14, 0x15);
// Trade list packet
protocol.registerOutgoing(State.PLAY, 0x27, 0x28, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -62,14 +59,10 @@ public class InventoryPackets {
} }
}); });
// Set slot packet itemRewriter.registerSetSlot(ClientboundPackets1_14.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x16, 0x17); itemRewriter.registerEntityEquipment(ClientboundPackets1_14.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
// Entity Equipment Packet protocol.registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x46, 0x47);
// Declare Recipes
protocol.registerOutgoing(State.PLAY, 0x5A, 0x5B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -135,11 +128,8 @@ public class InventoryPackets {
} }
}); });
// Click window packet itemRewriter.registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x09); itemRewriter.registerCreativeInvAction(ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
// Creative Inventory Action
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x26, 0x26);
} }
public static void toClient(Item item) { public static void toClient(Item item) {

Datei anzeigen

@ -5,15 +5,14 @@ import us.myles.ViaVersion.api.entities.Entity1_15Types;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
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_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 PlayerPackets { public class PlayerPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
// Respawn protocol.registerOutgoing(ClientboundPackets1_14.RESPAWN, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x3A, 0x3B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); map(Type.INT);
@ -28,8 +27,7 @@ public class PlayerPackets {
} }
}); });
// Join Game protocol.registerOutgoing(ClientboundPackets1_14.JOIN_GAME, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x25, 0x26, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Entity ID map(Type.INT); // 0 - Entity ID

Datei anzeigen

@ -8,7 +8,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.BlockRewriter; import us.myles.ViaVersion.api.rewriters.BlockRewriter;
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.types.Chunk1_14Type; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
@ -19,20 +19,12 @@ public class WorldPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_15To1_14_4::getNewBlockStateId, Protocol1_15To1_14_4::getNewBlockId); BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_15To1_14_4::getNewBlockStateId, Protocol1_15To1_14_4::getNewBlockId);
// Block action blockRewriter.registerBlockAction(ClientboundPackets1_14.BLOCK_ACTION);
blockRewriter.registerBlockAction(0x0A, 0x0B); blockRewriter.registerBlockChange(ClientboundPackets1_14.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_14.MULTI_BLOCK_CHANGE);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
// Block Change protocol.registerOutgoing(ClientboundPackets1_14.CHUNK_DATA, new PacketRemapper() {
blockRewriter.registerBlockChange(0x0B, 0x0C);
// Multi Block Change
blockRewriter.registerMultiBlockChange(0x0F, 0x10);
// Acknowledge player digging
blockRewriter.registerAcknowledgePlayerDigging(0x5C, 0x08);
// Chunk Data
protocol.registerOutgoing(State.PLAY, 0x21, 0x22, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -78,11 +70,8 @@ public class WorldPackets {
} }
}); });
// Effect blockRewriter.registerEffect(ClientboundPackets1_14.EFFECT, 1010, 2001, InventoryPackets::getNewItemId);
blockRewriter.registerEffect(0x22, 0x23, 1010, 2001, InventoryPackets::getNewItemId); protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_PARTICLE, new PacketRemapper() {
// Spawn Particle
protocol.registerOutgoing(State.PLAY, 0x23, 0x24, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Particle ID map(Type.INT); // 0 - Particle ID

Datei anzeigen

@ -0,0 +1,99 @@
package us.myles.ViaVersion.protocols.protocol1_16to1_15_2;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_16 implements ClientboundPacketType {
SPAWN_ENTITY, // 0x00
SPAWN_EXPERIENCE_ORB, // 0x01
SPAWN_MOB, // 0x02
SPAWN_PAINTING, // 0x03
SPAWN_PLAYER, // 0x04
ENTITY_ANIMATION, // 0x05
STATISTICS, // 0x06
ACKNOWLEDGE_PLAYER_DIGGING, // 0x07
BLOCK_BREAK_ANIMATION, // 0x08
BLOCK_ENTITY_DATA, // 0x09
BLOCK_ACTION, // 0x0A
BLOCK_CHANGE, // 0x0B
BOSSBAR, // 0x0C
SERVER_DIFFICULTY, // 0x0D
CHAT_MESSAGE, // 0x0E
MULTI_BLOCK_CHANGE, // 0x0F
TAB_COMPLETE, // 0x10
DECLARE_COMMANDS, // 0x11
WINDOW_CONFIRMATION, // 0x12
CLOSE_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
OPEN_HORSE_WINDOW, // 0x1F
KEEP_ALIVE, // 0x20
CHUNK_DATA, // 0x21
EFFECT, // 0x22
SPAWN_PARTICLE, // 0x23
UPDATE_LIGHT, // 0x24
JOIN_GAME, // 0x25
MAP_DATA, // 0x26
TRADE_LIST, // 0x27
ENTITY_POSITION, // 0x28
ENTITY_POSITION_AND_ROTATION, // 0x29
ENTITY_ROTATION, // 0x2A
ENTITY_MOVEMENT, // 0x2B
VEHICLE_MOVE, // 0x2C
OPEN_BOOK, // 0x2D
OPEN_WINDOW, // 0x2E
OPEN_SIGN_EDITOR, // 0x2F
CRAFT_RECIPE_RESPONSE, // 0x30
PLAYER_ABILITIES, // 0x31
COMBAT_EVENT, // 0x32
PLAYER_INFO, // 0x33
FACE_PLAYER, // 0x34
PLAYER_POSITION, // 0x35
UNLOCK_RECIPES, // 0x36
DESTROY_ENTITIES, // 0x37
REMOVE_ENTITY_EFFECT, // 0x38
RESOURCE_PACK, // 0x39
RESPAWN, // 0x3A
ENTITY_HEAD_LOOK, // 0x3B
SELECT_ADVANCEMENTS_TAB, // 0x3C
WORLD_BORDER, // 0x3D
CAMERA, // 0x3E
HELD_ITEM_CHANGE, // 0x3F
UPDATE_VIEW_POSITION, // 0x40
UPDATE_VIEW_DISTANCE, // 0x41
SPAWN_POSITION, // 0x42
DISPLAY_SCOREBOARD, // 0x43
ENTITY_METADATA, // 0x44
ATTACH_ENTITY, // 0x45
ENTITY_VELOCITY, // 0x46
ENTITY_EQUIPMENT, // 0x47
SET_EXPERIENCE, // 0x48
UPDATE_HEALTH, // 0x49
SCOREBOARD_OBJECTIVE, // 0x4A
SET_PASSENGERS, // 0x4B
TEAMS, // 0x4C
UPDATE_SCORE, // 0x4D
TIME_UPDATE, // 0x4E
TITLE, // 0x4F
ENTITY_SOUND, // 0x50
SOUND, // 0x51
STOP_SOUND, // 0x52
TAB_LIST, // 0x53
NBT_QUERY, // 0x54
COLLECT_ITEM, // 0x55
ENTITY_TELEPORT, // 0x56
ADVANCEMENTS, // 0x57
ENTITY_PROPERTIES, // 0x58
ENTITY_EFFECT, // 0x59
DECLARE_RECIPES, // 0x5A
TAGS, // 0x5B
}

Datei anzeigen

@ -9,6 +9,8 @@ import us.myles.ViaVersion.api.rewriters.TagRewriter;
import us.myles.ViaVersion.api.rewriters.TagType; import us.myles.ViaVersion.api.rewriters.TagType;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
@ -19,13 +21,13 @@ 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;
public Protocol1_16To1_15_2() { public Protocol1_16To1_15_2() {
super(true); super(ClientboundPackets1_15.class, ClientboundPackets1_16.class, ServerboundPackets1_14.class, ServerboundPackets1_16.class, true);
} }
@Override @Override
@ -37,7 +39,7 @@ public class Protocol1_16To1_15_2 extends Protocol {
InventoryPackets.register(this); InventoryPackets.register(this);
tagRewriter = new TagRewriter(this, Protocol1_16To1_15_2::getNewBlockId, InventoryPackets::getNewItemId, metadataRewriter::getNewEntityId); tagRewriter = new TagRewriter(this, Protocol1_16To1_15_2::getNewBlockId, InventoryPackets::getNewItemId, metadataRewriter::getNewEntityId);
tagRewriter.register(0x5C, 0x5B); tagRewriter.register(ClientboundPackets1_15.TAGS);
// Login Success // Login Success
registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() { registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
@ -51,8 +53,7 @@ public class Protocol1_16To1_15_2 extends Protocol {
} }
}); });
// Chat Message registerOutgoing(ClientboundPackets1_15.CHAT_MESSAGE, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x0F, 0x0E, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.STRING); map(Type.STRING);
@ -62,11 +63,10 @@ public class Protocol1_16To1_15_2 extends Protocol {
}); });
SoundRewriter soundRewriter = new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id)); SoundRewriter soundRewriter = new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id));
soundRewriter.registerSound(0x51, 0x50); soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
soundRewriter.registerSound(0x52, 0x51); soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
// Advancements registerOutgoing(ClientboundPackets1_15.ADVANCEMENTS, new PacketRemapper() {
registerOutgoing(State.PLAY, 0x58, 0x57, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {
@ -104,91 +104,8 @@ public class Protocol1_16To1_15_2 extends Protocol {
} }
}); });
registerOutgoing(State.PLAY, 0x04, 0x03); cancelIncoming(ServerboundPackets1_16.GENERATE_JIGSAW);
registerOutgoing(State.PLAY, 0x06, 0x05); cancelIncoming(ServerboundPackets1_16.UPDATE_JIGSAW_BLOCK);
registerOutgoing(State.PLAY, 0x07, 0x06);
registerOutgoing(State.PLAY, 0x09, 0x08);
registerOutgoing(State.PLAY, 0x0A, 0x09);
registerOutgoing(State.PLAY, 0x0D, 0x0C);
registerOutgoing(State.PLAY, 0x0E, 0x0D);
registerOutgoing(State.PLAY, 0x11, 0x10);
registerOutgoing(State.PLAY, 0x12, 0x11);
registerOutgoing(State.PLAY, 0x13, 0x12);
registerOutgoing(State.PLAY, 0x14, 0x13);
registerOutgoing(State.PLAY, 0x19, 0x18);
registerOutgoing(State.PLAY, 0x1A, 0x19);
registerOutgoing(State.PLAY, 0x1B, 0x1A);
registerOutgoing(State.PLAY, 0x1C, 0x1B);
registerOutgoing(State.PLAY, 0x1D, 0x1C);
registerOutgoing(State.PLAY, 0x1E, 0x1D);
registerOutgoing(State.PLAY, 0x1F, 0x1E);
registerOutgoing(State.PLAY, 0x20, 0x1F);
registerOutgoing(State.PLAY, 0x21, 0x20);
registerOutgoing(State.PLAY, 0x25, 0x24);
registerOutgoing(State.PLAY, 0x27, 0x26);
registerOutgoing(State.PLAY, 0x29, 0x28);
registerOutgoing(State.PLAY, 0x2A, 0x29);
registerOutgoing(State.PLAY, 0x2B, 0x2A);
registerOutgoing(State.PLAY, 0x2C, 0x2B);
registerOutgoing(State.PLAY, 0x2D, 0x2C);
registerOutgoing(State.PLAY, 0x2E, 0x2D);
registerOutgoing(State.PLAY, 0x30, 0x2F);
registerOutgoing(State.PLAY, 0x31, 0x30);
registerOutgoing(State.PLAY, 0x32, 0x31);
registerOutgoing(State.PLAY, 0x33, 0x32);
registerOutgoing(State.PLAY, 0x34, 0x33);
registerOutgoing(State.PLAY, 0x35, 0x34);
registerOutgoing(State.PLAY, 0x36, 0x35);
registerOutgoing(State.PLAY, 0x37, 0x36);
registerOutgoing(State.PLAY, 0x39, 0x38);
registerOutgoing(State.PLAY, 0x3A, 0x39);
registerOutgoing(State.PLAY, 0x3C, 0x3B);
registerOutgoing(State.PLAY, 0x3D, 0x3C);
registerOutgoing(State.PLAY, 0x3E, 0x3D);
registerOutgoing(State.PLAY, 0x3F, 0x3E);
registerOutgoing(State.PLAY, 0x40, 0x3F);
registerOutgoing(State.PLAY, 0x41, 0x40);
registerOutgoing(State.PLAY, 0x42, 0x41);
registerOutgoing(State.PLAY, 0x4E, 0x42);
registerOutgoing(State.PLAY, 0x4F, 0x4E);
registerOutgoing(State.PLAY, 0x50, 0x4F);
registerOutgoing(State.PLAY, 0x53, 0x52);
registerOutgoing(State.PLAY, 0x54, 0x53);
registerOutgoing(State.PLAY, 0x55, 0x54);
registerOutgoing(State.PLAY, 0x56, 0x55);
registerOutgoing(State.PLAY, 0x57, 0x56);
registerOutgoing(State.PLAY, 0x5A, 0x59);
cancelIncoming(State.PLAY, 0x0F); // Generate jisaw
cancelIncoming(State.PLAY, 0x28); // Jigsaw update
registerIncoming(State.PLAY, 0x0F, 0x10);
registerIncoming(State.PLAY, 0x10, 0x11);
registerIncoming(State.PLAY, 0x11, 0x12);
registerIncoming(State.PLAY, 0x12, 0x13);
registerIncoming(State.PLAY, 0x13, 0x14);
registerIncoming(State.PLAY, 0x14, 0x15);
registerIncoming(State.PLAY, 0x15, 0x16);
registerIncoming(State.PLAY, 0x16, 0x17);
registerIncoming(State.PLAY, 0x17, 0x18);
registerIncoming(State.PLAY, 0x18, 0x19);
registerIncoming(State.PLAY, 0x19, 0x1A);
registerIncoming(State.PLAY, 0x1A, 0x1B);
registerIncoming(State.PLAY, 0x1B, 0x1C);
registerIncoming(State.PLAY, 0x1C, 0x1D);
registerIncoming(State.PLAY, 0x1D, 0x1E);
registerIncoming(State.PLAY, 0x1E, 0x1F);
registerIncoming(State.PLAY, 0x1F, 0x20);
registerIncoming(State.PLAY, 0x20, 0x21);
registerIncoming(State.PLAY, 0x21, 0x22);
registerIncoming(State.PLAY, 0x22, 0x23);
registerIncoming(State.PLAY, 0x23, 0x24);
registerIncoming(State.PLAY, 0x24, 0x25);
registerIncoming(State.PLAY, 0x28, 0x29);
registerIncoming(State.PLAY, 0x29, 0x2A);
registerIncoming(State.PLAY, 0x2A, 0x2B);
registerIncoming(State.PLAY, 0x2B, 0x2C);
registerIncoming(State.PLAY, 0x2C, 0x2D);
registerIncoming(State.PLAY, 0x2D, 0x2E);
} }
@Override @Override

Datei anzeigen

@ -0,0 +1,54 @@
package us.myles.ViaVersion.protocols.protocol1_16to1_15_2;
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
public enum ServerboundPackets1_16 implements ServerboundPacketType {
TELEPORT_CONFIRM, // 0x00
QUERY_BLOCK_NBT, // 0x01
SET_DIFFICULTY, // 0x02
CHAT_MESSAGE, // 0x03
CLIENT_STATUS, // 0x04
CLIENT_SETTINGS, // 0x05
TAB_COMPLETE, // 0x06
WINDOW_CONFIRMATION, // 0x07
CLICK_WINDOW_BUTTON, // 0x08
CLICK_WINDOW, // 0x09
CLOSE_WINDOW, // 0x0A
PLUGIN_MESSAGE, // 0x0B
EDIT_BOOK, // 0x0C
ENTITY_NBT_REQUEST, // 0x0D
INTERACT_ENTITY, // 0x0E
GENERATE_JIGSAW, // 0x0F
KEEP_ALIVE, // 0x10
LOCK_DIFFICULTY, // 0x11
PLAYER_POSITION, // 0x12
PLAYER_POSITION_AND_ROTATION, // 0x13
PLAYER_ROTATION, // 0x14
PLAYER_MOVEMENT, // 0x15
VEHICLE_MOVE, // 0x16
STEER_BOAT, // 0x17
PICK_ITEM, // 0x18
CRAFT_RECIPE_REQUEST, // 0x19
PLAYER_ABILITIES, // 0x1A
PLAYER_DIGGING, // 0x1B
ENTITY_ACTION, // 0x1C
STEER_VEHICLE, // 0x1D
RECIPE_BOOK_DATA, // 0x1E
RENAME_ITEM, // 0x1F
RESOURCE_PACK_STATUS, // 0x20
ADVANCEMENT_TAB, // 0x21
SELECT_TRADE, // 0x22
SET_BEACON_EFFECT, // 0x23
HELD_ITEM_CHANGE, // 0x24
UPDATE_COMMAND_BLOCK, // 0x25
UPDATE_COMMAND_BLOCK_MINECART, // 0x26
CREATIVE_INVENTORY_ACTION, // 0x27
UPDATE_JIGSAW_BLOCK, // 0x28
UPDATE_STRUCTURE_BLOCK, // 0x29
UPDATE_SIGN, // 0x2A
ANIMATION, // 0x2B
SPECTATE, // 0x2C
PLAYER_BLOCK_PLACEMENT, // 0x2D
USE_ITEM, // 0x2E
}

Datei anzeigen

@ -9,13 +9,13 @@ import com.github.steveice10.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.entities.Entity1_16Types; import us.myles.ViaVersion.api.entities.Entity1_16Types;
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.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.Types1_14; import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2;
@ -102,11 +102,11 @@ public class EntityPackets {
return tag; return tag;
} }
public static void register(Protocol protocol) { public static void register(Protocol1_16To1_15_2 protocol) {
MetadataRewriter1_16To1_15_2 metadataRewriter = protocol.get(MetadataRewriter1_16To1_15_2.class); MetadataRewriter1_16To1_15_2 metadataRewriter = protocol.get(MetadataRewriter1_16To1_15_2.class);
// Spawn lightning -> Spawn entity // Spawn lightning -> Spawn entity
protocol.registerOutgoing(State.PLAY, 0x02, 0x00, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY, ClientboundPackets1_16.SPAWN_ENTITY, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {
@ -131,23 +131,13 @@ public class EntityPackets {
} }
}); });
// Spawn entity metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, Entity1_16Types.EntityType.FALLING_BLOCK, Protocol1_16To1_15_2::getNewBlockStateId);
metadataRewriter.registerSpawnTrackerWithData(0x00, 0x00, Entity1_16Types.EntityType.FALLING_BLOCK, Protocol1_16To1_15_2::getNewBlockStateId); metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_MOB);
metadataRewriter.registerTracker(ClientboundPackets1_15.SPAWN_PLAYER, Entity1_16Types.EntityType.PLAYER);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST);
metadataRewriter.registerEntityDestroy(ClientboundPackets1_15.DESTROY_ENTITIES);
// Spawn mob packet protocol.registerOutgoing(ClientboundPackets1_15.RESPAWN, new PacketRemapper() {
metadataRewriter.registerTracker(0x03, 0x02);
// Spawn player packet
metadataRewriter.registerTracker(0x05, 0x04, Entity1_16Types.EntityType.PLAYER);
// Metadata
metadataRewriter.registerMetadataRewriter(0x44, 0x44, Types1_14.METADATA_LIST);
// Entity Destroy
metadataRewriter.registerEntityDestroy(0x38, 0x37);
// Respawn
protocol.registerOutgoing(State.PLAY, 0x3B, 0x3A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(DIMENSION_HANDLER); handler(DIMENSION_HANDLER);
@ -166,8 +156,7 @@ public class EntityPackets {
} }
}); });
// Join Game protocol.registerOutgoing(ClientboundPackets1_15.JOIN_GAME, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x26, 0x25, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // Entity ID map(Type.INT); // Entity ID
@ -205,8 +194,7 @@ public class EntityPackets {
} }
}); });
// Entity Properties protocol.registerOutgoing(ClientboundPackets1_15.ENTITY_PROPERTIES, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x59, 0x58, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {

Datei anzeigen

@ -11,7 +11,8 @@ 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.api.type.types.UUIDIntArrayType; import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
import java.util.UUID; import java.util.UUID;
@ -21,8 +22,7 @@ public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer); ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
// Open Window protocol.registerOutgoing(ClientboundPackets1_15.OPEN_WINDOW, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x2F, 0x2E, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -37,9 +37,7 @@ public class InventoryPackets {
}); });
} }
}); });
protocol.registerOutgoing(ClientboundPackets1_15.WINDOW_PROPERTY, new PacketRemapper() {
// Window Property
protocol.registerOutgoing(State.PLAY, 0x16, 0x15, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // Window id map(Type.UNSIGNED_BYTE); // Window id
@ -58,14 +56,10 @@ public class InventoryPackets {
} }
}); });
// Set cooldown itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN, InventoryPackets::getNewItemId);
itemRewriter.registerSetCooldown(0x18, 0x17, InventoryPackets::getNewItemId); itemRewriter.registerWindowItems(ClientboundPackets1_15.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
// Window items packet protocol.registerOutgoing(ClientboundPackets1_15.TRADE_LIST, new PacketRemapper() {
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x14);
// Trade list packet
protocol.registerOutgoing(State.PLAY, 0x28, 0x27, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {
@ -100,14 +94,10 @@ public class InventoryPackets {
} }
}); });
// Set slot packet itemRewriter.registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x17, 0x16); itemRewriter.registerEntityEquipment(ClientboundPackets1_15.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
// Entity Equipment Packet protocol.registerOutgoing(ClientboundPackets1_15.DECLARE_RECIPES, new PacketRemapper() {
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x47, 0x47);
// Declare Recipes
protocol.registerOutgoing(State.PLAY, 0x5B, 0x5A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {
@ -166,14 +156,10 @@ public class InventoryPackets {
} }
}); });
// Click window packet itemRewriter.registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x09); itemRewriter.registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
// Creative Inventory Action protocol.registerIncoming(ServerboundPackets1_16.EDIT_BOOK, new PacketRemapper() {
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x26, 0x27);
// Edit Book
protocol.registerIncoming(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM))); handler(wrapper -> InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));

Datei anzeigen

@ -12,7 +12,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.BlockRewriter; import us.myles.ViaVersion.api.rewriters.BlockRewriter;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.UUIDIntArrayType; import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type; import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
@ -26,20 +26,12 @@ public class WorldPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_16To1_15_2::getNewBlockStateId, Protocol1_16To1_15_2::getNewBlockId); BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_16To1_15_2::getNewBlockStateId, Protocol1_16To1_15_2::getNewBlockId);
// Block action blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION);
blockRewriter.registerBlockAction(0x0B, 0x0A); blockRewriter.registerBlockChange(ClientboundPackets1_15.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);
// Block Change protocol.registerOutgoing(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() {
blockRewriter.registerBlockChange(0x0C, 0x0B);
// Multi Block Change
blockRewriter.registerMultiBlockChange(0x10, 0x0F);
// Acknowledge player digging
blockRewriter.registerAcknowledgePlayerDigging(0x08, 0x07);
// Chunk Data
protocol.registerOutgoing(State.PLAY, 0x22, 0x21, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(wrapper -> { handler(wrapper -> {
@ -96,12 +88,9 @@ public class WorldPackets {
} }
}); });
// Effect blockRewriter.registerEffect(ClientboundPackets1_15.EFFECT, 1010, 2001, InventoryPackets::getNewItemId);
blockRewriter.registerEffect(0x23, 0x22, 1010, 2001, InventoryPackets::getNewItemId); blockRewriter.registerSpawnParticle(ClientboundPackets1_15.SPAWN_PARTICLE, 3, 23, 32,
WorldPackets::getNewParticleId, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
// Spawn Particle
blockRewriter.registerSpawnParticle(Type.DOUBLE, 0x24, 0x23, 3, 23, 32,
WorldPackets::getNewParticleId, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM);
} }
public static int getNewParticleId(int id) { public static int getNewParticleId(int id) {

Datei anzeigen

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

Datei anzeigen

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

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,14 +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<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);
}
public class Protocol1_9_1To1_9 extends Protocol {
@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
@ -26,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

@ -0,0 +1,83 @@
package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2;
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
public enum ClientboundPackets1_9_3 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
SOUND, // 0x48
TAB_LIST, // 0x49
COLLECT_ITEM, // 0x4A
ENTITY_TELEPORT, // 0x4B
ENTITY_PROPERTIES, // 0x4C
ENTITY_EFFECT, // 0x4D
}

Datei anzeigen

@ -12,30 +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 {
@ -67,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() {
@ -104,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
@ -123,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
@ -142,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

@ -11,6 +11,8 @@ 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.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_8.ClientboundPackets1_8;
import us.myles.ViaVersion.protocols.protocol1_8.ServerboundPackets1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.packets.*; import us.myles.ViaVersion.protocols.protocol1_9to1_8.packets.*;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.*; import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.*;
@ -19,7 +21,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 Protocol<ClientboundPackets1_8, ClientboundPackets1_9, ServerboundPackets1_8, ServerboundPackets1_9> {
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) {
@ -27,6 +29,10 @@ public class Protocol1_9To1_8 extends Protocol {
} }
}; };
public Protocol1_9To1_8() {
super(ClientboundPackets1_8.class, ClientboundPackets1_9.class, ServerboundPackets1_8.class, ServerboundPackets1_9.class);
}
public static String fixJson(String line) { public static String fixJson(String line) {
if (line == null || line.equalsIgnoreCase("null")) { if (line == null || line.equalsIgnoreCase("null")) {
line = "{\"text\":\"\"}"; line = "{\"text\":\"\"}";

Datei anzeigen

@ -0,0 +1,37 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8;
import us.myles.ViaVersion.api.protocol.ServerboundPacketType;
public enum ServerboundPackets1_9 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

@ -7,20 +7,24 @@ import us.myles.ViaVersion.api.Triple;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
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.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.Types1_8; import us.myles.ViaVersion.api.type.types.version.Types1_8;
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_8.ClientboundPackets1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
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.protocols.protocol1_9to1_8.ServerboundPackets1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class EntityPackets { public class EntityPackets {
public static final ValueTransformer<Byte, Short> toNewShort = new ValueTransformer<Byte, Short>(Type.SHORT) { public static final ValueTransformer<Byte, Short> toNewShort = new ValueTransformer<Byte, Short>(Type.SHORT) {
@ -30,9 +34,9 @@ public class EntityPackets {
} }
}; };
public static void register(final Protocol protocol) { public static void register(Protocol1_9To1_8 protocol) {
// Attach Entity Packet // Attach Entity Packet
protocol.registerOutgoing(State.PLAY, 0x1B, 0x3A, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_8.ATTACH_ENTITY, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -68,8 +72,7 @@ public class EntityPackets {
}); });
} }
}); });
// Entity Teleport Packet protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_TELEPORT, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x18, 0x4A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -101,8 +104,7 @@ public class EntityPackets {
} }
}); });
// Entity Look Move Packet protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_POSITION_AND_ROTATION, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x17, 0x26, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -117,8 +119,7 @@ public class EntityPackets {
map(Type.BOOLEAN); // 6 - On Ground map(Type.BOOLEAN); // 6 - On Ground
} }
}); });
// Entity Relative Move Packet protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_POSITION, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x15, 0x25, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -130,8 +131,7 @@ public class EntityPackets {
map(Type.BOOLEAN); // 4 - On Ground map(Type.BOOLEAN); // 4 - On Ground
} }
}); });
// Entity Equipment Packet protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_EQUIPMENT, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x04, 0x3C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -179,8 +179,7 @@ public class EntityPackets {
}); });
} }
}); });
// Entity Metadata Packet protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_METADATA, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x1C, 0x39, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -218,7 +217,7 @@ public class EntityPackets {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0); List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
if (metadataList.size() == 0) { if (metadataList.isEmpty()) {
wrapper.cancel(); wrapper.cancel();
} }
} }
@ -226,9 +225,7 @@ public class EntityPackets {
} }
}); });
// Entity Effect Packet protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_EFFECT, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x1D, 0x4C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -247,16 +244,12 @@ public class EntityPackets {
} }
}); });
protocol.cancelOutgoing(ClientboundPackets1_8.UPDATE_ENTITY_NBT);
// Update Entity NBT protocol.registerOutgoing(ClientboundPackets1_8.COMBAT_EVENT, new PacketRemapper() {
protocol.cancelOutgoing(State.PLAY, 0x49, 0x49);
// Combat Event Packet
protocol.registerOutgoing(State.PLAY, 0x42, 0x2C, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); //Event id map(Type.VAR_INT); //Event id
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
@ -270,8 +263,7 @@ public class EntityPackets {
} }
}); });
// Entity Properties Packet protocol.registerOutgoing(ClientboundPackets1_8.ENTITY_PROPERTIES, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x20, 0x4B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -327,22 +319,8 @@ public class EntityPackets {
}); });
/* Packets which do not have any field remapping or handlers */
protocol.registerOutgoing(State.PLAY, 0x1A, 0x1B); // Entity Status Packet
protocol.registerOutgoing(State.PLAY, 0x16, 0x27); // Entity Look Packet
protocol.registerOutgoing(State.PLAY, 0x14, 0x28); // Entity Packet
protocol.registerOutgoing(State.PLAY, 0x0A, 0x2F); // Use Bed Packet
protocol.registerOutgoing(State.PLAY, 0x1E, 0x31); // Remove Entity Effect Packet
protocol.registerOutgoing(State.PLAY, 0x19, 0x34); // Entity Head Look Packet
protocol.registerOutgoing(State.PLAY, 0x12, 0x3B); // Entity Velocity Packet
/* Incoming Packets */ /* Incoming Packets */
protocol.registerIncoming(ServerboundPackets1_9.ENTITY_ACTION, new PacketRemapper() {
// Entity Action Packet
protocol.registerIncoming(State.PLAY, 0x0B, 0x14, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -363,9 +341,7 @@ public class EntityPackets {
} }
}); });
protocol.registerIncoming(ServerboundPackets1_9.INTERACT_ENTITY, new PacketRemapper() {
// Use Entity Packet
protocol.registerIncoming(State.PLAY, 0x02, 0x0A, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -392,11 +368,5 @@ public class EntityPackets {
}); });
} }
}); });
/* Packets which do not have any field remapping or handlers */
protocol.registerIncoming(State.PLAY, 0x0C, 0x15); // Steer Vehicle Packet
protocol.registerIncoming(State.PLAY, 0x18, 0x1B); // Spectate Packet
} }
} }

Datei anzeigen

@ -7,17 +7,17 @@ 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.ValueCreator; import us.myles.ViaVersion.api.remapper.ValueCreator;
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_8.ClientboundPackets1_8;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter; import us.myles.ViaVersion.protocols.protocol1_9to1_8.ItemRewriter;
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.protocols.protocol1_9to1_8.ServerboundPackets1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.InventoryTracker; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.InventoryTracker;
public class InventoryPackets { public class InventoryPackets {
public static void register(Protocol protocol) { public static void register(Protocol protocol) {
// Window Property Packet protocol.registerOutgoing(ClientboundPackets1_8.WINDOW_PROPERTY, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x31, 0x15, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -56,8 +56,7 @@ public class InventoryPackets {
}); });
} }
}); });
// Window Open Packet protocol.registerOutgoing(ClientboundPackets1_8.OPEN_WINDOW, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x2D, 0x13, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -87,12 +86,9 @@ public class InventoryPackets {
}); });
} }
}); });
// Window Set Slot Packet protocol.registerOutgoing(ClientboundPackets1_8.SET_SLOT, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x2F, 0x16, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.BYTE); // 0 - Window ID map(Type.BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot ID map(Type.SHORT); // 1 - Slot ID
map(Type.ITEM); // 2 - Slot Value map(Type.ITEM); // 2 - Slot Value
@ -121,8 +117,7 @@ public class InventoryPackets {
}); });
} }
}); });
// Window Set Slots Packet protocol.registerOutgoing(ClientboundPackets1_8.WINDOW_ITEMS, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x30, 0x14, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -162,8 +157,7 @@ public class InventoryPackets {
}); });
} }
}); });
// Close Window Packet protocol.registerOutgoing(ClientboundPackets1_8.CLOSE_WINDOW, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x2E, 0x12, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -179,8 +173,7 @@ public class InventoryPackets {
} }
}); });
// Map Packet protocol.registerOutgoing(ClientboundPackets1_8.MAP_DATA, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, 0x34, 0x24, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -196,14 +189,9 @@ public class InventoryPackets {
} }
}); });
/* Packets which do not have any field remapping or handlers */
protocol.registerOutgoing(State.PLAY, 0x09, 0x37); // Held Item Change Packet
protocol.registerOutgoing(State.PLAY, 0x32, 0x11); // Confirm Transaction Packet
/* Incoming Packets */ /* Incoming Packets */
protocol.registerIncoming(ServerboundPackets1_9.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
// Creative Inventory Slot Action Packet
protocol.registerIncoming(State.PLAY, 0x10, 0x18, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -240,8 +228,7 @@ public class InventoryPackets {
} }
}); });
// Player Click Window Packet protocol.registerIncoming(ServerboundPackets1_9.CLICK_WINDOW, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x0E, 0x07, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -297,8 +284,7 @@ public class InventoryPackets {
} }
}); });
// Close Window Incoming Packet protocol.registerIncoming(ServerboundPackets1_9.CLOSE_WINDOW, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x0D, 0x08, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
@ -313,8 +299,7 @@ public class InventoryPackets {
} }
}); });
// Held Item Change Packet protocol.registerIncoming(ServerboundPackets1_9.HELD_ITEM_CHANGE, new PacketRemapper() {
protocol.registerIncoming(State.PLAY, 0x09, 0x17, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
// Blocking patch // Blocking patch
@ -330,10 +315,5 @@ public class InventoryPackets {
}); });
} }
}); });
/* Packets which do not have any field remapping or handlers */
protocol.registerIncoming(State.PLAY, 0x0F, 0x05); // Confirm Transaction Packet
protocol.registerIncoming(State.PLAY, 0x11, 0x06); // Enchant Item Packet
} }
} }

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen