Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Allow registration of simple packet handlers over extending an abstract class
Dieser Commit ist enthalten in:
Ursprung
98c645f7ed
Commit
de5b7bf828
@ -64,7 +64,7 @@ public interface ViaAPI<T> {
|
|||||||
* @return API version incremented with meaningful API changes
|
* @return API version incremented with meaningful API changes
|
||||||
*/
|
*/
|
||||||
default int apiVersion() {
|
default int apiVersion() {
|
||||||
return 15;
|
return 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,25 +32,25 @@ import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.exception.CancelException;
|
import com.viaversion.viaversion.exception.CancelException;
|
||||||
import com.viaversion.viaversion.exception.InformativeException;
|
import com.viaversion.viaversion.exception.InformativeException;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType>
|
public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType>
|
||||||
implements Protocol<C1, C2, S1, S2> {
|
implements Protocol<C1, C2, S1, S2> {
|
||||||
private final Map<Packet, ProtocolPacket> serverbound = new HashMap<>();
|
private final Map<Packet, ProtocolPacket> serverbound = new HashMap<>();
|
||||||
private final Map<Packet, ProtocolPacket> clientbound = new HashMap<>();
|
private final Map<Packet, ProtocolPacket> clientbound = new HashMap<>();
|
||||||
private final Map<Class<?>, Object> storedObjects = new HashMap<>(); // currently only used for MetadataRewriters
|
private final Map<Class<?>, Object> storedObjects = new HashMap<>(); // currently only used for MetadataRewriters
|
||||||
protected final Class<C1> oldClientboundPacketEnum;
|
protected final Class<C1> unmappedClientboundPacketType;
|
||||||
protected final Class<C2> newClientboundPacketEnum;
|
protected final Class<C2> mappedClientboundPacketType;
|
||||||
protected final Class<S1> oldServerboundPacketEnum;
|
protected final Class<S1> mappedServerboundPacketType;
|
||||||
protected final Class<S2> newServerboundPacketEnum;
|
protected final Class<S2> unmappedServerboundPacketType;
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
|
|
||||||
protected AbstractProtocol() {
|
protected AbstractProtocol() {
|
||||||
@ -58,14 +58,14 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a protocol with automated id mapping if the respective enums are not null.
|
* Creates a protocol with automated id mapping if the respective packet type classes are not null.
|
||||||
*/
|
*/
|
||||||
protected AbstractProtocol(@Nullable Class<C1> oldClientboundPacketEnum, @Nullable Class<C2> clientboundPacketEnum,
|
protected AbstractProtocol(@Nullable Class<C1> unmappedClientboundPacketType, @Nullable Class<C2> mappedClientboundPacketType,
|
||||||
@Nullable Class<S1> oldServerboundPacketEnum, @Nullable Class<S2> serverboundPacketEnum) {
|
@Nullable Class<S1> mappedServerboundPacketType, @Nullable Class<S2> unmappedServerboundPacketType) {
|
||||||
this.oldClientboundPacketEnum = oldClientboundPacketEnum;
|
this.unmappedClientboundPacketType = unmappedClientboundPacketType;
|
||||||
this.newClientboundPacketEnum = clientboundPacketEnum;
|
this.mappedClientboundPacketType = mappedClientboundPacketType;
|
||||||
this.oldServerboundPacketEnum = oldServerboundPacketEnum;
|
this.mappedServerboundPacketType = mappedServerboundPacketType;
|
||||||
this.newServerboundPacketEnum = serverboundPacketEnum;
|
this.unmappedServerboundPacketType = unmappedServerboundPacketType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,24 +76,24 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
registerPackets();
|
registerPackets();
|
||||||
|
|
||||||
// Register the rest of the ids with no handlers if necessary
|
// Register the rest of the ids with no handlers if necessary
|
||||||
if (oldClientboundPacketEnum != null && newClientboundPacketEnum != null
|
if (unmappedClientboundPacketType != null && mappedClientboundPacketType != null
|
||||||
&& oldClientboundPacketEnum != newClientboundPacketEnum) {
|
&& unmappedClientboundPacketType != mappedClientboundPacketType) {
|
||||||
registerClientboundChannelIdChanges();
|
registerClientboundChannelIdChanges();
|
||||||
}
|
}
|
||||||
if (oldServerboundPacketEnum != null && newServerboundPacketEnum != null
|
if (mappedServerboundPacketType != null && unmappedServerboundPacketType != null
|
||||||
&& oldServerboundPacketEnum != newServerboundPacketEnum) {
|
&& mappedServerboundPacketType != unmappedServerboundPacketType) {
|
||||||
registerServerboundChannelIdChanges();
|
registerServerboundChannelIdChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerClientboundChannelIdChanges() {
|
protected void registerClientboundChannelIdChanges() {
|
||||||
C2[] newConstants = newClientboundPacketEnum.getEnumConstants();
|
C2[] newConstants = mappedClientboundPacketType.getEnumConstants();
|
||||||
Map<String, C2> newClientboundPackets = new HashMap<>(newConstants.length);
|
Map<String, C2> newClientboundPackets = new HashMap<>(newConstants.length);
|
||||||
for (C2 newConstant : newConstants) {
|
for (C2 newConstant : newConstants) {
|
||||||
newClientboundPackets.put(newConstant.getName(), newConstant);
|
newClientboundPackets.put(newConstant.getName(), newConstant);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (C1 packet : oldClientboundPacketEnum.getEnumConstants()) {
|
for (C1 packet : unmappedClientboundPacketType.getEnumConstants()) {
|
||||||
C2 mappedPacket = newClientboundPackets.get(packet.getName());
|
C2 mappedPacket = newClientboundPackets.get(packet.getName());
|
||||||
if (mappedPacket == null) {
|
if (mappedPacket == null) {
|
||||||
// Packet doesn't exist on new client
|
// Packet doesn't exist on new client
|
||||||
@ -109,13 +109,13 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void registerServerboundChannelIdChanges() {
|
protected void registerServerboundChannelIdChanges() {
|
||||||
S1[] oldConstants = oldServerboundPacketEnum.getEnumConstants();
|
S1[] oldConstants = mappedServerboundPacketType.getEnumConstants();
|
||||||
Map<String, S1> oldServerboundConstants = new HashMap<>(oldConstants.length);
|
Map<String, S1> oldServerboundConstants = new HashMap<>(oldConstants.length);
|
||||||
for (S1 oldConstant : oldConstants) {
|
for (S1 oldConstant : oldConstants) {
|
||||||
oldServerboundConstants.put(oldConstant.getName(), oldConstant);
|
oldServerboundConstants.put(oldConstant.getName(), oldConstant);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (S2 packet : newServerboundPacketEnum.getEnumConstants()) {
|
for (S2 packet : unmappedServerboundPacketType.getEnumConstants()) {
|
||||||
S1 mappedPacket = oldServerboundConstants.get(packet.getName());
|
S1 mappedPacket = oldServerboundConstants.get(packet.getName());
|
||||||
if (mappedPacket == null) {
|
if (mappedPacket == null) {
|
||||||
// Packet doesn't exist on old server
|
// Packet doesn't exist on old server
|
||||||
@ -156,9 +156,9 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerServerbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
|
public void registerServerbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler, boolean override) {
|
||||||
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
|
ProtocolPacket protocolPacket = new ProtocolPacket(state, unmappedPacketId, mappedPacketId, handler);
|
||||||
Packet packet = new Packet(state, newPacketID);
|
Packet packet = new Packet(state, mappedPacketId);
|
||||||
if (!override && serverbound.containsKey(packet)) {
|
if (!override && serverbound.containsKey(packet)) {
|
||||||
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
||||||
" If this override is intentional, set override to true. Stacktrace: ", new Exception());
|
" If this override is intentional, set override to true. Stacktrace: ", new Exception());
|
||||||
@ -167,39 +167,39 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelServerbound(State state, int oldPacketID, int newPacketID) {
|
public void cancelServerbound(State state, int unmappedPacketId, int mappedPacketId) {
|
||||||
registerServerbound(state, oldPacketID, newPacketID, new PacketRemapper() {
|
registerServerbound(state, unmappedPacketId, mappedPacketId, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(PacketWrapper::cancel);
|
handler(PacketWrapper::cancel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelServerbound(State state, int newPacketID) {
|
public void cancelServerbound(State state, int mappedPacketId) {
|
||||||
cancelServerbound(state, -1, newPacketID);
|
cancelServerbound(state, -1, mappedPacketId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelClientbound(State state, int oldPacketID, int newPacketID) {
|
public void cancelClientbound(State state, int unmappedPacketId, int mappedPacketId) {
|
||||||
registerClientbound(state, oldPacketID, newPacketID, new PacketRemapper() {
|
registerClientbound(state, unmappedPacketId, mappedPacketId, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(PacketWrapper::cancel);
|
handler(PacketWrapper::cancel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelClientbound(State state, int oldPacketID) {
|
public void cancelClientbound(State state, int unmappedPacketId) {
|
||||||
cancelClientbound(state, oldPacketID, -1);
|
cancelClientbound(state, unmappedPacketId, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerClientbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override) {
|
public void registerClientbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler, boolean override) {
|
||||||
ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
|
ProtocolPacket protocolPacket = new ProtocolPacket(state, unmappedPacketId, mappedPacketId, handler);
|
||||||
Packet packet = new Packet(state, oldPacketID);
|
Packet packet = new Packet(state, unmappedPacketId);
|
||||||
if (!override && clientbound.containsKey(packet)) {
|
if (!override && clientbound.containsKey(packet)) {
|
||||||
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
||||||
" If override is intentional, set override to true. Stacktrace: ", new Exception());
|
" If override is intentional, set override to true. Stacktrace: ", new Exception());
|
||||||
@ -209,52 +209,54 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerClientbound(C1 packetType, @Nullable PacketRemapper packetRemapper) {
|
public void registerClientbound(C1 packetType, @Nullable PacketHandler handler) {
|
||||||
checkPacketType(packetType, oldClientboundPacketEnum == null || packetType.getClass() == oldClientboundPacketEnum);
|
checkPacketType(packetType, unmappedClientboundPacketType == null || packetType.getClass() == unmappedClientboundPacketType);
|
||||||
|
|
||||||
C2 mappedPacket = oldClientboundPacketEnum == newClientboundPacketEnum ? (C2) packetType
|
//noinspection unchecked
|
||||||
: Arrays.stream(newClientboundPacketEnum.getEnumConstants()).filter(en -> en.getName().equals(packetType.getName())).findAny().orElse(null);
|
C2 mappedPacket = unmappedClientboundPacketType == mappedClientboundPacketType ? (C2) packetType
|
||||||
|
: Arrays.stream(mappedClientboundPacketType.getEnumConstants()).filter(en -> en.getName().equals(packetType.getName())).findAny().orElse(null);
|
||||||
Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!");
|
Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!");
|
||||||
|
|
||||||
registerClientbound(packetType, mappedPacket, packetRemapper);
|
registerClientbound(packetType, mappedPacket, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override) {
|
public void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketHandler handler, boolean override) {
|
||||||
register(clientbound, packetType, mappedPacketType, oldClientboundPacketEnum, newClientboundPacketEnum, packetRemapper, override);
|
register(clientbound, packetType, mappedPacketType, unmappedClientboundPacketType, mappedClientboundPacketType, handler, override);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelClientbound(C1 packetType) {
|
public void cancelClientbound(C1 packetType) {
|
||||||
registerClientbound(packetType, null, new PacketRemapper() {
|
registerClientbound(packetType, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(PacketWrapper::cancel);
|
handler(PacketWrapper::cancel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerServerbound(S2 packetType, @Nullable PacketRemapper packetRemapper) {
|
public void registerServerbound(S2 packetType, @Nullable PacketHandler handler) {
|
||||||
checkPacketType(packetType, newServerboundPacketEnum == null || packetType.getClass() == newServerboundPacketEnum);
|
checkPacketType(packetType, unmappedServerboundPacketType == null || packetType.getClass() == unmappedServerboundPacketType);
|
||||||
|
|
||||||
S1 mappedPacket = oldServerboundPacketEnum == newServerboundPacketEnum ? (S1) packetType
|
//noinspection unchecked
|
||||||
: Arrays.stream(oldServerboundPacketEnum.getEnumConstants()).filter(en -> en.getName().equals(packetType.getName())).findAny().orElse(null);
|
S1 mappedPacket = mappedServerboundPacketType == unmappedServerboundPacketType ? (S1) packetType
|
||||||
|
: Arrays.stream(mappedServerboundPacketType.getEnumConstants()).filter(en -> en.getName().equals(packetType.getName())).findAny().orElse(null);
|
||||||
Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!");
|
Preconditions.checkNotNull(mappedPacket, "Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " could not be automatically mapped!");
|
||||||
|
|
||||||
registerServerbound(packetType, mappedPacket, packetRemapper);
|
registerServerbound(packetType, mappedPacket, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override) {
|
public void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketHandler handler, boolean override) {
|
||||||
register(serverbound, packetType, mappedPacketType, newServerboundPacketEnum, oldServerboundPacketEnum, packetRemapper, override);
|
register(serverbound, packetType, mappedPacketType, unmappedServerboundPacketType, mappedServerboundPacketType, handler, override);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelServerbound(S2 packetType) {
|
public void cancelServerbound(S2 packetType) {
|
||||||
registerServerbound(packetType, null, new PacketRemapper() {
|
registerServerbound(packetType, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(PacketWrapper::cancel);
|
handler(PacketWrapper::cancel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -262,12 +264,12 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
|
|
||||||
private void register(Map<Packet, ProtocolPacket> packetMap, PacketType packetType, @Nullable PacketType mappedPacketType,
|
private void register(Map<Packet, ProtocolPacket> packetMap, PacketType packetType, @Nullable PacketType mappedPacketType,
|
||||||
Class<? extends PacketType> unmappedPacketEnum, Class<? extends PacketType> mappedPacketEnum,
|
Class<? extends PacketType> unmappedPacketEnum, Class<? extends PacketType> mappedPacketEnum,
|
||||||
@Nullable PacketRemapper remapper, boolean override) {
|
@Nullable PacketHandler handler, boolean override) {
|
||||||
checkPacketType(packetType, unmappedPacketEnum == null || packetType.getClass() == unmappedPacketEnum);
|
checkPacketType(packetType, unmappedPacketEnum == null || packetType.getClass() == unmappedPacketEnum);
|
||||||
checkPacketType(mappedPacketType, mappedPacketType == null || mappedPacketEnum == null || mappedPacketType.getClass() == mappedPacketEnum);
|
checkPacketType(mappedPacketType, mappedPacketType == null || mappedPacketEnum == null || mappedPacketType.getClass() == mappedPacketEnum);
|
||||||
Preconditions.checkArgument(mappedPacketType == null || packetType.state() == mappedPacketType.state(), "Packet type state does not match mapped packet type state");
|
Preconditions.checkArgument(mappedPacketType == null || packetType.state() == mappedPacketType.state(), "Packet type state does not match mapped packet type state");
|
||||||
|
|
||||||
ProtocolPacket protocolPacket = new ProtocolPacket(packetType.state(), packetType, mappedPacketType, remapper);
|
ProtocolPacket protocolPacket = new ProtocolPacket(packetType.state(), packetType, mappedPacketType, handler);
|
||||||
Packet packet = new Packet(packetType.state(), packetType.getId());
|
Packet packet = new Packet(packetType.state(), packetType.getId());
|
||||||
if (!override && packetMap.containsKey(packet)) {
|
if (!override && packetMap.containsKey(packet)) {
|
||||||
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
Via.getPlatform().getLogger().log(Level.WARNING, packet + " already registered!" +
|
||||||
@ -319,13 +321,24 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketRemapper remapper = protocolPacket.getRemapper();
|
PacketHandler handler = protocolPacket.getRemapper();
|
||||||
if (remapper != null) {
|
if (handler != null) {
|
||||||
try {
|
try {
|
||||||
remapper.remap(packetWrapper);
|
handler.handle(packetWrapper);
|
||||||
} catch (InformativeException e) { // Catch InformativeExceptions, pass through CancelExceptions
|
} catch (CancelException e) {
|
||||||
|
// Pass through CancelExceptions
|
||||||
|
throw e;
|
||||||
|
} catch (InformativeException e) {
|
||||||
|
// Catch InformativeExceptions
|
||||||
|
e.addSource(handler.getClass());
|
||||||
throwRemapError(direction, state, unmappedId, packetWrapper.getId(), e);
|
throwRemapError(direction, state, unmappedId, packetWrapper.getId(), e);
|
||||||
return;
|
return;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Wrap other exceptions during packet handling
|
||||||
|
InformativeException ex = new InformativeException(e);
|
||||||
|
ex.addSource(handler.getClass());
|
||||||
|
throwRemapError(direction, state, unmappedId, packetWrapper.getId(), ex);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packetWrapper.isCancelled()) {
|
if (packetWrapper.isCancelled()) {
|
||||||
@ -334,21 +347,21 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void throwRemapError(Direction direction, State state, int oldId, int newId, InformativeException e) throws InformativeException {
|
private void throwRemapError(Direction direction, State state, int unmappedPacketId, int mappedPacketId, InformativeException e) throws InformativeException {
|
||||||
// Don't print errors during handshake/login/status
|
// Don't print errors during handshake/login/status
|
||||||
if (state != State.PLAY && direction == Direction.SERVERBOUND && !Via.getManager().debugHandler().enabled()) {
|
if (state != State.PLAY && direction == Direction.SERVERBOUND && !Via.getManager().debugHandler().enabled()) {
|
||||||
e.setShouldBePrinted(false);
|
e.setShouldBePrinted(false);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<? extends PacketType> packetTypeClass = state == State.PLAY ? (direction == Direction.CLIENTBOUND ? oldClientboundPacketEnum : newServerboundPacketEnum) : null;
|
Class<? extends PacketType> packetTypeClass = state == State.PLAY ? (direction == Direction.CLIENTBOUND ? unmappedClientboundPacketType : unmappedServerboundPacketType) : null;
|
||||||
if (packetTypeClass != null) {
|
if (packetTypeClass != null) {
|
||||||
PacketType[] enumConstants = packetTypeClass.getEnumConstants();
|
PacketType[] enumConstants = packetTypeClass.getEnumConstants();
|
||||||
PacketType packetType = oldId < enumConstants.length && oldId >= 0 ? enumConstants[oldId] : null;
|
PacketType packetType = unmappedPacketId < enumConstants.length && unmappedPacketId >= 0 ? enumConstants[unmappedPacketId] : null;
|
||||||
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + " IN REMAP OF " + packetType + " (" + toNiceHex(oldId) + ")");
|
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + " IN REMAP OF " + packetType + " (" + toNiceHex(unmappedPacketId) + ")");
|
||||||
} else {
|
} else {
|
||||||
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName()
|
Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName()
|
||||||
+ " IN REMAP OF " + toNiceHex(oldId) + "->" + toNiceHex(newId));
|
+ " IN REMAP OF " + toNiceHex(unmappedPacketId) + "->" + toNiceHex(mappedPacketId));
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@ -365,7 +378,7 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
*/
|
*/
|
||||||
private void checkPacketType(PacketType packetType, boolean isValid) {
|
private void checkPacketType(PacketType packetType, boolean isValid) {
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
throw new IllegalArgumentException("Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " is taken from the wrong enum");
|
throw new IllegalArgumentException("Packet type " + packetType + " in " + packetType.getClass().getSimpleName() + " is taken from the wrong packet type class");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,11 +393,6 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
storedObjects.put(object.getClass(), object);
|
storedObjects.put(object.getClass(), object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasMappingDataToLoad() {
|
|
||||||
return getMappingData() != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Protocol:" + getClass().getSimpleName();
|
return "Protocol:" + getClass().getSimpleName();
|
||||||
@ -434,19 +442,19 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
private final int newId;
|
private final int newId;
|
||||||
private final PacketType unmappedPacketType;
|
private final PacketType unmappedPacketType;
|
||||||
private final PacketType mappedPacketType;
|
private final PacketType mappedPacketType;
|
||||||
private final PacketRemapper remapper;
|
private final PacketHandler handler;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public ProtocolPacket(State state, int oldId, int newId, @Nullable PacketRemapper remapper) {
|
public ProtocolPacket(State state, int oldId, int newId, @Nullable PacketHandler handler) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.oldId = oldId;
|
this.oldId = oldId;
|
||||||
this.newId = newId;
|
this.newId = newId;
|
||||||
this.remapper = remapper;
|
this.handler = handler;
|
||||||
this.unmappedPacketType = null;
|
this.unmappedPacketType = null;
|
||||||
this.mappedPacketType = null;
|
this.mappedPacketType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProtocolPacket(State state, PacketType unmappedPacketType, @Nullable PacketType mappedPacketType, @Nullable PacketRemapper remapper) {
|
public ProtocolPacket(State state, PacketType unmappedPacketType, @Nullable PacketType mappedPacketType, @Nullable PacketHandler handler) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.unmappedPacketType = unmappedPacketType;
|
this.unmappedPacketType = unmappedPacketType;
|
||||||
if (unmappedPacketType.direction() == Direction.CLIENTBOUND) {
|
if (unmappedPacketType.direction() == Direction.CLIENTBOUND) {
|
||||||
@ -458,7 +466,7 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
this.newId = unmappedPacketType.getId();
|
this.newId = unmappedPacketType.getId();
|
||||||
}
|
}
|
||||||
this.mappedPacketType = mappedPacketType;
|
this.mappedPacketType = mappedPacketType;
|
||||||
this.remapper = remapper;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public State getState() {
|
public State getState() {
|
||||||
@ -502,8 +510,8 @@ public abstract class AbstractProtocol<C1 extends ClientboundPacketType, C2 exte
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public PacketRemapper getRemapper() {
|
public PacketHandler getRemapper() {
|
||||||
return remapper;
|
return handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import com.viaversion.viaversion.api.protocol.packet.Direction;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||||
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
|
||||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||||
@ -39,69 +40,57 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
* Abstract protocol class handling packet transformation between two protocol versions.
|
* Abstract protocol class handling packet transformation between two protocol versions.
|
||||||
* Clientbound and serverbount packet types can be set to enforce correct usage of them.
|
* Clientbound and serverbount packet types can be set to enforce correct usage of them.
|
||||||
*
|
*
|
||||||
* @param <C1> old clientbound packet types
|
* @param <C1> unmapped ("old") clientbound packet types
|
||||||
* @param <C2> new clientbound packet types
|
* @param <C2> mapped ("new") clientbound packet types
|
||||||
* @param <S1> old serverbound packet types
|
* @param <S1> mapped ("old") serverbound packet types
|
||||||
* @param <S2> new serverbound packet types
|
* @param <S2> unmapped ("new") serverbound packet types
|
||||||
* @see SimpleProtocol for a helper class if you do not want to define any of the types above
|
* @see SimpleProtocol for a helper class if you do not want to define any of the types above
|
||||||
*/
|
*/
|
||||||
public interface Protocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType> {
|
public interface Protocol<C1 extends ClientboundPacketType, C2 extends ClientboundPacketType, S1 extends ServerboundPacketType, S2 extends ServerboundPacketType> {
|
||||||
|
|
||||||
default void registerServerbound(State state, int oldPacketID, int newPacketID) {
|
default void registerServerbound(State state, int unmappedPacketId, int mappedPacketId) {
|
||||||
registerServerbound(state, oldPacketID, newPacketID, null);
|
registerServerbound(state, unmappedPacketId, mappedPacketId, (PacketHandler) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
default void registerServerbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
default void registerServerbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler) {
|
||||||
registerServerbound(state, oldPacketID, newPacketID, packetRemapper, false);
|
registerServerbound(state, unmappedPacketId, mappedPacketId, handler, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a serverbound packet, with id transformation and remapper.
|
* Registers a serverbound packet, with id transformation and remapper.
|
||||||
*
|
*
|
||||||
* @param state state which the packet is sent in.
|
* @param state state which the packet is sent in.
|
||||||
* @param oldPacketID old packet ID
|
* @param unmappedPacketId unmapped packet id
|
||||||
* @param newPacketID new packet ID
|
* @param mappedPacketId mapped packet id
|
||||||
* @param packetRemapper remapper to use for the packet
|
* @param handler packet handler
|
||||||
* @param override whether an existing mapper should be overridden
|
* @param override whether an existing mapper should be overridden
|
||||||
* @see #registerServerbound(ServerboundPacketType, ServerboundPacketType, PacketRemapper, boolean)
|
* @see #registerServerbound(ServerboundPacketType, ServerboundPacketType, PacketHandler, boolean)
|
||||||
*/
|
*/
|
||||||
void registerServerbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override);
|
void registerServerbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler, boolean override);
|
||||||
|
|
||||||
/**
|
void cancelServerbound(State state, int mappedPacketId);
|
||||||
* @deprecated use {@link #cancelServerbound(State, int)}
|
|
||||||
*/
|
|
||||||
@Deprecated/*(forRemoval = true)*/
|
|
||||||
void cancelServerbound(State state, int oldPacketID, int newPacketID);
|
|
||||||
|
|
||||||
void cancelServerbound(State state, int newPacketID);
|
default void registerClientbound(State state, int unmappedPacketId, int mappedPacketId) {
|
||||||
|
registerClientbound(state, unmappedPacketId, mappedPacketId, (PacketHandler) null);
|
||||||
default void registerClientbound(State state, int oldPacketID, int newPacketID) {
|
|
||||||
registerClientbound(state, oldPacketID, newPacketID, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default void registerClientbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
|
default void registerClientbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler) {
|
||||||
registerClientbound(state, oldPacketID, newPacketID, packetRemapper, false);
|
registerClientbound(state, unmappedPacketId, mappedPacketId, handler, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void cancelClientbound(State state, int unmappedPacketId);
|
||||||
* @deprecated use {@link #cancelClientbound(State, int)}
|
|
||||||
*/
|
|
||||||
@Deprecated/*(forRemoval = true)*/
|
|
||||||
void cancelClientbound(State state, int oldPacketID, int newPacketID);
|
|
||||||
|
|
||||||
void cancelClientbound(State state, int oldPacketID);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a clientbound packet, with id transformation and remapper.
|
* Registers a clientbound packet, with id transformation and remapper.
|
||||||
*
|
*
|
||||||
* @param state state which the packet is sent in.
|
* @param state state which the packet is sent in.
|
||||||
* @param oldPacketID old packet ID
|
* @param unmappedPacketId unmapped packet id
|
||||||
* @param newPacketID new packet ID
|
* @param mappedPacketId mapped packet id
|
||||||
* @param packetRemapper remapper to use for the packet
|
* @param handler packet handler
|
||||||
* @param override whether an existing mapper should be overridden
|
* @param override whether an existing mapper should be overridden
|
||||||
* @see #registerClientbound(ClientboundPacketType, ClientboundPacketType, PacketRemapper, boolean)
|
* @see #registerClientbound(ClientboundPacketType, ClientboundPacketType, PacketHandler, boolean)
|
||||||
*/
|
*/
|
||||||
void registerClientbound(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper, boolean override);
|
void registerClientbound(State state, int unmappedPacketId, int mappedPacketId, PacketHandler handler, boolean override);
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -109,9 +98,9 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
* Registers a clientbound protocol and automatically maps it to the new id.
|
* Registers a clientbound protocol and automatically maps it to the new id.
|
||||||
*
|
*
|
||||||
* @param packetType clientbound packet type the server sends
|
* @param packetType clientbound packet type the server sends
|
||||||
* @param packetRemapper remapper
|
* @param handler packet handler
|
||||||
*/
|
*/
|
||||||
void registerClientbound(C1 packetType, @Nullable PacketRemapper packetRemapper);
|
void registerClientbound(C1 packetType, @Nullable PacketHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps a packet type to another packet type without a packet handler.
|
* Maps a packet type to another packet type without a packet handler.
|
||||||
@ -121,7 +110,7 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
* @param mappedPacketType clientbound packet type after transforming for the client
|
* @param mappedPacketType clientbound packet type after transforming for the client
|
||||||
*/
|
*/
|
||||||
default void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType) {
|
default void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType) {
|
||||||
registerClientbound(packetType, mappedPacketType, null);
|
registerClientbound(packetType, mappedPacketType, (PacketHandler) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,10 +118,10 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
*
|
*
|
||||||
* @param packetType clientbound packet type the server initially sends
|
* @param packetType clientbound packet type the server initially sends
|
||||||
* @param mappedPacketType clientbound packet type after transforming for the client
|
* @param mappedPacketType clientbound packet type after transforming for the client
|
||||||
* @param packetRemapper remapper
|
* @param handler packet handler
|
||||||
*/
|
*/
|
||||||
default void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
default void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketHandler handler) {
|
||||||
registerClientbound(packetType, mappedPacketType, packetRemapper, false);
|
registerClientbound(packetType, mappedPacketType, handler, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,10 +129,10 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
*
|
*
|
||||||
* @param packetType clientbound packet type the server initially sends
|
* @param packetType clientbound packet type the server initially sends
|
||||||
* @param mappedPacketType clientbound packet type after transforming for the client
|
* @param mappedPacketType clientbound packet type after transforming for the client
|
||||||
* @param packetRemapper remapper
|
* @param handler packet handler
|
||||||
* @param override whether an existing mapping should be overridden if present
|
* @param override whether an existing mapping should be overridden if present
|
||||||
*/
|
*/
|
||||||
void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override);
|
void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketHandler handler, boolean override);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels any clientbound packets from the given type.
|
* Cancels any clientbound packets from the given type.
|
||||||
@ -160,26 +149,26 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
* @param mappedPacketType serverbound packet type after transforming for the client
|
* @param mappedPacketType serverbound packet type after transforming for the client
|
||||||
*/
|
*/
|
||||||
default void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType) {
|
default void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType) {
|
||||||
registerServerbound(packetType, mappedPacketType, null);
|
registerServerbound(packetType, mappedPacketType, (PacketHandler) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a serverbound protocol and automatically maps it to the server's id.
|
* Registers a serverbound protocol and automatically maps it to the server's id.
|
||||||
*
|
*
|
||||||
* @param packetType serverbound packet type the client sends
|
* @param packetType serverbound packet type the client sends
|
||||||
* @param packetRemapper remapper
|
* @param handler packet handler
|
||||||
*/
|
*/
|
||||||
void registerServerbound(S2 packetType, @Nullable PacketRemapper packetRemapper);
|
void registerServerbound(S2 packetType, @Nullable PacketHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a serverbound protocol.
|
* Registers a serverbound protocol.
|
||||||
*
|
*
|
||||||
* @param packetType serverbound packet type initially sent by the client
|
* @param packetType serverbound packet type initially sent by the client
|
||||||
* @param mappedPacketType serverbound packet type after transforming for the server
|
* @param mappedPacketType serverbound packet type after transforming for the server
|
||||||
* @param packetRemapper remapper
|
* @param handler packet handler
|
||||||
*/
|
*/
|
||||||
default void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
default void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketHandler handler) {
|
||||||
registerServerbound(packetType, mappedPacketType, packetRemapper, false);
|
registerServerbound(packetType, mappedPacketType, handler, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,10 +176,10 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
*
|
*
|
||||||
* @param packetType serverbound packet type initially sent by the client
|
* @param packetType serverbound packet type initially sent by the client
|
||||||
* @param mappedPacketType serverbound packet type after transforming for the server
|
* @param mappedPacketType serverbound packet type after transforming for the server
|
||||||
* @param packetRemapper remapper
|
* @param handler packet handler
|
||||||
* @param override whether an existing mapping should be overridden if present
|
* @param override whether an existing mapping should be overridden if present
|
||||||
*/
|
*/
|
||||||
void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override);
|
void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketHandler handler, boolean override);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels any serverbound packets from the given type.
|
* Cancels any serverbound packets from the given type.
|
||||||
@ -220,16 +209,16 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
* Checks if a clientbound packet has already been registered.
|
* Checks if a clientbound packet has already been registered.
|
||||||
*
|
*
|
||||||
* @param state state which the packet is sent in
|
* @param state state which the packet is sent in
|
||||||
* @param oldPacketId old packet id
|
* @param unmappedPacketId unmapped packet id
|
||||||
* @return true if already registered
|
* @return true if already registered
|
||||||
*/
|
*/
|
||||||
boolean hasRegisteredClientbound(State state, int oldPacketId);
|
boolean hasRegisteredClientbound(State state, int unmappedPacketId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a serverbound packet has already been registered.
|
* Checks if a serverbound packet has already been registered.
|
||||||
*
|
*
|
||||||
* @param state state which the packet is sent in
|
* @param state state which the packet is sent in
|
||||||
* @param unmappedPacketId new packet id
|
* @param unmappedPacketId mapped packet id
|
||||||
* @return true if already registered
|
* @return true if already registered
|
||||||
*/
|
*/
|
||||||
boolean hasRegisteredServerbound(State state, int unmappedPacketId);
|
boolean hasRegisteredServerbound(State state, int unmappedPacketId);
|
||||||
@ -275,7 +264,9 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
*
|
*
|
||||||
* @return true if this Protocol's {@link #loadMappingData()} method should be called
|
* @return true if this Protocol's {@link #loadMappingData()} method should be called
|
||||||
*/
|
*/
|
||||||
boolean hasMappingDataToLoad();
|
default boolean hasMappingDataToLoad() {
|
||||||
|
return getMappingData() != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the protocol's mapping data.
|
* Loads the protocol's mapping data.
|
||||||
@ -319,7 +310,7 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
*
|
*
|
||||||
* @return entity rewriter
|
* @return entity rewriter
|
||||||
*/
|
*/
|
||||||
default @Nullable EntityRewriter getEntityRewriter() {
|
default @Nullable EntityRewriter<?> getEntityRewriter() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +319,7 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
*
|
*
|
||||||
* @return item rewriter
|
* @return item rewriter
|
||||||
*/
|
*/
|
||||||
default @Nullable ItemRewriter getItemRewriter() {
|
default @Nullable ItemRewriter<?> getItemRewriter() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,4 +331,68 @@ public interface Protocol<C1 extends ClientboundPacketType, C2 extends Clientbou
|
|||||||
default boolean isBaseProtocol() {
|
default boolean isBaseProtocol() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #cancelServerbound(State, int)}
|
||||||
|
*/
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
void cancelServerbound(State state, int unmappedPacketId, int mappedPacketId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #cancelClientbound(State, int)}
|
||||||
|
*/
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
void cancelClientbound(State state, int unmappedPacketId, int mappedPacketId);
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerClientbound(State state, int unmappedPacketId, int mappedPacketId, PacketRemapper packetRemapper) {
|
||||||
|
registerClientbound(state, unmappedPacketId, mappedPacketId, (PacketHandler) packetRemapper, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerClientbound(State state, int unmappedPacketId, int mappedPacketId, PacketRemapper packetRemapper, boolean override) {
|
||||||
|
registerClientbound(state, unmappedPacketId, mappedPacketId, (PacketHandler) packetRemapper, override);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerClientbound(C1 packetType, @Nullable PacketRemapper packetRemapper) {
|
||||||
|
registerClientbound(packetType, (PacketHandler) packetRemapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
||||||
|
registerClientbound(packetType, mappedPacketType, (PacketHandler) packetRemapper, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerClientbound(C1 packetType, @Nullable C2 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override) {
|
||||||
|
registerClientbound(packetType, mappedPacketType, (PacketHandler) packetRemapper, override);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerServerbound(State state, int unmappedPacketId, int mappedPacketId, PacketRemapper packetRemapper) {
|
||||||
|
registerServerbound(state, unmappedPacketId, mappedPacketId, (PacketHandler) packetRemapper, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerServerbound(State state, int unmappedPacketId, int mappedPacketId, PacketRemapper packetRemapper, boolean override) {
|
||||||
|
registerServerbound(state, unmappedPacketId, mappedPacketId, (PacketHandler) packetRemapper, override);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerServerbound(S2 packetType, @Nullable PacketRemapper packetRemapper) {
|
||||||
|
registerServerbound(packetType, (PacketHandler) packetRemapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper) {
|
||||||
|
registerServerbound(packetType, mappedPacketType, (PacketHandler) packetRemapper, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
|
default void registerServerbound(S2 packetType, @Nullable S1 mappedPacketType, @Nullable PacketRemapper packetRemapper, boolean override) {
|
||||||
|
registerServerbound(packetType, mappedPacketType, (PacketHandler) packetRemapper, override);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,161 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||||
|
* Copyright (C) 2016-2023 ViaVersion and contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
package com.viaversion.viaversion.api.protocol.remapper;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public abstract class PacketHandlers implements PacketHandler {
|
||||||
|
private final List<PacketHandler> packetHandlers = new ArrayList<>();
|
||||||
|
|
||||||
|
protected PacketHandlers() {
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
|
||||||
|
static PacketHandler fromRemapper(List<PacketHandler> valueRemappers) {
|
||||||
|
final PacketHandlers handlers = new PacketHandlers() {
|
||||||
|
@Override
|
||||||
|
public void register() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
handlers.packetHandlers.addAll(valueRemappers);
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads and writes the given type.
|
||||||
|
*
|
||||||
|
* @param type type to map
|
||||||
|
*/
|
||||||
|
public <T> void map(Type<T> type) {
|
||||||
|
handler(wrapper -> wrapper.write(type, wrapper.read(type)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the first given type and writes the second given type.
|
||||||
|
*
|
||||||
|
* @param oldType old type
|
||||||
|
* @param newType new type
|
||||||
|
*/
|
||||||
|
public void map(Type oldType, Type newType) {
|
||||||
|
handler(wrapper -> wrapper.write(newType, wrapper.read(oldType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a type from an old type to a transformed new type.
|
||||||
|
*
|
||||||
|
* @param <T1> old value type
|
||||||
|
* @param <T2> new value type
|
||||||
|
* @param oldType old type
|
||||||
|
* @param newType new type
|
||||||
|
* @param transformer transformer to produce the new type
|
||||||
|
*/
|
||||||
|
public <T1, T2> void map(Type<T1> oldType, Type<T2> newType, Function<T1, T2> transformer) {
|
||||||
|
map(oldType, new ValueTransformer<T1, T2>(newType) {
|
||||||
|
@Override
|
||||||
|
public T2 transform(PacketWrapper wrapper, T1 inputValue) {
|
||||||
|
return transformer.apply(inputValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a type from an old type to a transformed new type based on their input type.
|
||||||
|
*
|
||||||
|
* @param <T1> old value type
|
||||||
|
* @param <T2> new value type
|
||||||
|
* @param transformer transformer to produce the new type
|
||||||
|
*/
|
||||||
|
public <T1, T2> void map(ValueTransformer<T1, T2> transformer) {
|
||||||
|
if (transformer.getInputType() == null) {
|
||||||
|
throw new IllegalArgumentException("Use map(Type<T1>, ValueTransformer<T1, T2>) for value transformers without specified input type!");
|
||||||
|
}
|
||||||
|
map(transformer.getInputType(), transformer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a type from an old type to a transformed new type.
|
||||||
|
*
|
||||||
|
* @param <T1> old value type
|
||||||
|
* @param <T2> new value type
|
||||||
|
* @param oldType old type
|
||||||
|
* @param transformer transformer to produce the new type
|
||||||
|
*/
|
||||||
|
public <T1, T2> void map(Type<T1> oldType, ValueTransformer<T1, T2> transformer) {
|
||||||
|
map(new TypeRemapper<>(oldType), transformer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a type using a basic ValueReader to a ValueWriter.
|
||||||
|
*
|
||||||
|
* @param inputReader reader to read with
|
||||||
|
* @param outputWriter writer to write with
|
||||||
|
* @param <T> read/write type
|
||||||
|
*/
|
||||||
|
public <T> void map(ValueReader<T> inputReader, ValueWriter<T> outputWriter) {
|
||||||
|
handler(wrapper -> outputWriter.write(wrapper, inputReader.read(wrapper)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a packet handler.
|
||||||
|
*
|
||||||
|
* @param handler packet handler
|
||||||
|
*/
|
||||||
|
public void handler(PacketHandler handler) {
|
||||||
|
packetHandlers.add(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a value.
|
||||||
|
*
|
||||||
|
* @param type type to write
|
||||||
|
* @param value value to write
|
||||||
|
*/
|
||||||
|
public <T> void create(Type<T> type, T value) {
|
||||||
|
handler(wrapper -> wrapper.write(type, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads (and thus removes) the given type.
|
||||||
|
*
|
||||||
|
* @param type type to read
|
||||||
|
*/
|
||||||
|
public void read(Type<?> type) {
|
||||||
|
handler(wrapper -> wrapper.read(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers the handlers for this packet.
|
||||||
|
*/
|
||||||
|
protected abstract void register();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
for (PacketHandler handler : packetHandlers) {
|
||||||
|
handler.handle(wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,11 +26,14 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.exception.CancelException;
|
import com.viaversion.viaversion.exception.CancelException;
|
||||||
import com.viaversion.viaversion.exception.InformativeException;
|
import com.viaversion.viaversion.exception.InformativeException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link PacketHandlers} or directly implement {@link PacketHandler}
|
||||||
|
*/
|
||||||
|
@Deprecated/*(forRemoval = true)*/
|
||||||
public abstract class PacketRemapper {
|
public abstract class PacketRemapper {
|
||||||
private final List<PacketHandler> valueRemappers = new ArrayList<>();
|
private final List<PacketHandler> valueRemappers = new ArrayList<>();
|
||||||
|
|
||||||
@ -145,6 +148,10 @@ public abstract class PacketRemapper {
|
|||||||
*/
|
*/
|
||||||
public abstract void registerMap();
|
public abstract void registerMap();
|
||||||
|
|
||||||
|
public PacketHandler asPacketHandler() {
|
||||||
|
return PacketHandlers.fromRemapper(this.valueRemappers);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a packet wrapper.
|
* Processes a packet wrapper.
|
||||||
*
|
*
|
||||||
@ -152,6 +159,7 @@ public abstract class PacketRemapper {
|
|||||||
* @throws InformativeException if packet reading or writing fails
|
* @throws InformativeException if packet reading or writing fails
|
||||||
* @throws CancelException if the packet should be cancelled
|
* @throws CancelException if the packet should be cancelled
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public void remap(PacketWrapper packetWrapper) throws Exception {
|
public void remap(PacketWrapper packetWrapper) throws Exception {
|
||||||
try {
|
try {
|
||||||
for (PacketHandler handler : valueRemappers) {
|
for (PacketHandler handler : valueRemappers) {
|
||||||
|
@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ValueReader<T> {
|
public interface ValueReader<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads value from a PacketWrapper
|
* Reads value from a PacketWrapper
|
||||||
*
|
*
|
||||||
|
@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ValueWriter<T> {
|
public interface ValueWriter<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a value to a packet
|
* Write a value to a packet
|
||||||
*
|
*
|
||||||
|
@ -76,6 +76,7 @@ public class PacketWrapperImpl implements PacketWrapper {
|
|||||||
for (Pair<Type, Object> packetValue : packetValues) {
|
for (Pair<Type, Object> packetValue : packetValues) {
|
||||||
if (packetValue.key() != type) continue;
|
if (packetValue.key() != type) continue;
|
||||||
if (currentIndex == index) {
|
if (currentIndex == index) {
|
||||||
|
//noinspection unchecked
|
||||||
return (T) packetValue.value();
|
return (T) packetValue.value();
|
||||||
}
|
}
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
@ -145,6 +146,7 @@ public class PacketWrapperImpl implements PacketWrapper {
|
|||||||
if (rtype == type
|
if (rtype == type
|
||||||
|| (type.getBaseClass() == rtype.getBaseClass()
|
|| (type.getBaseClass() == rtype.getBaseClass()
|
||||||
&& type.getOutputClass() == rtype.getOutputClass())) {
|
&& type.getOutputClass() == rtype.getOutputClass())) {
|
||||||
|
//noinspection unchecked
|
||||||
return (T) read.value();
|
return (T) read.value();
|
||||||
} else if (rtype == Type.NOTHING) {
|
} else if (rtype == Type.NOTHING) {
|
||||||
return read(type); // retry
|
return read(type); // retry
|
||||||
@ -169,7 +171,7 @@ public class PacketWrapperImpl implements PacketWrapper {
|
|||||||
if (value != null && !expectedType.getOutputClass().isAssignableFrom(value.getClass())) {
|
if (value != null && !expectedType.getOutputClass().isAssignableFrom(value.getClass())) {
|
||||||
// Attempt conversion
|
// Attempt conversion
|
||||||
if (expectedType instanceof TypeConverter) {
|
if (expectedType instanceof TypeConverter) {
|
||||||
return ((TypeConverter) expectedType).from(value);
|
return ((TypeConverter<?>) expectedType).from(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Via.getPlatform().getLogger().warning("Possible type mismatch: " + value.getClass().getName() + " -> " + expectedType.getOutputClass());
|
Via.getPlatform().getLogger().warning("Possible type mismatch: " + value.getClass().getName() + " -> " + expectedType.getOutputClass());
|
||||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.protocol.ProtocolPipeline;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
@ -40,9 +40,9 @@ public class BaseProtocol extends AbstractProtocol {
|
|||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
// Handshake Packet
|
// Handshake Packet
|
||||||
registerServerbound(ServerboundHandshakePackets.CLIENT_INTENTION, new PacketRemapper() {
|
registerServerbound(ServerboundHandshakePackets.CLIENT_INTENTION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int protocolVersion = wrapper.passthrough(Type.VAR_INT);
|
int protocolVersion = wrapper.passthrough(Type.VAR_INT);
|
||||||
wrapper.passthrough(Type.STRING); // Server Address
|
wrapper.passthrough(Type.STRING); // Server Address
|
||||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.protocol.ProtocolPathEntry;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
import com.viaversion.viaversion.api.protocol.version.VersionProvider;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
@ -50,9 +50,9 @@ public class BaseProtocol1_7 extends AbstractProtocol {
|
|||||||
/* Outgoing Packets */
|
/* Outgoing Packets */
|
||||||
|
|
||||||
// Status Response Packet
|
// Status Response Packet
|
||||||
registerClientbound(ClientboundStatusPackets.STATUS_RESPONSE, new PacketRemapper() { // Status Response Packet
|
registerClientbound(ClientboundStatusPackets.STATUS_RESPONSE, new PacketHandlers() { // Status Response Packet
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING);
|
map(Type.STRING);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -125,9 +125,9 @@ public class BaseProtocol1_7 extends AbstractProtocol {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Login Success Packet
|
// Login Success Packet
|
||||||
registerClientbound(ClientboundLoginPackets.GAME_PROFILE, new PacketRemapper() {
|
registerClientbound(ClientboundLoginPackets.GAME_PROFILE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -162,9 +162,9 @@ public class BaseProtocol1_7 extends AbstractProtocol {
|
|||||||
|
|
||||||
/* Incoming Packets */
|
/* Incoming Packets */
|
||||||
// Login Start Packet
|
// Login Start Packet
|
||||||
registerServerbound(ServerboundLoginPackets.HELLO, new PacketRemapper() {
|
registerServerbound(ServerboundLoginPackets.HELLO, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(final PacketWrapper wrapper) throws Exception {
|
public void handle(final PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
@ -71,9 +71,9 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
itemRewriter.register();
|
itemRewriter.register();
|
||||||
|
|
||||||
// Named sound effect
|
// Named sound effect
|
||||||
registerClientbound(ClientboundPackets1_9_3.NAMED_SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.NAMED_SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Sound name
|
map(Type.STRING); // 0 - Sound name
|
||||||
map(Type.VAR_INT); // 1 - Sound Category
|
map(Type.VAR_INT); // 1 - Sound Category
|
||||||
map(Type.INT); // 2 - x
|
map(Type.INT); // 2 - x
|
||||||
@ -85,9 +85,9 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Sound effect
|
// Sound effect
|
||||||
registerClientbound(ClientboundPackets1_9_3.SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Sound name
|
map(Type.VAR_INT); // 0 - Sound name
|
||||||
map(Type.VAR_INT); // 1 - Sound Category
|
map(Type.VAR_INT); // 1 - Sound Category
|
||||||
map(Type.INT); // 2 - x
|
map(Type.INT); // 2 - x
|
||||||
@ -107,18 +107,18 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Metadata packet
|
// Metadata packet
|
||||||
registerClientbound(ClientboundPackets1_9_3.ENTITY_METADATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.ENTITY_METADATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Types1_9.METADATA_LIST, TRANSFORM_METADATA); // 1 - Metadata list
|
map(Types1_9.METADATA_LIST, TRANSFORM_METADATA); // 1 - Metadata list
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Spawn Mob
|
// Spawn Mob
|
||||||
registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity id
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
map(Type.UUID); // 1 - UUID
|
map(Type.UUID); // 1 - UUID
|
||||||
map(Type.UNSIGNED_BYTE); // 2 - Entity Type
|
map(Type.UNSIGNED_BYTE); // 2 - Entity Type
|
||||||
@ -136,9 +136,9 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Spawn Player
|
// Spawn Player
|
||||||
registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.SPAWN_PLAYER, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Player UUID
|
map(Type.UUID); // 1 - Player UUID
|
||||||
map(Type.DOUBLE); // 2 - X
|
map(Type.DOUBLE); // 2 - X
|
||||||
@ -151,9 +151,9 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Join Game
|
// Join Game
|
||||||
registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Entity ID
|
map(Type.INT); // 0 - Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
map(Type.INT); // 2 - Dimension
|
map(Type.INT); // 2 - Dimension
|
||||||
@ -171,9 +171,9 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Respawn
|
// Respawn
|
||||||
registerClientbound(ClientboundPackets1_9_3.RESPAWN, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Dimension ID
|
map(Type.INT); // 0 - Dimension ID
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -189,9 +189,9 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Chunk Data
|
// Chunk Data
|
||||||
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -211,9 +211,9 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Packet Send ResourcePack
|
// Packet Send ResourcePack
|
||||||
registerClientbound(ClientboundPackets1_9_3.RESOURCE_PACK, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.RESOURCE_PACK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - URL
|
map(Type.STRING); // 0 - URL
|
||||||
map(Type.STRING); // 1 - Hash
|
map(Type.STRING); // 1 - Hash
|
||||||
|
|
||||||
@ -228,9 +228,9 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol<ClientboundPackets1_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Packet ResourcePack status
|
// Packet ResourcePack status
|
||||||
registerServerbound(ServerboundPackets1_9_3.RESOURCE_PACK_STATUS, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_9_3.RESOURCE_PACK_STATUS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -18,14 +18,13 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_11_1to1_11;
|
package com.viaversion.viaversion.protocols.protocol1_11_1to1_11;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_11_1to1_11.packets.InventoryPackets;
|
import com.viaversion.viaversion.protocols.protocol1_11_1to1_11.packets.InventoryPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ClientboundPackets1_9_3;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.ServerboundPackets1_9_3;
|
||||||
|
|
||||||
public class Protocol1_11_1To1_11 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
public class Protocol1_11_1To1_11 extends AbstractProtocol<ClientboundPackets1_9_3, ClientboundPackets1_9_3, ServerboundPackets1_9_3, ServerboundPackets1_9_3> {
|
||||||
|
|
||||||
private final ItemRewriter itemRewriter = new InventoryPackets(this);
|
private final InventoryPackets itemRewriter = new InventoryPackets(this);
|
||||||
|
|
||||||
public Protocol1_11_1To1_11() {
|
public Protocol1_11_1To1_11() {
|
||||||
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
super(ClientboundPackets1_9_3.class, ClientboundPackets1_9_3.class, ServerboundPackets1_9_3.class, ServerboundPackets1_9_3.class);
|
||||||
@ -37,7 +36,7 @@ public class Protocol1_11_1To1_11 extends AbstractProtocol<ClientboundPackets1_9
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemRewriter getItemRewriter() {
|
public InventoryPackets getItemRewriter() {
|
||||||
return itemRewriter;
|
return itemRewriter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_11Types;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
||||||
@ -61,9 +61,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
entityRewriter.register();
|
entityRewriter.register();
|
||||||
itemRewriter.register();
|
itemRewriter.register();
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity id
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
map(Type.UUID); // 1 - UUID
|
map(Type.UUID); // 1 - UUID
|
||||||
map(Type.BYTE); // 2 - Type
|
map(Type.BYTE); // 2 - Type
|
||||||
@ -73,9 +73,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.UNSIGNED_BYTE, Type.VAR_INT); // 2 - Entity Type
|
map(Type.UNSIGNED_BYTE, Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -112,9 +112,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
|
|
||||||
new SoundRewriter<>(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
|
new SoundRewriter<>(this, this::getNewSoundId).registerSound(ClientboundPackets1_9_3.SOUND);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.COLLECT_ITEM, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Collected entity id
|
map(Type.VAR_INT); // 0 - Collected entity id
|
||||||
map(Type.VAR_INT); // 1 - Collector entity id
|
map(Type.VAR_INT); // 1 - Collector entity id
|
||||||
|
|
||||||
@ -129,9 +129,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
|
|
||||||
entityRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
entityRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_9.METADATA_LIST);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.ENTITY_TELEPORT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.ENTITY_TELEPORT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity id
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
map(Type.DOUBLE); // 1 - x
|
map(Type.DOUBLE); // 1 - x
|
||||||
map(Type.DOUBLE); // 2 - y
|
map(Type.DOUBLE); // 2 - y
|
||||||
@ -159,9 +159,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
|
|
||||||
entityRewriter.registerRemoveEntities(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
entityRewriter.registerRemoveEntities(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.TITLE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.TITLE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Action
|
map(Type.VAR_INT); // 0 - Action
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -178,9 +178,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.BLOCK_ACTION, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.BLOCK_ACTION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); // 0 - Position
|
map(Type.POSITION); // 0 - Position
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Action ID
|
map(Type.UNSIGNED_BYTE); // 1 - Action ID
|
||||||
map(Type.UNSIGNED_BYTE); // 2 - Action Param
|
map(Type.UNSIGNED_BYTE); // 2 - Action Param
|
||||||
@ -201,9 +201,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); // 0 - Position
|
map(Type.POSITION); // 0 - Position
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||||
map(Type.NBT); // 2 - NBT data
|
map(Type.NBT); // 2 - NBT data
|
||||||
@ -224,9 +224,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -251,9 +251,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Entity ID
|
map(Type.INT); // 0 - Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
map(Type.INT); // 2 - Dimension
|
map(Type.INT); // 2 - Dimension
|
||||||
@ -264,9 +264,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_9_3.RESPAWN, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT);
|
map(Type.INT);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
@ -276,9 +276,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.registerClientbound(ClientboundPackets1_9_3.EFFECT, new PacketRemapper() {
|
this.registerClientbound(ClientboundPackets1_9_3.EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
this.map(Type.INT); //effectID
|
this.map(Type.INT); //effectID
|
||||||
this.map(Type.POSITION); //pos
|
this.map(Type.POSITION); //pos
|
||||||
this.map(Type.INT); //effectData
|
this.map(Type.INT); //effectData
|
||||||
@ -309,9 +309,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
INCOMING PACKETS
|
INCOMING PACKETS
|
||||||
*/
|
*/
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_9_3.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); // 0 - Location
|
map(Type.POSITION); // 0 - Location
|
||||||
map(Type.VAR_INT); // 1 - Face
|
map(Type.VAR_INT); // 1 - Face
|
||||||
map(Type.VAR_INT); // 2 - Hand
|
map(Type.VAR_INT); // 2 - Hand
|
||||||
@ -322,9 +322,9 @@ public class Protocol1_11To1_10 extends AbstractProtocol<ClientboundPackets1_9_3
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_9_3.CHAT_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_9_3.CHAT_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Message
|
map(Type.STRING); // 0 - Message
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_11to1_10.packets;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.EntityIdRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_11to1_10.EntityIdRewriter;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
|
import com.viaversion.viaversion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
|
||||||
@ -41,9 +41,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, Serv
|
|||||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||||
|
|
||||||
// Plugin message Packet -> Trading
|
// Plugin message Packet -> Trading
|
||||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Channel
|
map(Type.STRING); // 0 - Channel
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_12_2to1_12_1;
|
package com.viaversion.viaversion.protocols.protocol1_12_2to1_12_1;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
|
||||||
@ -31,16 +31,16 @@ public class Protocol1_12_2To1_12_1 extends AbstractProtocol<ClientboundPackets1
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
registerClientbound(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.KEEP_ALIVE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT, Type.LONG);
|
map(Type.VAR_INT, Type.LONG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_12_1.KEEP_ALIVE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.LONG, Type.VAR_INT);
|
map(Type.LONG, Type.VAR_INT);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -32,7 +32,7 @@ import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||||
@ -63,9 +63,9 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
|||||||
metadataRewriter.register();
|
metadataRewriter.register();
|
||||||
itemRewriter.register();
|
itemRewriter.register();
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity id
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
map(Type.UUID); // 1 - UUID
|
map(Type.UUID); // 1 - UUID
|
||||||
map(Type.BYTE); // 2 - Type
|
map(Type.BYTE); // 2 - Type
|
||||||
@ -75,9 +75,9 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -97,9 +97,9 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.CHAT_MESSAGE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.CHAT_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -117,9 +117,9 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -158,9 +158,9 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
|||||||
metadataRewriter.registerRemoveEntities(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
metadataRewriter.registerRemoveEntities(ClientboundPackets1_9_3.DESTROY_ENTITIES);
|
||||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_12.METADATA_LIST);
|
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_9_3.ENTITY_METADATA, Types1_12.METADATA_LIST);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT);
|
map(Type.INT);
|
||||||
map(Type.UNSIGNED_BYTE);
|
map(Type.UNSIGNED_BYTE);
|
||||||
map(Type.INT);
|
map(Type.INT);
|
||||||
@ -178,9 +178,9 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_9_3.RESPAWN, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT);
|
map(Type.INT);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
@ -197,9 +197,9 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
|
|||||||
cancelServerbound(ServerboundPackets1_12.PREPARE_CRAFTING_GRID);
|
cancelServerbound(ServerboundPackets1_12.PREPARE_CRAFTING_GRID);
|
||||||
|
|
||||||
// Client Settings (max length changed)
|
// Client Settings (max length changed)
|
||||||
registerServerbound(ServerboundPackets1_12.CLIENT_SETTINGS, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_12.CLIENT_SETTINGS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Locale
|
map(Type.STRING); // 0 - Locale
|
||||||
map(Type.BYTE); // 1 - view distance
|
map(Type.BYTE); // 1 - view distance
|
||||||
map(Type.VAR_INT); // 2 - chat mode
|
map(Type.VAR_INT); // 2 - chat mode
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ServerboundPackets1_12;
|
||||||
@ -43,9 +43,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, Serv
|
|||||||
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
registerEntityEquipment(ClientboundPackets1_9_3.ENTITY_EQUIPMENT, Type.ITEM);
|
||||||
|
|
||||||
// Plugin message Packet -> Trading
|
// Plugin message Packet -> Trading
|
||||||
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_9_3.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Channel
|
map(Type.STRING); // 0 - Channel
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -75,9 +75,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, Serv
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_12.CLICK_WINDOW, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_12.CLICK_WINDOW, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.SHORT); // 1 - Slot
|
map(Type.SHORT); // 1 - Slot
|
||||||
map(Type.BYTE); // 2 - Button
|
map(Type.BYTE); // 2 - Button
|
||||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||||
@ -58,9 +58,9 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
EntityPackets.register(this);
|
EntityPackets.register(this);
|
||||||
WorldPackets.register(this);
|
WorldPackets.register(this);
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.TAB_COMPLETE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {
|
map(Type.STRING, new ValueTransformer<String, String>(Type.STRING) {
|
||||||
@Override
|
@Override
|
||||||
@ -72,9 +72,9 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.FLAT_ITEM);
|
map(Type.FLAT_ITEM);
|
||||||
map(Type.BOOLEAN);
|
map(Type.BOOLEAN);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -93,9 +93,9 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_13.TAB_COMPLETE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Transaction id
|
map(Type.VAR_INT); // Transaction id
|
||||||
map(Type.VAR_INT); // Start
|
map(Type.VAR_INT); // Start
|
||||||
map(Type.VAR_INT); // Length
|
map(Type.VAR_INT); // Length
|
||||||
@ -119,9 +119,9 @@ public class Protocol1_13_1To1_13 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_13.BOSSBAR, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_13.BOSSBAR, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UUID);
|
map(Type.UUID);
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
||||||
@ -32,9 +32,9 @@ public class EntityPackets {
|
|||||||
public static void register(Protocol1_13_1To1_13 protocol) {
|
public static void register(Protocol1_13_1To1_13 protocol) {
|
||||||
MetadataRewriter1_13_1To1_13 metadataRewriter = protocol.get(MetadataRewriter1_13_1To1_13.class);
|
MetadataRewriter1_13_1To1_13 metadataRewriter = protocol.get(MetadataRewriter1_13_1To1_13.class);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity id
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
map(Type.UUID); // 1 - UUID
|
map(Type.UUID); // 1 - UUID
|
||||||
map(Type.BYTE); // 2 - Type
|
map(Type.BYTE); // 2 - Type
|
||||||
@ -66,9 +66,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -87,9 +87,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Player UUID
|
map(Type.UUID); // 1 - Player UUID
|
||||||
map(Type.DOUBLE); // 2 - X
|
map(Type.DOUBLE); // 2 - X
|
||||||
|
@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
@ -41,9 +41,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_ITEM);
|
registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_ITEM);
|
||||||
registerSetCooldown(ClientboundPackets1_13.COOLDOWN);
|
registerSetCooldown(ClientboundPackets1_13.COOLDOWN);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Channel
|
map(Type.STRING); // Channel
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -78,16 +78,16 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
|
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
|
||||||
|
|
||||||
RecipeRewriter<ClientboundPackets1_13> recipeRewriter = new RecipeRewriter1_13_2<>(protocol);
|
RecipeRewriter<ClientboundPackets1_13> recipeRewriter = new RecipeRewriter1_13_2<>(protocol);
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int size = wrapper.passthrough(Type.VAR_INT);
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
// First id, then type
|
// First id, then type
|
||||||
String id = wrapper.passthrough(Type.STRING);
|
String id = wrapper.passthrough(Type.STRING);
|
||||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||||
recipeRewriter.handle(wrapper, type);
|
recipeRewriter.handleRecipeType(wrapper, type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
@ -36,9 +36,9 @@ public class WorldPackets {
|
|||||||
public static void register(Protocol1_13_1To1_13 protocol) {
|
public static void register(Protocol1_13_1To1_13 protocol) {
|
||||||
BlockRewriter<ClientboundPackets1_13> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION);
|
BlockRewriter<ClientboundPackets1_13> blockRewriter = new BlockRewriter<>(protocol, Type.POSITION);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -65,9 +65,9 @@ public class WorldPackets {
|
|||||||
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
|
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
|
||||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
|
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Effect Id
|
map(Type.INT); // Effect Id
|
||||||
map(Type.POSITION); // Location
|
map(Type.POSITION); // Location
|
||||||
map(Type.INT); // Data
|
map(Type.INT); // Data
|
||||||
@ -105,9 +105,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Entity ID
|
map(Type.INT); // 0 - Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
map(Type.INT); // 2 - Dimension
|
map(Type.INT); // 2 - Dimension
|
||||||
@ -124,9 +124,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Dimension ID
|
map(Type.INT); // 0 - Dimension ID
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets.EntityPackets;
|
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets.EntityPackets;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets.InventoryPackets;
|
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets.InventoryPackets;
|
||||||
@ -41,16 +41,16 @@ public class Protocol1_13_2To1_13_1 extends AbstractProtocol<ClientboundPackets1
|
|||||||
WorldPackets.register(this);
|
WorldPackets.register(this);
|
||||||
EntityPackets.register(this);
|
EntityPackets.register(this);
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM);
|
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_13.ADVANCEMENTS, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_13.ADVANCEMENTS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets;
|
|||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||||
@ -35,9 +35,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -56,9 +56,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Player UUID
|
map(Type.UUID); // 1 - Player UUID
|
||||||
map(Type.DOUBLE); // 2 - X
|
map(Type.DOUBLE); // 2 - X
|
||||||
@ -72,9 +72,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_METADATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_METADATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 1 - Metadata list
|
map(Types1_13.METADATA_LIST, Types1_13_2.METADATA_LIST); // 1 - Metadata list
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1;
|
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
@ -28,25 +28,25 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPacke
|
|||||||
public class InventoryPackets {
|
public class InventoryPackets {
|
||||||
|
|
||||||
public static void register(Protocol1_13_2To1_13_1 protocol) {
|
public static void register(Protocol1_13_2To1_13_1 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.SHORT); // 1 - Slot ID
|
map(Type.SHORT); // 1 - Slot ID
|
||||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value
|
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_ITEMS, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.WINDOW_ITEMS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.FLAT_ITEM_ARRAY, Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values
|
map(Type.FLAT_ITEM_ARRAY, Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Channel
|
map(Type.STRING); // Channel
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -77,18 +77,18 @@ public class InventoryPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_EQUIPMENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.VAR_INT); // 1 - Slot ID
|
map(Type.VAR_INT); // 1 - Slot ID
|
||||||
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Item
|
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 2 - Item
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -125,9 +125,9 @@ public class InventoryPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_13.CLICK_WINDOW, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_13.CLICK_WINDOW, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.SHORT); // 1 - Slot
|
map(Type.SHORT); // 1 - Slot
|
||||||
map(Type.BYTE); // 2 - Button
|
map(Type.BYTE); // 2 - Button
|
||||||
@ -136,9 +136,9 @@ public class InventoryPackets {
|
|||||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item
|
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.SHORT); // 0 - Slot
|
map(Type.SHORT); // 0 - Slot
|
||||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item
|
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1;
|
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
@ -27,9 +27,9 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPacke
|
|||||||
public class WorldPackets {
|
public class WorldPackets {
|
||||||
|
|
||||||
public static void register(Protocol1_13_2To1_13_1 protocol) {
|
public static void register(Protocol1_13_2To1_13_1 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PARTICLE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Particle ID
|
map(Type.INT); // 0 - Particle ID
|
||||||
map(Type.BOOLEAN); // 1 - Long Distance
|
map(Type.BOOLEAN); // 1 - Long Distance
|
||||||
map(Type.FLOAT); // 2 - X
|
map(Type.FLOAT); // 2 - X
|
||||||
|
@ -32,7 +32,7 @@ import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||||
@ -166,16 +166,16 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
EntityPackets.register(this);
|
EntityPackets.register(this);
|
||||||
WorldPackets.register(this);
|
WorldPackets.register(this);
|
||||||
|
|
||||||
registerClientbound(State.LOGIN, 0x0, 0x0, new PacketRemapper() {
|
registerClientbound(State.LOGIN, 0x0, 0x0, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> componentRewriter.processText(wrapper.passthrough(Type.COMPONENT)));
|
handler(wrapper -> componentRewriter.processText(wrapper.passthrough(Type.COMPONENT)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(State.STATUS, 0x00, 0x00, new PacketRemapper() {
|
registerClientbound(State.STATUS, 0x00, 0x00, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING);
|
map(Type.STRING);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -198,9 +198,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
// New packet 0x04 - Login Plugin Message
|
// New packet 0x04 - Login Plugin Message
|
||||||
|
|
||||||
// Statistics
|
// Statistics
|
||||||
registerClientbound(ClientboundPackets1_12_1.STATISTICS, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.STATISTICS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -270,9 +270,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
componentRewriter.registerBossBar(ClientboundPackets1_12_1.BOSSBAR);
|
componentRewriter.registerBossBar(ClientboundPackets1_12_1.BOSSBAR);
|
||||||
componentRewriter.registerComponentPacket(ClientboundPackets1_12_1.CHAT_MESSAGE);
|
componentRewriter.registerComponentPacket(ClientboundPackets1_12_1.CHAT_MESSAGE);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.TAB_COMPLETE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.TAB_COMPLETE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -311,18 +311,18 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.OPEN_WINDOW, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.OPEN_WINDOW, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Id
|
map(Type.UNSIGNED_BYTE); // Id
|
||||||
map(Type.STRING); // Window type
|
map(Type.STRING); // Window type
|
||||||
handler(wrapper -> componentRewriter.processText(wrapper.passthrough(Type.COMPONENT))); // Title
|
handler(wrapper -> componentRewriter.processText(wrapper.passthrough(Type.COMPONENT))); // Title
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.COOLDOWN, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.COOLDOWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -361,9 +361,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
|
|
||||||
componentRewriter.registerComponentPacket(ClientboundPackets1_12_1.DISCONNECT);
|
componentRewriter.registerComponentPacket(ClientboundPackets1_12_1.DISCONNECT);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.EFFECT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Effect Id
|
map(Type.INT); // Effect Id
|
||||||
map(Type.POSITION); // Location
|
map(Type.POSITION); // Location
|
||||||
map(Type.INT); // Data
|
map(Type.INT); // Data
|
||||||
@ -384,9 +384,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.CRAFT_RECIPE_RESPONSE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.CRAFT_RECIPE_RESPONSE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.BYTE);
|
map(Type.BYTE);
|
||||||
handler(wrapper -> wrapper.write(Type.STRING, "viaversion:legacy/" + wrapper.read(Type.VAR_INT)));
|
handler(wrapper -> wrapper.write(Type.STRING, "viaversion:legacy/" + wrapper.read(Type.VAR_INT)));
|
||||||
}
|
}
|
||||||
@ -394,9 +394,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
|
|
||||||
componentRewriter.registerCombatEvent(ClientboundPackets1_12_1.COMBAT_EVENT);
|
componentRewriter.registerCombatEvent(ClientboundPackets1_12_1.COMBAT_EVENT);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.MAP_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.MAP_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Map id
|
map(Type.VAR_INT); // 0 - Map id
|
||||||
map(Type.BYTE); // 1 - Scale
|
map(Type.BYTE); // 1 - Scale
|
||||||
map(Type.BOOLEAN); // 2 - Tracking Position
|
map(Type.BOOLEAN); // 2 - Tracking Position
|
||||||
@ -418,9 +418,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_12_1.UNLOCK_RECIPES, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.UNLOCK_RECIPES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // action
|
map(Type.VAR_INT); // action
|
||||||
map(Type.BOOLEAN); // crafting book open
|
map(Type.BOOLEAN); // crafting book open
|
||||||
map(Type.BOOLEAN); // crafting filter active
|
map(Type.BOOLEAN); // crafting filter active
|
||||||
@ -504,9 +504,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.RESPAWN, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Dimension ID
|
map(Type.INT); // 0 - Dimension ID
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -524,9 +524,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.SCOREBOARD_OBJECTIVE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.SCOREBOARD_OBJECTIVE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Objective name
|
map(Type.STRING); // 0 - Objective name
|
||||||
map(Type.BYTE); // 1 - Mode
|
map(Type.BYTE); // 1 - Mode
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -547,9 +547,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.TEAMS, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.TEAMS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Team Name
|
map(Type.STRING); // 0 - Team Name
|
||||||
map(Type.BYTE); // 1 - Mode
|
map(Type.BYTE); // 1 - Mode
|
||||||
|
|
||||||
@ -600,9 +600,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_12_1.UPDATE_SCORE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.UPDATE_SCORE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -627,9 +627,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
|
|
||||||
new SoundRewriter<>(this).registerSound(ClientboundPackets1_12_1.SOUND);
|
new SoundRewriter<>(this).registerSound(ClientboundPackets1_12_1.SOUND);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.TAB_LIST, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.TAB_LIST, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -640,9 +640,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_12_1.ADVANCEMENTS, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_12_1.ADVANCEMENTS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -693,9 +693,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
cancelServerbound(ServerboundPackets1_13.QUERY_BLOCK_NBT);
|
cancelServerbound(ServerboundPackets1_13.QUERY_BLOCK_NBT);
|
||||||
|
|
||||||
// Tab-Complete
|
// Tab-Complete
|
||||||
registerServerbound(ServerboundPackets1_13.TAB_COMPLETE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.TAB_COMPLETE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -734,9 +734,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
|
|
||||||
// New 0x0A - Edit book -> Plugin Message
|
// New 0x0A - Edit book -> Plugin Message
|
||||||
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.EDIT_BOOK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -756,9 +756,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
cancelServerbound(ServerboundPackets1_13.ENTITY_NBT_REQUEST);
|
cancelServerbound(ServerboundPackets1_13.ENTITY_NBT_REQUEST);
|
||||||
|
|
||||||
// New 0x15 - Pick Item -> Plugin Message
|
// New 0x15 - Pick Item -> Plugin Message
|
||||||
registerServerbound(ServerboundPackets1_13.PICK_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.PICK_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -768,9 +768,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_13.CRAFT_RECIPE_REQUEST, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.CRAFT_RECIPE_REQUEST, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.BYTE); // Window id
|
map(Type.BYTE); // Window id
|
||||||
|
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -786,9 +786,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_13.RECIPE_BOOK_DATA, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.RECIPE_BOOK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Type
|
map(Type.VAR_INT); // 0 - Type
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -819,9 +819,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
|
|
||||||
// New 0x1C - Name Item -> Plugin Message
|
// New 0x1C - Name Item -> Plugin Message
|
||||||
registerServerbound(ServerboundPackets1_13.RENAME_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.RENAME_ITEM, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.write(Type.STRING, "MC|ItemName"); // Channel
|
wrapper.write(Type.STRING, "MC|ItemName"); // Channel
|
||||||
});
|
});
|
||||||
@ -829,9 +829,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
|
|
||||||
// New 0x1F - Select Trade -> Plugin Message
|
// New 0x1F - Select Trade -> Plugin Message
|
||||||
registerServerbound(ServerboundPackets1_13.SELECT_TRADE, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.SELECT_TRADE, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.write(Type.STRING, "MC|TrSel"); // Channel
|
wrapper.write(Type.STRING, "MC|TrSel"); // Channel
|
||||||
});
|
});
|
||||||
@ -840,9 +840,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
|
|
||||||
// New 0x20 - Set Beacon Effect -> Plugin Message
|
// New 0x20 - Set Beacon Effect -> Plugin Message
|
||||||
registerServerbound(ServerboundPackets1_13.SET_BEACON_EFFECT, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.SET_BEACON_EFFECT, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.write(Type.STRING, "MC|Beacon"); // Channel
|
wrapper.write(Type.STRING, "MC|Beacon"); // Channel
|
||||||
});
|
});
|
||||||
@ -852,9 +852,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
|
|
||||||
// New 0x22 - Update Command Block -> Plugin Message
|
// New 0x22 - Update Command Block -> Plugin Message
|
||||||
registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> wrapper.write(Type.STRING, "MC|AutoCmd"));
|
handler(wrapper -> wrapper.write(Type.STRING, "MC|AutoCmd"));
|
||||||
handler(POS_TO_3_INT);
|
handler(POS_TO_3_INT);
|
||||||
map(Type.STRING); // Command
|
map(Type.STRING); // Command
|
||||||
@ -878,9 +878,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
|
|
||||||
// New 0x23 - Update Command Block Minecart -> Plugin Message
|
// New 0x23 - Update Command Block Minecart -> Plugin Message
|
||||||
registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK_MINECART, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.UPDATE_COMMAND_BLOCK_MINECART, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -895,9 +895,9 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
// 0x1B -> 0x24 in InventoryPackets
|
// 0x1B -> 0x24 in InventoryPackets
|
||||||
|
|
||||||
// New 0x25 - Update Structure Block -> Message Channel
|
// New 0x25 - Update Structure Block -> Message Channel
|
||||||
registerServerbound(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_13.UPDATE_STRUCTURE_BLOCK, ServerboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.write(Type.STRING, "MC|Struct"); // Channel
|
wrapper.write(Type.STRING, "MC|Struct"); // Channel
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
import com.viaversion.viaversion.api.type.types.version.Types1_12;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||||
@ -35,9 +35,9 @@ public class EntityPackets {
|
|||||||
public static void register(Protocol1_13To1_12_2 protocol) {
|
public static void register(Protocol1_13To1_12_2 protocol) {
|
||||||
MetadataRewriter1_13To1_12_2 metadataRewriter = protocol.get(MetadataRewriter1_13To1_12_2.class);
|
MetadataRewriter1_13To1_12_2 metadataRewriter = protocol.get(MetadataRewriter1_13To1_12_2.class);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity id
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
map(Type.UUID); // 1 - UUID
|
map(Type.UUID); // 1 - UUID
|
||||||
map(Type.BYTE); // 2 - Type
|
map(Type.BYTE); // 2 - Type
|
||||||
@ -93,9 +93,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_MOB, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -114,9 +114,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PLAYER, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PLAYER, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Player UUID
|
map(Type.UUID); // 1 - Player UUID
|
||||||
map(Type.DOUBLE); // 2 - X
|
map(Type.DOUBLE); // 2 - X
|
||||||
@ -130,9 +130,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Entity ID
|
map(Type.INT); // 0 - Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
map(Type.INT); // 2 - Dimension
|
map(Type.INT); // 2 - Dimension
|
||||||
@ -147,9 +147,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.ENTITY_EFFECT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.ENTITY_EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
map(Type.BYTE); // Effect id
|
map(Type.BYTE); // Effect id
|
||||||
map(Type.BYTE); // Amplifier
|
map(Type.BYTE); // Amplifier
|
||||||
|
@ -31,7 +31,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
@ -59,9 +59,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPackets() {
|
public void registerPackets() {
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.SET_SLOT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.SET_SLOT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.SHORT); // 1 - Slot ID
|
map(Type.SHORT); // 1 - Slot ID
|
||||||
map(Type.ITEM, Type.FLAT_ITEM); // 2 - Slot Value
|
map(Type.ITEM, Type.FLAT_ITEM); // 2 - Slot Value
|
||||||
@ -69,18 +69,18 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
handler(itemToClientHandler(Type.FLAT_ITEM));
|
handler(itemToClientHandler(Type.FLAT_ITEM));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.WINDOW_ITEMS, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.WINDOW_ITEMS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values
|
map(Type.ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values
|
||||||
|
|
||||||
handler(itemArrayHandler(Type.FLAT_ITEM_ARRAY));
|
handler(itemArrayHandler(Type.FLAT_ITEM_ARRAY));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.WINDOW_PROPERTY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.WINDOW_PROPERTY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Window id
|
map(Type.UNSIGNED_BYTE); // Window id
|
||||||
map(Type.SHORT); // Property
|
map(Type.SHORT); // Property
|
||||||
map(Type.SHORT); // Value
|
map(Type.SHORT); // Value
|
||||||
@ -98,9 +98,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Plugin message Packet -> Trading
|
// Plugin message Packet -> Trading
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.PLUGIN_MESSAGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Channel
|
map(Type.STRING); // 0 - Channel
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -199,9 +199,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.ENTITY_EQUIPMENT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.ENTITY_EQUIPMENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.VAR_INT); // 1 - Slot ID
|
map(Type.VAR_INT); // 1 - Slot ID
|
||||||
map(Type.ITEM, Type.FLAT_ITEM); // 2 - Item
|
map(Type.ITEM, Type.FLAT_ITEM); // 2 - Item
|
||||||
@ -211,9 +211,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_13.CLICK_WINDOW, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_13.CLICK_WINDOW, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.SHORT); // 1 - Slot
|
map(Type.SHORT); // 1 - Slot
|
||||||
map(Type.BYTE); // 2 - Button
|
map(Type.BYTE); // 2 - Button
|
||||||
@ -225,9 +225,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_13.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Channel
|
map(Type.STRING); // Channel
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -260,9 +260,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_12_1, Ser
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.SHORT); // 0 - Slot
|
map(Type.SHORT); // 0 - Slot
|
||||||
map(Type.FLAT_ITEM, Type.ITEM); // 1 - Clicked Item
|
map(Type.FLAT_ITEM, Type.ITEM); // 1 - Clicked Item
|
||||||
|
|
||||||
|
@ -29,9 +29,8 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.type.types.Particle;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||||
@ -78,9 +77,9 @@ public class WorldPackets {
|
|||||||
|
|
||||||
public static void register(Protocol1_13To1_12_2 protocol) {
|
public static void register(Protocol1_13To1_12_2 protocol) {
|
||||||
// Outgoing packets
|
// Outgoing packets
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PAINTING, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PAINTING, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
|
|
||||||
@ -98,9 +97,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); // 0 - Location
|
map(Type.POSITION); // 0 - Location
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||||
map(Type.NBT); // 2 - NBT data
|
map(Type.NBT); // 2 - NBT data
|
||||||
@ -128,9 +127,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.BLOCK_ACTION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.BLOCK_ACTION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); // Location
|
map(Type.POSITION); // Location
|
||||||
map(Type.UNSIGNED_BYTE); // Action Id
|
map(Type.UNSIGNED_BYTE); // Action Id
|
||||||
map(Type.UNSIGNED_BYTE); // Action param
|
map(Type.UNSIGNED_BYTE); // Action param
|
||||||
@ -173,9 +172,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.BLOCK_CHANGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.BLOCK_CHANGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION);
|
map(Type.POSITION);
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -200,9 +199,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.MULTI_BLOCK_CHANGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Chunk X
|
map(Type.INT); // 0 - Chunk X
|
||||||
map(Type.INT); // 1 - Chunk Z
|
map(Type.INT); // 1 - Chunk Z
|
||||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records
|
map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records
|
||||||
@ -257,9 +256,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.EXPLOSION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.EXPLOSION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
if (!Via.getConfig().isServersideBlockConnections())
|
if (!Via.getConfig().isServersideBlockConnections())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -299,9 +298,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.UNLOAD_CHUNK, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.UNLOAD_CHUNK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
if (Via.getConfig().isServersideBlockConnections()) {
|
if (Via.getConfig().isServersideBlockConnections()) {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int x = wrapper.passthrough(Type.INT);
|
int x = wrapper.passthrough(Type.INT);
|
||||||
@ -312,9 +311,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.NAMED_SOUND, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.NAMED_SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING);
|
map(Type.STRING);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
String sound = wrapper.get(Type.STRING, 0).replace("minecraft:", "");
|
String sound = wrapper.get(Type.STRING, 0).replace("minecraft:", "");
|
||||||
@ -324,9 +323,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_12_1.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
BlockStorage storage = wrapper.user().get(BlockStorage.class);
|
BlockStorage storage = wrapper.user().get(BlockStorage.class);
|
||||||
@ -461,11 +460,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PARTICLE, new
|
protocol.registerClientbound(ClientboundPackets1_12_1.SPAWN_PARTICLE, new PacketHandlers() {
|
||||||
|
|
||||||
PacketRemapper() {
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Particle ID
|
map(Type.INT); // 0 - Particle ID
|
||||||
map(Type.BOOLEAN); // 1 - Long Distance
|
map(Type.BOOLEAN); // 1 - Long Distance
|
||||||
map(Type.FLOAT); // 2 - X
|
map(Type.FLOAT); // 2 - X
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_14_1to1_14.packets;
|
package com.viaversion.viaversion.protocols.protocol1_14_1to1_14.packets;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14;
|
||||||
@ -30,9 +30,9 @@ public class EntityPackets {
|
|||||||
public static void register(Protocol1_14_1To1_14 protocol) {
|
public static void register(Protocol1_14_1To1_14 protocol) {
|
||||||
MetadataRewriter1_14_1To1_14 metadataRewriter = protocol.get(MetadataRewriter1_14_1To1_14.class);
|
MetadataRewriter1_14_1To1_14 metadataRewriter = protocol.get(MetadataRewriter1_14_1To1_14.class);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -53,9 +53,9 @@ public class EntityPackets {
|
|||||||
|
|
||||||
metadataRewriter.registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES);
|
metadataRewriter.registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Player UUID
|
map(Type.UUID); // 1 - Player UUID
|
||||||
map(Type.DOUBLE); // 2 - X
|
map(Type.DOUBLE); // 2 - X
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_14_3to1_14_2;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
@ -33,9 +33,9 @@ public class Protocol1_14_3To1_14_2 extends AbstractProtocol<ClientboundPackets1
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
registerClientbound(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_14.TRADE_LIST, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
@ -33,9 +33,9 @@ public class Protocol1_14_4To1_14_3 extends AbstractProtocol<ClientboundPackets1
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
registerClientbound(ClientboundPackets1_14.TRADE_LIST, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_14.TRADE_LIST, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||||
@ -79,9 +79,9 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
};
|
};
|
||||||
commandRewriter.registerDeclareCommands(ClientboundPackets1_13.DECLARE_COMMANDS);
|
commandRewriter.registerDeclareCommands(ClientboundPackets1_13.DECLARE_COMMANDS);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_13.TAGS, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_13.TAGS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
|||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||||
@ -43,9 +43,9 @@ public class EntityPackets {
|
|||||||
public static void register(Protocol1_14To1_13_2 protocol) {
|
public static void register(Protocol1_14To1_13_2 protocol) {
|
||||||
MetadataRewriter1_14To1_13_2 metadataRewriter = protocol.get(MetadataRewriter1_14To1_13_2.class);
|
MetadataRewriter1_14To1_13_2 metadataRewriter = protocol.get(MetadataRewriter1_14To1_13_2.class);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity id
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
map(Type.UUID); // 1 - UUID
|
map(Type.UUID); // 1 - UUID
|
||||||
map(Type.BYTE, Type.VAR_INT); // 2 - Type
|
map(Type.BYTE, Type.VAR_INT); // 2 - Type
|
||||||
@ -120,9 +120,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -141,9 +141,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PAINTING, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PAINTING, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
map(Type.UUID);
|
map(Type.UUID);
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
@ -152,9 +152,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_PLAYER, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Player UUID
|
map(Type.UUID); // 1 - Player UUID
|
||||||
map(Type.DOUBLE); // 2 - X
|
map(Type.DOUBLE); // 2 - X
|
||||||
@ -168,9 +168,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_ANIMATION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.ENTITY_ANIMATION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -196,9 +196,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Entity ID
|
map(Type.INT); // 0 - Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
map(Type.INT); // 2 - Dimension
|
map(Type.INT); // 2 - Dimension
|
||||||
@ -232,9 +232,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.USE_BED, ClientboundPackets1_14.ENTITY_METADATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.USE_BED, ClientboundPackets1_14.ENTITY_METADATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
@ -69,9 +69,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
registerSetCooldown(ClientboundPackets1_13.COOLDOWN);
|
registerSetCooldown(ClientboundPackets1_13.COOLDOWN);
|
||||||
registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
registerAdvancements(ClientboundPackets1_13.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.OPEN_WINDOW, null, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.OPEN_WINDOW, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -148,9 +148,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
registerWindowItems(ClientboundPackets1_13.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
|
||||||
registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
registerSetSlot(ClientboundPackets1_13.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Channel
|
map(Type.STRING); // Channel
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -204,9 +204,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
|
||||||
RecipeRewriter<ClientboundPackets1_13> recipeRewriter = new RecipeRewriter1_13_2<>(protocol);
|
RecipeRewriter<ClientboundPackets1_13> recipeRewriter = new RecipeRewriter1_13_2<>(protocol);
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.DECLARE_RECIPES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int size = wrapper.passthrough(Type.VAR_INT);
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
int deleted = 0;
|
int deleted = 0;
|
||||||
@ -220,7 +220,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
wrapper.write(Type.STRING, type);
|
wrapper.write(Type.STRING, type);
|
||||||
wrapper.write(Type.STRING, id);
|
wrapper.write(Type.STRING, id);
|
||||||
|
|
||||||
recipeRewriter.handle(wrapper, type);
|
recipeRewriter.handleRecipeType(wrapper, type);
|
||||||
}
|
}
|
||||||
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||||
});
|
});
|
||||||
@ -230,9 +230,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_13, Serve
|
|||||||
|
|
||||||
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
registerClickWindow(ServerboundPackets1_14.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.SELECT_TRADE, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_14.SELECT_TRADE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.Position;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||||
@ -36,24 +36,24 @@ import java.util.Collections;
|
|||||||
public class PlayerPackets {
|
public class PlayerPackets {
|
||||||
|
|
||||||
public static void register(Protocol1_14To1_13_2 protocol) {
|
public static void register(Protocol1_14To1_13_2 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.OPEN_SIGN_EDITOR, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.OPEN_SIGN_EDITOR, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION, Type.POSITION1_14);
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.QUERY_BLOCK_NBT, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_14.QUERY_BLOCK_NBT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
map(Type.POSITION1_14, Type.POSITION);
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -84,17 +84,17 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.PLAYER_DIGGING, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_14.PLAYER_DIGGING, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Action
|
map(Type.VAR_INT); // Action
|
||||||
map(Type.POSITION1_14, Type.POSITION); // Position
|
map(Type.POSITION1_14, Type.POSITION); // Position
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.RECIPE_BOOK_DATA, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_14.RECIPE_BOOK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -119,28 +119,28 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.UPDATE_COMMAND_BLOCK, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_14.UPDATE_COMMAND_BLOCK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION1_14, Type.POSITION);
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.UPDATE_STRUCTURE_BLOCK, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_14.UPDATE_STRUCTURE_BLOCK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION1_14, Type.POSITION);
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.UPDATE_SIGN, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_14.UPDATE_SIGN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION1_14, Type.POSITION);
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_14.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_14.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
@ -29,7 +29,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.NibbleArray;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||||
@ -57,23 +57,23 @@ public class WorldPackets {
|
|||||||
public static void register(Protocol1_14To1_13_2 protocol) {
|
public static void register(Protocol1_14To1_13_2 protocol) {
|
||||||
BlockRewriter<ClientboundPackets1_13> blockRewriter = new BlockRewriter<>(protocol, null);
|
BlockRewriter<ClientboundPackets1_13> blockRewriter = new BlockRewriter<>(protocol, null);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_BREAK_ANIMATION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
map(Type.POSITION, Type.POSITION1_14);
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
map(Type.BYTE);
|
map(Type.BYTE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION, Type.POSITION1_14);
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_ACTION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION, Type.POSITION1_14); // Location
|
map(Type.POSITION, Type.POSITION1_14); // Location
|
||||||
map(Type.UNSIGNED_BYTE); // Action id
|
map(Type.UNSIGNED_BYTE); // Action id
|
||||||
map(Type.UNSIGNED_BYTE); // Action param
|
map(Type.UNSIGNED_BYTE); // Action param
|
||||||
@ -86,9 +86,9 @@ public class WorldPackets {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.BLOCK_CHANGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION, Type.POSITION1_14);
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -102,9 +102,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SERVER_DIFFICULTY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SERVER_DIFFICULTY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE);
|
map(Type.UNSIGNED_BYTE);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -117,9 +117,9 @@ public class WorldPackets {
|
|||||||
|
|
||||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
|
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.EXPLOSION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.EXPLOSION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.FLOAT); // X
|
map(Type.FLOAT); // X
|
||||||
map(Type.FLOAT); // Y
|
map(Type.FLOAT); // Y
|
||||||
map(Type.FLOAT); // Z
|
map(Type.FLOAT); // Z
|
||||||
@ -140,9 +140,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -271,9 +271,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Effect Id
|
map(Type.INT); // Effect Id
|
||||||
map(Type.POSITION, Type.POSITION1_14); // Location
|
map(Type.POSITION, Type.POSITION1_14); // Location
|
||||||
map(Type.INT); // Data
|
map(Type.INT); // Data
|
||||||
@ -292,9 +292,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.MAP_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.MAP_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
map(Type.BYTE);
|
map(Type.BYTE);
|
||||||
map(Type.BOOLEAN);
|
map(Type.BOOLEAN);
|
||||||
@ -307,9 +307,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Dimension ID
|
map(Type.INT); // 0 - Dimension ID
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -341,9 +341,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_POSITION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_13.SPAWN_POSITION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION, Type.POSITION1_14);
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
@ -60,9 +60,9 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
|
|
||||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_14.STATISTICS);
|
new StatisticsRewriter<>(this).register(ClientboundPackets1_14.STATISTICS);
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_14.EDIT_BOOK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> itemRewriter.handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
handler(wrapper -> itemRewriter.handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
@ -39,9 +39,9 @@ public class EntityPackets {
|
|||||||
|
|
||||||
metadataRewriter.registerTrackerWithData(ClientboundPackets1_14.SPAWN_ENTITY, Entity1_15Types.FALLING_BLOCK);
|
metadataRewriter.registerTrackerWithData(ClientboundPackets1_14.SPAWN_ENTITY, Entity1_15Types.FALLING_BLOCK);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -60,9 +60,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PLAYER, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Player UUID
|
map(Type.UUID); // 1 - Player UUID
|
||||||
map(Type.DOUBLE); // 2 - X
|
map(Type.DOUBLE); // 2 - X
|
||||||
@ -80,17 +80,17 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_14.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_14.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT);
|
map(Type.INT);
|
||||||
handler(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed
|
handler(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_14.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_14.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Entity ID
|
map(Type.INT); // 0 - Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
map(Type.INT); // 2 - Dimension
|
map(Type.INT); // 2 - Dimension
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||||
@ -41,9 +41,9 @@ public class WorldPackets {
|
|||||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_14.MULTI_BLOCK_CHANGE);
|
blockRewriter.registerMultiBlockChange(ClientboundPackets1_14.MULTI_BLOCK_CHANGE);
|
||||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
|
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_14.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -90,9 +90,9 @@ public class WorldPackets {
|
|||||||
});
|
});
|
||||||
|
|
||||||
blockRewriter.registerEffect(ClientboundPackets1_14.EFFECT, 1010, 2001);
|
blockRewriter.registerEffect(ClientboundPackets1_14.EFFECT, 1010, 2001);
|
||||||
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PARTICLE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_14.SPAWN_PARTICLE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Particle ID
|
map(Type.INT); // 0 - Particle ID
|
||||||
map(Type.BOOLEAN); // 1 - Long Distance
|
map(Type.BOOLEAN); // 1 - Long Distance
|
||||||
map(Type.FLOAT, Type.DOUBLE); // 2 - X
|
map(Type.FLOAT, Type.DOUBLE); // 2 - X
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
||||||
@ -64,9 +64,9 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
|||||||
soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND);
|
soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND);
|
||||||
|
|
||||||
// Recipe book data has been split into 2 separate packets
|
// Recipe book data has been split into 2 separate packets
|
||||||
registerServerbound(ServerboundPackets1_16_2.RECIPE_BOOK_DATA, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_16_2.RECIPE_BOOK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int recipeType = wrapper.read(Type.VAR_INT);
|
int recipeType = wrapper.read(Type.VAR_INT);
|
||||||
boolean open = wrapper.read(Type.BOOLEAN);
|
boolean open = wrapper.read(Type.BOOLEAN);
|
||||||
@ -83,9 +83,9 @@ public class Protocol1_16_2To1_16_1 extends AbstractProtocol<ClientboundPackets1
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerServerbound(ServerboundPackets1_16_2.SEEN_RECIPE, ServerboundPackets1_16.RECIPE_BOOK_DATA, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_16_2.SEEN_RECIPE, ServerboundPackets1_16.RECIPE_BOOK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
String recipe = wrapper.read(Type.STRING);
|
String recipe = wrapper.read(Type.STRING);
|
||||||
wrapper.write(Type.VAR_INT, 0); // Shown
|
wrapper.write(Type.VAR_INT, 0); // Shown
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||||
@ -37,9 +37,9 @@ public class EntityPackets {
|
|||||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_16.METADATA_LIST);
|
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_16.METADATA_LIST);
|
||||||
metadataRewriter.registerRemoveEntities(ClientboundPackets1_16.DESTROY_ENTITIES);
|
metadataRewriter.registerRemoveEntities(ClientboundPackets1_16.DESTROY_ENTITIES);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Entity ID
|
map(Type.INT); // Entity ID
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
short gamemode = wrapper.read(Type.UNSIGNED_BYTE);
|
short gamemode = wrapper.read(Type.UNSIGNED_BYTE);
|
||||||
@ -67,9 +67,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
String dimensionType = wrapper.read(Type.STRING);
|
String dimensionType = wrapper.read(Type.STRING);
|
||||||
wrapper.write(Type.NBT, getDimensionData(dimensionType));
|
wrapper.write(Type.NBT, getDimensionData(dimensionType));
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets;
|
package com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.packets;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||||
@ -40,9 +40,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_16, Serve
|
|||||||
registerEntityEquipmentArray(ClientboundPackets1_16.ENTITY_EQUIPMENT);
|
registerEntityEquipmentArray(ClientboundPackets1_16.ENTITY_EQUIPMENT);
|
||||||
registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
registerAdvancements(ClientboundPackets1_16.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16.UNLOCK_RECIPES, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16.UNLOCK_RECIPES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.passthrough(Type.VAR_INT);
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
wrapper.passthrough(Type.BOOLEAN); // Open
|
wrapper.passthrough(Type.BOOLEAN); // Open
|
||||||
@ -62,9 +62,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_16, Serve
|
|||||||
|
|
||||||
registerClickWindow(ServerboundPackets1_16_2.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
registerClickWindow(ServerboundPackets1_16_2.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||||
registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
registerCreativeInvAction(ServerboundPackets1_16_2.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||||
protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||||
@ -46,9 +46,9 @@ public class WorldPackets {
|
|||||||
blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE);
|
blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE);
|
||||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING);
|
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
Chunk chunk = wrapper.read(new Chunk1_16Type());
|
Chunk chunk = wrapper.read(new Chunk1_16Type());
|
||||||
wrapper.write(new Chunk1_16_2Type(), chunk);
|
wrapper.write(new Chunk1_16_2Type(), chunk);
|
||||||
@ -69,9 +69,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16.MULTI_BLOCK_CHANGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16.MULTI_BLOCK_CHANGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_16_4to1_16_3;
|
package com.viaversion.viaversion.protocols.protocol1_16_4to1_16_3;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||||
@ -31,9 +31,9 @@ public class Protocol1_16_4To1_16_3 extends AbstractProtocol<ClientboundPackets1
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_16_2.EDIT_BOOK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.FLAT_VAR_INT_ITEM);
|
map(Type.FLAT_VAR_INT_ITEM);
|
||||||
map(Type.BOOLEAN);
|
map(Type.BOOLEAN);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.minecraft.RegistryType;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||||
@ -77,9 +77,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS);
|
new StatisticsRewriter<>(this).register(ClientboundPackets1_15.STATISTICS);
|
||||||
|
|
||||||
// Login Success
|
// Login Success
|
||||||
registerClientbound(State.LOGIN, 0x02, 0x02, new PacketRemapper() {
|
registerClientbound(State.LOGIN, 0x02, 0x02, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Transform string to a uuid
|
// Transform string to a uuid
|
||||||
UUID uuid = UUID.fromString(wrapper.read(Type.STRING));
|
UUID uuid = UUID.fromString(wrapper.read(Type.STRING));
|
||||||
@ -89,9 +89,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Motd Status - line breaks are no longer allowed for player samples
|
// Motd Status - line breaks are no longer allowed for player samples
|
||||||
registerClientbound(State.STATUS, 0x00, 0x00, new PacketRemapper() {
|
registerClientbound(State.STATUS, 0x00, 0x00, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
String original = wrapper.passthrough(Type.STRING);
|
String original = wrapper.passthrough(Type.STRING);
|
||||||
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);
|
JsonObject object = GsonUtil.getGson().fromJson(original, JsonObject.class);
|
||||||
@ -129,9 +129,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Handle (relevant) component cases for translatable and score changes
|
// Handle (relevant) component cases for translatable and score changes
|
||||||
registerClientbound(ClientboundPackets1_15.CHAT_MESSAGE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_15.CHAT_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.COMPONENT);
|
map(Type.COMPONENT);
|
||||||
map(Type.BYTE);
|
map(Type.BYTE);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -148,9 +148,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
|
soundRewriter.registerSound(ClientboundPackets1_15.SOUND);
|
||||||
soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
|
soundRewriter.registerSound(ClientboundPackets1_15.ENTITY_SOUND);
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_16.INTERACT_ENTITY, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_16.INTERACT_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.passthrough(Type.VAR_INT); // Entity Id
|
wrapper.passthrough(Type.VAR_INT); // Entity Id
|
||||||
int action = wrapper.passthrough(Type.VAR_INT);
|
int action = wrapper.passthrough(Type.VAR_INT);
|
||||||
@ -172,9 +172,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (Via.getConfig().isIgnoreLong1_16ChannelNames()) {
|
if (Via.getConfig().isIgnoreLong1_16ChannelNames()) {
|
||||||
registerServerbound(ServerboundPackets1_16.PLUGIN_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_16.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
String channel = wrapper.passthrough(Type.STRING);
|
String channel = wrapper.passthrough(Type.STRING);
|
||||||
if (channel.length() > 32) {
|
if (channel.length() > 32) {
|
||||||
@ -209,9 +209,9 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_16.PLAYER_ABILITIES, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_16.PLAYER_ABILITIES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.passthrough(Type.BYTE);
|
wrapper.passthrough(Type.BYTE);
|
||||||
// Flying and walking speed - not important anyways
|
// Flying and walking speed - not important anyways
|
||||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
import com.viaversion.viaversion.api.minecraft.WorldIdentifiers;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16Types;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||||
@ -159,9 +159,9 @@ public class EntityPackets {
|
|||||||
MetadataRewriter1_16To1_15_2 metadataRewriter = protocol.get(MetadataRewriter1_16To1_15_2.class);
|
MetadataRewriter1_16To1_15_2 metadataRewriter = protocol.get(MetadataRewriter1_16To1_15_2.class);
|
||||||
|
|
||||||
// Spawn lightning -> Spawn entity
|
// Spawn lightning -> Spawn entity
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY, ClientboundPackets1_16.SPAWN_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.SPAWN_GLOBAL_ENTITY, ClientboundPackets1_16.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int entityId = wrapper.passthrough(Type.VAR_INT);
|
int entityId = wrapper.passthrough(Type.VAR_INT);
|
||||||
byte type = wrapper.read(Type.BYTE);
|
byte type = wrapper.read(Type.BYTE);
|
||||||
@ -195,9 +195,9 @@ public class EntityPackets {
|
|||||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST, Types1_16.METADATA_LIST);
|
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_15.ENTITY_METADATA, Types1_14.METADATA_LIST, Types1_16.METADATA_LIST);
|
||||||
metadataRewriter.registerRemoveEntities(ClientboundPackets1_15.DESTROY_ENTITIES);
|
metadataRewriter.registerRemoveEntities(ClientboundPackets1_15.DESTROY_ENTITIES);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(DIMENSION_HANDLER);
|
handler(DIMENSION_HANDLER);
|
||||||
map(Type.LONG); // Seed
|
map(Type.LONG); // Seed
|
||||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
@ -212,9 +212,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Entity ID
|
map(Type.INT); // Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -239,9 +239,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.ENTITY_PROPERTIES, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.ENTITY_PROPERTIES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.passthrough(Type.VAR_INT);
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
int size = wrapper.passthrough(Type.INT);
|
int size = wrapper.passthrough(Type.INT);
|
||||||
@ -285,9 +285,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_16.ANIMATION, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_16.ANIMATION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class);
|
InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class);
|
||||||
// Don't send an arm swing if the player has an inventory opened.
|
// Don't send an arm swing if the player has an inventory opened.
|
||||||
|
@ -27,7 +27,7 @@ import com.github.steveice10.opennbt.tag.builtin.Tag;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
|
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.RecipeRewriter1_14;
|
||||||
@ -57,9 +57,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
clearPacket.send(Protocol1_16To1_15_2.class);
|
clearPacket.send(Protocol1_16To1_15_2.class);
|
||||||
};
|
};
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.OPEN_WINDOW, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.OPEN_WINDOW, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Window Id
|
map(Type.VAR_INT); // Window Id
|
||||||
map(Type.VAR_INT); // Window Type
|
map(Type.VAR_INT); // Window Type
|
||||||
map(Type.COMPONENT); // Window Title
|
map(Type.COMPONENT); // Window Title
|
||||||
@ -77,9 +77,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.CLOSE_WINDOW, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.CLOSE_WINDOW, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(cursorRemapper);
|
handler(cursorRemapper);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class);
|
InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class);
|
||||||
@ -88,9 +88,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.WINDOW_PROPERTY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.WINDOW_PROPERTY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Window Id
|
map(Type.UNSIGNED_BYTE); // Window Id
|
||||||
map(Type.SHORT); // Property
|
map(Type.SHORT); // Property
|
||||||
map(Type.SHORT); // Value
|
map(Type.SHORT); // Value
|
||||||
@ -113,9 +113,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
registerSetSlot(ClientboundPackets1_15.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
|
||||||
registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
registerAdvancements(ClientboundPackets1_15.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.ENTITY_EQUIPMENT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.ENTITY_EQUIPMENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -131,9 +131,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
|
||||||
registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_16.CLOSE_WINDOW, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_16.CLOSE_WINDOW, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class);
|
InventoryTracker1_16 inventoryTracker = wrapper.user().get(InventoryTracker1_16.class);
|
||||||
inventoryTracker.setInventory((short) -1);
|
inventoryTracker.setInventory((short) -1);
|
||||||
@ -141,9 +141,9 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_15, Serve
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_16.EDIT_BOOK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
|
import com.viaversion.viaversion.api.type.types.UUIDIntArrayType;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||||
@ -51,18 +51,18 @@ public class WorldPackets {
|
|||||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
|
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
|
||||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);
|
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.UPDATE_LIGHT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.UPDATE_LIGHT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // x
|
map(Type.VAR_INT); // x
|
||||||
map(Type.VAR_INT); // y
|
map(Type.VAR_INT); // y
|
||||||
handler(wrapper -> wrapper.write(Type.BOOLEAN, true)); // Take neighbour's light into account as well
|
handler(wrapper -> wrapper.write(Type.BOOLEAN, true)); // Take neighbour's light into account as well
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
Chunk chunk = wrapper.read(new Chunk1_15Type());
|
Chunk chunk = wrapper.read(new Chunk1_15Type());
|
||||||
wrapper.write(new Chunk1_16Type(), chunk);
|
wrapper.write(new Chunk1_16Type(), chunk);
|
||||||
@ -98,9 +98,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_15.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_15.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
Position position = wrapper.passthrough(Type.POSITION1_14);
|
Position position = wrapper.passthrough(Type.POSITION1_14);
|
||||||
short action = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
short action = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||||
|
@ -23,7 +23,7 @@ import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.StringType;
|
import com.viaversion.viaversion.api.type.types.StringType;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
|
||||||
@ -40,9 +40,9 @@ public final class Protocol1_17_1To1_17 extends AbstractProtocol<ClientboundPack
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
registerClientbound(ClientboundPackets1_17.REMOVE_ENTITY, ClientboundPackets1_17_1.REMOVE_ENTITIES, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_17.REMOVE_ENTITY, ClientboundPackets1_17_1.REMOVE_ENTITIES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Aaaaand back to an array again!
|
// Aaaaand back to an array again!
|
||||||
int entityId = wrapper.read(Type.VAR_INT);
|
int entityId = wrapper.read(Type.VAR_INT);
|
||||||
@ -51,17 +51,17 @@ public final class Protocol1_17_1To1_17 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_17.SET_SLOT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_17.SET_SLOT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Container id
|
map(Type.UNSIGNED_BYTE); // Container id
|
||||||
create(Type.VAR_INT, 0); // Add arbitrary state id
|
create(Type.VAR_INT, 0); // Add arbitrary state id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_17.WINDOW_ITEMS, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_17.WINDOW_ITEMS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Container id
|
map(Type.UNSIGNED_BYTE); // Container id
|
||||||
create(Type.VAR_INT, 0); // Add arbitrary state id
|
create(Type.VAR_INT, 0); // Add arbitrary state id
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -74,17 +74,17 @@ public final class Protocol1_17_1To1_17 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Container id
|
map(Type.UNSIGNED_BYTE); // Container id
|
||||||
read(Type.VAR_INT); // Remove state id
|
read(Type.VAR_INT); // Remove state id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_17.EDIT_BOOK, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_17.EDIT_BOOK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
Item item = new DataItem(942, (byte) 1, (short) 0, tag); // Magic value for writable books
|
Item item = new DataItem(942, (byte) 1, (short) 0, tag); // Magic value for writable books
|
||||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.minecraft.RegistryType;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||||
@ -59,9 +59,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
|||||||
|
|
||||||
WorldPackets.register(this);
|
WorldPackets.register(this);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_16_2.TAGS, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_16_2.TAGS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Tags are now generically written with resource location - 5 different Vanilla types
|
// Tags are now generically written with resource location - 5 different Vanilla types
|
||||||
wrapper.write(Type.VAR_INT, 5);
|
wrapper.write(Type.VAR_INT, 5);
|
||||||
@ -95,9 +95,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
|||||||
soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND);
|
soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND);
|
||||||
soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND);
|
soundRewriter.registerSound(ClientboundPackets1_16_2.ENTITY_SOUND);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_16_2.RESOURCE_PACK, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_16_2.RESOURCE_PACK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.passthrough(Type.STRING);
|
wrapper.passthrough(Type.STRING);
|
||||||
wrapper.passthrough(Type.STRING);
|
wrapper.passthrough(Type.STRING);
|
||||||
@ -107,9 +107,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_16_2.MAP_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_16_2.MAP_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.passthrough(Type.VAR_INT);
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
wrapper.passthrough(Type.BYTE);
|
wrapper.passthrough(Type.BYTE);
|
||||||
@ -128,9 +128,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_16_2.TITLE, null, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_16_2.TITLE, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Title packet actions have been split into individual packets (the content hasn't changed)
|
// Title packet actions have been split into individual packets (the content hasn't changed)
|
||||||
int type = wrapper.read(Type.VAR_INT);
|
int type = wrapper.read(Type.VAR_INT);
|
||||||
@ -165,9 +165,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_16_2.EXPLOSION, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_16_2.EXPLOSION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.FLOAT); // X
|
map(Type.FLOAT); // X
|
||||||
map(Type.FLOAT); // Y
|
map(Type.FLOAT); // Y
|
||||||
map(Type.FLOAT); // Z
|
map(Type.FLOAT); // Z
|
||||||
@ -179,9 +179,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_16_2.SPAWN_POSITION, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_16_2.SPAWN_POSITION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION1_14);
|
map(Type.POSITION1_14);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Angle (which Mojang just forgot to write to the buffer, lol)
|
// Angle (which Mojang just forgot to write to the buffer, lol)
|
||||||
@ -190,9 +190,9 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Locale
|
map(Type.STRING); // Locale
|
||||||
map(Type.BYTE); // View distance
|
map(Type.BYTE); // View distance
|
||||||
map(Type.VAR_INT); // Chat mode
|
map(Type.VAR_INT); // Chat mode
|
||||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||||
@ -50,9 +50,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
registerTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_17Types.PLAYER);
|
registerTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_17Types.PLAYER);
|
||||||
registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_16.METADATA_LIST, Types1_17.METADATA_LIST);
|
registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_16.METADATA_LIST, Types1_17.METADATA_LIST);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.DESTROY_ENTITIES, null, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.DESTROY_ENTITIES, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int[] entityIds = wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE);
|
int[] entityIds = wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
@ -70,9 +70,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Entity ID
|
map(Type.INT); // Entity ID
|
||||||
map(Type.BOOLEAN); // Hardcore
|
map(Type.BOOLEAN); // Hardcore
|
||||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
@ -96,9 +96,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
CompoundTag dimensionData = wrapper.passthrough(Type.NBT);
|
CompoundTag dimensionData = wrapper.passthrough(Type.NBT);
|
||||||
addNewDimensionData(dimensionData);
|
addNewDimensionData(dimensionData);
|
||||||
@ -106,9 +106,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.ENTITY_PROPERTIES, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.ENTITY_PROPERTIES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Collection length is now a var int
|
// Collection length is now a var int
|
||||||
@ -117,9 +117,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.PLAYER_POSITION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.PLAYER_POSITION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.DOUBLE);
|
map(Type.DOUBLE);
|
||||||
map(Type.DOUBLE);
|
map(Type.DOUBLE);
|
||||||
map(Type.DOUBLE);
|
map(Type.DOUBLE);
|
||||||
@ -134,9 +134,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.COMBAT_EVENT, null, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.COMBAT_EVENT, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Combat packet actions have been split into individual packets (the content hasn't changed)
|
// Combat packet actions have been split into individual packets (the content hasn't changed)
|
||||||
int type = wrapper.read(Type.VAR_INT);
|
int type = wrapper.read(Type.VAR_INT);
|
||||||
|
@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
|
||||||
@ -50,16 +50,16 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_16_
|
|||||||
|
|
||||||
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_17.EDIT_BOOK, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_17.EDIT_BOOK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Window Id
|
map(Type.UNSIGNED_BYTE); // Window Id
|
||||||
map(Type.SHORT); // Slot
|
map(Type.SHORT); // Slot
|
||||||
map(Type.BYTE); // Button
|
map(Type.BYTE); // Button
|
||||||
@ -92,9 +92,9 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_16_
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.WINDOW_CONFIRMATION, null, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.WINDOW_CONFIRMATION, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
short inventoryId = wrapper.read(Type.UNSIGNED_BYTE);
|
short inventoryId = wrapper.read(Type.UNSIGNED_BYTE);
|
||||||
short confirmationId = wrapper.read(Type.SHORT);
|
short confirmationId = wrapper.read(Type.SHORT);
|
||||||
@ -115,9 +115,9 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_16_
|
|||||||
});
|
});
|
||||||
|
|
||||||
// New pong packet
|
// New pong packet
|
||||||
protocol.registerServerbound(ServerboundPackets1_17.PONG, null, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_17.PONG, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int id = wrapper.read(Type.INT);
|
int id = wrapper.read(Type.INT);
|
||||||
// Check extra bit for fast dismissal
|
// Check extra bit for fast dismissal
|
||||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.types.Chunk1_16_2Type;
|
||||||
@ -48,9 +48,9 @@ public final class WorldPackets {
|
|||||||
blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_16_2.MULTI_BLOCK_CHANGE);
|
blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_16_2.MULTI_BLOCK_CHANGE);
|
||||||
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16_2.ACKNOWLEDGE_PLAYER_DIGGING);
|
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16_2.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.WORLD_BORDER, null, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.WORLD_BORDER, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Border packet actions have been split into individual packets (the content hasn't changed)
|
// Border packet actions have been split into individual packets (the content hasn't changed)
|
||||||
int type = wrapper.read(Type.VAR_INT);
|
int type = wrapper.read(Type.VAR_INT);
|
||||||
@ -83,9 +83,9 @@ public final class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.UPDATE_LIGHT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.UPDATE_LIGHT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // x
|
map(Type.VAR_INT); // x
|
||||||
map(Type.VAR_INT); // y
|
map(Type.VAR_INT); // y
|
||||||
map(Type.BOOLEAN); // trust edges
|
map(Type.BOOLEAN); // trust edges
|
||||||
@ -127,9 +127,9 @@ public final class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
Chunk chunk = wrapper.read(new Chunk1_16_2Type());
|
Chunk chunk = wrapper.read(new Chunk1_16_2Type());
|
||||||
if (!chunk.isFullChunk()) {
|
if (!chunk.isFullChunk()) {
|
||||||
|
@ -23,7 +23,7 @@ import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||||
@ -41,25 +41,25 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol<ClientboundPack
|
|||||||
tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:fall_damage_resetting");
|
tagRewriter.addEmptyTag(RegistryType.BLOCK, "minecraft:fall_damage_resetting");
|
||||||
tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS);
|
tagRewriter.registerGeneric(ClientboundPackets1_18.TAGS);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_18.ENTITY_EFFECT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.ENTITY_EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
map(Type.BYTE, Type.VAR_INT); // Effect id
|
map(Type.BYTE, Type.VAR_INT); // Effect id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_18.REMOVE_ENTITY_EFFECT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.REMOVE_ENTITY_EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
map(Type.BYTE, Type.VAR_INT); // Effect id
|
map(Type.BYTE, Type.VAR_INT); // Effect id
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Entity ID
|
map(Type.INT); // Entity ID
|
||||||
map(Type.BOOLEAN); // Hardcore
|
map(Type.BOOLEAN); // Hardcore
|
||||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
@ -80,9 +80,9 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> addTagPrefix(wrapper.passthrough(Type.NBT)));
|
handler(wrapper -> addTagPrefix(wrapper.passthrough(Type.NBT)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
|||||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
||||||
@ -67,9 +67,9 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
|||||||
|
|
||||||
new StatisticsRewriter<>(this).register(ClientboundPackets1_17_1.STATISTICS);
|
new StatisticsRewriter<>(this).register(ClientboundPackets1_17_1.STATISTICS);
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_17.CLIENT_SETTINGS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Language
|
map(Type.STRING); // Language
|
||||||
map(Type.BYTE); // View distance
|
map(Type.BYTE); // View distance
|
||||||
map(Type.VAR_INT); // Chat visibility
|
map(Type.VAR_INT); // Chat visibility
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets;
|
|||||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.type.types.Particle;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||||
@ -40,9 +40,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1
|
|||||||
public void registerPackets() {
|
public void registerPackets() {
|
||||||
registerMetadataRewriter(ClientboundPackets1_17_1.ENTITY_METADATA, Types1_17.METADATA_LIST, Types1_18.METADATA_LIST);
|
registerMetadataRewriter(ClientboundPackets1_17_1.ENTITY_METADATA, Types1_17.METADATA_LIST, Types1_18.METADATA_LIST);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_17_1.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_17_1.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Entity ID
|
map(Type.INT); // Entity ID
|
||||||
map(Type.BOOLEAN); // Hardcore
|
map(Type.BOOLEAN); // Hardcore
|
||||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
@ -62,9 +62,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_17_1.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_17_1.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.NBT); // Current dimension data
|
map(Type.NBT); // Current dimension data
|
||||||
map(Type.STRING); // World
|
map(Type.STRING); // World
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets;
|
package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.data.ParticleMappings;
|
import com.viaversion.viaversion.api.data.ParticleMappings;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||||
@ -41,9 +41,9 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_17_
|
|||||||
registerAdvancements(ClientboundPackets1_17_1.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
registerAdvancements(ClientboundPackets1_17_1.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||||
registerEntityEquipmentArray(ClientboundPackets1_17_1.ENTITY_EQUIPMENT);
|
registerEntityEquipmentArray(ClientboundPackets1_17_1.ENTITY_EQUIPMENT);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_17_1.EFFECT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_17_1.EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Effect id
|
map(Type.INT); // Effect id
|
||||||
map(Type.POSITION1_14); // Location
|
map(Type.POSITION1_14); // Location
|
||||||
map(Type.INT); // Data
|
map(Type.INT); // Data
|
||||||
@ -57,9 +57,9 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_17_
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_17_1.SPAWN_PARTICLE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_17_1.SPAWN_PARTICLE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Particle id
|
map(Type.INT); // Particle id
|
||||||
map(Type.BOOLEAN); // Override limiter
|
map(Type.BOOLEAN); // Override limiter
|
||||||
map(Type.DOUBLE); // X
|
map(Type.DOUBLE); // X
|
||||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
|||||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity;
|
||||||
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntityImpl;
|
import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntityImpl;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.*;
|
import com.viaversion.viaversion.api.minecraft.chunks.*;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
|
||||||
@ -43,9 +43,9 @@ import java.util.List;
|
|||||||
public final class WorldPackets {
|
public final class WorldPackets {
|
||||||
|
|
||||||
public static void register(final Protocol1_18To1_17_1 protocol) {
|
public static void register(final Protocol1_18To1_17_1 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_17_1.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_17_1.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION1_14);
|
map(Type.POSITION1_14);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final short id = wrapper.read(Type.UNSIGNED_BYTE);
|
final short id = wrapper.read(Type.UNSIGNED_BYTE);
|
||||||
@ -57,9 +57,9 @@ public final class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_17_1.UPDATE_LIGHT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_17_1.UPDATE_LIGHT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int chunkX = wrapper.passthrough(Type.VAR_INT);
|
final int chunkX = wrapper.passthrough(Type.VAR_INT);
|
||||||
final int chunkZ = wrapper.passthrough(Type.VAR_INT);
|
final int chunkZ = wrapper.passthrough(Type.VAR_INT);
|
||||||
@ -101,9 +101,9 @@ public final class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_17_1.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_17_1.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
||||||
final Chunk oldChunk = wrapper.read(new Chunk1_17Type(tracker.currentWorldSectionHeight()));
|
final Chunk oldChunk = wrapper.read(new Chunk1_17Type(tracker.currentWorldSectionHeight()));
|
||||||
@ -199,9 +199,9 @@ public final class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_17_1.UNLOAD_CHUNK, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_17_1.UNLOAD_CHUNK, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int chunkX = wrapper.passthrough(Type.INT);
|
final int chunkX = wrapper.passthrough(Type.INT);
|
||||||
final int chunkZ = wrapper.passthrough(Type.INT);
|
final int chunkZ = wrapper.passthrough(Type.INT);
|
||||||
|
@ -31,7 +31,7 @@ import com.viaversion.viaversion.api.minecraft.ProfileKey;
|
|||||||
import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO;
|
import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO;
|
||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.libs.kyori.adventure.text.Component;
|
import com.viaversion.viaversion.libs.kyori.adventure.text.Component;
|
||||||
import com.viaversion.viaversion.libs.kyori.adventure.text.TranslatableComponent;
|
import com.viaversion.viaversion.libs.kyori.adventure.text.TranslatableComponent;
|
||||||
@ -97,9 +97,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
registerClientbound(ClientboundPackets1_19.SYSTEM_CHAT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_19.SYSTEM_CHAT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.COMPONENT); // Content
|
map(Type.COMPONENT); // Content
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int type = wrapper.read(Type.VAR_INT);
|
final int type = wrapper.read(Type.VAR_INT);
|
||||||
@ -108,9 +108,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_19.PLAYER_CHAT, ClientboundPackets1_19_1.SYSTEM_CHAT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_19.PLAYER_CHAT, ClientboundPackets1_19_1.SYSTEM_CHAT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Back to system chat
|
// Back to system chat
|
||||||
final JsonElement signedContent = wrapper.read(Type.COMPONENT);
|
final JsonElement signedContent = wrapper.read(Type.COMPONENT);
|
||||||
@ -135,9 +135,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
read(Type.BYTE_ARRAY_PRIMITIVE); // Signature
|
read(Type.BYTE_ARRAY_PRIMITIVE); // Signature
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerServerbound(ServerboundPackets1_19_1.CHAT_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_19_1.CHAT_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Message
|
map(Type.STRING); // Message
|
||||||
map(Type.LONG); // Timestamp
|
map(Type.LONG); // Timestamp
|
||||||
map(Type.LONG); // Salt
|
map(Type.LONG); // Salt
|
||||||
@ -147,9 +147,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
read(Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE); // Last received message
|
read(Type.OPTIONAL_PLAYER_MESSAGE_SIGNATURE); // Last received message
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerServerbound(ServerboundPackets1_19_1.CHAT_COMMAND, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_19_1.CHAT_COMMAND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Command
|
map(Type.STRING); // Command
|
||||||
map(Type.LONG); // Timestamp
|
map(Type.LONG); // Timestamp
|
||||||
map(Type.LONG); // Salt
|
map(Type.LONG); // Salt
|
||||||
@ -167,9 +167,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
});
|
});
|
||||||
cancelServerbound(ServerboundPackets1_19_1.CHAT_ACK);
|
cancelServerbound(ServerboundPackets1_19_1.CHAT_ACK);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_19.JOIN_GAME, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_19.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Entity ID
|
map(Type.INT); // Entity ID
|
||||||
map(Type.BOOLEAN); // Hardcore
|
map(Type.BOOLEAN); // Hardcore
|
||||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
@ -193,9 +193,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_19.SERVER_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_19.SERVER_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.OPTIONAL_COMPONENT); // Motd
|
map(Type.OPTIONAL_COMPONENT); // Motd
|
||||||
map(Type.OPTIONAL_STRING); // Encoded icon
|
map(Type.OPTIONAL_STRING); // Encoded icon
|
||||||
map(Type.BOOLEAN); // Previews chat
|
map(Type.BOOLEAN); // Previews chat
|
||||||
@ -203,9 +203,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Name
|
map(Type.STRING); // Name
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Profile keys are not compatible; replace it with an empty one
|
// Profile keys are not compatible; replace it with an empty one
|
||||||
@ -219,9 +219,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
read(Type.OPTIONAL_UUID); // Profile uuid
|
read(Type.OPTIONAL_UUID); // Profile uuid
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Server id
|
map(Type.STRING); // Server id
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
if (wrapper.user().has(NonceStorage.class)) {
|
if (wrapper.user().has(NonceStorage.class)) {
|
||||||
@ -234,9 +234,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Keys
|
map(Type.BYTE_ARRAY_PRIMITIVE); // Keys
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final NonceStorage nonceStorage = wrapper.user().remove(NonceStorage.class);
|
final NonceStorage nonceStorage = wrapper.user().remove(NonceStorage.class);
|
||||||
@ -254,9 +254,9 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY.getId(), ClientboundLoginPackets.CUSTOM_QUERY.getId(), new PacketRemapper() {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.CUSTOM_QUERY.getId(), ClientboundLoginPackets.CUSTOM_QUERY.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
map(Type.STRING);
|
map(Type.STRING);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.BitSetType;
|
import com.viaversion.viaversion.api.type.types.BitSetType;
|
||||||
import com.viaversion.viaversion.api.type.types.ByteArrayType;
|
import com.viaversion.viaversion.api.type.types.ByteArrayType;
|
||||||
@ -79,9 +79,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
|||||||
itemRewriter.register();
|
itemRewriter.register();
|
||||||
|
|
||||||
final SoundRewriter<ClientboundPackets1_19_1> soundRewriter = new SoundRewriter<>(this);
|
final SoundRewriter<ClientboundPackets1_19_1> soundRewriter = new SoundRewriter<>(this);
|
||||||
registerClientbound(ClientboundPackets1_19_1.ENTITY_SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_19_1.ENTITY_SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Sound id
|
map(Type.VAR_INT); // Sound id
|
||||||
handler(soundRewriter.getSoundHandler());
|
handler(soundRewriter.getSoundHandler());
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -91,9 +91,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_19_1.SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_19_1.SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Sound id
|
map(Type.VAR_INT); // Sound id
|
||||||
handler(soundRewriter.getSoundHandler());
|
handler(soundRewriter.getSoundHandler());
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -103,9 +103,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_19_1.NAMED_SOUND, ClientboundPackets1_19_3.SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_19_1.NAMED_SOUND, ClientboundPackets1_19_3.SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.write(Type.VAR_INT, 0);
|
wrapper.write(Type.VAR_INT, 0);
|
||||||
wrapper.passthrough(Type.STRING); // Sound identifier
|
wrapper.passthrough(Type.STRING); // Sound identifier
|
||||||
@ -152,9 +152,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
|||||||
};
|
};
|
||||||
commandRewriter.registerDeclareCommands1_19(ClientboundPackets1_19_1.DECLARE_COMMANDS);
|
commandRewriter.registerDeclareCommands1_19(ClientboundPackets1_19_1.DECLARE_COMMANDS);
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_19_1.SERVER_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_19_1.SERVER_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.OPTIONAL_COMPONENT); // Motd
|
map(Type.OPTIONAL_COMPONENT); // Motd
|
||||||
map(Type.OPTIONAL_STRING); // Encoded icon
|
map(Type.OPTIONAL_STRING); // Encoded icon
|
||||||
read(Type.BOOLEAN); // Remove previews chat
|
read(Type.BOOLEAN); // Remove previews chat
|
||||||
@ -162,9 +162,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Aaaaand once more
|
// Aaaaand once more
|
||||||
registerClientbound(ClientboundPackets1_19_1.PLAYER_CHAT, ClientboundPackets1_19_3.DISGUISED_CHAT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_19_1.PLAYER_CHAT, ClientboundPackets1_19_3.DISGUISED_CHAT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
read(Type.OPTIONAL_BYTE_ARRAY_PRIMITIVE); // Previous signature
|
read(Type.OPTIONAL_BYTE_ARRAY_PRIMITIVE); // Previous signature
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final PlayerMessageSignature signature = wrapper.read(Type.PLAYER_MESSAGE_SIGNATURE);
|
final PlayerMessageSignature signature = wrapper.read(Type.PLAYER_MESSAGE_SIGNATURE);
|
||||||
@ -210,9 +210,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_19_3.CHAT_COMMAND, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_19_3.CHAT_COMMAND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Command
|
map(Type.STRING); // Command
|
||||||
map(Type.LONG); // Timestamp
|
map(Type.LONG); // Timestamp
|
||||||
map(Type.LONG); // Salt
|
map(Type.LONG); // Salt
|
||||||
@ -235,9 +235,9 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
|||||||
read(ACKNOWLEDGED_BIT_SET_TYPE); // Acknowledged
|
read(ACKNOWLEDGED_BIT_SET_TYPE); // Acknowledged
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerServerbound(ServerboundPackets1_19_3.CHAT_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_19_3.CHAT_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Command
|
map(Type.STRING); // Command
|
||||||
map(Type.LONG); // Timestamp
|
map(Type.LONG); // Timestamp
|
||||||
// Salt
|
// Salt
|
||||||
@ -260,16 +260,16 @@ public final class Protocol1_19_3To1_19_1 extends AbstractProtocol<ClientboundPa
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Remove the key once again
|
// Remove the key once again
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Name
|
map(Type.STRING); // Name
|
||||||
create(Type.OPTIONAL_PROFILE_KEY, null);
|
create(Type.OPTIONAL_PROFILE_KEY, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Keys
|
map(Type.BYTE_ARRAY_PRIMITIVE); // Keys
|
||||||
create(Type.BOOLEAN, true); // Is nonce
|
create(Type.BOOLEAN, true); // Is nonce
|
||||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Encrypted challenge
|
map(Type.BYTE_ARRAY_PRIMITIVE); // Encrypted challenge
|
||||||
|
@ -21,7 +21,7 @@ import com.google.gson.JsonElement;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.BitSetType;
|
import com.viaversion.viaversion.api.type.types.BitSetType;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||||
@ -48,9 +48,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1
|
|||||||
registerMetadataRewriter(ClientboundPackets1_19_1.ENTITY_METADATA, Types1_19.METADATA_LIST, Types1_19_3.METADATA_LIST);
|
registerMetadataRewriter(ClientboundPackets1_19_1.ENTITY_METADATA, Types1_19.METADATA_LIST, Types1_19_3.METADATA_LIST);
|
||||||
registerRemoveEntities(ClientboundPackets1_19_1.REMOVE_ENTITIES);
|
registerRemoveEntities(ClientboundPackets1_19_1.REMOVE_ENTITIES);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_19_1.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_19_1.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Entity id
|
map(Type.INT); // Entity id
|
||||||
map(Type.BOOLEAN); // Hardcore
|
map(Type.BOOLEAN); // Hardcore
|
||||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
@ -72,9 +72,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_19_1.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_19_1.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Dimension
|
map(Type.STRING); // Dimension
|
||||||
map(Type.STRING); // World
|
map(Type.STRING); // World
|
||||||
map(Type.LONG); // Seed
|
map(Type.LONG); // Seed
|
||||||
@ -94,9 +94,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_19_1.PLAYER_INFO, ClientboundPackets1_19_3.PLAYER_INFO_UPDATE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_19_1.PLAYER_INFO, ClientboundPackets1_19_3.PLAYER_INFO_UPDATE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int action = wrapper.read(Type.VAR_INT);
|
final int action = wrapper.read(Type.VAR_INT);
|
||||||
if (action == 4) { // Remove player
|
if (action == 4) { // Remove player
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.packets;
|
package com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.packets;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
||||||
@ -58,9 +58,9 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_19_
|
|||||||
registerSpawnParticle1_19(ClientboundPackets1_19_1.SPAWN_PARTICLE);
|
registerSpawnParticle1_19(ClientboundPackets1_19_1.SPAWN_PARTICLE);
|
||||||
|
|
||||||
final RecipeRewriter1_16<ClientboundPackets1_19_1> recipeRewriter = new RecipeRewriter1_16<>(protocol);
|
final RecipeRewriter1_16<ClientboundPackets1_19_1> recipeRewriter = new RecipeRewriter1_16<>(protocol);
|
||||||
protocol.registerClientbound(ClientboundPackets1_19_1.DECLARE_RECIPES, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_19_1.DECLARE_RECIPES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int size = wrapper.passthrough(Type.VAR_INT);
|
final int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@ -123,7 +123,7 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_19_
|
|||||||
wrapper.write(Type.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY);
|
wrapper.write(Type.VAR_INT, MISC_CRAFTING_BOOK_CATEGORY);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
recipeRewriter.handle(wrapper, type);
|
recipeRewriter.handleRecipeType(wrapper, type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,9 +131,9 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_19_
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_19_1.EXPLOSION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_19_1.EXPLOSION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.FLOAT, Type.DOUBLE); // X
|
map(Type.FLOAT, Type.DOUBLE); // X
|
||||||
map(Type.FLOAT, Type.DOUBLE); // Y
|
map(Type.FLOAT, Type.DOUBLE); // Y
|
||||||
map(Type.FLOAT, Type.DOUBLE); // Z
|
map(Type.FLOAT, Type.DOUBLE); // Z
|
||||||
|
@ -24,7 +24,7 @@ import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
|||||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_3;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19_3;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
||||||
@ -41,9 +41,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPackets() {
|
public void registerPackets() {
|
||||||
protocol.registerClientbound(ClientboundPackets1_19_3.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_19_3.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Entity id
|
map(Type.INT); // Entity id
|
||||||
map(Type.BOOLEAN); // Hardcore
|
map(Type.BOOLEAN); // Hardcore
|
||||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
@ -72,9 +72,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_19_3.ENTITY_ANIMATION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_19_3.ENTITY_ANIMATION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final short action = wrapper.read(Type.UNSIGNED_BYTE);
|
final short action = wrapper.read(Type.UNSIGNED_BYTE);
|
||||||
@ -89,18 +89,18 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_19_3.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_19_3.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Dimension
|
map(Type.STRING); // Dimension
|
||||||
map(Type.STRING); // World
|
map(Type.STRING); // World
|
||||||
handler(worldDataTrackerHandlerByKey());
|
handler(worldDataTrackerHandlerByKey());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_19_3.ENTITY_STATUS, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_19_3.ENTITY_STATUS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int entityId = wrapper.read(Type.INT);
|
final int entityId = wrapper.read(Type.INT);
|
||||||
final byte event = wrapper.read(Type.BYTE);
|
final byte event = wrapper.read(Type.BYTE);
|
||||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
import com.viaversion.viaversion.api.type.types.minecraft.ParticleType;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||||
@ -77,9 +77,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
|||||||
cancelClientbound(ClientboundPackets1_18.ADD_VIBRATION_SIGNAL);
|
cancelClientbound(ClientboundPackets1_18.ADD_VIBRATION_SIGNAL);
|
||||||
|
|
||||||
final SoundRewriter<ClientboundPackets1_18> soundRewriter = new SoundRewriter<>(this);
|
final SoundRewriter<ClientboundPackets1_18> soundRewriter = new SoundRewriter<>(this);
|
||||||
registerClientbound(ClientboundPackets1_18.SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Sound id
|
map(Type.VAR_INT); // Sound id
|
||||||
map(Type.VAR_INT); // Source
|
map(Type.VAR_INT); // Source
|
||||||
map(Type.INT); // X
|
map(Type.INT); // X
|
||||||
@ -91,9 +91,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
|||||||
handler(soundRewriter.getSoundHandler());
|
handler(soundRewriter.getSoundHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_18.ENTITY_SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.ENTITY_SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Sound id
|
map(Type.VAR_INT); // Sound id
|
||||||
map(Type.VAR_INT); // Source
|
map(Type.VAR_INT); // Source
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
@ -103,9 +103,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
|||||||
handler(soundRewriter.getSoundHandler());
|
handler(soundRewriter.getSoundHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_18.NAMED_SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.NAMED_SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Sound name
|
map(Type.STRING); // Sound name
|
||||||
map(Type.VAR_INT); // Source
|
map(Type.VAR_INT); // Source
|
||||||
map(Type.INT); // X
|
map(Type.INT); // X
|
||||||
@ -127,23 +127,23 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
|||||||
wrapper.write(Type.COMPONENT, GsonComponentSerializer.gson().serializeToTree(Component.empty()));
|
wrapper.write(Type.COMPONENT, GsonComponentSerializer.gson().serializeToTree(Component.empty()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
registerClientbound(ClientboundPackets1_18.TITLE_TEXT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.TITLE_TEXT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(titleHandler);
|
handler(titleHandler);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerClientbound(ClientboundPackets1_18.TITLE_SUBTITLE, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.TITLE_SUBTITLE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(titleHandler);
|
handler(titleHandler);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final CommandRewriter<ClientboundPackets1_18> commandRewriter = new CommandRewriter<>(this);
|
final CommandRewriter<ClientboundPackets1_18> commandRewriter = new CommandRewriter<>(this);
|
||||||
registerClientbound(ClientboundPackets1_18.DECLARE_COMMANDS, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.DECLARE_COMMANDS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int size = wrapper.passthrough(Type.VAR_INT);
|
final int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@ -180,9 +180,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Make every message a system message, including player ones; we don't want to analyze and remove player names from the original component
|
// Make every message a system message, including player ones; we don't want to analyze and remove player names from the original component
|
||||||
registerClientbound(ClientboundPackets1_18.CHAT_MESSAGE, ClientboundPackets1_19.SYSTEM_CHAT, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_18.CHAT_MESSAGE, ClientboundPackets1_19.SYSTEM_CHAT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.COMPONENT); // Message
|
map(Type.COMPONENT); // Message
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int type = wrapper.read(Type.BYTE);
|
final int type = wrapper.read(Type.BYTE);
|
||||||
@ -192,9 +192,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(ServerboundPackets1_19.CHAT_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_19.CHAT_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Message
|
map(Type.STRING); // Message
|
||||||
read(Type.LONG); // Timestamp
|
read(Type.LONG); // Timestamp
|
||||||
read(Type.LONG); // Salt
|
read(Type.LONG); // Salt
|
||||||
@ -202,9 +202,9 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
|||||||
read(Type.BOOLEAN); // Signed preview
|
read(Type.BOOLEAN); // Signed preview
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerServerbound(ServerboundPackets1_19.CHAT_COMMAND, ServerboundPackets1_17.CHAT_MESSAGE, new PacketRemapper() {
|
registerServerbound(ServerboundPackets1_19.CHAT_COMMAND, ServerboundPackets1_17.CHAT_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Command
|
map(Type.STRING); // Command
|
||||||
read(Type.LONG); // Timestamp
|
read(Type.LONG); // Timestamp
|
||||||
read(Type.LONG); // Salt
|
read(Type.LONG); // Salt
|
||||||
@ -224,18 +224,18 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
|||||||
cancelServerbound(ServerboundPackets1_19.CHAT_PREVIEW);
|
cancelServerbound(ServerboundPackets1_19.CHAT_PREVIEW);
|
||||||
|
|
||||||
// Login changes
|
// Login changes
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketRemapper() {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.GAME_PROFILE.getId(), ClientboundLoginPackets.GAME_PROFILE.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UUID); // UUID
|
map(Type.UUID); // UUID
|
||||||
map(Type.STRING); // Name
|
map(Type.STRING); // Name
|
||||||
create(Type.VAR_INT, 0); // No properties
|
create(Type.VAR_INT, 0); // No properties
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
registerClientbound(State.LOGIN, ClientboundLoginPackets.HELLO.getId(), ClientboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Server id
|
map(Type.STRING); // Server id
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final byte[] publicKey = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE);
|
final byte[] publicKey = wrapper.passthrough(Type.BYTE_ARRAY_PRIMITIVE);
|
||||||
@ -245,17 +245,17 @@ public final class Protocol1_19To1_18_2 extends AbstractProtocol<ClientboundPack
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketRemapper() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.HELLO.getId(), ServerboundLoginPackets.HELLO.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // Name
|
map(Type.STRING); // Name
|
||||||
read(Type.OPTIONAL_PROFILE_KEY); // Public profile key
|
read(Type.OPTIONAL_PROFILE_KEY); // Public profile key
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketRemapper() {
|
registerServerbound(State.LOGIN, ServerboundLoginPackets.ENCRYPTION_KEY.getId(), ServerboundLoginPackets.ENCRYPTION_KEY.getId(), new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.BYTE_ARRAY_PRIMITIVE); // Keys
|
map(Type.BYTE_ARRAY_PRIMITIVE); // Keys
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
if (wrapper.read(Type.BOOLEAN)) {
|
if (wrapper.read(Type.BOOLEAN)) {
|
||||||
|
@ -31,7 +31,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
|||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO;
|
import com.viaversion.viaversion.api.minecraft.nbt.BinaryTagIO;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||||
@ -96,9 +96,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
registerMetadataRewriter(ClientboundPackets1_18.ENTITY_METADATA, Types1_18.METADATA_LIST, Types1_19.METADATA_LIST);
|
registerMetadataRewriter(ClientboundPackets1_18.ENTITY_METADATA, Types1_18.METADATA_LIST, Types1_19.METADATA_LIST);
|
||||||
registerRemoveEntities(ClientboundPackets1_18.REMOVE_ENTITIES);
|
registerRemoveEntities(ClientboundPackets1_18.REMOVE_ENTITIES);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
map(Type.UUID); // Entity UUID
|
map(Type.UUID); // Entity UUID
|
||||||
map(Type.VAR_INT); // Entity type
|
map(Type.VAR_INT); // Entity type
|
||||||
@ -123,9 +123,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PAINTING, ClientboundPackets1_19.SPAWN_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PAINTING, ClientboundPackets1_19.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
map(Type.UUID); // Entity UUID
|
map(Type.UUID); // Entity UUID
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -159,9 +159,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_MOB, ClientboundPackets1_19.SPAWN_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_MOB, ClientboundPackets1_19.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity ID
|
map(Type.VAR_INT); // Entity ID
|
||||||
map(Type.UUID); // Entity UUID
|
map(Type.UUID); // Entity UUID
|
||||||
map(Type.VAR_INT); // Entity Type
|
map(Type.VAR_INT); // Entity Type
|
||||||
@ -184,9 +184,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.ENTITY_EFFECT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.ENTITY_EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
map(Type.VAR_INT); // Effect id
|
map(Type.VAR_INT); // Effect id
|
||||||
map(Type.BYTE); // Amplifier
|
map(Type.BYTE); // Amplifier
|
||||||
@ -196,9 +196,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Entity ID
|
map(Type.INT); // Entity ID
|
||||||
map(Type.BOOLEAN); // Hardcore
|
map(Type.BOOLEAN); // Hardcore
|
||||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
@ -250,9 +250,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> writeDimensionKey(wrapper, wrapper.user().get(DimensionRegistryStorage.class)));
|
handler(wrapper -> writeDimensionKey(wrapper, wrapper.user().get(DimensionRegistryStorage.class)));
|
||||||
map(Type.STRING); // World
|
map(Type.STRING); // World
|
||||||
map(Type.LONG); // Seed
|
map(Type.LONG); // Seed
|
||||||
@ -266,9 +266,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.PLAYER_INFO, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.PLAYER_INFO, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int action = wrapper.passthrough(Type.VAR_INT);
|
final int action = wrapper.passthrough(Type.VAR_INT);
|
||||||
final int entries = wrapper.passthrough(Type.VAR_INT);
|
final int entries = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
@ -19,7 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_19to1_18_2.packets;
|
|||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||||
@ -41,9 +41,9 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_18,
|
|||||||
registerSetSlot1_17_1(ClientboundPackets1_18.SET_SLOT);
|
registerSetSlot1_17_1(ClientboundPackets1_18.SET_SLOT);
|
||||||
registerAdvancements(ClientboundPackets1_18.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
registerAdvancements(ClientboundPackets1_18.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
|
||||||
registerEntityEquipmentArray(ClientboundPackets1_18.ENTITY_EQUIPMENT);
|
registerEntityEquipmentArray(ClientboundPackets1_18.ENTITY_EQUIPMENT);
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PARTICLE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.SPAWN_PARTICLE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT, Type.VAR_INT); // 0 - Particle ID
|
map(Type.INT, Type.VAR_INT); // 0 - Particle ID
|
||||||
map(Type.BOOLEAN); // 1 - Long Distance
|
map(Type.BOOLEAN); // 1 - Long Distance
|
||||||
map(Type.DOUBLE); // 2 - X
|
map(Type.DOUBLE); // 2 - X
|
||||||
@ -63,9 +63,9 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_18,
|
|||||||
|
|
||||||
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_18.WINDOW_PROPERTY);
|
registerWindowPropertyEnchantmentHandler(ClientboundPackets1_18.WINDOW_PROPERTY);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.TRADE_LIST, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.TRADE_LIST, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Container id
|
map(Type.VAR_INT); // Container id
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int size = wrapper.read(Type.UNSIGNED_BYTE);
|
final int size = wrapper.read(Type.UNSIGNED_BYTE);
|
||||||
@ -92,18 +92,18 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_18,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_19.PLAYER_DIGGING, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_19.PLAYER_DIGGING, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Action
|
map(Type.VAR_INT); // Action
|
||||||
map(Type.POSITION1_14); // Block position
|
map(Type.POSITION1_14); // Block position
|
||||||
map(Type.UNSIGNED_BYTE); // Direction
|
map(Type.UNSIGNED_BYTE); // Direction
|
||||||
handler(sequenceHandler());
|
handler(sequenceHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_19.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_19.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Hand
|
map(Type.VAR_INT); // Hand
|
||||||
map(Type.POSITION1_14); // Block position
|
map(Type.POSITION1_14); // Block position
|
||||||
map(Type.VAR_INT); // Direction
|
map(Type.VAR_INT); // Direction
|
||||||
@ -114,9 +114,9 @@ public final class InventoryPackets extends ItemRewriter<ClientboundPackets1_18,
|
|||||||
handler(sequenceHandler());
|
handler(sequenceHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_19.USE_ITEM, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_19.USE_ITEM, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Hand
|
map(Type.VAR_INT); // Hand
|
||||||
handler(sequenceHandler());
|
handler(sequenceHandler());
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
||||||
@ -43,9 +43,9 @@ public final class WorldPackets {
|
|||||||
|
|
||||||
protocol.cancelClientbound(ClientboundPackets1_18.ACKNOWLEDGE_PLAYER_DIGGING);
|
protocol.cancelClientbound(ClientboundPackets1_18.ACKNOWLEDGE_PLAYER_DIGGING);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_18.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_18.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
||||||
Preconditions.checkArgument(tracker.biomesSent() != 0, "Biome count not set");
|
Preconditions.checkArgument(tracker.biomesSent() != 0, "Biome count not set");
|
||||||
@ -65,9 +65,9 @@ public final class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_19.SET_BEACON_EFFECT, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_19.SET_BEACON_EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Primary effect
|
// Primary effect
|
||||||
if (wrapper.read(Type.BOOLEAN)) {
|
if (wrapper.read(Type.BOOLEAN)) {
|
||||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.chunks.BlockEntity;
|
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.chunks.BlockEntity;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||||
@ -46,9 +46,9 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); //Position
|
map(Type.POSITION); //Position
|
||||||
map(Type.UNSIGNED_BYTE); //Type
|
map(Type.UNSIGNED_BYTE); //Type
|
||||||
map(Type.NBT); //NBT
|
map(Type.NBT); //NBT
|
||||||
@ -75,9 +75,9 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -94,9 +94,9 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Entity ID
|
map(Type.INT); // 0 - Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
map(Type.INT); // 2 - Dimension
|
map(Type.INT); // 2 - Dimension
|
||||||
@ -113,9 +113,9 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9_3.RESPAWN, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9_3.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Dimension ID
|
map(Type.INT); // 0 - Dimension ID
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_9_1to1_9;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||||
@ -35,9 +35,9 @@ public class Protocol1_9_1To1_9 extends AbstractProtocol<ClientboundPackets1_9,
|
|||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
// Currently supports 1.9.1 and 1.9.2
|
// Currently supports 1.9.1 and 1.9.2
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Player ID
|
map(Type.INT); // 0 - Player ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Player Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Player Gamemode
|
||||||
// 1.9.1 PRE 2 Changed this
|
// 1.9.1 PRE 2 Changed this
|
||||||
@ -49,9 +49,9 @@ public class Protocol1_9_1To1_9 extends AbstractProtocol<ClientboundPackets1_9,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9.SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9.SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Sound ID
|
map(Type.VAR_INT); // 0 - Sound ID
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
|
@ -30,7 +30,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
import com.viaversion.viaversion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||||
@ -58,9 +58,9 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
|
|||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
// Sign update packet
|
// Sign update packet
|
||||||
registerClientbound(ClientboundPackets1_9.UPDATE_SIGN, null, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9.UPDATE_SIGN, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -94,9 +94,9 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9.CHUNK_DATA, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -128,9 +128,9 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Entity ID
|
map(Type.INT); // 0 - Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
map(Type.INT); // 2 - Dimension
|
map(Type.INT); // 2 - Dimension
|
||||||
@ -146,9 +146,9 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9.RESPAWN, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Dimension ID
|
map(Type.INT); // 0 - Dimension ID
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -162,9 +162,9 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Sound effect
|
// Sound effect
|
||||||
registerClientbound(ClientboundPackets1_9.SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9.SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Sound name
|
map(Type.VAR_INT); // 0 - Sound name
|
||||||
map(Type.VAR_INT); // 1 - Sound Category
|
map(Type.VAR_INT); // 1 - Sound Category
|
||||||
map(Type.INT); // 2 - x
|
map(Type.INT); // 2 - x
|
||||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||||
@ -113,9 +113,9 @@ public class Protocol1_9To1_8 extends AbstractProtocol<ClientboundPackets1_8, Cl
|
|||||||
metadataRewriter.register();
|
metadataRewriter.register();
|
||||||
|
|
||||||
// Disconnect workaround (JSON!)
|
// Disconnect workaround (JSON!)
|
||||||
registerClientbound(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
registerClientbound(State.LOGIN, 0x00, 0x00, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
if (wrapper.isReadable(Type.COMPONENT, 0)) {
|
if (wrapper.isReadable(Type.COMPONENT, 0)) {
|
||||||
// Already written as json somewhere else
|
// Already written as json somewhere else
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_8;
|
import com.viaversion.viaversion.api.type.types.version.Types1_8;
|
||||||
@ -54,10 +54,10 @@ public class EntityPackets {
|
|||||||
|
|
||||||
public static void register(Protocol1_9To1_8 protocol) {
|
public static void register(Protocol1_9To1_8 protocol) {
|
||||||
// Attach Entity Packet
|
// Attach Entity Packet
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.ATTACH_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.ATTACH_ENTITY, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Entity ID
|
map(Type.INT); // 0 - Entity ID
|
||||||
map(Type.INT); // 1 - Vehicle
|
map(Type.INT); // 1 - Vehicle
|
||||||
|
|
||||||
@ -90,10 +90,10 @@ public class EntityPackets {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_TELEPORT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_TELEPORT, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.INT, SpawnPackets.toNewDouble); // 1 - X - Needs to be divide by 32
|
map(Type.INT, SpawnPackets.toNewDouble); // 1 - X - Needs to be divide by 32
|
||||||
map(Type.INT, SpawnPackets.toNewDouble); // 2 - Y - Needs to be divide by 32
|
map(Type.INT, SpawnPackets.toNewDouble); // 2 - Y - Needs to be divide by 32
|
||||||
@ -122,10 +122,10 @@ public class EntityPackets {
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_POSITION_AND_ROTATION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_POSITION_AND_ROTATION, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.BYTE, toNewShort); // 1 - X
|
map(Type.BYTE, toNewShort); // 1 - X
|
||||||
map(Type.BYTE, toNewShort); // 2 - Y
|
map(Type.BYTE, toNewShort); // 2 - Y
|
||||||
@ -137,10 +137,10 @@ public class EntityPackets {
|
|||||||
map(Type.BOOLEAN); // 6 - On Ground
|
map(Type.BOOLEAN); // 6 - On Ground
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_POSITION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_POSITION, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.BYTE, toNewShort); // 1 - X
|
map(Type.BYTE, toNewShort); // 1 - X
|
||||||
map(Type.BYTE, toNewShort); // 2 - Y
|
map(Type.BYTE, toNewShort); // 2 - Y
|
||||||
@ -149,10 +149,10 @@ public class EntityPackets {
|
|||||||
map(Type.BOOLEAN); // 4 - On Ground
|
map(Type.BOOLEAN); // 4 - On Ground
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_EQUIPMENT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_EQUIPMENT, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
// 1 - Slot ID
|
// 1 - Slot ID
|
||||||
map(Type.SHORT, new ValueTransformer<Short, Integer>(Type.VAR_INT) {
|
map(Type.SHORT, new ValueTransformer<Short, Integer>(Type.VAR_INT) {
|
||||||
@ -197,10 +197,10 @@ public class EntityPackets {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_METADATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_METADATA, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST); // 1 - Metadata List
|
map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST); // 1 - Metadata List
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -243,9 +243,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_EFFECT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.BYTE); // 1 - Effect ID
|
map(Type.BYTE); // 1 - Effect ID
|
||||||
map(Type.BYTE); // 2 - Amplifier
|
map(Type.BYTE); // 2 - Amplifier
|
||||||
@ -264,9 +264,9 @@ public class EntityPackets {
|
|||||||
|
|
||||||
protocol.cancelClientbound(ClientboundPackets1_8.UPDATE_ENTITY_NBT);
|
protocol.cancelClientbound(ClientboundPackets1_8.UPDATE_ENTITY_NBT);
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.COMBAT_EVENT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.COMBAT_EVENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); //Event id
|
map(Type.VAR_INT); //Event id
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -281,9 +281,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_PROPERTIES, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_PROPERTIES, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -338,9 +338,9 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_ANIMATION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.ENTITY_ANIMATION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Animation
|
map(Type.UNSIGNED_BYTE); // 1 - Animation
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -356,10 +356,10 @@ public class EntityPackets {
|
|||||||
|
|
||||||
|
|
||||||
/* Incoming Packets */
|
/* Incoming Packets */
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.ENTITY_ACTION, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.ENTITY_ACTION, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Player ID
|
map(Type.VAR_INT); // 0 - Player ID
|
||||||
map(Type.VAR_INT); // 1 - Action
|
map(Type.VAR_INT); // 1 - Action
|
||||||
map(Type.VAR_INT); // 2 - Jump
|
map(Type.VAR_INT); // 2 - Jump
|
||||||
@ -377,10 +377,10 @@ public class EntityPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.INTERACT_ENTITY, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.INTERACT_ENTITY, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID (Target)
|
map(Type.VAR_INT); // 0 - Entity ID (Target)
|
||||||
map(Type.VAR_INT); // 1 - Action Type
|
map(Type.VAR_INT); // 1 - Action Type
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||||
@ -35,10 +35,10 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.InventoryTra
|
|||||||
public class InventoryPackets {
|
public class InventoryPackets {
|
||||||
|
|
||||||
public static void register(Protocol1_9To1_8 protocol) {
|
public static void register(Protocol1_9To1_8 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.WINDOW_PROPERTY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.WINDOW_PROPERTY, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.SHORT); // 1 - Property Key
|
map(Type.SHORT); // 1 - Property Key
|
||||||
map(Type.SHORT); // 2 - Property Value
|
map(Type.SHORT); // 2 - Property Value
|
||||||
@ -74,10 +74,10 @@ public class InventoryPackets {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.OPEN_WINDOW, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.OPEN_WINDOW, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.STRING); // 1 - Window Type
|
map(Type.STRING); // 1 - Window Type
|
||||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 2 - Window Title
|
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 2 - Window Title
|
||||||
@ -104,9 +104,9 @@ public class InventoryPackets {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.SET_SLOT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.SET_SLOT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.SHORT); // 1 - Slot ID
|
map(Type.SHORT); // 1 - Slot ID
|
||||||
map(Type.ITEM); // 2 - Slot Value
|
map(Type.ITEM); // 2 - Slot Value
|
||||||
@ -154,10 +154,10 @@ public class InventoryPackets {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.WINDOW_ITEMS, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.WINDOW_ITEMS, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.ITEM_ARRAY); // 1 - Window Values
|
map(Type.ITEM_ARRAY); // 1 - Window Values
|
||||||
|
|
||||||
@ -215,10 +215,10 @@ public class InventoryPackets {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.CLOSE_WINDOW, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.CLOSE_WINDOW, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
// Inventory tracking
|
// Inventory tracking
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -232,10 +232,10 @@ public class InventoryPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.MAP_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.MAP_DATA, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Map ID
|
map(Type.VAR_INT); // 0 - Map ID
|
||||||
map(Type.BYTE); // 1 - Map Scale
|
map(Type.BYTE); // 1 - Map Scale
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -250,10 +250,10 @@ public class InventoryPackets {
|
|||||||
|
|
||||||
|
|
||||||
/* Incoming Packets */
|
/* Incoming Packets */
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.CREATIVE_INVENTORY_ACTION, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.CREATIVE_INVENTORY_ACTION, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.SHORT); // 0 - Slot ID
|
map(Type.SHORT); // 0 - Slot ID
|
||||||
map(Type.ITEM); // 1 - Item
|
map(Type.ITEM); // 1 - Item
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -303,10 +303,10 @@ public class InventoryPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.CLICK_WINDOW, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.CLICK_WINDOW, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.SHORT); // 1 - Slot ID
|
map(Type.SHORT); // 1 - Slot ID
|
||||||
map(Type.BYTE); // 2 - Button
|
map(Type.BYTE); // 2 - Button
|
||||||
@ -371,10 +371,10 @@ public class InventoryPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.CLOSE_WINDOW, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.CLOSE_WINDOW, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
|
|
||||||
// Inventory tracking
|
// Inventory tracking
|
||||||
@ -389,9 +389,9 @@ public class InventoryPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.HELD_ITEM_CHANGE, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.HELD_ITEM_CHANGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.SHORT); // 0 - Slot id
|
map(Type.SHORT); // 0 - Slot id
|
||||||
|
|
||||||
// Blocking patch
|
// Blocking patch
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
@ -41,9 +41,9 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracke
|
|||||||
|
|
||||||
public class PlayerPackets {
|
public class PlayerPackets {
|
||||||
public static void register(Protocol1_9To1_8 protocol) {
|
public static void register(Protocol1_9To1_8 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.CHAT_MESSAGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.CHAT_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Chat Message (json)
|
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Chat Message (json)
|
||||||
map(Type.BYTE); // 1 - Chat Positon
|
map(Type.BYTE); // 1 - Chat Positon
|
||||||
|
|
||||||
@ -58,24 +58,24 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.TAB_LIST, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.TAB_LIST, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Header
|
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Header
|
||||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 1 - Footer
|
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 1 - Footer
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.DISCONNECT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.DISCONNECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Reason
|
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 0 - Reason
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.TITLE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.TITLE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Action
|
map(Type.VAR_INT); // 0 - Action
|
||||||
// We only handle if the title or subtitle is set then just write through.
|
// We only handle if the title or subtitle is set then just write through.
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -88,9 +88,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.PLAYER_POSITION, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.PLAYER_POSITION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.DOUBLE); // 0 - Player X
|
map(Type.DOUBLE); // 0 - Player X
|
||||||
map(Type.DOUBLE); // 1 - Player Y
|
map(Type.DOUBLE); // 1 - Player Y
|
||||||
map(Type.DOUBLE); // 2 - Player Z
|
map(Type.DOUBLE); // 2 - Player Z
|
||||||
@ -106,9 +106,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.TEAMS, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.TEAMS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Team Name
|
map(Type.STRING); // 0 - Team Name
|
||||||
map(Type.BYTE); // 1 - Mode
|
map(Type.BYTE); // 1 - Mode
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -167,9 +167,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.JOIN_GAME, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Player ID
|
map(Type.INT); // 0 - Player ID
|
||||||
// Parse this info
|
// Parse this info
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -220,9 +220,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.PLAYER_INFO, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.PLAYER_INFO, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Action
|
map(Type.VAR_INT); // 0 - Action
|
||||||
map(Type.VAR_INT); // 1 - Player Count
|
map(Type.VAR_INT); // 1 - Player Count
|
||||||
|
|
||||||
@ -263,9 +263,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.PLUGIN_MESSAGE, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Channel Name
|
map(Type.STRING); // 0 - Channel Name
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
String name = wrapper.get(Type.STRING, 0);
|
String name = wrapper.get(Type.STRING, 0);
|
||||||
@ -302,9 +302,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.RESPAWN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.RESPAWN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Dimension
|
map(Type.INT); // 0 - Dimension
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Difficulty
|
map(Type.UNSIGNED_BYTE); // 1 - Difficulty
|
||||||
map(Type.UNSIGNED_BYTE); // 2 - GameMode
|
map(Type.UNSIGNED_BYTE); // 2 - GameMode
|
||||||
@ -338,9 +338,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.GAME_EVENT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.GAME_EVENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); //0 - Reason
|
map(Type.UNSIGNED_BYTE); //0 - Reason
|
||||||
map(Type.FLOAT); //1 - Value
|
map(Type.FLOAT); //1 - Value
|
||||||
|
|
||||||
@ -358,9 +358,9 @@ public class PlayerPackets {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* Removed packets */
|
/* Removed packets */
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.SET_COMPRESSION, null, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.SET_COMPRESSION, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
CompressionProvider provider = Via.getManager().getProviders().get(CompressionProvider.class);
|
CompressionProvider provider = Via.getManager().getProviders().get(CompressionProvider.class);
|
||||||
@ -372,17 +372,17 @@ public class PlayerPackets {
|
|||||||
|
|
||||||
|
|
||||||
/* Incoming Packets */
|
/* Incoming Packets */
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.TAB_COMPLETE, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.TAB_COMPLETE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Requested Command
|
map(Type.STRING); // 0 - Requested Command
|
||||||
map(Type.BOOLEAN, Type.NOTHING); // 1 - Is Command Block
|
map(Type.BOOLEAN, Type.NOTHING); // 1 - Is Command Block
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.CLIENT_SETTINGS, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.CLIENT_SETTINGS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - locale
|
map(Type.STRING); // 0 - locale
|
||||||
map(Type.BYTE); // 1 - View Distance
|
map(Type.BYTE); // 1 - View Distance
|
||||||
map(Type.VAR_INT, Type.BYTE); // 2 - Chat Mode
|
map(Type.VAR_INT, Type.BYTE); // 2 - Chat Mode
|
||||||
@ -405,9 +405,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.ANIMATION, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.ANIMATION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT, Type.NOTHING); // 0 - Hand
|
map(Type.VAR_INT, Type.NOTHING); // 0 - Hand
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -416,9 +416,9 @@ public class PlayerPackets {
|
|||||||
protocol.cancelServerbound(ServerboundPackets1_9.VEHICLE_MOVE);
|
protocol.cancelServerbound(ServerboundPackets1_9.VEHICLE_MOVE);
|
||||||
protocol.cancelServerbound(ServerboundPackets1_9.STEER_BOAT);
|
protocol.cancelServerbound(ServerboundPackets1_9.STEER_BOAT);
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.PLUGIN_MESSAGE, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.PLUGIN_MESSAGE, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Channel Name
|
map(Type.STRING); // 0 - Channel Name
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
String name = wrapper.get(Type.STRING, 0);
|
String name = wrapper.get(Type.STRING, 0);
|
||||||
@ -446,9 +446,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.CLIENT_STATUS, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.CLIENT_STATUS, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Action ID
|
map(Type.VAR_INT); // 0 - Action ID
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int action = wrapper.get(Type.VAR_INT, 0);
|
int action = wrapper.get(Type.VAR_INT, 0);
|
||||||
@ -466,9 +466,9 @@ public class PlayerPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_POSITION, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_POSITION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.DOUBLE); // 0 - X
|
map(Type.DOUBLE); // 0 - X
|
||||||
map(Type.DOUBLE); // 1 - Y
|
map(Type.DOUBLE); // 1 - Y
|
||||||
map(Type.DOUBLE); // 2 - Z
|
map(Type.DOUBLE); // 2 - Z
|
||||||
@ -476,9 +476,9 @@ public class PlayerPackets {
|
|||||||
handler(new PlayerMovementMapper());
|
handler(new PlayerMovementMapper());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_POSITION_AND_ROTATION, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_POSITION_AND_ROTATION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.DOUBLE); // 0 - X
|
map(Type.DOUBLE); // 0 - X
|
||||||
map(Type.DOUBLE); // 1 - Y
|
map(Type.DOUBLE); // 1 - Y
|
||||||
map(Type.DOUBLE); // 2 - Z
|
map(Type.DOUBLE); // 2 - Z
|
||||||
@ -488,18 +488,18 @@ public class PlayerPackets {
|
|||||||
handler(new PlayerMovementMapper());
|
handler(new PlayerMovementMapper());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_ROTATION, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_ROTATION, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.FLOAT); // 0 - Yaw
|
map(Type.FLOAT); // 0 - Yaw
|
||||||
map(Type.FLOAT); // 1 - Pitch
|
map(Type.FLOAT); // 1 - Pitch
|
||||||
map(Type.BOOLEAN); // 2 - Ground
|
map(Type.BOOLEAN); // 2 - Ground
|
||||||
handler(new PlayerMovementMapper());
|
handler(new PlayerMovementMapper());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_MOVEMENT, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_MOVEMENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.BOOLEAN); // 0 - Ground
|
map(Type.BOOLEAN); // 0 - Ground
|
||||||
handler(new PlayerMovementMapper());
|
handler(new PlayerMovementMapper());
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
|||||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_8;
|
import com.viaversion.viaversion.api.type.types.version.Types1_8;
|
||||||
@ -50,9 +50,9 @@ public class SpawnPackets {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static void register(Protocol1_9To1_8 protocol) {
|
public static void register(Protocol1_9To1_8 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -138,9 +138,9 @@ public class SpawnPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_EXPERIENCE_ORB, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_EXPERIENCE_ORB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
|
||||||
// Parse this info
|
// Parse this info
|
||||||
@ -162,9 +162,9 @@ public class SpawnPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_GLOBAL_ENTITY, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_GLOBAL_ENTITY, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.BYTE); // 1 - Type
|
map(Type.BYTE); // 1 - Type
|
||||||
// Parse this info
|
// Parse this info
|
||||||
@ -185,9 +185,9 @@ public class SpawnPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_MOB, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_MOB, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -252,9 +252,9 @@ public class SpawnPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PAINTING, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PAINTING, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
|
||||||
// Parse this info
|
// Parse this info
|
||||||
@ -282,9 +282,9 @@ public class SpawnPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PLAYER, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PLAYER, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Player UUID
|
map(Type.UUID); // 1 - Player UUID
|
||||||
|
|
||||||
@ -354,10 +354,10 @@ public class SpawnPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.DESTROY_ENTITIES, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.DESTROY_ENTITIES, new PacketHandlers() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entities to destroy
|
map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entities to destroy
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
|
@ -29,7 +29,7 @@ import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||||
@ -51,9 +51,9 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class WorldPackets {
|
public class WorldPackets {
|
||||||
public static void register(Protocol1_9To1_8 protocol) {
|
public static void register(Protocol1_9To1_8 protocol) {
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.UPDATE_SIGN, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.UPDATE_SIGN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); // 0 - Sign Position
|
map(Type.POSITION); // 0 - Sign Position
|
||||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 1 - Sign Line (json)
|
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 1 - Sign Line (json)
|
||||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 2 - Sign Line (json)
|
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 2 - Sign Line (json)
|
||||||
@ -62,9 +62,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.EFFECT, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.EFFECT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Effect ID
|
map(Type.INT); // 0 - Effect ID
|
||||||
map(Type.POSITION); // 1 - Position
|
map(Type.POSITION); // 1 - Position
|
||||||
map(Type.INT); // 2 - Data
|
map(Type.INT); // 2 - Data
|
||||||
@ -94,9 +94,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.NAMED_SOUND, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.NAMED_SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.STRING); // 0 - Sound Name
|
map(Type.STRING); // 0 - Sound Name
|
||||||
// 1 - Sound Category ID
|
// 1 - Sound Category ID
|
||||||
// Everything else get's written through
|
// Everything else get's written through
|
||||||
@ -129,9 +129,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.CHUNK_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.CHUNK_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -191,9 +191,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.MAP_BULK_CHUNK, null, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.MAP_BULK_CHUNK, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.cancel(); // Cancel the packet from being sent
|
wrapper.cancel(); // Cancel the packet from being sent
|
||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
@ -227,9 +227,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerClientbound(ClientboundPackets1_8.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
protocol.registerClientbound(ClientboundPackets1_8.BLOCK_ENTITY_DATA, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); // 0 - Block Position
|
map(Type.POSITION); // 0 - Block Position
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Action
|
map(Type.UNSIGNED_BYTE); // 1 - Action
|
||||||
map(Type.NBT); // 2 - NBT (Might not be present)
|
map(Type.NBT); // 2 - NBT (Might not be present)
|
||||||
@ -266,9 +266,9 @@ public class WorldPackets {
|
|||||||
|
|
||||||
|
|
||||||
/* Incoming Packets */
|
/* Incoming Packets */
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.UPDATE_SIGN, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.UPDATE_SIGN, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); // 0 - Sign Position
|
map(Type.POSITION); // 0 - Sign Position
|
||||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 1 - Sign Line (json)
|
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 1 - Sign Line (json)
|
||||||
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 2 - Sign Line (json)
|
map(Type.STRING, Protocol1_9To1_8.FIX_JSON); // 2 - Sign Line (json)
|
||||||
@ -277,9 +277,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_DIGGING, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_DIGGING, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Action
|
map(Type.VAR_INT); // Action
|
||||||
map(Type.POSITION); // Position
|
map(Type.POSITION); // Position
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@ -309,9 +309,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.USE_ITEM, null, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.USE_ITEM, null, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
@ -375,9 +375,9 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_BLOCK_PLACEMENT, new PacketRemapper() {
|
protocol.registerServerbound(ServerboundPackets1_9.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION); // 0 - Position
|
map(Type.POSITION); // 0 - Position
|
||||||
map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 1 - Block Face
|
map(Type.VAR_INT, Type.UNSIGNED_BYTE); // 1 - Block Face
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_9to1_9_1;
|
|||||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
|
||||||
@ -35,9 +35,9 @@ public class Protocol1_9To1_9_1 extends AbstractProtocol<ClientboundPackets1_9,
|
|||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
// Currently supports 1.9.1 and 1.9.2
|
// Currently supports 1.9.1 and 1.9.2
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9.JOIN_GAME, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9.JOIN_GAME, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Player ID
|
map(Type.INT); // 0 - Player ID
|
||||||
map(Type.UNSIGNED_BYTE); // 1 - Player Gamemode
|
map(Type.UNSIGNED_BYTE); // 1 - Player Gamemode
|
||||||
// 1.9.1 PRE 2 Changed this
|
// 1.9.1 PRE 2 Changed this
|
||||||
@ -49,9 +49,9 @@ public class Protocol1_9To1_9_1 extends AbstractProtocol<ClientboundPackets1_9,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
registerClientbound(ClientboundPackets1_9.SOUND, new PacketRemapper() {
|
registerClientbound(ClientboundPackets1_9.SOUND, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Sound ID
|
map(Type.VAR_INT); // 0 - Sound ID
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
|
@ -29,7 +29,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
|
|||||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.util.MathUtil;
|
import com.viaversion.viaversion.util.MathUtil;
|
||||||
|
|
||||||
@ -45,9 +45,9 @@ public class BlockRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerBlockAction(C packetType) {
|
public void registerBlockAction(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(positionType); // Location
|
map(positionType); // Location
|
||||||
map(Type.UNSIGNED_BYTE); // Action id
|
map(Type.UNSIGNED_BYTE); // Action id
|
||||||
map(Type.UNSIGNED_BYTE); // Action param
|
map(Type.UNSIGNED_BYTE); // Action param
|
||||||
@ -68,9 +68,9 @@ public class BlockRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerBlockChange(C packetType) {
|
public void registerBlockChange(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(positionType);
|
map(positionType);
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
handler(wrapper -> wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.VAR_INT, 0))));
|
handler(wrapper -> wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.VAR_INT, 0))));
|
||||||
@ -79,9 +79,9 @@ public class BlockRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerMultiBlockChange(C packetType) {
|
public void registerMultiBlockChange(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Chunk X
|
map(Type.INT); // 0 - Chunk X
|
||||||
map(Type.INT); // 1 - Chunk Z
|
map(Type.INT); // 1 - Chunk Z
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -94,9 +94,9 @@ public class BlockRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerVarLongMultiBlockChange(C packetType) {
|
public void registerVarLongMultiBlockChange(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.LONG); // Chunk position
|
map(Type.LONG); // Chunk position
|
||||||
map(Type.BOOLEAN); // Suppress light updates
|
map(Type.BOOLEAN); // Suppress light updates
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -114,9 +114,9 @@ public class BlockRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerEffect(C packetType, int playRecordId, int blockBreakId) {
|
public void registerEffect(C packetType, int playRecordId, int blockBreakId) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // Effect Id
|
map(Type.INT); // Effect Id
|
||||||
map(positionType); // Location
|
map(positionType); // Location
|
||||||
map(Type.INT); // Data
|
map(Type.INT); // Data
|
||||||
@ -134,9 +134,9 @@ public class BlockRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerChunkData1_19(C packetType, ChunkTypeSupplier chunkTypeSupplier) {
|
public void registerChunkData1_19(C packetType, ChunkTypeSupplier chunkTypeSupplier) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
||||||
Preconditions.checkArgument(tracker.biomesSent() != 0, "Biome count not set");
|
Preconditions.checkArgument(tracker.biomesSent() != 0, "Biome count not set");
|
||||||
@ -167,9 +167,9 @@ public class BlockRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerBlockEntityData(C packetType) {
|
public void registerBlockEntityData(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.POSITION1_14);
|
map(Type.POSITION1_14);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int blockEntityId = wrapper.read(Type.VAR_INT);
|
final int blockEntityId = wrapper.read(Type.VAR_INT);
|
||||||
|
@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -67,9 +67,9 @@ public class CommandRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerDeclareCommands(C packetType) {
|
public void registerDeclareCommands(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int size = wrapper.passthrough(Type.VAR_INT);
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@ -107,9 +107,9 @@ public class CommandRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerDeclareCommands1_19(C packetType) {
|
public void registerDeclareCommands1_19(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int size = wrapper.passthrough(Type.VAR_INT);
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
|
@ -25,7 +25,7 @@ import com.google.gson.JsonSyntaxException;
|
|||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,9 +53,9 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
|
|||||||
* @param packetType clientbound packet type
|
* @param packetType clientbound packet type
|
||||||
*/
|
*/
|
||||||
public void registerComponentPacket(C packetType) {
|
public void registerComponentPacket(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
handler(wrapper -> processText(wrapper.passthrough(Type.COMPONENT)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -67,9 +67,9 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerBossBar(C packetType) {
|
public void registerBossBar(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UUID);
|
map(Type.UUID);
|
||||||
map(Type.VAR_INT);
|
map(Type.VAR_INT);
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -86,9 +86,9 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
|
|||||||
* Handles sub 1.17 combat event components.
|
* Handles sub 1.17 combat event components.
|
||||||
*/
|
*/
|
||||||
public void registerCombatEvent(C packetType) {
|
public void registerCombatEvent(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
if (wrapper.passthrough(Type.VAR_INT) == 2) {
|
if (wrapper.passthrough(Type.VAR_INT) == 2) {
|
||||||
wrapper.passthrough(Type.VAR_INT);
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
@ -104,9 +104,9 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
|
|||||||
* Handles sub 1.17 title components.
|
* Handles sub 1.17 title components.
|
||||||
*/
|
*/
|
||||||
public void registerTitle(C packetType) {
|
public void registerTitle(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int action = wrapper.passthrough(Type.VAR_INT);
|
int action = wrapper.passthrough(Type.VAR_INT);
|
||||||
if (action >= 0 && action <= 2) {
|
if (action >= 0 && action <= 2) {
|
||||||
|
@ -37,7 +37,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
|||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.type.types.Particle;
|
||||||
@ -253,9 +253,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerTracker(C packetType) {
|
public void registerTracker(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -265,9 +265,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerTrackerWithData(C packetType, EntityType fallingBlockType) {
|
public void registerTrackerWithData(C packetType, EntityType fallingBlockType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity id
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
@ -290,9 +290,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerTrackerWithData1_19(C packetType, EntityType fallingBlockType) {
|
public void registerTrackerWithData1_19(C packetType, EntityType fallingBlockType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Entity id
|
map(Type.VAR_INT); // Entity id
|
||||||
map(Type.UUID); // Entity UUID
|
map(Type.UUID); // Entity UUID
|
||||||
map(Type.VAR_INT); // Entity type
|
map(Type.VAR_INT); // Entity type
|
||||||
@ -323,9 +323,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
* @param intType int type of the entity id
|
* @param intType int type of the entity id
|
||||||
*/
|
*/
|
||||||
public void registerTracker(C packetType, EntityType entityType, Type<Integer> intType) {
|
public void registerTracker(C packetType, EntityType entityType, Type<Integer> intType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int entityId = wrapper.passthrough(intType);
|
int entityId = wrapper.passthrough(intType);
|
||||||
tracker(wrapper.user()).addEntity(entityId, entityType);
|
tracker(wrapper.user()).addEntity(entityId, entityType);
|
||||||
@ -350,9 +350,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
* @param packetType remove entities packet type
|
* @param packetType remove entities packet type
|
||||||
*/
|
*/
|
||||||
public void registerRemoveEntities(C packetType) {
|
public void registerRemoveEntities(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int[] entityIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
int[] entityIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||||
EntityTracker entityTracker = tracker(wrapper.user());
|
EntityTracker entityTracker = tracker(wrapper.user());
|
||||||
@ -370,9 +370,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
* @param packetType remove entities packet type
|
* @param packetType remove entities packet type
|
||||||
*/
|
*/
|
||||||
public void registerRemoveEntity(C packetType) {
|
public void registerRemoveEntity(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int entityId = wrapper.passthrough(Type.VAR_INT);
|
int entityId = wrapper.passthrough(Type.VAR_INT);
|
||||||
tracker(wrapper.user()).removeEntity(entityId);
|
tracker(wrapper.user()).removeEntity(entityId);
|
||||||
@ -382,9 +382,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerMetadataRewriter(C packetType, @Nullable Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
public void registerMetadataRewriter(C packetType, @Nullable Type<List<Metadata>> oldMetaType, Type<List<Metadata>> newMetaType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
if (oldMetaType != null) {
|
if (oldMetaType != null) {
|
||||||
map(oldMetaType, newMetaType);
|
map(oldMetaType, newMetaType);
|
||||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.protocol.Protocol;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
@ -57,9 +57,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerWindowItems(C packetType, Type<Item[]> type) {
|
public void registerWindowItems(C packetType, Type<Item[]> type) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Window id
|
map(Type.UNSIGNED_BYTE); // Window id
|
||||||
map(type); // Items
|
map(type); // Items
|
||||||
handler(itemArrayHandler(type));
|
handler(itemArrayHandler(type));
|
||||||
@ -68,9 +68,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerWindowItems1_17_1(C packetType) {
|
public void registerWindowItems1_17_1(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Window id
|
map(Type.UNSIGNED_BYTE); // Window id
|
||||||
map(Type.VAR_INT); // State id
|
map(Type.VAR_INT); // State id
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -86,9 +86,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerSetSlot(C packetType, Type<Item> type) {
|
public void registerSetSlot(C packetType, Type<Item> type) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Window id
|
map(Type.UNSIGNED_BYTE); // Window id
|
||||||
map(Type.SHORT); // Slot id
|
map(Type.SHORT); // Slot id
|
||||||
map(type); // Item
|
map(type); // Item
|
||||||
@ -98,9 +98,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerSetSlot1_17_1(C packetType) {
|
public void registerSetSlot1_17_1(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Window id
|
map(Type.UNSIGNED_BYTE); // Window id
|
||||||
map(Type.VAR_INT); // State id
|
map(Type.VAR_INT); // State id
|
||||||
map(Type.SHORT); // Slot id
|
map(Type.SHORT); // Slot id
|
||||||
@ -112,9 +112,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
|
|
||||||
// Sub 1.16
|
// Sub 1.16
|
||||||
public void registerEntityEquipment(C packetType, Type<Item> type) {
|
public void registerEntityEquipment(C packetType, Type<Item> type) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.VAR_INT); // 1 - Slot ID
|
map(Type.VAR_INT); // 1 - Slot ID
|
||||||
map(type); // 2 - Item
|
map(type); // 2 - Item
|
||||||
@ -126,9 +126,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
|
|
||||||
// 1.16+
|
// 1.16+
|
||||||
public void registerEntityEquipmentArray(C packetType) {
|
public void registerEntityEquipmentArray(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
@ -144,9 +144,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerCreativeInvAction(S packetType, Type<Item> type) {
|
public void registerCreativeInvAction(S packetType, Type<Item> type) {
|
||||||
protocol.registerServerbound(packetType, new PacketRemapper() {
|
protocol.registerServerbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.SHORT); // 0 - Slot
|
map(Type.SHORT); // 0 - Slot
|
||||||
map(type); // 1 - Clicked Item
|
map(type); // 1 - Clicked Item
|
||||||
|
|
||||||
@ -156,9 +156,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerClickWindow(S packetType, Type<Item> type) {
|
public void registerClickWindow(S packetType, Type<Item> type) {
|
||||||
protocol.registerServerbound(packetType, new PacketRemapper() {
|
protocol.registerServerbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.SHORT); // 1 - Slot
|
map(Type.SHORT); // 1 - Slot
|
||||||
map(Type.BYTE); // 2 - Button
|
map(Type.BYTE); // 2 - Button
|
||||||
@ -172,9 +172,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerClickWindow1_17_1(S packetType) {
|
public void registerClickWindow1_17_1(S packetType) {
|
||||||
protocol.registerServerbound(packetType, new PacketRemapper() {
|
protocol.registerServerbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Window Id
|
map(Type.UNSIGNED_BYTE); // Window Id
|
||||||
map(Type.VAR_INT); // State id
|
map(Type.VAR_INT); // State id
|
||||||
map(Type.SHORT); // Slot
|
map(Type.SHORT); // Slot
|
||||||
@ -197,9 +197,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerSetCooldown(C packetType) {
|
public void registerSetCooldown(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int itemId = wrapper.read(Type.VAR_INT);
|
int itemId = wrapper.read(Type.VAR_INT);
|
||||||
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewItemId(itemId));
|
wrapper.write(Type.VAR_INT, protocol.getMappingData().getNewItemId(itemId));
|
||||||
@ -210,9 +210,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
|
|
||||||
// 1.14.4+
|
// 1.14.4+
|
||||||
public void registerTradeList(C packetType) {
|
public void registerTradeList(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.passthrough(Type.VAR_INT);
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||||
@ -240,9 +240,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerTradeList1_19(C packetType) {
|
public void registerTradeList1_19(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.passthrough(Type.VAR_INT); // Container id
|
wrapper.passthrough(Type.VAR_INT); // Container id
|
||||||
int size = wrapper.passthrough(Type.VAR_INT);
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
@ -266,9 +266,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerAdvancements(C packetType, Type<Item> type) {
|
public void registerAdvancements(C packetType, Type<Item> type) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||||
@ -306,9 +306,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerWindowPropertyEnchantmentHandler(C packetType) {
|
public void registerWindowPropertyEnchantmentHandler(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.UNSIGNED_BYTE); // Container id
|
map(Type.UNSIGNED_BYTE); // Container id
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
short property = wrapper.passthrough(Type.SHORT);
|
short property = wrapper.passthrough(Type.SHORT);
|
||||||
@ -324,9 +324,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
|
|
||||||
// Not the very best place for this, but has to stay here until *everything* is abstracted
|
// Not the very best place for this, but has to stay here until *everything* is abstracted
|
||||||
public void registerSpawnParticle(C packetType, Type<Item> itemType, Type<?> coordType) {
|
public void registerSpawnParticle(C packetType, Type<Item> itemType, Type<?> coordType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.INT); // 0 - Particle ID
|
map(Type.INT); // 0 - Particle ID
|
||||||
map(Type.BOOLEAN); // 1 - Long Distance
|
map(Type.BOOLEAN); // 1 - Long Distance
|
||||||
map(coordType); // 2 - X
|
map(coordType); // 2 - X
|
||||||
@ -343,9 +343,9 @@ public abstract class ItemRewriter<C extends ClientboundPacketType, S extends Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerSpawnParticle1_19(C packetType) {
|
public void registerSpawnParticle1_19(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // 0 - Particle ID
|
map(Type.VAR_INT); // 0 - Particle ID
|
||||||
map(Type.BOOLEAN); // 1 - Long Distance
|
map(Type.BOOLEAN); // 1 - Long Distance
|
||||||
map(Type.DOUBLE); // 2 - X
|
map(Type.DOUBLE); // 2 - X
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public abstract class RecipeRewriter<C extends ClientboundPacketType> {
|
|||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketWrapper wrapper, String type) throws Exception {
|
public void handleRecipeType(PacketWrapper wrapper, String type) throws Exception {
|
||||||
RecipeConsumer handler = recipeHandlers.get(type);
|
RecipeConsumer handler = recipeHandlers.get(type);
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
handler.accept(wrapper);
|
handler.accept(wrapper);
|
||||||
@ -45,15 +45,15 @@ public abstract class RecipeRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void registerDefaultHandler(C packetType) {
|
public void registerDefaultHandler(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int size = wrapper.passthrough(Type.VAR_INT);
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||||
wrapper.passthrough(Type.STRING); // Recipe Identifier
|
wrapper.passthrough(Type.STRING); // Recipe Identifier
|
||||||
handle(wrapper, type);
|
handleRecipeType(wrapper, type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.rewriter;
|
|||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
|
||||||
public class SoundRewriter<C extends ClientboundPacketType> {
|
public class SoundRewriter<C extends ClientboundPacketType> {
|
||||||
@ -39,9 +39,9 @@ public class SoundRewriter<C extends ClientboundPacketType> {
|
|||||||
|
|
||||||
// The same for entity sound
|
// The same for entity sound
|
||||||
public void registerSound(C packetType) {
|
public void registerSound(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
map(Type.VAR_INT); // Sound Id
|
map(Type.VAR_INT); // Sound Id
|
||||||
handler(getSoundHandler());
|
handler(getSoundHandler());
|
||||||
}
|
}
|
||||||
@ -49,9 +49,9 @@ public class SoundRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register1_19_3Sound(C packetType) {
|
public void register1_19_3Sound(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int soundId = wrapper.read(Type.VAR_INT);
|
final int soundId = wrapper.read(Type.VAR_INT);
|
||||||
if (soundId == 0) {
|
if (soundId == 0) {
|
||||||
|
@ -20,7 +20,7 @@ package com.viaversion.viaversion.rewriter;
|
|||||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@ -33,9 +33,9 @@ public class StatisticsRewriter<C extends ClientboundPacketType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register(C packetType) {
|
public void register(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
int size = wrapper.passthrough(Type.VAR_INT);
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
int newSize = size;
|
int newSize = size;
|
||||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.protocol.Protocol;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
import it.unimi.dsi.fastutil.ints.IntList;
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
@ -136,9 +136,9 @@ public class TagRewriter<C extends ClientboundPacketType> {
|
|||||||
* @param readUntilType read and process the types until (including) the given registry type
|
* @param readUntilType read and process the types until (including) the given registry type
|
||||||
*/
|
*/
|
||||||
public void register(C packetType, @Nullable RegistryType readUntilType) {
|
public void register(C packetType, @Nullable RegistryType readUntilType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(getHandler(readUntilType));
|
handler(getHandler(readUntilType));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -150,9 +150,9 @@ public class TagRewriter<C extends ClientboundPacketType> {
|
|||||||
* @param packetType packet type
|
* @param packetType packet type
|
||||||
*/
|
*/
|
||||||
public void registerGeneric(C packetType) {
|
public void registerGeneric(C packetType) {
|
||||||
protocol.registerClientbound(packetType, new PacketRemapper() {
|
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void register() {
|
||||||
handler(getGenericHandler());
|
handler(getGenericHandler());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren