Java 类net.minecraft.item.ItemAxe 实例源码

项目:TreeChopper    文件:CommonProxy.java   
protected boolean CheckItemInHand(EntityPlayer entityPlayer) {

        if (entityPlayer.getHeldItemMainhand().isEmpty()) {
            return false;
        }

        if (ConfigurationHandler.axeTypes.contains(entityPlayer.getHeldItemMainhand().getItem().getUnlocalizedName())) {
            return true;
        }

        boolean test;

        try {
            ItemAxe tmp = (ItemAxe) entityPlayer.getHeldItemMainhand().getItem();
            test = true;
        } catch (Exception e) {
            test = false;
        }

        return test;
    }
项目:AquaRegia    文件:ShapelessCuttingRecipe.java   
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) {
    final ItemStack[] remainingItems = new ItemStack[inventoryCrafting.getSizeInventory()];

    for (int i = 0; i < remainingItems.length; ++i) {
        final ItemStack itemstack = inventoryCrafting.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem() instanceof ItemAxe) {
            remainingItems[i] = damageAxe(itemstack.copy());
        } else {
            remainingItems[i] = ForgeHooks.getContainerItem(itemstack);
        }
    }

    return remainingItems;
}
项目:BIGB    文件:AutoCreateForOres.java   
/**
 * Finds or creates a axe for an ore.
 */
public static void PopulateAxe(OreStuff stuff)
{
    if (!stuff.HasAxe)
    {
        Item Axe = Util.FindItemFromString(stuff.BaseName + "axe");

        if (Axe != null)
        {
            stuff.HasAxe = true;
        }
        else
        {
            ItemAxe axe;
            axe = AutoItemAndBlock.CreateAxe(stuff.MetalMaterial, Util.rand.nextInt(10), ModTabs.maintab, stuff.MetalMaterial.getHarvestLevel(), Reference.MODID + ":MissingAxeTexture", stuff.BaseName + "Axe");
            stuff.Axe = axe;
        }
    }
}
项目:toolscompressor    文件:ScanningForToolsEvent.java   
@SubscribeEvent
public void addVanillaTools(ValidatingToolsEvent event){
    Iterator<Item> iterator = Item.itemRegistry.iterator();
    while(iterator.hasNext()){
        Item i = iterator.next();
        if(i instanceof ItemSword){
            event.addSword(i);
        }
        if(i instanceof ItemPickaxe){
            event.addPickaxe(i);
        }
        if(i instanceof ItemSpade){
            event.addShovel(i);
        }
        if(i instanceof ItemAxe){
            event.addAxe(i);
        }
        if(i instanceof ItemHoe){
            event.addHoe(i);
        }
    }
}
项目:HarderStart    文件:CuttingTableRecipeParser.java   
/**
 * switches through input number to determine desired tool
 * 
 * @param tool
 * @return
 */
