3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-09-08 22:02:50 +02:00

Packet type constants and auto channel mapping

Dieser Commit ist enthalten in:
KennyTV 2020-06-05 20:30:09 +02:00
Ursprung 5293417900
Commit d7d4e58106
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
54 geänderte Dateien mit 1269 neuen und 758 gelöschten Zeilen

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,6 @@
package us.myles.ViaVersion.api.protocol;
import com.google.common.base.Preconditions;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
@ -9,6 +10,7 @@ import us.myles.ViaVersion.exception.CancelException;
import us.myles.ViaVersion.packets.Direction;
import us.myles.ViaVersion.packets.State;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -18,15 +20,89 @@ public abstract class Protocol {
private final Map<Packet, ProtocolPacket> incoming = 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 boolean hasMappingDataToLoad;
protected final Class<? extends ClientboundPacketType> oldClientboundPacketEnum;
protected final Class<? extends ClientboundPacketType> newClientboundPacketEnum;
protected final Class<? extends ServerboundPacketType> oldServerboundPacketEnum;
protected final Class<? extends ServerboundPacketType> newServerboundPacketEnum;
protected final boolean hasMappingDataToLoad;
public Protocol() {
this(false);
protected Protocol() {
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(Class<? extends ClientboundPacketType> oldClientboundPacketEnum, Class<? extends ClientboundPacketType> clientboundPacketEnum,
Class<? extends ServerboundPacketType> oldServerboundPacketEnum, Class<? extends ServerboundPacketType> 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(Class<? extends ClientboundPacketType> oldClientboundPacketEnum, Class<? extends ClientboundPacketType> clientboundPacketEnum,
Class<? extends ServerboundPacketType> oldServerboundPacketEnum, Class<? extends ServerboundPacketType> serverboundPacketEnum, boolean hasMappingDataToLoad) {
this.oldClientboundPacketEnum = oldClientboundPacketEnum;
this.newClientboundPacketEnum = clientboundPacketEnum;
this.oldServerboundPacketEnum = oldServerboundPacketEnum;
this.newServerboundPacketEnum = serverboundPacketEnum;
this.hasMappingDataToLoad = hasMappingDataToLoad;
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());
if (mappedPacket == null) continue; // Packet doesn't exist on new client
int oldId = packet.ordinal();
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());
if (mappedPacket == null) continue; // Packet doesn't exist on old server
int oldId = mappedPacket.ordinal();
int newId = packet.ordinal();
if (!hasRegisteredIncoming(State.PLAY, newId)) {
registerIncoming(State.PLAY, oldId, newId);
}
}
}
/**
@ -155,16 +231,6 @@ public abstract class Protocol {
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) {
registerOutgoing(state, oldPacketID, newPacketID, new PacketRemapper() {
@Override
@ -178,6 +244,118 @@ public abstract class Protocol {
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 packet type the server sends
* @param packetRemapper remapper
*/
public void registerOutgoing(ClientboundPacketType packetType, PacketRemapper packetRemapper) {
Preconditions.checkArgument(packetType.getClass() == oldClientboundPacketEnum);
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 oldPacketType packet type the server sends
* @param newPacketType new packet type
* @param packetRemapper remapper
*/
public void registerOutgoing(ClientboundPacketType oldPacketType, ClientboundPacketType newPacketType, PacketRemapper packetRemapper) {
Preconditions.checkArgument(oldPacketType.getClass() == oldClientboundPacketEnum);
Preconditions.checkArgument(newPacketType == null || newPacketType.getClass() == newClientboundPacketEnum);
registerOutgoing(State.PLAY, oldPacketType.ordinal(), newPacketType != null ? newPacketType.ordinal() : -1, packetRemapper);
}
public void registerOutgoing(ClientboundPacketType oldPacketType, ClientboundPacketType newPacketType) {
registerOutgoing(oldPacketType, newPacketType, null);
}
public void cancelOutgoing(ClientboundPacketType packetType) {
Preconditions.checkArgument(packetType.getClass() == oldClientboundPacketEnum);
cancelOutgoing(State.PLAY, packetType.ordinal(), packetType.ordinal());
}
/**
* Registers an incoming protocol and automatically maps it to the server's id.
*
* @param packetType packet type the client sends
* @param packetRemapper remapper
*/
public void registerIncoming(ServerboundPacketType packetType, 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 oldPacketType packet type for the server
* @param newPacketType packet type the client sends
* @param packetRemapper remapper
*/
public void registerIncoming(ServerboundPacketType oldPacketType, ServerboundPacketType newPacketType, PacketRemapper packetRemapper) {
Preconditions.checkArgument(oldPacketType == null || oldPacketType.getClass() == oldServerboundPacketEnum);
Preconditions.checkArgument(newPacketType.getClass() == newServerboundPacketEnum);
registerIncoming(State.PLAY, oldPacketType != null ? oldPacketType.ordinal() : -1, newPacketType.ordinal(), packetRemapper);
}
public void cancelIncoming(ServerboundPacketType 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() {
return hasMappingDataToLoad;
}

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

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

Datei anzeigen

@ -1,7 +1,9 @@
package us.myles.ViaVersion.api.rewriters;
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.ServerboundPacketType;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
@ -19,8 +21,8 @@ public class ItemRewriter {
this.toServer = toServer;
}
public void registerWindowItems(Type<Item[]> type, int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerWindowItems(Type<Item[]> type, ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -31,8 +33,8 @@ public class ItemRewriter {
});
}
public void registerSetSlot(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerSetSlot(Type<Item> type, ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.BYTE); // 0 - Window ID
@ -44,8 +46,8 @@ public class ItemRewriter {
});
}
public void registerEntityEquipment(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerEntityEquipment(Type<Item> type, ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -57,8 +59,8 @@ public class ItemRewriter {
});
}
public void registerCreativeInvAction(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerCreativeInvAction(Type<Item> type, ServerboundPacketType packetType) {
protocol.registerIncoming(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.SHORT); // 0 - Slot
@ -69,8 +71,8 @@ public class ItemRewriter {
});
}
public void registerClickWindow(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerClickWindow(Type<Item> type, ServerboundPacketType packetType) {
protocol.registerIncoming(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -85,8 +87,8 @@ public class ItemRewriter {
});
}
public void registerSetCooldown(int oldPacketId, int newPacketId, IdRewriteFunction itemIDRewriteFunction) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerSetCooldown(ClientboundPacketType packetType, IdRewriteFunction itemIDRewriteFunction) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
@ -115,6 +117,77 @@ public class ItemRewriter {
return wrapper -> toServer.rewrite(wrapper.get(type, 0));
}
@Deprecated
public void registerWindowItems(Type<Item[]> type, int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(type); // 1 - Window Values
handler(itemArrayHandler(type));
}
});
}
@Deprecated
public void registerSetSlot(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot ID
map(type); // 2 - Slot Value
handler(itemToClientHandler(type));
}
});
}
@Deprecated
public void registerEntityEquipment(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
map(Type.VAR_INT); // 1 - Slot ID
map(type); // 2 - Item
handler(itemToClientHandler(type));
}
});
}
@Deprecated
public void registerCreativeInvAction(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.SHORT); // 0 - Slot
map(type); // 1 - Clicked Item
handler(itemToServerHandler(type));
}
});
}
@Deprecated
public void registerClickWindow(Type<Item> type, int oldPacketId, int newPacketId) {
protocol.registerIncoming(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot
map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode
map(type); // 5 - Clicked Item
handler(itemToServerHandler(type));
}
});
}
@FunctionalInterface
public interface RewriteFunction {

Datei anzeigen

@ -4,6 +4,7 @@ import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.EntityType;
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.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
@ -12,7 +13,11 @@ 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 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;
public abstract class MetadataRewriter {
@ -54,8 +59,8 @@ public abstract class MetadataRewriter {
}
}
public void registerJoinGame(int oldPacketId, int newPacketId, EntityType playerType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerJoinGame(ClientboundPacketType packetType, EntityType playerType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Entity ID
@ -74,8 +79,8 @@ public abstract class MetadataRewriter {
});
}
public void registerRespawn(int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerRespawn(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT);
@ -88,8 +93,8 @@ public abstract class MetadataRewriter {
});
}
public void registerTracker(int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerTracker(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
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) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerSpawnTrackerWithData(ClientboundPacketType packetType, EntityType fallingBlockType, IdRewriteFunction itemRewriter) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id
@ -125,8 +130,8 @@ public abstract class MetadataRewriter {
});
}
public void registerTracker(int oldPacketId, int newPacketId, EntityType entityType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerTracker(ClientboundPacketType packetType, EntityType entityType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -138,8 +143,8 @@ public abstract class MetadataRewriter {
});
}
public void registerEntityDestroy(int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerEntityDestroy(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
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) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
public void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
protocol.registerOutgoing(packetType, new PacketRemapper() {
@Override
public void registerMap() {
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) {
registerMetadataRewriter(oldPacketId, newPacketId, null, metaType);
public void registerMetadataRewriter(ClientboundPacketType packetType, Type<List<Metadata>> metaType) {
registerMetadataRewriter(packetType, null, metaType);
}
public <T extends Enum<T> & EntityType> void mapTypes(EntityType[] oldTypes, Class<T> newTypeClass) {
@ -185,7 +190,7 @@ public abstract class MetadataRewriter {
} catch (IllegalArgumentException notFound) {
if (!typeMapping.containsKey(oldType.getId())) {
Via.getPlatform().getLogger().warning("Could not find new entity type for " + oldType + "! " +
"Old type: " + oldType.getClass().getSimpleName() + " New type: " + newTypeClass.getSimpleName());
"Old type: " + oldType.getClass().getSimpleName() + " New type: " + newTypeClass.getSimpleName());
}
}
}
@ -200,6 +205,78 @@ public abstract class MetadataRewriter {
return getTrackerAndRewriter(null);
}
@Deprecated
public void registerJoinGame(int oldPacketId, int newPacketId, EntityType playerType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Entity ID
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
map(Type.INT); // 2 - Dimension
handler(wrapper -> {
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 1);
clientChunks.setEnvironment(dimensionId);
if (playerType != null) {
wrapper.user().get(entityTrackerClass).addEntity(wrapper.get(Type.INT, 0), playerType);
}
});
}
});
}
@Deprecated
public void registerRespawn(int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT);
handler(wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
int dimensionId = wrapper.get(Type.INT, 0);
clientWorld.setEnvironment(dimensionId);
});
}
});
}
@Deprecated
public void registerEntityDestroy(int oldPacketId, int newPacketId) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entity ids
handler(wrapper -> {
EntityTracker entityTracker = wrapper.user().get(entityTrackerClass);
for (int entity : wrapper.get(Type.VAR_INT_ARRAY_PRIMITIVE, 0)) {
entityTracker.removeEntity(entity);
}
});
}
});
}
@Deprecated
public void registerMetadataRewriter(int oldPacketId, int newPacketId, Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
protocol.registerOutgoing(State.PLAY, oldPacketId, newPacketId, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
if (oldMetaType != null) {
map(oldMetaType, newMetaType);
} else {
map(newMetaType);
}
handler(wrapper -> {
int entityId = wrapper.get(Type.VAR_INT, 0);
List<Metadata> metadata = wrapper.get(newMetaType, 0);
handleMetadata(entityId, metadata, wrapper.user());
});
}
});
}
// ---------------------------------------------------------------------------
// Sub 1.14.1 methods

