Fixed b1.3 - b1.4 metadata reading edge case

This commit is contained in:
RaphiMC 2023-07-28 00:41:03 +02:00
parent ec1b88627b
commit 72688b334b
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94

View File

@ -17,8 +17,10 @@
*/
package net.raphimc.vialegacy.protocols.beta.protocolb1_5_0_2tob1_4_0_1.types;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
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;
@ -29,7 +31,19 @@ public enum MetaTypeb1_4 implements MetaType {
Int(2, Type.INT),
Float(3, Type.FLOAT),
String(4, Typesb1_7_0_3.STRING),
Slot(5, Types1_3_1.NBTLESS_ITEM),
Slot(5, new Type<Item>(Item.class) { // b1.3 - b1.4 had broken read/write code where type 5 had a missing break statement causing it to read a type 6 as well (Both are unused)
@Override
public Item read(ByteBuf buffer) throws Exception {
Types1_3_1.NBTLESS_ITEM.read(buffer);
Type.VECTOR.read(buffer);
return null;
}
@Override
public void write(ByteBuf buffer, Item value) {
throw new UnsupportedOperationException();
}
}),
Position(6, Type.VECTOR);
private final int typeID;