yeelp/Distinct-Damage-Descriptions

Betweenlands Compat

Opened this issue · 0 comments

yeelp commented

Betweenlands shields don't play nicely with DDD as ItemBLShield.java in Betweenlands cancels LivingAttackEvents when handling their own shields. https://github.com/Angry-Pixel/The-Betweenlands/blob/7e54e8f64dee155e649ddcf7512dce69af557ea7/src/main/java/thebetweenlands/common/item/tools/ItemBLShield.java#L231

Here's the solution:

  1. Create a handler to listen to LivingAttackEvent with highest priority.
  2. Use reflection to read ItemBLShield#EventHandler.INSTANCE.ignoreEvent. Don't do anything if it is set to true.
  3. Do the same checks Betweenlands does to determine if the event should be canceled.
  4. If the event should be canceled by Betweenlands, set a flag.
  5. Within the same handler, listen to LivingAttackEvent again but this time at LOW priority while also receiving canceled events.
  6. If the flag is set, unset it and unset the canceled state of the event. We need the event to not be canceled else further calculations and damage and hurt events won't be fired.