mirror of
https://github.com/ViaVersion/ViaLegacy.git
synced 2025-02-01 23:21:27 +01:00
Updated to ViaVersion 5
This commit is contained in:
parent
e1bf8b9680
commit
f5f99622cf
@ -6,7 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
base {
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"
|
||||
|
||||
group = project.maven_group ?: rootProject.maven_group
|
||||
@ -23,7 +23,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "com.viaversion:viaversion-common:4.10.1-SNAPSHOT"
|
||||
compileOnly "com.viaversion:viaversion-common:5.0.0-SNAPSHOT"
|
||||
compileOnly "org.yaml:snakeyaml:2.2"
|
||||
compileOnly "com.google.guava:guava:33.2.0-jre"
|
||||
compileOnly "io.netty:netty-handler:4.1.109.Final"
|
||||
@ -40,7 +40,6 @@ sourceSets {
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -4,4 +4,4 @@ org.gradle.configureondemand=true
|
||||
|
||||
maven_group=net.raphimc
|
||||
maven_name=ViaLegacy
|
||||
maven_version=2.2.23-SNAPSHOT
|
||||
maven_version=3.0.0-SNAPSHOT
|
||||
|
@ -24,6 +24,7 @@ import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ViaLegacyConfig extends Config implements net.raphimc.vialegacy.platform.ViaLegacyConfig {
|
||||
|
||||
@ -37,8 +38,8 @@ public class ViaLegacyConfig extends Config implements net.raphimc.vialegacy.pla
|
||||
private int classicChunkRange;
|
||||
private boolean enableClassicFly;
|
||||
|
||||
public ViaLegacyConfig(final File configFile) {
|
||||
super(configFile);
|
||||
public ViaLegacyConfig(final File configFile, final Logger logger) {
|
||||
super(configFile, logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.connection.ProtocolInfo;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.base.ServerboundHandshakePackets;
|
||||
import com.viaversion.viaversion.protocols.base.ServerboundLoginPackets;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.HandshakeStorage;
|
||||
@ -39,9 +39,9 @@ public class PreNettyBaseProtocol extends AbstractSimpleProtocol {
|
||||
protected void registerPackets() {
|
||||
this.registerServerbound(State.HANDSHAKE, ServerboundHandshakePackets.CLIENT_INTENTION.getId(), ServerboundHandshakePackets.CLIENT_INTENTION.getId(), wrapper -> {
|
||||
wrapper.cancel();
|
||||
wrapper.read(Type.VAR_INT); // protocolVersion
|
||||
final String hostname = wrapper.read(Type.STRING); // hostName
|
||||
final int port = wrapper.read(Type.UNSIGNED_SHORT); // port
|
||||
wrapper.read(Types.VAR_INT); // protocolVersion
|
||||
final String hostname = wrapper.read(Types.STRING); // hostName
|
||||
final int port = wrapper.read(Types.UNSIGNED_SHORT); // port
|
||||
wrapper.user().put(new HandshakeStorage(hostname, port));
|
||||
});
|
||||
|
||||
|
@ -19,6 +19,8 @@ package net.raphimc.vialegacy.api.protocol;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.*;
|
||||
import com.viaversion.viaversion.exception.CancelException;
|
||||
import com.viaversion.viaversion.exception.InformativeException;
|
||||
|
||||
public abstract class StatelessProtocol<CU extends ClientboundPacketType, CM extends ClientboundPacketType, SM extends ServerboundPacketType, SU extends ServerboundPacketType> extends AbstractProtocol<CU, CM, SM, SU> {
|
||||
|
||||
@ -27,7 +29,7 @@ public abstract class StatelessProtocol<CU extends ClientboundPacketType, CM ext
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception {
|
||||
public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws InformativeException, CancelException {
|
||||
super.transform(direction, direction == Direction.SERVERBOUND ? state : State.PLAY, packetWrapper);
|
||||
}
|
||||
|
||||
|
@ -17,22 +17,24 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.api.remapper;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.nbt.tag.ListTag;
|
||||
import com.viaversion.nbt.tag.StringTag;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.ObjectArrayList;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.ObjectList;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
|
||||
public abstract class LegacyItemRewriter<P extends Protocol> extends RewriterBase<P> implements ItemRewriter<P> {
|
||||
public abstract class LegacyItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType, P extends Protocol<C, ?, ?, S>> extends RewriterBase<P> implements ItemRewriter<P> {
|
||||
|
||||
private final ObjectList<RewriteEntry> rewriteEntries = new ObjectArrayList<>();
|
||||
private final ObjectList<NonExistentEntry> nonExistentItems = new ObjectArrayList<>();
|
||||
@ -90,11 +92,11 @@ public abstract class LegacyItemRewriter<P extends Protocol> extends RewriterBas
|
||||
}
|
||||
|
||||
|
||||
public void registerCreativeInventoryAction(final ServerboundPacketType packetType) {
|
||||
public void registerCreativeInventoryAction(final S packetType) {
|
||||
this.protocol.registerServerbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.SHORT); // slot
|
||||
map(Types.SHORT); // slot
|
||||
handler(wrapper -> handleServerboundItem(wrapper));
|
||||
}
|
||||
});
|
||||
@ -159,12 +161,12 @@ public abstract class LegacyItemRewriter<P extends Protocol> extends RewriterBas
|
||||
return "VL|" + this.protocol.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
private void handleClientboundItem(final PacketWrapper wrapper) throws Exception {
|
||||
private void handleClientboundItem(final PacketWrapper wrapper) {
|
||||
final Item item = this.handleItemToClient(wrapper.user(), wrapper.read(this.itemType));
|
||||
wrapper.write(this.mappedItemType, item);
|
||||
}
|
||||
|
||||
private void handleServerboundItem(final PacketWrapper wrapper) throws Exception {
|
||||
private void handleServerboundItem(final PacketWrapper wrapper) {
|
||||
final Item item = this.handleItemToServer(wrapper.user(), wrapper.read(this.mappedItemType));
|
||||
wrapper.write(this.itemType, item);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
public class PacketUtil {
|
||||
|
||||
public static int calculateLength(final PacketWrapper wrapper) throws Exception {
|
||||
public static int calculateLength(final PacketWrapper wrapper) {
|
||||
final PacketType packetType = wrapper.getPacketType();
|
||||
wrapper.setPacketType(null);
|
||||
|
||||
|
@ -19,7 +19,7 @@ package net.raphimc.vialegacy.netty;
|
||||
|
||||
import com.google.common.collect.EvictingQueue;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@ -77,8 +77,8 @@ public class PreNettyLengthPrepender extends ByteToMessageDecoder {
|
||||
}
|
||||
|
||||
final ByteBuf buf = ctx.alloc().buffer();
|
||||
Type.VAR_INT.writePrimitive(buf, totalLength); // length
|
||||
Type.VAR_INT.writePrimitive(buf, packetId); // id
|
||||
Types.VAR_INT.writePrimitive(buf, totalLength); // length
|
||||
Types.VAR_INT.writePrimitive(buf, packetId); // id
|
||||
buf.writeBytes(in.readSlice(length)); // content
|
||||
out.add(buf);
|
||||
} catch (IndexOutOfBoundsException e) { // Not enough data
|
||||
|
@ -18,7 +18,7 @@
|
||||
package net.raphimc.vialegacy.netty;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
@ -33,8 +33,8 @@ public class PreNettyLengthRemover extends MessageToByteEncoder<ByteBuf> {
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) {
|
||||
Type.VAR_INT.readPrimitive(in); // length
|
||||
out.writeByte(Type.VAR_INT.readPrimitive(in) & 255); // id
|
||||
Types.VAR_INT.readPrimitive(in); // length
|
||||
out.writeByte(Types.VAR_INT.readPrimitive(in) & 255); // id
|
||||
out.writeBytes(in); // content
|
||||
}
|
||||
|
||||
|
@ -69,10 +69,10 @@ import java.util.logging.Logger;
|
||||
public interface ViaLegacyPlatform {
|
||||
|
||||
default void init(final File configFile) {
|
||||
final ViaLegacyConfig config = new ViaLegacyConfig(configFile);
|
||||
final ViaLegacyConfig config = new ViaLegacyConfig(configFile, this.getLogger());
|
||||
config.reload();
|
||||
ViaLegacy.init(this, config);
|
||||
Via.getManager().getConfigurationProvider().register(config);
|
||||
ViaLegacy.init(this, config);
|
||||
Via.getManager().getSubPlatforms().add(ViaLegacy.IMPL_VERSION);
|
||||
|
||||
final ProtocolManager protocolManager = Via.getManager().getProtocolManager();
|
||||
|
@ -29,47 +29,47 @@ public enum ClientboundPacketsa1_0_15 implements ClientboundPacketType, PreNetty
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
}),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ADD_TO_INVENTORY(17, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
DISCONNECT(255, (user, buf) -> PreNettyTypes.readUTF(buf));
|
||||
|
||||
private static final ClientboundPacketsa1_0_15[] REGISTRY = new ClientboundPacketsa1_0_15[256];
|
||||
|
@ -34,15 +34,15 @@ public enum ServerboundPacketsa1_0_15 implements ServerboundPacketType, PreNetty
|
||||
PreNettyTypes.readUTF(buf);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
}),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> buf.skipBytes(12)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
DISCONNECT(255, (user, buf) -> PreNettyTypes.readUTF(buf));
|
||||
|
||||
|
@ -30,48 +30,48 @@ public enum ClientboundPacketsa1_0_16 implements ClientboundPacketType, PreNetty
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ADD_TO_INVENTORY(17, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
DISCONNECT(255, (user, buf) -> readUTF(buf));
|
||||
|
||||
private static final ClientboundPacketsa1_0_16[] REGISTRY = new ClientboundPacketsa1_0_16[256];
|
||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.storage.TimeLockStorage;
|
||||
@ -38,14 +38,14 @@ public class Protocola1_0_17_1_0_17_4toa1_0_16_2 extends StatelessProtocol<Clien
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerServerbound(ServerboundPacketsa1_0_17.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsa1_0_17.USE_ITEM_ON, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.SHORT); // item id
|
||||
map(Types.SHORT); // item id
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.UNSIGNED_BYTE); // direction
|
||||
map(Types.UNSIGNED_BYTE); // direction
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.SHORT, 0) < 0) {
|
||||
if (wrapper.get(Types.SHORT, 0) < 0) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
|
@ -20,7 +20,7 @@ package net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.Protocola1_0_17_1_0_17_4toa1_0_16_2;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.storage.TimeLockStorage;
|
||||
@ -47,13 +47,13 @@ public class TimeLockTask implements Runnable {
|
||||
if (timeLockStorage.getTime() == 0) { // 0 always does the daylight cycle
|
||||
timeLockStorage.setTime(1); // Set it to 1 which is close enough
|
||||
}
|
||||
final PacketWrapper updateTime = PacketWrapper.create(ClientboundPackets1_6_1.TIME_UPDATE, info);
|
||||
updateTime.write(Type.LONG, timeLockStorage.getTime()); // time
|
||||
updateTime.write(Type.LONG, -(timeLockStorage.getTime() % 24000)); // time of day
|
||||
final PacketWrapper updateTime = PacketWrapper.create(ClientboundPackets1_6_1.SET_TIME, info);
|
||||
updateTime.write(Types.LONG, timeLockStorage.getTime()); // time
|
||||
updateTime.write(Types.LONG, -(timeLockStorage.getTime() % 24000)); // time of day
|
||||
updateTime.send(Protocol1_6_1to1_5_2.class);
|
||||
} else {
|
||||
final PacketWrapper updateTime = PacketWrapper.create(ClientboundPacketsa1_0_17.TIME_UPDATE, info);
|
||||
updateTime.write(Type.LONG, timeLockStorage.getTime()); // time
|
||||
final PacketWrapper updateTime = PacketWrapper.create(ClientboundPacketsa1_0_17.SET_TIME, info);
|
||||
updateTime.write(Types.LONG, timeLockStorage.getTime()); // time
|
||||
updateTime.send(Protocola1_0_17_1_0_17_4toa1_0_16_2.class);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
|
@ -30,50 +30,50 @@ public enum ClientboundPacketsa1_0_17 implements ClientboundPacketType, PreNetty
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ADD_TO_INVENTORY(17, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
DISCONNECT(255, (user, buf) -> readUTF(buf));
|
||||
|
||||
private static final ClientboundPacketsa1_0_17[] REGISTRY = new ClientboundPacketsa1_0_17[256];
|
||||
|
@ -31,7 +31,7 @@ public class Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4 extends StatelessProtocol<
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.cancelServerbound(ServerboundPacketsa1_1_0.COMPLEX_ENTITY);
|
||||
this.cancelServerbound(ServerboundPacketsa1_1_0.BLOCK_ENTITY_DATA);
|
||||
this.cancelServerbound(ServerboundPacketsa1_1_0.PLAYER_INVENTORY);
|
||||
}
|
||||
|
||||
|
@ -36,15 +36,15 @@ public enum ServerboundPacketsa1_0_17 implements ServerboundPacketType, PreNetty
|
||||
readUTF(buf);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> buf.skipBytes(12)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
DISCONNECT(255, (user, buf) -> readUTF(buf));
|
||||
|
||||
|
@ -31,57 +31,57 @@ public enum ClientboundPacketsa1_1_0 implements ClientboundPacketType, PreNettyP
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_INVENTORY(5, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ADD_TO_INVENTORY(17, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
COMPLEX_ENTITY(59, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ENTITY_DATA(59, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readUnsignedShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
|
@ -19,7 +19,7 @@ package net.raphimc.vialegacy.protocols.alpha.protocola1_2_0_1_2_1_1toa1_1_0_1_1
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_2toa1_2_0_1_2_1_1.ClientboundPacketsa1_2_0;
|
||||
@ -34,25 +34,25 @@ public class Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1 extends StatelessProtocol<Cl
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsa1_1_0.JOIN_GAME, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsa1_1_0.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Typesb1_7_0_3.STRING); // username
|
||||
map(Typesb1_7_0_3.STRING); // password
|
||||
create(Type.LONG, 0L); // seed
|
||||
create(Type.BYTE, (byte) 0); // dimension id
|
||||
create(Types.LONG, 0L); // seed
|
||||
create(Types.BYTE, (byte) 0); // dimension id
|
||||
}
|
||||
});
|
||||
|
||||
this.registerServerbound(ServerboundPacketsa1_2_0.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // protocol id
|
||||
map(Types.INT); // protocol id
|
||||
map(Typesb1_7_0_3.STRING); // username
|
||||
map(Typesb1_7_0_3.STRING); // password
|
||||
read(Type.LONG); // seed
|
||||
read(Type.BYTE); // dimension id
|
||||
read(Types.LONG); // seed
|
||||
read(Types.BYTE); // dimension id
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -37,22 +37,22 @@ public enum ServerboundPacketsa1_1_0 implements ServerboundPacketType, PreNettyP
|
||||
readUTF(buf);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
PLAYER_INVENTORY(5, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> buf.skipBytes(12)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COMPLEX_ENTITY(59, (user, buf) -> {
|
||||
BLOCK_ENTITY_DATA(59, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readUnsignedShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
|
@ -29,58 +29,58 @@ public enum ClientboundPacketsa1_2_0 implements ClientboundPacketType, PreNettyP
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_INVENTORY(5, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) PreNettyTypes.readItemStackb1_2(buf);
|
||||
}),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ADD_TO_INVENTORY(17, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
COMPLEX_ENTITY(59, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ENTITY_DATA(59, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readUnsignedShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
|
@ -19,7 +19,7 @@ package net.raphimc.vialegacy.protocols.alpha.protocola1_2_2toa1_2_0_1_2_1_1;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_1_2_3_4toa1_2_2.ClientboundPacketsa1_2_2;
|
||||
@ -33,25 +33,25 @@ public class Protocola1_2_2toa1_2_0_1_2_1_1 extends StatelessProtocol<Clientboun
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_0.SPAWN_MOB, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_0.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.UNSIGNED_BYTE); // type id
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Types.INT); // entity id
|
||||
map(Types.UNSIGNED_BYTE); // type id
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 91) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 0, (short) 93);
|
||||
if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 91) {
|
||||
wrapper.set(Types.UNSIGNED_BYTE, 0, (short) 93);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.cancelServerbound(ServerboundPacketsa1_2_2.INTERACT_ENTITY);
|
||||
this.cancelServerbound(ServerboundPacketsa1_2_2.INTERACT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,22 +36,22 @@ public enum ServerboundPacketsa1_2_0 implements ServerboundPacketType, PreNettyP
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
PLAYER_INVENTORY(5, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) PreNettyTypes.readItemStackb1_2(buf);
|
||||
}),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> buf.skipBytes(12)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COMPLEX_ENTITY(59, (user, buf) -> {
|
||||
BLOCK_ENTITY_DATA(59, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readUnsignedShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
|
@ -29,60 +29,60 @@ public enum ClientboundPacketsa1_2_2 implements ClientboundPacketType, PreNettyP
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_INVENTORY(5, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) PreNettyTypes.readItemStackb1_2(buf);
|
||||
}),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ADD_TO_INVENTORY(17, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
COMPLEX_ENTITY(59, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ENTITY_DATA(59, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readUnsignedShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
|
@ -20,7 +20,7 @@ package net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_1_2_3_4toa1_2_2;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4.ClientboundPacketsa1_2_3;
|
||||
@ -34,21 +34,21 @@ public class Protocola1_2_3_1_2_3_4toa1_2_2 extends StatelessProtocol<Clientboun
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_2.JOIN_GAME, wrapper -> {
|
||||
final PacketWrapper updateHealth = PacketWrapper.create(ClientboundPacketsa1_2_3.UPDATE_HEALTH, wrapper.user());
|
||||
updateHealth.write(Type.BYTE, (byte) 20); // health
|
||||
this.registerClientbound(ClientboundPacketsa1_2_2.LOGIN, wrapper -> {
|
||||
final PacketWrapper updateHealth = PacketWrapper.create(ClientboundPacketsa1_2_3.SET_HEALTH, wrapper.user());
|
||||
updateHealth.write(Types.BYTE, (byte) 20); // health
|
||||
|
||||
wrapper.send(Protocola1_2_3_1_2_3_4toa1_2_2.class);
|
||||
updateHealth.send(Protocola1_2_3_1_2_3_4toa1_2_2.class);
|
||||
wrapper.cancel();
|
||||
});
|
||||
|
||||
this.registerServerbound(ServerboundPacketsa1_2_6.INTERACT_ENTITY, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsa1_2_6.INTERACT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // player id
|
||||
map(Type.INT); // entity id
|
||||
read(Type.BYTE); // mode
|
||||
map(Types.INT); // player id
|
||||
map(Types.INT); // entity id
|
||||
read(Types.BYTE); // mode
|
||||
}
|
||||
});
|
||||
this.cancelServerbound(ServerboundPacketsa1_2_6.RESPAWN);
|
||||
|
@ -36,23 +36,23 @@ public enum ServerboundPacketsa1_2_2 implements ServerboundPacketType, PreNettyP
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
PLAYER_INVENTORY(5, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) PreNettyTypes.readItemStackb1_2(buf);
|
||||
}),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> buf.skipBytes(12)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(8)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COMPLEX_ENTITY(59, (user, buf) -> {
|
||||
BLOCK_ENTITY_DATA(59, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readUnsignedShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
|
@ -31,64 +31,64 @@ public enum ClientboundPacketsa1_2_3 implements ClientboundPacketType, PreNettyP
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_INVENTORY(5, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(1)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ADD_TO_INVENTORY(17, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
COMPLEX_ENTITY(59, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ENTITY_DATA(59, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readUnsignedShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
|
@ -19,7 +19,7 @@ package net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_5_1_2_6toa1_2_3_1_2
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.ClientboundPacketsa1_2_6;
|
||||
@ -33,13 +33,13 @@ public class Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4 extends StatelessProtocol<Cl
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_3.ENTITY_VELOCITY, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_3.SET_ENTITY_MOTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.SHORT, Type.SHORT, v -> (short) (v / 4.0F)); // velocity x
|
||||
map(Type.SHORT, Type.SHORT, v -> (short) (v / 4.0F)); // velocity y
|
||||
map(Type.SHORT, Type.SHORT, v -> (short) (v / 4.0F)); // velocity z
|
||||
map(Types.INT); // entity id
|
||||
map(Types.SHORT, Types.SHORT, v -> (short) (v / 4.0F)); // velocity x
|
||||
map(Types.SHORT, Types.SHORT, v -> (short) (v / 4.0F)); // velocity y
|
||||
map(Types.SHORT, Types.SHORT, v -> (short) (v / 4.0F)); // velocity z
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -31,69 +31,69 @@ public enum ClientboundPacketsa1_2_6 implements ClientboundPacketType, PreNettyP
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_INVENTORY(5, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(1)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ADD_TO_INVENTORY(17, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
COMPLEX_ENTITY(59, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ENTITY_DATA(59, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readUnsignedShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6;
|
||||
|
||||
import com.viaversion.nbt.tag.*;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
@ -25,8 +26,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.api.data.BlockList1_6;
|
||||
@ -64,10 +64,10 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.PLAYER_INVENTORY, ClientboundPacketsb1_1.WINDOW_ITEMS, wrapper -> {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.PLAYER_INVENTORY, ClientboundPacketsb1_1.CONTAINER_SET_CONTENT, wrapper -> {
|
||||
final InventoryStorage inventoryStorage = wrapper.user().get(InventoryStorage.class);
|
||||
final AlphaInventoryTracker inventoryTracker = wrapper.user().get(AlphaInventoryTracker.class);
|
||||
final int type = wrapper.read(Type.INT); // type
|
||||
final int type = wrapper.read(Types.INT); // type
|
||||
Item[] items = wrapper.read(Types1_4_2.NBTLESS_ITEM_ARRAY); // items
|
||||
|
||||
final Item[] windowItems = new Item[45];
|
||||
@ -94,13 +94,13 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
System.arraycopy(reverseArray(items), 0, windowItems, 5, 4);
|
||||
}
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) 0); // window id
|
||||
wrapper.write(Types.BYTE, (byte) 0); // window id
|
||||
wrapper.write(Types1_4_2.NBTLESS_ITEM_ARRAY, copyItems(windowItems)); // items
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.UPDATE_HEALTH, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.SET_HEALTH, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE, Type.SHORT); // health
|
||||
map(Types.BYTE, Types.SHORT); // health
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.RESPAWN, wrapper -> {
|
||||
@ -109,15 +109,15 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
final AlphaInventoryTracker inventoryTracker = wrapper.user().get(AlphaInventoryTracker.class);
|
||||
if (inventoryTracker != null) inventoryTracker.onRespawn();
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.HELD_ITEM_CHANGE, ClientboundPacketsb1_1.ENTITY_EQUIPMENT, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.SET_CARRIED_ITEM, ClientboundPacketsb1_1.SET_EQUIPPED_ITEM, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
create(Type.SHORT, (short) 0); // slot (hand)
|
||||
map(Type.SHORT); // item id
|
||||
map(Types.INT); // entity id
|
||||
create(Types.SHORT, (short) 0); // slot (hand)
|
||||
map(Types.SHORT); // item id
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.SHORT, 1) == 0) {
|
||||
wrapper.set(Type.SHORT, 1, (short) -1);
|
||||
if (wrapper.get(Types.SHORT, 1) == 0) {
|
||||
wrapper.set(Types.SHORT, 1, (short) -1);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -130,41 +130,41 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.PRE_CHUNK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // chunkX
|
||||
map(Type.INT); // chunkZ
|
||||
map(Type.UNSIGNED_BYTE); // mode
|
||||
handler(wrapper -> wrapper.user().get(InventoryStorage.class).unload(wrapper.get(Type.INT, 0), wrapper.get(Type.INT, 1)));
|
||||
map(Types.INT); // chunkX
|
||||
map(Types.INT); // chunkZ
|
||||
map(Types.UNSIGNED_BYTE); // mode
|
||||
handler(wrapper -> wrapper.user().get(InventoryStorage.class).unload(wrapper.get(Types.INT, 0), wrapper.get(Types.INT, 1)));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.COMPLEX_ENTITY, null, wrapper -> {
|
||||
this.registerClientbound(ClientboundPacketsa1_2_6.BLOCK_ENTITY_DATA, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
final InventoryStorage tracker = wrapper.user().get(InventoryStorage.class);
|
||||
final Position pos = wrapper.read(Types1_7_6.POSITION_SHORT); // position
|
||||
final CompoundTag tag = wrapper.read(Types1_7_6.NBT); // data
|
||||
|
||||
if (tag.<IntTag>get("x").asInt() != pos.x() || tag.<IntTag>get("y").asInt() != pos.y() || tag.<IntTag>get("z").asInt() != pos.z()) {
|
||||
if (tag.getInt("x") != pos.x() || tag.getInt("y") != pos.y() || tag.getInt("z") != pos.z()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IdAndData block = wrapper.user().get(ChunkTracker.class).getBlockNotNull(pos);
|
||||
final String blockName = tag.get("id") != null ? tag.<StringTag>get("id").getValue() : "";
|
||||
final String blockName = tag.getString("id", "");
|
||||
|
||||
if (block.getId() == BlockList1_6.signPost.blockID || block.getId() == BlockList1_6.signWall.blockID || blockName.equals("Sign")) {
|
||||
final PacketWrapper updateSign = PacketWrapper.create(ClientboundPacketsb1_1.UPDATE_SIGN, wrapper.user());
|
||||
updateSign.write(Types1_7_6.POSITION_SHORT, pos); // position
|
||||
updateSign.write(Typesb1_7_0_3.STRING, tag.<StringTag>get("Text1").getValue()); // line 1
|
||||
updateSign.write(Typesb1_7_0_3.STRING, tag.<StringTag>get("Text2").getValue()); // line 2
|
||||
updateSign.write(Typesb1_7_0_3.STRING, tag.<StringTag>get("Text3").getValue()); // line 3
|
||||
updateSign.write(Typesb1_7_0_3.STRING, tag.<StringTag>get("Text4").getValue()); // line 4
|
||||
updateSign.write(Typesb1_7_0_3.STRING, tag.getString("Text1", "")); // line 1
|
||||
updateSign.write(Typesb1_7_0_3.STRING, tag.getString("Text2", "")); // line 2
|
||||
updateSign.write(Typesb1_7_0_3.STRING, tag.getString("Text3", "")); // line 3
|
||||
updateSign.write(Typesb1_7_0_3.STRING, tag.getString("Text4", "")); // line 4
|
||||
updateSign.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
} else if (block.getId() == BlockList1_6.mobSpawner.blockID || blockName.equals("MobSpawner")) {
|
||||
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocol1_2_1_3to1_1.class)) {
|
||||
final PacketWrapper spawnerData = PacketWrapper.create(ClientboundPackets1_2_1.BLOCK_ENTITY_DATA, wrapper.user());
|
||||
spawnerData.write(Types1_7_6.POSITION_SHORT, pos); // position
|
||||
spawnerData.write(Type.BYTE, (byte) 1); // type
|
||||
spawnerData.write(Type.INT, EntityList.getEntityId(tag.<StringTag>get("EntityId").getValue())); // entity id
|
||||
spawnerData.write(Type.INT, 0); // unused
|
||||
spawnerData.write(Type.INT, 0); // unused
|
||||
spawnerData.write(Types.BYTE, (byte) 1); // type
|
||||
spawnerData.write(Types.INT, EntityList.getEntityId(tag.getString("EntityId"))); // entity id
|
||||
spawnerData.write(Types.INT, 0); // unused
|
||||
spawnerData.write(Types.INT, 0); // unused
|
||||
spawnerData.send(Protocol1_2_1_3to1_1.class);
|
||||
}
|
||||
} else if (block.getId() == BlockList1_6.chest.blockID || blockName.equals("Chest")) {
|
||||
@ -178,8 +178,8 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
tracker.containers.put(pos, furnaceItems);
|
||||
if (pos.equals(tracker.openContainerPos)) {
|
||||
sendWindowItems(wrapper.user(), InventoryStorage.FURNACE_WID, furnaceItems);
|
||||
sendProgressUpdate(wrapper.user(), InventoryStorage.FURNACE_WID, (short) 0, tag.<ShortTag>get("CookTime").asShort()); // cook time
|
||||
sendProgressUpdate(wrapper.user(), InventoryStorage.FURNACE_WID, (short) 1, tag.<ShortTag>get("BurnTime").asShort()); // furnace burn time
|
||||
sendProgressUpdate(wrapper.user(), InventoryStorage.FURNACE_WID, (short) 0, tag.getShort("CookTime")); // cook time
|
||||
sendProgressUpdate(wrapper.user(), InventoryStorage.FURNACE_WID, (short) 1, tag.getShort("BurnTime")); // furnace burn time
|
||||
sendProgressUpdate(wrapper.user(), InventoryStorage.FURNACE_WID, (short) 2, getBurningTime(furnaceItems[1])); // item burn time
|
||||
}
|
||||
} else {
|
||||
@ -187,14 +187,14 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
}
|
||||
});
|
||||
|
||||
this.registerServerbound(ServerboundPacketsb1_1.PLAYER_DIGGING, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_1.PLAYER_ACTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // status
|
||||
map(Types.UNSIGNED_BYTE); // status
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.UNSIGNED_BYTE); // direction
|
||||
map(Types.UNSIGNED_BYTE); // direction
|
||||
handler(wrapper -> {
|
||||
final short status = wrapper.get(Type.UNSIGNED_BYTE, 0);
|
||||
final short status = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
||||
if (status == 4) {
|
||||
wrapper.cancel();
|
||||
|
||||
@ -212,20 +212,20 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_1.PLAYER_BLOCK_PLACEMENT, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsb1_1.USE_ITEM_ON, wrapper -> {
|
||||
final InventoryStorage tracker = wrapper.user().get(InventoryStorage.class);
|
||||
final AlphaInventoryTracker inventoryTracker = wrapper.user().get(AlphaInventoryTracker.class);
|
||||
final Position pos = wrapper.read(Types1_7_6.POSITION_UBYTE); // position
|
||||
final short direction = wrapper.read(Type.UNSIGNED_BYTE); // direction
|
||||
final short direction = wrapper.read(Types.UNSIGNED_BYTE); // direction
|
||||
Item item = fixItem(wrapper.read(Typesb1_1.NBTLESS_ITEM)); // item
|
||||
|
||||
if (item == null && inventoryTracker != null) {
|
||||
item = Via.getManager().getProviders().get(AlphaInventoryProvider.class).getHandItem(wrapper.user());
|
||||
}
|
||||
|
||||
wrapper.write(Type.SHORT, item == null ? (short) -1 : (short) item.identifier()); // item id
|
||||
wrapper.write(Types.SHORT, item == null ? (short) -1 : (short) item.identifier()); // item id
|
||||
wrapper.write(Types1_7_6.POSITION_UBYTE, pos);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, direction);
|
||||
wrapper.write(Types.UNSIGNED_BYTE, direction);
|
||||
|
||||
if (inventoryTracker != null) inventoryTracker.onBlockPlace(pos, direction);
|
||||
|
||||
@ -239,30 +239,30 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
final Item[] containerItems = tracker.containers.get(tracker.openContainerPos = pos);
|
||||
if (containerItems == null && block.getId() != BlockList1_6.workbench.blockID) {
|
||||
tracker.openContainerPos = null;
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsb1_1.CHAT_MESSAGE, wrapper.user());
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsb1_1.CHAT, wrapper.user());
|
||||
chatMessage.write(Typesb1_7_0_3.STRING, "§cMissing Container"); // message
|
||||
chatMessage.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
return;
|
||||
}
|
||||
|
||||
final PacketWrapper openWindow = PacketWrapper.create(ClientboundPacketsb1_1.OPEN_WINDOW, wrapper.user());
|
||||
final PacketWrapper openWindow = PacketWrapper.create(ClientboundPacketsb1_1.OPEN_SCREEN, wrapper.user());
|
||||
if (block.getId() == BlockList1_6.chest.blockID) {
|
||||
openWindow.write(Type.UNSIGNED_BYTE, (short) InventoryStorage.CHEST_WID); // window id
|
||||
openWindow.write(Type.UNSIGNED_BYTE, (short) 0); // window type
|
||||
openWindow.write(Types.UNSIGNED_BYTE, (short) InventoryStorage.CHEST_WID); // window id
|
||||
openWindow.write(Types.UNSIGNED_BYTE, (short) 0); // window type
|
||||
openWindow.write(Typesb1_7_0_3.STRING, "Chest"); // title
|
||||
openWindow.write(Type.UNSIGNED_BYTE, (short) (3 * 9)); // slots
|
||||
openWindow.write(Types.UNSIGNED_BYTE, (short) (3 * 9)); // slots
|
||||
if (inventoryTracker != null) inventoryTracker.onWindowOpen(0, 3 * 9);
|
||||
} else if (block.getId() == BlockList1_6.workbench.blockID) {
|
||||
openWindow.write(Type.UNSIGNED_BYTE, (short) InventoryStorage.WORKBENCH_WID); // window id
|
||||
openWindow.write(Type.UNSIGNED_BYTE, (short) 1); // window type
|
||||
openWindow.write(Types.UNSIGNED_BYTE, (short) InventoryStorage.WORKBENCH_WID); // window id
|
||||
openWindow.write(Types.UNSIGNED_BYTE, (short) 1); // window type
|
||||
openWindow.write(Typesb1_7_0_3.STRING, "Crafting Table"); // title
|
||||
openWindow.write(Type.UNSIGNED_BYTE, (short) 9); // slots
|
||||
openWindow.write(Types.UNSIGNED_BYTE, (short) 9); // slots
|
||||
if (inventoryTracker != null) inventoryTracker.onWindowOpen(1, 10);
|
||||
} else { // furnace
|
||||
openWindow.write(Type.UNSIGNED_BYTE, (short) InventoryStorage.FURNACE_WID); // window id
|
||||
openWindow.write(Type.UNSIGNED_BYTE, (short) 2); // window type
|
||||
openWindow.write(Types.UNSIGNED_BYTE, (short) InventoryStorage.FURNACE_WID); // window id
|
||||
openWindow.write(Types.UNSIGNED_BYTE, (short) 2); // window type
|
||||
openWindow.write(Typesb1_7_0_3.STRING, "Furnace"); // title
|
||||
openWindow.write(Type.UNSIGNED_BYTE, (short) 3); // slots
|
||||
openWindow.write(Types.UNSIGNED_BYTE, (short) 3); // slots
|
||||
if (inventoryTracker != null) inventoryTracker.onWindowOpen(2, 3);
|
||||
}
|
||||
openWindow.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
@ -271,9 +271,9 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
sendWindowItems(wrapper.user(), block.getId() == BlockList1_6.chest.blockID ? InventoryStorage.CHEST_WID : InventoryStorage.FURNACE_WID, containerItems);
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_1.HELD_ITEM_CHANGE, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsb1_1.SET_CARRIED_ITEM, wrapper -> {
|
||||
final InventoryStorage inventoryStorage = wrapper.user().get(InventoryStorage.class);
|
||||
short slot = wrapper.read(Type.SHORT); // slot
|
||||
short slot = wrapper.read(Types.SHORT); // slot
|
||||
if (slot < 0 || slot > 8) slot = 0;
|
||||
inventoryStorage.selectedHotbarSlot = slot;
|
||||
final Item selectedItem = fixItem(Via.getManager().getProviders().get(AlphaInventoryProvider.class).getHandItem(wrapper.user()));
|
||||
@ -283,23 +283,23 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
}
|
||||
inventoryStorage.handItem = selectedItem;
|
||||
|
||||
wrapper.write(Type.INT, 0); // entity id (always 0)
|
||||
wrapper.write(Type.SHORT, (short) (selectedItem == null ? 0 : selectedItem.identifier())); // item id
|
||||
wrapper.write(Types.INT, 0); // entity id (always 0)
|
||||
wrapper.write(Types.SHORT, (short) (selectedItem == null ? 0 : selectedItem.identifier())); // item id
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_1.CLOSE_WINDOW, null, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsb1_1.CONTAINER_CLOSE, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
wrapper.user().get(InventoryStorage.class).openContainerPos = null;
|
||||
|
||||
final AlphaInventoryTracker inventoryTracker = wrapper.user().get(AlphaInventoryTracker.class);
|
||||
if (inventoryTracker != null) inventoryTracker.onWindowClose();
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_1.CLICK_WINDOW, ServerboundPacketsa1_2_6.COMPLEX_ENTITY, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsb1_1.CONTAINER_CLICK, ServerboundPacketsa1_2_6.BLOCK_ENTITY_DATA, wrapper -> {
|
||||
final InventoryStorage tracker = wrapper.user().get(InventoryStorage.class);
|
||||
final AlphaInventoryTracker inventoryTracker = wrapper.user().get(AlphaInventoryTracker.class);
|
||||
final byte windowId = wrapper.read(Type.BYTE); // window id
|
||||
final short slot = wrapper.read(Type.SHORT); // slot
|
||||
final byte button = wrapper.read(Type.BYTE); // button
|
||||
final short action = wrapper.read(Type.SHORT); // action
|
||||
final byte windowId = wrapper.read(Types.BYTE); // window id
|
||||
final short slot = wrapper.read(Types.SHORT); // slot
|
||||
final byte button = wrapper.read(Types.BYTE); // button
|
||||
final short action = wrapper.read(Types.SHORT); // action
|
||||
final Item item = fixItem(wrapper.read(Typesb1_1.NBTLESS_ITEM)); // item
|
||||
|
||||
if (inventoryTracker != null) inventoryTracker.onWindowClick(windowId, slot, button, action, item);
|
||||
@ -322,12 +322,12 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
tag.put("z", new IntTag(tracker.openContainerPos.z()));
|
||||
writeItemsToTag(tag, containerItems);
|
||||
|
||||
wrapper.write(Type.INT, tracker.openContainerPos.x());
|
||||
wrapper.write(Type.SHORT, (short) tracker.openContainerPos.y());
|
||||
wrapper.write(Type.INT, tracker.openContainerPos.z());
|
||||
wrapper.write(Types.INT, tracker.openContainerPos.x());
|
||||
wrapper.write(Types.SHORT, (short) tracker.openContainerPos.y());
|
||||
wrapper.write(Types.INT, tracker.openContainerPos.z());
|
||||
wrapper.write(Types1_7_6.NBT, tag);
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_1.UPDATE_SIGN, ServerboundPacketsa1_2_6.COMPLEX_ENTITY, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsb1_1.SIGN_UPDATE, ServerboundPacketsa1_2_6.BLOCK_ENTITY_DATA, wrapper -> {
|
||||
final Position pos = wrapper.passthrough(Types1_7_6.POSITION_SHORT); // position
|
||||
|
||||
final CompoundTag tag = new CompoundTag();
|
||||
@ -341,35 +341,34 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
tag.put("Text4", new StringTag(wrapper.read(Typesb1_7_0_3.STRING))); // line 4
|
||||
wrapper.write(Types1_7_6.NBT, tag); // data
|
||||
});
|
||||
this.cancelServerbound(ServerboundPacketsb1_1.WINDOW_CONFIRMATION);
|
||||
this.cancelServerbound(ServerboundPacketsb1_1.CONTAINER_ACK);
|
||||
}
|
||||
|
||||
private void writeItemsToTag(final CompoundTag tag, final Item[] items) {
|
||||
final ListTag slotList = new ListTag();
|
||||
final ListTag<CompoundTag> itemList = new ListTag<>(CompoundTag.class);
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
final Item item = items[i];
|
||||
if (item == null) continue;
|
||||
final CompoundTag slotTag = new CompoundTag();
|
||||
slotTag.put("Slot", new ByteTag((byte) i));
|
||||
slotTag.put("id", new ShortTag((short) item.identifier()));
|
||||
slotTag.put("Count", new ByteTag((byte) item.amount()));
|
||||
slotTag.put("Damage", new ShortTag(item.data()));
|
||||
slotList.add(slotTag);
|
||||
final CompoundTag itemTag = new CompoundTag();
|
||||
itemTag.put("Slot", new ByteTag((byte) i));
|
||||
itemTag.put("id", new ShortTag((short) item.identifier()));
|
||||
itemTag.put("Count", new ByteTag((byte) item.amount()));
|
||||
itemTag.put("Damage", new ShortTag(item.data()));
|
||||
itemList.add(itemTag);
|
||||
}
|
||||
tag.put("Items", slotList);
|
||||
tag.put("Items", itemList);
|
||||
}
|
||||
|
||||
private void readItemsFromTag(final CompoundTag tag, final Item[] items) {
|
||||
final ListTag<?> slotList = tag.get("Items");
|
||||
for (Tag itemTag : slotList) {
|
||||
final CompoundTag slotTag = (CompoundTag) itemTag;
|
||||
items[slotTag.<ByteTag>get("Slot").asByte() & 255] = new DataItem(slotTag.<ShortTag>get("id").asShort(), slotTag.<ByteTag>get("Count").asByte(), slotTag.<ShortTag>get("Damage").asShort(), null);
|
||||
final ListTag<CompoundTag> itemList = tag.getListTag("Items", CompoundTag.class);
|
||||
for (CompoundTag itemTag : itemList) {
|
||||
items[itemTag.getByte("Slot") & 255] = new DataItem(itemTag.getShort("id"), itemTag.getByte("Count"), itemTag.getShort("Damage"), null);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendWindowItems(final UserConnection user, final byte windowId, final Item[] items) throws Exception {
|
||||
final PacketWrapper windowItems = PacketWrapper.create(ClientboundPacketsb1_1.WINDOW_ITEMS, user);
|
||||
windowItems.write(Type.BYTE, windowId); // window id
|
||||
private void sendWindowItems(final UserConnection user, final byte windowId, final Item[] items) {
|
||||
final PacketWrapper windowItems = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_CONTENT, user);
|
||||
windowItems.write(Types.BYTE, windowId); // window id
|
||||
windowItems.write(Types1_4_2.NBTLESS_ITEM_ARRAY, copyItems(items)); // items
|
||||
windowItems.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
|
||||
@ -377,11 +376,11 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
if (inventoryTracker != null) inventoryTracker.setOpenContainerItems(copyItems(items));
|
||||
}
|
||||
|
||||
private void sendProgressUpdate(final UserConnection user, final short windowId, final short id, final short value) throws Exception {
|
||||
final PacketWrapper windowProperty = PacketWrapper.create(ClientboundPacketsb1_1.WINDOW_PROPERTY, user);
|
||||
windowProperty.write(Type.UNSIGNED_BYTE, windowId); // window id
|
||||
windowProperty.write(Type.SHORT, id); // progress bar id
|
||||
windowProperty.write(Type.SHORT, value); // progress bar value
|
||||
private void sendProgressUpdate(final UserConnection user, final short windowId, final short id, final short value) {
|
||||
final PacketWrapper windowProperty = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_DATA, user);
|
||||
windowProperty.write(Types.UNSIGNED_BYTE, windowId); // window id
|
||||
windowProperty.write(Types.SHORT, id); // progress bar id
|
||||
windowProperty.write(Types.SHORT, value); // progress bar value
|
||||
windowProperty.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
}
|
||||
|
||||
@ -401,7 +400,7 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void dropItem(final UserConnection user, final Item item, final boolean flag) throws Exception {
|
||||
public static void dropItem(final UserConnection user, final Item item, final boolean flag) {
|
||||
final PlayerInfoStorage playerInfoStorage = user.get(PlayerInfoStorage.class);
|
||||
final double itemX = playerInfoStorage.posX;
|
||||
final double itemY = playerInfoStorage.posY + 1.62F - 0.30000001192092896D + 0.12D;
|
||||
@ -427,15 +426,15 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
|
||||
}
|
||||
|
||||
final PacketWrapper spawnItem = PacketWrapper.create(ServerboundPacketsa1_2_6.SPAWN_ITEM, user);
|
||||
spawnItem.write(Type.INT, 0); // entity id
|
||||
spawnItem.write(Type.SHORT, (short) item.identifier()); // item id
|
||||
spawnItem.write(Type.BYTE, (byte) item.amount()); // item count
|
||||
spawnItem.write(Type.INT, (int) (itemX * 32)); // x
|
||||
spawnItem.write(Type.INT, (int) (itemY * 32)); // y
|
||||
spawnItem.write(Type.INT, (int) (itemZ * 32)); // z
|
||||
spawnItem.write(Type.BYTE, (byte) (motionX * 128)); // velocity x
|
||||
spawnItem.write(Type.BYTE, (byte) (motionY * 128)); // velocity y
|
||||
spawnItem.write(Type.BYTE, (byte) (motionZ * 128)); // velocity z
|
||||
spawnItem.write(Types.INT, 0); // entity id
|
||||
spawnItem.write(Types.SHORT, (short) item.identifier()); // item id
|
||||
spawnItem.write(Types.BYTE, (byte) item.amount()); // item count
|
||||
spawnItem.write(Types.INT, (int) (itemX * 32)); // x
|
||||
spawnItem.write(Types.INT, (int) (itemY * 32)); // y
|
||||
spawnItem.write(Types.INT, (int) (itemZ * 32)); // z
|
||||
spawnItem.write(Types.BYTE, (byte) (motionX * 128)); // velocity x
|
||||
spawnItem.write(Types.BYTE, (byte) (motionY * 128)); // velocity y
|
||||
spawnItem.write(Types.BYTE, (byte) (motionZ * 128)); // velocity z
|
||||
spawnItem.sendToServer(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
}
|
||||
|
||||
|
@ -36,25 +36,25 @@ public enum ServerboundPacketsa1_2_6 implements ServerboundPacketType, PreNettyP
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
PLAYER_INVENTORY(5, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) PreNettyTypes.readItemStackb1_2(buf);
|
||||
}),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(9)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(9)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> buf.skipBytes(12)),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(6)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(6)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COMPLEX_ENTITY(59, (user, buf) -> {
|
||||
BLOCK_ENTITY_DATA(59, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readUnsignedShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.data.BlockList1_6;
|
||||
@ -67,7 +67,7 @@ public class AlphaInventoryTracker extends StoredObject {
|
||||
this.openContainerItems = new Item[containerSlots];
|
||||
}
|
||||
|
||||
public void onWindowClose() throws Exception {
|
||||
public void onWindowClose() {
|
||||
if (this.openWindowType == 1) { // crafting table
|
||||
for (int i = 1; i <= 9; i++) {
|
||||
final Item item = this.openContainerItems[i];
|
||||
@ -93,7 +93,7 @@ public class AlphaInventoryTracker extends StoredObject {
|
||||
this.updateCursorItem();
|
||||
}
|
||||
|
||||
public void onWindowClick(final byte windowId, final short slot, final byte button, final short action, final Item item) throws Exception {
|
||||
public void onWindowClick(final byte windowId, final short slot, final byte button, final short action, final Item item) {
|
||||
final boolean leftClick = button != 1;
|
||||
|
||||
if (slot == -999) {
|
||||
@ -405,15 +405,11 @@ public class AlphaInventoryTracker extends StoredObject {
|
||||
}
|
||||
|
||||
private void updateInventorySlot(final byte windowId, final short slot, final Item item) {
|
||||
try {
|
||||
final PacketWrapper setSlot = PacketWrapper.create(ClientboundPacketsb1_1.SET_SLOT, this.getUser());
|
||||
setSlot.write(Type.BYTE, windowId); // window id
|
||||
setSlot.write(Type.SHORT, slot); // slot
|
||||
setSlot.write(Typesb1_1.NBTLESS_ITEM, copyItem(item)); // item
|
||||
setSlot.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final PacketWrapper setSlot = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_SLOT, this.getUser());
|
||||
setSlot.write(Types.BYTE, windowId); // window id
|
||||
setSlot.write(Types.SHORT, slot); // slot
|
||||
setSlot.write(Typesb1_1.NBTLESS_ITEM, copyItem(item)); // item
|
||||
setSlot.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
}
|
||||
|
||||
private void updatePlayerInventory() {
|
||||
@ -427,14 +423,10 @@ public class AlphaInventoryTracker extends StoredObject {
|
||||
}
|
||||
|
||||
private void updateInventory(final byte windowId, final Item[] items) {
|
||||
try {
|
||||
final PacketWrapper windowItems = PacketWrapper.create(ClientboundPacketsb1_1.WINDOW_ITEMS, this.getUser());
|
||||
windowItems.write(Type.BYTE, windowId); // window id
|
||||
windowItems.write(Types1_4_2.NBTLESS_ITEM_ARRAY, copyItems(items)); // items
|
||||
windowItems.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final PacketWrapper windowItems = PacketWrapper.create(ClientboundPacketsb1_1.CONTAINER_SET_CONTENT, this.getUser());
|
||||
windowItems.write(Types.BYTE, windowId); // window id
|
||||
windowItems.write(Types1_4_2.NBTLESS_ITEM_ARRAY, copyItems(items)); // items
|
||||
windowItems.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
}
|
||||
|
||||
private Item splitStack(final Item item, final int size) {
|
||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.Protocolb1_0_1_1_1toa1_2_3_5_1_2_6;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.ServerboundPacketsa1_2_6;
|
||||
@ -54,8 +54,8 @@ public class AlphaInventoryUpdateTask implements Runnable {
|
||||
final Item handItem = fixItem(Via.getManager().getProviders().get(AlphaInventoryProvider.class).getHandItem(info));
|
||||
|
||||
if (!Objects.equals(handItem, inventoryStorage.handItem)) {
|
||||
final PacketWrapper heldItemChange = PacketWrapper.create(ServerboundPacketsb1_1.HELD_ITEM_CHANGE, info);
|
||||
heldItemChange.write(Type.SHORT, inventoryStorage.selectedHotbarSlot); // slot
|
||||
final PacketWrapper heldItemChange = PacketWrapper.create(ServerboundPacketsb1_1.SET_CARRIED_ITEM, info);
|
||||
heldItemChange.write(Types.SHORT, inventoryStorage.selectedHotbarSlot); // slot
|
||||
heldItemChange.sendToServer(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class, false);
|
||||
}
|
||||
|
||||
@ -74,15 +74,15 @@ public class AlphaInventoryUpdateTask implements Runnable {
|
||||
inventoryStorage.armorInventory = copyItems(mergedArmorInventory);
|
||||
|
||||
final PacketWrapper mainContent = PacketWrapper.create(ServerboundPacketsa1_2_6.PLAYER_INVENTORY, info);
|
||||
mainContent.write(Type.INT, -1); // type
|
||||
mainContent.write(Types.INT, -1); // type
|
||||
mainContent.write(Types1_4_2.NBTLESS_ITEM_ARRAY, mergedMainInventory); // items
|
||||
|
||||
final PacketWrapper craftingContent = PacketWrapper.create(ServerboundPacketsa1_2_6.PLAYER_INVENTORY, info);
|
||||
craftingContent.write(Type.INT, -2); // type
|
||||
craftingContent.write(Types.INT, -2); // type
|
||||
craftingContent.write(Types1_4_2.NBTLESS_ITEM_ARRAY, mergedCraftingInventory); // items
|
||||
|
||||
final PacketWrapper armorContent = PacketWrapper.create(ServerboundPacketsa1_2_6.PLAYER_INVENTORY, info);
|
||||
armorContent.write(Type.INT, -3); // type
|
||||
armorContent.write(Types.INT, -3); // type
|
||||
armorContent.write(Types1_4_2.NBTLESS_ITEM_ARRAY, mergedArmorInventory); // items
|
||||
|
||||
mainContent.sendToServer(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
|
||||
|
@ -29,107 +29,107 @@ import static net.raphimc.vialegacy.api.splitter.PreNettyTypes.*;
|
||||
public enum ClientboundPacketsb1_8 implements ClientboundPacketType, PreNettyPacketType {
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> buf.skipBytes(4)),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(8)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(8)),
|
||||
RESPAWN(9, (user, buf) -> buf.skipBytes(13)),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
USE_BED(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
PLAYER_SLEEP(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(24)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> {
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> {
|
||||
buf.skipBytes(17);
|
||||
int i = buf.readInt();
|
||||
if (i > 0) {
|
||||
buf.skipBytes(6);
|
||||
}
|
||||
}),
|
||||
SPAWN_MOB(24, (user, buf) -> {
|
||||
ADD_MOB(24, (user, buf) -> {
|
||||
buf.skipBytes(19);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
SPAWN_PAINTING(25, (user, buf) -> {
|
||||
ADD_PAINTING(25, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_EXPERIENCE_ORB(26, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_METADATA(40, (user, buf) -> {
|
||||
ADD_EXPERIENCE_ORB(26, (user, buf) -> buf.skipBytes(18)),
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_ENTITY_DATA(40, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
ENTITY_EFFECT(41, (user, buf) -> buf.skipBytes(8)),
|
||||
REMOVE_ENTITY_EFFECT(42, (user, buf) -> buf.skipBytes(5)),
|
||||
UPDATE_MOB_EFFECT(41, (user, buf) -> buf.skipBytes(8)),
|
||||
REMOVE_MOB_EFFECT(42, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_EXPERIENCE(43, (user, buf) -> buf.skipBytes(4)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ACTION(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_EVENT(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
buf.skipBytes(3);
|
||||
}
|
||||
}),
|
||||
EFFECT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
LEVEL_EVENT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
GAME_EVENT(70, (user, buf) -> buf.skipBytes(2)),
|
||||
SPAWN_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
ADD_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readString(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CREATIVE_INVENTORY_ACTION(107, (user, buf) -> buf.skipBytes(10)),
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SET_CREATIVE_MODE_SLOT(107, (user, buf) -> buf.skipBytes(10)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readString(buf);
|
||||
@ -137,12 +137,12 @@ public enum ClientboundPacketsb1_8 implements ClientboundPacketType, PreNettyPac
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
}),
|
||||
MAP_DATA(131, (user, buf) -> {
|
||||
MAP_ITEM_DATA(131, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
short x = buf.readUnsignedByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
STATISTICS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
AWARD_STATS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_INFO(201, (user, buf) -> {
|
||||
readString(buf);
|
||||
buf.skipBytes(3);
|
||||
|
@ -21,9 +21,8 @@ import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.rewriter.ItemRewriter;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.storage.PlayerAirTimeStorage;
|
||||
@ -36,7 +35,7 @@ import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types
|
||||
|
||||
public class Protocol1_0_0_1tob1_8_0_1 extends StatelessProtocol<ClientboundPacketsb1_8, ClientboundPackets1_0, ServerboundPacketsb1_8, ServerboundPackets1_0> {
|
||||
|
||||
private final LegacyItemRewriter<Protocol1_0_0_1tob1_8_0_1> itemRewriter = new ItemRewriter(this);
|
||||
private final ItemRewriter itemRewriter = new ItemRewriter(this);
|
||||
|
||||
public Protocol1_0_0_1tob1_8_0_1() {
|
||||
super(ClientboundPacketsb1_8.class, ClientboundPackets1_0.class, ServerboundPacketsb1_8.class, ServerboundPackets1_0.class);
|
||||
@ -47,50 +46,50 @@ public class Protocol1_0_0_1tob1_8_0_1 extends StatelessProtocol<ClientboundPack
|
||||
this.itemRewriter.register();
|
||||
|
||||
this.registerClientbound(ClientboundPacketsb1_8.SET_EXPERIENCE, wrapper -> {
|
||||
float experience = (float) wrapper.read(Type.BYTE);
|
||||
final byte experienceLevel = wrapper.read(Type.BYTE);
|
||||
final short experienceTotal = wrapper.read(Type.SHORT);
|
||||
float experience = (float) wrapper.read(Types.BYTE);
|
||||
final byte experienceLevel = wrapper.read(Types.BYTE);
|
||||
final short experienceTotal = wrapper.read(Types.SHORT);
|
||||
experience = (experience - 1.0f) / (10 * experienceLevel);
|
||||
wrapper.write(Type.FLOAT, experience); // experience bar
|
||||
wrapper.write(Type.SHORT, (short) experienceLevel); // level
|
||||
wrapper.write(Type.SHORT, experienceTotal); // total experience
|
||||
wrapper.write(Types.FLOAT, experience); // experience bar
|
||||
wrapper.write(Types.SHORT, (short) experienceLevel); // level
|
||||
wrapper.write(Types.SHORT, experienceTotal); // total experience
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_8.SET_SLOT, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_8.CONTAINER_SET_SLOT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // window id
|
||||
map(Type.SHORT); // slot
|
||||
map(Types.BYTE); // window id
|
||||
map(Types.SHORT); // slot
|
||||
map(Types1_4_2.NBTLESS_ITEM, Types1_2_4.NBT_ITEM); // item
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_8.WINDOW_ITEMS, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_8.CONTAINER_SET_CONTENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // window id
|
||||
map(Types.BYTE); // window id
|
||||
map(Types1_4_2.NBTLESS_ITEM_ARRAY, Types1_2_4.NBT_ITEM_ARRAY); // item
|
||||
}
|
||||
});
|
||||
|
||||
this.registerServerbound(ServerboundPackets1_0.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPackets1_0.USE_ITEM_ON, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.UNSIGNED_BYTE); // direction
|
||||
map(Types.UNSIGNED_BYTE); // direction
|
||||
map(Types1_2_4.NBT_ITEM, Types1_4_2.NBTLESS_ITEM);
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPackets1_0.CLICK_WINDOW, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPackets1_0.CONTAINER_CLICK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // window id
|
||||
map(Type.SHORT); // slot
|
||||
map(Type.BYTE); // button
|
||||
map(Type.SHORT); // action
|
||||
map(Type.BYTE); // mode
|
||||
map(Types.BYTE); // window id
|
||||
map(Types.SHORT); // slot
|
||||
map(Types.BYTE); // button
|
||||
map(Types.SHORT); // action
|
||||
map(Types.BYTE); // mode
|
||||
map(Types1_2_4.NBT_ITEM, Types1_4_2.NBTLESS_ITEM); // item
|
||||
}
|
||||
});
|
||||
this.cancelServerbound(ServerboundPackets1_0.CLICK_WINDOW_BUTTON);
|
||||
this.cancelServerbound(ServerboundPackets1_0.CONTAINER_BUTTON_CLICK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -106,7 +105,7 @@ public class Protocol1_0_0_1tob1_8_0_1 extends StatelessProtocol<ClientboundPack
|
||||
}
|
||||
|
||||
@Override
|
||||
public LegacyItemRewriter<Protocol1_0_0_1tob1_8_0_1> getItemRewriter() {
|
||||
public ItemRewriter getItemRewriter() {
|
||||
return this.itemRewriter;
|
||||
}
|
||||
|
||||
|
@ -36,30 +36,30 @@ public enum ServerboundPacketsb1_8 implements ServerboundPacketType, PreNettyPac
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(9)),
|
||||
RESPAWN(9, (user, buf) -> buf.skipBytes(13)),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> {
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(2)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ACTION(19, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(2)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_COMMAND(19, (user, buf) -> buf.skipBytes(5)),
|
||||
POSITION(27, (user, buf) -> buf.skipBytes(18)),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CLICK_WINDOW(102, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_CLICK(102, (user, buf) -> {
|
||||
buf.skipBytes(7);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CREATIVE_INVENTORY_ACTION(107, (user, buf) -> buf.skipBytes(10)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SET_CREATIVE_MODE_SLOT(107, (user, buf) -> buf.skipBytes(10)),
|
||||
SIGN_UPDATE(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
|
@ -18,12 +18,13 @@
|
||||
package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.rewriter;
|
||||
|
||||
import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.ClientboundPacketsb1_8;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.Protocol1_0_0_1tob1_8_0_1;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.types.Typesb1_8_0_1;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_1to1_0_0_1.ServerboundPackets1_0;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.types.Types1_2_4;
|
||||
|
||||
public class ItemRewriter extends LegacyItemRewriter<Protocol1_0_0_1tob1_8_0_1> {
|
||||
public class ItemRewriter extends LegacyItemRewriter<ClientboundPacketsb1_8, ServerboundPackets1_0, Protocol1_0_0_1tob1_8_0_1> {
|
||||
|
||||
public ItemRewriter(final Protocol1_0_0_1tob1_8_0_1 protocol) {
|
||||
super(protocol, "b1.8.1", Typesb1_8_0_1.CREATIVE_ITEM, null, Types1_2_4.NBT_ITEM, Types1_2_4.NBT_ITEM_ARRAY);
|
||||
@ -36,7 +37,7 @@ public class ItemRewriter extends LegacyItemRewriter<Protocol1_0_0_1tob1_8_0_1>
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerCreativeInventoryAction(ServerboundPackets1_0.CREATIVE_INVENTORY_ACTION);
|
||||
this.registerCreativeInventoryAction(ServerboundPackets1_0.SET_CREATIVE_MODE_SLOT);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.task;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.api.data.BlockList1_6;
|
||||
@ -68,10 +68,10 @@ public class PlayerAirTimeUpdateTask implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendAirTime(final PlayerInfoStorage playerInfoStorage, final PlayerAirTimeStorage playerAirTimeStorage, final UserConnection userConnection) throws Exception {
|
||||
final PacketWrapper updateAirTime = PacketWrapper.create(ClientboundPackets1_0.ENTITY_METADATA, userConnection);
|
||||
updateAirTime.write(Type.INT, playerInfoStorage.entityId); // entity id
|
||||
updateAirTime.write(Types1_3_1.METADATA_LIST, Lists.newArrayList(new Metadata(1, MetaType1_3_1.Short, Integer.valueOf(playerAirTimeStorage.air).shortValue()))); // metadata
|
||||
private void sendAirTime(final PlayerInfoStorage playerInfoStorage, final PlayerAirTimeStorage playerAirTimeStorage, final UserConnection userConnection) {
|
||||
final PacketWrapper updateAirTime = PacketWrapper.create(ClientboundPackets1_0.SET_ENTITY_DATA, userConnection);
|
||||
updateAirTime.write(Types.INT, playerInfoStorage.entityId); // entity id
|
||||
updateAirTime.write(Types1_3_1.METADATA_LIST, Lists.newArrayList(new EntityData(1, MetaType1_3_1.Short, Integer.valueOf(playerAirTimeStorage.air).shortValue()))); // metadata
|
||||
updateAirTime.send(Protocol1_0_0_1tob1_8_0_1.class);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class NbtLessItemType extends Type<Item> {
|
||||
super(Item.class);
|
||||
}
|
||||
|
||||
public Item read(ByteBuf buffer) throws Exception {
|
||||
public Item read(ByteBuf buffer) {
|
||||
final short id = buffer.readShort();
|
||||
if (id < 0) {
|
||||
return null;
|
||||
@ -41,7 +41,7 @@ public class NbtLessItemType extends Type<Item> {
|
||||
}
|
||||
}
|
||||
|
||||
public void write(ByteBuf buffer, Item item) throws Exception {
|
||||
public void write(ByteBuf buffer, Item item) {
|
||||
if (item == null) {
|
||||
buffer.writeShort(-1);
|
||||
buffer.writeShort(0);
|
||||
|
@ -30,81 +30,81 @@ public enum ClientboundPacketsb1_1 implements ClientboundPacketType, PreNettyPac
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(22)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> buf.skipBytes(19)),
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
buf.skipBytes(3);
|
||||
}
|
||||
}),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
readItemStackb1_1(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readUTF(buf);
|
||||
|
@ -19,11 +19,11 @@ package net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
@ -49,23 +49,23 @@ public class Protocolb1_2_0_2tob1_1_2 extends StatelessProtocol<ClientboundPacke
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsb1_1.ENTITY_EQUIPMENT, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_1.SET_EQUIPPED_ITEM, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.SHORT); // slot
|
||||
map(Type.SHORT); // item id
|
||||
create(Type.SHORT, (short) 0); // item damage
|
||||
map(Types.INT); // entity id
|
||||
map(Types.SHORT); // slot
|
||||
map(Types.SHORT); // item id
|
||||
create(Types.SHORT, (short) 0); // item damage
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_1.ENTITY_ANIMATION, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_1.ANIMATE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.BYTE); // animation id
|
||||
map(Types.INT); // entity id
|
||||
map(Types.BYTE); // animation id
|
||||
handler(wrapper -> {
|
||||
final int entityId = wrapper.get(Type.INT, 0);
|
||||
final byte animationId = wrapper.get(Type.BYTE, 0);
|
||||
final int entityId = wrapper.get(Types.INT, 0);
|
||||
final byte animationId = wrapper.get(Types.BYTE, 0);
|
||||
if (animationId <= 2) return; // 1 - Swing | 2 - Hurt
|
||||
|
||||
wrapper.cancel();
|
||||
@ -93,9 +93,9 @@ public class Protocolb1_2_0_2tob1_1_2 extends StatelessProtocol<ClientboundPacke
|
||||
}
|
||||
|
||||
if (oldMask != entityFlagStorage.getFlagMask(entityId)) {
|
||||
final PacketWrapper metadata = PacketWrapper.create(ClientboundPacketsb1_2.ENTITY_METADATA, wrapper.user());
|
||||
metadata.write(Type.INT, wrapper.get(Type.INT, 0)); // entity id
|
||||
metadata.write(Typesb1_2.METADATA_LIST, Lists.newArrayList(new Metadata(0, MetaTypeb1_2.Byte, (byte) entityFlagStorage.getFlagMask(entityId)))); // metadata
|
||||
final PacketWrapper metadata = PacketWrapper.create(ClientboundPacketsb1_2.SET_ENTITY_DATA, wrapper.user());
|
||||
metadata.write(Types.INT, wrapper.get(Types.INT, 0)); // entity id
|
||||
metadata.write(Typesb1_2.METADATA_LIST, Lists.newArrayList(new EntityData(0, MetaTypeb1_2.Byte, (byte) entityFlagStorage.getFlagMask(entityId)))); // metadata
|
||||
metadata.send(Protocolb1_2_0_2tob1_1_2.class);
|
||||
}
|
||||
});
|
||||
@ -104,93 +104,93 @@ public class Protocolb1_2_0_2tob1_1_2 extends StatelessProtocol<ClientboundPacke
|
||||
this.registerClientbound(ClientboundPacketsb1_1.SPAWN_ITEM, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
handler(wrapper -> {
|
||||
final short itemId = wrapper.read(Type.SHORT); // item id
|
||||
final byte itemCount = wrapper.read(Type.BYTE); // item count
|
||||
final short itemId = wrapper.read(Types.SHORT); // item id
|
||||
final byte itemCount = wrapper.read(Types.BYTE); // item count
|
||||
wrapper.write(Types1_3_1.NBTLESS_ITEM, new DataItem(itemId, itemCount, (short) 0, null)); // item
|
||||
});
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // velocity x
|
||||
map(Type.BYTE); // velocity y
|
||||
map(Type.BYTE); // velocity z
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // velocity x
|
||||
map(Types.BYTE); // velocity y
|
||||
map(Types.BYTE); // velocity z
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_1.SPAWN_MOB, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_1.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.UNSIGNED_BYTE); // type id
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
handler(wrapper -> wrapper.write(Typesb1_2.METADATA_LIST, Lists.newArrayList(new Metadata(0, MetaTypeb1_2.Byte, (byte) 0)))); // metadata
|
||||
map(Types.INT); // entity id
|
||||
map(Types.UNSIGNED_BYTE); // type id
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
handler(wrapper -> wrapper.write(Typesb1_2.METADATA_LIST, Lists.newArrayList(new EntityData(0, MetaTypeb1_2.Byte, (byte) 0)))); // metadata
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_1.CHUNK_DATA, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_1.LEVEL_CHUNK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(wrapper -> BLOCK_DATA_REWRITER.remapChunk(wrapper.passthrough(Types1_1.CHUNK))); // chunk
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_1.MULTI_BLOCK_CHANGE, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_1.CHUNK_BLOCKS_UPDATE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // chunkX
|
||||
map(Type.INT); // chunkZ
|
||||
map(Types.INT); // chunkX
|
||||
map(Types.INT); // chunkZ
|
||||
map(Types1_1.BLOCK_CHANGE_RECORD_ARRAY); // blockChangeRecords
|
||||
handler(wrapper -> BLOCK_DATA_REWRITER.remapBlockChangeRecords(wrapper.get(Types1_1.BLOCK_CHANGE_RECORD_ARRAY, 0)));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_1.BLOCK_CHANGE, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_1.BLOCK_UPDATE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.UNSIGNED_BYTE); // block id
|
||||
map(Type.UNSIGNED_BYTE); // block data
|
||||
map(Types.UNSIGNED_BYTE); // block id
|
||||
map(Types.UNSIGNED_BYTE); // block data
|
||||
handler(wrapper -> {
|
||||
final IdAndData block = new IdAndData(wrapper.get(Type.UNSIGNED_BYTE, 0), wrapper.get(Type.UNSIGNED_BYTE, 1));
|
||||
final IdAndData block = new IdAndData(wrapper.get(Types.UNSIGNED_BYTE, 0), wrapper.get(Types.UNSIGNED_BYTE, 1));
|
||||
BLOCK_DATA_REWRITER.remapBlock(block);
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 0, (short) block.getId());
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 1, (short) block.getData());
|
||||
wrapper.set(Types.UNSIGNED_BYTE, 0, (short) block.getId());
|
||||
wrapper.set(Types.UNSIGNED_BYTE, 1, (short) block.getData());
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_1.SET_SLOT, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_1.CONTAINER_SET_SLOT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // window id
|
||||
map(Type.SHORT); // slot
|
||||
map(Types.BYTE); // window id
|
||||
map(Types.SHORT); // slot
|
||||
map(Typesb1_1.NBTLESS_ITEM, Types1_4_2.NBTLESS_ITEM); // item
|
||||
}
|
||||
});
|
||||
|
||||
this.registerServerbound(ServerboundPacketsb1_2.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_2.USE_ITEM_ON, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.UNSIGNED_BYTE); // direction
|
||||
map(Types.UNSIGNED_BYTE); // direction
|
||||
map(Types1_4_2.NBTLESS_ITEM, Typesb1_1.NBTLESS_ITEM); // item
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_2.ENTITY_ACTION, ServerboundPacketsb1_1.ANIMATION, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_2.PLAYER_COMMAND, ServerboundPacketsb1_1.SWING, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.BYTE, Type.UNSIGNED_BYTE, i -> (short) (i + 103)); // action id | start/stop sneaking (1/2) -> 104/105
|
||||
map(Types.INT); // entity id
|
||||
map(Types.BYTE, Types.UNSIGNED_BYTE, i -> (short) (i + 103)); // action id | start/stop sneaking (1/2) -> 104/105
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_2.CLICK_WINDOW, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_2.CONTAINER_CLICK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // window id
|
||||
map(Type.SHORT); // slot
|
||||
map(Type.BYTE); // button
|
||||
map(Type.SHORT); // action
|
||||
map(Types.BYTE); // window id
|
||||
map(Types.SHORT); // slot
|
||||
map(Types.BYTE); // button
|
||||
map(Types.SHORT); // action
|
||||
map(Types1_4_2.NBTLESS_ITEM, Typesb1_1.NBTLESS_ITEM); // item
|
||||
}
|
||||
});
|
||||
|
@ -38,28 +38,28 @@ public enum ServerboundPacketsb1_1 implements ServerboundPacketType, PreNettyPac
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(9)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> {
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readItemStackb1_1(buf);
|
||||
}),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(2)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CLICK_WINDOW(102, (user, buf) -> {
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(2)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_CLICK(102, (user, buf) -> {
|
||||
buf.skipBytes(6);
|
||||
readItemStackb1_1(buf);
|
||||
}),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SIGN_UPDATE(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
|
@ -28,7 +28,7 @@ public class NbtLessItemType extends Type<Item> {
|
||||
super(Item.class);
|
||||
}
|
||||
|
||||
public Item read(ByteBuf buffer) throws Exception {
|
||||
public Item read(ByteBuf buffer) {
|
||||
final short id = buffer.readShort();
|
||||
if (id < 0) {
|
||||
return null;
|
||||
@ -41,7 +41,7 @@ public class NbtLessItemType extends Type<Item> {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void write(ByteBuf buffer, Item item) throws Exception {
|
||||
public void write(ByteBuf buffer, Item item) {
|
||||
if (item == null) {
|
||||
buffer.writeShort(-1);
|
||||
} else {
|
||||
|
@ -29,94 +29,94 @@ public enum ClientboundPacketsb1_2 implements ClientboundPacketType, PreNettyPac
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(24)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> {
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> {
|
||||
buf.skipBytes(19);
|
||||
PreNettyTypes.readEntityMetadatab1_2(buf);
|
||||
}),
|
||||
SPAWN_PAINTING(25, (user, buf) -> {
|
||||
ADD_PAINTING(25, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_METADATA(40, (user, buf) -> {
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_ENTITY_DATA(40, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readEntityMetadatab1_2(buf);
|
||||
}),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ACTION(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_EVENT(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
buf.skipBytes(3);
|
||||
}
|
||||
}),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
PreNettyTypes.readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) PreNettyTypes.readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
|
@ -20,11 +20,11 @@ package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
@ -49,34 +49,34 @@ public class Protocolb1_3_0_1tob1_2_0_2 extends StatelessProtocol<ClientboundPac
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsb1_2.SPAWN_MOB, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_2.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.UNSIGNED_BYTE); // type id
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Types.INT); // entity id
|
||||
map(Types.UNSIGNED_BYTE); // type id
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
map(Typesb1_2.METADATA_LIST, Typesb1_4.METADATA_LIST); // metadata
|
||||
handler(wrapper -> rewriteMetadata(wrapper.get(Typesb1_4.METADATA_LIST, 0)));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_2.ENTITY_METADATA, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_2.SET_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Typesb1_2.METADATA_LIST, Typesb1_4.METADATA_LIST); // metadata
|
||||
handler(wrapper -> rewriteMetadata(wrapper.get(Typesb1_4.METADATA_LIST, 0)));
|
||||
}
|
||||
});
|
||||
|
||||
this.registerServerbound(ServerboundPacketsb1_4.PLAYER_DIGGING, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsb1_4.PLAYER_ACTION, wrapper -> {
|
||||
wrapper.cancel();
|
||||
final short status = wrapper.read(Type.UNSIGNED_BYTE); // status
|
||||
final short status = wrapper.read(Types.UNSIGNED_BYTE); // status
|
||||
final Position pos = wrapper.read(Types1_7_6.POSITION_UBYTE); // position
|
||||
final short facing = wrapper.read(Type.UNSIGNED_BYTE); // direction
|
||||
final short facing = wrapper.read(Types.UNSIGNED_BYTE); // direction
|
||||
|
||||
if (status != 4) {
|
||||
wrapper.user().getStoredObjects().remove(BlockDigStorage.class);
|
||||
@ -109,22 +109,22 @@ public class Protocolb1_3_0_1tob1_2_0_2 extends StatelessProtocol<ClientboundPac
|
||||
break;
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_4.ENTITY_ACTION, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_4.PLAYER_COMMAND, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.BYTE); // action id
|
||||
map(Types.INT); // entity id
|
||||
map(Types.BYTE); // action id
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.BYTE, 0) > 2) wrapper.cancel();
|
||||
if (wrapper.get(Types.BYTE, 0) > 2) wrapper.cancel();
|
||||
});
|
||||
}
|
||||
});
|
||||
this.cancelServerbound(ServerboundPacketsb1_4.POSITION);
|
||||
}
|
||||
|
||||
private void rewriteMetadata(final List<Metadata> metadataList) {
|
||||
for (Metadata metadata : metadataList) {
|
||||
metadata.setMetaType(MetaTypeb1_4.byId(metadata.metaType().typeId()));
|
||||
private void rewriteMetadata(final List<EntityData> metadataList) {
|
||||
for (EntityData metadata : metadataList) {
|
||||
metadata.setDataType(MetaTypeb1_4.byId(metadata.dataType().typeId()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,11 +139,11 @@ public class Protocolb1_3_0_1tob1_2_0_2 extends StatelessProtocol<ClientboundPac
|
||||
}
|
||||
|
||||
|
||||
public static void sendBlockDigPacket(final UserConnection userConnection, final short status, final Position position, final short facing) throws Exception {
|
||||
final PacketWrapper blockDig = PacketWrapper.create(ServerboundPacketsb1_2.PLAYER_DIGGING, userConnection);
|
||||
blockDig.write(Type.UNSIGNED_BYTE, status); // status
|
||||
public static void sendBlockDigPacket(final UserConnection userConnection, final short status, final Position position, final short facing) {
|
||||
final PacketWrapper blockDig = PacketWrapper.create(ServerboundPacketsb1_2.PLAYER_ACTION, userConnection);
|
||||
blockDig.write(Types.UNSIGNED_BYTE, status); // status
|
||||
blockDig.write(Types1_7_6.POSITION_UBYTE, position); // position
|
||||
blockDig.write(Type.UNSIGNED_BYTE, facing); // direction
|
||||
blockDig.write(Types.UNSIGNED_BYTE, facing); // direction
|
||||
blockDig.sendToServer(Protocolb1_3_0_1tob1_2_0_2.class);
|
||||
}
|
||||
|
||||
|
@ -36,29 +36,29 @@ public enum ServerboundPacketsb1_2 implements ServerboundPacketType, PreNettyPac
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readUTF(buf)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(9)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> {
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
PreNettyTypes.readItemStackb1_2(buf);
|
||||
}),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(2)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ACTION(19, (user, buf) -> buf.skipBytes(5)),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CLICK_WINDOW(102, (user, buf) -> {
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(2)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_COMMAND(19, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_CLICK(102, (user, buf) -> {
|
||||
buf.skipBytes(6);
|
||||
PreNettyTypes.readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SIGN_UPDATE(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
PreNettyTypes.readUTF(buf);
|
||||
|
@ -20,11 +20,8 @@ package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.storage;
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.Protocolb1_3_0_1tob1_2_0_2;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BlockDigStorage extends StoredObject {
|
||||
|
||||
public int tick = 1;
|
||||
@ -38,17 +35,13 @@ public class BlockDigStorage extends StoredObject {
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
try {
|
||||
if (tick >= 5) {
|
||||
Protocolb1_3_0_1tob1_2_0_2.sendBlockDigPacket(this.getUser(), (byte) 0, position, facing);
|
||||
tick = 0;
|
||||
} else {
|
||||
tick++;
|
||||
}
|
||||
Protocolb1_3_0_1tob1_2_0_2.sendBlockDigPacket(this.getUser(), (byte) 1, position, facing);
|
||||
} catch (Throwable e) {
|
||||
ViaLegacy.getPlatform().getLogger().log(Level.WARNING, "Error while ticking BlockDigStorage", e);
|
||||
if (this.tick >= 5) {
|
||||
Protocolb1_3_0_1tob1_2_0_2.sendBlockDigPacket(this.getUser(), (byte) 0, this.position, this.facing);
|
||||
this.tick = 0;
|
||||
} else {
|
||||
this.tick++;
|
||||
}
|
||||
Protocolb1_3_0_1tob1_2_0_2.sendBlockDigPacket(this.getUser(), (byte) 1, this.position, this.facing);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,8 +19,11 @@ package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.task;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.storage.BlockDigStorage;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BlockDigTickTask implements Runnable {
|
||||
|
||||
@Override
|
||||
@ -28,7 +31,15 @@ public class BlockDigTickTask implements Runnable {
|
||||
for (UserConnection info : Via.getManager().getConnectionManager().getConnections()) {
|
||||
final BlockDigStorage blockDigStorage = info.get(BlockDigStorage.class);
|
||||
if (blockDigStorage != null) {
|
||||
info.getChannel().eventLoop().submit(blockDigStorage::tick);
|
||||
info.getChannel().eventLoop().submit(() -> {
|
||||
if (!info.getChannel().isActive()) return;
|
||||
|
||||
try {
|
||||
blockDigStorage.tick();
|
||||
} catch (Throwable e) {
|
||||
ViaLegacy.getPlatform().getLogger().log(Level.WARNING, "Error while ticking BlockDigStorage", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,17 +17,18 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.types.Typesb1_7_0_3;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types.Types1_3_1;
|
||||
|
||||
public enum MetaTypeb1_2 implements MetaType {
|
||||
public enum MetaTypeb1_2 implements EntityDataType {
|
||||
|
||||
Byte(0, Type.BYTE),
|
||||
Short(1, Type.SHORT),
|
||||
Int(2, Type.INT),
|
||||
Float(3, Type.FLOAT),
|
||||
Byte(0, Types.BYTE),
|
||||
Short(1, Types.SHORT),
|
||||
Int(2, Types.INT),
|
||||
Float(3, Types.FLOAT),
|
||||
String(4, Typesb1_7_0_3.STRING),
|
||||
Slot(5, Types1_3_1.NBTLESS_ITEM);
|
||||
|
||||
|
@ -17,13 +17,13 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.type.types.metadata.OldMetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.types.entitydata.OldEntityDataType;
|
||||
|
||||
public class MetadataType extends OldMetaType {
|
||||
public class MetadataType extends OldEntityDataType {
|
||||
|
||||
@Override
|
||||
protected MetaType getType(int index) {
|
||||
protected EntityDataType getType(int index) {
|
||||
return MetaTypeb1_2.byId(index);
|
||||
}
|
||||
|
||||
|
@ -17,15 +17,15 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.metadata.MetaListType;
|
||||
import com.viaversion.viaversion.api.type.types.entitydata.EntityDataListType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Typesb1_2 {
|
||||
|
||||
public static final Type<Metadata> METADATA = new MetadataType();
|
||||
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
|
||||
public static final Type<EntityData> METADATA = new MetadataType();
|
||||
public static final Type<List<EntityData>> METADATA_LIST = new EntityDataListType(METADATA);
|
||||
|
||||
}
|
||||
|
@ -30,95 +30,95 @@ public enum ClientboundPacketsb1_3 implements ClientboundPacketType, PreNettyPac
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
USE_BED(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
PLAYER_SLEEP(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(24)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> {
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> {
|
||||
buf.skipBytes(19);
|
||||
readEntityMetadatab1_3(buf);
|
||||
}),
|
||||
SPAWN_PAINTING(25, (user, buf) -> {
|
||||
ADD_PAINTING(25, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_METADATA(40, (user, buf) -> {
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_ENTITY_DATA(40, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readEntityMetadatab1_3(buf);
|
||||
}),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ACTION(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_EVENT(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
buf.skipBytes(3);
|
||||
}
|
||||
}),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readUTF(buf);
|
||||
|
@ -30,72 +30,72 @@ public enum ClientboundPacketsb1_4 implements ClientboundPacketType, PreNettyPac
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
USE_BED(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
PLAYER_SLEEP(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(24)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> {
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> {
|
||||
buf.skipBytes(19);
|
||||
readEntityMetadatab1_3(buf);
|
||||
}),
|
||||
SPAWN_PAINTING(25, (user, buf) -> {
|
||||
ADD_PAINTING(25, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_METADATA(40, (user, buf) -> {
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_ENTITY_DATA(40, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readEntityMetadatab1_3(buf);
|
||||
}),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ACTION(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_EVENT(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
@ -103,23 +103,23 @@ public enum ClientboundPacketsb1_4 implements ClientboundPacketType, PreNettyPac
|
||||
}
|
||||
}),
|
||||
GAME_EVENT(70, (user, buf) -> buf.skipBytes(1)),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readUTF(buf);
|
||||
|
@ -18,9 +18,9 @@
|
||||
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types.Typesb1_4;
|
||||
@ -49,67 +49,67 @@ public class Protocolb1_5_0_2tob1_4_0_1 extends StatelessProtocol<ClientboundPac
|
||||
map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // server hash
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_4.JOIN_GAME, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_4.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // username
|
||||
read(Typesb1_7_0_3.STRING); // password
|
||||
map(Type.LONG); // seed
|
||||
map(Type.BYTE); // dimension id
|
||||
map(Types.LONG); // seed
|
||||
map(Types.BYTE); // dimension id
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_4.CHAT_MESSAGE, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_4.CHAT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // message
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_4.SPAWN_PLAYER, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_4.ADD_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // username
|
||||
handler(wrapper -> {
|
||||
String name = wrapper.get(Types1_6_4.STRING, 0);
|
||||
name = name.substring(0, Math.min(name.length(), 16));
|
||||
wrapper.set(Types1_6_4.STRING, 0, name);
|
||||
});
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Type.UNSIGNED_SHORT); // item
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
map(Types.UNSIGNED_SHORT); // item
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_4.SPAWN_MOB, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_4.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.UNSIGNED_BYTE); // type id
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Types.INT); // entity id
|
||||
map(Types.UNSIGNED_BYTE); // type id
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
map(Typesb1_4.METADATA_LIST, Types1_3_1.METADATA_LIST); // metadata
|
||||
handler(wrapper -> rewriteMetadata(wrapper.get(Types1_3_1.METADATA_LIST, 0)));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_4.SPAWN_PAINTING, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_4.ADD_PAINTING, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // motive
|
||||
map(Types1_7_6.POSITION_INT); // position
|
||||
map(Type.INT); // rotation
|
||||
map(Types.INT); // rotation
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_4.ENTITY_METADATA, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_4.SET_ENTITY_DATA, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Typesb1_4.METADATA_LIST, Types1_3_1.METADATA_LIST); // metadata
|
||||
handler(wrapper -> rewriteMetadata(wrapper.get(Types1_3_1.METADATA_LIST, 0)));
|
||||
}
|
||||
@ -140,31 +140,31 @@ public class Protocolb1_5_0_2tob1_4_0_1 extends StatelessProtocol<ClientboundPac
|
||||
this.registerServerbound(ServerboundPacketsb1_5.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // protocol id
|
||||
map(Types.INT); // protocol id
|
||||
map(Types1_6_4.STRING, Typesb1_7_0_3.STRING); // username
|
||||
create(Typesb1_7_0_3.STRING, "Password"); // password
|
||||
map(Type.LONG); // seed
|
||||
map(Type.BYTE); // dimension id
|
||||
map(Types.LONG); // seed
|
||||
map(Types.BYTE); // dimension id
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_5.CHAT_MESSAGE, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_5.CHAT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_6_4.STRING, Typesb1_7_0_3.STRING); // message
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_5.CLICK_WINDOW, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_5.CONTAINER_CLICK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // window id
|
||||
map(Type.SHORT); // slot
|
||||
map(Type.BYTE); // button
|
||||
map(Type.SHORT); // action
|
||||
read(Type.BYTE); // mode
|
||||
map(Types.BYTE); // window id
|
||||
map(Types.SHORT); // slot
|
||||
map(Types.BYTE); // button
|
||||
map(Types.SHORT); // action
|
||||
read(Types.BYTE); // mode
|
||||
map(Types1_4_2.NBTLESS_ITEM); // item
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_5.UPDATE_SIGN, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_5.SIGN_UPDATE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_7_6.POSITION_SHORT); // position
|
||||
@ -182,9 +182,9 @@ public class Protocolb1_5_0_2tob1_4_0_1 extends StatelessProtocol<ClientboundPac
|
||||
});
|
||||
}
|
||||
|
||||
private void rewriteMetadata(final List<Metadata> metadataList) {
|
||||
for (Metadata metadata : metadataList) {
|
||||
metadata.setMetaType(MetaType1_3_1.byId(metadata.metaType().typeId()));
|
||||
private void rewriteMetadata(final List<EntityData> metadataList) {
|
||||
for (EntityData metadata : metadataList) {
|
||||
metadata.setDataType(MetaType1_3_1.byId(metadata.dataType().typeId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,30 +38,30 @@ public enum ServerboundPacketsb1_4 implements ServerboundPacketType, PreNettyPac
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readUTF(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readUTF(buf)),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> readUTF(buf)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(9)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> {
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(2)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ACTION(19, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(2)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_COMMAND(19, (user, buf) -> buf.skipBytes(5)),
|
||||
POSITION(27, (user, buf) -> buf.skipBytes(18)),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CLICK_WINDOW(102, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_CLICK(102, (user, buf) -> {
|
||||
buf.skipBytes(6);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SIGN_UPDATE(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readUTF(buf);
|
||||
readUTF(buf);
|
||||
|
@ -17,25 +17,26 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.types.Typesb1_7_0_3;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types.Types1_3_1;
|
||||
|
||||
public enum MetaTypeb1_4 implements MetaType {
|
||||
public enum MetaTypeb1_4 implements EntityDataType {
|
||||
|
||||
Byte(0, Type.BYTE),
|
||||
Short(1, Type.SHORT),
|
||||
Int(2, Type.INT),
|
||||
Float(3, Type.FLOAT),
|
||||
Byte(0, Types.BYTE),
|
||||
Short(1, Types.SHORT),
|
||||
Int(2, Types.INT),
|
||||
Float(3, Types.FLOAT),
|
||||
String(4, Typesb1_7_0_3.STRING),
|
||||
Slot(5, new Type<Item>(Item.class) { // b1.3 - b1.4 had broken read/write code where type 5 had a missing break statement causing it to read a type 6 as well (Both are unused)
|
||||
@Override
|
||||
public Item read(ByteBuf buffer) throws Exception {
|
||||
public Item read(ByteBuf buffer) {
|
||||
Types1_3_1.NBTLESS_ITEM.read(buffer);
|
||||
Type.VECTOR.read(buffer);
|
||||
Types.VECTOR.read(buffer);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -44,7 +45,7 @@ public enum MetaTypeb1_4 implements MetaType {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}),
|
||||
Position(6, Type.VECTOR);
|
||||
Position(6, Types.VECTOR);
|
||||
|
||||
private final int typeID;
|
||||
private final Type<?> type;
|
||||
|
@ -17,13 +17,13 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.type.types.metadata.OldMetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
|
||||
import com.viaversion.viaversion.api.type.types.entitydata.OldEntityDataType;
|
||||
|
||||
public class MetadataType extends OldMetaType {
|
||||
public class MetadataType extends OldEntityDataType {
|
||||
|
||||
@Override
|
||||
protected MetaType getType(int index) {
|
||||
protected EntityDataType getType(int index) {
|
||||
return MetaTypeb1_4.byId(index);
|
||||
}
|
||||
|
||||
|
@ -17,15 +17,15 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.metadata.MetaListType;
|
||||
import com.viaversion.viaversion.api.type.types.entitydata.EntityDataListType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Typesb1_4 {
|
||||
|
||||
public static final Type<Metadata> METADATA = new MetadataType();
|
||||
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
|
||||
public static final Type<EntityData> METADATA = new MetadataType();
|
||||
public static final Type<List<EntityData>> METADATA_LIST = new EntityDataListType(METADATA);
|
||||
|
||||
}
|
||||
|
@ -30,71 +30,71 @@ public enum ClientboundPacketsb1_5 implements ClientboundPacketType, PreNettyPac
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
USE_BED(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
PLAYER_SLEEP(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(24)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
SPAWN_MOB(24, (user, buf) -> {
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> buf.skipBytes(17)),
|
||||
ADD_MOB(24, (user, buf) -> {
|
||||
buf.skipBytes(19);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
SPAWN_PAINTING(25, (user, buf) -> {
|
||||
ADD_PAINTING(25, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_METADATA(40, (user, buf) -> {
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_ENTITY_DATA(40, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ACTION(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_EVENT(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
@ -102,24 +102,24 @@ public enum ClientboundPacketsb1_5 implements ClientboundPacketType, PreNettyPac
|
||||
}
|
||||
}),
|
||||
GAME_EVENT(70, (user, buf) -> buf.skipBytes(1)),
|
||||
SPAWN_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
ADD_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readString(buf);
|
||||
@ -127,7 +127,7 @@ public enum ClientboundPacketsb1_5 implements ClientboundPacketType, PreNettyPac
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
}),
|
||||
STATISTICS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
AWARD_STATS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
DISCONNECT(255, (user, buf) -> readString(buf));
|
||||
|
||||
private static final ClientboundPacketsb1_5[] REGISTRY = new ClientboundPacketsb1_5[256];
|
||||
|
@ -24,7 +24,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.api.data.BlockList1_6;
|
||||
import net.raphimc.vialegacy.api.data.ItemList1_6;
|
||||
@ -48,42 +48,42 @@ public class Protocolb1_6_0_6tob1_5_0_2 extends StatelessProtocol<ClientboundPac
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsb1_5.TIME_UPDATE, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_5.SET_TIME, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.LONG); // time
|
||||
handler(wrapper -> wrapper.user().get(WorldTimeStorage.class).time = wrapper.get(Type.LONG, 0));
|
||||
map(Types.LONG); // time
|
||||
handler(wrapper -> wrapper.user().get(WorldTimeStorage.class).time = wrapper.get(Types.LONG, 0));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_5.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
create(Type.BYTE, (byte) 0); // dimension id
|
||||
create(Types.BYTE, (byte) 0); // dimension id
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_5.SPAWN_ENTITY, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_5.ADD_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.BYTE); // type id
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
create(Type.INT, 0); // data
|
||||
map(Types.INT); // entity id
|
||||
map(Types.BYTE); // type id
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
create(Types.INT, 0); // data
|
||||
}
|
||||
});
|
||||
|
||||
this.registerServerbound(ServerboundPacketsb1_7.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
read(Type.BYTE); // dimension id
|
||||
read(Types.BYTE); // dimension id
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_7.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_7.USE_ITEM_ON, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.UNSIGNED_BYTE); // direction
|
||||
map(Types.UNSIGNED_BYTE); // direction
|
||||
map(Types1_4_2.NBTLESS_ITEM); // item
|
||||
handler(wrapper -> {
|
||||
final PlayerInfoStorage playerInfoStorage = wrapper.user().get(PlayerInfoStorage.class);
|
||||
@ -102,7 +102,7 @@ public class Protocolb1_6_0_6tob1_5_0_2 extends StatelessProtocol<ClientboundPac
|
||||
|
||||
final boolean isOccupied = (block.getData() & 4) != 0;
|
||||
if (isOccupied) {
|
||||
final PacketWrapper chat = PacketWrapper.create(ClientboundPacketsb1_7.CHAT_MESSAGE, wrapper.user());
|
||||
final PacketWrapper chat = PacketWrapper.create(ClientboundPacketsb1_7.CHAT, wrapper.user());
|
||||
chat.write(Types1_6_4.STRING, "This bed is occupied");
|
||||
chat.send(Protocolb1_6_0_6tob1_5_0_2.class);
|
||||
return;
|
||||
@ -123,7 +123,7 @@ public class Protocolb1_6_0_6tob1_5_0_2 extends StatelessProtocol<ClientboundPac
|
||||
final boolean isDayTime = (int) (skyRotation * 11F) < 4;
|
||||
|
||||
if (isDayTime) {
|
||||
final PacketWrapper chat = PacketWrapper.create(ClientboundPacketsb1_7.CHAT_MESSAGE, wrapper.user());
|
||||
final PacketWrapper chat = PacketWrapper.create(ClientboundPacketsb1_7.CHAT, wrapper.user());
|
||||
chat.write(Types1_6_4.STRING, "You can only sleep at night");
|
||||
chat.send(Protocolb1_6_0_6tob1_5_0_2.class);
|
||||
return;
|
||||
@ -133,23 +133,23 @@ public class Protocolb1_6_0_6tob1_5_0_2 extends StatelessProtocol<ClientboundPac
|
||||
return;
|
||||
}
|
||||
|
||||
final PacketWrapper useBed = PacketWrapper.create(ClientboundPacketsb1_7.USE_BED, wrapper.user());
|
||||
useBed.write(Type.INT, playerInfoStorage.entityId); // entity id
|
||||
useBed.write(Type.BYTE, (byte) 0); // magic value (always 0)
|
||||
final PacketWrapper useBed = PacketWrapper.create(ClientboundPacketsb1_7.PLAYER_SLEEP, wrapper.user());
|
||||
useBed.write(Types.INT, playerInfoStorage.entityId); // entity id
|
||||
useBed.write(Types.BYTE, (byte) 0); // magic value (always 0)
|
||||
useBed.write(Types1_7_6.POSITION_BYTE, pos); // position
|
||||
useBed.send(Protocolb1_6_0_6tob1_5_0_2.class);
|
||||
} else if (block.getId() == BlockList1_6.jukebox.blockID) {
|
||||
if (block.getData() > 0) {
|
||||
final PacketWrapper effect = PacketWrapper.create(ClientboundPacketsb1_7.EFFECT, wrapper.user());
|
||||
effect.write(Type.INT, 1005); // effect id
|
||||
final PacketWrapper effect = PacketWrapper.create(ClientboundPacketsb1_7.LEVEL_EVENT, wrapper.user());
|
||||
effect.write(Types.INT, 1005); // effect id
|
||||
effect.write(Types1_7_6.POSITION_UBYTE, pos); // position
|
||||
effect.write(Type.INT, 0); // data
|
||||
effect.write(Types.INT, 0); // data
|
||||
effect.send(Protocolb1_6_0_6tob1_5_0_2.class);
|
||||
} else if (item != null && (item.identifier() == ItemList1_6.record13.itemID || item.identifier() == ItemList1_6.recordCat.itemID)) {
|
||||
final PacketWrapper effect = PacketWrapper.create(ClientboundPacketsb1_7.EFFECT, wrapper.user());
|
||||
effect.write(Type.INT, 1005); // effect id
|
||||
final PacketWrapper effect = PacketWrapper.create(ClientboundPacketsb1_7.LEVEL_EVENT, wrapper.user());
|
||||
effect.write(Types.INT, 1005); // effect id
|
||||
effect.write(Types1_7_6.POSITION_UBYTE, pos); // position
|
||||
effect.write(Type.INT, item.identifier()); // data
|
||||
effect.write(Types.INT, item.identifier()); // data
|
||||
effect.send(Protocolb1_6_0_6tob1_5_0_2.class);
|
||||
}
|
||||
}
|
||||
|
@ -37,30 +37,30 @@ public enum ServerboundPacketsb1_5 implements ServerboundPacketType, PreNettyPac
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(9)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
}),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> {
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(2)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ACTION(19, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(2)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_COMMAND(19, (user, buf) -> buf.skipBytes(5)),
|
||||
POSITION(27, (user, buf) -> buf.skipBytes(18)),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CLICK_WINDOW(102, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_CLICK(102, (user, buf) -> {
|
||||
buf.skipBytes(7);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SIGN_UPDATE(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
|
@ -30,102 +30,102 @@ public enum ClientboundPacketsb1_7 implements ClientboundPacketType, PreNettyPac
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> {
|
||||
}),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(2)),
|
||||
RESPAWN(9, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
USE_BED(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
PLAYER_SLEEP(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(24)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> {
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> {
|
||||
buf.skipBytes(17);
|
||||
int i = buf.readInt();
|
||||
if (i > 0) {
|
||||
buf.skipBytes(6);
|
||||
}
|
||||
}),
|
||||
SPAWN_MOB(24, (user, buf) -> {
|
||||
ADD_MOB(24, (user, buf) -> {
|
||||
buf.skipBytes(19);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
SPAWN_PAINTING(25, (user, buf) -> {
|
||||
ADD_PAINTING(25, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_METADATA(40, (user, buf) -> {
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_ENTITY_DATA(40, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ACTION(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_EVENT(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
buf.skipBytes(3);
|
||||
}
|
||||
}),
|
||||
EFFECT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
LEVEL_EVENT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
GAME_EVENT(70, (user, buf) -> buf.skipBytes(1)),
|
||||
SPAWN_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
ADD_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readUTF(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readString(buf);
|
||||
@ -133,12 +133,12 @@ public enum ClientboundPacketsb1_7 implements ClientboundPacketType, PreNettyPac
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
}),
|
||||
MAP_DATA(131, (user, buf) -> {
|
||||
MAP_ITEM_DATA(131, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
short x = buf.readUnsignedByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
STATISTICS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
AWARD_STATS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
DISCONNECT(255, (user, buf) -> readString(buf));
|
||||
|
||||
private static final ClientboundPacketsb1_7[] REGISTRY = new ClientboundPacketsb1_7[256];
|
||||
|
@ -26,7 +26,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.api.data.BlockList1_6;
|
||||
import net.raphimc.vialegacy.api.data.ItemList1_6;
|
||||
@ -61,27 +61,27 @@ public class Protocolb1_8_0_1tob1_7_0_3 extends StatelessProtocol<ClientboundPac
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsb1_7.KEEP_ALIVE, wrapper -> {
|
||||
wrapper.write(Type.INT, ThreadLocalRandom.current().nextInt(1, Short.MAX_VALUE)); // key
|
||||
wrapper.write(Types.INT, ThreadLocalRandom.current().nextInt(1, Short.MAX_VALUE)); // key
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_7.JOIN_GAME, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_7.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Types1_6_4.STRING); // username
|
||||
map(Type.LONG); // seed
|
||||
create(Type.INT, 0); // game mode
|
||||
map(Type.BYTE); // dimension id
|
||||
create(Type.BYTE, (byte) 1); // difficulty
|
||||
create(Type.BYTE, (byte) -128); // world height
|
||||
create(Type.BYTE, (byte) 100); // max players
|
||||
map(Types.LONG); // seed
|
||||
create(Types.INT, 0); // game mode
|
||||
map(Types.BYTE); // dimension id
|
||||
create(Types.BYTE, (byte) 1); // difficulty
|
||||
create(Types.BYTE, (byte) -128); // world height
|
||||
create(Types.BYTE, (byte) 100); // max players
|
||||
handler(wrapper -> {
|
||||
final PacketWrapper playerListEntry = PacketWrapper.create(ClientboundPacketsb1_8.PLAYER_INFO, wrapper.user());
|
||||
playerListEntry.write(Types1_6_4.STRING, wrapper.user().getProtocolInfo().getUsername()); // name
|
||||
playerListEntry.write(Type.BOOLEAN, true); // online
|
||||
playerListEntry.write(Type.SHORT, (short) 0); // ping
|
||||
playerListEntry.write(Types.BOOLEAN, true); // online
|
||||
playerListEntry.write(Types.SHORT, (short) 0); // ping
|
||||
|
||||
final PacketWrapper updateHealth = PacketWrapper.create(ClientboundPacketsb1_7.UPDATE_HEALTH, wrapper.user());
|
||||
updateHealth.write(Type.SHORT, (short) 20); // health
|
||||
final PacketWrapper updateHealth = PacketWrapper.create(ClientboundPacketsb1_7.SET_HEALTH, wrapper.user());
|
||||
updateHealth.write(Types.SHORT, (short) 20); // health
|
||||
|
||||
wrapper.send(Protocolb1_8_0_1tob1_7_0_3.class);
|
||||
wrapper.cancel();
|
||||
@ -90,17 +90,17 @@ public class Protocolb1_8_0_1tob1_7_0_3 extends StatelessProtocol<ClientboundPac
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_7.UPDATE_HEALTH, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_7.SET_HEALTH, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.SHORT); // health
|
||||
create(Type.SHORT, (short) 6); // food
|
||||
create(Type.FLOAT, 0F); // saturation
|
||||
handler(wrapper -> wrapper.user().get(PlayerHealthTracker.class).setHealth(wrapper.get(Type.SHORT, 0)));
|
||||
map(Types.SHORT); // health
|
||||
create(Types.SHORT, (short) 6); // food
|
||||
create(Types.FLOAT, 0F); // saturation
|
||||
handler(wrapper -> wrapper.user().get(PlayerHealthTracker.class).setHealth(wrapper.get(Types.SHORT, 0)));
|
||||
handler(wrapper -> {
|
||||
if (ViaLegacy.getConfig().enableB1_7_3Sprinting()) {
|
||||
wrapper.set(Type.SHORT, 1, (short) 20); // food
|
||||
wrapper.set(Type.FLOAT, 0, 0F); // saturation
|
||||
wrapper.set(Types.SHORT, 1, (short) 20); // food
|
||||
wrapper.set(Types.FLOAT, 0, 0F); // saturation
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -108,63 +108,63 @@ public class Protocolb1_8_0_1tob1_7_0_3 extends StatelessProtocol<ClientboundPac
|
||||
this.registerClientbound(ClientboundPacketsb1_7.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // dimension id
|
||||
create(Type.BYTE, (byte) 1); // difficulty
|
||||
create(Type.BYTE, (byte) 0); // game mode
|
||||
create(Type.SHORT, (short) 128); // world height
|
||||
handler(wrapper -> wrapper.write(Type.LONG, wrapper.user().get(SeedStorage.class).seed)); // seed
|
||||
map(Types.BYTE); // dimension id
|
||||
create(Types.BYTE, (byte) 1); // difficulty
|
||||
create(Types.BYTE, (byte) 0); // game mode
|
||||
create(Types.SHORT, (short) 128); // world height
|
||||
handler(wrapper -> wrapper.write(Types.LONG, wrapper.user().get(SeedStorage.class).seed)); // seed
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_7.SPAWN_PLAYER, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_7.ADD_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Types1_6_4.STRING); // username
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Type.UNSIGNED_SHORT); // item
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
map(Types.UNSIGNED_SHORT); // item
|
||||
handler(wrapper -> {
|
||||
final int entityId = wrapper.get(Type.INT, 0);
|
||||
final int entityId = wrapper.get(Types.INT, 0);
|
||||
final PlayerNameTracker playerNameTracker = wrapper.user().get(PlayerNameTracker.class);
|
||||
playerNameTracker.names.put(entityId, wrapper.get(Types1_6_4.STRING, 0));
|
||||
|
||||
final PacketWrapper playerListEntry = PacketWrapper.create(ClientboundPacketsb1_8.PLAYER_INFO, wrapper.user());
|
||||
playerListEntry.write(Types1_6_4.STRING, playerNameTracker.names.get(entityId)); // name
|
||||
playerListEntry.write(Type.BOOLEAN, true); // online
|
||||
playerListEntry.write(Type.SHORT, (short) 0); // ping
|
||||
playerListEntry.write(Types.BOOLEAN, true); // online
|
||||
playerListEntry.write(Types.SHORT, (short) 0); // ping
|
||||
playerListEntry.send(Protocolb1_8_0_1tob1_7_0_3.class);
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_7.SPAWN_MOB, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_7.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.UNSIGNED_BYTE); // type id
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Types.INT); // entity id
|
||||
map(Types.UNSIGNED_BYTE); // type id
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
map(Types1_3_1.METADATA_LIST); // metadata
|
||||
handler(wrapper -> {
|
||||
final short entityType = wrapper.get(Type.UNSIGNED_BYTE, 0);
|
||||
final short entityType = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
||||
if (entityType == 49) { // monster
|
||||
final PacketWrapper spawnMonster = PacketWrapper.create(ClientboundPacketsb1_8.SPAWN_PLAYER, wrapper.user());
|
||||
spawnMonster.write(Type.INT, wrapper.get(Type.INT, 0)); // entity id
|
||||
final PacketWrapper spawnMonster = PacketWrapper.create(ClientboundPacketsb1_8.ADD_PLAYER, wrapper.user());
|
||||
spawnMonster.write(Types.INT, wrapper.get(Types.INT, 0)); // entity id
|
||||
spawnMonster.write(Types1_6_4.STRING, "Monster"); // username
|
||||
spawnMonster.write(Type.INT, wrapper.get(Type.INT, 1)); // x
|
||||
spawnMonster.write(Type.INT, wrapper.get(Type.INT, 2)); // y
|
||||
spawnMonster.write(Type.INT, wrapper.get(Type.INT, 3)); // z
|
||||
spawnMonster.write(Type.BYTE, wrapper.get(Type.BYTE, 0)); // yaw
|
||||
spawnMonster.write(Type.BYTE, wrapper.get(Type.BYTE, 1)); // pitch
|
||||
spawnMonster.write(Type.UNSIGNED_SHORT, 0); // item
|
||||
spawnMonster.write(Types.INT, wrapper.get(Types.INT, 1)); // x
|
||||
spawnMonster.write(Types.INT, wrapper.get(Types.INT, 2)); // y
|
||||
spawnMonster.write(Types.INT, wrapper.get(Types.INT, 3)); // z
|
||||
spawnMonster.write(Types.BYTE, wrapper.get(Types.BYTE, 0)); // yaw
|
||||
spawnMonster.write(Types.BYTE, wrapper.get(Types.BYTE, 1)); // pitch
|
||||
spawnMonster.write(Types.UNSIGNED_SHORT, 0); // item
|
||||
|
||||
final PacketWrapper entityMetadata = PacketWrapper.create(ClientboundPacketsb1_8.ENTITY_METADATA, wrapper.user());
|
||||
entityMetadata.write(Type.INT, wrapper.get(Type.INT, 0)); // entity id
|
||||
final PacketWrapper entityMetadata = PacketWrapper.create(ClientboundPacketsb1_8.SET_ENTITY_DATA, wrapper.user());
|
||||
entityMetadata.write(Types.INT, wrapper.get(Types.INT, 0)); // entity id
|
||||
entityMetadata.write(Types1_3_1.METADATA_LIST, wrapper.get(Types1_3_1.METADATA_LIST, 0)); // metadata
|
||||
|
||||
wrapper.cancel();
|
||||
@ -174,24 +174,24 @@ public class Protocolb1_8_0_1tob1_7_0_3 extends StatelessProtocol<ClientboundPac
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_7.DESTROY_ENTITIES, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_7.REMOVE_ENTITIES, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
handler(wrapper -> {
|
||||
final PlayerNameTracker playerNameTracker = wrapper.user().get(PlayerNameTracker.class);
|
||||
final String name = playerNameTracker.names.get(wrapper.get(Type.INT, 0).intValue());
|
||||
final String name = playerNameTracker.names.get(wrapper.get(Types.INT, 0).intValue());
|
||||
if (name != null) {
|
||||
final PacketWrapper playerListEntry = PacketWrapper.create(ClientboundPacketsb1_8.PLAYER_INFO, wrapper.user());
|
||||
playerListEntry.write(Types1_6_4.STRING, name); // name
|
||||
playerListEntry.write(Type.BOOLEAN, false); // online
|
||||
playerListEntry.write(Type.SHORT, (short) 0); // ping
|
||||
playerListEntry.write(Types.BOOLEAN, false); // online
|
||||
playerListEntry.write(Types.SHORT, (short) 0); // ping
|
||||
playerListEntry.send(Protocolb1_8_0_1tob1_7_0_3.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_7.CHUNK_DATA, wrapper -> {
|
||||
this.registerClientbound(ClientboundPacketsb1_7.LEVEL_CHUNK, wrapper -> {
|
||||
final Chunk chunk = wrapper.passthrough(Types1_1.CHUNK);
|
||||
|
||||
boolean hasChest = false;
|
||||
@ -216,17 +216,17 @@ public class Protocolb1_8_0_1tob1_7_0_3 extends StatelessProtocol<ClientboundPac
|
||||
this.registerClientbound(ClientboundPacketsb1_7.GAME_EVENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // reason
|
||||
create(Type.BYTE, (byte) 0); // value
|
||||
map(Types.BYTE); // reason
|
||||
create(Types.BYTE, (byte) 0); // value
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsb1_7.OPEN_WINDOW, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsb1_7.OPEN_SCREEN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // window id
|
||||
map(Type.UNSIGNED_BYTE); // window type
|
||||
map(Types.UNSIGNED_BYTE); // window id
|
||||
map(Types.UNSIGNED_BYTE); // window type
|
||||
map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // title
|
||||
map(Type.UNSIGNED_BYTE); // slots
|
||||
map(Types.UNSIGNED_BYTE); // slots
|
||||
}
|
||||
});
|
||||
|
||||
@ -247,96 +247,96 @@ public class Protocolb1_8_0_1tob1_7_0_3 extends StatelessProtocol<ClientboundPac
|
||||
this.registerServerbound(ServerboundPacketsb1_8.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // protocol id
|
||||
map(Types.INT); // protocol id
|
||||
map(Types1_6_4.STRING); // username
|
||||
map(Type.LONG); // seed
|
||||
read(Type.INT); // game mode
|
||||
map(Type.BYTE); // dimension id
|
||||
read(Type.BYTE); // difficulty
|
||||
read(Type.BYTE); // world height
|
||||
read(Type.BYTE); // max players
|
||||
map(Types.LONG); // seed
|
||||
read(Types.INT); // game mode
|
||||
map(Types.BYTE); // dimension id
|
||||
read(Types.BYTE); // difficulty
|
||||
read(Types.BYTE); // world height
|
||||
read(Types.BYTE); // max players
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_8.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // dimension id
|
||||
read(Type.BYTE); // difficulty
|
||||
read(Type.BYTE); // game mode
|
||||
read(Type.SHORT); // world height
|
||||
read(Type.LONG); // seed
|
||||
map(Types.BYTE); // dimension id
|
||||
read(Types.BYTE); // difficulty
|
||||
read(Types.BYTE); // game mode
|
||||
read(Types.SHORT); // world height
|
||||
read(Types.LONG); // seed
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_8.PLAYER_DIGGING, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_8.PLAYER_ACTION, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // status
|
||||
map(Types.UNSIGNED_BYTE); // status
|
||||
handler(wrapper -> {
|
||||
final short status = wrapper.get(Type.UNSIGNED_BYTE, 0);
|
||||
final short status = wrapper.get(Types.UNSIGNED_BYTE, 0);
|
||||
if (status == 5) wrapper.cancel(); // Stop using item
|
||||
});
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.UNSIGNED_BYTE); // direction
|
||||
map(Types.UNSIGNED_BYTE); // direction
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_8.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_8.USE_ITEM_ON, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.UNSIGNED_BYTE); // direction
|
||||
map(Types.UNSIGNED_BYTE); // direction
|
||||
map(Types1_4_2.NBTLESS_ITEM); // item
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.UNSIGNED_BYTE, 0) == 255) {
|
||||
if (wrapper.get(Types.UNSIGNED_BYTE, 0) == 255) {
|
||||
final Item item = wrapper.get(Types1_4_2.NBTLESS_ITEM, 0);
|
||||
if (item != null && isSword(item)) {
|
||||
wrapper.cancel();
|
||||
final PacketWrapper entityStatus = PacketWrapper.create(ClientboundPacketsb1_8.ENTITY_STATUS, wrapper.user());
|
||||
entityStatus.write(Type.INT, wrapper.user().get(EntityTracker.class).getPlayerID()); // entity id
|
||||
entityStatus.write(Type.BYTE, (byte) 9); // status | 9 = STOP_ITEM_USE
|
||||
final PacketWrapper entityStatus = PacketWrapper.create(ClientboundPacketsb1_8.ENTITY_EVENT, wrapper.user());
|
||||
entityStatus.write(Types.INT, wrapper.user().get(EntityTracker.class).getPlayerID()); // entity id
|
||||
entityStatus.write(Types.BYTE, (byte) 9); // status | 9 = STOP_ITEM_USE
|
||||
entityStatus.send(Protocolb1_8_0_1tob1_7_0_3.class);
|
||||
}
|
||||
} else {
|
||||
final Position pos = wrapper.get(Types1_7_6.POSITION_UBYTE, 0);
|
||||
if (wrapper.user().get(ChunkTracker.class).getBlockNotNull(pos).getId() == BlockList1_6.cake.blockID) {
|
||||
final PacketWrapper updateHealth = PacketWrapper.create(ClientboundPacketsb1_7.UPDATE_HEALTH, wrapper.user());
|
||||
updateHealth.write(Type.SHORT, wrapper.user().get(PlayerHealthTracker.class).getHealth()); // health
|
||||
final PacketWrapper updateHealth = PacketWrapper.create(ClientboundPacketsb1_7.SET_HEALTH, wrapper.user());
|
||||
updateHealth.write(Types.SHORT, wrapper.user().get(PlayerHealthTracker.class).getHealth()); // health
|
||||
updateHealth.send(Protocolb1_8_0_1tob1_7_0_3.class, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_8.ENTITY_ACTION, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_8.PLAYER_COMMAND, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.BYTE); // action id
|
||||
map(Types.INT); // entity id
|
||||
map(Types.BYTE); // action id
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.BYTE, 0) > 3) wrapper.cancel();
|
||||
if (wrapper.get(Types.BYTE, 0) > 3) wrapper.cancel();
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_8.CLICK_WINDOW, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsb1_8.CONTAINER_CLICK, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // window id
|
||||
map(Types.BYTE); // window id
|
||||
handler(wrapper -> {
|
||||
if (wrapper.passthrough(Type.SHORT) /*slot*/ == -1) wrapper.cancel();
|
||||
if (wrapper.passthrough(Types.SHORT) /*slot*/ == -1) wrapper.cancel();
|
||||
});
|
||||
map(Type.BYTE); // button
|
||||
map(Type.SHORT); // action
|
||||
map(Type.BYTE); // mode
|
||||
map(Types.BYTE); // button
|
||||
map(Types.SHORT); // action
|
||||
map(Types.BYTE); // mode
|
||||
map(Types1_4_2.NBTLESS_ITEM); // item
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_8.CREATIVE_INVENTORY_ACTION, null, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsb1_8.SET_CREATIVE_MODE_SLOT, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
// Track the item for later use in classic protocols
|
||||
final AlphaInventoryTracker inventoryTracker = wrapper.user().get(AlphaInventoryTracker.class);
|
||||
if (inventoryTracker != null) inventoryTracker.handleCreativeSetSlot(wrapper.read(Type.SHORT), wrapper.read(Typesb1_8_0_1.CREATIVE_ITEM));
|
||||
if (inventoryTracker != null) inventoryTracker.handleCreativeSetSlot(wrapper.read(Types.SHORT), wrapper.read(Typesb1_8_0_1.CREATIVE_ITEM));
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsb1_8.KEEP_ALIVE, wrapper -> {
|
||||
if (wrapper.read(Type.INT) != 0) { // beta client only sends this packet with the key set to 0 every second if in downloading terrain screen
|
||||
if (wrapper.read(Types.INT) != 0) { // beta client only sends this packet with the key set to 0 every second if in downloading terrain screen
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
|
@ -37,29 +37,29 @@ public enum ServerboundPacketsb1_7 implements ServerboundPacketType, PreNettyPac
|
||||
buf.skipBytes(9);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(9)),
|
||||
RESPAWN(9, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> {
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(2)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ACTION(19, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(2)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_COMMAND(19, (user, buf) -> buf.skipBytes(5)),
|
||||
POSITION(27, (user, buf) -> buf.skipBytes(18)),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CLICK_WINDOW(102, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_CLICK(102, (user, buf) -> {
|
||||
buf.skipBytes(7);
|
||||
readItemStackb1_2(buf);
|
||||
}),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SIGN_UPDATE(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
|
@ -30,14 +30,22 @@ public class StringType extends Type<String> {
|
||||
super(String.class);
|
||||
}
|
||||
|
||||
public String read(ByteBuf buffer) throws IOException {
|
||||
public String read(ByteBuf buffer) {
|
||||
final ByteBufInputStream dis = new ByteBufInputStream(buffer);
|
||||
return dis.readUTF();
|
||||
try {
|
||||
return dis.readUTF();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(ByteBuf buffer, String s) throws IOException {
|
||||
public void write(ByteBuf buffer, String s) {
|
||||
final ByteBufOutputStream dos = new ByteBufOutputStream(buffer);
|
||||
dos.writeUTF(s);
|
||||
try {
|
||||
dos.writeUTF(s);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,21 +26,21 @@ import java.util.function.BiConsumer;
|
||||
|
||||
public enum ClientboundPacketsc0_28 implements ClientboundPacketType, PreNettyPacketType {
|
||||
|
||||
JOIN_GAME(0, (user, buf) -> buf.skipBytes(130)),
|
||||
LOGIN(0, (user, buf) -> buf.skipBytes(130)),
|
||||
KEEP_ALIVE(1, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_INIT(2, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_DATA(3, (user, buf) -> buf.skipBytes(1027)),
|
||||
LEVEL_FINALIZE(4, (user, buf) -> buf.skipBytes(6)),
|
||||
BLOCK_CHANGE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
SPAWN_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
ENTITY_TELEPORT(8, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_POSITION_AND_ROTATION(9, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION(10, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_ROTATION(11, (user, buf) -> buf.skipBytes(3)),
|
||||
DESTROY_ENTITIES(12, (user, buf) -> buf.skipBytes(1)),
|
||||
CHAT_MESSAGE(13, (user, buf) -> buf.skipBytes(65)),
|
||||
BLOCK_UPDATE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
ADD_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
TELEPORT_ENTITY(8, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_ENTITY_POS_ROT(9, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS(10, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_ROT(11, (user, buf) -> buf.skipBytes(3)),
|
||||
REMOVE_ENTITIES(12, (user, buf) -> buf.skipBytes(1)),
|
||||
CHAT(13, (user, buf) -> buf.skipBytes(65)),
|
||||
DISCONNECT(14, (user, buf) -> buf.skipBytes(64)),
|
||||
OP_LEVEL_UPDATE(15, (user, buf) -> buf.skipBytes(1));
|
||||
|
||||
|
@ -24,8 +24,8 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_8;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.api.data.BlockList1_6;
|
||||
@ -67,18 +67,18 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.JOIN_GAME, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
read(Type.BYTE); // protocol id
|
||||
read(Types.BYTE); // protocol id
|
||||
handler(wrapper -> {
|
||||
final String title = wrapper.read(Typesc0_30.STRING).replace("&", "§"); // title
|
||||
final String motd = wrapper.read(Typesc0_30.STRING).replace("&", "§"); // motd
|
||||
final byte opLevel = wrapper.read(Type.BYTE); // op level
|
||||
final byte opLevel = wrapper.read(Types.BYTE); // op level
|
||||
wrapper.user().put(new ClassicServerTitleStorage(wrapper.user(), title, motd));
|
||||
wrapper.user().get(ClassicOpLevelStorage.class).setOpLevel(opLevel);
|
||||
|
||||
wrapper.write(Type.INT, wrapper.user().getProtocolInfo().getUsername().hashCode()); // entity id
|
||||
wrapper.write(Types.INT, wrapper.user().getProtocolInfo().getUsername().hashCode()); // entity id
|
||||
wrapper.write(Typesb1_7_0_3.STRING, wrapper.user().getProtocolInfo().getUsername()); // username
|
||||
wrapper.write(Typesb1_7_0_3.STRING, ""); // password
|
||||
|
||||
@ -88,8 +88,8 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
|
||||
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocol1_8to1_7_6_10.class)) {
|
||||
final PacketWrapper tabList = PacketWrapper.create(ClientboundPackets1_8.TAB_LIST, wrapper.user());
|
||||
tabList.write(Type.STRING, Protocol1_8to1_7_6_10.LEGACY_TO_JSON.transform(wrapper, "§6" + title + "\n")); // header
|
||||
tabList.write(Type.STRING, Protocol1_8to1_7_6_10.LEGACY_TO_JSON.transform(wrapper, "\n§b" + motd)); // footer
|
||||
tabList.write(Types.STRING, Protocol1_8to1_7_6_10.LEGACY_TO_JSON.transform(wrapper, "§6" + title + "\n")); // header
|
||||
tabList.write(Types.STRING, Protocol1_8to1_7_6_10.LEGACY_TO_JSON.transform(wrapper, "\n§b" + motd)); // footer
|
||||
tabList.send(Protocol1_8to1_7_6_10.class);
|
||||
}
|
||||
|
||||
@ -106,18 +106,18 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
if (wrapper.user().has(ClassicLevelStorage.class)) { // Switch world
|
||||
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocolb1_6_0_6tob1_5_0_2.class)) {
|
||||
final PacketWrapper fakeRespawn = PacketWrapper.create(ClientboundPacketsb1_7.RESPAWN, wrapper.user());
|
||||
fakeRespawn.write(Type.BYTE, (byte) -1); // dimension id
|
||||
fakeRespawn.write(Types.BYTE, (byte) -1); // dimension id
|
||||
fakeRespawn.send(Protocolb1_6_0_6tob1_5_0_2.class);
|
||||
final PacketWrapper respawn = PacketWrapper.create(ClientboundPacketsb1_7.RESPAWN, wrapper.user());
|
||||
respawn.write(Type.BYTE, (byte) 0); // dimension id
|
||||
respawn.write(Types.BYTE, (byte) 0); // dimension id
|
||||
respawn.send(Protocolb1_6_0_6tob1_5_0_2.class);
|
||||
wrapper.user().get(ClassicPositionTracker.class).spawned = false;
|
||||
}
|
||||
}
|
||||
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocolb1_8_0_1tob1_7_0_3.class)) {
|
||||
final PacketWrapper gameEvent = PacketWrapper.create(ClientboundPacketsb1_8.GAME_EVENT, wrapper.user());
|
||||
gameEvent.write(Type.BYTE, (byte) 3); // reason (game mode)
|
||||
gameEvent.write(Type.BYTE, (byte) 1); // value (creative)
|
||||
gameEvent.write(Types.BYTE, (byte) 3); // reason (game mode)
|
||||
gameEvent.write(Types.BYTE, (byte) 1); // value (creative)
|
||||
gameEvent.send(Protocolb1_8_0_1tob1_7_0_3.class);
|
||||
}
|
||||
wrapper.user().get(ClassicOpLevelStorage.class).updateAbilities();
|
||||
@ -131,9 +131,9 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.LEVEL_DATA, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
final short partSize = wrapper.read(Type.SHORT); // part size
|
||||
final short partSize = wrapper.read(Types.SHORT); // part size
|
||||
final byte[] data = wrapper.read(Typesc0_30.BYTE_ARRAY); // data
|
||||
final byte progress = wrapper.read(Type.BYTE); // progress
|
||||
final byte progress = wrapper.read(Types.BYTE); // progress
|
||||
|
||||
wrapper.user().get(ClassicLevelStorage.class).addDataPart(data, partSize);
|
||||
|
||||
@ -144,9 +144,9 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.LEVEL_FINALIZE, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
final short sizeX = wrapper.read(Type.SHORT);
|
||||
final short sizeY = wrapper.read(Type.SHORT);
|
||||
final short sizeZ = wrapper.read(Type.SHORT);
|
||||
final short sizeX = wrapper.read(Types.SHORT);
|
||||
final short sizeY = wrapper.read(Types.SHORT);
|
||||
final short sizeZ = wrapper.read(Types.SHORT);
|
||||
|
||||
final ClassicProgressStorage classicProgressStorage = wrapper.user().get(ClassicProgressStorage.class);
|
||||
final ClassicLevelStorage levelStorage = wrapper.user().get(ClassicLevelStorage.class);
|
||||
@ -159,16 +159,16 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
levelStorage.sendChunk(new ChunkCoord(0, 0));
|
||||
|
||||
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocol1_8to1_7_6_10.class)) {
|
||||
final PacketWrapper worldBorder = PacketWrapper.create(ClientboundPackets1_8.WORLD_BORDER, wrapper.user());
|
||||
worldBorder.write(Type.VAR_INT, 3); // action (INITIALIZE)
|
||||
worldBorder.write(Type.DOUBLE, sizeX / 2D); // centerX
|
||||
worldBorder.write(Type.DOUBLE, sizeZ / 2D); // centerZ
|
||||
worldBorder.write(Type.DOUBLE, 0.0D); // diameter
|
||||
worldBorder.write(Type.DOUBLE, (double) Math.max(sizeX, sizeZ)); // target size
|
||||
worldBorder.write(Type.VAR_LONG, 0L); // time until target size
|
||||
worldBorder.write(Type.VAR_INT, Math.max(sizeX, sizeZ)); // size
|
||||
worldBorder.write(Type.VAR_INT, 0); // warning distance
|
||||
worldBorder.write(Type.VAR_INT, 0); // warning time
|
||||
final PacketWrapper worldBorder = PacketWrapper.create(ClientboundPackets1_8.SET_BORDER, wrapper.user());
|
||||
worldBorder.write(Types.VAR_INT, 3); // action (INITIALIZE)
|
||||
worldBorder.write(Types.DOUBLE, sizeX / 2D); // centerX
|
||||
worldBorder.write(Types.DOUBLE, sizeZ / 2D); // centerZ
|
||||
worldBorder.write(Types.DOUBLE, 0.0D); // diameter
|
||||
worldBorder.write(Types.DOUBLE, (double) Math.max(sizeX, sizeZ)); // target size
|
||||
worldBorder.write(Types.VAR_LONG, 0L); // time until target size
|
||||
worldBorder.write(Types.VAR_INT, Math.max(sizeX, sizeZ)); // size
|
||||
worldBorder.write(Types.VAR_INT, 0); // warning distance
|
||||
worldBorder.write(Types.VAR_INT, 0); // warning time
|
||||
worldBorder.send(Protocol1_8to1_7_6_10.class);
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
classicProgressStorage.progress = 1;
|
||||
classicProgressStorage.status = "Finishing level... §7Waiting for server";
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.BLOCK_CHANGE, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.BLOCK_UPDATE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Typesc0_30.POSITION, Types1_7_6.POSITION_UBYTE); // position
|
||||
@ -192,37 +192,37 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
}
|
||||
final ClassicBlockRemapper remapper = wrapper.user().get(ClassicBlockRemapper.class);
|
||||
final Position pos = wrapper.get(Types1_7_6.POSITION_UBYTE, 0);
|
||||
final byte blockId = wrapper.read(Type.BYTE); // block id
|
||||
final byte blockId = wrapper.read(Types.BYTE); // block id
|
||||
levelStorage.getClassicLevel().setBlock(pos, blockId);
|
||||
if (!levelStorage.isChunkLoaded(pos)) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
final IdAndData mappedBlock = remapper.getMapper().get(blockId);
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) mappedBlock.getId()); // block id
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) mappedBlock.getData()); // block data
|
||||
wrapper.write(Types.UNSIGNED_BYTE, (short) mappedBlock.getId()); // block id
|
||||
wrapper.write(Types.UNSIGNED_BYTE, (short) mappedBlock.getData()); // block data
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.SPAWN_PLAYER, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.ADD_PLAYER, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE, Type.INT); // entity id
|
||||
map(Types.BYTE, Types.INT); // entity id
|
||||
map(Typesc0_30.STRING, Typesb1_7_0_3.STRING, n -> n.replace("&", "§")); // username
|
||||
map(Type.SHORT, Type.INT); // x
|
||||
map(Type.SHORT, Type.INT); // y
|
||||
map(Type.SHORT, Type.INT); // z
|
||||
map(Type.BYTE, Type.BYTE, yaw -> (byte) (yaw + 128)); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
create(Type.UNSIGNED_SHORT, 0); // item
|
||||
map(Types.SHORT, Types.INT); // x
|
||||
map(Types.SHORT, Types.INT); // y
|
||||
map(Types.SHORT, Types.INT); // z
|
||||
map(Types.BYTE, Types.BYTE, yaw -> (byte) (yaw + 128)); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
create(Types.UNSIGNED_SHORT, 0); // item
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.INT, 0) < 0) { // client player
|
||||
if (wrapper.get(Types.INT, 0) < 0) { // client player
|
||||
wrapper.cancel();
|
||||
final int x = wrapper.get(Type.INT, 1);
|
||||
final int y = wrapper.get(Type.INT, 2);
|
||||
final int z = wrapper.get(Type.INT, 3);
|
||||
final byte yaw = wrapper.get(Type.BYTE, 0);
|
||||
final byte pitch = wrapper.get(Type.BYTE, 1);
|
||||
final int x = wrapper.get(Types.INT, 1);
|
||||
final int y = wrapper.get(Types.INT, 2);
|
||||
final int z = wrapper.get(Types.INT, 3);
|
||||
final byte yaw = wrapper.get(Types.BYTE, 0);
|
||||
final byte pitch = wrapper.get(Types.BYTE, 1);
|
||||
|
||||
final ClassicProgressStorage classicProgressStorage = wrapper.user().get(ClassicProgressStorage.class);
|
||||
classicProgressStorage.progress = 2;
|
||||
@ -237,85 +237,85 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
wrapper.user().get(ClassicLevelStorage.class).sendChunks(classicPositionTracker.getChunkPosition(), 1);
|
||||
|
||||
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.class)) {
|
||||
final PacketWrapper spawnPosition = PacketWrapper.create(ClientboundPacketsa1_1_0.SPAWN_POSITION, wrapper.user());
|
||||
final PacketWrapper spawnPosition = PacketWrapper.create(ClientboundPacketsa1_1_0.SET_DEFAULT_SPAWN_POSITION, wrapper.user());
|
||||
spawnPosition.write(Types1_7_6.POSITION_INT, new Position((int) classicPositionTracker.posX, (int) (classicPositionTracker.stance), (int) classicPositionTracker.posZ));
|
||||
spawnPosition.send(Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.class);
|
||||
}
|
||||
|
||||
final PacketWrapper playerPosition = PacketWrapper.create(ClientboundPacketsa1_0_15.PLAYER_POSITION, wrapper.user());
|
||||
playerPosition.write(Type.DOUBLE, classicPositionTracker.posX); // x
|
||||
playerPosition.write(Type.DOUBLE, classicPositionTracker.stance); // stance
|
||||
playerPosition.write(Type.DOUBLE, classicPositionTracker.stance - 1.62F); // y
|
||||
playerPosition.write(Type.DOUBLE, classicPositionTracker.posZ); // z
|
||||
playerPosition.write(Type.FLOAT, classicPositionTracker.yaw); // yaw
|
||||
playerPosition.write(Type.FLOAT, classicPositionTracker.pitch); // pitch
|
||||
playerPosition.write(Type.BOOLEAN, true); // onGround
|
||||
playerPosition.write(Types.DOUBLE, classicPositionTracker.posX); // x
|
||||
playerPosition.write(Types.DOUBLE, classicPositionTracker.stance); // stance
|
||||
playerPosition.write(Types.DOUBLE, classicPositionTracker.stance - 1.62F); // y
|
||||
playerPosition.write(Types.DOUBLE, classicPositionTracker.posZ); // z
|
||||
playerPosition.write(Types.FLOAT, classicPositionTracker.yaw); // yaw
|
||||
playerPosition.write(Types.FLOAT, classicPositionTracker.pitch); // pitch
|
||||
playerPosition.write(Types.BOOLEAN, true); // onGround
|
||||
playerPosition.send(Protocola1_0_15toc0_30.class);
|
||||
classicPositionTracker.spawned = true;
|
||||
} else {
|
||||
wrapper.set(Type.INT, 2, wrapper.get(Type.INT, 2) - Float.valueOf(1.62F * 32).intValue());
|
||||
wrapper.set(Types.INT, 2, wrapper.get(Types.INT, 2) - Float.valueOf(1.62F * 32).intValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.ENTITY_TELEPORT, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.TELEPORT_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE, Type.INT); // entity id
|
||||
map(Type.SHORT, Type.INT); // x
|
||||
map(Type.SHORT, Type.INT); // y
|
||||
map(Type.SHORT, Type.INT); // z
|
||||
map(Type.BYTE, Type.BYTE, yaw -> (byte) (yaw + 128)); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Types.BYTE, Types.INT); // entity id
|
||||
map(Types.SHORT, Types.INT); // x
|
||||
map(Types.SHORT, Types.INT); // y
|
||||
map(Types.SHORT, Types.INT); // z
|
||||
map(Types.BYTE, Types.BYTE, yaw -> (byte) (yaw + 128)); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
handler(wrapper -> {
|
||||
if (wrapper.get(Type.INT, 0) < 0) { // client player
|
||||
wrapper.set(Type.INT, 2, wrapper.get(Type.INT, 2) - 29);
|
||||
wrapper.set(Type.INT, 0, wrapper.user().getProtocolInfo().getUsername().hashCode());
|
||||
if (wrapper.get(Types.INT, 0) < 0) { // client player
|
||||
wrapper.set(Types.INT, 2, wrapper.get(Types.INT, 2) - 29);
|
||||
wrapper.set(Types.INT, 0, wrapper.user().getProtocolInfo().getUsername().hashCode());
|
||||
} else {
|
||||
wrapper.set(Type.INT, 2, wrapper.get(Type.INT, 2) - Float.valueOf(1.62F * 32).intValue());
|
||||
wrapper.set(Types.INT, 2, wrapper.get(Types.INT, 2) - Float.valueOf(1.62F * 32).intValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.ENTITY_POSITION_AND_ROTATION, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.MOVE_ENTITY_POS_ROT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE, Type.INT); // entity id
|
||||
map(Type.BYTE); // x
|
||||
map(Type.BYTE); // y
|
||||
map(Type.BYTE); // z
|
||||
map(Type.BYTE, Type.BYTE, yaw -> (byte) (yaw + 128)); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Types.BYTE, Types.INT); // entity id
|
||||
map(Types.BYTE); // x
|
||||
map(Types.BYTE); // y
|
||||
map(Types.BYTE); // z
|
||||
map(Types.BYTE, Types.BYTE, yaw -> (byte) (yaw + 128)); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.ENTITY_POSITION, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.MOVE_ENTITY_POS, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE, Type.INT); // entity id
|
||||
map(Type.BYTE); // x
|
||||
map(Type.BYTE); // y
|
||||
map(Type.BYTE); // z
|
||||
map(Types.BYTE, Types.INT); // entity id
|
||||
map(Types.BYTE); // x
|
||||
map(Types.BYTE); // y
|
||||
map(Types.BYTE); // z
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.ENTITY_ROTATION, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.MOVE_ENTITY_ROT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE, Type.INT); // entity id
|
||||
map(Type.BYTE, Type.BYTE, yaw -> (byte) (yaw + 128)); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Types.BYTE, Types.INT); // entity id
|
||||
map(Types.BYTE, Types.BYTE, yaw -> (byte) (yaw + 128)); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.DESTROY_ENTITIES, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.REMOVE_ENTITIES, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE, Type.INT); // entity id
|
||||
map(Types.BYTE, Types.INT); // entity id
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_28.CHAT_MESSAGE, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_28.CHAT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
handler(packetWrapper -> {
|
||||
final byte senderId = packetWrapper.read(Type.BYTE); // sender id
|
||||
final byte senderId = packetWrapper.read(Types.BYTE); // sender id
|
||||
String message = packetWrapper.read(Typesc0_30.STRING).replace("&", "§"); // message
|
||||
if (senderId < 0) {
|
||||
message = "§e" + message;
|
||||
@ -333,19 +333,19 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
this.registerClientbound(ClientboundPacketsc0_28.OP_LEVEL_UPDATE, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
final ClassicOpLevelStorage opLevelStorage = wrapper.user().get(ClassicOpLevelStorage.class);
|
||||
final byte opLevel = wrapper.read(Type.BYTE); // op level
|
||||
final byte opLevel = wrapper.read(Types.BYTE); // op level
|
||||
opLevelStorage.setOpLevel(opLevel);
|
||||
});
|
||||
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT, Type.BYTE); // protocol id
|
||||
map(Types.INT, Types.BYTE); // protocol id
|
||||
map(Typesb1_7_0_3.STRING, Typesc0_30.STRING); // username
|
||||
read(Typesb1_7_0_3.STRING); // password
|
||||
handler(wrapper -> {
|
||||
wrapper.write(Typesc0_30.STRING, Via.getManager().getProviders().get(ClassicMPPassProvider.class).getMpPass(wrapper.user())); // mp pass
|
||||
wrapper.write(Type.BYTE, (byte) 0); // op level
|
||||
wrapper.write(Types.BYTE, (byte) 0); // op level
|
||||
|
||||
final ClassicProgressStorage classicProgressStorage = wrapper.user().get(ClassicProgressStorage.class);
|
||||
classicProgressStorage.upperBound = 2;
|
||||
@ -353,60 +353,60 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.CHAT_MESSAGE, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.CHAT, wrapper -> {
|
||||
final String message = wrapper.read(Typesb1_7_0_3.STRING); // message
|
||||
wrapper.write(Type.BYTE, (byte) 0); // sender id
|
||||
wrapper.write(Types.BYTE, (byte) 0); // sender id
|
||||
wrapper.write(Typesc0_30.STRING, message); // message
|
||||
if (Via.getManager().getProviders().get(ClassicCustomCommandProvider.class).handleChatMessage(wrapper.user(), message)) {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.PLAYER_MOVEMENT, ServerboundPacketsc0_28.PLAYER_POSITION_AND_ROTATION, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.MOVE_PLAYER_STATUS_ONLY, ServerboundPacketsc0_28.MOVE_PLAYER_POS_ROT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
read(Type.BOOLEAN); // onGround
|
||||
read(Types.BOOLEAN); // onGround
|
||||
handler(wrapper -> wrapper.user().get(ClassicPositionTracker.class).writeToPacket(wrapper));
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.PLAYER_POSITION, ServerboundPacketsc0_28.PLAYER_POSITION_AND_ROTATION, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.MOVE_PLAYER_POS, ServerboundPacketsc0_28.MOVE_PLAYER_POS_ROT, wrapper -> {
|
||||
final ClassicPositionTracker positionTracker = wrapper.user().get(ClassicPositionTracker.class);
|
||||
positionTracker.posX = wrapper.read(Type.DOUBLE); // x
|
||||
wrapper.read(Type.DOUBLE); // y
|
||||
positionTracker.stance = wrapper.read(Type.DOUBLE); // stance
|
||||
positionTracker.posZ = wrapper.read(Type.DOUBLE); // z
|
||||
wrapper.read(Type.BOOLEAN); // onGround
|
||||
positionTracker.posX = wrapper.read(Types.DOUBLE); // x
|
||||
wrapper.read(Types.DOUBLE); // y
|
||||
positionTracker.stance = wrapper.read(Types.DOUBLE); // stance
|
||||
positionTracker.posZ = wrapper.read(Types.DOUBLE); // z
|
||||
wrapper.read(Types.BOOLEAN); // onGround
|
||||
|
||||
positionTracker.writeToPacket(wrapper);
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.PLAYER_ROTATION, ServerboundPacketsc0_28.PLAYER_POSITION_AND_ROTATION, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.MOVE_PLAYER_ROT, ServerboundPacketsc0_28.MOVE_PLAYER_POS_ROT, wrapper -> {
|
||||
final ClassicPositionTracker positionTracker = wrapper.user().get(ClassicPositionTracker.class);
|
||||
positionTracker.yaw = wrapper.read(Type.FLOAT); // yaw
|
||||
positionTracker.pitch = wrapper.read(Type.FLOAT); // pitch
|
||||
wrapper.read(Type.BOOLEAN); // onGround
|
||||
positionTracker.yaw = wrapper.read(Types.FLOAT); // yaw
|
||||
positionTracker.pitch = wrapper.read(Types.FLOAT); // pitch
|
||||
wrapper.read(Types.BOOLEAN); // onGround
|
||||
|
||||
positionTracker.writeToPacket(wrapper);
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.PLAYER_POSITION_AND_ROTATION, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.MOVE_PLAYER_POS_ROT, wrapper -> {
|
||||
final ClassicPositionTracker positionTracker = wrapper.user().get(ClassicPositionTracker.class);
|
||||
positionTracker.posX = wrapper.read(Type.DOUBLE); // x
|
||||
wrapper.read(Type.DOUBLE); // y
|
||||
positionTracker.stance = wrapper.read(Type.DOUBLE); // stance
|
||||
positionTracker.posZ = wrapper.read(Type.DOUBLE); // z
|
||||
positionTracker.yaw = wrapper.read(Type.FLOAT); // yaw
|
||||
positionTracker.pitch = wrapper.read(Type.FLOAT); // pitch
|
||||
wrapper.read(Type.BOOLEAN); // onGround
|
||||
positionTracker.posX = wrapper.read(Types.DOUBLE); // x
|
||||
wrapper.read(Types.DOUBLE); // y
|
||||
positionTracker.stance = wrapper.read(Types.DOUBLE); // stance
|
||||
positionTracker.posZ = wrapper.read(Types.DOUBLE); // z
|
||||
positionTracker.yaw = wrapper.read(Types.FLOAT); // yaw
|
||||
positionTracker.pitch = wrapper.read(Types.FLOAT); // pitch
|
||||
wrapper.read(Types.BOOLEAN); // onGround
|
||||
|
||||
positionTracker.writeToPacket(wrapper);
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.PLAYER_DIGGING, ServerboundPacketsc0_28.PLAYER_BLOCK_PLACEMENT, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.PLAYER_ACTION, ServerboundPacketsc0_28.USE_ITEM_ON, wrapper -> {
|
||||
wrapper.user().getStoredObjects().remove(BlockDigStorage.class);
|
||||
final ClassicLevel level = wrapper.user().get(ClassicLevelStorage.class).getClassicLevel();
|
||||
final ClassicOpLevelStorage opTracker = wrapper.user().get(ClassicOpLevelStorage.class);
|
||||
final boolean extendedVerification = wrapper.user().has(ExtBlockPermissionsStorage.class);
|
||||
|
||||
final short status = wrapper.read(Type.UNSIGNED_BYTE); // status
|
||||
final short status = wrapper.read(Types.UNSIGNED_BYTE); // status
|
||||
final Position pos = wrapper.read(Types1_7_6.POSITION_UBYTE); // position
|
||||
wrapper.read(Type.UNSIGNED_BYTE); // direction
|
||||
wrapper.read(Types.UNSIGNED_BYTE); // direction
|
||||
final int blockId = level.getBlock(pos);
|
||||
|
||||
final boolean hasCreative = wrapper.user().getProtocolInfo().getPipeline().contains(Protocolb1_8_0_1tob1_7_0_3.class);
|
||||
@ -423,20 +423,20 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
}
|
||||
|
||||
wrapper.write(Typesc0_30.POSITION, pos); // position
|
||||
wrapper.write(Type.BOOLEAN, false); // place block
|
||||
wrapper.write(Type.BYTE, (byte) ClassicBlocks.STONE); // block id
|
||||
wrapper.write(Types.BOOLEAN, false); // place block
|
||||
wrapper.write(Types.BYTE, (byte) ClassicBlocks.STONE); // block id
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.PLAYER_BLOCK_PLACEMENT, wrapper -> {
|
||||
this.registerServerbound(ServerboundPacketsa1_0_15.USE_ITEM_ON, wrapper -> {
|
||||
final ClassicLevel level = wrapper.user().get(ClassicLevelStorage.class).getClassicLevel();
|
||||
final ClassicBlockRemapper remapper = wrapper.user().get(ClassicBlockRemapper.class);
|
||||
final boolean extendedVerification = wrapper.user().has(ExtBlockPermissionsStorage.class);
|
||||
|
||||
wrapper.read(Type.SHORT); // item id (is useless because it has no item damage)
|
||||
wrapper.read(Types.SHORT); // item id (is useless because it has no item damage)
|
||||
Position pos = wrapper.read(Types1_7_6.POSITION_UBYTE); // position
|
||||
final short direction = wrapper.read(Type.UNSIGNED_BYTE); // direction
|
||||
final short direction = wrapper.read(Types.UNSIGNED_BYTE); // direction
|
||||
|
||||
final Item item = Via.getManager().getProviders().get(AlphaInventoryProvider.class).getHandItem(wrapper.user());
|
||||
if (item == null || direction == 255) {
|
||||
@ -460,27 +460,27 @@ public class Protocola1_0_15toc0_30 extends StatelessProtocol<ClientboundPackets
|
||||
}
|
||||
|
||||
wrapper.write(Typesc0_30.POSITION, pos); // position
|
||||
wrapper.write(Type.BOOLEAN, true); // place block
|
||||
wrapper.write(Type.BYTE, classicBlock); // block id
|
||||
wrapper.write(Types.BOOLEAN, true); // place block
|
||||
wrapper.write(Types.BYTE, classicBlock); // block id
|
||||
});
|
||||
this.cancelServerbound(ServerboundPacketsa1_0_15.KEEP_ALIVE);
|
||||
this.cancelServerbound(ServerboundPacketsa1_0_15.HELD_ITEM_CHANGE);
|
||||
this.cancelServerbound(ServerboundPacketsa1_0_15.ANIMATION);
|
||||
this.cancelServerbound(ServerboundPacketsa1_0_15.SET_CARRIED_ITEM);
|
||||
this.cancelServerbound(ServerboundPacketsa1_0_15.SWING);
|
||||
this.cancelServerbound(ServerboundPacketsa1_0_15.SPAWN_ITEM);
|
||||
this.cancelServerbound(ServerboundPacketsa1_0_15.DISCONNECT);
|
||||
}
|
||||
|
||||
private void sendChatMessage(final UserConnection user, final String msg) throws Exception {
|
||||
final PacketWrapper message = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT_MESSAGE, user);
|
||||
private void sendChatMessage(final UserConnection user, final String msg) {
|
||||
final PacketWrapper message = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT, user);
|
||||
message.write(Typesb1_7_0_3.STRING, msg); // message
|
||||
message.send(Protocola1_0_15toc0_30.class);
|
||||
}
|
||||
|
||||
private void sendBlockChange(final UserConnection user, final Position pos, final IdAndData block) throws Exception {
|
||||
final PacketWrapper blockChange = PacketWrapper.create(ClientboundPacketsa1_0_15.BLOCK_CHANGE, user);
|
||||
private void sendBlockChange(final UserConnection user, final Position pos, final IdAndData block) {
|
||||
final PacketWrapper blockChange = PacketWrapper.create(ClientboundPacketsa1_0_15.BLOCK_UPDATE, user);
|
||||
blockChange.write(Types1_7_6.POSITION_UBYTE, pos); // position
|
||||
blockChange.write(Type.UNSIGNED_BYTE, (short) block.getId()); // block id
|
||||
blockChange.write(Type.UNSIGNED_BYTE, (short) block.getData()); // block data
|
||||
blockChange.write(Types.UNSIGNED_BYTE, (short) block.getId()); // block id
|
||||
blockChange.write(Types.UNSIGNED_BYTE, (short) block.getData()); // block data
|
||||
blockChange.send(Protocola1_0_15toc0_30.class);
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,9 @@ import java.util.function.BiConsumer;
|
||||
public enum ServerboundPacketsc0_28 implements ServerboundPacketType, PreNettyPacketType {
|
||||
|
||||
LOGIN(0, (user, buf) -> buf.skipBytes(130)),
|
||||
PLAYER_BLOCK_PLACEMENT(5, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_POSITION_AND_ROTATION(8, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT_MESSAGE(13, (user, buf) -> buf.skipBytes(65));
|
||||
USE_ITEM_ON(5, (user, buf) -> buf.skipBytes(8)),
|
||||
MOVE_PLAYER_POS_ROT(8, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(13, (user, buf) -> buf.skipBytes(65));
|
||||
|
||||
private static final ServerboundPacketsc0_28[] REGISTRY = new ServerboundPacketsc0_28[256];
|
||||
|
||||
|
@ -30,8 +30,8 @@ public class ClassicCustomCommandProvider implements Provider {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void sendFeedback(final UserConnection user, final String message) throws Exception {
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT_MESSAGE, user);
|
||||
public void sendFeedback(final UserConnection user, final String message) {
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT, user);
|
||||
chatMessage.write(Typesb1_7_0_3.STRING, message); // message
|
||||
chatMessage.send(Protocola1_0_15toc0_30.class);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class ClassicLevelStorage extends StoredObject {
|
||||
this.netBuffer.write(part, 0, partSize);
|
||||
}
|
||||
|
||||
public void finish(final int sizeX, final int sizeY, final int sizeZ) throws Exception {
|
||||
public void finish(final int sizeX, final int sizeY, final int sizeZ) {
|
||||
try {
|
||||
final DataInputStream dis = new DataInputStream(new GZIPInputStream(new ByteArrayInputStream(this.netBuffer.toByteArray()), 64 * 1024));
|
||||
final byte[] blocks = new byte[dis.readInt()];
|
||||
@ -103,7 +103,7 @@ public class ClassicLevelStorage extends StoredObject {
|
||||
if (chunkX < 0 || chunkX >= this.chunkXCount || chunkZ < 0 || chunkZ >= this.chunkZCount) {
|
||||
final Chunk chunk = ChunkUtil.createEmptyChunk(chunkX, chunkZ, Math.max(8, this.sectionYCount), this.sectionBitmask);
|
||||
ChunkUtil.setDummySkylight(chunk, true);
|
||||
final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.CHUNK_DATA, this.getUser());
|
||||
final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.getUser());
|
||||
chunkData.write(Types1_1.CHUNK, chunk);
|
||||
chunkData.send(Protocola1_0_15toc0_30.class);
|
||||
}
|
||||
@ -112,7 +112,7 @@ public class ClassicLevelStorage extends StoredObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void tick() throws Exception {
|
||||
public void tick() {
|
||||
final ClassicPositionTracker positionTracker = this.getUser().get(ClassicPositionTracker.class);
|
||||
if (!positionTracker.spawned) return;
|
||||
|
||||
@ -136,11 +136,11 @@ public class ClassicLevelStorage extends StoredObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendChunks(final ChunkCoord center, final int radius) throws Exception {
|
||||
public void sendChunks(final ChunkCoord center, final int radius) {
|
||||
this.sendChunks(center, radius, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void sendChunks(final ChunkCoord center, final int radius, int limit) throws Exception {
|
||||
public void sendChunks(final ChunkCoord center, final int radius, int limit) {
|
||||
final ChunkCoordSpiral spiral = new ChunkCoordSpiral(center, new ChunkCoord(radius, radius));
|
||||
for (ChunkCoord coord : spiral) {
|
||||
if (!this.shouldSend(coord)) continue;
|
||||
@ -149,7 +149,7 @@ public class ClassicLevelStorage extends StoredObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendChunk(final ChunkCoord coord) throws Exception {
|
||||
public void sendChunk(final ChunkCoord coord) {
|
||||
if (!this.shouldSend(coord)) return;
|
||||
final ClassicBlockRemapper remapper = this.getUser().get(ClassicBlockRemapper.class);
|
||||
|
||||
@ -179,7 +179,7 @@ public class ClassicLevelStorage extends StoredObject {
|
||||
this.loadedChunks.add(coord);
|
||||
|
||||
final Chunk viaChunk = new BaseChunk(coord.chunkX, coord.chunkZ, true, false, this.sectionBitmask, modernSections, new int[256], new ArrayList<>());
|
||||
final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.CHUNK_DATA, this.getUser());
|
||||
final PacketWrapper chunkData = PacketWrapper.create(ClientboundPacketsa1_0_15.LEVEL_CHUNK, this.getUser());
|
||||
chunkData.write(Types1_1.CHUNK, viaChunk);
|
||||
chunkData.send(Protocola1_0_15toc0_30.class);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ package net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storag
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_16_2toa1_0_15.ClientboundPacketsa1_0_15;
|
||||
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.types.Typesb1_7_0_3;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.Protocola1_0_15toc0_30;
|
||||
@ -49,7 +49,7 @@ public class ClassicOpLevelStorage extends StoredObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateHax(final boolean flying, final boolean noClip, final boolean speed, final boolean respawn) throws Exception {
|
||||
public void updateHax(final boolean flying, final boolean noClip, final boolean speed, final boolean respawn) {
|
||||
if (!this.haxEnabled) return;
|
||||
|
||||
boolean changed = this.flying != flying;
|
||||
@ -76,13 +76,13 @@ public class ClassicOpLevelStorage extends StoredObject {
|
||||
statusMessage += " ";
|
||||
statusMessage += this.respawn ? "§aRespawn" : "§cRespawn";
|
||||
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT_MESSAGE, this.getUser());
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsa1_0_15.CHAT, this.getUser());
|
||||
chatMessage.write(Typesb1_7_0_3.STRING, statusMessage); // message
|
||||
chatMessage.send(Protocola1_0_15toc0_30.class);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOpLevel(final byte opLevel) throws Exception {
|
||||
public void setOpLevel(final byte opLevel) {
|
||||
final boolean changed = this.opLevel != opLevel;
|
||||
this.opLevel = opLevel;
|
||||
|
||||
@ -99,13 +99,13 @@ public class ClassicOpLevelStorage extends StoredObject {
|
||||
return this.opLevel;
|
||||
}
|
||||
|
||||
public void updateAbilities() throws Exception {
|
||||
public void updateAbilities() {
|
||||
if (this.getUser().getProtocolInfo().getPipeline().contains(Protocol1_2_4_5to1_2_1_3.class)) {
|
||||
final PacketWrapper playerAbilities = PacketWrapper.create(ClientboundPackets1_2_4.PLAYER_ABILITIES, this.getUser());
|
||||
playerAbilities.write(Type.BOOLEAN, true); // invulnerable
|
||||
playerAbilities.write(Type.BOOLEAN, false); // flying
|
||||
playerAbilities.write(Type.BOOLEAN, this.flying); // allow flying
|
||||
playerAbilities.write(Type.BOOLEAN, true); // creative mode
|
||||
playerAbilities.write(Types.BOOLEAN, true); // invulnerable
|
||||
playerAbilities.write(Types.BOOLEAN, false); // flying
|
||||
playerAbilities.write(Types.BOOLEAN, this.flying); // allow flying
|
||||
playerAbilities.write(Types.BOOLEAN, true); // creative mode
|
||||
playerAbilities.scheduleSend(Protocol1_2_4_5to1_2_1_3.class);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ package net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storag
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.model.ChunkCoord;
|
||||
|
||||
public class ClassicPositionTracker implements StorableObject {
|
||||
@ -40,12 +40,12 @@ public class ClassicPositionTracker implements StorableObject {
|
||||
final int yaw = (int) (this.yaw * 256.0F / 360.0F) & 255;
|
||||
final int pitch = (int) (this.pitch * 256.0F / 360.0F) & 255;
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) -1); // entity id
|
||||
wrapper.write(Type.SHORT, (short) x); // x
|
||||
wrapper.write(Type.SHORT, (short) y); // y
|
||||
wrapper.write(Type.SHORT, (short) z); // z
|
||||
wrapper.write(Type.BYTE, (byte) (yaw - 128)); // yaw
|
||||
wrapper.write(Type.BYTE, (byte) pitch); // pitch
|
||||
wrapper.write(Types.BYTE, (byte) -1); // entity id
|
||||
wrapper.write(Types.SHORT, (short) x); // x
|
||||
wrapper.write(Types.SHORT, (short) y); // y
|
||||
wrapper.write(Types.SHORT, (short) z); // z
|
||||
wrapper.write(Types.BYTE, (byte) (yaw - 128)); // yaw
|
||||
wrapper.write(Types.BYTE, (byte) pitch); // pitch
|
||||
}
|
||||
|
||||
public Position getBlockPosition() {
|
||||
|
@ -26,13 +26,13 @@ public class ByteArrayType extends Type<byte[]> {
|
||||
super(byte[].class);
|
||||
}
|
||||
|
||||
public void write(ByteBuf buffer, byte[] array) throws Exception {
|
||||
public void write(ByteBuf buffer, byte[] array) {
|
||||
if (array.length != 1024) throw new IllegalStateException("Byte array needs to be exactly 1024 bytes long");
|
||||
|
||||
buffer.writeBytes(array);
|
||||
}
|
||||
|
||||
public byte[] read(ByteBuf buffer) throws Exception {
|
||||
public byte[] read(ByteBuf buffer) {
|
||||
final byte[] array = new byte[1024];
|
||||
buffer.readBytes(array);
|
||||
return array;
|
||||
|
@ -28,12 +28,12 @@ public class PositionType extends Type<Position> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position read(ByteBuf buffer) throws Exception {
|
||||
public Position read(ByteBuf buffer) {
|
||||
return new Position(buffer.readShort(), (int) buffer.readShort(), buffer.readShort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, Position position) throws Exception {
|
||||
public void write(ByteBuf buffer, Position position) {
|
||||
buffer.writeShort(position.x());
|
||||
buffer.writeShort(position.y());
|
||||
buffer.writeShort(position.z());
|
||||
|
@ -21,7 +21,6 @@ import com.viaversion.viaversion.api.type.Type;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.data.Cp437String;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class StringType extends Type<String> {
|
||||
@ -30,13 +29,13 @@ public class StringType extends Type<String> {
|
||||
super(String.class);
|
||||
}
|
||||
|
||||
public String read(ByteBuf buffer) throws IOException {
|
||||
public String read(ByteBuf buffer) {
|
||||
final byte[] stringBytes = new byte[64];
|
||||
buffer.readBytes(stringBytes);
|
||||
return Cp437String.fromBytes(stringBytes).trim();
|
||||
}
|
||||
|
||||
public void write(ByteBuf buffer, String s) throws IOException {
|
||||
public void write(ByteBuf buffer, String s) {
|
||||
final byte[] bytes = new byte[64];
|
||||
final byte[] stringBytes = Cp437String.toBytes(s);
|
||||
|
||||
|
@ -26,17 +26,17 @@ import java.util.function.BiConsumer;
|
||||
|
||||
public enum ClientboundPacketsc0_15a implements ClientboundPacketType, PreNettyPacketType {
|
||||
|
||||
JOIN_GAME(0, (user, buf) -> buf.skipBytes(64)),
|
||||
LOGIN(0, (user, buf) -> buf.skipBytes(64)),
|
||||
KEEP_ALIVE(1, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_INIT(2, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_DATA(3, (user, buf) -> buf.skipBytes(1027)),
|
||||
LEVEL_FINALIZE(4, (user, buf) -> buf.skipBytes(6)),
|
||||
BLOCK_CHANGE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
SPAWN_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
ENTITY_TELEPORT(8, (user, buf) -> buf.skipBytes(9)),
|
||||
DESTROY_ENTITIES(9, (user, buf) -> buf.skipBytes(1));
|
||||
BLOCK_UPDATE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
ADD_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
TELEPORT_ENTITY(8, (user, buf) -> buf.skipBytes(9)),
|
||||
REMOVE_ENTITIES(9, (user, buf) -> buf.skipBytes(1));
|
||||
|
||||
private static final ClientboundPacketsc0_15a[] REGISTRY = new ClientboundPacketsc0_15a[256];
|
||||
|
||||
|
@ -20,7 +20,7 @@ package net.raphimc.vialegacy.protocols.classic.protocolc0_0_16a_02to0_0_15a_1;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.types.Typesc0_30;
|
||||
@ -35,31 +35,31 @@ public class Protocolc0_0_16a_02to0_0_15a_1 extends StatelessProtocol<Clientboun
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsc0_15a.JOIN_GAME, wrapper -> {
|
||||
this.registerClientbound(ClientboundPacketsc0_15a.LOGIN, wrapper -> {
|
||||
final String username = wrapper.read(Typesc0_30.STRING); // username
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) 0); // protocol id
|
||||
wrapper.write(Types.BYTE, (byte) 0); // protocol id
|
||||
wrapper.write(Typesc0_30.STRING, "c0.0.15a Server"); // title
|
||||
wrapper.write(Typesc0_30.STRING, "Logged in as: " + username); // motd
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_15a.ENTITY_TELEPORT, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_15a.TELEPORT_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // entity id
|
||||
map(Type.SHORT); // x
|
||||
map(Type.SHORT); // y
|
||||
map(Type.SHORT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
map(Types.BYTE); // entity id
|
||||
map(Types.SHORT); // x
|
||||
map(Types.SHORT); // y
|
||||
map(Types.SHORT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
handler(wrapper -> {
|
||||
final byte entityId = wrapper.get(Type.BYTE, 0);
|
||||
final byte yaw = wrapper.get(Type.BYTE, 1);
|
||||
final byte pitch = wrapper.get(Type.BYTE, 2);
|
||||
final byte entityId = wrapper.get(Types.BYTE, 0);
|
||||
final byte yaw = wrapper.get(Types.BYTE, 1);
|
||||
final byte pitch = wrapper.get(Types.BYTE, 2);
|
||||
|
||||
final PacketWrapper entityRotation = PacketWrapper.create(ClientboundPacketsc0_19a.ENTITY_ROTATION, wrapper.user());
|
||||
entityRotation.write(Type.BYTE, entityId); // entity id
|
||||
entityRotation.write(Type.BYTE, yaw); // yaw
|
||||
entityRotation.write(Type.BYTE, pitch); // pitch
|
||||
final PacketWrapper entityRotation = PacketWrapper.create(ClientboundPacketsc0_19a.MOVE_ENTITY_ROT, wrapper.user());
|
||||
entityRotation.write(Types.BYTE, entityId); // entity id
|
||||
entityRotation.write(Types.BYTE, yaw); // yaw
|
||||
entityRotation.write(Types.BYTE, pitch); // pitch
|
||||
|
||||
wrapper.send(Protocolc0_0_16a_02to0_0_15a_1.class);
|
||||
entityRotation.send(Protocolc0_0_16a_02to0_0_15a_1.class);
|
||||
@ -72,7 +72,7 @@ public class Protocolc0_0_16a_02to0_0_15a_1 extends StatelessProtocol<Clientboun
|
||||
wrapper.clearPacket();
|
||||
wrapper.write(Typesc0_30.STRING, wrapper.user().getProtocolInfo().getUsername()); // username
|
||||
});
|
||||
this.cancelServerbound(ServerboundPacketsc0_19a.CHAT_MESSAGE);
|
||||
this.cancelServerbound(ServerboundPacketsc0_19a.CHAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,8 +27,8 @@ import java.util.function.BiConsumer;
|
||||
public enum ServerboundPacketsc0_15a implements ServerboundPacketType, PreNettyPacketType {
|
||||
|
||||
LOGIN(0, (user, buf) -> buf.skipBytes(64)),
|
||||
PLAYER_BLOCK_PLACEMENT(5, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_POSITION_AND_ROTATION(8, (user, buf) -> buf.skipBytes(9));
|
||||
USE_ITEM_ON(5, (user, buf) -> buf.skipBytes(8)),
|
||||
MOVE_PLAYER_POS_ROT(8, (user, buf) -> buf.skipBytes(9));
|
||||
|
||||
private static final ServerboundPacketsc0_15a[] REGISTRY = new ServerboundPacketsc0_15a[256];
|
||||
|
||||
|
@ -26,21 +26,21 @@ import java.util.function.BiConsumer;
|
||||
|
||||
public enum ClientboundPacketsc0_19a implements ClientboundPacketType, PreNettyPacketType {
|
||||
|
||||
JOIN_GAME(0, (user, buf) -> buf.skipBytes(129)),
|
||||
LOGIN(0, (user, buf) -> buf.skipBytes(129)),
|
||||
KEEP_ALIVE(1, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_INIT(2, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_DATA(3, (user, buf) -> buf.skipBytes(1027)),
|
||||
LEVEL_FINALIZE(4, (user, buf) -> buf.skipBytes(6)),
|
||||
BLOCK_CHANGE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
SPAWN_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
ENTITY_TELEPORT(8, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_POSITION_AND_ROTATION(9, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION(10, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_ROTATION(11, (user, buf) -> buf.skipBytes(3)),
|
||||
DESTROY_ENTITIES(12, (user, buf) -> buf.skipBytes(1)),
|
||||
CHAT_MESSAGE(13, (user, buf) -> buf.skipBytes(65)),
|
||||
BLOCK_UPDATE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
ADD_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
TELEPORT_ENTITY(8, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_ENTITY_POS_ROT(9, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS(10, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_ROT(11, (user, buf) -> buf.skipBytes(3)),
|
||||
REMOVE_ENTITIES(12, (user, buf) -> buf.skipBytes(1)),
|
||||
CHAT(13, (user, buf) -> buf.skipBytes(65)),
|
||||
DISCONNECT(14, (user, buf) -> buf.skipBytes(64));
|
||||
|
||||
private static final ClientboundPacketsc0_19a[] REGISTRY = new ClientboundPacketsc0_19a[256];
|
||||
|
@ -19,7 +19,7 @@ package net.raphimc.vialegacy.protocols.classic.protocolc0_0_20a_27toc0_0_19a_06
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
@ -37,23 +37,23 @@ public class Protocolc0_27toc0_0_19a_06 extends StatelessProtocol<ClientboundPac
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsc0_19a.JOIN_GAME, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPacketsc0_19a.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // protocol id
|
||||
map(Types.BYTE); // protocol id
|
||||
map(Typesc0_30.STRING); // title
|
||||
map(Typesc0_30.STRING); // motd
|
||||
create(Type.BYTE, (byte) 0); // op level
|
||||
create(Types.BYTE, (byte) 0); // op level
|
||||
}
|
||||
});
|
||||
|
||||
this.registerServerbound(ServerboundPacketsc0_28.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // protocol id
|
||||
map(Types.BYTE); // protocol id
|
||||
map(Typesc0_30.STRING); // username
|
||||
map(Typesc0_30.STRING); // mp pass
|
||||
read(Type.BYTE); // op level
|
||||
read(Types.BYTE); // op level
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ import java.util.function.BiConsumer;
|
||||
public enum ServerboundPacketsc0_19a implements ServerboundPacketType, PreNettyPacketType {
|
||||
|
||||
LOGIN(0, (user, buf) -> buf.skipBytes(129)),
|
||||
PLAYER_BLOCK_PLACEMENT(5, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_POSITION_AND_ROTATION(8, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT_MESSAGE(13, (user, buf) -> buf.skipBytes(65));
|
||||
USE_ITEM_ON(5, (user, buf) -> buf.skipBytes(8)),
|
||||
MOVE_PLAYER_POS_ROT(8, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(13, (user, buf) -> buf.skipBytes(65));
|
||||
|
||||
private static final ServerboundPacketsc0_19a[] REGISTRY = new ServerboundPacketsc0_19a[256];
|
||||
|
||||
|
@ -26,21 +26,21 @@ import java.util.function.BiConsumer;
|
||||
|
||||
public enum ClientboundPacketsc0_20a implements ClientboundPacketType, PreNettyPacketType {
|
||||
|
||||
JOIN_GAME(0, (user, buf) -> buf.skipBytes(130)),
|
||||
LOGIN(0, (user, buf) -> buf.skipBytes(130)),
|
||||
KEEP_ALIVE(1, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_INIT(2, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_DATA(3, (user, buf) -> buf.skipBytes(1027)),
|
||||
LEVEL_FINALIZE(4, (user, buf) -> buf.skipBytes(6)),
|
||||
BLOCK_CHANGE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
SPAWN_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
ENTITY_TELEPORT(8, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_POSITION_AND_ROTATION(9, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION(10, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_ROTATION(11, (user, buf) -> buf.skipBytes(3)),
|
||||
DESTROY_ENTITIES(12, (user, buf) -> buf.skipBytes(1)),
|
||||
CHAT_MESSAGE(13, (user, buf) -> buf.skipBytes(65)),
|
||||
BLOCK_UPDATE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
ADD_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
TELEPORT_ENTITY(8, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_ENTITY_POS_ROT(9, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS(10, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_ROT(11, (user, buf) -> buf.skipBytes(3)),
|
||||
REMOVE_ENTITIES(12, (user, buf) -> buf.skipBytes(1)),
|
||||
CHAT(13, (user, buf) -> buf.skipBytes(65)),
|
||||
DISCONNECT(14, (user, buf) -> buf.skipBytes(64));
|
||||
|
||||
private static final ClientboundPacketsc0_20a[] REGISTRY = new ClientboundPacketsc0_20a[256];
|
||||
|
@ -26,21 +26,21 @@ import java.util.function.BiConsumer;
|
||||
|
||||
public enum ClientboundPacketsc0_30cpe implements ClientboundPacketType, PreNettyPacketType {
|
||||
|
||||
JOIN_GAME(0, (user, buf) -> buf.skipBytes(130)),
|
||||
LOGIN(0, (user, buf) -> buf.skipBytes(130)),
|
||||
KEEP_ALIVE(1, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_INIT(2, (user, buf) -> {
|
||||
}),
|
||||
LEVEL_DATA(3, (user, buf) -> buf.skipBytes(1027)),
|
||||
LEVEL_FINALIZE(4, (user, buf) -> buf.skipBytes(6)),
|
||||
BLOCK_CHANGE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
SPAWN_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
ENTITY_TELEPORT(8, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_POSITION_AND_ROTATION(9, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION(10, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_ROTATION(11, (user, buf) -> buf.skipBytes(3)),
|
||||
DESTROY_ENTITIES(12, (user, buf) -> buf.skipBytes(1)),
|
||||
CHAT_MESSAGE(13, (user, buf) -> buf.skipBytes(65)),
|
||||
BLOCK_UPDATE(6, (user, buf) -> buf.skipBytes(7)),
|
||||
ADD_PLAYER(7, (user, buf) -> buf.skipBytes(73)),
|
||||
TELEPORT_ENTITY(8, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_ENTITY_POS_ROT(9, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS(10, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_ROT(11, (user, buf) -> buf.skipBytes(3)),
|
||||
REMOVE_ENTITIES(12, (user, buf) -> buf.skipBytes(1)),
|
||||
CHAT(13, (user, buf) -> buf.skipBytes(65)),
|
||||
DISCONNECT(14, (user, buf) -> buf.skipBytes(64)),
|
||||
OP_LEVEL_UPDATE(15, (user, buf) -> buf.skipBytes(1)),
|
||||
EXTENSION_PROTOCOL_INFO(16, (user, buf) -> buf.skipBytes(66)),
|
||||
|
@ -25,7 +25,7 @@ import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.FixedByteArrayType;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
@ -68,14 +68,14 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerClientbound(ClientboundPacketsc0_30cpe.JOIN_GAME, wrapper -> {
|
||||
this.registerClientbound(ClientboundPacketsc0_30cpe.LOGIN, wrapper -> {
|
||||
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocol1_6_2to1_6_1.class)) {
|
||||
final ExtensionProtocolMetadataStorage protocolMetadataStorage = wrapper.user().get(ExtensionProtocolMetadataStorage.class);
|
||||
final PacketWrapper brand = PacketWrapper.create(ClientboundPackets1_6_4.PLUGIN_MESSAGE, wrapper.user());
|
||||
final PacketWrapper brand = PacketWrapper.create(ClientboundPackets1_6_4.CUSTOM_PAYLOAD, wrapper.user());
|
||||
brand.write(Types1_6_4.STRING, "MC|Brand");
|
||||
final byte[] brandBytes = protocolMetadataStorage.getServerSoftwareName().getBytes(StandardCharsets.UTF_8);
|
||||
brand.write(Type.SHORT, (short) brandBytes.length); // length
|
||||
brand.write(Type.REMAINING_BYTES, brandBytes); // data
|
||||
brand.write(Types.SHORT, (short) brandBytes.length); // length
|
||||
brand.write(Types.REMAINING_BYTES, brandBytes); // data
|
||||
|
||||
wrapper.send(Protocolc0_30toc0_30cpe.class);
|
||||
brand.send(Protocol1_6_2to1_6_1.class);
|
||||
@ -86,7 +86,7 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
wrapper.cancel();
|
||||
final ExtensionProtocolMetadataStorage protocolMetadataStorage = wrapper.user().get(ExtensionProtocolMetadataStorage.class);
|
||||
protocolMetadataStorage.setServerSoftwareName(wrapper.read(Typesc0_30.STRING)); // app name
|
||||
protocolMetadataStorage.setExtensionCount(wrapper.read(Type.SHORT)); // extension count
|
||||
protocolMetadataStorage.setExtensionCount(wrapper.read(Types.SHORT)); // extension count
|
||||
|
||||
final ClassicProgressStorage classicProgressStorage = wrapper.user().get(ClassicProgressStorage.class);
|
||||
classicProgressStorage.progress = 0;
|
||||
@ -97,7 +97,7 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
wrapper.cancel();
|
||||
final ExtensionProtocolMetadataStorage protocolMetadataStorage = wrapper.user().get(ExtensionProtocolMetadataStorage.class);
|
||||
final String extensionName = wrapper.read(Typesc0_30.STRING); // name
|
||||
final int extensionVersion = wrapper.read(Type.INT); // version
|
||||
final int extensionVersion = wrapper.read(Types.INT); // version
|
||||
|
||||
final ClassicProtocolExtension extension = ClassicProtocolExtension.byName(extensionName);
|
||||
if (extension != null) {
|
||||
@ -128,45 +128,45 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
|
||||
final PacketWrapper extensionProtocolInfo = PacketWrapper.create(ServerboundPacketsc0_30cpe.EXTENSION_PROTOCOL_INFO, wrapper.user());
|
||||
extensionProtocolInfo.write(Typesc0_30.STRING, ViaLegacy.getPlatform().getCpeAppName()); // app name
|
||||
extensionProtocolInfo.write(Type.SHORT, (short) supportedExtensions.size()); // extension count
|
||||
extensionProtocolInfo.write(Types.SHORT, (short) supportedExtensions.size()); // extension count
|
||||
extensionProtocolInfo.sendToServer(Protocolc0_30toc0_30cpe.class);
|
||||
|
||||
for (ClassicProtocolExtension protocolExtension : supportedExtensions) {
|
||||
final PacketWrapper extensionProtocolEntry = PacketWrapper.create(ServerboundPacketsc0_30cpe.EXTENSION_PROTOCOL_ENTRY, wrapper.user());
|
||||
extensionProtocolEntry.write(Typesc0_30.STRING, protocolExtension.getName()); // name
|
||||
extensionProtocolEntry.write(Type.INT, protocolExtension.getHighestSupportedVersion()); // version
|
||||
extensionProtocolEntry.write(Types.INT, protocolExtension.getHighestSupportedVersion()); // version
|
||||
extensionProtocolEntry.sendToServer(Protocolc0_30toc0_30cpe.class);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_30cpe.EXT_CUSTOM_BLOCKS_SUPPORT_LEVEL, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
final byte level = wrapper.read(Type.BYTE); // support level
|
||||
final byte level = wrapper.read(Types.BYTE); // support level
|
||||
if (level != 1) {
|
||||
ViaLegacy.getPlatform().getLogger().info("Classic server supports CustomBlocks level " + level);
|
||||
}
|
||||
final PacketWrapper response = PacketWrapper.create(ServerboundPacketsc0_30cpe.EXT_CUSTOM_BLOCKS_SUPPORT_LEVEL, wrapper.user());
|
||||
response.write(Type.BYTE, (byte) 1); // support level
|
||||
response.write(Types.BYTE, (byte) 1); // support level
|
||||
response.sendToServer(Protocolc0_30toc0_30cpe.class);
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_30cpe.EXT_HACK_CONTROL, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
final ClassicOpLevelStorage opLevelStorage = wrapper.user().get(ClassicOpLevelStorage.class);
|
||||
final boolean flying = wrapper.read(Type.BOOLEAN); // flying
|
||||
final boolean noClip = wrapper.read(Type.BOOLEAN); // no clip
|
||||
final boolean speed = wrapper.read(Type.BOOLEAN); // speed
|
||||
final boolean respawn = wrapper.read(Type.BOOLEAN); // respawn key
|
||||
wrapper.read(Type.BOOLEAN); // third person view
|
||||
wrapper.read(Type.SHORT); // jump height
|
||||
final boolean flying = wrapper.read(Types.BOOLEAN); // flying
|
||||
final boolean noClip = wrapper.read(Types.BOOLEAN); // no clip
|
||||
final boolean speed = wrapper.read(Types.BOOLEAN); // speed
|
||||
final boolean respawn = wrapper.read(Types.BOOLEAN); // respawn key
|
||||
wrapper.read(Types.BOOLEAN); // third person view
|
||||
wrapper.read(Types.SHORT); // jump height
|
||||
|
||||
opLevelStorage.updateHax(flying, noClip, speed, respawn);
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_30cpe.EXT_SET_BLOCK_PERMISSION, null, wrapper -> {
|
||||
wrapper.cancel();
|
||||
final ExtBlockPermissionsStorage blockPermissionsStorage = wrapper.user().get(ExtBlockPermissionsStorage.class);
|
||||
final byte blockId = wrapper.read(Type.BYTE); // block id
|
||||
final boolean canPlace = wrapper.read(Type.BOOLEAN); // can place
|
||||
final boolean canDelete = wrapper.read(Type.BOOLEAN); // can delete
|
||||
final byte blockId = wrapper.read(Types.BYTE); // block id
|
||||
final boolean canPlace = wrapper.read(Types.BOOLEAN); // can place
|
||||
final boolean canDelete = wrapper.read(Types.BOOLEAN); // can delete
|
||||
|
||||
if (canPlace) {
|
||||
blockPermissionsStorage.addPlaceable(blockId);
|
||||
@ -188,7 +188,7 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
final ClassicBlockRemapper remapper = wrapper.user().get(ClassicBlockRemapper.class);
|
||||
final ClassicLevel level = levelStorage.getClassicLevel();
|
||||
|
||||
final int count = wrapper.read(Type.UNSIGNED_BYTE) + 1; // count
|
||||
final int count = wrapper.read(Types.UNSIGNED_BYTE) + 1; // count
|
||||
final byte[] indices = wrapper.read(new FixedByteArrayType(1024)); // indices
|
||||
final byte[] blocks = wrapper.read(new FixedByteArrayType(256)); // blocks
|
||||
|
||||
@ -205,22 +205,22 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
}
|
||||
|
||||
for (Map.Entry<ChunkCoord, List<BlockChangeRecord>> entry : records.entrySet()) {
|
||||
final PacketWrapper multiBlockChange = PacketWrapper.create(ClientboundPacketsa1_0_15.MULTI_BLOCK_CHANGE, wrapper.user());
|
||||
multiBlockChange.write(Type.INT, entry.getKey().chunkX); // chunkX
|
||||
multiBlockChange.write(Type.INT, entry.getKey().chunkZ); // chunkZ
|
||||
final PacketWrapper multiBlockChange = PacketWrapper.create(ClientboundPacketsa1_0_15.CHUNK_BLOCKS_UPDATE, wrapper.user());
|
||||
multiBlockChange.write(Types.INT, entry.getKey().chunkX); // chunkX
|
||||
multiBlockChange.write(Types.INT, entry.getKey().chunkZ); // chunkZ
|
||||
multiBlockChange.write(Types1_1.BLOCK_CHANGE_RECORD_ARRAY, entry.getValue().toArray(new BlockChangeRecord[0])); // blockChangeRecords
|
||||
multiBlockChange.send(Protocola1_0_16_2toa1_0_15.class);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPacketsc0_30cpe.EXT_TWO_WAY_PING, ClientboundPacketsc0_28.KEEP_ALIVE, wrapper -> {
|
||||
final byte direction = wrapper.read(Type.BYTE); // direction
|
||||
final short data = wrapper.read(Type.SHORT); // data
|
||||
final byte direction = wrapper.read(Types.BYTE); // direction
|
||||
final short data = wrapper.read(Types.SHORT); // data
|
||||
|
||||
if (direction == 1) {
|
||||
final PacketWrapper pingResponse = PacketWrapper.create(ServerboundPacketsc0_30cpe.EXT_TWO_WAY_PING, wrapper.user());
|
||||
pingResponse.write(Type.BYTE, direction); // direction
|
||||
pingResponse.write(Type.SHORT, data); // data
|
||||
pingResponse.write(Types.BYTE, direction); // direction
|
||||
pingResponse.write(Types.SHORT, data); // data
|
||||
pingResponse.sendToServer(Protocolc0_30toc0_30cpe.class);
|
||||
}
|
||||
});
|
||||
@ -228,19 +228,19 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
this.registerServerbound(ServerboundPacketsc0_28.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // protocol id
|
||||
map(Types.BYTE); // protocol id
|
||||
map(Typesc0_30.STRING); // username
|
||||
map(Typesc0_30.STRING); // mp pass
|
||||
map(Type.BYTE); // op level
|
||||
map(Types.BYTE); // op level
|
||||
handler(wrapper -> {
|
||||
wrapper.set(Type.BYTE, 1, (byte) 0x42); // extension protocol magic number
|
||||
wrapper.set(Types.BYTE, 1, (byte) 0x42); // extension protocol magic number
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsc0_28.CHAT_MESSAGE, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsc0_28.CHAT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // sender id
|
||||
map(Types.BYTE); // sender id
|
||||
map(Typesc0_30.STRING); // message
|
||||
handler(wrapper -> {
|
||||
final ExtensionProtocolMetadataStorage protocolMetadata = wrapper.user().get(ExtensionProtocolMetadataStorage.class);
|
||||
@ -252,20 +252,20 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
final int pos = Math.min(message.length(), 64);
|
||||
final String msg = message.substring(0, pos);
|
||||
message = message.substring(pos);
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ServerboundPacketsc0_30cpe.CHAT_MESSAGE, wrapper.user());
|
||||
chatMessage.write(Type.BYTE, (byte) (!message.isEmpty() ? 1 : 0)); // 1 = more parts | 0 = last part
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ServerboundPacketsc0_30cpe.CHAT, wrapper.user());
|
||||
chatMessage.write(Types.BYTE, (byte) (!message.isEmpty() ? 1 : 0)); // 1 = more parts | 0 = last part
|
||||
chatMessage.write(Typesc0_30.STRING, msg); // message
|
||||
chatMessage.sendToServer(Protocolc0_30toc0_30cpe.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPacketsc0_28.PLAYER_BLOCK_PLACEMENT, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPacketsc0_28.USE_ITEM_ON, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Typesc0_30.POSITION); // position
|
||||
map(Type.BOOLEAN); // place block
|
||||
map(Type.BYTE); // block id
|
||||
map(Types.BOOLEAN); // place block
|
||||
map(Types.BYTE); // block id
|
||||
handler(wrapper -> {
|
||||
if (!wrapper.user().has(ExtBlockPermissionsStorage.class)) return;
|
||||
|
||||
@ -273,16 +273,16 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
final ClassicLevel level = wrapper.user().get(ClassicLevelStorage.class).getClassicLevel();
|
||||
|
||||
final Position position = wrapper.get(Typesc0_30.POSITION, 0);
|
||||
final boolean placeBlock = wrapper.get(Type.BOOLEAN, 0);
|
||||
final int blockId = wrapper.get(Type.BYTE, 0);
|
||||
final boolean placeBlock = wrapper.get(Types.BOOLEAN, 0);
|
||||
final int blockId = wrapper.get(Types.BYTE, 0);
|
||||
|
||||
int block = level.getBlock(position);
|
||||
final boolean disallow = (placeBlock && blockPermissions.isPlacingDenied(blockId)) || (!placeBlock && blockPermissions.isBreakingDenied(block));
|
||||
|
||||
if (disallow) {
|
||||
wrapper.cancel();
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsc0_30cpe.CHAT_MESSAGE, wrapper.user());
|
||||
chatMessage.write(Type.BYTE, (byte) 0); // sender id
|
||||
final PacketWrapper chatMessage = PacketWrapper.create(ClientboundPacketsc0_30cpe.CHAT, wrapper.user());
|
||||
chatMessage.write(Types.BYTE, (byte) 0); // sender id
|
||||
chatMessage.write(Typesc0_30.STRING, "&cYou are not allowed to place/break this block"); // message
|
||||
chatMessage.send(Protocolc0_30toc0_30cpe.class);
|
||||
} else {
|
||||
@ -290,9 +290,9 @@ public class Protocolc0_30toc0_30cpe extends StatelessProtocol<ClientboundPacket
|
||||
level.setBlock(position, block);
|
||||
}
|
||||
|
||||
final PacketWrapper blockChange = PacketWrapper.create(ClientboundPacketsc0_30cpe.BLOCK_CHANGE, wrapper.user());
|
||||
final PacketWrapper blockChange = PacketWrapper.create(ClientboundPacketsc0_30cpe.BLOCK_UPDATE, wrapper.user());
|
||||
blockChange.write(Typesc0_30.POSITION, position); // position
|
||||
blockChange.write(Type.BYTE, (byte) block); // block id
|
||||
blockChange.write(Types.BYTE, (byte) block); // block id
|
||||
blockChange.send(Protocolc0_30toc0_30cpe.class);
|
||||
});
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ import java.util.function.BiConsumer;
|
||||
public enum ServerboundPacketsc0_30cpe implements ServerboundPacketType, PreNettyPacketType {
|
||||
|
||||
LOGIN(0, (user, buf) -> buf.skipBytes(130)),
|
||||
PLAYER_BLOCK_PLACEMENT(5, (user, buf) -> buf.skipBytes(8)),
|
||||
PLAYER_POSITION_AND_ROTATION(8, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT_MESSAGE(13, (user, buf) -> buf.skipBytes(65)),
|
||||
USE_ITEM_ON(5, (user, buf) -> buf.skipBytes(8)),
|
||||
MOVE_PLAYER_POS_ROT(8, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(13, (user, buf) -> buf.skipBytes(65)),
|
||||
EXTENSION_PROTOCOL_INFO(16, (user, buf) -> buf.skipBytes(66)),
|
||||
EXTENSION_PROTOCOL_ENTRY(17, (user, buf) -> buf.skipBytes(68)),
|
||||
EXT_CUSTOM_BLOCKS_SUPPORT_LEVEL(19, (user, buf) -> buf.skipBytes(1)),
|
||||
|
@ -20,7 +20,7 @@ package net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.ta
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.Protocolc0_30toc0_30cpe;
|
||||
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.ServerboundPacketsc0_30cpe;
|
||||
@ -43,8 +43,8 @@ public class ClassicPingTask implements Runnable {
|
||||
|
||||
try {
|
||||
final PacketWrapper pingRequest = PacketWrapper.create(ServerboundPacketsc0_30cpe.EXT_TWO_WAY_PING, info);
|
||||
pingRequest.write(Type.BYTE, (byte) 0); // direction
|
||||
pingRequest.write(Type.SHORT, (short) (ThreadLocalRandom.current().nextInt() % Short.MAX_VALUE)); // data
|
||||
pingRequest.write(Types.BYTE, (byte) 0); // direction
|
||||
pingRequest.write(Types.SHORT, (short) (ThreadLocalRandom.current().nextInt() % Short.MAX_VALUE)); // data
|
||||
pingRequest.sendToServer(Protocolc0_30toc0_30cpe.class);
|
||||
} catch (Throwable e) {
|
||||
ViaLegacy.getPlatform().getLogger().log(Level.WARNING, "Error sending TwoWayPing extension ping packet", e);
|
||||
|
@ -29,107 +29,107 @@ import static net.raphimc.vialegacy.api.splitter.PreNettyTypes.*;
|
||||
public enum ClientboundPackets1_0 implements ClientboundPacketType, PreNettyPacketType {
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> buf.skipBytes(4)),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(8)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(8)),
|
||||
RESPAWN(9, (user, buf) -> buf.skipBytes(13)),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
USE_BED(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
PLAYER_SLEEP(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(24)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> {
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> {
|
||||
buf.skipBytes(17);
|
||||
int i = buf.readInt();
|
||||
if (i > 0) {
|
||||
buf.skipBytes(6);
|
||||
}
|
||||
}),
|
||||
SPAWN_MOB(24, (user, buf) -> {
|
||||
ADD_MOB(24, (user, buf) -> {
|
||||
buf.skipBytes(19);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
SPAWN_PAINTING(25, (user, buf) -> {
|
||||
ADD_PAINTING(25, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_EXPERIENCE_ORB(26, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_METADATA(40, (user, buf) -> {
|
||||
ADD_EXPERIENCE_ORB(26, (user, buf) -> buf.skipBytes(18)),
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_ENTITY_DATA(40, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
ENTITY_EFFECT(41, (user, buf) -> buf.skipBytes(8)),
|
||||
REMOVE_ENTITY_EFFECT(42, (user, buf) -> buf.skipBytes(5)),
|
||||
UPDATE_MOB_EFFECT(41, (user, buf) -> buf.skipBytes(8)),
|
||||
REMOVE_MOB_EFFECT(42, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_EXPERIENCE(43, (user, buf) -> buf.skipBytes(8)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ACTION(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_EVENT(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
buf.skipBytes(3);
|
||||
}
|
||||
}),
|
||||
EFFECT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
LEVEL_EVENT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
GAME_EVENT(70, (user, buf) -> buf.skipBytes(2)),
|
||||
SPAWN_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
ADD_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readString(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStack1_0(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CREATIVE_INVENTORY_ACTION(107, (user, buf) -> {
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SET_CREATIVE_MODE_SLOT(107, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
@ -140,12 +140,12 @@ public enum ClientboundPackets1_0 implements ClientboundPacketType, PreNettyPack
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
}),
|
||||
MAP_DATA(131, (user, buf) -> {
|
||||
MAP_ITEM_DATA(131, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
short x = buf.readUnsignedByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
STATISTICS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
AWARD_STATS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_INFO(201, (user, buf) -> {
|
||||
readString(buf);
|
||||
buf.skipBytes(3);
|
||||
|
@ -19,9 +19,8 @@ package net.raphimc.vialegacy.protocols.release.protocol1_1to1_0_0_1;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_1to1_0_0_1.rewriter.ChatFilter;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_1to1_0_0_1.rewriter.ItemRewriter;
|
||||
@ -32,7 +31,7 @@ import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types
|
||||
|
||||
public class Protocol1_1to1_0_0_1 extends StatelessProtocol<ClientboundPackets1_0, ClientboundPackets1_1, ServerboundPackets1_0, ServerboundPackets1_1> {
|
||||
|
||||
private final LegacyItemRewriter<Protocol1_1to1_0_0_1> itemRewriter = new ItemRewriter(this);
|
||||
private final ItemRewriter itemRewriter = new ItemRewriter(this);
|
||||
|
||||
public Protocol1_1to1_0_0_1() {
|
||||
super(ClientboundPackets1_0.class, ClientboundPackets1_1.class, ServerboundPackets1_0.class, ServerboundPackets1_1.class);
|
||||
@ -45,18 +44,18 @@ public class Protocol1_1to1_0_0_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
this.registerServerbound(ServerboundPackets1_1.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // protocol id
|
||||
map(Types.INT); // protocol id
|
||||
map(Types1_6_4.STRING); // username
|
||||
map(Type.LONG); // seed
|
||||
map(Types.LONG); // seed
|
||||
read(Types1_6_4.STRING); // level type
|
||||
map(Type.INT); // game mode
|
||||
map(Type.BYTE); // dimension id
|
||||
map(Type.BYTE); // difficulty
|
||||
map(Type.BYTE); // world height
|
||||
map(Type.BYTE); // max players
|
||||
map(Types.INT); // game mode
|
||||
map(Types.BYTE); // dimension id
|
||||
map(Types.BYTE); // difficulty
|
||||
map(Types.BYTE); // world height
|
||||
map(Types.BYTE); // max players
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPackets1_1.CHAT_MESSAGE, new PacketHandlers() {
|
||||
this.registerServerbound(ServerboundPackets1_1.CHAT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_6_4.STRING, Types1_6_4.STRING, ChatFilter::filter); // message
|
||||
@ -65,31 +64,31 @@ public class Protocol1_1to1_0_0_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
this.registerServerbound(ServerboundPackets1_1.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // dimension id
|
||||
map(Type.BYTE); // difficulty
|
||||
map(Type.BYTE); // game mode
|
||||
map(Type.SHORT); // world height
|
||||
map(Type.LONG); // seed
|
||||
map(Types.BYTE); // dimension id
|
||||
map(Types.BYTE); // difficulty
|
||||
map(Types.BYTE); // game mode
|
||||
map(Types.SHORT); // world height
|
||||
map(Types.LONG); // seed
|
||||
read(Types1_6_4.STRING); // level type
|
||||
}
|
||||
});
|
||||
this.cancelServerbound(ServerboundPackets1_1.PLUGIN_MESSAGE);
|
||||
this.cancelServerbound(ServerboundPackets1_1.CUSTOM_PAYLOAD);
|
||||
|
||||
this.registerClientbound(ClientboundPackets1_0.JOIN_GAME, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_0.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Types1_6_4.STRING); // username
|
||||
map(Type.LONG); // seed
|
||||
map(Types.LONG); // seed
|
||||
create(Types1_6_4.STRING, "default_1_1"); // level type
|
||||
map(Type.INT); // game mode
|
||||
map(Type.BYTE); // dimension id
|
||||
map(Type.BYTE); // difficulty
|
||||
map(Type.BYTE); // world height
|
||||
map(Type.BYTE); // max players
|
||||
map(Types.INT); // game mode
|
||||
map(Types.BYTE); // dimension id
|
||||
map(Types.BYTE); // difficulty
|
||||
map(Types.BYTE); // world height
|
||||
map(Types.BYTE); // max players
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_0.CHAT_MESSAGE, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_0.CHAT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_6_4.STRING, Types1_6_4.STRING, msg -> msg.replace("\u00C2", "")); // message
|
||||
@ -98,11 +97,11 @@ public class Protocol1_1to1_0_0_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
this.registerClientbound(ClientboundPackets1_0.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE); // dimension id
|
||||
map(Type.BYTE); // difficulty
|
||||
map(Type.BYTE); // game mode
|
||||
map(Type.SHORT); // world height
|
||||
map(Type.LONG); // seed
|
||||
map(Types.BYTE); // dimension id
|
||||
map(Types.BYTE); // difficulty
|
||||
map(Types.BYTE); // game mode
|
||||
map(Types.SHORT); // world height
|
||||
map(Types.LONG); // seed
|
||||
create(Types1_6_4.STRING, "default_1_1"); // level type
|
||||
}
|
||||
});
|
||||
@ -132,7 +131,7 @@ public class Protocol1_1to1_0_0_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
}
|
||||
|
||||
@Override
|
||||
public LegacyItemRewriter<Protocol1_1to1_0_0_1> getItemRewriter() {
|
||||
public ItemRewriter getItemRewriter() {
|
||||
return this.itemRewriter;
|
||||
}
|
||||
|
||||
|
@ -36,34 +36,34 @@ public enum ServerboundPackets1_0 implements ServerboundPacketType, PreNettyPack
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(9)),
|
||||
RESPAWN(9, (user, buf) -> buf.skipBytes(13)),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> {
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(2)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ACTION(19, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(2)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_COMMAND(19, (user, buf) -> buf.skipBytes(5)),
|
||||
POSITION(27, (user, buf) -> buf.skipBytes(18)),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CLICK_WINDOW(102, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_CLICK(102, (user, buf) -> {
|
||||
buf.skipBytes(7);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CREATIVE_INVENTORY_ACTION(107, (user, buf) -> {
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SET_CREATIVE_MODE_SLOT(107, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
CLICK_WINDOW_BUTTON(108, (user, buf) -> buf.skipBytes(2)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
CONTAINER_BUTTON_CLICK(108, (user, buf) -> buf.skipBytes(2)),
|
||||
SIGN_UPDATE(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
|
@ -18,11 +18,12 @@
|
||||
package net.raphimc.vialegacy.protocols.release.protocol1_1to1_0_0_1.rewriter;
|
||||
|
||||
import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_1to1_0_0_1.ClientboundPackets1_0;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_1to1_0_0_1.Protocol1_1to1_0_0_1;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.ServerboundPackets1_1;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.types.Types1_2_4;
|
||||
|
||||
public class ItemRewriter extends LegacyItemRewriter<Protocol1_1to1_0_0_1> {
|
||||
public class ItemRewriter extends LegacyItemRewriter<ClientboundPackets1_0, ServerboundPackets1_1, Protocol1_1to1_0_0_1> {
|
||||
|
||||
public ItemRewriter(final Protocol1_1to1_0_0_1 protocol) {
|
||||
super(protocol, "1.0", Types1_2_4.NBT_ITEM, Types1_2_4.NBT_ITEM_ARRAY);
|
||||
@ -32,7 +33,7 @@ public class ItemRewriter extends LegacyItemRewriter<Protocol1_1to1_0_0_1> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerCreativeInventoryAction(ServerboundPackets1_1.CREATIVE_INVENTORY_ACTION);
|
||||
this.registerCreativeInventoryAction(ServerboundPackets1_1.SET_CREATIVE_MODE_SLOT);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import java.util.function.BiConsumer;
|
||||
public enum ClientboundPackets1_1 implements ClientboundPacketType, PreNettyPacketType {
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> buf.skipBytes(4)),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readString(buf);
|
||||
buf.skipBytes(8);
|
||||
@ -36,104 +36,104 @@ public enum ClientboundPackets1_1 implements ClientboundPacketType, PreNettyPack
|
||||
buf.skipBytes(8);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> PreNettyTypes.readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> PreNettyTypes.readString(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(8)),
|
||||
CHAT(3, (user, buf) -> PreNettyTypes.readString(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(8)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
PreNettyTypes.readString(buf);
|
||||
}),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
USE_BED(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
PLAYER_SLEEP(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(24)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> {
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> {
|
||||
buf.skipBytes(17);
|
||||
int i = buf.readInt();
|
||||
if (i > 0) {
|
||||
buf.skipBytes(6);
|
||||
}
|
||||
}),
|
||||
SPAWN_MOB(24, (user, buf) -> {
|
||||
ADD_MOB(24, (user, buf) -> {
|
||||
buf.skipBytes(19);
|
||||
PreNettyTypes.readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
SPAWN_PAINTING(25, (user, buf) -> {
|
||||
ADD_PAINTING(25, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_EXPERIENCE_ORB(26, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_METADATA(40, (user, buf) -> {
|
||||
ADD_EXPERIENCE_ORB(26, (user, buf) -> buf.skipBytes(18)),
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_ENTITY_DATA(40, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
PreNettyTypes.readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
ENTITY_EFFECT(41, (user, buf) -> buf.skipBytes(8)),
|
||||
REMOVE_ENTITY_EFFECT(42, (user, buf) -> buf.skipBytes(5)),
|
||||
UPDATE_MOB_EFFECT(41, (user, buf) -> buf.skipBytes(8)),
|
||||
REMOVE_MOB_EFFECT(42, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_EXPERIENCE(43, (user, buf) -> buf.skipBytes(8)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
short x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readShort();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ACTION(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_EVENT(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
buf.skipBytes(3);
|
||||
}
|
||||
}),
|
||||
EFFECT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
LEVEL_EVENT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
GAME_EVENT(70, (user, buf) -> buf.skipBytes(2)),
|
||||
SPAWN_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
ADD_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
PreNettyTypes.readString(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
PreNettyTypes.readItemStack1_0(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) PreNettyTypes.readItemStack1_0(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CREATIVE_INVENTORY_ACTION(107, (user, buf) -> {
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SET_CREATIVE_MODE_SLOT(107, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
PreNettyTypes.readItemStack1_0(buf);
|
||||
}),
|
||||
@ -144,17 +144,17 @@ public enum ClientboundPackets1_1 implements ClientboundPacketType, PreNettyPack
|
||||
PreNettyTypes.readString(buf);
|
||||
PreNettyTypes.readString(buf);
|
||||
}),
|
||||
MAP_DATA(131, (user, buf) -> {
|
||||
MAP_ITEM_DATA(131, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
short x = buf.readUnsignedByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
STATISTICS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
AWARD_STATS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_INFO(201, (user, buf) -> {
|
||||
PreNettyTypes.readString(buf);
|
||||
buf.skipBytes(3);
|
||||
}),
|
||||
PLUGIN_MESSAGE(250, (user, buf) -> {
|
||||
CUSTOM_PAYLOAD(250, (user, buf) -> {
|
||||
PreNettyTypes.readString(buf);
|
||||
short s = buf.readShort();
|
||||
for (int i = 0; i < s; i++) buf.readByte();
|
||||
|
@ -27,12 +27,11 @@ import com.viaversion.viaversion.api.minecraft.chunks.NibbleArray;
|
||||
import com.viaversion.viaversion.api.platform.providers.ViaProviders;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
|
||||
import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter;
|
||||
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.biome.EndBiomeGenerator;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.biome.NetherBiomeGenerator;
|
||||
@ -59,7 +58,7 @@ import java.util.Arrays;
|
||||
|
||||
public class Protocol1_2_1_3to1_1 extends StatelessProtocol<ClientboundPackets1_1, ClientboundPackets1_2_1, ServerboundPackets1_1, ServerboundPackets1_2_1> {
|
||||
|
||||
private final LegacyItemRewriter<Protocol1_2_1_3to1_1> itemRewriter = new ItemRewriter(this);
|
||||
private final ItemRewriter itemRewriter = new ItemRewriter(this);
|
||||
|
||||
public Protocol1_2_1_3to1_1() {
|
||||
super(ClientboundPackets1_1.class, ClientboundPackets1_2_1.class, ServerboundPackets1_1.class, ServerboundPackets1_2_1.class);
|
||||
@ -69,81 +68,81 @@ public class Protocol1_2_1_3to1_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
protected void registerPackets() {
|
||||
this.itemRewriter.register();
|
||||
|
||||
this.registerClientbound(ClientboundPackets1_1.JOIN_GAME, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_1.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Types.INT); // entity id
|
||||
map(Types1_6_4.STRING); // username
|
||||
handler(wrapper -> wrapper.user().get(SeedStorage.class).seed = wrapper.read(Type.LONG)); // seed
|
||||
handler(wrapper -> wrapper.user().get(SeedStorage.class).seed = wrapper.read(Types.LONG)); // seed
|
||||
map(Types1_6_4.STRING); // level type
|
||||
map(Type.INT); // game mode
|
||||
map(Type.BYTE, Type.INT); // dimension id
|
||||
map(Type.BYTE); // difficulty
|
||||
map(Type.BYTE); // world height
|
||||
map(Type.BYTE); // max players
|
||||
handler(wrapper -> handleRespawn(wrapper.get(Type.INT, 2), wrapper.user()));
|
||||
map(Types.INT); // game mode
|
||||
map(Types.BYTE, Types.INT); // dimension id
|
||||
map(Types.BYTE); // difficulty
|
||||
map(Types.BYTE); // world height
|
||||
map(Types.BYTE); // max players
|
||||
handler(wrapper -> handleRespawn(wrapper.get(Types.INT, 2), wrapper.user()));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.BYTE, Type.INT); // dimension id
|
||||
map(Type.BYTE); // difficulty
|
||||
map(Type.BYTE); // game mode
|
||||
map(Type.SHORT); // world height
|
||||
handler(wrapper -> wrapper.user().get(SeedStorage.class).seed = wrapper.read(Type.LONG)); // seed
|
||||
map(Types.BYTE, Types.INT); // dimension id
|
||||
map(Types.BYTE); // difficulty
|
||||
map(Types.BYTE); // game mode
|
||||
map(Types.SHORT); // world height
|
||||
handler(wrapper -> wrapper.user().get(SeedStorage.class).seed = wrapper.read(Types.LONG)); // seed
|
||||
map(Types1_6_4.STRING); // level type
|
||||
handler(wrapper -> handleRespawn(wrapper.get(Type.INT, 0), wrapper.user()));
|
||||
handler(wrapper -> handleRespawn(wrapper.get(Types.INT, 0), wrapper.user()));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.SPAWN_MOB, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_1.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.UNSIGNED_BYTE); // type id
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
handler(wrapper -> wrapper.write(Type.BYTE, wrapper.get(Type.BYTE, 0))); // head yaw
|
||||
map(Types.INT); // entity id
|
||||
map(Types.UNSIGNED_BYTE); // type id
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
handler(wrapper -> wrapper.write(Types.BYTE, wrapper.get(Types.BYTE, 0))); // head yaw
|
||||
map(Types1_3_1.METADATA_LIST); // metadata
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.ENTITY_ROTATION, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_1.MOVE_ENTITY_ROT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
handler(wrapper -> sendEntityHeadLook(wrapper.get(Type.INT, 0), wrapper.get(Type.BYTE, 0), wrapper));
|
||||
map(Types.INT); // entity id
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
handler(wrapper -> sendEntityHeadLook(wrapper.get(Types.INT, 0), wrapper.get(Types.BYTE, 0), wrapper));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.ENTITY_POSITION_AND_ROTATION, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_1.MOVE_ENTITY_POS_ROT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.BYTE); // x
|
||||
map(Type.BYTE); // y
|
||||
map(Type.BYTE); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
handler(wrapper -> sendEntityHeadLook(wrapper.get(Type.INT, 0), wrapper.get(Type.BYTE, 3), wrapper));
|
||||
map(Types.INT); // entity id
|
||||
map(Types.BYTE); // x
|
||||
map(Types.BYTE); // y
|
||||
map(Types.BYTE); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
handler(wrapper -> sendEntityHeadLook(wrapper.get(Types.INT, 0), wrapper.get(Types.BYTE, 3), wrapper));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.ENTITY_TELEPORT, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_1.TELEPORT_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // entity id
|
||||
map(Type.INT); // x
|
||||
map(Type.INT); // y
|
||||
map(Type.INT); // z
|
||||
map(Type.BYTE); // yaw
|
||||
map(Type.BYTE); // pitch
|
||||
handler(wrapper -> sendEntityHeadLook(wrapper.get(Type.INT, 0), wrapper.get(Type.BYTE, 0), wrapper));
|
||||
map(Types.INT); // entity id
|
||||
map(Types.INT); // x
|
||||
map(Types.INT); // y
|
||||
map(Types.INT); // z
|
||||
map(Types.BYTE); // yaw
|
||||
map(Types.BYTE); // pitch
|
||||
handler(wrapper -> sendEntityHeadLook(wrapper.get(Types.INT, 0), wrapper.get(Types.BYTE, 0), wrapper));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.CHUNK_DATA, wrapper -> {
|
||||
this.registerClientbound(ClientboundPackets1_1.LEVEL_CHUNK, wrapper -> {
|
||||
final ChunkTracker chunkTracker = wrapper.user().get(ChunkTracker.class);
|
||||
final SeedStorage seedStorage = wrapper.user().get(SeedStorage.class);
|
||||
final PendingBlocksTracker pendingBlocksTracker = wrapper.user().get(PendingBlocksTracker.class);
|
||||
@ -156,9 +155,9 @@ public class Protocol1_2_1_3to1_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
}
|
||||
|
||||
final NonFullChunk1_1 nfc = (NonFullChunk1_1) chunk;
|
||||
wrapper.setPacketType(ClientboundPackets1_2_1.MULTI_BLOCK_CHANGE);
|
||||
wrapper.write(Type.INT, nfc.getX());
|
||||
wrapper.write(Type.INT, nfc.getZ());
|
||||
wrapper.setPacketType(ClientboundPackets1_2_1.CHUNK_BLOCKS_UPDATE);
|
||||
wrapper.write(Types.INT, nfc.getX());
|
||||
wrapper.write(Types.INT, nfc.getZ());
|
||||
wrapper.write(Types1_7_6.BLOCK_CHANGE_RECORD_ARRAY, nfc.asBlockChangeRecords().toArray(new BlockChangeRecord[0]));
|
||||
|
||||
pendingBlocksTracker.markReceived(new Position((nfc.getX() << 4) + nfc.getStartPos().x(), nfc.getStartPos().y(), (nfc.getZ() << 4) + nfc.getStartPos().z()), new Position((nfc.getX() << 4) + nfc.getEndPos().x() - 1, nfc.getEndPos().y() - 1, (nfc.getZ() << 4) + nfc.getEndPos().z() - 1));
|
||||
@ -206,16 +205,16 @@ public class Protocol1_2_1_3to1_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
|
||||
wrapper.write(Types1_2_4.CHUNK, chunk);
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.MULTI_BLOCK_CHANGE, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_1.CHUNK_BLOCKS_UPDATE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // chunkX
|
||||
map(Type.INT); // chunkZ
|
||||
map(Types.INT); // chunkX
|
||||
map(Types.INT); // chunkZ
|
||||
map(Types1_1.BLOCK_CHANGE_RECORD_ARRAY, Types1_7_6.BLOCK_CHANGE_RECORD_ARRAY); // blockChangeRecords
|
||||
handler(wrapper -> {
|
||||
final PendingBlocksTracker pendingBlocksTracker = wrapper.user().get(PendingBlocksTracker.class);
|
||||
final int chunkX = wrapper.get(Type.INT, 0);
|
||||
final int chunkZ = wrapper.get(Type.INT, 1);
|
||||
final int chunkX = wrapper.get(Types.INT, 0);
|
||||
final int chunkZ = wrapper.get(Types.INT, 1);
|
||||
final BlockChangeRecord[] blockChangeRecords = wrapper.get(Types1_7_6.BLOCK_CHANGE_RECORD_ARRAY, 0);
|
||||
for (BlockChangeRecord record : blockChangeRecords) {
|
||||
final int targetX = record.getSectionX() + (chunkX << 4);
|
||||
@ -226,32 +225,32 @@ public class Protocol1_2_1_3to1_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.BLOCK_CHANGE, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_1.BLOCK_UPDATE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.UNSIGNED_BYTE); // block id
|
||||
map(Type.UNSIGNED_BYTE); // block data
|
||||
map(Types.UNSIGNED_BYTE); // block id
|
||||
map(Types.UNSIGNED_BYTE); // block data
|
||||
handler(wrapper -> wrapper.user().get(PendingBlocksTracker.class).markReceived(wrapper.get(Types1_7_6.POSITION_UBYTE, 0)));
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.EXPLOSION, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_1.EXPLODE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.DOUBLE); // x
|
||||
map(Type.DOUBLE); // y
|
||||
map(Type.DOUBLE); // z
|
||||
map(Type.FLOAT); // radius
|
||||
map(Type.INT); // record count
|
||||
map(Types.DOUBLE); // x
|
||||
map(Types.DOUBLE); // y
|
||||
map(Types.DOUBLE); // z
|
||||
map(Types.FLOAT); // radius
|
||||
map(Types.INT); // record count
|
||||
handler(wrapper -> {
|
||||
final PendingBlocksTracker pendingBlocksTracker = wrapper.user().get(PendingBlocksTracker.class);
|
||||
final ChunkTracker chunkTracker = wrapper.user().get(ChunkTracker.class);
|
||||
final int x = wrapper.get(Type.DOUBLE, 0).intValue();
|
||||
final int y = wrapper.get(Type.DOUBLE, 1).intValue();
|
||||
final int z = wrapper.get(Type.DOUBLE, 2).intValue();
|
||||
final int recordCount = wrapper.get(Type.INT, 0);
|
||||
final int x = wrapper.get(Types.DOUBLE, 0).intValue();
|
||||
final int y = wrapper.get(Types.DOUBLE, 1).intValue();
|
||||
final int z = wrapper.get(Types.DOUBLE, 2).intValue();
|
||||
final int recordCount = wrapper.get(Types.INT, 0);
|
||||
for (int i = 0; i < recordCount; i++) {
|
||||
final Position pos = new Position(x + wrapper.passthrough(Type.BYTE), y + wrapper.passthrough(Type.BYTE), z + wrapper.passthrough(Type.BYTE));
|
||||
final Position pos = new Position(x + wrapper.passthrough(Types.BYTE), y + wrapper.passthrough(Types.BYTE), z + wrapper.passthrough(Types.BYTE));
|
||||
final IdAndData block = chunkTracker.getBlockNotNull(pos);
|
||||
if (block.getId() != 0) {
|
||||
pendingBlocksTracker.addPending(pos, block);
|
||||
@ -260,21 +259,21 @@ public class Protocol1_2_1_3to1_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
});
|
||||
}
|
||||
});
|
||||
this.registerClientbound(ClientboundPackets1_1.EFFECT, new PacketHandlers() {
|
||||
this.registerClientbound(ClientboundPackets1_1.LEVEL_EVENT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // effect id
|
||||
map(Types.INT); // effect id
|
||||
map(Types1_7_6.POSITION_UBYTE); // position
|
||||
map(Type.INT); // data
|
||||
map(Types.INT); // data
|
||||
handler(wrapper -> {
|
||||
final int sfxId = wrapper.get(Type.INT, 0);
|
||||
final int sfxData = wrapper.get(Type.INT, 1);
|
||||
final int sfxId = wrapper.get(Types.INT, 0);
|
||||
final int sfxData = wrapper.get(Types.INT, 1);
|
||||
if (sfxId == 2001) { // Block Break effect
|
||||
final int blockID = sfxData & 255;
|
||||
final int blockData = sfxData >> 8 & 255;
|
||||
wrapper.set(Type.INT, 1, blockID + (blockData << 12));
|
||||
wrapper.set(Types.INT, 1, blockID + (blockData << 12));
|
||||
} else if (sfxId == 1009) { // Ghast fireball effect (volume 1) (sound packet would be a better replacement but changing the id is easier and the difference is minimal)
|
||||
wrapper.set(Type.INT, 0, 1008); // Ghast fireball effect (volume 10)
|
||||
wrapper.set(Types.INT, 0, 1008); // Ghast fireball effect (volume 10)
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -289,25 +288,25 @@ public class Protocol1_2_1_3to1_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
this.registerServerbound(ServerboundPackets1_2_1.LOGIN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT); // protocol id
|
||||
map(Types.INT); // protocol id
|
||||
map(Types1_6_4.STRING); // username
|
||||
create(Type.LONG, 0L); // seed
|
||||
create(Types.LONG, 0L); // seed
|
||||
map(Types1_6_4.STRING); // level type
|
||||
map(Type.INT); // game mode
|
||||
map(Type.INT, Type.BYTE); // dimension id
|
||||
map(Type.BYTE); // difficulty
|
||||
map(Type.BYTE); // world height
|
||||
map(Type.BYTE); // max players
|
||||
map(Types.INT); // game mode
|
||||
map(Types.INT, Types.BYTE); // dimension id
|
||||
map(Types.BYTE); // difficulty
|
||||
map(Types.BYTE); // world height
|
||||
map(Types.BYTE); // max players
|
||||
}
|
||||
});
|
||||
this.registerServerbound(ServerboundPackets1_2_1.RESPAWN, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.INT, Type.BYTE); // dimension id
|
||||
map(Type.BYTE); // difficulty
|
||||
map(Type.BYTE); // game mode
|
||||
map(Type.SHORT); // world height
|
||||
create(Type.LONG, 0L); // seed
|
||||
map(Types.INT, Types.BYTE); // dimension id
|
||||
map(Types.BYTE); // difficulty
|
||||
map(Types.BYTE); // game mode
|
||||
map(Types.SHORT); // world height
|
||||
create(Types.LONG, 0L); // seed
|
||||
map(Types1_6_4.STRING); // level type
|
||||
}
|
||||
});
|
||||
@ -339,10 +338,10 @@ public class Protocol1_2_1_3to1_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
}
|
||||
}
|
||||
|
||||
private void sendEntityHeadLook(final int entityId, final byte headYaw, final PacketWrapper wrapper) throws Exception {
|
||||
final PacketWrapper entityHeadLook = PacketWrapper.create(ClientboundPackets1_2_1.ENTITY_HEAD_LOOK, wrapper.user());
|
||||
entityHeadLook.write(Type.INT, entityId); // entity id
|
||||
entityHeadLook.write(Type.BYTE, headYaw); // head yaw
|
||||
private void sendEntityHeadLook(final int entityId, final byte headYaw, final PacketWrapper wrapper) {
|
||||
final PacketWrapper entityHeadLook = PacketWrapper.create(ClientboundPackets1_2_1.ROTATE_HEAD, wrapper.user());
|
||||
entityHeadLook.write(Types.INT, entityId); // entity id
|
||||
entityHeadLook.write(Types.BYTE, headYaw); // head yaw
|
||||
|
||||
wrapper.send(Protocol1_2_1_3to1_1.class);
|
||||
entityHeadLook.send(Protocol1_2_1_3to1_1.class);
|
||||
@ -364,7 +363,7 @@ public class Protocol1_2_1_3to1_1 extends StatelessProtocol<ClientboundPackets1_
|
||||
}
|
||||
|
||||
@Override
|
||||
public LegacyItemRewriter<Protocol1_2_1_3to1_1> getItemRewriter() {
|
||||
public ItemRewriter getItemRewriter() {
|
||||
return this.itemRewriter;
|
||||
}
|
||||
|
||||
|
@ -38,43 +38,43 @@ public enum ServerboundPackets1_1 implements ServerboundPacketType, PreNettyPack
|
||||
buf.skipBytes(8);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
INTERACT_ENTITY(7, (user, buf) -> buf.skipBytes(9)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
INTERACT(7, (user, buf) -> buf.skipBytes(9)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
readString(buf);
|
||||
}),
|
||||
PLAYER_MOVEMENT(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_ROTATION(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION_AND_ROTATION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_DIGGING(14, (user, buf) -> buf.skipBytes(11)),
|
||||
PLAYER_BLOCK_PLACEMENT(15, (user, buf) -> {
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_POS_ROT(13, (user, buf) -> buf.skipBytes(41)),
|
||||
PLAYER_ACTION(14, (user, buf) -> buf.skipBytes(11)),
|
||||
USE_ITEM_ON(15, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
HELD_ITEM_CHANGE(16, (user, buf) -> buf.skipBytes(2)),
|
||||
ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_ACTION(19, (user, buf) -> buf.skipBytes(5)),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CLICK_WINDOW(102, (user, buf) -> {
|
||||
SET_CARRIED_ITEM(16, (user, buf) -> buf.skipBytes(2)),
|
||||
SWING(18, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_COMMAND(19, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_CLICK(102, (user, buf) -> {
|
||||
buf.skipBytes(7);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CREATIVE_INVENTORY_ACTION(107, (user, buf) -> {
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SET_CREATIVE_MODE_SLOT(107, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
CLICK_WINDOW_BUTTON(108, (user, buf) -> buf.skipBytes(2)),
|
||||
UPDATE_SIGN(130, (user, buf) -> {
|
||||
CONTAINER_BUTTON_CLICK(108, (user, buf) -> buf.skipBytes(2)),
|
||||
SIGN_UPDATE(130, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
}),
|
||||
PLUGIN_MESSAGE(250, (user, buf) -> {
|
||||
CUSTOM_PAYLOAD(250, (user, buf) -> {
|
||||
readString(buf);
|
||||
short s = buf.readShort();
|
||||
for (int i = 0; i < s; i++) buf.readByte();
|
||||
|
@ -17,13 +17,13 @@
|
||||
*/
|
||||
package net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.model;
|
||||
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_8;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -18,11 +18,12 @@
|
||||
package net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.rewriter;
|
||||
|
||||
import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.ClientboundPackets1_1;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.Protocol1_2_1_3to1_1;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_4_5to1_2_1_3.ServerboundPackets1_2_1;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.types.Types1_2_4;
|
||||
|
||||
public class ItemRewriter extends LegacyItemRewriter<Protocol1_2_1_3to1_1> {
|
||||
public class ItemRewriter extends LegacyItemRewriter<ClientboundPackets1_1, ServerboundPackets1_2_1, Protocol1_2_1_3to1_1> {
|
||||
|
||||
public ItemRewriter(final Protocol1_2_1_3to1_1 protocol) {
|
||||
super(protocol, "1.1", Types1_2_4.NBT_ITEM, Types1_2_4.NBT_ITEM_ARRAY);
|
||||
@ -38,7 +39,7 @@ public class ItemRewriter extends LegacyItemRewriter<Protocol1_2_1_3to1_1> {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
this.registerCreativeInventoryAction(ServerboundPackets1_2_1.CREATIVE_INVENTORY_ACTION);
|
||||
this.registerCreativeInventoryAction(ServerboundPackets1_2_1.SET_CREATIVE_MODE_SLOT);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,9 +21,8 @@ import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.util.IdAndData;
|
||||
import net.raphimc.vialegacy.ViaLegacy;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.Protocol1_2_1_3to1_1;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.model.PendingBlockEntry;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_4_5to1_2_1_3.ClientboundPackets1_2_1;
|
||||
@ -32,7 +31,6 @@ import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class PendingBlocksTracker extends StoredObject {
|
||||
|
||||
@ -70,15 +68,11 @@ public class PendingBlocksTracker extends StoredObject {
|
||||
final PendingBlockEntry pendingBlockEntry = it.next();
|
||||
if (pendingBlockEntry.decrementAndCheckIsExpired()) {
|
||||
it.remove();
|
||||
try {
|
||||
final PacketWrapper blockChange = PacketWrapper.create(ClientboundPackets1_2_1.BLOCK_CHANGE, this.getUser());
|
||||
blockChange.write(Types1_7_6.POSITION_UBYTE, pendingBlockEntry.getPosition()); // position
|
||||
blockChange.write(Type.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getId()); // block id
|
||||
blockChange.write(Type.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getData()); // block data
|
||||
blockChange.send(Protocol1_2_1_3to1_1.class);
|
||||
} catch (Throwable e) {
|
||||
ViaLegacy.getPlatform().getLogger().log(Level.WARNING, "Could not send block update for expired pending block", e);
|
||||
}
|
||||
final PacketWrapper blockChange = PacketWrapper.create(ClientboundPackets1_2_1.BLOCK_UPDATE, this.getUser());
|
||||
blockChange.write(Types1_7_6.POSITION_UBYTE, pendingBlockEntry.getPosition()); // position
|
||||
blockChange.write(Types.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getId()); // block id
|
||||
blockChange.write(Types.UNSIGNED_BYTE, (short) pendingBlockEntry.getBlock().getData()); // block data
|
||||
blockChange.send(Protocol1_2_1_3to1_1.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class BlockChangeRecordArrayType extends Type<BlockChangeRecord[]> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockChangeRecord[] read(ByteBuf buffer) throws Exception {
|
||||
public BlockChangeRecord[] read(ByteBuf buffer) {
|
||||
final int length = buffer.readUnsignedShort();
|
||||
final short[] positions = new short[length];
|
||||
final short[] blocks = new short[length];
|
||||
@ -53,7 +53,7 @@ public class BlockChangeRecordArrayType extends Type<BlockChangeRecord[]> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, BlockChangeRecord[] records) throws Exception {
|
||||
public void write(ByteBuf buffer, BlockChangeRecord[] records) {
|
||||
buffer.writeShort(records.length);
|
||||
for (BlockChangeRecord record : records) {
|
||||
buffer.writeShort(record.getSectionX() << 12 | record.getSectionZ() << 8 | record.getY(-1));
|
||||
|
@ -25,7 +25,6 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.chunks.NibbleArray1_1;
|
||||
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.model.NonFullChunk1_1;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
@ -37,7 +36,7 @@ public class ChunkType1_1 extends Type<Chunk> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk read(ByteBuf byteBuf) throws Exception {
|
||||
public Chunk read(ByteBuf byteBuf) {
|
||||
final int xPosition = byteBuf.readInt();
|
||||
final int yPosition = byteBuf.readShort();
|
||||
final int zPosition = byteBuf.readInt();
|
||||
@ -53,7 +52,7 @@ public class ChunkType1_1 extends Type<Chunk> {
|
||||
try {
|
||||
inflater.inflate(uncompressedData);
|
||||
} catch (DataFormatException dataformatexception) {
|
||||
throw new IOException("Bad compressed data format");
|
||||
throw new RuntimeException("Bad compressed data format");
|
||||
} finally {
|
||||
inflater.end();
|
||||
}
|
||||
@ -62,7 +61,7 @@ public class ChunkType1_1 extends Type<Chunk> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf byteBuf, Chunk chunk) throws Exception {
|
||||
public void write(ByteBuf byteBuf, Chunk chunk) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -29,111 +29,111 @@ import static net.raphimc.vialegacy.api.splitter.PreNettyTypes.*;
|
||||
public enum ClientboundPackets1_2_1 implements ClientboundPacketType, PreNettyPacketType {
|
||||
|
||||
KEEP_ALIVE(0, (user, buf) -> buf.skipBytes(4)),
|
||||
JOIN_GAME(1, (user, buf) -> {
|
||||
LOGIN(1, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
buf.skipBytes(11);
|
||||
}),
|
||||
HANDSHAKE(2, (user, buf) -> readString(buf)),
|
||||
CHAT_MESSAGE(3, (user, buf) -> readString(buf)),
|
||||
TIME_UPDATE(4, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_EQUIPMENT(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
UPDATE_HEALTH(8, (user, buf) -> buf.skipBytes(8)),
|
||||
CHAT(3, (user, buf) -> readString(buf)),
|
||||
SET_TIME(4, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_EQUIPPED_ITEM(5, (user, buf) -> buf.skipBytes(10)),
|
||||
SET_DEFAULT_SPAWN_POSITION(6, (user, buf) -> buf.skipBytes(12)),
|
||||
SET_HEALTH(8, (user, buf) -> buf.skipBytes(8)),
|
||||
RESPAWN(9, (user, buf) -> {
|
||||
buf.skipBytes(8);
|
||||
readString(buf);
|
||||
}),
|
||||
PLAYER_POSITION_ONLY_ONGROUND(10, (user, buf) -> buf.skipBytes(1)),
|
||||
PLAYER_POSITION_ONLY_POSITION(11, (user, buf) -> buf.skipBytes(33)),
|
||||
PLAYER_POSITION_ONLY_LOOK(12, (user, buf) -> buf.skipBytes(9)),
|
||||
MOVE_PLAYER_STATUS_ONLY(10, (user, buf) -> buf.skipBytes(1)),
|
||||
MOVE_PLAYER_POS(11, (user, buf) -> buf.skipBytes(33)),
|
||||
MOVE_PLAYER_ROT(12, (user, buf) -> buf.skipBytes(9)),
|
||||
PLAYER_POSITION(13, (user, buf) -> buf.skipBytes(41)),
|
||||
USE_BED(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ENTITY_ANIMATION(18, (user, buf) -> buf.skipBytes(5)),
|
||||
SPAWN_PLAYER(20, (user, buf) -> {
|
||||
PLAYER_SLEEP(17, (user, buf) -> buf.skipBytes(14)),
|
||||
ANIMATE(18, (user, buf) -> buf.skipBytes(5)),
|
||||
ADD_PLAYER(20, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_ITEM(21, (user, buf) -> buf.skipBytes(24)),
|
||||
COLLECT_ITEM(22, (user, buf) -> buf.skipBytes(8)),
|
||||
SPAWN_ENTITY(23, (user, buf) -> {
|
||||
TAKE_ITEM_ENTITY(22, (user, buf) -> buf.skipBytes(8)),
|
||||
ADD_ENTITY(23, (user, buf) -> {
|
||||
buf.skipBytes(17);
|
||||
int i = buf.readInt();
|
||||
if (i > 0) {
|
||||
buf.skipBytes(6);
|
||||
}
|
||||
}),
|
||||
SPAWN_MOB(24, (user, buf) -> {
|
||||
ADD_MOB(24, (user, buf) -> {
|
||||
buf.skipBytes(20);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
SPAWN_PAINTING(25, (user, buf) -> {
|
||||
ADD_PAINTING(25, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readString(buf);
|
||||
buf.skipBytes(16);
|
||||
}),
|
||||
SPAWN_EXPERIENCE_ORB(26, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_VELOCITY(28, (user, buf) -> buf.skipBytes(10)),
|
||||
DESTROY_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_MOVEMENT(30, (user, buf) -> buf.skipBytes(4)),
|
||||
ENTITY_POSITION(31, (user, buf) -> buf.skipBytes(7)),
|
||||
ENTITY_ROTATION(32, (user, buf) -> buf.skipBytes(6)),
|
||||
ENTITY_POSITION_AND_ROTATION(33, (user, buf) -> buf.skipBytes(9)),
|
||||
ENTITY_TELEPORT(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ENTITY_HEAD_LOOK(35, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_STATUS(38, (user, buf) -> buf.skipBytes(5)),
|
||||
ATTACH_ENTITY(39, (user, buf) -> buf.skipBytes(8)),
|
||||
ENTITY_METADATA(40, (user, buf) -> {
|
||||
ADD_EXPERIENCE_ORB(26, (user, buf) -> buf.skipBytes(18)),
|
||||
SET_ENTITY_MOTION(28, (user, buf) -> buf.skipBytes(10)),
|
||||
REMOVE_ENTITIES(29, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY(30, (user, buf) -> buf.skipBytes(4)),
|
||||
MOVE_ENTITY_POS(31, (user, buf) -> buf.skipBytes(7)),
|
||||
MOVE_ENTITY_ROT(32, (user, buf) -> buf.skipBytes(6)),
|
||||
MOVE_ENTITY_POS_ROT(33, (user, buf) -> buf.skipBytes(9)),
|
||||
TELEPORT_ENTITY(34, (user, buf) -> buf.skipBytes(18)),
|
||||
ROTATE_HEAD(35, (user, buf) -> buf.skipBytes(5)),
|
||||
ENTITY_EVENT(38, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_ENTITY_LINK(39, (user, buf) -> buf.skipBytes(8)),
|
||||
SET_ENTITY_DATA(40, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
readEntityMetadatab1_5(buf);
|
||||
}),
|
||||
ENTITY_EFFECT(41, (user, buf) -> buf.skipBytes(8)),
|
||||
REMOVE_ENTITY_EFFECT(42, (user, buf) -> buf.skipBytes(5)),
|
||||
UPDATE_MOB_EFFECT(41, (user, buf) -> buf.skipBytes(8)),
|
||||
REMOVE_MOB_EFFECT(42, (user, buf) -> buf.skipBytes(5)),
|
||||
SET_EXPERIENCE(43, (user, buf) -> buf.skipBytes(8)),
|
||||
PRE_CHUNK(50, (user, buf) -> buf.skipBytes(9)),
|
||||
CHUNK_DATA(51, (user, buf) -> {
|
||||
LEVEL_CHUNK(51, (user, buf) -> {
|
||||
buf.skipBytes(13);
|
||||
int x = buf.readInt();
|
||||
buf.skipBytes(4);
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
MULTI_BLOCK_CHANGE(52, (user, buf) -> {
|
||||
CHUNK_BLOCKS_UPDATE(52, (user, buf) -> {
|
||||
buf.skipBytes(10);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_CHANGE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_ACTION(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLOSION(60, (user, buf) -> {
|
||||
BLOCK_UPDATE(53, (user, buf) -> buf.skipBytes(11)),
|
||||
BLOCK_EVENT(54, (user, buf) -> buf.skipBytes(12)),
|
||||
EXPLODE(60, (user, buf) -> {
|
||||
buf.skipBytes(28);
|
||||
int x = buf.readInt();
|
||||
for (int i = 0; i < x; i++) {
|
||||
buf.skipBytes(3);
|
||||
}
|
||||
}),
|
||||
EFFECT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
LEVEL_EVENT(61, (user, buf) -> buf.skipBytes(17)),
|
||||
GAME_EVENT(70, (user, buf) -> buf.skipBytes(2)),
|
||||
SPAWN_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_WINDOW(100, (user, buf) -> {
|
||||
ADD_GLOBAL_ENTITY(71, (user, buf) -> buf.skipBytes(17)),
|
||||
OPEN_SCREEN(100, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readString(buf);
|
||||
buf.skipBytes(1);
|
||||
}),
|
||||
CLOSE_WINDOW(101, (user, buf) -> buf.skipBytes(1)),
|
||||
SET_SLOT(103, (user, buf) -> {
|
||||
CONTAINER_CLOSE(101, (user, buf) -> buf.skipBytes(1)),
|
||||
CONTAINER_SET_SLOT(103, (user, buf) -> {
|
||||
buf.skipBytes(3);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
WINDOW_ITEMS(104, (user, buf) -> {
|
||||
CONTAINER_SET_CONTENT(104, (user, buf) -> {
|
||||
buf.skipBytes(1);
|
||||
int x = buf.readShort();
|
||||
for (int i = 0; i < x; i++) readItemStack1_0(buf);
|
||||
}),
|
||||
WINDOW_PROPERTY(105, (user, buf) -> buf.skipBytes(5)),
|
||||
WINDOW_CONFIRMATION(106, (user, buf) -> buf.skipBytes(4)),
|
||||
CREATIVE_INVENTORY_ACTION(107, (user, buf) -> {
|
||||
CONTAINER_SET_DATA(105, (user, buf) -> buf.skipBytes(5)),
|
||||
CONTAINER_ACK(106, (user, buf) -> buf.skipBytes(4)),
|
||||
SET_CREATIVE_MODE_SLOT(107, (user, buf) -> {
|
||||
buf.skipBytes(2);
|
||||
readItemStack1_0(buf);
|
||||
}),
|
||||
@ -144,18 +144,18 @@ public enum ClientboundPackets1_2_1 implements ClientboundPacketType, PreNettyPa
|
||||
readString(buf);
|
||||
readString(buf);
|
||||
}),
|
||||
MAP_DATA(131, (user, buf) -> {
|
||||
MAP_ITEM_DATA(131, (user, buf) -> {
|
||||
buf.skipBytes(4);
|
||||
short x = buf.readUnsignedByte();
|
||||
for (int i = 0; i < x; i++) buf.readByte();
|
||||
}),
|
||||
BLOCK_ENTITY_DATA(132, (user, buf) -> buf.skipBytes(23)),
|
||||
STATISTICS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
AWARD_STATS(200, (user, buf) -> buf.skipBytes(5)),
|
||||
PLAYER_INFO(201, (user, buf) -> {
|
||||
readString(buf);
|
||||
buf.skipBytes(3);
|
||||
}),
|
||||
PLUGIN_MESSAGE(250, (user, buf) -> {
|
||||
CUSTOM_PAYLOAD(250, (user, buf) -> {
|
||||
readString(buf);
|
||||
short s = buf.readShort();
|
||||
for (int i = 0; i < s; i++) buf.readByte();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user