Jump to content

[Unsolved] Problem with ChatEvent


Zillex_

Recommended Posts

Hello, this is a really simple problem. when I use ClientChatReceivedEvent my chat completely stops working, I can type but nothing shows up. all I'm trying to do is play a sound when the server says something eg: Zillex_ was killed by etc. thanks for your answers :)

Edited by Zillex_
Link to comment
Share on other sites

35 minutes ago, Differentiation said:

Please post your code. :)

Spoiler

package *****;

import cerni.proxy.CommonProxy;

import ibxm.Player;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.Chat;
import net.minecraftforge.client.event.sound.SoundEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod(modid = Main.MOD_ID, name = Main.NAME, version = Main.VERSION)
public class Main {
    public static final String MOD_ID = "zillexcm";
    public static final String NAME = "*****";
    public static final String VERSION = "0.1";
    public String msg;
    
    @Instance
    
    public static Main instance;
    
    @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
    
    public static CommonProxy proxy;
    
    @Mod.EventHandler
    
    public void init(FMLInitializationEvent event) {
        MinecraftForge.EVENT_BUS.register(this);
    }
    

    
    
    @SubscribeEvent
    
    public void onChatReceived(ClientChatReceivedEvent event) {
        
        if(msg.contains("Zillex_ was killed by")) {
            Minecraft.getMinecraft().thePlayer.playSound("zillexcm:sounds.jigglypuff1", 5.0F, 1.0F);
        }
        if(event.message.contains("Zillex_ fell into the void")) {
            Minecraft.getMinecraft().thePlayer.playSound("zillexcm:sounds.jigglypuff2", 5.0F, 1.0F);
        }
        if(event.message.contains("Zillex_ was thrown into the void")) {
            Minecraft.getMinecraft().thePlayer.playSound("zillexcm:sounds.jigglypuff3", 5.0F, 1.0F);
        }
        if(event.message.contains("fell from a high place")) {
            Minecraft.getMinecraft().thePlayer.playSound("zillexcm:sounds.jigglypuff4", 5.0F, 1.0F);
        }


    }
    

}
 

 

Edited by Zillex_
Link to comment
Share on other sites

Using ClientChatReceivedEvent is probably the reason it isn't working, and I don't know why it was the first event you thought of to detect player deaths, but there's the LivingDeathEvent you can use to detect entity deaths (for players: event.getEntityLiving() instanceof EntityPlayer).

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

1 hour ago, larsgerrits said:

Using ClientChatReceivedEvent is probably the reason it isn't working, and I don't know why it was the first event you thought of to detect player deaths, but there's the LivingDeathEvent you can use to detect entity deaths (for players: event.getEntityLiving() instanceof EntityPlayer).

I'd rather not use that because I'm making the mod for a specific person who wants it to only play when they die and not for others :/

Link to comment
Share on other sites

4 hours ago, Zillex_ said:

I'd rather not use that because I'm making the mod for a specific person who wants it to only play when they die and not for others :/

You can also check which player died by checking their UUID.

 

Just now, jabelar said:

Then just check for his/her username when you're processing the event.

Usernames can change, it's best to compare UUIDs instead as they're constant and unique.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

5 hours ago, Choonster said:

You can also check which player died by checking their UUID.

 

Usernames can change, it's best to compare UUIDs instead as they're constant and unique.

But how will i know his uuid? or even mine for that matter

Edited by Zillex_
Link to comment
Share on other sites

1 hour ago, diesieben07 said:

this plays when not checking the uuid but when it checks it the sound doesn't play, any suggestions? code:

Spoiler

