update packetid to 1.21
fix compile issue
This commit is contained in:
51
data/packetid/generator/GenPacketId.java
Normal file
51
data/packetid/generator/GenPacketId.java
Normal file
@ -0,0 +1,51 @@
|
||||
package pers.tnze.gomc.gen;
|
||||
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.network.ProtocolInfo;
|
||||
import net.minecraft.network.protocol.configuration.ConfigurationProtocols;
|
||||
import net.minecraft.network.protocol.game.GameProtocols;
|
||||
import net.minecraft.network.protocol.login.LoginProtocols;
|
||||
import net.minecraft.network.protocol.status.StatusProtocols;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
public class GenPacketId {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SharedConstants.tryDetectVersion();
|
||||
Bootstrap.bootStrap();
|
||||
try (FileWriter w = new FileWriter("packet_names.txt")) {
|
||||
handlePackets(w, LoginProtocols.CLIENTBOUND_TEMPLATE, "ClientboundLogin");
|
||||
handlePackets(w, LoginProtocols.SERVERBOUND_TEMPLATE, "ServerboundLogin");
|
||||
handlePackets(w, StatusProtocols.CLIENTBOUND_TEMPLATE, "ClientboundStatus");
|
||||
handlePackets(w, StatusProtocols.SERVERBOUND_TEMPLATE, "ServerboundStatus");
|
||||
handlePackets(w, ConfigurationProtocols.CLIENTBOUND_TEMPLATE, "ClientboundConfig");
|
||||
handlePackets(w, ConfigurationProtocols.SERVERBOUND_TEMPLATE, "ServerboundConfig");
|
||||
handlePackets(w, GameProtocols.CLIENTBOUND_TEMPLATE, "");
|
||||
handlePackets(w, GameProtocols.SERVERBOUND_TEMPLATE, "");
|
||||
}
|
||||
}
|
||||
|
||||
private static void handlePackets(Writer w, ProtocolInfo.Unbound<?, ?> packets, String prefix) throws IOException {
|
||||
packets.listPackets((packetType, i) -> {
|
||||
String packetName = packetType.id().getPath();
|
||||
String[] words = packetName.split("_");
|
||||
try {
|
||||
if (prefix != null) {
|
||||
w.write(prefix);
|
||||
}
|
||||
for (String word : words) {
|
||||
w.write(Character.toUpperCase(word.charAt(0)));
|
||||
w.write(word.substring(1));
|
||||
}
|
||||
w.write("\n");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
w.write('\n');
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package pers.tnze.gomc.gen;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.network.ConnectionProtocol;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
try (FileWriter w = new FileWriter("packet_names.txt")) {
|
||||
handlePackets(w, ConnectionProtocol.LOGIN.getPacketsByIds(PacketFlow.CLIENTBOUND));
|
||||
System.out.println();
|
||||
handlePackets(w, ConnectionProtocol.LOGIN.getPacketsByIds(PacketFlow.SERVERBOUND));
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
handlePackets(w, ConnectionProtocol.STATUS.getPacketsByIds(PacketFlow.CLIENTBOUND));
|
||||
System.out.println();
|
||||
handlePackets(w, ConnectionProtocol.STATUS.getPacketsByIds(PacketFlow.SERVERBOUND));
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
handlePackets(w, ConnectionProtocol.CONFIGURATION.getPacketsByIds(PacketFlow.CLIENTBOUND));
|
||||
System.out.println();
|
||||
handlePackets(w, ConnectionProtocol.CONFIGURATION.getPacketsByIds(PacketFlow.SERVERBOUND));
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
handlePackets(w, ConnectionProtocol.PLAY.getPacketsByIds(PacketFlow.CLIENTBOUND));
|
||||
System.out.println();
|
||||
handlePackets(w, ConnectionProtocol.PLAY.getPacketsByIds(PacketFlow.SERVERBOUND));
|
||||
}
|
||||
}
|
||||
|
||||
private static void handlePackets(Writer w, Int2ObjectMap<Class<? extends Packet<?>>> packets) throws IOException {
|
||||
for (int i = 0; i < packets.size(); i++) {
|
||||
Class<? extends Packet<?>> c = packets.get(i);
|
||||
String className = c.getSimpleName();
|
||||
if (className.endsWith("Packet"))
|
||||
className = className.substring(0, className.length() - "Packet".length());
|
||||
else {
|
||||
String superClassName = c.getSuperclass().getSimpleName();
|
||||
if (superClassName.endsWith("Packet"))
|
||||
className = superClassName.substring(0, superClassName.length() - "Packet".length()) + className;
|
||||
}
|
||||
System.out.println(className);
|
||||
w.write(className + "\n");
|
||||
}
|
||||
w.write('\n');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user