mirror of
https://e.coding.net/circlecloud/YumCore.git
synced 2024-11-24 02:08:48 +00:00
修复聊天包
This commit is contained in:
parent
1ed587e01a
commit
ff4c5f6f46
@ -48,52 +48,37 @@ public class C {
|
|||||||
private static Object[] chatMessageTypes;
|
private static Object[] chatMessageTypes;
|
||||||
|
|
||||||
public static boolean init;
|
public static boolean init;
|
||||||
public static boolean cauldron;
|
public static boolean cauldron1710;
|
||||||
public static boolean uranium;
|
public static boolean uranium;
|
||||||
public static boolean titlePAB;
|
public static boolean titlePAB;
|
||||||
static {
|
static {
|
||||||
version=getNMSVersion();
|
version=getNMSVersion();
|
||||||
titlePAB=false;
|
titlePAB=false;
|
||||||
if(version.equals("v1_7_R4")&&Package.getPackage("net.minecraftforge.cauldron")!=null) {
|
|
||||||
|
try {
|
||||||
|
cauldron1710 =version.equals("v1_7_R4")&&Package.getPackage("net.minecraftforge.cauldron1710")!=null;
|
||||||
|
if(cauldron1710) {
|
||||||
try{
|
try{
|
||||||
Class.forName("cc.uraniummc.Uranium");
|
Class.forName("cc.uraniummc.Uranium");
|
||||||
uranium=true;
|
uranium=true;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
Log.d("检测到不是Uranium服务端");
|
Log.d("检测到不是Uranium服务端");
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
cauldron=true;
|
|
||||||
newversion=false;
|
newversion=false;
|
||||||
nmsChatSerializer = Class.forName("net.minecraft.util.IChatComponent$Serializer");
|
nmsChatSerializer = Class.forName("net.minecraft.util.IChatComponent$Serializer");
|
||||||
chatSerializer = nmsChatSerializer.getMethod("func_150699_a", String.class);
|
chatSerializer = nmsChatSerializer.getMethod("func_150699_a", String.class);
|
||||||
nmsIChatBaseComponent = Class.forName("net.minecraft.util.IChatComponent");
|
nmsIChatBaseComponent = Class.forName("net.minecraft.util.IChatComponent");
|
||||||
packetType = Class.forName("net.minecraft.network.play.server.S02PacketChat");
|
packetType = Class.forName("net.minecraft.network.play.server.S02PacketChat");
|
||||||
Arrays.stream(packetType.getConstructors()).forEach(c -> {
|
Arrays.stream(packetType.getConstructors()).forEach(c -> {
|
||||||
if (c.getParameterTypes().length == 2) {
|
if (c.getParameterTypes().length == 2&&uranium) {
|
||||||
|
packetTypeConstructor = c;
|
||||||
|
}else if(c.getParameterTypes().length==1){
|
||||||
packetTypeConstructor = c;
|
packetTypeConstructor = c;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
nmsChatMessageTypeClass = packetTypeConstructor.getParameterTypes()[1];
|
|
||||||
if (nmsChatMessageTypeClass.isEnum()) {
|
|
||||||
chatMessageTypes = nmsChatMessageTypeClass.getEnumConstants();
|
|
||||||
} else if(uranium) {
|
|
||||||
titlePAB=true;
|
|
||||||
}
|
|
||||||
Class<?> typeCraftPlayer = Class.forName(b("entity.CraftPlayer"));
|
|
||||||
Class<?> typeNMSPlayer = Class.forName("net.minecraft.entity.player.EntityPlayerMP");
|
|
||||||
Class<?> typePlayerConnection = Class.forName("net.minecraft.network.NetHandlerPlayServer");
|
|
||||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
|
||||||
playerConnection = typeNMSPlayer.getField("field_71135_a");
|
|
||||||
sendPacket = typePlayerConnection.getMethod("func_147359_a", Class.forName("net.minecraft.network.Packet"));
|
|
||||||
init = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.w("C(Cauldron_1710) 兼容性工具初始化失败 可能造成部分功能不可用!");
|
|
||||||
Log.d(e);
|
|
||||||
}
|
|
||||||
}else {
|
}else {
|
||||||
try {
|
|
||||||
version = getNMSVersion();
|
|
||||||
newversion = Integer.parseInt(version.split("_")[1]) > 7;
|
newversion = Integer.parseInt(version.split("_")[1]) > 7;
|
||||||
|
titlePAB=newversion;
|
||||||
nmsChatSerializer = Class.forName(a(newversion ? "IChatBaseComponent$ChatSerializer" : "ChatSerializer"));
|
nmsChatSerializer = Class.forName(a(newversion ? "IChatBaseComponent$ChatSerializer" : "ChatSerializer"));
|
||||||
chatSerializer = nmsChatSerializer.getMethod("a", String.class);
|
chatSerializer = nmsChatSerializer.getMethod("a", String.class);
|
||||||
nmsIChatBaseComponent = Class.forName(a("IChatBaseComponent"));
|
nmsIChatBaseComponent = Class.forName(a("IChatBaseComponent"));
|
||||||
@ -103,6 +88,8 @@ public class C {
|
|||||||
packetTypeConstructor = c;
|
packetTypeConstructor = c;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
if(!cauldron1710||uranium) {
|
||||||
try {
|
try {
|
||||||
nmsChatMessageTypeClass = packetTypeConstructor.getParameterTypes()[1];
|
nmsChatMessageTypeClass = packetTypeConstructor.getParameterTypes()[1];
|
||||||
if (nmsChatMessageTypeClass.isEnum()) {
|
if (nmsChatMessageTypeClass.isEnum()) {
|
||||||
@ -119,19 +106,26 @@ public class C {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
packetTypeConstructor = packetType.getConstructor(String.class);
|
packetTypeConstructor = packetType.getConstructor(String.class);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Class<?> typeCraftPlayer = Class.forName(b("entity.CraftPlayer"));
|
Class<?> typeCraftPlayer = Class.forName(b("entity.CraftPlayer"));
|
||||||
|
getHandle = typeCraftPlayer.getMethod("getHandle");
|
||||||
|
if(cauldron1710) {
|
||||||
|
Class<?> typeNMSPlayer = Class.forName("net.minecraft.entity.player.EntityPlayerMP");
|
||||||
|
Class<?> typePlayerConnection = Class.forName("net.minecraft.network.NetHandlerPlayServer");
|
||||||
|
playerConnection = typeNMSPlayer.getField("field_71135_a");
|
||||||
|
sendPacket = typePlayerConnection.getMethod("func_147359_a", Class.forName("net.minecraft.network.Packet"));
|
||||||
|
}else{
|
||||||
Class<?> typeNMSPlayer = Class.forName(a("EntityPlayer"));
|
Class<?> typeNMSPlayer = Class.forName(a("EntityPlayer"));
|
||||||
Class<?> typePlayerConnection = Class.forName(a("PlayerConnection"));
|
Class<?> typePlayerConnection = Class.forName(a("PlayerConnection"));
|
||||||
getHandle = typeCraftPlayer.getMethod("getHandle");
|
|
||||||
playerConnection = typeNMSPlayer.getField("playerConnection");
|
playerConnection = typeNMSPlayer.getField("playerConnection");
|
||||||
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet")));
|
sendPacket = typePlayerConnection.getMethod("sendPacket", Class.forName(a("Packet")));
|
||||||
|
}
|
||||||
init = true;
|
init = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w("C 兼容性工具初始化失败 可能造成部分功能不可用!");
|
Log.w("C 兼容性工具初始化失败 可能造成部分功能不可用!");
|
||||||
Log.d(e);
|
Log.d(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private C() {
|
private C() {
|
||||||
}
|
}
|
||||||
@ -386,7 +380,7 @@ public class C {
|
|||||||
private static Constructor<?> packetTitleSetTimeConstructor;
|
private static Constructor<?> packetTitleSetTimeConstructor;
|
||||||
private static Object[] actions;
|
private static Object[] actions;
|
||||||
static {
|
static {
|
||||||
if(cauldron&&uranium) {
|
if(cauldron1710 &&uranium) {
|
||||||
try {
|
try {
|
||||||
packetActions = Class.forName("cc.uraniummc.packet.S45PacketTitle$Type");
|
packetActions = Class.forName("cc.uraniummc.packet.S45PacketTitle$Type");
|
||||||
packetTitle = Class.forName("cc.uraniummc.packet.S45PacketTitle");
|
packetTitle = Class.forName("cc.uraniummc.packet.S45PacketTitle");
|
||||||
|
Loading…
Reference in New Issue
Block a user