mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 00:37:57 +00:00
Shears effect.
This commit is contained in:
1 parent
e6d7ad2609
commit
7fb06bea22
3 files changed
+60
-3
No files matched your search
@@ -34,8 +34,8 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem {
|
||||
|
||||
private static final int COST_PER = 55;
|
||||
|
||||
static final List<Block> validBlocks = new ArrayList() {private static final long serialVersionUID = 1378413169035169782L;
|
||||
|
||||
static final List<Block> validBlocks = new ArrayList() {
|
||||
private static final long serialVersionUID = 1378413169035169782L;
|
||||
{
|
||||
add(Blocks.stone);
|
||||
add(Blocks.dirt);
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
package vazkii.botania.common.item.equipment.tool.elementium;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelShears;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
@@ -8,5 +23,47 @@ public class ItemElementiumShears extends ItemManasteelShears {
|
||||
public ItemElementiumShears() {
|
||||
super(LibItemNames.ELEMENTIUM_SHEARS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
|
||||
return EnumAction.bow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack));
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
|
||||
if(count != getMaxItemUseDuration(stack) && count % 5 == 0) {
|
||||
int range = 12;
|
||||
List<IShearable> sheep = player.worldObj.getEntitiesWithinAABB(IShearable.class, AxisAlignedBB.getBoundingBox(player.posX - range, player.posY - range, player.posZ - range, player.posX + range, player.posY + range, player.posZ + range));
|
||||
if(sheep.size() > 0) {
|
||||
for(IShearable target : sheep) {
|
||||
Entity entity = (Entity) target;
|
||||
if(target.isShearable(stack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ)) {
|
||||
ArrayList<ItemStack> drops = target.onSheared(stack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ, EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack));
|
||||
|
||||
Random rand = new Random();
|
||||
for(ItemStack drop : drops) {
|
||||
EntityItem ent = entity.entityDropItem(drop, 1.0F);
|
||||
ent.motionY += rand.nextFloat() * 0.05F;
|
||||
ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
|
||||
ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
|
||||
}
|
||||
ToolCommons.damageItem(stack, 1, player, MANA_PER_DAMAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemManasteelShears extends ItemShears implements IManaUsingItem {
|
||||
|
||||
private static final int MANA_PER_DAMAGE = 30;
|
||||
public static final int MANA_PER_DAMAGE = 30;
|
||||
|
||||
public ItemManasteelShears() {
|
||||
this(LibItemNames.MANASTEEL_SHEARS);
|
||||
|
||||
Reference in new issue
Block a user