@SubscribeEvent
    
    public void onDeath(LivingDeathEvent event) {
        
        if(event.entity instanceof EntityPlayer) {
            
            if(!event.entity.isEntityAlive()) {
                if(event.entity.getUniqueID().equals("74a1dcea-1946-45a9-a373-5f1b211f4d07")) {
                    Minecraft.getMinecraft().thePlayer.playSound("zillexcm:sounds.jigglypuff", 5.0F, 1.0F);
                }

 

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

getUniqueID returns a UUID, it will never be equal to a String. Your IDE should warn you about this. Either it doesn't (get a proper IDE or configure it properly) or you ignored that warning (why?).

Also why are you bumping after 2 hours?

sorry for the bump, and yes I accidentally ignored the warning woops. but what do I do, you didn't give me a fix?

Link to comment
Share on other sites

32 minutes ago, diesieben07 said:

If you know basic Java you should know how to fix this.

this still doesn't help me, i know basic java, I have made plugins for servers before. This is my first week with the forge api, so will you help? or just give me more elusive statements

Link to comment
Share on other sites

5 minutes ago, diesieben07 said:

This has nothing to do with the Forge API.

Two objects of different types (java.util.UUID and java.lang.String, both not from the Forge API) will never be equal to each other. You have to use the same type for both, in this case java.util.UUID is appropriate, since you are comparing UUIDs.

okay but how do I compare the uuids with the forge api the only function compareTo(UUID) which says it takes in a byte but as you mentioned I can't get a byte to a UUID or can I? I'm not fluent in the forge api so what do I pass inside the compareTo(UUID) a byte or a UUID?

Link to comment
Share on other sites

someUuid == otherUuid

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

4 minutes ago, Draco18s said:

someUuid == otherUuid

thanks but its late and I understand nothing so I did this: if(event.entity.getUniqueID().compareTo(74a1dcea-1946-45a9-a373-5f1b211f4d07 == 74a1dcea-1946-45a9-a373-5f1b211f4d07))

 

ik I'm doing something wrong but only worked with uuids a few times

Link to comment
Share on other sites

7 minutes ago, diesieben07 said:

but you said you are not a Java beginner.

not what I meant, I am a beginner but usually know what I'm doing but I thought, hey lets go on the forums for help instead of taking a couple hours to figure it out on my own, but all you're giving me is the same statement in different ways :)

Link to comment
Share on other sites

3 minutes ago, diesieben07 said:

Did you even read this (emphasis added)?

UUID uid = UUID.fromString("74a1dcea-1946-45a9-a373-5f1b211f4d07"); 
                
                if(event.entity.getUniqueID().equals(uid)) {

 

 not even going to ask you for help :) even if its incorrect

 

Edited by Zillex_
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Slot depo 5k merupakan situs slot depo 5k yang menyediakan slot minimal deposit 5rb atau 5k via dana yang super gacor, dimana para pemain hanya butuh modal depo sebesar 5k untuk bisa bermain di link slot gacor thailand terbaru tahun 2024 yang gampang menang ini.   DAFTAR & LOGIN AKUN PRO SLOT DEPO 5K ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit 3000 adalah situs slot deposit 3000 via dana yang super gacor dimana para pemain dijamin garansi wd hari ini juga hanya dengan modal receh berupa deposit sebesar 3000 baik via dana, ovo, gopay maupun linkaja untuk para pemain pengguna e-wallet di seluruh Indonesia.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT 3000 ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • OLXTOTO: Menikmati Sensasi Bermain Togel dan Slot dengan Aman dan Mengasyikkan Dunia perjudian daring terus berkembang dengan cepat, dan salah satu situs yang telah menonjol dalam pasar adalah OLXTOTO. Sebagai platform resmi untuk permainan togel dan slot, OLXTOTO telah memenangkan kepercayaan banyak pemain dengan menyediakan pengalaman bermain yang aman, adil, dan mengasyikkan. DAFTAR OLXTOTO DISINI Keamanan Sebagai Prioritas Utama Salah satu aspek utama yang membuat OLXTOTO begitu menonjol adalah komitmennya terhadap keamanan pemain. Dengan menggunakan teknologi enkripsi terkini, situs ini memastikan bahwa semua informasi pribadi dan keuangan para pemain tetap aman dan terlindungi dari akses yang tidak sah. Beragam Permainan yang Menarik Di OLXTOTO, pemain dapat menemukan beragam permainan yang menarik untuk dinikmati. Mulai dari permainan klasik seperti togel hingga slot modern dengan fitur-fitur inovatif, ada sesuatu untuk setiap selera dan preferensi. Grafik yang memukau dan efek suara yang mengagumkan menambah keseruan setiap putaran. Peluang Menang yang Tinggi Salah satu hal yang paling menarik bagi para pemain adalah peluang menang yang tinggi yang ditawarkan oleh OLXTOTO. Dengan pembayaran yang adil dan peluang yang setara bagi semua pemain, setiap taruhan memberikan kesempatan nyata untuk memenangkan hadiah besar. Layanan Pelanggan yang Responsif Tim layanan pelanggan OLXTOTO siap membantu para pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Dengan layanan yang ramah dan responsif, pemain dapat yakin bahwa mereka akan mendapatkan bantuan yang mereka butuhkan dengan cepat dan efisien. Kesimpulan OLXTOTO telah membuktikan dirinya sebagai salah satu situs terbaik untuk penggemar togel dan slot online. Dengan fokus pada keamanan, beragam permainan yang menarik, peluang menang yang tinggi, dan layanan pelanggan yang luar biasa, tidak mengherankan bahwa situs ini telah menjadi pilihan utama bagi banyak pemain. Jadi, jika Anda mencari pengalaman bermain yang aman, adil, dan mengasyikkan, jangan ragu untuk bergabung dengan OLXTOTO hari ini dan rasakan sensasi kemenangan!
    • Slot deposit dana adalah situs slot deposit dana yang juga menerima dari e-wallet lain seperti deposit via dana, ovo, gopay & linkaja terlengkap saat ini, sehingga para pemain yang tidak memiliki rekening bank lokal bisa tetap bermain slot dan terbantu dengan adanya fitur tersebut.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit dana adalah situs slot deposit dana minimal 5000 yang dijamin garansi super gacor dan gampang menang, dimana para pemain yang tidak memiliki rekening bank lokal tetap dalam bermain slot dengan melakukan deposit dana serta e-wallet lainnya seperti ovo, gopay maupun linkaja lengkap. Agar para pecinta slot di seluruh Indonesia tetap dapat menikmati permainan tanpa halangan apapun khususnya metode deposit, dimana ketersediaan cara deposit saat ini yang lebih beragam tentunya sangat membantu para pecinta slot.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
  • Topics

×
×
  • Create New...

Important Information

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