public static Class getToolClassFromNode(Node tool)
{
    if (tool != null)
    {
        if (tool.getNodeType() == Node.ELEMENT_NODE)
        {
            int toolIndex = 0;
            Element toolElement = (Element) tool;
            toolIndex = Integer.parseInt(toolElement.getTextContent());

            switch (toolIndex)
            {
                case 0:
                    return CuttingKnifeBase.class;
                case 1:
                    return ItemAxe.class;
                case 2:
                    return ItemPickaxe.class;
                case 3:
                    return ItemSpade.class;
            }
        }
    }
    return CuttingKnifeBase.class;
}
项目:MerchantsTFC    文件:ToolRackContainer.java   
@Override
protected boolean isItemValid(TileEntity tileEntity, ItemStack itemStack)
{
    Class<?> cls = tileEntity.getClass();

    if(cls != TEToolRack.class)
        return false;

    Item item = itemStack.getItem();

    return item instanceof ItemTool ||
        item instanceof ItemWeapon ||
        item instanceof ItemHoe ||
        item instanceof ItemProPick ||
        item instanceof ItemBow ||
        item instanceof ItemSword ||
        item instanceof ItemAxe ||
        item instanceof ItemSpade ||
        item instanceof ItemShears ||
        item instanceof ItemSpindle
        ;
}
项目:ProgressiveAutomation    文件:ToolHelper.java   
public static int getType(ItemStack itemStack) {
    Item item = itemStack.getItem();
    if (item instanceof ItemPickaxe) {
        return TYPE_PICKAXE;
    } else if (item instanceof ItemAxe) {
        return TYPE_AXE;
    } else if (item instanceof ItemSpade) {
        return TYPE_SHOVEL;
    } else if (item instanceof ItemSword) {
        return TYPE_SWORD;
    } else if (item instanceof ItemHoe) {
        return TYPE_HOE;
    } else if (item instanceof ItemTool) {
        Set<String> toolClasses = ((ItemTool)item).getToolClasses(itemStack);
        if (toolClasses.contains("pickaxe")) return TYPE_PICKAXE;
        else if (toolClasses.contains("axe")) return TYPE_AXE;
        else if (toolClasses.contains("shovel")) return TYPE_SHOVEL;
        else if (toolClasses.contains("hoe")) return TYPE_HOE;
        else return -1;
    } else if (tinkersType(item)>=0) { //see if it's a tinkers type
        return tinkersType(item);
    } else {
        return -1;
    }
}
项目:OpenBlocks    文件:LoreFlimFlam.java   
private static String identityType(@Nonnull ItemStack stack) {
    Item item = stack.getItem();
    if (item instanceof ItemArmor) {
        switch (((ItemArmor)item).armorType) {
            case HEAD:
                return "helmet";
            case CHEST:
                return "chestplate";
            case LEGS:
                return "leggings";
            case FEET:
                return "boots";
            default:
                break;
        }
    } else if (item instanceof ItemPickaxe) return "pickaxe";
    else if (item instanceof ItemShears) return "shears";
    else if (item instanceof ItemAxe) return "axe";
    else if (item instanceof ItemSpade) return "shovel";
    else if (item instanceof ItemBlock) return "block";
    else if (item instanceof ItemBucket) return "bucket";

    return "gizmo";
}
项目:bit-client    文件:Wrapper.java   
public static boolean isHoldingWeapon() {
    if (thePlayer().func_70694_bm() != null && (thePlayer().func_70694_bm().func_77973_b() instanceof ItemSword
            || thePlayer().func_70694_bm().func_77973_b() instanceof ItemAxe))
        return true;

    return false;
}
项目:Zombe-Modpack    文件:EntityPlayer.java   
protected void func_190629_c(EntityLivingBase p_190629_1_)
{
    super.func_190629_c(p_190629_1_);

    if (p_190629_1_.getHeldItemMainhand().getItem() instanceof ItemAxe)
    {
        this.func_190777_m(true);
    }
}
项目:Backmemed    文件:EntityPlayer.java   
protected void func_190629_c(EntityLivingBase p_190629_1_)
{
    super.func_190629_c(p_190629_1_);

    if (p_190629_1_.getHeldItemMainhand().getItem() instanceof ItemAxe)
    {
        this.func_190777_m(true);
    }
}
项目:ExPetrum    文件:BlockCrop.java   
@SuppressWarnings("deprecation")
@Override
public float getPlayerRelativeBlockHardness(IBlockState state, EntityPlayer player, World worldIn, BlockPos pos)
{
    // Axes are hardcoded to break blocks with a material of PLANT at their efficiency speed, need to fix that.
    ItemStack stack = player.getHeldItemMainhand();
    return !stack.isEmpty() && stack.getItem() instanceof ItemAxe ? super.getPlayerRelativeBlockHardness(state, player, worldIn, pos) / stack.getItem().getStrVsBlock(stack, state) : super.getPlayerRelativeBlockHardness(state, player, worldIn, pos);
}
项目:BetterWithAddons    文件:ButcherHandler.java   
private boolean isSuitableWeapon(ItemStack stack)
{
    if(stack.isEmpty()) return false;

    Item item = stack.getItem();
    return item.getToolClasses(stack).contains("axe") || item instanceof ItemSword || item instanceof ItemAxe;
}
项目:ToroQuest    文件:EntityToroNpc.java   
protected void handleSuccessfulAttack(Entity entityIn, int knockback) {
    if (knockback > 0 && entityIn instanceof EntityLivingBase) {
        ((EntityLivingBase) entityIn).knockBack(this, (float) knockback * 0.5F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F)));
        this.motionX *= 0.6D;
        this.motionZ *= 0.6D;
    }

    int j = EnchantmentHelper.getFireAspectModifier(this);

    if (j > 0) {
        entityIn.setFire(j * 4);
    }

    if (entityIn instanceof EntityPlayer) {
        EntityPlayer entityplayer = (EntityPlayer) entityIn;
        ItemStack itemstack = this.getHeldItemMainhand();
        ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

        if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD) {
            float f1 = 0.25F + (float) EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

            if (this.rand.nextFloat() < f1) {
                entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                this.world.setEntityState(entityplayer, (byte) 30);
            }
        }
    }

    this.applyEnchantments(this, entityIn);
}
项目:BIGB    文件:AutoItemAndBlock.java   
/**
 * Creates a axe from the specs provided.
 */