Datei anzeigen

@ -1,5 +1,6 @@
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.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
@ -17,7 +18,15 @@ public class SoundRewriter {
// The same for entity sound effect
public void registerSound(int oldId, int newId) {
protocol.registerOutgoing(State.PLAY, oldId, newId, new PacketRemapper() {
protocol.registerOutgoing(State.PLAY, oldId, newId, getRemapper());
}
public void registerSound(ClientboundPacketType packetType) {
protocol.registerOutgoing(packetType, getRemapper());
}
protected PacketRemapper getRemapper() {
return new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Sound Id
@ -31,6 +40,6 @@ public class SoundRewriter {
}
});
}
});
};
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_11_1to1_11;
import us.myles.ViaVersion.api.protocol.Protocol;
public class Protocol1_11_1To1_11 extends Protocol {
@Override
protected void registerPackets() {
// Only had metadata changes, see wiki.vg for full info.

Datei anzeigen

@ -106,7 +106,7 @@ public class Protocol1_11To1_10 extends Protocol {
});
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x39, 0x39, Types1_9.METADATA_LIST);
metadataRewriter.registerMetadataRewriter(0x39, 0x39, null, Types1_9.METADATA_LIST);
// Entity teleport
registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() {

Datei anzeigen

@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
public class Protocol1_12_1To1_12 extends Protocol {
@Override
protected void registerPackets() {
registerOutgoing(State.PLAY, -1, 0x2B); // TODO new packet?

Datei anzeigen

@ -6,6 +6,7 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
public class Protocol1_12_2To1_12_1 extends Protocol {
@Override
protected void registerPackets() {
// Outgoing

Datei anzeigen

@ -168,7 +168,7 @@ public class Protocol1_12To1_11_1 extends Protocol {
registerOutgoing(State.PLAY, 0x38, 0x3a);
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x39, 0x3b, Types1_12.METADATA_LIST);
metadataRewriter.registerMetadataRewriter(0x39, 0x3b, null, Types1_12.METADATA_LIST);
registerOutgoing(State.PLAY, 0x3a, 0x3c);
registerOutgoing(State.PLAY, 0x3b, 0x3d);

Datei anzeigen

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

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.entities.Entity1_13Types;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
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.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;
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);
//spawn entity
protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id
@ -52,8 +50,7 @@ public class EntityPackets {
}
});
// Spawn mob packet
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -74,8 +71,7 @@ public class EntityPackets {
}
});
// Spawn player packet
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -91,10 +87,7 @@ public class EntityPackets {
}
});
// Destroy entities
metadataRewriter.registerEntityDestroy(0x35, 0x35);
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x3F, 0x3F, Types1_13.METADATA_LIST);
metadataRewriter.registerEntityDestroy(ClientboundPackets1_13.DESTROY_ENTITIES);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, 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.rewriters.ItemRewriter;
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 static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
// Set cooldown
itemRewriter.registerSetCooldown(0x18, 0x18, InventoryPackets::getNewItemId);
itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets::getNewItemId);
itemRewriter.registerSetSlot(Type.FLAT_ITEM, ClientboundPackets1_13.SET_SLOT);
itemRewriter.registerWindowItems(Type.FLAT_ITEM_ARRAY, ClientboundPackets1_13.WINDOW_ITEMS);
// Set slot packet
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() {
protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.STRING); // Channel
@ -58,11 +53,9 @@ public class InventoryPackets {
}
});
// Entity Equipment Packet
itemRewriter.registerEntityEquipment(Type.FLAT_ITEM, 0x42, 0x42);
itemRewriter.registerEntityEquipment(Type.FLAT_ITEM, ClientboundPackets1_13.ENTITY_EQUIPMENT);
// Declare Recipes
protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -77,8 +70,8 @@ public class InventoryPackets {
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
for (int i1 = 0; i1 < ingredientsNo; i1++) {
Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT);
for (int i2 = 0; i2 < items.length; i2++) {
InventoryPackets.toClient(items[i2]);
for (Item item : items) {
InventoryPackets.toClient(item);
}
}
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM)); // Result
@ -87,8 +80,8 @@ public class InventoryPackets {
wrapper.passthrough(Type.STRING); // Group
for (int i1 = 0; i1 < ingredientsNo; i1++) {
Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT);
for (int i2 = 0; i2 < items.length; i2++) {
InventoryPackets.toClient(items[i2]);
for (Item item : items) {
InventoryPackets.toClient(item);
}
}
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM)); // Result
@ -96,8 +89,8 @@ public class InventoryPackets {
wrapper.passthrough(Type.STRING); // Group
// Ingredient start
Item[] items = wrapper.passthrough(Type.FLAT_ITEM_ARRAY_VAR_INT);
for (int i2 = 0; i2 < items.length; i2++) {
InventoryPackets.toClient(items[i2]);
for (Item item : items) {
InventoryPackets.toClient(item);
}
// Ingredient end
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_ITEM));
@ -110,12 +103,8 @@ public class InventoryPackets {
}
});
// Click window packet
itemRewriter.registerClickWindow(Type.FLAT_ITEM, 0x08, 0x08);
// Creative Inventory Action
itemRewriter.registerCreativeInvAction(Type.FLAT_ITEM, 0x24, 0x24);
itemRewriter.registerClickWindow(Type.FLAT_ITEM, ServerboundPackets1_13.CLICK_WINDOW);
itemRewriter.registerCreativeInvAction(Type.FLAT_ITEM, ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION);
}
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.rewriters.BlockRewriter;
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_13to1_12_2.ClientboundPackets1_13;
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;
@ -18,8 +18,7 @@ public class WorldPackets {
public static void register(Protocol protocol) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION, Protocol1_13_1To1_13::getNewBlockStateId, Protocol1_13_1To1_13::getNewBlockId);
//Chunk
protocol.registerOutgoing(State.PLAY, 0x22, 0x22, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -39,20 +38,12 @@ public class WorldPackets {
}
});
// Block action
blockRewriter.registerBlockAction(0x0A, 0x0A);
blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001, InventoryPackets::getNewItemId);
// Block Change
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() {
protocol.registerOutgoing(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Entity ID
@ -71,8 +62,7 @@ public class WorldPackets {
}
});
//respawn
protocol.registerOutgoing(State.PLAY, 0x38, 0x38, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.RESPAWN, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Dimension ID
@ -87,7 +77,6 @@ public class WorldPackets {
}
});
//spawn particle
blockRewriter.registerSpawnParticle(Type.FLOAT, 0x24, 0x24, 3, 20, 27, InventoryPackets::toClient, Type.FLAT_ITEM);
blockRewriter.registerSpawnParticle(Type.FLOAT, ClientboundPackets1_13.SPAWN_PARTICLE, 3, 20, 27, InventoryPackets::toClient, Type.FLAT_ITEM);
}
}

