Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.halestormxv.item;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- import com.halestormxv.lib.RefStrings;
- import cpw.mods.fml.relauncher.Side;
- import cpw.mods.fml.relauncher.SideOnly;
- import net.minecraft.block.Block;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.enchantment.Enchantment;
- import net.minecraft.enchantment.EnchantmentHelper;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.item.EntityItem;
- import net.minecraft.entity.passive.EntityChicken;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.EnumRarity;
- import net.minecraft.item.ItemShears;
- import net.minecraft.item.ItemStack;
- import net.minecraft.stats.StatList;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraftforge.common.IShearable;
- public class celShears extends ItemShears
- {
- public celShears()
- {
- this.setMaxStackSize(1);
- this.setTextureName(RefStrings.MODID + ":celestial_shears");
- this.setMaxDamage(600);
- }
- public boolean isDamageable()
- {
- return false;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public EnumRarity getRarity(ItemStack par1ItemStack){
- return EnumRarity.uncommon;
- }
- @Override
- public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
- {
- par3List.add("");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "Mystical shears imbued with Aries's power.");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "Aries is a timid and easy spirit to gain trust from.");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "However, because of this she is often taken");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "advantage of. You have proven to be a good");
- par3List.add(EnumChatFormatting.LIGHT_PURPLE + "and kind Matster.");
- par3List.add("");
- par3List.add(EnumChatFormatting.UNDERLINE + "Shears sheep in a radius.");
- }
- @Override
- public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity)
- {
- if (entity.worldObj.isRemote)
- {
- return false;
- }
- List shearList = entity.worldObj.getEntitiesWithinAABBExcludingEntity(player, player.boundingBox.expand(8.0D, 8.0D, 8.0D));
- for (int i = 0; i < shearList.size(); i++)
- {
- if (entity instanceof IShearable)
- {
- IShearable target = (IShearable)shearList.get(i);
- if (target.isShearable(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ) )
- {
- ArrayList<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ,
- EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));
- Random rand = new Random();
- for(ItemStack stack : drops)
- {
- EntityItem ent = entity.entityDropItem(stack, 1.0F);
- ent.motionY += rand.nextFloat() * 0.05F;
- ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
- ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
- }
- }
- return true;
- }
- }
- return false;
- }
- @Override
- public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player)
- {
- if (player.worldObj.isRemote)
- {
- return false;
- }
- Block block = player.worldObj.getBlock(x, y, z);
- if (block instanceof IShearable)
- {
- IShearable target = (IShearable)block;
- if (target.isShearable(itemstack, player.worldObj, x, y, z))
- {
- ArrayList<ItemStack> drops = target.onSheared(itemstack, player.worldObj, x, y, z,
- EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));
- Random rand = new Random();
- for(ItemStack stack : drops)
- {
- float f = 0.7F;
- double d = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
- double d1 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
- double d2 = (double)(rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
- EntityItem entityitem = new EntityItem(player.worldObj, (double)x + d, (double)y + d1, (double)z + d2, stack);
- entityitem.delayBeforeCanPickup = 10;
- player.worldObj.spawnEntityInWorld(entityitem);
- }
- player.addStat(StatList.mineBlockStatArray[Block.getIdFromBlock(block)], 1);
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement