Jump to content

intermediateuser

Members
  • Posts

    57
  • Joined

  • Last visited

Everything posted by intermediateuser

  1. Okay, thanks for the help, folks. I appreciate it. I've updated the original post to reflect the information learned here.
  2. I've been searching for a way to change the vanilla mobs' damage. For all the searching I've done, the only solution that makes itself apparent to me is to make a coremod, and that's way beyond me and honestly too much for the mod I currently have planned. I hope I'm wrong and that there's a way that I'm just not finding. Is there something I'm missing? I don't want to modify the core classes to achieve this.
  3. I was thinking that too. I'm hoping his snippet isn't suggesting modifying the base classes.
  4. Um...duh? Events are "hey, this thing happened. Here's what it was." They are a after-the-fact alert. Now, you can cancel them (prevents other code up the chain from receiving the event and doing things with it--doing so may prevent the effects of the event, e.g. the player wouldn't actually take the damage) but you can't alter the event details: the damage was already assigned. Excellent, thank you for the fast response and the clarification. The only thing that this leaves me wondering is where you'd put the basic mob attack you quoted above. It looks like you took the default mob basic attack code and modified it, but I certainly do not want to do that in the base classes and I'm not adding new mobs. I want to affect the vanilla mobs' damage.
  5. UPDATE - Cleared up In case anyone else new to modding was confused about this topic, this thread taught me that Forge events provide "after-the-fact" information. You can do whatever you want with this information, and in some cases you can cancel the event itself, but you cannot modify what actually happened in the event. So, as in my situation here, you cannot use an event to increase (or modify in any way) mob damage. I thought I could hook into the event, change its fields, and then have the event resolve. But no, the event resolves first, and then passes that information to your handler class, where you can make use of it. Events are still useful; they're just not useful for the application I had in mind. Original thread below: Alright, so I want to make it so any time a mob attacks, that mob makes a damage roll instead of doing flat damage. To my understanding (and I've searched and read and looked up tutorials and videos for 2-3 days, honestly), the best way to do this is to use the LivingAttackEvent event. I know how to set this up. I have my event handler (below) and I have the event registered properly in my mod. What I want to know is: what do I even do with the limited number of fields the event gives me? For example, I have this: public class LivingAttackHandler { @ForgeSubscribe public void onEntityAttack(LivingAttackEvent event) { Entity entity = event.entity; DamageSource source = event.source; int amount = event.ammount; } } So, that's cool and all. But I get errors when I actually try to change the event's fields. Case in point, if I try this code: event.ammount = 4; Eclipse gives me an error saying "The final field LivingAttackEvent.ammount cannot be assigned." So I can't actually change the event fields. I'm having this problem with pretty much all events. It seems to me I can only get information from events, which I can then subsequently do nothing with. I know I'm approaching this the wrong way. Events sound like they're useful, but I'm not "getting" it. I honestly have been at this for at least 2 days now, and there are frustratingly few resources online about Forge events and how to actually use them.
×
×
  • Create New...

Important Information

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