net.minecraft.item.ItemAxe Java Examples

The following examples show how to use net.minecraft.item.ItemAxe. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityToroNpc.java    From ToroQuest with GNU General Public License v3.0 7 votes vote down vote up
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);
}
 
Example #2
Source File: ExtraInventory.java    From ForgeHax with MIT License 6 votes vote down vote up
private static int getItemValue(ItemStack stack, boolean loopGuard) {
  Item item = stack.getItem();
  if (stack.isEmpty()) {
    return 0;
  } else if (item instanceof ItemArmor
      || item instanceof ItemPickaxe
      || item instanceof ItemAxe
      || item instanceof ItemSword
      || item instanceof ItemFood
      || item instanceof ItemArrow
      || Items.TOTEM_OF_UNDYING.equals(item)) {
    return 100 * stack.getCount(); // very important
  } else if (item instanceof ItemShulkerBox) {
    return 5
        + (loopGuard
        ? 0
        : Utils.getShulkerContents(stack)
            .stream()
            .mapToInt(ExtraInventory::getItemValueSafe)
            .sum());
  } else {
    return 5;
  }
}
 
Example #3
Source File: EntityToro.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
@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;
}
 
Example #4
Source File: EnchantmentWrath.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
public boolean canApply(ItemStack stack)
{
    return stack.getItem() instanceof ItemAxe ? true : super.canApply(stack);
}