Jump to content

Recommended Posts

Posted (edited)

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_
Posted (edited)
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_
Posted

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/

Posted
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 :/

Posted
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.

Posted (edited)
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_
Posted
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);
                }

 

Posted
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?

Posted
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

Posted
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?

Posted

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.

Posted
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

Posted
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 :)

Posted
1 minute ago, diesieben07 said:

equals. You need to call equals.

 

Seriously, you could not figure that out from my responses?

"if(event.entity.getUniqueID().equals(74a1dcea-1946-45a9-a373-5f1b211f4d07))" gives an error so I tried something else

Posted (edited)
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_

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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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