Compare commits

...

2 Commits

Author SHA1 Message Date
RaphiMC 09828c1747
Refactored code 2024-05-17 22:43:17 +02:00
RaphiMC f5f99622cf
Updated to ViaVersion 5 2024-05-17 17:21:21 +02:00
321 changed files with 8572 additions and 8629 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -191,7 +191,7 @@ public class BlockList1_6 {
public static Block1_6 getByID(final int id) {
for (Block1_6 block : blockList) {
if (block.blockID == id) {
if (block.blockId == id) {
return block;
}
}
@ -207,13 +207,10 @@ public class BlockList1_6 {
return null;
}
public static class Block1_6 {
public record Block1_6(int blockId, String name) {
public final int blockID;
public final String name;
public Block1_6(final int blockID, final String name) {
this.blockID = blockID;
public Block1_6(final int blockId, final String name) {
this.blockId = blockId;
this.name = name;
blockList.add(this);

View File

@ -221,7 +221,7 @@ public class ItemList1_6 {
public static Item1_6 getByID(final int itemID) {
for (Item1_6 item : itemList) {
if (item.itemID == itemID) {
if (item.itemId() == itemID) {
return item;
}
}
@ -230,22 +230,17 @@ public class ItemList1_6 {
public static Item1_6 getByName(final String name) {
for (Item1_6 item : itemList) {
if (item.name.equalsIgnoreCase(name)) {
if (item.name().equalsIgnoreCase(name)) {
return item;
}
}
return null;
}
public static class Item1_6 {
public record Item1_6(int itemId, String name, int maxDamage, boolean hasSubTypes) {
public final int itemID;
public final int maxDamage;
public final boolean hasSubTypes;
public final String name;
public Item1_6(final int itemID, final String name, final int maxDamage, final boolean hasSubTypes) {
this.itemID = itemID;
public Item1_6(final int itemId, final String name, final int maxDamage, final boolean hasSubTypes) {
this.itemId = itemId;
this.name = name;
this.maxDamage = maxDamage;
this.hasSubTypes = hasSubTypes;
@ -254,7 +249,7 @@ public class ItemList1_6 {
}
public boolean isDamageable() {
return maxDamage > 0 && !hasSubTypes;
return this.maxDamage > 0 && !this.hasSubTypes;
}
}

View File

@ -21,11 +21,11 @@ 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;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.HandshakeStorage;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ProtocolMetadataStorage;
public class PreNettyBaseProtocol extends AbstractSimpleProtocol {
@ -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));
});

View File

@ -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);
}

View File

@ -44,8 +44,7 @@ public abstract class StatelessTransitionProtocol<CU extends ClientboundPacketTy
final State currentState = wrapper.user().getProtocolInfo().getServerState();
for (int i = 0; i < handlers.length; i += 2) {
if (handlers[i] instanceof State) {
final State state = (State) handlers[i];
if (handlers[i] instanceof State state) {
if (state != currentState) continue;
} else {
final ClientboundPacketType mappedPacketType = (ClientboundPacketType) handlers[i];

View File

@ -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);
}
@ -230,21 +232,7 @@ public abstract class LegacyItemRewriter<P extends Protocol> extends RewriterBas
}
private static class RewriteEntry {
private final int oldItemID;
private final short oldItemMeta;
private final int newItemID;
private final short newItemMeta;
private final String newItemName;
public RewriteEntry(final int oldItemID, final short oldItemMeta, final int newItemID, final short newItemMeta, final String newItemName) {
this.oldItemID = oldItemID;
this.oldItemMeta = oldItemMeta;
this.newItemID = newItemID;
this.newItemMeta = newItemMeta;
this.newItemName = newItemName;
}
private record RewriteEntry(int oldItemID, short oldItemMeta, int newItemID, short newItemMeta, String newItemName) {
public boolean rewrites(final Item item) {
return item.identifier() == this.oldItemID && (this.oldItemMeta == -1 || this.oldItemMeta == item.data());
@ -252,15 +240,7 @@ public abstract class LegacyItemRewriter<P extends Protocol> extends RewriterBas
}
private static class NonExistentEntry {
private final int itemId;
private final short itemMeta;
public NonExistentEntry(final int itemId, final short itemMeta) {
this.itemId = itemId;
this.itemMeta = itemMeta;
}
private record NonExistentEntry(int itemId, short itemMeta) {
public boolean rewrites(final Item item) {
return item.identifier() == this.itemId && (this.itemMeta == -1 || this.itemMeta == item.data());

View File

@ -18,7 +18,7 @@
package net.raphimc.vialegacy.api.splitter;
import io.netty.buffer.ByteBuf;
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.data.NbtItemList;
import net.raphimc.vialegacy.protocol.release.r1_2_4_5tor1_3_1_2.data.NbtItemList1_2_4;
public class PreNettyTypes {
@ -50,7 +50,7 @@ public class PreNettyTypes {
if (s >= 0) {
buffer.readByte();
buffer.readShort();
if (NbtItemList.hasNbt(s)) {
if (NbtItemList1_2_4.hasNbt(s)) {
readTag(buffer);
}
}
@ -86,7 +86,7 @@ public class PreNettyTypes {
for (int i = 0; i < s; i++) buffer.readByte();
}
public static void readEntityMetadata1_4_4(final ByteBuf buffer) {
public static void readEntityDataList1_4_4(final ByteBuf buffer) {
for (byte b = buffer.readByte(); b != 127; b = buffer.readByte()) {
int i = (b & 224) >> 5;
switch (i) {
@ -116,7 +116,7 @@ public class PreNettyTypes {
}
}
public static void readEntityMetadata1_4_2(final ByteBuf buffer) {
public static void readEntityDataList1_4_2(final ByteBuf buffer) {
for (byte b = buffer.readByte(); b != 127; b = buffer.readByte()) {
int i = (b & 224) >> 5;
switch (i) {
@ -150,7 +150,7 @@ public class PreNettyTypes {
}
}
public static void readEntityMetadatab1_5(final ByteBuf buffer) {
public static void readEntityDataListb1_5(final ByteBuf buffer) {
for (byte b = buffer.readByte(); b != 127; b = buffer.readByte()) {
int i = (b & 224) >> 5;
switch (i) {
@ -182,7 +182,7 @@ public class PreNettyTypes {
}
}
public static void readEntityMetadatab1_3(final ByteBuf buffer) {
public static void readEntityDataListb1_3(final ByteBuf buffer) {
for (byte b = buffer.readByte(); b != 127; b = buffer.readByte()) {
int i = (b & 224) >> 5;
switch (i) {
@ -214,7 +214,7 @@ public class PreNettyTypes {
}
}
public static void readEntityMetadatab1_2(final ByteBuf buffer) {
public static void readEntityDataListb1_2(final ByteBuf buffer) {
for (byte b = buffer.readByte(); b != 127; b = buffer.readByte()) {
int i = (b & 224) >> 5;
switch (i) {

View File

@ -22,21 +22,14 @@ import com.viaversion.viaversion.api.minecraft.BlockFace;
public class BlockFaceUtil {
public static BlockFace getFace(final int direction) {
switch (direction) {
case 0:
return BlockFace.BOTTOM;
default:
case 1:
return BlockFace.TOP;
case 2:
return BlockFace.NORTH;
case 3:
return BlockFace.SOUTH;
case 4:
return BlockFace.WEST;
case 5:
return BlockFace.EAST;
}
return switch (direction) {
case 0 -> BlockFace.BOTTOM;
default -> BlockFace.TOP;
case 2 -> BlockFace.NORTH;
case 3 -> BlockFace.SOUTH;
case 4 -> BlockFace.WEST;
case 5 -> BlockFace.EAST;
};
}
}

View File

@ -49,7 +49,7 @@ public class ChunkCoordSpiral implements Iterable<ChunkCoord> {
@Override
public Iterator<ChunkCoord> iterator() {
return new Iterator<ChunkCoord>() {
return new Iterator<>() {
int x = center.chunkX;
int z = center.chunkZ;

View File

@ -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);

View File

@ -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

View File

@ -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
}

View File

@ -23,45 +23,45 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import net.raphimc.vialegacy.ViaLegacy;
import net.raphimc.vialegacy.ViaLegacyConfig;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_16_2toa1_0_15.Protocola1_0_16_2toa1_0_15;
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_1_0_1_1_2_1toa1_0_17_1_0_17_4.Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4;
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1;
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_2toa1_2_0_1_2_1_1.Protocola1_2_2toa1_2_0_1_2_1_1;
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_1_2_3_4toa1_2_2.Protocola1_2_3_1_2_3_4toa1_2_2;
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4.Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4;
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.beta.protocol1_0_0_1tob1_8_0_1.Protocol1_0_0_1tob1_8_0_1;
import net.raphimc.vialegacy.protocols.beta.protocolb1_1_2tob1_0_1_1.Protocolb1_1_2tob1_0_1_1;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.Protocolb1_2_0_2tob1_1_2;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.Protocolb1_3_0_1tob1_2_0_2;
import net.raphimc.vialegacy.protocols.beta.protocolb1_4_0_1tob1_3_0_1.Protocolb1_4_0_1tob1_3_0_1;
import net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.Protocolb1_5_0_2tob1_4_0_1;
import net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2.Protocolb1_6_0_6tob1_5_0_2;
import net.raphimc.vialegacy.protocols.beta.protocolb1_7_0_3tob1_6_0_6.Protocolb1_7_0_3tob1_6_0_6;
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.Protocolb1_8_0_1tob1_7_0_3;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.Protocola1_0_15toc0_30;
import net.raphimc.vialegacy.protocols.classic.protocolc0_0_16a_02to0_0_15a_1.Protocolc0_0_16a_02to0_0_15a_1;
import net.raphimc.vialegacy.protocols.classic.protocolc0_0_18a_02toc0_0_16a_02.Protocolc0_0_18a_02toc0_0_16a_02;
import net.raphimc.vialegacy.protocols.classic.protocolc0_0_19a_06toc0_0_18a_02.Protocolc0_0_19a_06toc0_0_18a_02;
import net.raphimc.vialegacy.protocols.classic.protocolc0_0_20a_27toc0_0_19a_06.Protocolc0_27toc0_0_19a_06;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_0_20a_27.Protocolc0_30toc0_27;
import net.raphimc.vialegacy.protocols.classic.protocolc0_28_30toc0_28_30cpe.Protocolc0_30toc0_30cpe;
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.Protocol1_2_1_3to1_1;
import net.raphimc.vialegacy.protocols.release.protocol1_2_4_5to1_2_1_3.Protocol1_2_4_5to1_2_1_3;
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.Protocol1_3_1_2to1_2_4_5;
import net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.Protocol1_4_2to1_3_1_2;
import net.raphimc.vialegacy.protocols.release.protocol1_4_4_5to1_4_2.Protocol1_4_4_5to1_4_2;
import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.Protocol1_4_6_7to1_4_4_5;
import net.raphimc.vialegacy.protocols.release.protocol1_5_0_1to1_4_6_7.Protocol1_5_0_1to1_4_6_7;
import net.raphimc.vialegacy.protocols.release.protocol1_5_2to1_5_0_1.Protocol1_5_2to1_5_0_1;
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.Protocol1_6_1to1_5_2;
import net.raphimc.vialegacy.protocols.release.protocol1_6_2to1_6_1.Protocol1_6_2to1_6_1;
import net.raphimc.vialegacy.protocols.release.protocol1_6_4to1_6_2.Protocol1_6_4to1_6_2;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.Protocol1_7_2_5to1_6_4;
import net.raphimc.vialegacy.protocols.release.protocol1_7_6_10to1_7_2_5.Protocol1_7_6_10to1_7_2_5;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.Protocol1_8to1_7_6_10;
import net.raphimc.vialegacy.protocol.alpha.a1_0_15toa1_0_16_2.Protocola1_0_15Toa1_0_16_2;
import net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.Protocola1_0_16_2Toa1_0_17_1_0_17_4;
import net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1.Protocola1_0_17_1_0_17_4Toa1_1_0_1_1_2_1;
import net.raphimc.vialegacy.protocol.alpha.a1_1_0_1_1_2_1toa1_2_0_1_2_1_1.Protocola1_1_0_1_1_2_1Toa1_2_0_1_2_1_1;
import net.raphimc.vialegacy.protocol.alpha.a1_2_0_1_2_1_1toa1_2_2.Protocola1_2_0_1_2_1_1Toa1_2_2;
import net.raphimc.vialegacy.protocol.alpha.a1_2_2toa1_2_3_1_2_3_4.Protocola1_2_2Toa1_2_3_1_2_3_4;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_1_2_3_4toa1_2_3_5_1_2_6.Protocola1_2_3_1_2_3_4Toa1_2_3_5_1_2_6;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.Protocola1_2_3_5_1_2_6Tob1_0_1_1_1;
import net.raphimc.vialegacy.protocol.beta.b1_0_1_1tob1_1_2.Protocolb1_0_1_1Tob1_1_2;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.Protocolb1_1_2Tob1_2_0_2;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.Protocolb1_2_0_2Tob1_3_0_1;
import net.raphimc.vialegacy.protocol.beta.b1_3_0_1tob1_4_0_1.Protocolb1_3_0_1Tob1_4_0_1;
import net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.Protocolb1_4_0_1Tob1_5_0_2;
import net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.Protocolb1_5_0_2Tob1_6_0_6;
import net.raphimc.vialegacy.protocol.beta.b1_6_0_6tob1_7_0_3.Protocolb1_6_0_6Tob1_7_0_3;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.Protocolb1_7_0_3Tob1_8_0_1;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.Protocolb1_8_0_1tor1_0_0_1;
import net.raphimc.vialegacy.protocol.classic.c0_0_15a_1toc0_0_16a_02.Protocolc0_0_15a_1Toc0_0_16a_02;
import net.raphimc.vialegacy.protocol.classic.c0_0_16a_02toc0_0_18a_02.Protocolc0_0_16a_02Toc0_0_18a_02;
import net.raphimc.vialegacy.protocol.classic.c0_0_18a_02toc0_0_19a_06.Protocolc0_0_18a_02Toc0_0_19a_06;
import net.raphimc.vialegacy.protocol.classic.c0_0_19a_06toc0_0_20a_27.Protocolc0_0_19a_06Toc0_0_20a_27;
import net.raphimc.vialegacy.protocol.classic.c0_0_20a_27toc0_28_30.Protocolc0_0_20a_27Toc0_28_30;
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.Protocolc0_28_30Toa1_0_15;
import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.Protocolc0_30cpeToc0_28_30;
import net.raphimc.vialegacy.protocol.release.r1_0_0_1tor1_1.Protocolr1_0_0_1Tor1_1;
import net.raphimc.vialegacy.protocol.release.r1_1tor1_2_1_3.Protocolr1_1Tor1_2_1_3;
import net.raphimc.vialegacy.protocol.release.r1_2_1_3tor1_2_4_5.Protocolr1_2_1_3Tor1_2_4_5;
import net.raphimc.vialegacy.protocol.release.r1_2_4_5tor1_3_1_2.Protocolr1_2_4_5Tor1_3_1_2;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.Protocolr1_3_1_2Tor1_4_2;
import net.raphimc.vialegacy.protocol.release.r1_4_2tor1_4_4_5.Protocolr1_4_2Tor1_4_4_5;
import net.raphimc.vialegacy.protocol.release.r1_4_4_5tor1_4_6_7.Protocolr1_4_4_5Tor1_4_6_7;
import net.raphimc.vialegacy.protocol.release.r1_4_6_7tor1_5_0_1.Protocolr1_4_6_7Tor1_5_0_1;
import net.raphimc.vialegacy.protocol.release.r1_5_0_1tor1_5_2.Protocolr1_5_0_1Tor1_5_2;
import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.Protocolr1_5_2Tor1_6_1;
import net.raphimc.vialegacy.protocol.release.r1_6_1tor1_6_2.Protocolr1_6_1Tor1_6_2;
import net.raphimc.vialegacy.protocol.release.r1_6_2tor1_6_4.Protocolr1_6_2Tor1_6_4;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.Protocolr1_6_4Tor1_7_2_5;
import net.raphimc.vialegacy.protocol.release.r1_7_2_5tor1_7_6_10.Protocolr1_7_2_5Tor1_7_6_10;
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.Protocolr1_7_6_10Tor1_8;
import java.io.File;
import java.util.logging.Logger;
@ -69,52 +69,52 @@ 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();
protocolManager.registerProtocol(new Protocol1_8to1_7_6_10(), ProtocolVersion.v1_8, ProtocolVersion.v1_7_6);
protocolManager.registerProtocol(new Protocol1_7_6_10to1_7_2_5(), ProtocolVersion.v1_7_6, ProtocolVersion.v1_7_2);
protocolManager.registerProtocol(new Protocol1_7_2_5to1_6_4(), ProtocolVersion.v1_7_2, LegacyProtocolVersion.r1_6_4);
protocolManager.registerProtocol(new Protocol1_6_4to1_6_2(), LegacyProtocolVersion.r1_6_4, LegacyProtocolVersion.r1_6_2);
protocolManager.registerProtocol(new Protocol1_6_2to1_6_1(), LegacyProtocolVersion.r1_6_2, LegacyProtocolVersion.r1_6_1);
protocolManager.registerProtocol(new Protocol1_6_1to1_5_2(), LegacyProtocolVersion.r1_6_1, LegacyProtocolVersion.r1_5_2);
protocolManager.registerProtocol(new Protocol1_5_2to1_5_0_1(), LegacyProtocolVersion.r1_5_2, LegacyProtocolVersion.r1_5tor1_5_1);
protocolManager.registerProtocol(new Protocol1_5_0_1to1_4_6_7(), LegacyProtocolVersion.r1_5tor1_5_1, LegacyProtocolVersion.r1_4_6tor1_4_7);
protocolManager.registerProtocol(new Protocol1_4_6_7to1_4_4_5(), LegacyProtocolVersion.r1_4_6tor1_4_7, LegacyProtocolVersion.r1_4_4tor1_4_5);
protocolManager.registerProtocol(new Protocol1_4_4_5to1_4_2(), LegacyProtocolVersion.r1_4_4tor1_4_5, LegacyProtocolVersion.r1_4_2);
protocolManager.registerProtocol(new Protocol1_4_2to1_3_1_2(), LegacyProtocolVersion.r1_4_2, LegacyProtocolVersion.r1_3_1tor1_3_2);
protocolManager.registerProtocol(new Protocol1_3_1_2to1_2_4_5(), LegacyProtocolVersion.r1_3_1tor1_3_2, LegacyProtocolVersion.r1_2_4tor1_2_5);
protocolManager.registerProtocol(new Protocol1_2_4_5to1_2_1_3(), LegacyProtocolVersion.r1_2_4tor1_2_5, LegacyProtocolVersion.r1_2_1tor1_2_3);
protocolManager.registerProtocol(new Protocol1_2_1_3to1_1(), LegacyProtocolVersion.r1_2_1tor1_2_3, LegacyProtocolVersion.r1_1);
protocolManager.registerProtocol(new Protocol1_1to1_0_0_1(), LegacyProtocolVersion.r1_1, LegacyProtocolVersion.r1_0_0tor1_0_1);
protocolManager.registerProtocol(new Protocol1_0_0_1tob1_8_0_1(), LegacyProtocolVersion.r1_0_0tor1_0_1, LegacyProtocolVersion.b1_8tob1_8_1);
protocolManager.registerProtocol(new Protocolb1_8_0_1tob1_7_0_3(), LegacyProtocolVersion.b1_8tob1_8_1, LegacyProtocolVersion.b1_7tob1_7_3);
protocolManager.registerProtocol(new Protocolb1_7_0_3tob1_6_0_6(), LegacyProtocolVersion.b1_7tob1_7_3, LegacyProtocolVersion.b1_6tob1_6_6);
protocolManager.registerProtocol(new Protocolb1_6_0_6tob1_5_0_2(), LegacyProtocolVersion.b1_6tob1_6_6, LegacyProtocolVersion.b1_5tob1_5_2);
protocolManager.registerProtocol(new Protocolb1_5_0_2tob1_4_0_1(), LegacyProtocolVersion.b1_5tob1_5_2, LegacyProtocolVersion.b1_4tob1_4_1);
protocolManager.registerProtocol(new Protocolb1_4_0_1tob1_3_0_1(), LegacyProtocolVersion.b1_4tob1_4_1, LegacyProtocolVersion.b1_3tob1_3_1);
protocolManager.registerProtocol(new Protocolb1_3_0_1tob1_2_0_2(), LegacyProtocolVersion.b1_3tob1_3_1, LegacyProtocolVersion.b1_2_0tob1_2_2);
protocolManager.registerProtocol(new Protocolb1_2_0_2tob1_1_2(), LegacyProtocolVersion.b1_2_0tob1_2_2, LegacyProtocolVersion.b1_1_2);
protocolManager.registerProtocol(new Protocolb1_1_2tob1_0_1_1(), LegacyProtocolVersion.b1_1_2, LegacyProtocolVersion.b1_0tob1_1_1);
protocolManager.registerProtocol(new Protocolb1_0_1_1_1toa1_2_3_5_1_2_6(), LegacyProtocolVersion.b1_0tob1_1_1, LegacyProtocolVersion.a1_2_3_5toa1_2_6);
protocolManager.registerProtocol(new Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4(), LegacyProtocolVersion.a1_2_3_5toa1_2_6, LegacyProtocolVersion.a1_2_3toa1_2_3_4);
protocolManager.registerProtocol(new Protocola1_2_3_1_2_3_4toa1_2_2(), LegacyProtocolVersion.a1_2_3toa1_2_3_4, LegacyProtocolVersion.a1_2_2);
protocolManager.registerProtocol(new Protocola1_2_2toa1_2_0_1_2_1_1(), LegacyProtocolVersion.a1_2_2, LegacyProtocolVersion.a1_2_0toa1_2_1_1);
protocolManager.registerProtocol(new Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1(), LegacyProtocolVersion.a1_2_0toa1_2_1_1, LegacyProtocolVersion.a1_1_0toa1_1_2_1);
protocolManager.registerProtocol(new Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4(), LegacyProtocolVersion.a1_1_0toa1_1_2_1, LegacyProtocolVersion.a1_0_17toa1_0_17_4);
protocolManager.registerProtocol(new Protocola1_0_17_1_0_17_4toa1_0_16_2(), LegacyProtocolVersion.a1_0_17toa1_0_17_4, LegacyProtocolVersion.a1_0_16toa1_0_16_2);
protocolManager.registerProtocol(new Protocola1_0_16_2toa1_0_15(), LegacyProtocolVersion.a1_0_16toa1_0_16_2, LegacyProtocolVersion.a1_0_15);
protocolManager.registerProtocol(new Protocola1_0_15toc0_30(), LegacyProtocolVersion.a1_0_15, LegacyProtocolVersion.c0_28toc0_30);
protocolManager.registerProtocol(new Protocolc0_30toc0_30cpe(), LegacyProtocolVersion.c0_28toc0_30, LegacyProtocolVersion.c0_30cpe);
protocolManager.registerProtocol(new Protocolc0_30toc0_27(), LegacyProtocolVersion.c0_28toc0_30, LegacyProtocolVersion.c0_0_20ac0_27);
protocolManager.registerProtocol(new Protocolc0_27toc0_0_19a_06(), LegacyProtocolVersion.c0_0_20ac0_27, LegacyProtocolVersion.c0_0_19a_06);
protocolManager.registerProtocol(new Protocolc0_0_19a_06toc0_0_18a_02(), LegacyProtocolVersion.c0_0_19a_06, LegacyProtocolVersion.c0_0_18a_02);
protocolManager.registerProtocol(new Protocolc0_0_18a_02toc0_0_16a_02(), LegacyProtocolVersion.c0_0_18a_02, LegacyProtocolVersion.c0_0_16a_02);
protocolManager.registerProtocol(new Protocolc0_0_16a_02to0_0_15a_1(), LegacyProtocolVersion.c0_0_16a_02, LegacyProtocolVersion.c0_0_15a_1);
protocolManager.registerProtocol(new Protocolr1_7_6_10Tor1_8(), ProtocolVersion.v1_8, ProtocolVersion.v1_7_6);
protocolManager.registerProtocol(new Protocolr1_7_2_5Tor1_7_6_10(), ProtocolVersion.v1_7_6, ProtocolVersion.v1_7_2);
protocolManager.registerProtocol(new Protocolr1_6_4Tor1_7_2_5(), ProtocolVersion.v1_7_2, LegacyProtocolVersion.r1_6_4);
protocolManager.registerProtocol(new Protocolr1_6_2Tor1_6_4(), LegacyProtocolVersion.r1_6_4, LegacyProtocolVersion.r1_6_2);
protocolManager.registerProtocol(new Protocolr1_6_1Tor1_6_2(), LegacyProtocolVersion.r1_6_2, LegacyProtocolVersion.r1_6_1);
protocolManager.registerProtocol(new Protocolr1_5_2Tor1_6_1(), LegacyProtocolVersion.r1_6_1, LegacyProtocolVersion.r1_5_2);
protocolManager.registerProtocol(new Protocolr1_5_0_1Tor1_5_2(), LegacyProtocolVersion.r1_5_2, LegacyProtocolVersion.r1_5tor1_5_1);
protocolManager.registerProtocol(new Protocolr1_4_6_7Tor1_5_0_1(), LegacyProtocolVersion.r1_5tor1_5_1, LegacyProtocolVersion.r1_4_6tor1_4_7);
protocolManager.registerProtocol(new Protocolr1_4_4_5Tor1_4_6_7(), LegacyProtocolVersion.r1_4_6tor1_4_7, LegacyProtocolVersion.r1_4_4tor1_4_5);
protocolManager.registerProtocol(new Protocolr1_4_2Tor1_4_4_5(), LegacyProtocolVersion.r1_4_4tor1_4_5, LegacyProtocolVersion.r1_4_2);
protocolManager.registerProtocol(new Protocolr1_3_1_2Tor1_4_2(), LegacyProtocolVersion.r1_4_2, LegacyProtocolVersion.r1_3_1tor1_3_2);
protocolManager.registerProtocol(new Protocolr1_2_4_5Tor1_3_1_2(), LegacyProtocolVersion.r1_3_1tor1_3_2, LegacyProtocolVersion.r1_2_4tor1_2_5);
protocolManager.registerProtocol(new Protocolr1_2_1_3Tor1_2_4_5(), LegacyProtocolVersion.r1_2_4tor1_2_5, LegacyProtocolVersion.r1_2_1tor1_2_3);
protocolManager.registerProtocol(new Protocolr1_1Tor1_2_1_3(), LegacyProtocolVersion.r1_2_1tor1_2_3, LegacyProtocolVersion.r1_1);
protocolManager.registerProtocol(new Protocolr1_0_0_1Tor1_1(), LegacyProtocolVersion.r1_1, LegacyProtocolVersion.r1_0_0tor1_0_1);
protocolManager.registerProtocol(new Protocolb1_8_0_1tor1_0_0_1(), LegacyProtocolVersion.r1_0_0tor1_0_1, LegacyProtocolVersion.b1_8tob1_8_1);
protocolManager.registerProtocol(new Protocolb1_7_0_3Tob1_8_0_1(), LegacyProtocolVersion.b1_8tob1_8_1, LegacyProtocolVersion.b1_7tob1_7_3);
protocolManager.registerProtocol(new Protocolb1_6_0_6Tob1_7_0_3(), LegacyProtocolVersion.b1_7tob1_7_3, LegacyProtocolVersion.b1_6tob1_6_6);
protocolManager.registerProtocol(new Protocolb1_5_0_2Tob1_6_0_6(), LegacyProtocolVersion.b1_6tob1_6_6, LegacyProtocolVersion.b1_5tob1_5_2);
protocolManager.registerProtocol(new Protocolb1_4_0_1Tob1_5_0_2(), LegacyProtocolVersion.b1_5tob1_5_2, LegacyProtocolVersion.b1_4tob1_4_1);
protocolManager.registerProtocol(new Protocolb1_3_0_1Tob1_4_0_1(), LegacyProtocolVersion.b1_4tob1_4_1, LegacyProtocolVersion.b1_3tob1_3_1);
protocolManager.registerProtocol(new Protocolb1_2_0_2Tob1_3_0_1(), LegacyProtocolVersion.b1_3tob1_3_1, LegacyProtocolVersion.b1_2_0tob1_2_2);
protocolManager.registerProtocol(new Protocolb1_1_2Tob1_2_0_2(), LegacyProtocolVersion.b1_2_0tob1_2_2, LegacyProtocolVersion.b1_1_2);
protocolManager.registerProtocol(new Protocolb1_0_1_1Tob1_1_2(), LegacyProtocolVersion.b1_1_2, LegacyProtocolVersion.b1_0tob1_1_1);
protocolManager.registerProtocol(new Protocola1_2_3_5_1_2_6Tob1_0_1_1_1(), LegacyProtocolVersion.b1_0tob1_1_1, LegacyProtocolVersion.a1_2_3_5toa1_2_6);
protocolManager.registerProtocol(new Protocola1_2_3_1_2_3_4Toa1_2_3_5_1_2_6(), LegacyProtocolVersion.a1_2_3_5toa1_2_6, LegacyProtocolVersion.a1_2_3toa1_2_3_4);
protocolManager.registerProtocol(new Protocola1_2_2Toa1_2_3_1_2_3_4(), LegacyProtocolVersion.a1_2_3toa1_2_3_4, LegacyProtocolVersion.a1_2_2);
protocolManager.registerProtocol(new Protocola1_2_0_1_2_1_1Toa1_2_2(), LegacyProtocolVersion.a1_2_2, LegacyProtocolVersion.a1_2_0toa1_2_1_1);
protocolManager.registerProtocol(new Protocola1_1_0_1_1_2_1Toa1_2_0_1_2_1_1(), LegacyProtocolVersion.a1_2_0toa1_2_1_1, LegacyProtocolVersion.a1_1_0toa1_1_2_1);
protocolManager.registerProtocol(new Protocola1_0_17_1_0_17_4Toa1_1_0_1_1_2_1(), LegacyProtocolVersion.a1_1_0toa1_1_2_1, LegacyProtocolVersion.a1_0_17toa1_0_17_4);
protocolManager.registerProtocol(new Protocola1_0_16_2Toa1_0_17_1_0_17_4(), LegacyProtocolVersion.a1_0_17toa1_0_17_4, LegacyProtocolVersion.a1_0_16toa1_0_16_2);
protocolManager.registerProtocol(new Protocola1_0_15Toa1_0_16_2(), LegacyProtocolVersion.a1_0_16toa1_0_16_2, LegacyProtocolVersion.a1_0_15);
protocolManager.registerProtocol(new Protocolc0_28_30Toa1_0_15(), LegacyProtocolVersion.a1_0_15, LegacyProtocolVersion.c0_28toc0_30);
protocolManager.registerProtocol(new Protocolc0_30cpeToc0_28_30(), LegacyProtocolVersion.c0_28toc0_30, LegacyProtocolVersion.c0_30cpe);
protocolManager.registerProtocol(new Protocolc0_0_20a_27Toc0_28_30(), LegacyProtocolVersion.c0_28toc0_30, LegacyProtocolVersion.c0_0_20ac0_27);
protocolManager.registerProtocol(new Protocolc0_0_19a_06Toc0_0_20a_27(), LegacyProtocolVersion.c0_0_20ac0_27, LegacyProtocolVersion.c0_0_19a_06);
protocolManager.registerProtocol(new Protocolc0_0_18a_02Toc0_0_19a_06(), LegacyProtocolVersion.c0_0_19a_06, LegacyProtocolVersion.c0_0_18a_02);
protocolManager.registerProtocol(new Protocolc0_0_16a_02Toc0_0_18a_02(), LegacyProtocolVersion.c0_0_18a_02, LegacyProtocolVersion.c0_0_16a_02);
protocolManager.registerProtocol(new Protocolc0_0_15a_1Toc0_0_16a_02(), LegacyProtocolVersion.c0_0_16a_02, LegacyProtocolVersion.c0_0_15a_1);
}
Logger getLogger();

View File

@ -15,19 +15,21 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_0_16_2toa1_0_15;
package net.raphimc.vialegacy.protocol.alpha.a1_0_15toa1_0_16_2;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
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.ClientboundPacketsa1_0_16;
import net.raphimc.vialegacy.protocols.alpha.protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.ServerboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.types.Typesb1_7_0_3;
import net.raphimc.vialegacy.protocol.alpha.a1_0_15toa1_0_16_2.packet.ClientboundPacketsa1_0_15;
import net.raphimc.vialegacy.protocol.alpha.a1_0_15toa1_0_16_2.packet.ServerboundPacketsa1_0_15;
import net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.packet.ClientboundPacketsa1_0_16;
import net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1.packet.ServerboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.types.Typesb1_7_0_3;
public class Protocola1_0_16_2toa1_0_15 extends StatelessProtocol<ClientboundPacketsa1_0_15, ClientboundPacketsa1_0_16, ServerboundPacketsa1_0_15, ServerboundPacketsa1_0_17> {
public class Protocola1_0_15Toa1_0_16_2 extends StatelessProtocol<ClientboundPacketsa1_0_15, ClientboundPacketsa1_0_16, ServerboundPacketsa1_0_15, ServerboundPacketsa1_0_17> {
public Protocola1_0_16_2toa1_0_15() {
public Protocola1_0_15Toa1_0_16_2() {
super(ClientboundPacketsa1_0_15.class, ClientboundPacketsa1_0_16.class, ServerboundPacketsa1_0_15.class, ServerboundPacketsa1_0_17.class);
}
@ -37,13 +39,13 @@ public class Protocola1_0_16_2toa1_0_15 extends StatelessProtocol<ClientboundPac
wrapper.cancel();
final PacketWrapper handshake = PacketWrapper.create(ClientboundPacketsa1_0_16.HANDSHAKE, wrapper.user());
handshake.write(Typesb1_7_0_3.STRING, "-"); // server hash
handshake.send(Protocola1_0_16_2toa1_0_15.class);
handshake.send(Protocola1_0_15Toa1_0_16_2.class);
});
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocola1_0_16_2toa1_0_15.class, ClientboundPacketsa1_0_15::getPacket));
userConnection.put(new PreNettySplitter(Protocola1_0_15Toa1_0_16_2.class, ClientboundPacketsa1_0_15::getPacket));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_0_16_2toa1_0_15;
package net.raphimc.vialegacy.protocol.alpha.a1_0_15toa1_0_16_2.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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];

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_0_16_2toa1_0_15;
package net.raphimc.vialegacy.protocol.alpha.a1_0_15toa1_0_16_2.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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));

View File

@ -15,37 +15,38 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2;
package net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4;
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;
import net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.task.TimeLockTask;
import net.raphimc.vialegacy.protocols.alpha.protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.ClientboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocols.alpha.protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.ServerboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;
import net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.packet.ClientboundPacketsa1_0_16;
import net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.storage.TimeLockStorage;
import net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.task.TimeLockTask;
import net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1.packet.ClientboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1.packet.ServerboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.types.Types1_7_6;
public class Protocola1_0_17_1_0_17_4toa1_0_16_2 extends StatelessProtocol<ClientboundPacketsa1_0_16, ClientboundPacketsa1_0_17, ServerboundPacketsa1_0_17, ServerboundPacketsa1_0_17> {
public class Protocola1_0_16_2Toa1_0_17_1_0_17_4 extends StatelessProtocol<ClientboundPacketsa1_0_16, ClientboundPacketsa1_0_17, ServerboundPacketsa1_0_17, ServerboundPacketsa1_0_17> {
public Protocola1_0_17_1_0_17_4toa1_0_16_2() {
public Protocola1_0_16_2Toa1_0_17_1_0_17_4() {
super(ClientboundPacketsa1_0_16.class, ClientboundPacketsa1_0_17.class, ServerboundPacketsa1_0_17.class, ServerboundPacketsa1_0_17.class);
}
@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();
}
});
@ -60,7 +61,7 @@ public class Protocola1_0_17_1_0_17_4toa1_0_16_2 extends StatelessProtocol<Clien
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocola1_0_17_1_0_17_4toa1_0_16_2.class, ClientboundPacketsa1_0_16::getPacket));
userConnection.put(new PreNettySplitter(Protocola1_0_16_2Toa1_0_17_1_0_17_4.class, ClientboundPacketsa1_0_16::getPacket));
userConnection.put(new TimeLockStorage(0));
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2;
package net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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];

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.storage;
package net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.storage;
import com.viaversion.viaversion.api.connection.StorableObject;

View File

@ -15,19 +15,19 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_0_17_1_0_17_4toa1_0_16_2.task;
package net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.task;
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;
import net.raphimc.vialegacy.protocols.alpha.protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.ClientboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.Protocol1_6_1to1_5_2;
import net.raphimc.vialegacy.protocols.release.protocol1_6_2to1_6_1.ClientboundPackets1_6_1;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.PlayerInfoStorage;
import net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.Protocola1_0_16_2Toa1_0_17_1_0_17_4;
import net.raphimc.vialegacy.protocol.alpha.a1_0_16_2toa1_0_17_1_0_17_4.storage.TimeLockStorage;
import net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1.packet.ClientboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocol.release.r1_5_2tor1_6_1.Protocolr1_5_2Tor1_6_1;
import net.raphimc.vialegacy.protocol.release.r1_6_1tor1_6_2.packet.ClientboundPackets1_6_1;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.PlayerInfoStorage;
import java.util.logging.Level;
@ -43,18 +43,18 @@ public class TimeLockTask implements Runnable {
if (!info.getChannel().isActive()) return;
try {
if (info.getProtocolInfo().getPipeline().contains(Protocol1_6_1to1_5_2.class)) {
if (info.getProtocolInfo().getPipeline().contains(Protocolr1_5_2Tor1_6_1.class)) {
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
updateTime.send(Protocol1_6_1to1_5_2.class);
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(Protocolr1_5_2Tor1_6_1.class);
} else {
final PacketWrapper updateTime = PacketWrapper.create(ClientboundPacketsa1_0_17.TIME_UPDATE, info);
updateTime.write(Type.LONG, timeLockStorage.getTime()); // time
updateTime.send(Protocola1_0_17_1_0_17_4toa1_0_16_2.class);
final PacketWrapper updateTime = PacketWrapper.create(ClientboundPacketsa1_0_17.SET_TIME, info);
updateTime.write(Types.LONG, timeLockStorage.getTime()); // time
updateTime.send(Protocola1_0_16_2Toa1_0_17_1_0_17_4.class);
}
} catch (Throwable e) {
ViaLegacy.getPlatform().getLogger().log(Level.WARNING, "Error sending time update", e);

View File

@ -15,29 +15,31 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4;
package net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.ClientboundPacketsa1_1_0;
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.ServerboundPacketsa1_1_0;
import net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1.packet.ClientboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1.packet.ServerboundPacketsa1_0_17;
import net.raphimc.vialegacy.protocol.alpha.a1_1_0_1_1_2_1toa1_2_0_1_2_1_1.packet.ClientboundPacketsa1_1_0;
import net.raphimc.vialegacy.protocol.alpha.a1_1_0_1_1_2_1toa1_2_0_1_2_1_1.packet.ServerboundPacketsa1_1_0;
public class Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4 extends StatelessProtocol<ClientboundPacketsa1_0_17, ClientboundPacketsa1_1_0, ServerboundPacketsa1_0_17, ServerboundPacketsa1_1_0> {
public class Protocola1_0_17_1_0_17_4Toa1_1_0_1_1_2_1 extends StatelessProtocol<ClientboundPacketsa1_0_17, ClientboundPacketsa1_1_0, ServerboundPacketsa1_0_17, ServerboundPacketsa1_1_0> {
public Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4() {
public Protocola1_0_17_1_0_17_4Toa1_1_0_1_1_2_1() {
super(ClientboundPacketsa1_0_17.class, ClientboundPacketsa1_1_0.class, ServerboundPacketsa1_0_17.class, ServerboundPacketsa1_1_0.class);
}
@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);
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4.class, ClientboundPacketsa1_0_17::getPacket));
userConnection.put(new PreNettySplitter(Protocola1_0_17_1_0_17_4Toa1_1_0_1_1_2_1.class, ClientboundPacketsa1_0_17::getPacket));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4;
package net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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];

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_1_0_1_1_2_1toa1_0_17_1_0_17_4;
package net.raphimc.vialegacy.protocol.alpha.a1_0_17_1_0_17_4toa1_1_0_1_1_2_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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));

View File

@ -15,51 +15,53 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1;
package net.raphimc.vialegacy.protocol.alpha.a1_1_0_1_1_2_1toa1_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_2toa1_2_0_1_2_1_1.ClientboundPacketsa1_2_0;
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_2toa1_2_0_1_2_1_1.ServerboundPacketsa1_2_0;
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.types.Typesb1_7_0_3;
import net.raphimc.vialegacy.protocol.alpha.a1_1_0_1_1_2_1toa1_2_0_1_2_1_1.packet.ClientboundPacketsa1_1_0;
import net.raphimc.vialegacy.protocol.alpha.a1_1_0_1_1_2_1toa1_2_0_1_2_1_1.packet.ServerboundPacketsa1_1_0;
import net.raphimc.vialegacy.protocol.alpha.a1_2_0_1_2_1_1toa1_2_2.packet.ClientboundPacketsa1_2_0;
import net.raphimc.vialegacy.protocol.alpha.a1_2_0_1_2_1_1toa1_2_2.packet.ServerboundPacketsa1_2_0;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.types.Typesb1_7_0_3;
public class Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1 extends StatelessProtocol<ClientboundPacketsa1_1_0, ClientboundPacketsa1_2_0, ServerboundPacketsa1_1_0, ServerboundPacketsa1_2_0> {
public class Protocola1_1_0_1_1_2_1Toa1_2_0_1_2_1_1 extends StatelessProtocol<ClientboundPacketsa1_1_0, ClientboundPacketsa1_2_0, ServerboundPacketsa1_1_0, ServerboundPacketsa1_2_0> {
public Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1() {
public Protocola1_1_0_1_1_2_1Toa1_2_0_1_2_1_1() {
super(ClientboundPacketsa1_1_0.class, ClientboundPacketsa1_2_0.class, ServerboundPacketsa1_1_0.class, ServerboundPacketsa1_2_0.class);
}
@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
}
});
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1.class, ClientboundPacketsa1_1_0::getPacket));
userConnection.put(new PreNettySplitter(Protocola1_1_0_1_1_2_1Toa1_2_0_1_2_1_1.class, ClientboundPacketsa1_1_0::getPacket));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1;
package net.raphimc.vialegacy.protocol.alpha.a1_1_0_1_1_2_1toa1_2_0_1_2_1_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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();

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_0_1_2_1_1toa1_1_0_1_1_2_1;
package net.raphimc.vialegacy.protocol.alpha.a1_1_0_1_1_2_1toa1_2_0_1_2_1_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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();

View File

@ -15,48 +15,50 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_2toa1_2_0_1_2_1_1;
package net.raphimc.vialegacy.protocol.alpha.a1_2_0_1_2_1_1toa1_2_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.protocola1_2_3_1_2_3_4toa1_2_2.ClientboundPacketsa1_2_2;
import net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_1_2_3_4toa1_2_2.ServerboundPacketsa1_2_2;
import net.raphimc.vialegacy.protocol.alpha.a1_2_0_1_2_1_1toa1_2_2.packet.ClientboundPacketsa1_2_0;
import net.raphimc.vialegacy.protocol.alpha.a1_2_0_1_2_1_1toa1_2_2.packet.ServerboundPacketsa1_2_0;
import net.raphimc.vialegacy.protocol.alpha.a1_2_2toa1_2_3_1_2_3_4.packet.ClientboundPacketsa1_2_2;
import net.raphimc.vialegacy.protocol.alpha.a1_2_2toa1_2_3_1_2_3_4.packet.ServerboundPacketsa1_2_2;
public class Protocola1_2_2toa1_2_0_1_2_1_1 extends StatelessProtocol<ClientboundPacketsa1_2_0, ClientboundPacketsa1_2_2, ServerboundPacketsa1_2_0, ServerboundPacketsa1_2_2> {
public class Protocola1_2_0_1_2_1_1Toa1_2_2 extends StatelessProtocol<ClientboundPacketsa1_2_0, ClientboundPacketsa1_2_2, ServerboundPacketsa1_2_0, ServerboundPacketsa1_2_2> {
public Protocola1_2_2toa1_2_0_1_2_1_1() {
public Protocola1_2_0_1_2_1_1Toa1_2_2() {
super(ClientboundPacketsa1_2_0.class, ClientboundPacketsa1_2_2.class, ServerboundPacketsa1_2_0.class, ServerboundPacketsa1_2_2.class);
}
@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
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocola1_2_2toa1_2_0_1_2_1_1.class, ClientboundPacketsa1_2_0::getPacket));
userConnection.put(new PreNettySplitter(Protocola1_2_0_1_2_1_1Toa1_2_2.class, ClientboundPacketsa1_2_0::getPacket));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_2toa1_2_0_1_2_1_1;
package net.raphimc.vialegacy.protocol.alpha.a1_2_0_1_2_1_1toa1_2_2.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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();

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_2toa1_2_0_1_2_1_1;
package net.raphimc.vialegacy.protocol.alpha.a1_2_0_1_2_1_1toa1_2_2.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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();

View File

@ -15,40 +15,42 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_1_2_3_4toa1_2_2;
package net.raphimc.vialegacy.protocol.alpha.a1_2_2toa1_2_3_1_2_3_4;
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;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.ServerboundPacketsa1_2_6;
import net.raphimc.vialegacy.protocol.alpha.a1_2_2toa1_2_3_1_2_3_4.packet.ClientboundPacketsa1_2_2;
import net.raphimc.vialegacy.protocol.alpha.a1_2_2toa1_2_3_1_2_3_4.packet.ServerboundPacketsa1_2_2;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_1_2_3_4toa1_2_3_5_1_2_6.packet.ClientboundPacketsa1_2_3;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.packet.ServerboundPacketsa1_2_6;
public class Protocola1_2_3_1_2_3_4toa1_2_2 extends StatelessProtocol<ClientboundPacketsa1_2_2, ClientboundPacketsa1_2_3, ServerboundPacketsa1_2_2, ServerboundPacketsa1_2_6> {
public class Protocola1_2_2Toa1_2_3_1_2_3_4 extends StatelessProtocol<ClientboundPacketsa1_2_2, ClientboundPacketsa1_2_3, ServerboundPacketsa1_2_2, ServerboundPacketsa1_2_6> {
public Protocola1_2_3_1_2_3_4toa1_2_2() {
public Protocola1_2_2Toa1_2_3_1_2_3_4() {
super(ClientboundPacketsa1_2_2.class, ClientboundPacketsa1_2_3.class, ServerboundPacketsa1_2_2.class, ServerboundPacketsa1_2_6.class);
}
@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.send(Protocola1_2_2Toa1_2_3_1_2_3_4.class);
updateHealth.send(Protocola1_2_2Toa1_2_3_1_2_3_4.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);
@ -56,7 +58,7 @@ public class Protocola1_2_3_1_2_3_4toa1_2_2 extends StatelessProtocol<Clientboun
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocola1_2_3_1_2_3_4toa1_2_2.class, ClientboundPacketsa1_2_2::getPacket));
userConnection.put(new PreNettySplitter(Protocola1_2_2Toa1_2_3_1_2_3_4.class, ClientboundPacketsa1_2_2::getPacket));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_1_2_3_4toa1_2_2;
package net.raphimc.vialegacy.protocol.alpha.a1_2_2toa1_2_3_1_2_3_4.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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();

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_1_2_3_4toa1_2_2;
package net.raphimc.vialegacy.protocol.alpha.a1_2_2toa1_2_3_1_2_3_4.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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();

View File

@ -15,38 +15,39 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_1_2_3_4toa1_2_3_5_1_2_6;
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;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.ServerboundPacketsa1_2_6;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_1_2_3_4toa1_2_3_5_1_2_6.packet.ClientboundPacketsa1_2_3;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.packet.ClientboundPacketsa1_2_6;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.packet.ServerboundPacketsa1_2_6;
public class Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4 extends StatelessProtocol<ClientboundPacketsa1_2_3, ClientboundPacketsa1_2_6, ServerboundPacketsa1_2_6, ServerboundPacketsa1_2_6> {
public class Protocola1_2_3_1_2_3_4Toa1_2_3_5_1_2_6 extends StatelessProtocol<ClientboundPacketsa1_2_3, ClientboundPacketsa1_2_6, ServerboundPacketsa1_2_6, ServerboundPacketsa1_2_6> {
public Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4() {
public Protocola1_2_3_1_2_3_4Toa1_2_3_5_1_2_6() {
super(ClientboundPacketsa1_2_3.class, ClientboundPacketsa1_2_6.class, ServerboundPacketsa1_2_6.class, ServerboundPacketsa1_2_6.class);
}
@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
}
});
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4.class, ClientboundPacketsa1_2_3::getPacket));
userConnection.put(new PreNettySplitter(Protocola1_2_3_1_2_3_4Toa1_2_3_5_1_2_6.class, ClientboundPacketsa1_2_3::getPacket));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocola1_2_3_5_1_2_6toa1_2_3_1_2_3_4;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_1_2_3_4toa1_2_3_5_1_2_6.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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();

View File

@ -15,8 +15,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.Position;
@ -25,49 +27,50 @@ 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;
import net.raphimc.vialegacy.api.data.ItemList1_6;
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.data.AlphaItems;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers.AlphaInventoryProvider;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers.TrackingAlphaInventoryProvider;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage.AlphaInventoryTracker;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage.InventoryStorage;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.task.AlphaInventoryUpdateTask;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.ClientboundPacketsb1_1;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.ServerboundPacketsb1_1;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.types.Typesb1_1;
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_2_1_3to1_1.Protocol1_2_1_3to1_1;
import net.raphimc.vialegacy.protocols.release.protocol1_2_4_5to1_2_1_3.ClientboundPackets1_2_1;
import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.data.EntityList;
import net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types.Types1_3_1;
import net.raphimc.vialegacy.protocols.release.protocol1_4_4_5to1_4_2.types.Types1_4_2;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ChunkTracker;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.PlayerInfoStorage;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.data.AlphaItems;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.packet.ClientboundPacketsa1_2_6;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.packet.ServerboundPacketsa1_2_6;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.provider.AlphaInventoryProvider;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.provider.TrackingAlphaInventoryProvider;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.storage.AlphaInventoryTracker;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.storage.InventoryStorage;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.task.AlphaInventoryUpdateTask;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet.ClientboundPacketsb1_1;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet.ServerboundPacketsb1_1;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.types.Typesb1_1;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.types.Typesb1_7_0_3;
import net.raphimc.vialegacy.protocol.release.r1_1tor1_2_1_3.Protocolr1_1Tor1_2_1_3;
import net.raphimc.vialegacy.protocol.release.r1_2_1_3tor1_2_4_5.packet.ClientboundPackets1_2_1;
import net.raphimc.vialegacy.protocol.release.r1_2_4_5tor1_3_1_2.data.EntityList1_2_4;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.types.Types1_3_1;
import net.raphimc.vialegacy.protocol.release.r1_4_2tor1_4_4_5.types.Types1_4_2;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ChunkTracker;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.PlayerInfoStorage;
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.types.Types1_7_6;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<ClientboundPacketsa1_2_6, ClientboundPacketsb1_1, ServerboundPacketsa1_2_6, ServerboundPacketsb1_1> {
public class Protocola1_2_3_5_1_2_6Tob1_0_1_1_1 extends StatelessProtocol<ClientboundPacketsa1_2_6, ClientboundPacketsb1_1, ServerboundPacketsa1_2_6, ServerboundPacketsb1_1> {
public Protocolb1_0_1_1_1toa1_2_3_5_1_2_6() {
public Protocola1_2_3_5_1_2_6Tob1_0_1_1_1() {
super(ClientboundPacketsa1_2_6.class, ClientboundPacketsb1_1.class, ServerboundPacketsa1_2_6.class, ServerboundPacketsb1_1.class);
}
@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 +97,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 +112,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,56 +133,56 @@ 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")) {
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.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)) {
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(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
} else if (block.getId() == BlockList1_6.mobSpawner.blockId() || blockName.equals("MobSpawner")) {
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocolr1_1Tor1_2_1_3.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.send(Protocol1_2_1_3to1_1.class);
spawnerData.write(Types.BYTE, (byte) 1); // type
spawnerData.write(Types.INT, EntityList1_2_4.getEntityId(tag.getString("EntityId"))); // entity id
spawnerData.write(Types.INT, 0); // unused
spawnerData.write(Types.INT, 0); // unused
spawnerData.send(Protocolr1_1Tor1_2_1_3.class);
}
} else if (block.getId() == BlockList1_6.chest.blockID || blockName.equals("Chest")) {
} else if (block.getId() == BlockList1_6.chest.blockId() || blockName.equals("Chest")) {
final Item[] chestItems = new Item[3 * 9];
readItemsFromTag(tag, chestItems);
tracker.containers.put(pos, chestItems);
if (pos.equals(tracker.openContainerPos)) sendWindowItems(wrapper.user(), InventoryStorage.CHEST_WID, chestItems);
} else if (block.getId() == BlockList1_6.furnaceIdle.blockID || block.getId() == BlockList1_6.furnaceBurning.blockID || blockName.equals("Furnace")) {
} else if (block.getId() == BlockList1_6.furnaceIdle.blockId() || block.getId() == BlockList1_6.furnaceBurning.blockId() || blockName.equals("Furnace")) {
final Item[] furnaceItems = new Item[3];
readItemsFromTag(tag, furnaceItems);
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 +190,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,68 +215,68 @@ 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);
if (direction == 255) return;
final IdAndData block = wrapper.user().get(ChunkTracker.class).getBlockNotNull(pos);
if (block.getId() != BlockList1_6.furnaceIdle.blockID && block.getId() != BlockList1_6.furnaceBurning.blockID && block.getId() != BlockList1_6.chest.blockID && block.getId() != BlockList1_6.workbench.blockID) {
if (block.getId() != BlockList1_6.furnaceIdle.blockId() && block.getId() != BlockList1_6.furnaceBurning.blockId() && block.getId() != BlockList1_6.chest.blockId() && block.getId() != BlockList1_6.workbench.blockId()) {
return;
}
final Item[] containerItems = tracker.containers.get(tracker.openContainerPos = pos);
if (containerItems == null && block.getId() != BlockList1_6.workbench.blockID) {
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);
chatMessage.send(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
return;
}
final PacketWrapper openWindow = PacketWrapper.create(ClientboundPacketsb1_1.OPEN_WINDOW, 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
final PacketWrapper openWindow = PacketWrapper.create(ClientboundPacketsb1_1.OPEN_SCREEN, wrapper.user());
if (block.getId() == BlockList1_6.chest.blockId()) {
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
} else if (block.getId() == BlockList1_6.workbench.blockId()) {
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);
openWindow.send(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
if (block.getId() != BlockList1_6.workbench.blockID) {
sendWindowItems(wrapper.user(), block.getId() == BlockList1_6.chest.blockID ? InventoryStorage.CHEST_WID : InventoryStorage.FURNACE_WID, containerItems);
if (block.getId() != BlockList1_6.workbench.blockId()) {
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 +286,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);
@ -316,92 +319,91 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
tracker.containers.put(tracker.openContainerPos, containerItems);
final CompoundTag tag = new CompoundTag();
tag.put("id", new StringTag(windowId == InventoryStorage.CHEST_WID ? "Chest" : "Furnace"));
tag.put("x", new IntTag(tracker.openContainerPos.x()));
tag.put("y", new IntTag(tracker.openContainerPos.y()));
tag.put("z", new IntTag(tracker.openContainerPos.z()));
tag.putString("id", windowId == InventoryStorage.CHEST_WID ? "Chest" : "Furnace");
tag.putInt("x", tracker.openContainerPos.x());
tag.putInt("y", tracker.openContainerPos.y());
tag.putInt("z", 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();
tag.put("id", new StringTag("Sign"));
tag.put("x", new IntTag(pos.x()));
tag.put("y", new IntTag(pos.y()));
tag.put("z", new IntTag(pos.z()));
tag.put("Text1", new StringTag(wrapper.read(Typesb1_7_0_3.STRING))); // line 1
tag.put("Text2", new StringTag(wrapper.read(Typesb1_7_0_3.STRING))); // line 2
tag.put("Text3", new StringTag(wrapper.read(Typesb1_7_0_3.STRING))); // line 3
tag.put("Text4", new StringTag(wrapper.read(Typesb1_7_0_3.STRING))); // line 4
tag.putString("id", "Sign");
tag.putInt("x", pos.x());
tag.putInt("y", pos.y());
tag.putInt("z", pos.z());
tag.putString("Text1", wrapper.read(Typesb1_7_0_3.STRING)); // line 1
tag.putString("Text2", wrapper.read(Typesb1_7_0_3.STRING)); // line 2
tag.putString("Text3", wrapper.read(Typesb1_7_0_3.STRING)); // line 3
tag.putString("Text4", 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.putByte("Slot", (byte) i);
itemTag.putShort("id", (short) item.identifier());
itemTag.putByte("Count", (byte) item.amount());
itemTag.putShort("Damage", 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);
windowItems.send(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
final AlphaInventoryTracker inventoryTracker = user.get(AlphaInventoryTracker.class);
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
windowProperty.send(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
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(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
}
private short getBurningTime(final Item item) {
if (item == null) return 0;
final int id = item.identifier();
if (id == BlockList1_6.bookShelf.blockID || id == BlockList1_6.chest.blockID || id == BlockList1_6.fence.blockID || id == BlockList1_6.jukebox.blockID || id == BlockList1_6.wood.blockID || id == BlockList1_6.planks.blockID || id == BlockList1_6.doorWood.blockID || id == BlockList1_6.signWall.blockID || id == BlockList1_6.signPost.blockID || id == BlockList1_6.workbench.blockID) {
if (id == BlockList1_6.bookShelf.blockId() || id == BlockList1_6.chest.blockId() || id == BlockList1_6.fence.blockId() || id == BlockList1_6.jukebox.blockId() || id == BlockList1_6.wood.blockId() || id == BlockList1_6.planks.blockId() || id == BlockList1_6.doorWood.blockId() || id == BlockList1_6.signWall.blockId() || id == BlockList1_6.signPost.blockId() || id == BlockList1_6.workbench.blockId()) {
return 300;
} else if (id == ItemList1_6.stick.itemID) {
} else if (id == ItemList1_6.stick.itemId()) {
return 100;
} else if (id == ItemList1_6.coal.itemID) {
} else if (id == ItemList1_6.coal.itemId()) {
return 1600;
} else if (id == ItemList1_6.bucketLava.itemID) {
} else if (id == ItemList1_6.bucketLava.itemId()) {
return 20000;
}
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,16 +429,16 @@ 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.sendToServer(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
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(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
}
public static Item[] reverseArray(final Item[] array) {
@ -456,7 +458,7 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
}
public static Item[] copyItems(final Item[] items) {
return Arrays.stream(items).map(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6::copyItem).toArray(Item[]::new);
return Arrays.stream(items).map(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1::copyItem).toArray(Item[]::new);
}
public static Item fixItem(final Item item) {
@ -481,7 +483,7 @@ public class Protocolb1_0_1_1_1toa1_2_3_5_1_2_6 extends StatelessProtocol<Client
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class, ClientboundPacketsa1_2_6::getPacket));
userConnection.put(new PreNettySplitter(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class, ClientboundPacketsa1_2_6::getPacket));
userConnection.put(new InventoryStorage());
if (Via.getManager().getProviders().get(AlphaInventoryProvider.class).usesInventoryTracker()) {

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.data;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.data;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.libs.fastutil.ints.*;
@ -312,7 +312,7 @@ public class AlphaItems {
}
});
PLACE_ACTION.put(290, (i, d) -> {
if (d.value().getId() == BlockList1_6.grass.blockID || d.value().getId() == BlockList1_6.dirt.blockID) {
if (d.value().getId() == BlockList1_6.grass.blockId() || d.value().getId() == BlockList1_6.dirt.blockId()) {
i.setData((short) (i.data() + 1));
if (i.data() > 32) {
i.setAmount(i.amount() - 1);
@ -320,7 +320,7 @@ public class AlphaItems {
}
});
PLACE_ACTION.put(291, (i, d) -> {
if (d.value().getId() == BlockList1_6.grass.blockID || d.value().getId() == BlockList1_6.dirt.blockID) {
if (d.value().getId() == BlockList1_6.grass.blockId() || d.value().getId() == BlockList1_6.dirt.blockId()) {
i.setData((short) (i.data() + 1));
if (i.data() > 64) {
i.setAmount(i.amount() - 1);
@ -328,7 +328,7 @@ public class AlphaItems {
}
});
PLACE_ACTION.put(292, (i, d) -> {
if (d.value().getId() == BlockList1_6.grass.blockID || d.value().getId() == BlockList1_6.dirt.blockID) {
if (d.value().getId() == BlockList1_6.grass.blockId() || d.value().getId() == BlockList1_6.dirt.blockId()) {
i.setData((short) (i.data() + 1));
if (i.data() > 128) {
i.setAmount(i.amount() - 1);
@ -336,7 +336,7 @@ public class AlphaItems {
}
});
PLACE_ACTION.put(293, (i, d) -> {
if (d.value().getId() == BlockList1_6.grass.blockID || d.value().getId() == BlockList1_6.dirt.blockID) {
if (d.value().getId() == BlockList1_6.grass.blockId() || d.value().getId() == BlockList1_6.dirt.blockId()) {
i.setData((short) (i.data() + 1));
if (i.data() > 256) {
i.setAmount(i.amount() - 1);
@ -344,7 +344,7 @@ public class AlphaItems {
}
});
PLACE_ACTION.put(294, (i, d) -> {
if (d.value().getId() == BlockList1_6.grass.blockID || d.value().getId() == BlockList1_6.dirt.blockID) {
if (d.value().getId() == BlockList1_6.grass.blockId() || d.value().getId() == BlockList1_6.dirt.blockId()) {
i.setData((short) (i.data() + 1));
if (i.data() > 64) {
i.setAmount(i.amount() - 1);
@ -352,7 +352,7 @@ public class AlphaItems {
}
});
PLACE_ACTION.put(295, (i, d) -> {
if (d.keyInt() == 1 && d.value().getId() == BlockList1_6.tilledField.blockID) {
if (d.keyInt() == 1 && d.value().getId() == BlockList1_6.tilledField.blockId()) {
i.setAmount(i.amount() - 1);
}
});
@ -363,7 +363,7 @@ public class AlphaItems {
if (d.keyInt() == 1) i.setAmount(i.amount() - 1);
});
PLACE_ACTION.put(328, (i, d) -> {
if (d.value().getId() == BlockList1_6.rail.blockID) {
if (d.value().getId() == BlockList1_6.rail.blockId()) {
i.setAmount(i.amount() - 1);
}
});
@ -371,22 +371,22 @@ public class AlphaItems {
if (d.keyInt() == 1) i.setAmount(i.amount() - 1);
});
PLACE_ACTION.put(342, (i, d) -> {
if (d.value().getId() == BlockList1_6.rail.blockID) {
if (d.value().getId() == BlockList1_6.rail.blockId()) {
i.setAmount(i.amount() - 1);
}
});
PLACE_ACTION.put(343, (i, d) -> {
if (d.value().getId() == BlockList1_6.rail.blockID) {
if (d.value().getId() == BlockList1_6.rail.blockId()) {
i.setAmount(i.amount() - 1);
}
});
PLACE_ACTION.put(2256, (i, d) -> {
if (d.value().getId() == BlockList1_6.jukebox.blockID && d.value().getData() == 0) {
if (d.value().getId() == BlockList1_6.jukebox.blockId() && d.value().getData() == 0) {
i.setAmount(i.amount() - 1);
}
});
PLACE_ACTION.put(2257, (i, d) -> {
if (d.value().getId() == BlockList1_6.jukebox.blockID && d.value().getData() == 0) {
if (d.value().getId() == BlockList1_6.jukebox.blockId() && d.value().getData() == 0) {
i.setAmount(i.amount() - 1);
}
});

View File

@ -0,0 +1,182 @@
/*
* This file is part of ViaLegacy - https://github.com/RaphiMC/ViaLegacy
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.data;
import com.viaversion.viaversion.api.minecraft.item.DataItem;
import com.viaversion.viaversion.api.minecraft.item.Item;
import net.raphimc.vialegacy.api.data.BlockList1_6;
import net.raphimc.vialegacy.api.data.ItemList1_6;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.model.CraftingRecipe;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class CraftingManager {
private static final List<CraftingRecipe> recipes = new ArrayList<>();
private static final String[][] tools_pattern = new String[][]{{"XXX", " # ", " # "}, {"X", "#", "#"}, {"XX", "X#", " #"}, {"XX", " #", " #"}};
private static final int[][] tools_ingredients = new int[][]{{BlockList1_6.planks.blockId(), BlockList1_6.cobblestone.blockId(), ItemList1_6.ingotIron.itemId(), ItemList1_6.diamond.itemId(), ItemList1_6.ingotGold.itemId()}, {ItemList1_6.pickaxeWood.itemId(), ItemList1_6.pickaxeStone.itemId(), ItemList1_6.pickaxeIron.itemId(), ItemList1_6.pickaxeDiamond.itemId(), ItemList1_6.pickaxeGold.itemId()}, {ItemList1_6.shovelWood.itemId(), ItemList1_6.shovelStone.itemId(), ItemList1_6.shovelIron.itemId(), ItemList1_6.shovelDiamond.itemId(), ItemList1_6.shovelGold.itemId()}, {ItemList1_6.axeWood.itemId(), ItemList1_6.axeStone.itemId(), ItemList1_6.axeIron.itemId(), ItemList1_6.axeDiamond.itemId(), ItemList1_6.axeGold.itemId()}, {ItemList1_6.hoeWood.itemId(), ItemList1_6.hoeStone.itemId(), ItemList1_6.hoeIron.itemId(), ItemList1_6.hoeDiamond.itemId(), ItemList1_6.hoeGold.itemId()}};
private static final String[][] weapons_pattern = new String[][]{{"X", "X", "#"}};
private static final int[][] weapons_ingredients = new int[][]{{BlockList1_6.planks.blockId(), BlockList1_6.cobblestone.blockId(), ItemList1_6.ingotIron.itemId(), ItemList1_6.diamond.itemId(), ItemList1_6.ingotGold.itemId()}, {ItemList1_6.swordWood.itemId(), ItemList1_6.swordStone.itemId(), ItemList1_6.swordIron.itemId(), ItemList1_6.swordDiamond.itemId(), ItemList1_6.swordGold.itemId()}};
private static final int[][] ingots_ingredients = new int[][]{{BlockList1_6.blockGold.blockId(), ItemList1_6.ingotGold.itemId()}, {BlockList1_6.blockIron.blockId(), ItemList1_6.ingotIron.itemId()}, {BlockList1_6.blockDiamond.blockId(), ItemList1_6.diamond.itemId()}};
private static final String[][] armor_pattern = new String[][]{{"XXX", "X X"}, {"X X", "XXX", "XXX"}, {"XXX", "X X", "X X"}, {"X X", "X X"}};
private static final int[][] armor_ingredients = new int[][]{{ItemList1_6.leather.itemId(), BlockList1_6.fire.blockId(), ItemList1_6.ingotIron.itemId(), ItemList1_6.diamond.itemId(), ItemList1_6.ingotGold.itemId()}, {ItemList1_6.helmetLeather.itemId(), ItemList1_6.helmetChain.itemId(), ItemList1_6.helmetIron.itemId(), ItemList1_6.helmetDiamond.itemId(), ItemList1_6.helmetGold.itemId()}, {ItemList1_6.plateLeather.itemId(), ItemList1_6.plateChain.itemId(), ItemList1_6.plateIron.itemId(), ItemList1_6.plateDiamond.itemId(), ItemList1_6.plateGold.itemId()}, {ItemList1_6.legsLeather.itemId(), ItemList1_6.legsChain.itemId(), ItemList1_6.legsIron.itemId(), ItemList1_6.legsDiamond.itemId(), ItemList1_6.legsGold.itemId()}, {ItemList1_6.bootsLeather.itemId(), ItemList1_6.bootsChain.itemId(), ItemList1_6.bootsIron.itemId(), ItemList1_6.bootsDiamond.itemId(), ItemList1_6.bootsGold.itemId()}};
static {
for (int i = 0; i < tools_ingredients[0].length; ++i) {
for (int i1 = 0; i1 < tools_ingredients.length - 1; ++i1) {
addRecipe(new DataItem(tools_ingredients[i1 + 1][i], (byte) 1, (short) 0, null), tools_pattern[i1], '#', ItemList1_6.stick.itemId(), 'X', tools_ingredients[0][i]);
}
}
for (int i = 0; i < weapons_ingredients[0].length; ++i) {
for (int i1 = 0; i1 < weapons_ingredients.length - 1; ++i1) {
addRecipe(new DataItem(weapons_ingredients[i1 + 1][i], (byte) 1, (short) 0, null), weapons_pattern[i1], '#', ItemList1_6.stick.itemId(), 'X', weapons_ingredients[0][i]);
}
}
addRecipe(new DataItem(ItemList1_6.bow.itemId(), (byte) 1, (short) 0, null), " #X", "# X", " #X", 'X', ItemList1_6.silk.itemId(), '#', ItemList1_6.stick.itemId());
addRecipe(new DataItem(ItemList1_6.arrow.itemId(), (byte) 4, (short) 0, null), "X", "#", "Y", 'Y', ItemList1_6.feather.itemId(), 'X', ItemList1_6.flint.itemId(), '#', ItemList1_6.stick.itemId());
for (int[] ingots_ingredient : ingots_ingredients) {
addRecipe(new DataItem(ingots_ingredient[0], (byte) 1, (short) 0, null), "###", "###", "###", '#', ingots_ingredient[1]);
addRecipe(new DataItem(ingots_ingredient[1], (byte) 9, (short) 0, null), "#", '#', ingots_ingredient[0]);
}
addRecipe(new DataItem(ItemList1_6.bowlSoup.itemId(), (byte) 1, (short) 0, null), "Y", "X", "#", 'X', BlockList1_6.mushroomBrown.blockId(), 'Y', BlockList1_6.mushroomRed.blockId(), '#', ItemList1_6.bowlEmpty.itemId());
addRecipe(new DataItem(ItemList1_6.bowlSoup.itemId(), (byte) 1, (short) 0, null), "Y", "X", "#", 'X', BlockList1_6.mushroomRed.blockId(), 'Y', BlockList1_6.mushroomBrown.blockId(), '#', ItemList1_6.bowlEmpty.itemId());
addRecipe(new DataItem(BlockList1_6.chest.blockId(), (byte) 1, (short) 0, null), "###", "# #", "###", '#', BlockList1_6.planks.blockId());
addRecipe(new DataItem(BlockList1_6.furnaceIdle.blockId(), (byte) 1, (short) 0, null), "###", "# #", "###", '#', BlockList1_6.cobblestone.blockId());
addRecipe(new DataItem(BlockList1_6.workbench.blockId(), (byte) 1, (short) 0, null), "##", "##", '#', BlockList1_6.planks.blockId());
for (int i = 0; i < armor_ingredients[0].length; ++i) {
for (int i1 = 0; i1 < armor_ingredients.length - 1; ++i1) {
addRecipe(new DataItem(armor_ingredients[i1 + 1][i], (byte) 1, (short) 0, null), armor_pattern[i1], 'X', armor_ingredients[0][i]);
}
}
addRecipe(new DataItem(ItemList1_6.paper.itemId(), (byte) 3, (short) 0, null), "###", '#', ItemList1_6.reed.itemId());
addRecipe(new DataItem(ItemList1_6.book.itemId(), (byte) 1, (short) 0, null), "#", "#", "#", '#', ItemList1_6.paper.itemId());
addRecipe(new DataItem(BlockList1_6.fence.blockId(), (byte) 2, (short) 0, null), "###", "###", '#', ItemList1_6.stick.itemId());
addRecipe(new DataItem(BlockList1_6.jukebox.blockId(), (byte) 1, (short) 0, null), "###", "#X#", "###", '#', BlockList1_6.planks.blockId(), 'X', ItemList1_6.diamond.itemId());
addRecipe(new DataItem(BlockList1_6.bookShelf.blockId(), (byte) 1, (short) 0, null), "###", "XXX", "###", '#', BlockList1_6.planks.blockId(), 'X', ItemList1_6.book.itemId());
addRecipe(new DataItem(BlockList1_6.blockSnow.blockId(), (byte) 1, (short) 0, null), "##", "##", '#', ItemList1_6.snowball.itemId());
addRecipe(new DataItem(BlockList1_6.blockClay.blockId(), (byte) 1, (short) 0, null), "##", "##", '#', ItemList1_6.clay.itemId());
addRecipe(new DataItem(BlockList1_6.brick.blockId(), (byte) 1, (short) 0, null), "##", "##", '#', ItemList1_6.brick.itemId());
addRecipe(new DataItem(BlockList1_6.glowStone.blockId(), (byte) 1, (short) 0, null), "###", "###", "###", '#', ItemList1_6.glowstone.itemId());
addRecipe(new DataItem(BlockList1_6.cloth.blockId(), (byte) 1, (short) 0, null), "###", "###", "###", '#', ItemList1_6.silk.itemId());
addRecipe(new DataItem(BlockList1_6.tnt.blockId(), (byte) 1, (short) 0, null), "X#X", "#X#", "X#X", 'X', ItemList1_6.gunpowder.itemId(), '#', BlockList1_6.sand.blockId());
addRecipe(new DataItem(BlockList1_6.stoneSingleSlab.blockId(), (byte) 3, (short) 0, null), "###", '#', BlockList1_6.cobblestone.blockId());
addRecipe(new DataItem(BlockList1_6.ladder.blockId(), (byte) 1, (short) 0, null), "# #", "###", "# #", '#', ItemList1_6.stick.itemId());
addRecipe(new DataItem(ItemList1_6.doorWood.itemId(), (byte) 1, (short) 0, null), "##", "##", "##", '#', BlockList1_6.planks.blockId());
addRecipe(new DataItem(ItemList1_6.doorIron.itemId(), (byte) 1, (short) 0, null), "##", "##", "##", '#', ItemList1_6.ingotIron.itemId());
addRecipe(new DataItem(ItemList1_6.sign.itemId(), (byte) 1, (short) 0, null), "###", "###", " X ", '#', BlockList1_6.planks.blockId(), 'X', ItemList1_6.stick.itemId());
addRecipe(new DataItem(BlockList1_6.planks.blockId(), (byte) 4, (short) 0, null), "#", '#', BlockList1_6.wood.blockId());
addRecipe(new DataItem(ItemList1_6.stick.itemId(), (byte) 4, (short) 0, null), "#", "#", '#', BlockList1_6.planks.blockId());
addRecipe(new DataItem(BlockList1_6.torchWood.blockId(), (byte) 4, (short) 0, null), "X", "#", 'X', ItemList1_6.coal.itemId(), '#', ItemList1_6.stick.itemId());
addRecipe(new DataItem(ItemList1_6.bowlEmpty.itemId(), (byte) 4, (short) 0, null), "# #", " # ", '#', BlockList1_6.planks.blockId());
addRecipe(new DataItem(BlockList1_6.rail.blockId(), (byte) 16, (short) 0, null), "X X", "X#X", "X X", 'X', ItemList1_6.ingotIron.itemId(), '#', ItemList1_6.stick.itemId());
addRecipe(new DataItem(ItemList1_6.minecartEmpty.itemId(), (byte) 1, (short) 0, null), "# #", "###", '#', ItemList1_6.ingotIron.itemId());
addRecipe(new DataItem(BlockList1_6.pumpkinLantern.blockId(), (byte) 1, (short) 0, null), "A", "B", 'A', BlockList1_6.pumpkin.blockId(), 'B', BlockList1_6.torchWood.blockId());
addRecipe(new DataItem(ItemList1_6.minecartCrate.itemId(), (byte) 1, (short) 0, null), "A", "B", 'A', BlockList1_6.chest.blockId(), 'B', ItemList1_6.minecartEmpty.itemId());
addRecipe(new DataItem(ItemList1_6.minecartPowered.itemId(), (byte) 1, (short) 0, null), "A", "B", 'A', BlockList1_6.furnaceIdle.blockId(), 'B', ItemList1_6.minecartEmpty.itemId());
addRecipe(new DataItem(ItemList1_6.boat.itemId(), (byte) 1, (short) 0, null), "# #", "###", '#', BlockList1_6.planks.blockId());
addRecipe(new DataItem(ItemList1_6.bucketEmpty.itemId(), (byte) 1, (short) 0, null), "# #", " # ", '#', ItemList1_6.ingotIron.itemId());
addRecipe(new DataItem(ItemList1_6.flintAndSteel.itemId(), (byte) 1, (short) 0, null), "A ", " B", 'A', ItemList1_6.ingotIron.itemId(), 'B', ItemList1_6.flint.itemId());
addRecipe(new DataItem(ItemList1_6.bread.itemId(), (byte) 1, (short) 0, null), "###", '#', ItemList1_6.wheat.itemId());
addRecipe(new DataItem(BlockList1_6.stairsWoodOak.blockId(), (byte) 4, (short) 0, null), "# ", "## ", "###", '#', BlockList1_6.planks.blockId());
addRecipe(new DataItem(ItemList1_6.fishingRod.itemId(), (byte) 1, (short) 0, null), " #", " #X", "# X", '#', ItemList1_6.stick.itemId(), 'X', ItemList1_6.silk.itemId());
addRecipe(new DataItem(BlockList1_6.stairsCobblestone.blockId(), (byte) 4, (short) 0, null), "# ", "## ", "###", '#', BlockList1_6.cobblestone.blockId());
addRecipe(new DataItem(ItemList1_6.painting.itemId(), (byte) 1, (short) 0, null), "###", "#X#", "###", '#', ItemList1_6.stick.itemId(), 'X', BlockList1_6.cloth.blockId());
addRecipe(new DataItem(ItemList1_6.appleGold.itemId(), (byte) 1, (short) 0, null), "###", "#X#", "###", '#', BlockList1_6.blockGold.blockId(), 'X', ItemList1_6.appleRed.itemId());
addRecipe(new DataItem(BlockList1_6.lever.blockId(), (byte) 1, (short) 0, null), "X", "#", '#', BlockList1_6.cobblestone.blockId(), 'X', ItemList1_6.stick.itemId());
addRecipe(new DataItem(BlockList1_6.torchRedstoneActive.blockId(), (byte) 1, (short) 0, null), "X", "#", '#', ItemList1_6.stick.itemId(), 'X', ItemList1_6.redstone.itemId());
addRecipe(new DataItem(ItemList1_6.pocketSundial.itemId(), (byte) 1, (short) 0, null), " # ", "#X#", " # ", '#', ItemList1_6.ingotGold.itemId(), 'X', ItemList1_6.redstone.itemId());
addRecipe(new DataItem(ItemList1_6.compass.itemId(), (byte) 1, (short) 0, null), " # ", "#X#", " # ", '#', ItemList1_6.ingotIron.itemId(), 'X', ItemList1_6.redstone.itemId());
addRecipe(new DataItem(BlockList1_6.stoneButton.blockId(), (byte) 1, (short) 0, null), "#", "#", '#', BlockList1_6.stone.blockId());
addRecipe(new DataItem(BlockList1_6.pressurePlateStone.blockId(), (byte) 1, (short) 0, null), "###", '#', BlockList1_6.stone.blockId());
addRecipe(new DataItem(BlockList1_6.pressurePlatePlanks.blockId(), (byte) 1, (short) 0, null), "###", '#', BlockList1_6.planks.blockId());
recipes.sort((o1, o2) -> Integer.compare(o2.getRecipeSize(), o1.getRecipeSize()));
}
private static void addRecipe(final Item resultItem, final Object... objects) {
StringBuilder var3 = new StringBuilder();
int pos = 0;
int width = 0;
int height = 0;
if (objects[pos] instanceof String[]) {
String[] var11 = (String[]) objects[pos++];
for (String var9 : var11) {
height++;
width = var9.length();
var3.append(var9);
}
} else {
while (objects[pos] instanceof String) {
String var7 = (String) objects[pos++];
height++;
width = var7.length();
var3.append(var7);
}
}
final HashMap<Character, Integer> lookup = new HashMap<>();
while (pos < objects.length) {
lookup.put((char) objects[pos], (int) objects[pos + 1]);
pos += 2;
}
final int[] ingredientMap = new int[width * height];
for (int i = 0; i < ingredientMap.length; i++) {
ingredientMap[i] = lookup.getOrDefault(var3.charAt(i), -1);
}
recipes.add(new CraftingRecipe(width, height, ingredientMap, resultItem));
}
public static Item getResult(final Item[] craftingGrid) {
final int gridSize = (int) Math.sqrt(craftingGrid.length);
final int[] ingredientMap = new int[9];
for (int x = 0; x < 3; ++x) {
for (int y = 0; y < 3; ++y) {
int ingredient = -1;
if (x < gridSize && y < gridSize) {
final Item item = craftingGrid[x + y * gridSize];
if (item != null) {
ingredient = item.identifier();
}
}
ingredientMap[x + y * 3] = ingredient;
}
}
return getResult(ingredientMap);
}
public static Item getResult(final int[] ingredientMap) {
for (CraftingRecipe recipe : recipes) {
if (recipe.matches(ingredientMap)) {
return recipe.createResult();
}
}
return null;
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.model;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.model;
import com.viaversion.viaversion.api.minecraft.item.DataItem;
import com.viaversion.viaversion.api.minecraft.item.Item;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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++) {

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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();

View File

@ -15,12 +15,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.provider;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.platform.providers.Provider;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage.InventoryStorage;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.storage.InventoryStorage;
public abstract class AlphaInventoryProvider implements Provider {

View File

@ -15,11 +15,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.provider;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.item.Item;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage.InventoryStorage;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.storage.InventoryStorage;
public class NoOpAlphaInventoryProvider extends AlphaInventoryProvider {

View File

@ -15,13 +15,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.provider;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.item.Item;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage.AlphaInventoryTracker;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.storage.AlphaInventoryTracker;
import static 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.copyItems;
import static net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.copyItems;
public class TrackingAlphaInventoryProvider extends AlphaInventoryProvider {

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.storage;
import com.viaversion.viaversion.api.connection.StoredObject;
import com.viaversion.viaversion.api.connection.UserConnection;
@ -23,23 +23,23 @@ 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;
import net.raphimc.vialegacy.api.data.ItemList1_6;
import net.raphimc.vialegacy.api.util.BlockFaceUtil;
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.data.AlphaItems;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.data.CraftingManager;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.ClientboundPacketsb1_1;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.types.Typesb1_1;
import net.raphimc.vialegacy.protocols.release.protocol1_4_4_5to1_4_2.types.Types1_4_2;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ChunkTracker;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.Protocola1_2_3_5_1_2_6Tob1_0_1_1_1;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.data.AlphaItems;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.data.CraftingManager;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet.ClientboundPacketsb1_1;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.types.Typesb1_1;
import net.raphimc.vialegacy.protocol.release.r1_4_2tor1_4_4_5.types.Types1_4_2;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ChunkTracker;
import java.util.Arrays;
import static 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 static net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.*;
public class AlphaInventoryTracker extends StoredObject {
@ -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) {
@ -260,13 +260,13 @@ public class AlphaInventoryTracker extends StoredObject {
final IdAndData targetBlock = this.getUser().get(ChunkTracker.class).getBlockNotNull(position.getRelative(BlockFaceUtil.getFace(direction)));
AlphaItems.doPlace(handItem, direction, placedAgainst);
if (handItem.identifier() < 256 || handItem.identifier() == ItemList1_6.reed.itemID) { // block item
if (targetBlock.getId() == 0 || targetBlock.getId() == BlockList1_6.waterStill.blockID || targetBlock.getId() == BlockList1_6.waterMoving.blockID || targetBlock.getId() == BlockList1_6.lavaStill.blockID || targetBlock.getId() == BlockList1_6.lavaMoving.blockID || targetBlock.getId() == BlockList1_6.fire.blockID || targetBlock.getId() == BlockList1_6.snow.blockID) {
if (handItem.identifier() < 256 || handItem.identifier() == ItemList1_6.reed.itemId()) { // block item
if (targetBlock.getId() == 0 || targetBlock.getId() == BlockList1_6.waterStill.blockId() || targetBlock.getId() == BlockList1_6.waterMoving.blockId() || targetBlock.getId() == BlockList1_6.lavaStill.blockId() || targetBlock.getId() == BlockList1_6.lavaMoving.blockId() || targetBlock.getId() == BlockList1_6.fire.blockId() || targetBlock.getId() == BlockList1_6.snow.blockId()) {
handItem.setAmount(handItem.amount() - 1);
}
} else if (handItem.identifier() == ItemList1_6.sign.itemID) {
} else if (handItem.identifier() == ItemList1_6.sign.itemId()) {
if (direction != 0 && targetBlock.getId() == 0) handItem.setAmount(handItem.amount() - 1);
} else if (handItem.identifier() == ItemList1_6.redstone.itemID) {
} else if (handItem.identifier() == ItemList1_6.redstone.itemId()) {
if (targetBlock.getId() == 0) handItem.setAmount(handItem.amount() - 1);
}
}
@ -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(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.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(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
}
private Item splitStack(final Item item, final int size) {

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.minecraft.Position;

View File

@ -15,26 +15,26 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.task;
package net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.task;
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;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers.AlphaInventoryProvider;
import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage.InventoryStorage;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.ServerboundPacketsb1_1;
import net.raphimc.vialegacy.protocols.release.protocol1_4_4_5to1_4_2.types.Types1_4_2;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.Protocola1_2_3_5_1_2_6Tob1_0_1_1_1;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.packet.ServerboundPacketsa1_2_6;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.provider.AlphaInventoryProvider;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.storage.InventoryStorage;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet.ServerboundPacketsb1_1;
import net.raphimc.vialegacy.protocol.release.r1_4_2tor1_4_4_5.types.Types1_4_2;
import java.util.Arrays;
import java.util.Objects;
import java.util.logging.Level;
import static 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 static net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.*;
public class AlphaInventoryUpdateTask implements Runnable {
@ -54,9 +54,9 @@ 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
heldItemChange.sendToServer(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class, false);
final PacketWrapper heldItemChange = PacketWrapper.create(ServerboundPacketsb1_1.SET_CARRIED_ITEM, info);
heldItemChange.write(Types.SHORT, inventoryStorage.selectedHotbarSlot); // slot
heldItemChange.sendToServer(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class, false);
}
final Item[] mergedMainInventory = copyItems(inventoryStorage.mainInventory);
@ -74,20 +74,20 @@ 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);
craftingContent.sendToServer(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
armorContent.sendToServer(Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.class);
mainContent.sendToServer(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
craftingContent.sendToServer(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
armorContent.sendToServer(Protocola1_2_3_5_1_2_6Tob1_0_1_1_1.class);
} catch (Throwable e) {
ViaLegacy.getPlatform().getLogger().log(Level.WARNING, "Error sending inventory update packets", e);
}

View File

@ -15,15 +15,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_1_2tob1_0_1_1;
package net.raphimc.vialegacy.protocol.beta.b1_0_1_1tob1_1_2;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.ClientboundPacketsb1_1;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.ServerboundPacketsb1_1;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet.ClientboundPacketsb1_1;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet.ServerboundPacketsb1_1;
public class Protocolb1_1_2tob1_0_1_1 extends StatelessProtocol<ClientboundPacketsb1_1, ClientboundPacketsb1_1, ServerboundPacketsb1_1, ServerboundPacketsb1_1> {
public class Protocolb1_0_1_1Tob1_1_2 extends StatelessProtocol<ClientboundPacketsb1_1, ClientboundPacketsb1_1, ServerboundPacketsb1_1, ServerboundPacketsb1_1> {
public Protocolb1_1_2tob1_0_1_1() {
public Protocolb1_0_1_1Tob1_1_2() {
super(ClientboundPacketsb1_1.class, ClientboundPacketsb1_1.class, ServerboundPacketsb1_1.class, ServerboundPacketsb1_1.class);
}

View File

@ -15,57 +15,59 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2;
package net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_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;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.rewriter.BlockDataRewriter;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.storage.EntityFlagStorage;
import net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.types.Typesb1_1;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.ClientboundPacketsb1_2;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.ServerboundPacketsb1_2;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.types.MetaTypeb1_2;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.types.Typesb1_2;
import net.raphimc.vialegacy.protocols.release.protocol1_2_1_3to1_1.types.Types1_1;
import net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types.Types1_3_1;
import net.raphimc.vialegacy.protocols.release.protocol1_4_4_5to1_4_2.types.Types1_4_2;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet.ClientboundPacketsb1_1;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet.ServerboundPacketsb1_1;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.rewriter.BlockDataRewriter;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.storage.EntityFlagStorage;
import net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.types.Typesb1_1;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.packet.ClientboundPacketsb1_2;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.packet.ServerboundPacketsb1_2;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.types.EntityDataTypesb1_2;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.types.Typesb1_2;
import net.raphimc.vialegacy.protocol.release.r1_1tor1_2_1_3.types.Types1_1;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.types.Types1_3_1;
import net.raphimc.vialegacy.protocol.release.r1_4_2tor1_4_4_5.types.Types1_4_2;
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.types.Types1_7_6;
public class Protocolb1_2_0_2tob1_1_2 extends StatelessProtocol<ClientboundPacketsb1_1, ClientboundPacketsb1_2, ServerboundPacketsb1_1, ServerboundPacketsb1_2> {
public class Protocolb1_1_2Tob1_2_0_2 extends StatelessProtocol<ClientboundPacketsb1_1, ClientboundPacketsb1_2, ServerboundPacketsb1_1, ServerboundPacketsb1_2> {
private final BlockDataRewriter BLOCK_DATA_REWRITER = new BlockDataRewriter();
public Protocolb1_2_0_2tob1_1_2() {
public Protocolb1_1_2Tob1_2_0_2() {
super(ClientboundPacketsb1_1.class, ClientboundPacketsb1_2.class, ServerboundPacketsb1_1.class, ServerboundPacketsb1_2.class);
}
@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,10 +95,10 @@ 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
metadata.send(Protocolb1_2_0_2tob1_1_2.class);
final PacketWrapper setEntityData = PacketWrapper.create(ClientboundPacketsb1_2.SET_ENTITY_DATA, wrapper.user());
setEntityData.write(Types.INT, wrapper.get(Types.INT, 0)); // entity id
setEntityData.write(Typesb1_2.ENTITY_DATA_LIST, Lists.newArrayList(new EntityData(0, EntityDataTypesb1_2.BYTE, (byte) entityFlagStorage.getFlagMask(entityId)))); // entity data
setEntityData.send(Protocolb1_1_2Tob1_2_0_2.class);
}
});
}
@ -104,93 +106,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.ENTITY_DATA_LIST, Lists.newArrayList(new EntityData(0, EntityDataTypesb1_2.BYTE, (byte) 0)))); // entity data
}
});
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
}
});
@ -198,7 +200,7 @@ public class Protocolb1_2_0_2tob1_1_2 extends StatelessProtocol<ClientboundPacke
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolb1_2_0_2tob1_1_2.class, ClientboundPacketsb1_1::getPacket));
userConnection.put(new PreNettySplitter(Protocolb1_1_2Tob1_2_0_2.class, ClientboundPacketsb1_1::getPacket));
userConnection.put(new EntityFlagStorage());
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2;
package net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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);

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2;
package net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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);

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.rewriter;
package net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.rewriter;
import com.viaversion.viaversion.util.IdAndData;
import net.raphimc.vialegacy.api.data.BlockList1_6;
@ -25,16 +25,16 @@ public class BlockDataRewriter extends AbstractBlockRemapper {
public BlockDataRewriter() {
for (int i = 1; i < 16; i++) { // cobblestone
this.registerReplacement(new IdAndData(BlockList1_6.cobblestone.blockID, i), new IdAndData(BlockList1_6.cobblestone.blockID, 0));
this.registerReplacement(new IdAndData(BlockList1_6.cobblestone.blockId(), i), new IdAndData(BlockList1_6.cobblestone.blockId(), 0));
}
for (int i = 1; i < 16; i++) { // sand
this.registerReplacement(new IdAndData(BlockList1_6.sand.blockID, i), new IdAndData(BlockList1_6.sand.blockID, 0));
this.registerReplacement(new IdAndData(BlockList1_6.sand.blockId(), i), new IdAndData(BlockList1_6.sand.blockId(), 0));
}
for (int i = 1; i < 16; i++) { // gravel
this.registerReplacement(new IdAndData(BlockList1_6.gravel.blockID, i), new IdAndData(BlockList1_6.gravel.blockID, 0));
this.registerReplacement(new IdAndData(BlockList1_6.gravel.blockId(), i), new IdAndData(BlockList1_6.gravel.blockId(), 0));
}
for (int i = 1; i < 16; i++) { // obsidian
this.registerReplacement(new IdAndData(BlockList1_6.obsidian.blockID, i), new IdAndData(BlockList1_6.obsidian.blockID, 0));
this.registerReplacement(new IdAndData(BlockList1_6.obsidian.blockId(), i), new IdAndData(BlockList1_6.obsidian.blockId(), 0));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.storage;
package net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.types;
package net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.types;
import com.viaversion.viaversion.api.minecraft.item.DataItem;
import com.viaversion.viaversion.api.minecraft.item.Item;
@ -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 {

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_2_0_2tob1_1_2.types;
package net.raphimc.vialegacy.protocol.beta.b1_1_2tob1_2_0_2.types;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.type.Type;

View File

@ -15,68 +15,70 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2;
package net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1;
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;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.data.BlockHardnessList;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.storage.BlockDigStorage;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.task.BlockDigTickTask;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.types.Typesb1_2;
import net.raphimc.vialegacy.protocols.beta.protocolb1_4_0_1tob1_3_0_1.ClientboundPacketsb1_3;
import net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.ServerboundPacketsb1_4;
import net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types.MetaTypeb1_4;
import net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types.Typesb1_4;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ChunkTracker;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.data.BlockHardnessList;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.packet.ClientboundPacketsb1_2;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.packet.ServerboundPacketsb1_2;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.storage.BlockDigStorage;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.task.BlockDigTickTask;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.types.Typesb1_2;
import net.raphimc.vialegacy.protocol.beta.b1_3_0_1tob1_4_0_1.packet.ClientboundPacketsb1_3;
import net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.packet.ServerboundPacketsb1_4;
import net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.types.EntityDataTypesb1_4;
import net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.types.Typesb1_4;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ChunkTracker;
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.types.Types1_7_6;
import java.util.List;
public class Protocolb1_3_0_1tob1_2_0_2 extends StatelessProtocol<ClientboundPacketsb1_2, ClientboundPacketsb1_3, ServerboundPacketsb1_2, ServerboundPacketsb1_4> {
public class Protocolb1_2_0_2Tob1_3_0_1 extends StatelessProtocol<ClientboundPacketsb1_2, ClientboundPacketsb1_3, ServerboundPacketsb1_2, ServerboundPacketsb1_4> {
public Protocolb1_3_0_1tob1_2_0_2() {
public Protocolb1_2_0_2Tob1_3_0_1() {
super(ClientboundPacketsb1_2.class, ClientboundPacketsb1_3.class, ServerboundPacketsb1_2.class, ServerboundPacketsb1_4.class);
}
@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(Typesb1_2.METADATA_LIST, Typesb1_4.METADATA_LIST); // metadata
handler(wrapper -> rewriteMetadata(wrapper.get(Typesb1_4.METADATA_LIST, 0)));
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.ENTITY_DATA_LIST, Typesb1_4.ENTITY_DATA_LIST); // entity data
handler(wrapper -> rewriteEntityData(wrapper.get(Typesb1_4.ENTITY_DATA_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(Typesb1_2.METADATA_LIST, Typesb1_4.METADATA_LIST); // metadata
handler(wrapper -> rewriteMetadata(wrapper.get(Typesb1_4.METADATA_LIST, 0)));
map(Types.INT); // entity id
map(Typesb1_2.ENTITY_DATA_LIST, Typesb1_4.ENTITY_DATA_LIST); // entity data
handler(wrapper -> rewriteEntityData(wrapper.get(Typesb1_4.ENTITY_DATA_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 +111,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 rewriteEntityData(final List<EntityData> entityDataList) {
for (EntityData entityData : entityDataList) {
entityData.setDataType(EntityDataTypesb1_4.byId(entityData.dataType().typeId()));
}
}
@ -135,16 +137,16 @@ public class Protocolb1_3_0_1tob1_2_0_2 extends StatelessProtocol<ClientboundPac
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolb1_3_0_1tob1_2_0_2.class, ClientboundPacketsb1_2::getPacket));
userConnection.put(new PreNettySplitter(Protocolb1_2_0_2Tob1_3_0_1.class, ClientboundPacketsb1_2::getPacket));
}
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.sendToServer(Protocolb1_3_0_1tob1_2_0_2.class);
blockDig.write(Types.UNSIGNED_BYTE, facing); // direction
blockDig.sendToServer(Protocolb1_2_0_2Tob1_3_0_1.class);
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.data;
package net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.data;
import com.viaversion.viaversion.util.IdAndData;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2;
package net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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);
PreNettyTypes.readEntityDataListb1_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);
PreNettyTypes.readEntityDataListb1_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);

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2;
package net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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);

View File

@ -15,15 +15,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.storage;
package net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.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;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.Protocolb1_2_0_2Tob1_3_0_1;
public class BlockDigStorage extends StoredObject {
@ -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_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.getUser(), (byte) 0, this.position, this.facing);
this.tick = 0;
} else {
this.tick++;
}
Protocolb1_2_0_2Tob1_3_0_1.sendBlockDigPacket(this.getUser(), (byte) 1, this.position, this.facing);
}
}

View File

@ -15,11 +15,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.task;
package net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.task;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.storage.BlockDigStorage;
import net.raphimc.vialegacy.ViaLegacy;
import net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.storage.BlockDigStorage;
import java.util.logging.Level;
public class BlockDigTickTask implements Runnable {
@ -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);
}
});
}
}
}

View File

@ -15,16 +15,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.types;
package net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_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.type.types.entitydata.OldEntityDataType;
public class MetadataType extends OldMetaType {
public class EntityDataType extends OldEntityDataType {
@Override
protected MetaType getType(int index) {
return MetaTypeb1_2.byId(index);
protected com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType getType(int index) {
return EntityDataTypesb1_2.byId(index);
}
}

View File

@ -15,31 +15,32 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types;
package net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_0_1.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 net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
import com.viaversion.viaversion.api.type.Types;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.types.Typesb1_7_0_3;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.types.Types1_3_1;
public enum MetaType1_3_1 implements MetaType {
public enum EntityDataTypesb1_2 implements EntityDataType {
Byte(0, Type.BYTE),
Short(1, Type.SHORT),
Int(2, Type.INT),
Float(3, Type.FLOAT),
String(4, Types1_6_4.STRING),
Slot(5, Types1_3_1.NBTLESS_ITEM),
Position(6, Type.VECTOR);
BYTE(0, Types.BYTE),
SHORT(1, Types.SHORT),
INT(2, Types.INT),
FLOAT(3, Types.FLOAT),
STRING(4, Typesb1_7_0_3.STRING),
ITEM(5, Types1_3_1.NBTLESS_ITEM);
private final int typeID;
private final Type<?> type;
MetaType1_3_1(int typeID, Type<?> type) {
EntityDataTypesb1_2(int typeID, Type<?> type) {
this.typeID = typeID;
this.type = type;
}
public static MetaType1_3_1 byId(int id) {
public static EntityDataTypesb1_2 byId(int id) {
return values()[id];
}

View File

@ -15,17 +15,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_3_0_1tob1_2_0_2.types;
package net.raphimc.vialegacy.protocol.beta.b1_2_0_2tob1_3_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_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> ENTITY_DATA = new EntityDataType();
public static final Type<List<EntityData>> ENTITY_DATA_LIST = new EntityDataListType(ENTITY_DATA);
}

View File

@ -15,23 +15,24 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_4_0_1tob1_3_0_1;
package net.raphimc.vialegacy.protocol.beta.b1_3_0_1tob1_4_0_1;
import com.viaversion.viaversion.api.connection.UserConnection;
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.ClientboundPacketsb1_4;
import net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.ServerboundPacketsb1_4;
import net.raphimc.vialegacy.protocol.beta.b1_3_0_1tob1_4_0_1.packet.ClientboundPacketsb1_3;
import net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.packet.ClientboundPacketsb1_4;
import net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.packet.ServerboundPacketsb1_4;
public class Protocolb1_4_0_1tob1_3_0_1 extends StatelessProtocol<ClientboundPacketsb1_3, ClientboundPacketsb1_4, ServerboundPacketsb1_4, ServerboundPacketsb1_4> {
public class Protocolb1_3_0_1Tob1_4_0_1 extends StatelessProtocol<ClientboundPacketsb1_3, ClientboundPacketsb1_4, ServerboundPacketsb1_4, ServerboundPacketsb1_4> {
public Protocolb1_4_0_1tob1_3_0_1() {
public Protocolb1_3_0_1Tob1_4_0_1() {
super(ClientboundPacketsb1_3.class, ClientboundPacketsb1_4.class, ServerboundPacketsb1_4.class, ServerboundPacketsb1_4.class);
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolb1_4_0_1tob1_3_0_1.class, ClientboundPacketsb1_3::getPacket));
userConnection.put(new PreNettySplitter(Protocolb1_3_0_1Tob1_4_0_1.class, ClientboundPacketsb1_3::getPacket));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_4_0_1tob1_3_0_1;
package net.raphimc.vialegacy.protocol.beta.b1_3_0_1tob1_4_0_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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);
readEntityDataListb1_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);
readEntityDataListb1_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);

View File

@ -15,29 +15,31 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1;
package net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2;
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;
import net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2.ClientboundPacketsb1_5;
import net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2.ServerboundPacketsb1_5;
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.MetaType1_3_1;
import net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types.Types1_3_1;
import net.raphimc.vialegacy.protocols.release.protocol1_4_4_5to1_4_2.types.Types1_4_2;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;
import net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.packet.ClientboundPacketsb1_4;
import net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.packet.ServerboundPacketsb1_4;
import net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.types.Typesb1_4;
import net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.packet.ClientboundPacketsb1_5;
import net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.packet.ServerboundPacketsb1_5;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.types.Typesb1_7_0_3;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.types.EntityDataTypes1_3_1;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.types.Types1_3_1;
import net.raphimc.vialegacy.protocol.release.r1_4_2tor1_4_4_5.types.Types1_4_2;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.types.Types1_7_6;
import java.util.List;
public class Protocolb1_5_0_2tob1_4_0_1 extends StatelessProtocol<ClientboundPacketsb1_4, ClientboundPacketsb1_5, ServerboundPacketsb1_4, ServerboundPacketsb1_5> {
public class Protocolb1_4_0_1Tob1_5_0_2 extends StatelessProtocol<ClientboundPacketsb1_4, ClientboundPacketsb1_5, ServerboundPacketsb1_4, ServerboundPacketsb1_5> {
public Protocolb1_5_0_2tob1_4_0_1() {
public Protocolb1_4_0_1Tob1_5_0_2() {
super(ClientboundPacketsb1_4.class, ClientboundPacketsb1_5.class, ServerboundPacketsb1_4.class, ServerboundPacketsb1_5.class);
}
@ -49,69 +51,69 @@ 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(Typesb1_4.METADATA_LIST, Types1_3_1.METADATA_LIST); // metadata
handler(wrapper -> rewriteMetadata(wrapper.get(Types1_3_1.METADATA_LIST, 0)));
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.ENTITY_DATA_LIST, Types1_3_1.ENTITY_DATA_LIST); // entity data
handler(wrapper -> rewriteEntityData(wrapper.get(Types1_3_1.ENTITY_DATA_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(Typesb1_4.METADATA_LIST, Types1_3_1.METADATA_LIST); // metadata
handler(wrapper -> rewriteMetadata(wrapper.get(Types1_3_1.METADATA_LIST, 0)));
map(Types.INT); // entity id
map(Typesb1_4.ENTITY_DATA_LIST, Types1_3_1.ENTITY_DATA_LIST); // entity data
handler(wrapper -> rewriteEntityData(wrapper.get(Types1_3_1.ENTITY_DATA_LIST, 0)));
}
});
this.registerClientbound(ClientboundPacketsb1_4.UPDATE_SIGN, new PacketHandlers() {
@ -140,31 +142,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,15 +184,15 @@ 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 rewriteEntityData(final List<EntityData> entityDataList) {
for (EntityData entityData : entityDataList) {
entityData.setDataType(EntityDataTypes1_3_1.byId(entityData.dataType().typeId()));
}
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolb1_5_0_2tob1_4_0_1.class, ClientboundPacketsb1_4::getPacket));
userConnection.put(new PreNettySplitter(Protocolb1_4_0_1Tob1_5_0_2.class, ClientboundPacketsb1_4::getPacket));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1;
package net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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);
readEntityDataListb1_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);
readEntityDataListb1_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);

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1;
package net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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);

View File

@ -15,16 +15,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types;
package net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_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.type.types.entitydata.OldEntityDataType;
public class MetadataType extends OldMetaType {
public class EntityDataType extends OldEntityDataType {
@Override
protected MetaType getType(int index) {
return MetaType1_3_1.byId(index);
protected com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType getType(int index) {
return EntityDataTypesb1_4.byId(index);
}
}

View File

@ -15,27 +15,28 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types;
package net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_0_2.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;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.types.Typesb1_7_0_3;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.types.Types1_3_1;
public enum MetaTypeb1_4 implements MetaType {
public enum EntityDataTypesb1_4 implements EntityDataType {
Byte(0, Type.BYTE),
Short(1, Type.SHORT),
Int(2, Type.INT),
Float(3, Type.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)
BYTE(0, Types.BYTE),
SHORT(1, Types.SHORT),
INT(2, Types.INT),
FLOAT(3, Types.FLOAT),
STRING(4, Typesb1_7_0_3.STRING),
ITEM(5, new Type<>(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,17 +45,17 @@ public enum MetaTypeb1_4 implements MetaType {
throw new UnsupportedOperationException();
}
}),
Position(6, Type.VECTOR);
BLOCK_POSITION(6, Types.VECTOR);
private final int typeID;
private final Type<?> type;
MetaTypeb1_4(int typeID, Type<?> type) {
EntityDataTypesb1_4(int typeID, Type<?> type) {
this.typeID = typeID;
this.type = type;
}
public static MetaTypeb1_4 byId(int id) {
public static EntityDataTypesb1_4 byId(int id) {
return values()[id];
}

View File

@ -15,17 +15,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types;
package net.raphimc.vialegacy.protocol.beta.b1_4_0_1tob1_5_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_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> ENTITY_DATA = new EntityDataType();
public static final Type<List<EntityData>> ENTITY_DATA_LIST = new EntityDataListType(ENTITY_DATA);
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2;
package net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
@ -24,87 +24,89 @@ 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;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
import net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2.storage.WorldTimeStorage;
import net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2.task.TimeTrackTask;
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.ClientboundPacketsb1_7;
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.ServerboundPacketsb1_7;
import net.raphimc.vialegacy.protocols.release.protocol1_4_4_5to1_4_2.types.Types1_4_2;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ChunkTracker;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.PlayerInfoStorage;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;
import net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.packet.ClientboundPacketsb1_5;
import net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.packet.ServerboundPacketsb1_5;
import net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.storage.WorldTimeStorage;
import net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.task.TimeTrackTask;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.packet.ClientboundPacketsb1_7;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.packet.ServerboundPacketsb1_7;
import net.raphimc.vialegacy.protocol.release.r1_4_2tor1_4_4_5.types.Types1_4_2;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ChunkTracker;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.PlayerInfoStorage;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.types.Types1_7_6;
public class Protocolb1_6_0_6tob1_5_0_2 extends StatelessProtocol<ClientboundPacketsb1_5, ClientboundPacketsb1_7, ServerboundPacketsb1_5, ServerboundPacketsb1_7> {
public class Protocolb1_5_0_2Tob1_6_0_6 extends StatelessProtocol<ClientboundPacketsb1_5, ClientboundPacketsb1_7, ServerboundPacketsb1_5, ServerboundPacketsb1_7> {
public Protocolb1_6_0_6tob1_5_0_2() {
public Protocolb1_5_0_2Tob1_6_0_6() {
super(ClientboundPacketsb1_5.class, ClientboundPacketsb1_7.class, ServerboundPacketsb1_5.class, ServerboundPacketsb1_7.class);
}
@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);
Position pos = wrapper.get(Types1_7_6.POSITION_UBYTE, 0);
IdAndData block = wrapper.user().get(ChunkTracker.class).getBlockNotNull(pos);
final Item item = wrapper.get(Types1_4_2.NBTLESS_ITEM, 0);
if (block.getId() == BlockList1_6.bed.blockID) {
if (block.getId() == BlockList1_6.bed.blockId()) {
final byte[][] headBlockToFootBlock = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
final boolean isFoot = (block.getData() & 8) != 0;
if (!isFoot) {
final int bedDirection = block.getData() & 3;
pos = new Position(pos.x() + headBlockToFootBlock[bedDirection][0], pos.y(), pos.z() + headBlockToFootBlock[bedDirection][1]);
block = wrapper.user().get(ChunkTracker.class).getBlockNotNull(pos);
if (block.getId() != BlockList1_6.bed.blockID) return;
if (block.getId() != BlockList1_6.bed.blockId()) return;
}
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);
chat.send(Protocolb1_5_0_2Tob1_6_0_6.class);
return;
}
@ -123,9 +125,9 @@ 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);
chat.send(Protocolb1_5_0_2Tob1_6_0_6.class);
return;
}
@ -133,24 +135,24 @@ 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) {
useBed.send(Protocolb1_5_0_2Tob1_6_0_6.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.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
effect.write(Types.INT, 0); // data
effect.send(Protocolb1_5_0_2Tob1_6_0_6.class);
} else if (item != null && (item.identifier() == ItemList1_6.record13.itemId() || item.identifier() == ItemList1_6.recordCat.itemId())) {
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.send(Protocolb1_6_0_6tob1_5_0_2.class);
effect.write(Types.INT, item.identifier()); // data
effect.send(Protocolb1_5_0_2Tob1_6_0_6.class);
}
}
});
@ -165,7 +167,7 @@ public class Protocolb1_6_0_6tob1_5_0_2 extends StatelessProtocol<ClientboundPac
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolb1_6_0_6tob1_5_0_2.class, ClientboundPacketsb1_5::getPacket));
userConnection.put(new PreNettySplitter(Protocolb1_5_0_2Tob1_6_0_6.class, ClientboundPacketsb1_5::getPacket));
userConnection.put(new WorldTimeStorage());
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2;
package net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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);
readEntityDataListb1_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);
readEntityDataListb1_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];

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2;
package net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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);

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2.storage;
package net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.storage;
import com.viaversion.viaversion.api.connection.StorableObject;

View File

@ -15,11 +15,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2.task;
package net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.task;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import net.raphimc.vialegacy.protocols.beta.protocolb1_6_0_6tob1_5_0_2.storage.WorldTimeStorage;
import net.raphimc.vialegacy.protocol.beta.b1_5_0_2tob1_6_0_6.storage.WorldTimeStorage;
public class TimeTrackTask implements Runnable {

View File

@ -15,15 +15,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_7_0_3tob1_6_0_6;
package net.raphimc.vialegacy.protocol.beta.b1_6_0_6tob1_7_0_3;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.ClientboundPacketsb1_7;
import net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.ServerboundPacketsb1_7;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.packet.ClientboundPacketsb1_7;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.packet.ServerboundPacketsb1_7;
public class Protocolb1_7_0_3tob1_6_0_6 extends StatelessProtocol<ClientboundPacketsb1_7, ClientboundPacketsb1_7, ServerboundPacketsb1_7, ServerboundPacketsb1_7> {
public class Protocolb1_6_0_6Tob1_7_0_3 extends StatelessProtocol<ClientboundPacketsb1_7, ClientboundPacketsb1_7, ServerboundPacketsb1_7, ServerboundPacketsb1_7> {
public Protocolb1_7_0_3tob1_6_0_6() {
public Protocolb1_6_0_6Tob1_7_0_3() {
super(ClientboundPacketsb1_7.class, ClientboundPacketsb1_7.class, ServerboundPacketsb1_7.class, ServerboundPacketsb1_7.class);
}

View File

@ -0,0 +1,363 @@
/*
* This file is part of ViaLegacy - https://github.com/RaphiMC/ViaLegacy
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
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.Types;
import net.raphimc.vialegacy.ViaLegacy;
import net.raphimc.vialegacy.api.data.BlockList1_6;
import net.raphimc.vialegacy.api.data.ItemList1_6;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
import net.raphimc.vialegacy.protocol.alpha.a1_2_3_5_1_2_6tob1_0_1_1_1.storage.AlphaInventoryTracker;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.packet.ClientboundPacketsb1_7;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.packet.ServerboundPacketsb1_7;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.storage.PlayerHealthTracker;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.storage.PlayerNameTracker;
import net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.types.Typesb1_7_0_3;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.packet.ClientboundPacketsb1_8;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.packet.ServerboundPacketsb1_8;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.types.Typesb1_8_0_1;
import net.raphimc.vialegacy.protocol.classic.c0_0_20a_27toc0_28_30.Protocolc0_0_20a_27Toc0_28_30;
import net.raphimc.vialegacy.protocol.release.r1_1tor1_2_1_3.model.LegacyNibbleArray;
import net.raphimc.vialegacy.protocol.release.r1_1tor1_2_1_3.storage.SeedStorage;
import net.raphimc.vialegacy.protocol.release.r1_1tor1_2_1_3.types.Types1_1;
import net.raphimc.vialegacy.protocol.release.r1_2_4_5tor1_3_1_2.storage.EntityTracker;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.types.Types1_3_1;
import net.raphimc.vialegacy.protocol.release.r1_4_2tor1_4_4_5.types.Types1_4_2;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ChunkTracker;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.types.Types1_6_4;
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.types.Types1_7_6;
import java.util.concurrent.ThreadLocalRandom;
public class Protocolb1_7_0_3Tob1_8_0_1 extends StatelessProtocol<ClientboundPacketsb1_7, ClientboundPacketsb1_8, ServerboundPacketsb1_7, ServerboundPacketsb1_8> {
public Protocolb1_7_0_3Tob1_8_0_1() {
super(ClientboundPacketsb1_7.class, ClientboundPacketsb1_8.class, ServerboundPacketsb1_7.class, ServerboundPacketsb1_8.class);
}
@Override
protected void registerPackets() {
this.registerClientbound(ClientboundPacketsb1_7.KEEP_ALIVE, wrapper -> {
wrapper.write(Types.INT, ThreadLocalRandom.current().nextInt(1, Short.MAX_VALUE)); // key
});
this.registerClientbound(ClientboundPacketsb1_7.LOGIN, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // entity id
map(Types1_6_4.STRING); // username
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(Types.BOOLEAN, true); // online
playerListEntry.write(Types.SHORT, (short) 0); // ping
final PacketWrapper updateHealth = PacketWrapper.create(ClientboundPacketsb1_7.SET_HEALTH, wrapper.user());
updateHealth.write(Types.SHORT, (short) 20); // health
wrapper.send(Protocolb1_7_0_3Tob1_8_0_1.class);
wrapper.cancel();
playerListEntry.send(Protocolb1_7_0_3Tob1_8_0_1.class);
updateHealth.send(Protocolb1_7_0_3Tob1_8_0_1.class, false);
});
}
});
this.registerClientbound(ClientboundPacketsb1_7.SET_HEALTH, new PacketHandlers() {
@Override
public void register() {
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(Types.SHORT, 1, (short) 20); // food
wrapper.set(Types.FLOAT, 0, 0F); // saturation
}
});
}
});
this.registerClientbound(ClientboundPacketsb1_7.RESPAWN, new PacketHandlers() {
@Override
public void register() {
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.ADD_PLAYER, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // entity id
map(Types1_6_4.STRING); // username
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(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(Types.BOOLEAN, true); // online
playerListEntry.write(Types.SHORT, (short) 0); // ping
playerListEntry.send(Protocolb1_7_0_3Tob1_8_0_1.class);
});
}
});
this.registerClientbound(ClientboundPacketsb1_7.ADD_MOB, new PacketHandlers() {
@Override
public void register() {
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.ENTITY_DATA_LIST); // entity data
handler(wrapper -> {
final short entityType = wrapper.get(Types.UNSIGNED_BYTE, 0);
if (entityType == 49) { // monster
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(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 setEntityData = PacketWrapper.create(ClientboundPacketsb1_8.SET_ENTITY_DATA, wrapper.user());
setEntityData.write(Types.INT, wrapper.get(Types.INT, 0)); // entity id
setEntityData.write(Types1_3_1.ENTITY_DATA_LIST, wrapper.get(Types1_3_1.ENTITY_DATA_LIST, 0)); // entity data
wrapper.cancel();
spawnMonster.send(Protocolb1_7_0_3Tob1_8_0_1.class);
setEntityData.send(Protocolb1_7_0_3Tob1_8_0_1.class);
}
});
}
});
this.registerClientbound(ClientboundPacketsb1_7.REMOVE_ENTITIES, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // entity id
handler(wrapper -> {
final PlayerNameTracker playerNameTracker = wrapper.user().get(PlayerNameTracker.class);
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(Types.BOOLEAN, false); // online
playerListEntry.write(Types.SHORT, (short) 0); // ping
playerListEntry.send(Protocolb1_7_0_3Tob1_8_0_1.class);
}
});
}
});
this.registerClientbound(ClientboundPacketsb1_7.LEVEL_CHUNK, wrapper -> {
final Chunk chunk = wrapper.passthrough(Types1_1.CHUNK);
boolean hasChest = false;
for (ChunkSection section : chunk.getSections()) {
if (section == null || !section.getLight().hasSkyLight()) continue;
for (int i = 0; i < section.palette(PaletteType.BLOCKS).size(); i++) {
if (section.palette(PaletteType.BLOCKS).idByIndex(i) >> 4 == BlockList1_6.chest.blockId()) {
hasChest = true;
break;
}
}
if (!hasChest) continue;
final LegacyNibbleArray sectionSkyLight = new LegacyNibbleArray(section.getLight().getSkyLight(), 4);
for (int y = 0; y < 16; y++)
for (int x = 0; x < 16; x++)
for (int z = 0; z < 16; z++)
if (section.palette(PaletteType.BLOCKS).idAt(x, y, z) >> 4 == BlockList1_6.chest.blockId())
sectionSkyLight.set(x, y, z, 15);
}
});
this.registerClientbound(ClientboundPacketsb1_7.GAME_EVENT, new PacketHandlers() {
@Override
public void register() {
map(Types.BYTE); // reason
create(Types.BYTE, (byte) 0); // value
}
});
this.registerClientbound(ClientboundPacketsb1_7.OPEN_SCREEN, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // window id
map(Types.UNSIGNED_BYTE); // window type
map(Typesb1_7_0_3.STRING, Types1_6_4.STRING); // title
map(Types.UNSIGNED_BYTE); // slots
}
});
this.registerServerbound(State.PLAY, ServerboundPacketsb1_8.SERVER_PING.getId(), -2, wrapper -> {
if (wrapper.user().getProtocolInfo().getPipeline().contains(Protocolc0_0_20a_27Toc0_28_30.class)) {
// Classic servers have issues with sockets connecting and disconnecting without sending any data.
// Because of that we send an invalid packet id to force the server to disconnect us.
// This is the reason why the packet id is mapped to -2. (-1 gets handled internally by ViaVersion)
// This fix is needed for <= c0.27, >= c0.28 closes the socket after 3 seconds of inactivity.
wrapper.clearPacket();
} else {
wrapper.cancel();
}
final PacketWrapper pingResponse = PacketWrapper.create(ClientboundPacketsb1_8.DISCONNECT, wrapper.user());
pingResponse.write(Types1_6_4.STRING, "The server seems to be running!\nWait 5 seconds between each connection§0§1");
pingResponse.send(Protocolb1_7_0_3Tob1_8_0_1.class);
});
this.registerServerbound(ServerboundPacketsb1_8.LOGIN, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // protocol id
map(Types1_6_4.STRING); // username
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(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_ACTION, new PacketHandlers() {
@Override
public void register() {
map(Types.UNSIGNED_BYTE); // status
handler(wrapper -> {
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(Types.UNSIGNED_BYTE); // direction
}
});
this.registerServerbound(ServerboundPacketsb1_8.USE_ITEM_ON, new PacketHandlers() {
@Override
public void register() {
map(Types1_7_6.POSITION_UBYTE); // position
map(Types.UNSIGNED_BYTE); // direction
map(Types1_4_2.NBTLESS_ITEM); // item
handler(wrapper -> {
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_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_7_0_3Tob1_8_0_1.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.SET_HEALTH, wrapper.user());
updateHealth.write(Types.SHORT, wrapper.user().get(PlayerHealthTracker.class).getHealth()); // health
updateHealth.send(Protocolb1_7_0_3Tob1_8_0_1.class, false);
}
}
});
}
});
this.registerServerbound(ServerboundPacketsb1_8.PLAYER_COMMAND, new PacketHandlers() {
@Override
public void register() {
map(Types.INT); // entity id
map(Types.BYTE); // action id
handler(wrapper -> {
if (wrapper.get(Types.BYTE, 0) > 3) wrapper.cancel();
});
}
});
this.registerServerbound(ServerboundPacketsb1_8.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
map(Types.BYTE); // window id
handler(wrapper -> {
if (wrapper.passthrough(Types.SHORT) /*slot*/ == -1) wrapper.cancel();
});
map(Types.BYTE); // button
map(Types.SHORT); // action
map(Types.BYTE); // mode
map(Types1_4_2.NBTLESS_ITEM); // item
}
});
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(Types.SHORT), wrapper.read(Typesb1_8_0_1.CREATIVE_ITEM));
});
this.registerServerbound(ServerboundPacketsb1_8.KEEP_ALIVE, wrapper -> {
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();
}
});
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolb1_7_0_3Tob1_8_0_1.class, ClientboundPacketsb1_7::getPacket));
userConnection.put(new PlayerNameTracker());
userConnection.put(new PlayerHealthTracker());
}
private boolean isSword(final Item item) {
return item.identifier() == ItemList1_6.swordWood.itemId() ||
item.identifier() == ItemList1_6.swordStone.itemId() ||
item.identifier() == ItemList1_6.swordIron.itemId() ||
item.identifier() == ItemList1_6.swordGold.itemId() ||
item.identifier() == ItemList1_6.swordDiamond.itemId();
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3;
package net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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);
readEntityDataListb1_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);
readEntityDataListb1_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];

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3;
package net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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);

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.storage;
package net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.storage;
import com.viaversion.viaversion.api.connection.StorableObject;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.storage;
package net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.storage;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectArrayMap;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.types;
package net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.types;
import com.viaversion.viaversion.api.type.Type;
import io.netty.buffer.ByteBuf;
@ -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);
}
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_8_0_1tob1_7_0_3.types;
package net.raphimc.vialegacy.protocol.beta.b1_7_0_3tob1_8_0_1.types;
import com.viaversion.viaversion.api.type.Type;

View File

@ -0,0 +1,114 @@
/*
* This file is part of ViaLegacy - https://github.com/RaphiMC/ViaLegacy
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1;
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.Types;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.packet.ClientboundPacketsb1_8;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.packet.ServerboundPacketsb1_8;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.rewriter.ItemRewriter;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.storage.PlayerAirTimeStorage;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.task.PlayerAirTimeUpdateTask;
import net.raphimc.vialegacy.protocol.release.r1_0_0_1tor1_1.packet.ClientboundPackets1_0_0;
import net.raphimc.vialegacy.protocol.release.r1_0_0_1tor1_1.packet.ServerboundPackets1_0_0;
import net.raphimc.vialegacy.protocol.release.r1_2_4_5tor1_3_1_2.types.Types1_2_4;
import net.raphimc.vialegacy.protocol.release.r1_4_2tor1_4_4_5.types.Types1_4_2;
import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.types.Types1_7_6;
public class Protocolb1_8_0_1tor1_0_0_1 extends StatelessProtocol<ClientboundPacketsb1_8, ClientboundPackets1_0_0, ServerboundPacketsb1_8, ServerboundPackets1_0_0> {
private final ItemRewriter itemRewriter = new ItemRewriter(this);
public Protocolb1_8_0_1tor1_0_0_1() {
super(ClientboundPacketsb1_8.class, ClientboundPackets1_0_0.class, ServerboundPacketsb1_8.class, ServerboundPackets1_0_0.class);
}
@Override
protected void registerPackets() {
super.registerPackets();
this.registerClientbound(ClientboundPacketsb1_8.SET_EXPERIENCE, wrapper -> {
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(Types.FLOAT, experience); // experience bar
wrapper.write(Types.SHORT, (short) experienceLevel); // level
wrapper.write(Types.SHORT, experienceTotal); // total experience
});
this.registerClientbound(ClientboundPacketsb1_8.CONTAINER_SET_SLOT, new PacketHandlers() {
@Override
public void register() {
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.CONTAINER_SET_CONTENT, new PacketHandlers() {
@Override
public void register() {
map(Types.BYTE); // window id
map(Types1_4_2.NBTLESS_ITEM_ARRAY, Types1_2_4.NBT_ITEM_ARRAY); // item
}
});
this.registerServerbound(ServerboundPackets1_0_0.USE_ITEM_ON, new PacketHandlers() {
@Override
public void register() {
map(Types1_7_6.POSITION_UBYTE); // position
map(Types.UNSIGNED_BYTE); // direction
map(Types1_2_4.NBT_ITEM, Types1_4_2.NBTLESS_ITEM);
}
});
this.registerServerbound(ServerboundPackets1_0_0.CONTAINER_CLICK, new PacketHandlers() {
@Override
public void register() {
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_0.CONTAINER_BUTTON_CLICK);
}
@Override
public void register(ViaProviders providers) {
Via.getPlatform().runRepeatingSync(new PlayerAirTimeUpdateTask(), 1L);
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolb1_8_0_1tor1_0_0_1.class, ClientboundPacketsb1_8::getPacket));
userConnection.put(new PlayerAirTimeStorage());
}
@Override
public ItemRewriter getItemRewriter() {
return this.itemRewriter;
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1;
package net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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);
readEntityDataListb1_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);
readEntityDataListb1_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);

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1;
package net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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);

View File

@ -15,17 +15,18 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.rewriter;
package net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.rewriter;
import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter;
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;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.Protocolb1_8_0_1tor1_0_0_1;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.packet.ClientboundPacketsb1_8;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.types.Typesb1_8_0_1;
import net.raphimc.vialegacy.protocol.release.r1_0_0_1tor1_1.packet.ServerboundPackets1_0_0;
import net.raphimc.vialegacy.protocol.release.r1_2_4_5tor1_3_1_2.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_0, Protocolb1_8_0_1tor1_0_0_1> {
public ItemRewriter(final Protocol1_0_0_1tob1_8_0_1 protocol) {
public ItemRewriter(final Protocolb1_8_0_1tor1_0_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);
this.addNonExistentItemRange(110, 122);
@ -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_0.SET_CREATIVE_MODE_SLOT);
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.storage;
package net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.storage;
import com.viaversion.viaversion.api.connection.StorableObject;

View File

@ -15,24 +15,24 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.task;
package net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_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;
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.storage.PlayerAirTimeStorage;
import net.raphimc.vialegacy.protocols.release.protocol1_1to1_0_0_1.ClientboundPackets1_0;
import net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types.MetaType1_3_1;
import net.raphimc.vialegacy.protocols.release.protocol1_4_2to1_3_1_2.types.Types1_3_1;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ChunkTracker;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.PlayerInfoStorage;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.Protocolb1_8_0_1tor1_0_0_1;
import net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.storage.PlayerAirTimeStorage;
import net.raphimc.vialegacy.protocol.release.r1_0_0_1tor1_1.packet.ClientboundPackets1_0_0;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.types.EntityDataTypes1_3_1;
import net.raphimc.vialegacy.protocol.release.r1_3_1_2tor1_4_2.types.Types1_3_1;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ChunkTracker;
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.PlayerInfoStorage;
import java.util.logging.Level;
@ -50,7 +50,7 @@ public class PlayerAirTimeUpdateTask implements Runnable {
try {
final IdAndData headBlock = info.get(ChunkTracker.class).getBlockNotNull(floor(playerInfoStorage.posX), floor(playerInfoStorage.posY + 1.62F), floor(playerInfoStorage.posZ));
if (headBlock.getId() == BlockList1_6.waterMoving.blockID || headBlock.getId() == BlockList1_6.waterStill.blockID) {
if (headBlock.getId() == BlockList1_6.waterMoving.blockId() || headBlock.getId() == BlockList1_6.waterStill.blockId()) {
playerAirTimeStorage.sentPacket = false;
playerAirTimeStorage.air--;
if (playerAirTimeStorage.air < 0) playerAirTimeStorage.air = 0;
@ -68,11 +68,11 @@ 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
updateAirTime.send(Protocol1_0_0_1tob1_8_0_1.class);
private void sendAirTime(final PlayerInfoStorage playerInfoStorage, final PlayerAirTimeStorage playerAirTimeStorage, final UserConnection userConnection) {
final PacketWrapper updateAirTime = PacketWrapper.create(ClientboundPackets1_0_0.SET_ENTITY_DATA, userConnection);
updateAirTime.write(Types.INT, playerInfoStorage.entityId); // entity id
updateAirTime.write(Types1_3_1.ENTITY_DATA_LIST, Lists.newArrayList(new EntityData(1, EntityDataTypes1_3_1.SHORT, Integer.valueOf(playerAirTimeStorage.air).shortValue()))); // entity data
updateAirTime.send(Protocolb1_8_0_1tor1_0_0_1.class);
}
private static int floor(double f) {

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.types;
package net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.types;
import com.viaversion.viaversion.api.minecraft.item.DataItem;
import com.viaversion.viaversion.api.minecraft.item.Item;
@ -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);

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.beta.protocol1_0_0_1tob1_8_0_1.types;
package net.raphimc.vialegacy.protocol.beta.b1_8_0_1tor1_0_0_1.types;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.type.Type;

View File

@ -0,0 +1,85 @@
/*
* This file is part of ViaLegacy - https://github.com/RaphiMC/ViaLegacy
* Copyright (C) 2020-2024 RK_01/RaphiMC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocol.classic.c0_0_15a_1toc0_0_16a_02;
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.Types;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
import net.raphimc.vialegacy.protocol.classic.c0_0_15a_1toc0_0_16a_02.packet.ClientboundPacketsc0_15a;
import net.raphimc.vialegacy.protocol.classic.c0_0_15a_1toc0_0_16a_02.packet.ServerboundPacketsc0_15a;
import net.raphimc.vialegacy.protocol.classic.c0_0_19a_06toc0_0_20a_27.packet.ClientboundPacketsc0_19a;
import net.raphimc.vialegacy.protocol.classic.c0_0_19a_06toc0_0_20a_27.packet.ServerboundPacketsc0_19a;
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.types.Typesc0_30;
public class Protocolc0_0_15a_1Toc0_0_16a_02 extends StatelessProtocol<ClientboundPacketsc0_15a, ClientboundPacketsc0_19a, ServerboundPacketsc0_15a, ServerboundPacketsc0_19a> {
public Protocolc0_0_15a_1Toc0_0_16a_02() {
super(ClientboundPacketsc0_15a.class, ClientboundPacketsc0_19a.class, ServerboundPacketsc0_15a.class, ServerboundPacketsc0_19a.class);
}
@Override
protected void registerPackets() {
this.registerClientbound(ClientboundPacketsc0_15a.LOGIN, wrapper -> {
final String username = wrapper.read(Typesc0_30.STRING); // username
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.TELEPORT_ENTITY, new PacketHandlers() {
@Override
public void register() {
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(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.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_15a_1Toc0_0_16a_02.class);
entityRotation.send(Protocolc0_0_15a_1Toc0_0_16a_02.class);
wrapper.cancel();
});
}
});
this.registerServerbound(ServerboundPacketsc0_19a.LOGIN, wrapper -> {
wrapper.clearPacket();
wrapper.write(Typesc0_30.STRING, wrapper.user().getProtocolInfo().getUsername()); // username
});
this.cancelServerbound(ServerboundPacketsc0_19a.CHAT);
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new PreNettySplitter(Protocolc0_0_15a_1Toc0_0_16a_02.class, ClientboundPacketsc0_15a::getPacket));
}
}

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.classic.protocolc0_0_16a_02to0_0_15a_1;
package net.raphimc.vialegacy.protocol.classic.c0_0_15a_1toc0_0_16a_02.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@ -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];

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.classic.protocolc0_0_16a_02to0_0_15a_1;
package net.raphimc.vialegacy.protocol.classic.c0_0_15a_1toc0_0_16a_02.packet;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
@ -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];

View File

@ -15,15 +15,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.classic.protocolc0_0_18a_02toc0_0_16a_02;
package net.raphimc.vialegacy.protocol.classic.c0_0_16a_02toc0_0_18a_02;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.protocols.classic.protocolc0_0_20a_27toc0_0_19a_06.ClientboundPacketsc0_19a;
import net.raphimc.vialegacy.protocols.classic.protocolc0_0_20a_27toc0_0_19a_06.ServerboundPacketsc0_19a;
import net.raphimc.vialegacy.protocol.classic.c0_0_19a_06toc0_0_20a_27.packet.ClientboundPacketsc0_19a;
import net.raphimc.vialegacy.protocol.classic.c0_0_19a_06toc0_0_20a_27.packet.ServerboundPacketsc0_19a;
public class Protocolc0_0_18a_02toc0_0_16a_02 extends StatelessProtocol<ClientboundPacketsc0_19a, ClientboundPacketsc0_19a, ServerboundPacketsc0_19a, ServerboundPacketsc0_19a> {
public class Protocolc0_0_16a_02Toc0_0_18a_02 extends StatelessProtocol<ClientboundPacketsc0_19a, ClientboundPacketsc0_19a, ServerboundPacketsc0_19a, ServerboundPacketsc0_19a> {
public Protocolc0_0_18a_02toc0_0_16a_02() {
public Protocolc0_0_16a_02Toc0_0_18a_02() {
super(ClientboundPacketsc0_19a.class, ClientboundPacketsc0_19a.class, ServerboundPacketsc0_19a.class, ServerboundPacketsc0_19a.class);
}

View File

@ -15,26 +15,26 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.vialegacy.protocols.classic.protocolc0_0_19a_06toc0_0_18a_02;
package net.raphimc.vialegacy.protocol.classic.c0_0_18a_02toc0_0_19a_06;
import com.viaversion.viaversion.api.connection.UserConnection;
import net.raphimc.vialegacy.api.protocol.StatelessProtocol;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.data.ClassicBlocks;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.storage.ClassicBlockRemapper;
import net.raphimc.vialegacy.protocols.classic.protocolc0_0_20a_27toc0_0_19a_06.ClientboundPacketsc0_19a;
import net.raphimc.vialegacy.protocols.classic.protocolc0_0_20a_27toc0_0_19a_06.ServerboundPacketsc0_19a;
import net.raphimc.vialegacy.protocol.classic.c0_0_19a_06toc0_0_20a_27.packet.ClientboundPacketsc0_19a;
import net.raphimc.vialegacy.protocol.classic.c0_0_19a_06toc0_0_20a_27.packet.ServerboundPacketsc0_19a;
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.data.ClassicBlocks;
import net.raphimc.vialegacy.protocol.classic.c0_28_30toa1_0_15.storage.ClassicBlockRemapper;
public class Protocolc0_0_19a_06toc0_0_18a_02 extends StatelessProtocol<ClientboundPacketsc0_19a, ClientboundPacketsc0_19a, ServerboundPacketsc0_19a, ServerboundPacketsc0_19a> {
public class Protocolc0_0_18a_02Toc0_0_19a_06 extends StatelessProtocol<ClientboundPacketsc0_19a, ClientboundPacketsc0_19a, ServerboundPacketsc0_19a, ServerboundPacketsc0_19a> {
public Protocolc0_0_19a_06toc0_0_18a_02() {
public Protocolc0_0_18a_02Toc0_0_19a_06() {
super(ClientboundPacketsc0_19a.class, ClientboundPacketsc0_19a.class, ServerboundPacketsc0_19a.class, ServerboundPacketsc0_19a.class);
}
@Override
public void init(UserConnection userConnection) {
final ClassicBlockRemapper previousRemapper = userConnection.get(ClassicBlockRemapper.class);
userConnection.put(new ClassicBlockRemapper(previousRemapper.getMapper(), o -> {
int block = previousRemapper.getReverseMapper().getInt(o);
userConnection.put(new ClassicBlockRemapper(previousRemapper.mapper(), o -> {
int block = previousRemapper.reverseMapper().getInt(o);
if (block != ClassicBlocks.STONE && block != ClassicBlocks.DIRT && block != ClassicBlocks.WOOD && block != ClassicBlocks.SAPLING && block != ClassicBlocks.GRAVEL && block != ClassicBlocks.LOG && block != ClassicBlocks.LEAVES && block != ClassicBlocks.SAND && block != ClassicBlocks.COBBLESTONE) {
block = ClassicBlocks.STONE;
}

Some files were not shown because too many files have changed in this diff Show More