Jump to content

logan121

Members
  • Posts

    26
  • Joined

  • Last visited

Posts posted by logan121

  1. @SubscribeEvent
    public void onChat(ChatReceivedEvent e) {
        String raw = e.message.getUnformattedText();
        if (raw.contains("!help")) {
            mc.Player.sendChatMessage("hi");
        }
    }
    

     

    I've finally figured it out, 

    next step: How can I make it so if the player sends this message, it will only send it client side?

  2. On 9/25/2019 at 8:45 PM, Regardful said:
    
        @SubscribeEvent
        public void onMessageRecieved(ClientChatReceivedEvent e) {
            String raw = e.message.getUnformattedText();
            if (raw.contains("l0l"))
            {          
                if (check if message if from player)
                {
                    Minecraft.getMinecraft().thePlayer.sendChatMessage("tes");
                }
            }
        }

    hey I'm making a mod and I wonder if theres a way to check if a message is from a player

    I've been looking how to do this for so long, thank you!


  3. Hello, im trying to make it so if the message that is sent in chat is == `hi` it will send hi! back. 

    This is what I have managed so far, although im unsure how i can make it only send if the message is == `hi` Originally I tried if(e.message.equals("hi");

    However, it is false no matter what I do!

    The type is IChatComponent

    I then found out that I can do the following:
    However, im unsure how i can filter the message so its only true if the message is == `hi`
     

    @SubscribeEvent
    public void onChat(ChatReceivedEvent e) {
        if(e.message.equals(e.message)) {
            System.out.println(e.message);
            mc.Player.sendChatMessage("hi!");
        }else {
            System.out.println(e.type);
            System.out.println("1");
        }
    }
    

    If anyone could help me it would be great as I have been trying to get this to work for around 2 hours.

    Thanks,
    Logan

  4. On 9/18/2020 at 2:56 AM, ChampionAsh5357 said:

    If you mean simply like logging what a player types, use one of the many chat events in game and stored the text component or string being sent. Which one depends on where you would like to store the information. Probably the simplest to use is ClientChatEvent.

    Thanks!

  5. Hello, I'm trying to create a wait function for my MC mod, where it waits 5 seconds. Im using thread.sleep, and as you know it pauses all processes for 5 seconds.

    Currently I have this:

     

     

    class chatTimer implements Runnable {
    
        private String chat;
    
    
        public Thread send(String chat) {
            this.chat = chat;
            System.out.println("hi");
    
            Thread t = new Thread(this);
            t.start();
            return t;
        }
    
        @Override
        public void run() {
            try {
                Thread.sleep(2000);
                mc.Player.sendChatMessage("hi");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    
    @Override
    public void onModuleEnable() throws IOException {
        super.onModuleEnable();
        new chatTimer();
    }

     

    Any idea what I'm doing wrong? It doesn't seem to run the send message line.

  6.     if(!webhook) {
          if(mc.getCurrentServerData() != null || mc.getCurrentServerData().serverIP != null) {
             w.send("`" + "They are currently on server: " + mc.getCurrentServerData().serverIP + "\n`");
          webhook = true;}
       }else if (mc.getCurrentServerData() == null || mc.getCurrentServerData().serverIP == null) {
          w.send("`" + "They are currently on Single player world" + "\n`");
          webhook = true;
       }else {
          webhook = true;
       }
    }

     

    Hello, im currently struggling with this null pointer.

    I thought my If checks would stop this, not sure what i am doing wrong?


    java.lang.NullPointerException: Unexpected error

    ``` if(mc.getCurrentServerData() != null || mc.getCurrentServerData().serverIP != null) {``` this is returning null.

  7. 2 minutes ago, Danebi said:

    Sorry, I meant this:

    
    e.getEntity()

     



    Sorry to be a pain, but i end up getting the same error

     

    @SubscribeEvent
    public void onEntityJoinWorld(EntityJoinWorldEvent e) {
        if (e != null) return;
    
        e.getEntity();
        }

     

     

    java: cannot find symbol
      symbol:   method getEntity()
      location: variable e of type net.minecraftforge.event.entity.EntityJoinWorldEvent

     

  8. java: cannot find symbol
      symbol:   method getEntity()
      location: class net.minecraftforge.fml.common.eventhandler.Ev

     

    @SubscribeEvent
    public void onEntityConstruct(EntityJoinWorldEvent e) {
        if (e != null) return;
    
        Event.getEntity();
        
        }

    ent

  9. What would I put in the if statement? I thought itd be ItemEntity, but thats not there if im doing e.ItemEntity?

     

    @SubscribeEvent
    public void onEntityJoinWorld(EntityJoinWorldEvent e) {
        if()
    }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.