Added CriticalHitEvent to allow more control over whether a attack is a critical or not, and what damage it does.

This commit is contained in:
mcenderdragon authored and LexManos committed 2017-08-01 14:13:37 -05:00
1 parent eee8b7ff38
commit c8379da83b
4 files changed
+208 -13

No files matched your search

@@ -120,6 +120,7 @@ import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
import net.minecraftforge.event.entity.living.LootingLevelEvent;
import net.minecraftforge.event.entity.player.AnvilRepairEvent;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.event.entity.player.CriticalHitEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
@@ -1259,6 +1260,18 @@ public class ForgeHooks
return errored;
}
@Nullable
public static CriticalHitEvent getCriticalHit(EntityPlayer player, Entity target, boolean vanillaCritical, float damageModifier)
{
CriticalHitEvent hitResult = new CriticalHitEvent(player, target, damageModifier, vanillaCritical);
MinecraftForge.EVENT_BUS.post(hitResult);
if (hitResult.getResult() == Event.Result.ALLOW || (vanillaCritical && hitResult.getResult() == Event.Result.DEFAULT))
{
return hitResult;
}
return null;
}
private static void setActiveModContainer(ModContainer mod)
{
if (Loader.instance().getLoaderState() != LoaderState.NOINIT) //Unit Tests..