Skip to content

Instantly share code, notes, and snippets.

@mcenderdragon
Last active August 23, 2016 19:22
Show Gist options
  • Save mcenderdragon/b2e11c054dca08c566934a860087d881 to your computer and use it in GitHub Desktop.
Save mcenderdragon/b2e11c054dca08c566934a860087d881 to your computer and use it in GitHub Desktop.
example for CriticalHitEvent
package net.minecraftforge.test;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.CriticalHitEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod(modid="CriticalHitEventTest", name="CriticalHitEventTest", version="0.0.0")
public class CriticalHitEventTestEventTest
{
public static final boolean ENABLE = false;
@EventHandler
public void init(FMLInitializationEvent event)
{
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onCriticalHit(CriticalHitEvent.HitModifier event)
{
if(ENABLE)
{
event.setResult(Result.ALLOW); //Every hit is Critical
//event.setResult(Result.Deny);//No hit will be Critical
//event.setResult(Result.Default); //Vanilla Hits
System.out.println(event.getTarget() + " got hit by " + event.getEntityPlayer);
event.setDamageModifier(2.0F);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment