mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-28 15:56:14 +00:00
Axe Effect.
This commit is contained in:
1 parent
7fb06bea22
commit
188c214d3b
1 file changed
+51
@@ -1,13 +1,64 @@
|
||||
package vazkii.botania.common.item.equipment.tool.elementium;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelAxe;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ItemElementiumAxe extends ItemManasteelAxe {
|
||||
|
||||
public ItemElementiumAxe() {
|
||||
super(BotaniaAPI.elementiumToolMaterial, LibItemNames.ELEMENTIUM_AXE);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
// Thanks to SpitefulFox for the drop rates
|
||||
// https://github.com/SpitefulFox/ForbiddenMagic/blob/master/src/com/spiteful/forbidden/FMEventHandler.java
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityDrops(LivingDropsEvent event) {
|
||||
if(event.recentlyHit && event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) {
|
||||
ItemStack weapon = ((EntityPlayer) event.source.getEntity()).getCurrentEquippedItem();
|
||||
if(weapon != null && weapon.getItem() == this) {
|
||||
Random rand = event.entity.worldObj.rand;
|
||||
int looting = EnchantmentHelper.getEnchantmentLevel(Enchantment.looting.effectId, weapon);
|
||||
|
||||
if(event.entityLiving instanceof EntitySkeleton && rand.nextInt(26) <= (3 + looting))
|
||||
addDrop(event, new ItemStack(Items.skull, 1, ((EntitySkeleton)event.entityLiving).getSkeletonType()));
|
||||
else if(event.entityLiving instanceof EntityZombie && rand.nextInt(26) <= (2 + 2 * looting))
|
||||
addDrop(event, new ItemStack(Items.skull, 1, 2));
|
||||
else if(event.entityLiving instanceof EntityCreeper && rand.nextInt(26) <= (2 + 2 * looting))
|
||||
addDrop(event, new ItemStack(Items.skull, 1, 4));
|
||||
else if(event.entityLiving instanceof EntityPlayer && rand.nextInt(11) <= (1 + looting)) {
|
||||
ItemStack head = new ItemStack(Items.skull, 1, 3);
|
||||
NBTTagCompound nametag = new NBTTagCompound();
|
||||
nametag.setString("SkullOwner", ((EntityPlayer)event.entityLiving).getCommandSenderName());
|
||||
head.setTagInfo("SkullOwner", nametag);
|
||||
addDrop(event, head);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addDrop(LivingDropsEvent event, ItemStack drop) {
|
||||
EntityItem entityitem = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, drop);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
event.drops.add(entityitem);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user