Where is the mistake?
-
help me!Why can't it be detected?
var S45PacketTitle = Java.type("net.minecraft.network.play.server.S45PacketTitle"); this.onPacket = function(event) { var packet = event.getPacket(); if(packet instanceof S45PacketTitle) { if(packet.getType().equals(S45PacketTitle.Type.TITLE)) { var text = packet.getMessage().getUnformattedText(); if (text.equals("Victory!")) { //problem mc.thePlayer.sendChatMessage("GG"); } } }
-
gettype()
-
@idkwhome-v2 How to deal with it?
-
@ButterChicken Title messages are often in siblings or smth, print the component and find where the "Victory!" is.
-
@ButterChicken said in Where is the mistake?:
if (text.equals("Victory!")) { //problem
mc.thePlayer.sendChatMessage("GG");
}if (text.equals("Victory!")) { //problem mc.thePlayer.sendChatMessage("GG"); } else chat.print(text) //So that u can actually see what the title really is (exact string will be shown in [CHAT in .minecraft/logs/latest.txt)
but anyway I suggest to find/match part of the string. like
text.contains("Victory")
but it seemed that there is no such method in nashorn so u might have to usetext.indexOf("Victory") != -1
-
@commandblock2 Text would probably return "". So he would need to get siblings and stuff to get the msg. String.contains() is in Nashorn tho.
-
So have figured out a solution?
-
@ButterChicken That's what you were supposed to do.
@CzechHek said in Where is the mistake?:
@ButterChicken Title messages are often in siblings or smth, print the component and find where the "Victory!" is.
Here is the documentation: https://scriptapi.liquidbounce.net/net/minecraft/util/ChatComponentText.html