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()
-
gettype()
@idkwhome-v2 How to deal with it?
-
@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.
-
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"); } } }@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 -
@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.
-
@commandblock2 Text would probably return "". So he would need to get siblings and stuff to get the msg. String.contains() is in Nashorn tho.
@CzechHek nvm I was blind
if (text.equals("Victory!")) { //problem mc.thePlayer.sendChatMessage("GG"); } else chat.print(packet.getMessage()) // anyway that's better -
So have figured out a solution?
-
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login