Datei anzeigen

@ -6,29 +6,32 @@ import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
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.InventoryPackets;
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 Protocol1_13_2To1_13_1() {
super(ClientboundPackets1_13.class, ClientboundPackets1_13.class, ServerboundPackets1_13.class, ServerboundPackets1_13.class);
}
@Override
protected void registerPackets() {
InventoryPackets.register(this);
WorldPackets.register(this);
EntityPackets.register(this);
//Edit Book
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
registerIncoming(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM);
}
});
// Advancements
registerOutgoing(State.PLAY, 0x51, 0x51, new PacketRemapper() {
registerOutgoing(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {

Datei anzeigen

@ -1,6 +1,5 @@
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.types.MetaType1_13_2;
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.types.version.Types1_13;
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 static void register(Protocol protocol) {
final PacketHandler metaTypeHandler = new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
metadata.setMetaType(MetaType1_13_2.byId(metadata.getMetaType().getTypeID()));
}
final PacketHandler metaTypeHandler = wrapper -> {
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
metadata.setMetaType(MetaType1_13_2.byId(metadata.getMetaType().getTypeID()));
}
};
// Spawn mob packet
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -45,8 +40,7 @@ public class EntityPackets {
}
});
// Spawn player packet
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -62,9 +56,7 @@ public class EntityPackets {
}
});
// Metadata packet
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_METADATA, new PacketRemapper() {
@Override
public void registerMap() {
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.PacketRemapper;
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 static void register(Protocol protocol) {
// Set slot packet
protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
@Override
public void registerMap() {
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
}
});
// Window items packet
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.WINDOW_ITEMS, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -29,8 +27,7 @@ public class InventoryPackets {
}
});
// Plugin message
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.STRING); // Channel
@ -63,8 +60,7 @@ public class InventoryPackets {
}
});
// Entity Equipment Packet
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -73,8 +69,7 @@ public class InventoryPackets {
}
});
// Declare Recipes
protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -113,28 +108,23 @@ public class InventoryPackets {
}
});
// Click window packet
protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot
map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item
}
}
);
// Creative Inventory Action
protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.SHORT); // 0 - Slot
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item
}
}
);
protocol.registerIncoming(ServerboundPackets1_13.CLICK_WINDOW, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.SHORT); // 1 - Slot
map(Type.BYTE); // 2 - Button
map(Type.SHORT); // 3 - Action number
map(Type.VAR_INT); // 4 - Mode
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item
}
});
protocol.registerIncoming(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.SHORT); // 0 - Slot
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.PacketRemapper;
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 static void register(Protocol protocol) {
//spawn particle
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
@Override
public void registerMap() {
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

@ -11,6 +11,7 @@ import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.item.Item;
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.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueCreator;

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,18 +2,19 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets;
import us.myles.ViaVersion.api.PacketWrapper;
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.PacketRemapper;
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_13;
import us.myles.ViaVersion.packets.State;
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.storage.EntityTracker1_13;
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);
// Spawn Object

Datei anzeigen

@ -5,9 +5,15 @@ 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.packets.EntityPackets;
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 Protocol1_14_1To1_14() {
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
}
@Override
protected void registerPackets() {
new MetadataRewriter1_14_1To1_14(this);

Datei anzeigen

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

Datei anzeigen

@ -1,17 +1,10 @@
package us.myles.ViaVersion.protocols.protocol1_14_2to1_14_1;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
public class Protocol1_14_2To1_14_1 extends Protocol {
@Override
protected void registerPackets() {
}
@Override
public void init(UserConnection userConnection) {
}
@Override
protected void registerPackets() {
}
}

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.rewriters.SoundRewriter;
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.metadata.MetadataRewriter1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.EntityPackets;
@ -21,7 +22,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_14To1_13_2 extends Protocol {
public Protocol1_14To1_13_2() {
super(true);
super(ClientboundPackets1_13.class, ClientboundPackets1_14.class, ServerboundPackets1_13.class, ServerboundPackets1_14.class, true);
}
@Override
@ -33,61 +34,9 @@ public class Protocol1_14To1_13_2 extends Protocol {
WorldPackets.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(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() {
registerOutgoing(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -128,10 +77,7 @@ public class Protocol1_14To1_13_2 extends Protocol {
}
});
registerOutgoing(State.PLAY, 0x52, 0x58);
registerOutgoing(State.PLAY, 0x53, 0x59);
registerOutgoing(State.PLAY, 0x55, 0x5B, new PacketRemapper() {
registerOutgoing(ClientboundPackets1_13.TAGS, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -194,54 +140,12 @@ public class Protocol1_14To1_13_2 extends Protocol {
}
});
//Set Difficulty packet added in 19w11a
cancelIncoming(State.PLAY, 0x02);
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
cancelIncoming(State.PLAY, 0x10);
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
cancelIncoming(State.PLAY, 0x27);
registerIncoming(State.PLAY, 0x27, 0x2A);
registerIncoming(State.PLAY, 0x28, 0x2B);
registerIncoming(State.PLAY, 0x2A, 0x2D);
// Set Difficulty packet added in 19w11a
cancelIncoming(ServerboundPackets1_14.SET_DIFFICULTY);
// Lock Difficulty packet added in 19w11a
cancelIncoming(ServerboundPackets1_14.LOCK_DIFFICULTY);
// Unknown packet added in 19w13a
cancelIncoming(ServerboundPackets1_14.UPDATE_JIGSAW_BLOCK);
}
@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.metadata.Metadata;
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.PacketRemapper;
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_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.data.EntityTypeRewriter;
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 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);
// Spawn entity
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id
@ -104,8 +103,7 @@ public class EntityPackets {
}
});
// Spawn mob packet
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -126,8 +124,7 @@ public class EntityPackets {
}
});
// Spawn painting
protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PAINTING, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
@ -138,8 +135,7 @@ public class EntityPackets {
}
});
// Spawn player packet
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -155,8 +151,7 @@ public class EntityPackets {
}
});
// Animation
protocol.registerOutgoing(State.PLAY, 0x06, 0x06, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.ENTITY_ANIMATION, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
@ -184,8 +179,7 @@ public class EntityPackets {
}
});
// Use bed
protocol.registerOutgoing(State.PLAY, 0x33, 0x43, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.USE_BED, ClientboundPackets1_14.ENTITY_METADATA, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
@ -208,10 +202,7 @@ public class EntityPackets {
}
});
// Destroy entities
metadataRewriter.registerEntityDestroy(0x35, 0x37);
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x3F, 0x43, Types1_13_2.METADATA_LIST, Types1_14.METADATA_LIST);
metadataRewriter.registerEntityDestroy(ClientboundPackets1_13.DESTROY_ENTITIES);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_13.ENTITY_METADATA, 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;
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 us.myles.ViaVersion.api.PacketWrapper;
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.rewriters.ItemRewriter;
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.ClientboundPackets1_13;
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.ServerboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
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) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
// Set cooldown
itemRewriter.registerSetCooldown(0x18, 0x17, InventoryPackets::getNewItemId);
itemRewriter.registerSetCooldown(ClientboundPackets1_13.COOLDOWN, InventoryPackets::getNewItemId);
// Open Inventory
protocol.registerOutgoing(State.PLAY, 0x14, -1, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.OPEN_WINDOW, null, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -105,14 +108,10 @@ public class InventoryPackets {
}
});
// Window items packet
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x14);
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, ClientboundPackets1_13.WINDOW_ITEMS);
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, ClientboundPackets1_13.SET_SLOT);
// Set slot packet
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x17, 0x16);
// Plugin message
protocol.registerOutgoing(State.PLAY, 0x19, 0x18, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.STRING); // Channel
@ -164,11 +163,9 @@ public class InventoryPackets {
}
});
// Entity Equipment Packet
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x42, 0x46);
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, ClientboundPackets1_13.ENTITY_EQUIPMENT);
// Declare Recipes
protocol.registerOutgoing(State.PLAY, 0x54, 0x5A, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -218,11 +215,9 @@ public class InventoryPackets {
});
// Click window packet
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x08, 0x09);
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, ServerboundPackets1_14.CLICK_WINDOW);
// Select trade
protocol.registerIncoming(State.PLAY, 0x1F, 0x21, new PacketRemapper() {
protocol.registerIncoming(ServerboundPackets1_14.SELECT_TRADE, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -244,11 +239,9 @@ public class InventoryPackets {
}
});
// Creative Inventory Action
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x24, 0x26);
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION);
}
public static void toClient(Item item) {
if (item == null) return;
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.PacketRemapper;
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 static void register(Protocol protocol) {
// Open Sign Editor
protocol.registerOutgoing(State.PLAY, 0x2C, 0x2F, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.OPEN_SIGN_EDITOR, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION, Type.POSITION1_14);
}
});
// Query Block NBT
protocol.registerIncoming(State.PLAY, 0x01, 0x01, new PacketRemapper() {
protocol.registerIncoming(ServerboundPackets1_14.QUERY_BLOCK_NBT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
@ -34,14 +32,13 @@ public class PlayerPackets {
}
});
// Edit Book
protocol.registerIncoming(State.PLAY, 0x0B, 0x0C, new PacketRemapper() {
protocol.registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
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);
// 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(State.PLAY, 0x18, 0x1A, new PacketRemapper() {
protocol.registerIncoming(ServerboundPackets1_14.PLAYER_DIGGING, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
@ -73,8 +69,7 @@ public class PlayerPackets {
}
});
// Recipe Book Data
protocol.registerIncoming(State.PLAY, 0x1B, 0x1D, new PacketRemapper() {
protocol.registerIncoming(ServerboundPackets1_14.RECIPE_BOOK_DATA, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
@ -101,32 +96,26 @@ public class PlayerPackets {
}
});
// Update Command Block
protocol.registerIncoming(State.PLAY, 0x22, 0x24, new PacketRemapper() {
protocol.registerIncoming(ServerboundPackets1_14.UPDATE_COMMAND_BLOCK, 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
public void registerMap() {
map(Type.POSITION1_14, Type.POSITION);
}
});
// Update Structure Block
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() {
protocol.registerIncoming(ServerboundPackets1_14.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
@Override
public void registerMap() {
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.rewriters.BlockRewriter;
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_14to1_13_2.Protocol1_14To1_13_2;
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) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, null, Protocol1_14To1_13_2::getNewBlockStateId, Protocol1_14To1_13_2::getNewBlockId);
// Block Break Animation
protocol.registerOutgoing(State.PLAY, 0x08, 0x08, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
@ -50,17 +49,13 @@ public class WorldPackets {
map(Type.BYTE);
}
});
// Update Block Entity
protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION, Type.POSITION1_14);
}
});
// Block Action
protocol.registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_ACTION, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION, Type.POSITION1_14); // Location
@ -75,9 +70,7 @@ public class WorldPackets {
});
}
});
// Block Change
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.BLOCK_CHANGE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION, Type.POSITION1_14);
@ -93,8 +86,7 @@ public class WorldPackets {
}
});
// Server Difficulty
protocol.registerOutgoing(State.PLAY, 0x0D, 0x0D, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SERVER_DIFFICULTY, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE);
@ -107,11 +99,9 @@ public class WorldPackets {
}
});
// Multi Block Change
blockRewriter.registerMultiBlockChange(0x0F, 0x0F);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
// Explosion
protocol.registerOutgoing(State.PLAY, 0x1E, 0x1C, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.EXPLOSION, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.FLOAT); // X
@ -134,8 +124,7 @@ public class WorldPackets {
}
});
// Chunk
protocol.registerOutgoing(State.PLAY, 0x22, 0x21, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -264,8 +253,7 @@ public class WorldPackets {
}
});
// Effect
protocol.registerOutgoing(State.PLAY, 0x23, 0x22, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Effect Id
@ -286,12 +274,10 @@ public class WorldPackets {
}
});
// Spawn particle
blockRewriter.registerSpawnParticle(Type.FLOAT, 0x24, 0x23, 3, 20, 27,
blockRewriter.registerSpawnParticle(Type.FLOAT, ClientboundPackets1_13.SPAWN_PARTICLE, 3, 20, 27,
MetadataRewriter1_14To1_13_2::getNewParticleId, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM);
// Join Game
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Entity ID
@ -334,8 +320,7 @@ public class WorldPackets {
}
});
// Map Data
protocol.registerOutgoing(State.PLAY, 0x26, 0x26, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.MAP_DATA, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
@ -350,8 +335,7 @@ public class WorldPackets {
}
});
// Respawn
protocol.registerOutgoing(State.PLAY, 0x38, 0x3A, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.RESPAWN, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // 0 - Dimension ID
@ -379,8 +363,7 @@ public class WorldPackets {
}
});
// Spawn Position
protocol.registerOutgoing(State.PLAY, 0x49, 0x4D, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_13.SPAWN_POSITION, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION, Type.POSITION1_14);

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.TagType;
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.metadata.MetadataRewriter1_15To1_14_4;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.EntityPackets;
@ -25,7 +26,7 @@ public class Protocol1_15To1_14_4 extends Protocol {
private TagRewriter tagRewriter;
public Protocol1_15To1_14_4() {
super(true);
super(ClientboundPackets1_14.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class, true);
}
@Override
@ -38,24 +39,17 @@ public class Protocol1_15To1_14_4 extends Protocol {
InventoryPackets.register(this);
SoundRewriter soundRewriter = new SoundRewriter(this, id -> MappingData.soundMappings.getNewId(id));
soundRewriter.registerSound(0x50, 0x51); // Entity Sound Effect (added somewhere in 1.14)
soundRewriter.registerSound(0x51, 0x52);
soundRewriter.registerSound(ClientboundPackets1_14.ENTITY_SOUND); // Entity Sound Effect (added somewhere in 1.14)
soundRewriter.registerSound(ClientboundPackets1_14.SOUND);
// Edit Book
registerIncoming(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
registerIncoming(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
}
});
handler(wrapper -> InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
}
});
// Advancements
registerOutgoing(State.PLAY, 0x57, 0x58, new PacketRemapper() {
registerOutgoing(ClientboundPackets1_14.ADVANCEMENTS, new PacketRemapper() {
@Override
public void registerMap() {
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.register(0x5B, 0x5C);
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);
tagRewriter.register(ClientboundPackets1_14.TAGS);
}
@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.entities.Entity1_15Types;
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.type.Type;
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.metadata.MetadataRewriter1_15To1_14_4;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15;
@ -16,14 +15,12 @@ import java.util.List;
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);
// Spawn entity
metadataRewriter.registerSpawnTrackerWithData(0x00, 0x00, Entity1_15Types.EntityType.FALLING_BLOCK, Protocol1_15To1_14_4::getNewBlockStateId);
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_14.SPAWN_ENTITY, Entity1_15Types.EntityType.FALLING_BLOCK, Protocol1_15To1_14_4::getNewBlockStateId);
// Spawn mob packet
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -52,8 +49,7 @@ public class EntityPackets {
}
});
// Spawn player packet
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
@ -79,10 +75,8 @@ public class EntityPackets {
}
});
// Metadata packet
metadataRewriter.registerMetadataRewriter(0x43, 0x44, Types1_14.METADATA_LIST);
metadataRewriter.registerEntityDestroy(0x37, 0x38);
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_14.ENTITY_METADATA, Types1_14.METADATA_LIST);
metadataRewriter.registerEntityDestroy(ClientboundPackets1_14.DESTROY_ENTITIES);
}
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.rewriters.ItemRewriter;
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;
public class InventoryPackets {
@ -16,14 +17,10 @@ public class InventoryPackets {
public static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
// Set cooldown
itemRewriter.registerSetCooldown(0x17, 0x18, InventoryPackets::getNewItemId);
itemRewriter.registerSetCooldown(ClientboundPackets1_14.COOLDOWN, InventoryPackets::getNewItemId);
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, ClientboundPackets1_14.WINDOW_ITEMS);
// Window items packet
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x14, 0x15);
// Trade list packet
protocol.registerOutgoing(State.PLAY, 0x27, 0x28, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -62,14 +59,10 @@ public class InventoryPackets {
}
});
// Set slot packet
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x16, 0x17);
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, ClientboundPackets1_14.SET_SLOT);
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, ClientboundPackets1_14.ENTITY_EQUIPMENT);
// Entity Equipment Packet
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x46, 0x47);
// Declare Recipes
protocol.registerOutgoing(State.PLAY, 0x5A, 0x5B, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_14.DECLARE_RECIPES, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -135,11 +128,8 @@ public class InventoryPackets {
}
});
// Click window packet
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x09);
// Creative Inventory Action
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x26, 0x26);
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, ServerboundPackets1_14.CLICK_WINDOW);
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, ServerboundPackets1_14.CREATIVE_INVENTORY_ACTION);
}
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.remapper.PacketRemapper;
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_9_3to1_9_1_2.storage.ClientWorld;
public class PlayerPackets {
public static void register(Protocol protocol) {
// Respawn
protocol.registerOutgoing(State.PLAY, 0x3A, 0x3B, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_14.RESPAWN, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT);
@ -28,8 +27,7 @@ public class PlayerPackets {
}
});
// Join Game
protocol.registerOutgoing(State.PLAY, 0x25, 0x26, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_14.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {
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.rewriters.BlockRewriter;
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_15to1_14_4.Protocol1_15To1_14_4;
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) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_15To1_14_4::getNewBlockStateId, Protocol1_15To1_14_4::getNewBlockId);
// Block action
blockRewriter.registerBlockAction(0x0A, 0x0B);
blockRewriter.registerBlockAction(ClientboundPackets1_14.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_14.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_14.MULTI_BLOCK_CHANGE);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
// Block Change
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() {
protocol.registerOutgoing(ClientboundPackets1_14.CHUNK_DATA, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@ -78,11 +70,8 @@ public class WorldPackets {
}
});
// Effect
blockRewriter.registerEffect(0x22, 0x23, 1010, 2001, InventoryPackets::getNewItemId);
// Spawn Particle
protocol.registerOutgoing(State.PLAY, 0x23, 0x24, new PacketRemapper() {
blockRewriter.registerEffect(ClientboundPackets1_14.EFFECT, 1010, 2001, InventoryPackets::getNewItemId);
protocol.registerOutgoing(ClientboundPackets1_14.SPAWN_PARTICLE, new PacketRemapper() {
@Override
public void registerMap() {
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.type.Type;
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.metadata.MetadataRewriter1_16To1_15_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
@ -25,7 +27,7 @@ public class Protocol1_16To1_15_2 extends Protocol {
private TagRewriter tagRewriter;
public Protocol1_16To1_15_2() {
super(true);
super(ClientboundPackets1_15.class, ClientboundPackets1_16.class, ServerboundPackets1_14.class, ServerboundPackets1_16.class, true);
}
@Override
@ -37,7 +39,7 @@ public class Protocol1_16To1_15_2 extends Protocol {
InventoryPackets.register(this);
tagRewriter = new TagRewriter(this, Protocol1_16To1_15_2::getNewBlockId, InventoryPackets::getNewItemId, metadataRewriter::getNewEntityId);
tagRewriter.register(0x5C, 0x5B);
tagRewriter.register(ClientboundPackets1_15.TAGS);
// Login Success
registerOutgoing(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
@ -51,8 +53,7 @@ public class Protocol1_16To1_15_2 extends Protocol {
}
});
// Chat Message
registerOutgoing(State.PLAY, 0x0F, 0x0E, new PacketRemapper() {
registerOutgoing(ClientboundPackets1_15.CHAT_MESSAGE, new PacketRemapper() {
@Override
public void registerMap() {
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.registerSound(0x51, 0x50);
soundRewriter.registerSound(0x52, 0x51);
soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
// Advancements
registerOutgoing(State.PLAY, 0x58, 0x57, new PacketRemapper() {
registerOutgoing(ClientboundPackets1_15.ADVANCEMENTS, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
@ -104,91 +104,8 @@ public class Protocol1_16To1_15_2 extends Protocol {
}
});
registerOutgoing(State.PLAY, 0x04, 0x03);
registerOutgoing(State.PLAY, 0x06, 0x05);
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);
cancelIncoming(ServerboundPackets1_16.GENERATE_JIGSAW);
cancelIncoming(ServerboundPackets1_16.UPDATE_JIGSAW_BLOCK);
}
@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.Via;
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.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type;
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.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata.MetadataRewriter1_16To1_15_2;
@ -102,11 +102,11 @@ public class EntityPackets {
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);
// 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
public void registerMap() {
handler(wrapper -> {
@ -131,23 +131,13 @@ public class EntityPackets {
}
});
// Spawn entity
metadataRewriter.registerSpawnTrackerWithData(0x00, 0x00, Entity1_16Types.EntityType.FALLING_BLOCK, Protocol1_16To1_15_2::getNewBlockStateId);
metadataRewriter.registerSpawnTrackerWithData(ClientboundPackets1_15.SPAWN_ENTITY, 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
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() {
protocol.registerOutgoing(ClientboundPackets1_15.RESPAWN, new PacketRemapper() {
@Override
public void registerMap() {
handler(DIMENSION_HANDLER);
@ -166,8 +156,7 @@ public class EntityPackets {
}
});
// Join Game
protocol.registerOutgoing(State.PLAY, 0x26, 0x25, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_15.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Entity ID
@ -205,8 +194,7 @@ public class EntityPackets {
}
});
// Entity Properties
protocol.registerOutgoing(State.PLAY, 0x59, 0x58, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_15.ENTITY_PROPERTIES, new PacketRemapper() {
@Override
public void registerMap() {
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.type.Type;
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 java.util.UUID;
@ -21,8 +22,7 @@ public class InventoryPackets {
public static void register(Protocol protocol) {
ItemRewriter itemRewriter = new ItemRewriter(protocol, InventoryPackets::toClient, InventoryPackets::toServer);
// Open Window
protocol.registerOutgoing(State.PLAY, 0x2F, 0x2E, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_15.OPEN_WINDOW, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT);
@ -37,9 +37,7 @@ public class InventoryPackets {
});
}
});
// Window Property
protocol.registerOutgoing(State.PLAY, 0x16, 0x15, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_15.WINDOW_PROPERTY, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // Window id
@ -58,14 +56,10 @@ public class InventoryPackets {
}
});
// Set cooldown
itemRewriter.registerSetCooldown(0x18, 0x17, InventoryPackets::getNewItemId);
itemRewriter.registerSetCooldown(ClientboundPackets1_15.COOLDOWN, InventoryPackets::getNewItemId);
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, ClientboundPackets1_15.WINDOW_ITEMS);
// Window items packet
itemRewriter.registerWindowItems(Type.FLAT_VAR_INT_ITEM_ARRAY, 0x15, 0x14);
// Trade list packet
protocol.registerOutgoing(State.PLAY, 0x28, 0x27, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_15.TRADE_LIST, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
@ -100,14 +94,10 @@ public class InventoryPackets {
}
});
// Set slot packet
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, 0x17, 0x16);
itemRewriter.registerSetSlot(Type.FLAT_VAR_INT_ITEM, ClientboundPackets1_15.SET_SLOT);
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, ClientboundPackets1_15.ENTITY_EQUIPMENT);
// Entity Equipment Packet
itemRewriter.registerEntityEquipment(Type.FLAT_VAR_INT_ITEM, 0x47, 0x47);
// Declare Recipes
protocol.registerOutgoing(State.PLAY, 0x5B, 0x5A, new PacketRemapper() {
protocol.registerOutgoing(ClientboundPackets1_15.DECLARE_RECIPES, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
@ -166,14 +156,10 @@ public class InventoryPackets {
}
});
// Click window packet
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, 0x09, 0x09);
itemRewriter.registerClickWindow(Type.FLAT_VAR_INT_ITEM, ServerboundPackets1_16.CLICK_WINDOW);
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION);
// Creative Inventory Action
itemRewriter.registerCreativeInvAction(Type.FLAT_VAR_INT_ITEM, 0x26, 0x27);
// Edit Book
protocol.registerIncoming(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
protocol.registerIncoming(ServerboundPackets1_16.EDIT_BOOK, new PacketRemapper() {
@Override
public void registerMap() {
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.type.Type;
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_16to1_15_2.Protocol1_16To1_15_2;
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) {
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_16To1_15_2::getNewBlockStateId, Protocol1_16To1_15_2::getNewBlockId);
// Block action
blockRewriter.registerBlockAction(0x0B, 0x0A);
blockRewriter.registerBlockAction(ClientboundPackets1_15.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_15.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);
// Block Change
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() {
protocol.registerOutgoing(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
@ -96,11 +88,8 @@ public class WorldPackets {
}
});
// Effect
blockRewriter.registerEffect(0x23, 0x22, 1010, 2001, InventoryPackets::getNewItemId);
// Spawn Particle
blockRewriter.registerSpawnParticle(Type.DOUBLE, 0x24, 0x23, 3, 23, 32,
blockRewriter.registerEffect(ClientboundPackets1_15.EFFECT, 1010, 2001, InventoryPackets::getNewItemId);
blockRewriter.registerSpawnParticle(Type.DOUBLE, ClientboundPackets1_15.SPAWN_PARTICLE, 3, 23, 32,
WorldPackets::getNewParticleId, InventoryPackets::toClient, Type.FLAT_VAR_INT_ITEM);
}

Datei anzeigen

@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
public class Protocol1_9_1To1_9 extends Protocol {
@Override
protected void registerPackets() {
// Currently supports 1.9.1 and 1.9.2

Datei anzeigen

@ -20,6 +20,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.types.Chunk1_9_1_2Ty
import java.util.List;
public class Protocol1_9_3To1_9_1_2 extends Protocol {
@Override
protected void registerPackets() {

Datei anzeigen

@ -7,7 +7,6 @@ import us.myles.ViaVersion.api.Triple;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.item.Item;
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.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer;
@ -30,7 +29,7 @@ public class EntityPackets {
}
};
public static void register(final Protocol protocol) {
public static void register(Protocol1_9To1_8 protocol) {
// Attach Entity Packet
protocol.registerOutgoing(State.PLAY, 0x1B, 0x3A, new PacketRemapper() {

Datei anzeigen

@ -31,7 +31,7 @@ public class SpawnPackets {
}
};
public static void register(final Protocol protocol) {
public static void register(Protocol1_9To1_8 protocol) {
// Spawn Object Packet
protocol.registerOutgoing(State.PLAY, 0x0E, 0x00, new PacketRemapper() {
@Override

Datei anzeigen

@ -8,6 +8,7 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
public class Protocol1_9To1_9_1 extends Protocol {
@Override
protected void registerPackets() {
// Currently supports 1.9.1 and 1.9.2