public static ItemAxe CreateAxe(ToolMaterial toolmaterial, float EfficiencyOnProperMaterial, CreativeTabs creativetab, int mininglevel, String texture, String unlocalizedname)
{
    ItemAxe axe;
    axe = new AutoAxe(toolmaterial, EfficiencyOnProperMaterial, creativetab, mininglevel, texture, unlocalizedname);
    return axe;
}
项目:Factorization    文件:MiscellaneousNonsense.java   
@SubscribeEvent
public void doTheZorroThing(EntityInteractEvent event) {
    EntityPlayer player = event.entityPlayer;
    if (player.worldObj.isRemote) return;
    if (player.isRiding()) return;
    if (!(event.target instanceof EntityHorse)) return;
    EntityHorse horse = (EntityHorse) event.target;
    if (player.fallDistance <= 2) return;
    if (!horse.isHorseSaddled()) return;
    if (horse.getLeashed()) {
        if (!(horse.getLeashedToEntity() instanceof EntityLeashKnot)) return;
        horse.getLeashedToEntity().interactFirst(player);
    }
    boolean awesome = false;
    if (player.fallDistance > 5 && player.getHeldItem() != null) {
        Item held = player.getHeldItem().getItem();
        boolean has_baby = false;
        if (player.riddenByEntity instanceof EntityAgeable) {
            EntityAgeable ea = (EntityAgeable) player.riddenByEntity;
            has_baby = ea.isChild();
        }
        awesome = held instanceof ItemSword || held instanceof ItemAxe || held instanceof ItemBow || player.riddenByEntity instanceof EntityPlayer || has_baby;
    }
    if (awesome) {
        horse.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20 * 40, 2, false, false));
        horse.addPotionEffect(new PotionEffect(Potion.resistance.id, 20 * 40, 1, true, true));
        horse.addPotionEffect(new PotionEffect(Potion.jump.id, 20 * 40, 1, true, true));
    } else {
        horse.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20 * 8, 1, false, false));
    }
    horse.playLivingSound();
}
项目:MinExtension    文件:AxeHelper.java   
public ItemAxe setNameAndTab(String name, CreativeTabs tab, Item material)
{
    this.setTextureName(ResourcePathHelper.getResourcesPath() + name);
    this.setUnlocalizedName(name);
    this.setCreativeTab(tab);
    this.material = material;
    return this;
}
项目:AnimalWarriors    文件:AxeHelper.java   
public ItemAxe setNameAndTab(String name, CreativeTabs tab)
{
    this.setTextureName(ResourcePathHelper.getResourcesPath() + name);
    this.setUnlocalizedName(name);
    this.setCreativeTab(tab);
    return this;
}
项目:VanillaImp    文件:ItemHelper.java   
public static Item getColoredVersion(Item tool) {

    if (tool instanceof ItemPickaxe || tool instanceof ModPickaxe) {
        return ModItems.colored_pickaxe;
    } else if (tool instanceof ItemSpade || tool instanceof ModShovel) {
        return ModItems.colored_shovel;
    } else if (tool instanceof ItemAxe || tool instanceof ModAxe) {
        return ModItems.colored_axe;
    } else if (tool instanceof ItemHoe || tool instanceof ModHoe) {
        return ModItems.colored_hoe;
    } else if (tool instanceof Hammer) {
        return ModItems.colored_hammer;
    } else if (tool instanceof Trident) {
        Trident trident = (Trident) tool;
        switch (trident.HeadMaterial) {
        case EMERALD:
            return ModItems.diamond_colored_trident;
        case GOLD:
            return ModItems.gold_colored_trident;
        case IRON:
            return ModItems.iron_colored_trident;
        case STONE:
            return ModItems.stone_colored_trident;
        case WOOD:
            return ModItems.wood_colored_trident;
        default:
            return ModItems.colored_colored_trident;
        }
    } else if (tool instanceof ItemSword || tool instanceof ModSword) {
        return ModItems.colored_sword;
    }
    return null;

}
项目:Rubedo    文件:ToolAxe.java   
public ToolAxe() {
    super();

    this.vanillaEquivalent = new ItemAxe(ToolMaterial.EMERALD) {
    };
    this.vanillaEquivalent.setUnlocalizedName("hatchetDiamond")
            .setTextureName("diamond_axe");
    GameRegistry.registerItem(this.vanillaEquivalent, "dummy_axe");

    this.allowedEnchants.add(EnumEnchantmentType.digger);
}
项目:EnderIO    文件:TileSliceAndSplice.java   
@Override
public boolean isMachineItemValidForSlot(int slot, @Nonnull ItemStack itemstack) {
  if (Prep.isInvalid(itemstack)) {
    return false;
  }
  if (!slotDefinition.isInputSlot(slot)) {
    return false;
  }
  if (slot == axeIndex) {
    return itemstack.getItem() instanceof ItemAxe;
  }
  if (slot == shearsIndex) {
    return itemstack.getItem() instanceof ItemShears;
  }

  ItemStack currentStackInSlot = getStackInSlot(slot);
  if (Prep.isValid(currentStackInSlot)) {
    return currentStackInSlot.isItemEqual(itemstack);
  }

  int numSlotsFilled = 0;
  for (int i = slotDefinition.getMinInputSlot(); i <= slotDefinition.getMaxInputSlot(); i++) {
    if (i >= 0 && i < inventory.length && i != axeIndex && i != shearsIndex) {
      if (Prep.isValid(getStackInSlot(i))) {
        numSlotsFilled++;
      }
    }
  }
  List<IMachineRecipe> recipes = MachineRecipeRegistry.instance.getRecipesForInput(getMachineName(), MachineRecipeInput.create(slot, itemstack));

  return isValidInputForAlloyRecipe(slot, itemstack, numSlotsFilled, recipes);
}
项目:DecompiledMinecraft    文件:EnchantmentDamage.java   
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
}
项目:DecompiledMinecraft    文件:EnchantmentDamage.java   
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
}
项目:BaseClient    文件:EnchantmentDamage.java   
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
}
项目:BaseClient    文件:EnchantmentDamage.java   
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
}
项目:Backmemed    文件:EntityMob.java   
public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).knockBack(this, (float)i * 0.5F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.field_190927_a;

            if (!itemstack.func_190926_b() && !itemstack1.func_190926_b() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
            {
                float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1)
                {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.world.setEntityState(entityplayer, (byte)30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
项目:Backmemed    文件:EnchantmentDamage.java   
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
}
项目:Mods    文件:EnchantmentSpin.java   
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack) {
    return stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemAxe;
}
项目:Mods    文件:EntityTF2Character.java   
@Override
public boolean attackEntityAsMob(Entity entityIn) {
    float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase) {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(),
                ((EntityLivingBase) entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag) {
        if (i > 0 && entityIn instanceof EntityLivingBase) {
            ((EntityLivingBase) entityIn).knockBack(this, i * 0.5F, MathHelper.sin(this.rotationYaw * 0.017453292F),
                    (-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
            entityIn.setFire(j * 4);

        if (entityIn instanceof EntityPlayer) {
            EntityPlayer entityplayer = (EntityPlayer) entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

            if (!itemstack.isEmpty() && itemstack1 != null && itemstack.getItem() instanceof ItemAxe
                    && itemstack1.getItem() == Items.SHIELD) {
                float f1 = 0.25F + EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1) {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.world.setEntityState(entityplayer, (byte) 30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
项目:Mods    文件:EntitySaxtonHale.java   
@Override
public boolean attackEntityAsMob(Entity entityIn) {
    float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase) {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(),
                ((EntityLivingBase) entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag) {
        if (i > 0 && entityIn instanceof EntityLivingBase) {
            ((EntityLivingBase) entityIn).knockBack(this, i * 0.5F, MathHelper.sin(this.rotationYaw * 0.017453292F),
                    (-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
            entityIn.setFire(j * 4);

        if (entityIn instanceof EntityPlayer) {
            EntityPlayer entityplayer = (EntityPlayer) entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

            if (!itemstack.isEmpty() && itemstack1 != null && itemstack.getItem() instanceof ItemAxe
                    && itemstack1.getItem() == Items.SHIELD) {
                float f1 = 0.25F + EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1) {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.world.setEntityState(entityplayer, (byte) 30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);

        if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).getHealth() <= 0)
            if (entityIn instanceof EntityBuilding)
                this.playSound(TF2Sounds.MOB_SAXTON_DESTROY, 2.2F, 1f);
            else
                this.playSound(TF2Sounds.MOB_SAXTON_KILL, 2.2F, 1f);
    }

    return flag;
}
项目:CustomWorldGen    文件:EntityMob.java   
public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).knockBack(this, (float)i * 0.5F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

            if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
            {
                float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1)
                {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.worldObj.setEntityState(entityplayer, (byte)30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
项目:CustomWorldGen    文件:EnchantmentDamage.java   
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
}
项目:Overlord    文件:EntityArmyMember.java   
@Override
public boolean attackEntityAsMob(@Nonnull Entity entityIn) {
    ItemStack mainHandItem = this.getHeldItemMainhand();
    if (mainHandItem.isEmpty()) {
        mainHandItem = ItemStack.EMPTY;
        setHeldItem(EnumHand.MAIN_HAND, mainHandItem);
    }
    float attackDamage = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int knockback = 0;

    if (entityIn instanceof EntityLivingBase) {
        attackDamage += EnchantmentHelper.getModifierForCreature(mainHandItem, ((EntityLivingBase) entityIn).getCreatureAttribute());
        knockback += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean successfulAttack = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage);

    if (successfulAttack) {
        if (knockback > 0) {
            ((EntityLivingBase) entityIn).knockBack(this, (float) knockback * 0.5F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F), (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0) {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer) {
            EntityPlayer entityplayer = (EntityPlayer) entityIn;
            ItemStack playerItemBeingUsed = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.EMPTY;

            if (!mainHandItem.isEmpty() && !playerItemBeingUsed.isEmpty() && mainHandItem.getItem() instanceof ItemAxe && playerItemBeingUsed.getItem() == Items.SHIELD) {
                float f1 = 0.25F + (float) EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1) {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.world.setEntityState(entityplayer, (byte) 30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);

        if (!mainHandItem.isEmpty() && entityIn instanceof EntityLivingBase)
            mainHandItem.getItem().hitEntity(mainHandItem, (EntityLivingBase) entityIn, this);

        if (this.getAugment() != null)
            this.getAugment().onStrike(this, entityIn);
    }
    if (mainHandItem.isEmpty())
        setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);

    return successfulAttack;
}
项目:ToroQuest    文件:EntityToro.java   
@Override
public boolean attackEntityAsMob(Entity victim) {

    float attackDamage = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int knockback = 2;

    if (victim instanceof EntityLivingBase) {
        attackDamage += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase) victim).getCreatureAttribute());
        knockback += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean wasDamaged = victim.attackEntityFrom(DamageSource.causeMobDamage(this), attackDamage);

    if (wasDamaged) {

        setRevengeTarget(getAttackTarget());
        setAttackTarget(null);

        if (knockback > 0 && victim instanceof EntityLivingBase) {
            ((EntityLivingBase) victim).knockBack(this, (float) knockback * 0.5F, (double) MathHelper.sin(this.rotationYaw * 0.017453292F),
                    (double) (-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        if (victim instanceof EntityPlayer) {
            EntityPlayer entityplayer = (EntityPlayer) victim;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

            if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD) {
                float f1 = 0.25F + (float) EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1) {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.world.setEntityState(entityplayer, (byte) 30);
                }
            }
        }

        this.applyEnchantments(this, victim);
    }

    return wasDamaged;
}
项目:TWBB-Tweaks    文件:BetterBeginningsHandler.java   
private static AdditionalCosts getAdditionalCosts (final Item output)
{
    int index = 0;

    if (output instanceof ItemArmor)
    {
        index = ((ItemArmor) output).armorType;
    }
    else if (output instanceof ItemPickaxe)
    {
        index = 4;
    }
    else if (output instanceof ItemSword)
    {
        index = 5;
    }
    else if (output instanceof ItemAxe)
    {
        index = 6;
    }
    else if (output instanceof ItemSpade)
    {
        index = 7;
    }
    else if (output instanceof ItemHoe)
    {
        index = 8;
    }
    else if (output instanceof ItemBow)
    {
        index = 9;
    }
    else if (output instanceof ItemShears)
    {
        index = 10;
    }
    else if (output instanceof ItemFishingRod)
    {
        index = 11;
    }

    return AdditionalCosts.values()[index];
}
项目:FutureCraft    文件:StartupCommon.java   
/**
 * Just a shortcut method to register items and keep code cleaner.
 */
public static void registerItems() {
    ToolMaterial bronzeMaterial = EnumHelper.addToolMaterial("bronze", 2, 350, 6.5F, 2.2F, 10);
    ToolMaterial steelMaterial = EnumHelper.addToolMaterial("steel", 3, 700, 7.0F, 2.7F, 12);

    //ingots
    ItemList.copper_ingot = new SimpleItem("copper_ingot");
    ItemList.tin_ingot = new SimpleItem("tin_ingot");
    ItemList.bronze_ingot = new SimpleItem("bronze_ingot");
    ItemList.steel_ingot = new SimpleItem("steel_ingot");

    //bronze tools
    ItemList.bronze_sword = (ItemSword) new ItemSword(bronzeMaterial).setUnlocalizedName("bronze_sword").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.bronze_sword, "bronze_sword");

    ItemList.bronze_shovel = (ItemSpade) new ItemSpade(bronzeMaterial).setUnlocalizedName("bronze_shovel").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.bronze_shovel, "bronze_shovel");

    ItemList.bronze_axe = (ItemAxe) new SimpleAxe(bronzeMaterial).setUnlocalizedName("bronze_axe").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.bronze_axe, "bronze_axe");

    ItemList.bronze_pickaxe = (ItemPickaxe) new SimplePickaxe(bronzeMaterial).setUnlocalizedName("bronze_pickaxe").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.bronze_pickaxe, "bronze_pickaxe");

    ItemList.bronze_hoe = (ItemHoe) new ItemHoe(bronzeMaterial).setUnlocalizedName("bronze_hoe").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.bronze_hoe, "bronze_hoe");

    //steel tools
    ItemList.steel_sword = (ItemSword) new ItemSword(steelMaterial).setUnlocalizedName("steel_sword").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.steel_sword, "steel_sword");

    ItemList.steel_shovel = (ItemSpade) new ItemSpade(steelMaterial).setUnlocalizedName("steel_shovel").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.steel_shovel, "steel_shovel");

    ItemList.steel_axe = (ItemAxe) new SimpleAxe(steelMaterial).setUnlocalizedName("steel_axe").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.steel_axe, "steel_axe");

    ItemList.steel_pickaxe = (ItemPickaxe) new SimplePickaxe(steelMaterial).setUnlocalizedName("steel_pickaxe").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.steel_pickaxe, "steel_pickaxe");

    ItemList.steel_hoe = (ItemHoe) new ItemHoe(steelMaterial).setUnlocalizedName("steel_hoe").setCreativeTab(FutureCraft.tabFutureCraft);
    GameRegistry.registerItem(ItemList.steel_hoe, "steel_hoe");

    //space suit
    ItemList.space_suit_helmet = new ItemSpaceSuit(ArmorMaterial.IRON, 2, 0);
    GameRegistry.registerItem(ItemList.space_suit_helmet, "space_suit_helmet");

    ItemList.space_suit_chestplate = new ItemSpaceSuit(ArmorMaterial.IRON, 2, 1);
    GameRegistry.registerItem(ItemList.space_suit_chestplate, "space_suit_chestplate");

    ItemList.space_suit_leggings = new ItemSpaceSuit(ArmorMaterial.IRON, 2, 2);
    GameRegistry.registerItem(ItemList.space_suit_leggings, "space_suit_leggings");

    ItemList.space_suit_boots = new ItemSpaceSuit(ArmorMaterial.IRON, 2, 3);
    GameRegistry.registerItem(ItemList.space_suit_boots, "space_suit_boots");

    //misc
    ItemList.stone_channel = new SimpleItem("stone_channel");
    ItemList.stone_cast = new SimpleItem("stone_cast");
    ItemList.multimeter = new ItemMultimeter("multimeter");
    ItemList.itemLaser = new ItemLaser("laser");
    ItemList.creative_tab = new SimpleItem("creative_tab", false);
}
项目:Resilience-Client-Source    文件:EnchantmentDamage.java   
public boolean canApply(ItemStack par1ItemStack)
{
    return par1ItemStack.getItem() instanceof ItemAxe ? true : super.canApply(par1ItemStack);
}
项目:ToolUtilities    文件:ToolUtilities.java   
public void doConfig()
{
    rightClickItem = getStackFromString(Config.rightClickItem);
    areaItem = getStackFromString(Config.areaItem);
    logger.info("Column item: " + areaItem.getUnlocalizedName());
    nineItem = getStackFromString(Config.nineItem);
    hoeAreaItem = getStackFromString(Config.hoeAreaItem);
    swordAreaItem = getStackFromString(Config.swordAreaItem);
    //unbreakableItem = getStackFromString(Config.unbreakableItem);

    String[] seperatedItems = blacklist.split(",");
    blacklistedItems.clear();
    for (int i = 0; i < seperatedItems.length; i++)
    {
        blacklistedItems.add(getStackFromString(seperatedItems[i]).getItem());
    }

    ToolUpgradeRecipe.clear();

    // place
    ToolUpgradeRecipe.addUpgradeRecipe(ItemTool.class, rightClickItem, ToolUpgrade.PLACE, XPAmount, allowPlace);

    // 3x1
    ToolUpgradeRecipe.addUpgradeRecipe(ItemPickaxe.class, areaItem, ToolUpgrade.THREExONE, areaXPAmount, allow3x1Pick);
    ToolUpgradeRecipe.addUpgradeRecipe(ItemSpade.class, areaItem, ToolUpgrade.THREExONE, areaXPAmount, allow3x1Shovel);
    ToolUpgradeRecipe.addUpgradeRecipe(ItemAxe.class, areaItem, ToolUpgrade.THREExONE, areaXPAmount, allow3x1Axe);

    // 3x3
    ToolUpgradeRecipe.addUpgradeRecipe(ItemPickaxe.class, nineItem, ToolUpgrade.THREExTHREE, nineXPAmount, allow3x3Pick);
    ToolUpgradeRecipe.addUpgradeRecipe(ItemSpade.class, nineItem, ToolUpgrade.THREExTHREE, nineXPAmount, allow3x3Shovel);

    //Hoe's in AoE for tall grass
    ToolUpgradeRecipe.addUpgradeRecipe(ItemHoe.class, hoeAreaItem, ToolUpgrade.HOExTHREE, hoeAreaXP, allow3x3Hoe);

    ToolUpgradeRecipe.addUpgradeRecipe(ItemSword.class, swordAreaItem, ToolUpgrade.SWORD_AOE, swordAreaXP, allowSwordAOE);

    //ToolUpgradeRecipe.addUpgradeRecipe(ItemTool.class, unbreakableItem, ToolUpgrade.UNBREAKABLE, unbreakableXP, allowUnbreakable);

    doBlacklist(Config.blacklistPlace,ToolUpgrade.PLACE);
    doBlacklist(Config.blacklist3x1,ToolUpgrade.THREExONE);
    doBlacklist(Config.blacklist3x3,ToolUpgrade.THREExTHREE);
    doBlacklist(Config.blacklistHoe,ToolUpgrade.HOExTHREE);
    doBlacklist(Config.blacklistSword,ToolUpgrade.SWORD_AOE);
}
项目:ExpandedRailsMod    文件:EntityMob.java   
public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).knockBack(this, (float)i * 0.5F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

            if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
            {
                float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1)
                {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.worldObj.setEntityState(entityplayer, (byte)30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
项目:ExpandedRailsMod    文件:EnchantmentDamage.java   
/**
 * Determines if this enchantment can be applied to a specific ItemStack.
 */
public boolean canApply(ItemStack stack)
{
    return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
}