Jump to content

Can someone explain to me what 'events' are? [SOLVED]


EliteCreature

Recommended Posts

It's a big question. Maybe anyone has his own opinion. I'm trying to talk about mine.

 

'Event' is something that happened or is happening. When the zombie hit you, it's an event(And we would know that it's LivingAttackEvent and LivingHurtEvent).

 

As the mod required, you may want to know about what event is happenning. If we want to make zombie very very strong, we can catch the 'event' that when the damage is count(LivingHurtEvent), and change the damage to make the zombie stronger(there is other way to do this of course). Or we could apply special effect to the player when he's hit by zombie. To know when the player is hit, you need events.

 

And many other events, like LivingDeathEvent. To catch this event allow you to do something when someone(Zombie, Player or other living) died. And do something you want after this, like bury them. To know when someone die, you need events.

 

To catch the event, add an annotation before the method, and register it. The class is as below.

 

public class EventTest {
@ForgeSubscribe(priority = EventPriority.LOW,receiveCanceled = true)
public void test1(LivingFallEvent event)
{
    if(event.entityLiving instanceof EntityPlayer)
    {
        EntityPlayer entityPlayer = (EntityPlayer)event.entityLiving;
        entityPlayer.sendChatToPlayer(ChatMessageComponent.func_111066_d("Falling Star!You fell "+event.distance+ " meters.That's cool,man!");
    }
}
}

 

And registe it with

 MinecraftForge.EVENT_BUS.register(new EventTest());

 

So when someone fall to the ground, he will receive a message how far he fall.

 

And you can set event.distance to 0.0f or 24.f to get rid of the falling damage or make the player die when fall, no matter how far he falls.

 

And there are many feature of event, like result, priority, cancelable and so on.

Maybe you should figure it out yourself.

Link to comment
Share on other sites

Hi

 

Forge events are a way for the vanilla+forge code to call your code when something happens.  This lets you customise the game behaviour without having to modify the vanilla code yourself.

 

For example - PlayerSleepInBedEvent

If you register a listener for this event (say thePlayerSleptInBed()), then your method thePlayerSleptInBed will be called whenever a player sleeps in a bed.

 

Forge uses a bit of a mishmash of events, handlers, hooks, and other techniques to enable your code to get itself called when particular things happen.  Events is just one of those.

 

A useful link:

http://www.minecraftforge.net/wiki/Event_Reference

 

-TGG

Link to comment
Share on other sites

Another thing to note is that events is NOT a forge concept.

Events is a programming concept, as are much of the confusing forge and minecraft stuff.

It's a good idea to search around for general peogramming information on such concepts as well as to learn about the specifics of forge ;)

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've been having a huge lag issue and discovered my server has a tendency to climb in ram usage, as pictured here. I've tested all mods individually on a copy of the server, with the world reset and at 1GB of ram for testing, and it happens regardless of the mod used. Here is a zip file of mods I'm using if you need it. I can provide any other info needed. I'm not doing anything special to recreate it but it does get worse when people connect to the server.
    • The Risks of Online Crypto Investment: A Cautionary Tale EMAIL: rap iddigitalreco ve ry @ exe cs. com. WHAT SAPP: + 1 41 4 80 7 14 85 Online crypto investment can seem like a promising opportunity, but it’s crucial to recognize that there are no guarantees. My own experience serves as a stark reminder of this reality. I was drawn in by the allure of high returns and the persuasive marketing tactics employed by various brokers on platforms like Instagram. Their polished presentations and testimonials made it seem easy to profit from cryptocurrency trading. Everything appeared to be legitimate. I received enticing messages about the potential for substantial gains, and the brokers seemed knowledgeable and professional. Driven by excitement and the fear of missing out, I invested a significant amount of my savings. The promise of quick profits overshadowed the red flags I should have noticed. I trusted these brokers without conducting proper research, which was a major mistake. As time went on, I realized that the promised returns were nothing but illusions. My attempts to withdraw funds were met with endless excuses and delays. It became painfully clear that I had fallen victim to a scam. The reality hit hard: my hard-earned money was gone, and I was left feeling foolish and defeated. In my desperation, I sought help from a company called Rapid Digital Recovery. They specialize in helping individuals recover funds lost to online scams. Their expertise and guidance have been invaluable during this difficult time. While I remain cautious and skeptical, I’m hopeful that they can assist me in retrieving my funds. This has taught me an important lesson: if something seems too good to be true, it probably is. I urge anyone considering online crypto investments to be extremely cautious. Do your research, scrutinize the brokers, and avoid rushing into decisions driven by hype or pressure. The world of cryptocurrency can be volatile and unregulated, making it a breeding ground for scams. while online investments can be appealing, they come with significant risks. Protect yourself by staying informed and skeptical. Learn from my experience and prioritize due diligence over quick gains. Stay away from unverified platforms and be wary of offers that sound too good to be true. Your financial security is worth the effort to ensure you’re making safe and informed decisions.
    • This is the log for Prism launcher after I added it https://mclo.gs/uXywaR5 As for AT launcher i'm not sure where to change the JVM arguments.  
    • Please help me out! Here is the report: pastebin.com/uiJMSG5Y
    • Hello,   I am playing the Modified Cobblemon modpack and I am able to join the server, the server is also hosted on my pc, but yet no one else is able to join the server, they get an error code of fieldSize is too long yet I have triple checked to be sure that all of the mods are the same outside of the client side mods. The specific code is Internal Exception: io.netty.handler.codec.DecoderException: io.netty.handler.codec.EncoderException: Java.io.EOFException: fieldSize is too long! Length is 1638, but maximum is 38. The first number changes at random but it is always a fairly large number and I have tried looking and logs and it says that there are mismatched mods between the server and client yet they are both present so I am not sure what is creating an issue for players joining. Client Log https://pastebin.com/UxpcCXr6 https://pastebin.com/aWuHaN57 I had to split the client log because it was too large for a single pastebin, I have had all three friends try to join the server and they all get this message but the client logs provided are from the person joining from LAN. Forge version is 47.3.11. Any help or insight on what is causing the issue would be greatly appreciated.
  • Topics

×
×
  • Create New...

Important Information

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