Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 08:10:09 +01:00
Implement 1.12 Meta Type & Remove Pre6 support since Spigot released 1.12
Dieser Commit ist enthalten in:
Ursprung
2446577188
Commit
e19d7e88bd
@ -9,7 +9,6 @@ import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_11_1to1_11.Protocol1_11_1To1_11;
|
||||
import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_12_Pre6;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2TO1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.Protocol1_9_3TO1_9_1_2;
|
||||
@ -43,8 +42,6 @@ public class ProtocolRegistry {
|
||||
registerProtocol(new Protocol1_11To1_10(), Collections.singletonList(ProtocolVersion.v1_11.getId()), ProtocolVersion.v1_10.getId());
|
||||
registerProtocol(new Protocol1_11_1To1_11(), Collections.singletonList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_11.getId());
|
||||
registerProtocol(new Protocol1_12To1_11_1(), Collections.singletonList(ProtocolVersion.v1_12.getId()), ProtocolVersion.v1_11_1.getId());
|
||||
// 1.12 -> 1.12-pre6 server (as per popular request)
|
||||
registerProtocol(new Protocol1_12To1_12_Pre6(), Collections.singletonList(ProtocolVersion.v1_12.getId()), ProtocolVersion.v1_12_pre6.getId());
|
||||
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ public class ProtocolVersion {
|
||||
public static final ProtocolVersion v1_11;
|
||||
public static final ProtocolVersion v1_11_1;
|
||||
public static final ProtocolVersion v1_12;
|
||||
public static final ProtocolVersion v1_12_pre6;
|
||||
public static final ProtocolVersion unknown;
|
||||
|
||||
private final int id;
|
||||
@ -57,7 +56,6 @@ public class ProtocolVersion {
|
||||
register(v1_11 = new ProtocolVersion(315, "1.11"));
|
||||
register(v1_11_1 = new ProtocolVersion(316, "1.11.1"));
|
||||
register(v1_12 = new ProtocolVersion(335, "1.12"));
|
||||
register(v1_12_pre6 = new ProtocolVersion(333, "1.12-pre6"));
|
||||
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
package us.myles.ViaVersion.api.type.types.version;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_12;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.MetaTypeTemplate;
|
||||
|
||||
public class Metadata1_12Type extends MetaTypeTemplate {
|
||||
@Override
|
||||
public Metadata read(ByteBuf buffer) throws Exception {
|
||||
short index = buffer.readUnsignedByte();
|
||||
|
||||
if (index == 0xff) return null; //End of metadata
|
||||
MetaType1_12 type = MetaType1_12.byId(buffer.readByte());
|
||||
|
||||
return new Metadata(index, type, type.getType().read(buffer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, Metadata object) throws Exception {
|
||||
if (object == null) {
|
||||
buffer.writeByte(255);
|
||||
} else {
|
||||
buffer.writeByte(object.getId());
|
||||
buffer.writeByte(object.getMetaType().getTypeID());
|
||||
object.getMetaType().getType().write(buffer, object.getValue());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package us.myles.ViaVersion.api.type.types.version;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.MetaListTypeTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataList1_12Type extends MetaListTypeTemplate {
|
||||
@Override
|
||||
public List<Metadata> read(ByteBuf buffer) throws Exception {
|
||||
List<Metadata> list = new ArrayList<>();
|
||||
Metadata meta;
|
||||
do {
|
||||
meta = Types1_12.METADATA.read(buffer);
|
||||
if (meta != null)
|
||||
list.add(meta);
|
||||
} while (meta != null);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, List<Metadata> object) throws Exception {
|
||||
for (Metadata m : object)
|
||||
Types1_12.METADATA.write(buffer, m);
|
||||
|
||||
// Write end of list
|
||||
Types1_12.METADATA.write(buffer, null);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package us.myles.ViaVersion.api.type.types.version;
|
||||
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Types1_12 {
|
||||
/**
|
||||
* Metadata list type for 1.12
|
||||
*/
|
||||
public static final Type<List<Metadata>> METADATA_LIST = new MetadataList1_12Type();
|
||||
|
||||
/**
|
||||
* Metadata type for 1.12
|
||||
*/
|
||||
public static final Type<Metadata> METADATA = new Metadata1_12Type();
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
|
||||
public class Protocol1_12To1_12_Pre6 extends Protocol {
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerOutgoing(State.PLAY, 0x48, 0x48, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Sound name
|
||||
map(Type.VAR_INT); // 1 - Sound Category
|
||||
map(Type.INT); // 2 - x
|
||||
map(Type.INT); // 3 - y
|
||||
map(Type.INT); // 4 - z
|
||||
map(Type.FLOAT); // 5 - Volume
|
||||
map(Type.FLOAT); // 6 - Pitch
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int id = wrapper.get(Type.VAR_INT, 0);
|
||||
id = getNewSoundId(id);
|
||||
|
||||
if (id == -1) // Removed
|
||||
wrapper.cancel();
|
||||
wrapper.set(Type.VAR_INT, 0, id);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
|
||||
}
|
||||
|
||||
private int getNewSoundId(int id) { //TODO Make it better, suggestions are welcome. It's ugly and hardcoded now.
|
||||
int newId = id;
|
||||
if (id >= 544) // UI toast sound
|
||||
newId += 3;
|
||||
return newId;
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren