diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/handler/events')
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java b/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java new file mode 100644 index 0000000000..c1c2341dd6 --- /dev/null +++ b/src/Java/gtPlusPlus/core/handler/events/EnderDragonDeathHandler.java @@ -0,0 +1,57 @@ +package gtPlusPlus.core.handler.events; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraftforge.event.entity.living.LivingDropsEvent; + +public class EnderDragonDeathHandler { + + private static final String mDragonClassName = "chylex.hee.entity.boss.EntityBossDragon"; + private static final boolean mHEE; + private static final Class mHardcoreDragonClass; + + static { + mHEE = ReflectionUtils.doesClassExist(mDragonClassName); + mHardcoreDragonClass = (mHEE ? ReflectionUtils.getClass(mDragonClassName) : null); + } + + @SubscribeEvent + public void onEntityDrop(LivingDropsEvent event) { + + boolean aDidDrop = false; + + //HEE Dragon + if (mHEE) { + if (mHardcoreDragonClass != null) { + if (mHardcoreDragonClass.isInstance(event.entityLiving)) { + for (int y = 0; y < MathUtils.randInt(100, 250); y++) { + int aAmount = MathUtils.randInt(5, 25); + event.entityLiving.entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); + aDidDrop = true; + } + } + } + } + //Vanilla Dragon or any other dragon that extends it + else { + if (event.entityLiving instanceof EntityDragon) { + for (int y = 0; y < MathUtils.randInt(25, 50); y++) { + int aAmount = MathUtils.randInt(1, 10); + event.entityLiving.entityDropItem(ELEMENT.STANDALONE.DRAGON_METAL.getNugget(aAmount), MathUtils.randFloat(0, 1)); + aDidDrop = true; + } + } + } + + if (aDidDrop) { + PlayerUtils.messageAllPlayers("Small quantities of Dragonsblood has crystalized after the death of the Ender Dragon!"); + } + + } + +} |