Beispiel #1
0
 @Override
 public boolean hitEntity(
     ItemStack itemstack, EntityLivingBase entity1, EntityLivingBase entity2) {
   if (itemstack.hasTagCompound() && itemstack.stackTagCompound.getInteger("Type") == 1) {
     itemstack.damageItem(1, entity2);
   }
   itemstack.damageItem(2, entity2);
   return true;
 }
Beispiel #2
0
 @Override
 public boolean onBlockDestroyed(
     ItemStack itemstack, World world, Block block, int x, int y, int z, EntityLivingBase entiy) {
   if (itemstack.hasTagCompound() && itemstack.stackTagCompound.getInteger("Type") == 1) {
     itemstack.damageItem(2, entiy);
   } else {
     if ((double) block.getBlockHardness(world, x, y, z) != 0.0D) {
       itemstack.damageItem(1, entiy);
     }
   }
   return true;
 }
Beispiel #3
0
  @Override
  public boolean hitEntity(
      ItemStack stack, EntityLivingBase entity, EntityLivingBase entityPlayer) {

    if (ToolUtils.isMobLava(entity.getEntityName())) {
      stack.damageItem(1000, entityPlayer);
      return false;
    }

    stack.damageItem(10, entityPlayer);
    return true;
  }
  /**
   * Callback for item usage. If the item does something special on right clicking, he will have one
   * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS
   */
  public boolean onItemUse(
      ItemStack var1,
      EntityPlayer var2,
      World var3,
      int var4,
      int var5,
      int var6,
      int var7,
      float var8,
      float var9,
      float var10) {
    if (!var2.canPlayerEdit(var4, var5, var6, var7, var1)) {
      return false;
    } else {
      UseHoeEvent var11 = new UseHoeEvent(var2, var1, var3, var4, var5, var6);

      if (MinecraftForge.EVENT_BUS.post(var11)) {
        return false;
      } else if (var11.getResult() == Result.ALLOW) {
        var1.damageItem(1, var2);
        return true;
      } else {
        int var12 = var3.getBlockId(var4, var5, var6);
        int var13 = var3.getBlockId(var4, var5 + 1, var6);

        if ((var7 == 0 || var13 != 0 || var12 != Block.grass.blockID)
            && var12 != Block.dirt.blockID) {
          return false;
        } else {
          Block var14 = Block.tilledField;
          var3.playSoundEffect(
              (double) ((float) var4 + 0.5F),
              (double) ((float) var5 + 0.5F),
              (double) ((float) var6 + 0.5F),
              var14.stepSound.getStepSound(),
              (var14.stepSound.getVolume() + 1.0F) / 2.0F,
              var14.stepSound.getPitch() * 0.8F);

          if (var3.isRemote) {
            return true;
          } else {
            var3.setBlock(var4, var5, var6, var14.blockID);
            var1.damageItem(1, var2);
            return true;
          }
        }
      }
    }
  }
Beispiel #5
0
  @Override
  public void doSpacialAttack(ItemStack stack, EntityPlayer player) {
    World world = player.worldObj;

    NBTTagCompound tag = ItemSlashBlade.getItemTagCompound(stack);

    player.worldObj.playSoundAtEntity(player, "mob.blaze.hit", 0.2F, 0.6F);

    if (!world.isRemote) {

      final int cost = -20;
      if (!ItemSlashBlade.ProudSoul.tryAdd(tag, cost, false)) {
        stack.damageItem(10, player);
      }

      ItemSlashBlade blade = (ItemSlashBlade) stack.getItem();

      {
        AxisAlignedBB bb = player.getEntityBoundingBox();
        bb = bb.expand(5.0f, 0.25f, 5.0f);

        List<Entity> list =
            world.getEntitiesInAABBexcluding(player, bb, EntitySelectorAttackable.getInstance());

        for (Entity curEntity : list) {
          StylishRankManager.setNextAttackType(player, StylishRankManager.AttackTypes.CircleSlash);
          blade.attackTargetEntity(stack, curEntity, player, true);
          player.onCriticalHit(curEntity);
        }
      }

      float baseModif = blade.getBaseAttackModifiers(tag);
      int level =
          Math.max(1, EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack));
      float magicDamage = (baseModif / 2.0f);

      int rank = StylishRankManager.getStylishRank(player);
      if (5 <= rank)
        magicDamage += ItemSlashBlade.AttackAmplifier.get(tag) * (0.25f + (level / 5.0f));

      for (int i = 0; i < 6; i++) {
        EntityDrive entityDrive = new EntityDrive(world, player, magicDamage, false, 0);
        entityDrive.setLocationAndAngles(
            player.posX,
            player.posY + (double) player.getEyeHeight() / 2D,
            player.posZ,
            player.rotationYaw + 60 * i /*+ (entityDrive.getRand().nextFloat() - 0.5f) * 60*/,
            0); // (entityDrive.getRand().nextFloat() - 0.5f) * 60);
        entityDrive.setDriveVector(0.5f);
        entityDrive.setLifeTime(10);
        entityDrive.setIsMultiHit(false);
        entityDrive.setRoll(90.0f /*+ 120 * (entityDrive.getRand().nextFloat() - 0.5f)*/);
        if (entityDrive != null) {
          world.spawnEntityInWorld(entityDrive);
        }
      }
    }

    ItemSlashBlade.setComboSequence(tag, ItemSlashBlade.ComboSequence.Battou);
  }
  @Override
  @SuppressWarnings("rawtypes")
  public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    coolDown--;
    if (coolDown == 0) {
      if (stack.getItemDamage() > 0) stack.setItemDamage(stack.getItemDamage() - 1);
      else if (stack.getItemDamage() < 0) stack.setItemDamage(0);
      coolDown = MAX_COOL_DOWN;
    }

    boolean isWaterproof = false;
    Map enchs = EnchantmentHelper.getEnchantments(stack);
    if (!enchs.isEmpty() && enchs.get(GanysEndManager.getImperviousnessID()) != null)
      isWaterproof = true;

    if (!isWaterproof)
      if (player.isInWater()) stack.damageItem(1, player);
      else if (player.handleLavaMovement() || player.isBurning())
        if (stack.getItemDamage() > 0) stack.setItemDamage(stack.getItemDamage() - 2);

    if (stack.getItemDamage() < 0) stack.setItemDamage(0);
    else if (stack.getItemDamage() >= this.getMaxDamage())
      for (int i = 0; i < player.inventory.armorInventory.length; i++)
        if (player.inventory.armorInventory[i] != null)
          if (player.inventory.armorInventory[i].getItemDamage() >= this.getMaxDamage()) {
            player.inventory.armorInventory[i] = null;
            player.renderBrokenItemStack(stack);
          }
  }
  @SuppressWarnings("incomplete-switch")
  @Override
  public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound());

    if (stack.getItemDamage() >= stack.getMaxDamage() - 2) {
      NBTTagCompound tag = stack.getTagCompound();
      tag.setBoolean("destroyed", true);
      stack.setTagCompound(tag);

      return;
    }

    switch (this.armorType) {
      case HEAD:
        if (stack.getTagCompound().getBoolean("respiration")
            && stack.getItemDamage() < stack.getMaxDamage() - 16)
          if (player.getAir() == 0) {
            player.setAir(150);
            stack.damageItem(16, player);
          }
        break;
      case LEGS:
      case FEET:
        if (stack.getTagCompound().getBoolean("fall")) {
          if (player.fallDistance > 0) player.fallDistance = 0;
        }
    }
  }
  @Override
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer player,
      World world,
      int i,
      int j,
      int k,
      int side,
      float par8,
      float par9,
      float par10) {
    Block block = world.getBlock(i, j, k);

    if (block == Blocks.snow_layer) side = 1;
    else {
      if (side == 0) --j;
      else if (side == 1) ++j;
      else if (side == 2) --k;
      else if (side == 3) ++k;
      else if (side == 4) --i;
      else if (side == 5) ++i;
    }

    if (!player.canPlayerEdit(i, j, k, side, stack) || stack.stackSize == 0) return false;

    if (!world.isRemote) world.setBlock(i, j, k, Blocks.flowing_water, 0, 3);
    if (!player.capabilities.isCreativeMode) stack.damageItem(1, player);
    return true;
  }
  @Override
  public boolean hitEntity(
      ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1) {

    itemstack.damageItem(1, entityliving1);
    return true;
  }
  /**
   * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a
   * pig.
   */
  public boolean interact(EntityPlayer player) {
    ItemStack var2 = player.inventory.getCurrentItem();

    if (var2 != null && var2.getItem() == Items.shears && !this.getSheared() && !this.isChild()) {
      if (!this.world.isRemote) {
        this.setSheared(true);
        int var3 = 1 + this.rand.nextInt(3);

        for (int var4 = 0; var4 < var3; ++var4) {
          EntityItem var5 =
              this.dropItem(
                  new ItemStack(
                      Item.getItemForBlock(Blocks.wool),
                      1,
                      this.func_175509_cj().getInverseDyeColorValue()),
                  1.0F);
          var5.motionY += (double) (this.rand.nextFloat() * 0.05F);
          var5.motionX += (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
          var5.motionZ += (double) ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
        }
      }

      var2.damageItem(1, player);
      this.playSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.interact(player);
  }
  public void func_151367_b(EntityLivingBase p_151367_1_, Entity p_151367_2_, int p_151367_3_) {
    Random random = p_151367_1_.getRNG();
    ItemStack itemstack = EnchantmentHelper.func_92099_a(Enchantment.thorns, p_151367_1_);

    if (func_92094_a(p_151367_3_, random)) {
      p_151367_2_.attackEntityFrom(
          DamageSource.causeThornsDamage(p_151367_1_), (float) func_92095_b(p_151367_3_, random));
      p_151367_2_.playSound("damage.thorns", 0.5F, 1.0F);

      if (itemstack != null) {
        itemstack.damageItem(3, p_151367_1_);
      }
    } else if (itemstack != null) {
      itemstack.damageItem(1, p_151367_1_);
    }
  }
 @Override
 public boolean onBlockDestroyed(
     ItemStack itemStack,
     World world,
     Block destroyedBlock,
     int x,
     int y,
     int z,
     EntityLivingBase player) {
   // System.out.println("Test (" + x + "," + y + "," + z + ")");
   // player.getLookVec();
   int numBlocks = 0;
   for (int i = -1; i <= 1; i++) {
     for (int j = -1; j <= 1; j++) {
       for (int k = -1; k <= 1; k++) {
         Block block = world.getBlock(x + i, y + j, z + k);
         if (block != null) {
           System.out.println("block: " + block.getUnlocalizedName());
           System.out.println("can:  " + itemStack.getItem().canHarvestBlock(block, itemStack));
           if (this.canHarvestBlock(block, itemStack)) {
             int fortuneLevel =
                 EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemStack);
             block.dropBlockAsItem(
                 world, x, y, z, world.getBlockMetadata(x + i, y + j, z + k), fortuneLevel);
             world.setBlockToAir(x + i, y + j, z + k);
             numBlocks++;
           }
         }
       }
     }
   }
   itemStack.damageItem(numBlocks / 3, player);
   // Block block = Block.blocksList[l]
   return false;
 }
Beispiel #13
0
  @Override
  public ActionResult<ItemStack> onItemRightClick(
      ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {

    if (!playerIn.capabilities.isCreativeMode) {
      itemStackIn.damageItem(1, playerIn);
      if (itemStackIn.getItemDamage() == 0) {
        itemStackIn = new ItemStack(ModItems.staff);
      }
    }

    worldIn.playSound(
        (EntityPlayer) null,
        playerIn.posX,
        playerIn.posY,
        playerIn.posZ,
        SoundEvents.ENTITY_SNOWBALL_THROW,
        SoundCategory.NEUTRAL,
        0.5F,
        0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote) {
      EntityLargeSnowBall snowball = new EntityLargeSnowBall(worldIn, playerIn);
      snowball.setHeadingFromThrower(
          playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
      worldIn.spawnEntityInWorld(snowball);
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
  }
 @Override
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   if (par3EntityLivingBase instanceof EntityClientPlayerMP) {
     // System.out.println("Atk: " + par2EntityLivingBase.hurtTime);
     // EntityClientPlayerMP player = (EntityClientPlayerMP)par3EntityLivingBase;
     // player.heal(1.0F);
     // player.setHealth(player.getHealth()+1);
     if (par2EntityLivingBase.hurtTime == 0) {
       ByteArrayOutputStream bt = new ByteArrayOutputStream();
       DataOutputStream out = new DataOutputStream(bt);
       try {
         // System.out.println("Building packet...");
         out.writeInt(1);
         out.writeFloat(1);
         Packet250CustomPayload packet = new Packet250CustomPayload("Artifacts", bt.toByteArray());
         Player player = (Player) par3EntityLivingBase;
         // System.out.println("Sending packet..." + player);
         PacketDispatcher.sendPacketToServer(packet);
         par1ItemStack.damageItem(1, par3EntityLivingBase);
       } catch (IOException ex) {
         System.out.println("couldnt send packet!");
       }
     }
   }
   return false;
 }
 @Override
 public boolean onBlockDestroyed(
     ItemStack par1ItemStack,
     World world,
     int block,
     int x,
     int y,
     int z,
     EntityLivingBase par7EntityLivingBase) {
   world.newExplosion(par7EntityLivingBase, x, y, z, 3F, false, true);
   par1ItemStack.damageItem(3, par7EntityLivingBase);
   /*ByteArrayOutputStream bt = new ByteArrayOutputStream();
   DataOutputStream out = new DataOutputStream(bt);
   try
   {
   	//System.out.println("Building packet...");
   	out.writeInt(7);
   	out.writeInt(-1);
   	out.writeInt(x);
   	out.writeInt(y);
   	out.writeInt(z);
   	//out.writeFloat(par3EntityPlayer.getHealth()+1);
   	Packet250CustomPayload packet = new Packet250CustomPayload("Artifacts", bt.toByteArray());
   	Player player = (Player)par7EntityLivingBase;
   	//System.out.println("Sending packet..." + player);
   	PacketDispatcher.sendPacketToServer(packet);
   	par1ItemStack.damageItem(3, par7EntityLivingBase);
   	return true;
   }
   catch (IOException ex)
   {
   	System.out.println("couldnt send packet!");
   }*/
   return false;
 }
  @SubscribeEvent
  public void onPlayerDrops(PlayerDropsEvent event) {
    Iterator<EntityItem> iterator = event.drops.iterator();
    while (iterator.hasNext()) {
      EntityItem entItem = iterator.next();
      ItemStack is = entItem.getEntityItem();

      if ((is != null) && (is.getItem() instanceof ItemEnderGlove)) {
        is.damageItem(2, event.entityPlayer);
        InventoryUtils.addItemStackToInventory(
            InventoryUtils.getPlayerEnderChest(event.entityPlayer), is);
        PlayerUtils.sendMessage(
            event.entityPlayer,
            EnumChatFormatting.DARK_PURPLE
                + is.getDisplayName()
                + " was succesfully saved to your Ender Chest!");
        boilerplate.common.utils.Utils.playSFX(
            event.entityPlayer.worldObj,
            (int) entItem.prevPosX,
            (int) entItem.prevPosY,
            (int) entItem.prevPosZ,
            "mob.endermen.portal");
        entItem.setDead();
      }
    }
  }
 @Override
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   if (par3EntityLivingBase instanceof EntityClientPlayerMP) {
     if (par2EntityLivingBase.hurtTime == 0) {
       ByteArrayOutputStream bt = new ByteArrayOutputStream();
       DataOutputStream out = new DataOutputStream(bt);
       try {
         out.writeInt(7);
         out.writeInt(par2EntityLivingBase.entityId);
         EntityPlayer par3EntityPlayer = (EntityPlayer) par3EntityLivingBase;
         out.writeInt(par3EntityPlayer.inventory.currentItem);
         Packet250CustomPayload packet = new Packet250CustomPayload("Artifacts", bt.toByteArray());
         Player player = (Player) par3EntityLivingBase;
         PacketDispatcher.sendPacketToServer(packet);
         par1ItemStack.damageItem(3, par3EntityLivingBase);
       } catch (IOException ex) {
         System.out.println("couldnt send packet!");
       }
     }
   }
   return false;
 }
Beispiel #18
0
 /**
  * Current implementations of this method in child classes do not use the entry argument beside
  * ev. They just raise the damage on the stack.
  */
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   par1ItemStack.damageItem(2, par3EntityLivingBase);
   return true;
 }
  public ActionResult<ItemStack> onItemRightClick(
      ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
    if (playerIn.fishEntity != null) {
      int i = playerIn.fishEntity.handleHookRetraction();
      itemStackIn.damageItem(i, playerIn);
      playerIn.swingArm(hand);
    } else {
      worldIn.playSound(
          (EntityPlayer) null,
          playerIn.posX,
          playerIn.posY,
          playerIn.posZ,
          SoundEvents.ENTITY_BOBBER_THROW,
          SoundCategory.NEUTRAL,
          0.5F,
          0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

      if (!worldIn.isRemote) {
        worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
      }

      playerIn.swingArm(hand);
      playerIn.addStat(StatList.getObjectUseStats(this));
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
  }
Beispiel #20
0
  /**
   * called when the player releases the use item button. Args: itemstack, world, entityplayer,
   * itemInUseCount
   */
  public void onPlayerStoppedUsing(
      ItemStack p_77615_1_, World p_77615_2_, EntityPlayer p_77615_3_, int p_77615_4_) {
    boolean var5 =
        p_77615_3_.capabilities.isCreativeMode
            || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, p_77615_1_) > 0;

    if (var5 || p_77615_3_.inventory.hasItem(Items.arrow)) {
      int var6 = this.getMaxItemUseDuration(p_77615_1_) - p_77615_4_;
      float var7 = (float) var6 / 20.0F;
      var7 = (var7 * var7 + var7 * 2.0F) / 3.0F;

      if ((double) var7 < 0.1D) {
        return;
      }

      if (var7 > 1.0F) {
        var7 = 1.0F;
      }

      EntityArrow var8 = new EntityArrow(p_77615_2_, p_77615_3_, var7 * 2.0F);

      if (var7 == 1.0F) {
        var8.setIsCritical(true);
      }

      int var9 = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, p_77615_1_);

      if (var9 > 0) {
        var8.setDamage(var8.getDamage() + (double) var9 * 0.5D + 0.5D);
      }

      int var10 = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, p_77615_1_);

      if (var10 > 0) {
        var8.setKnockbackStrength(var10);
      }

      if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, p_77615_1_) > 0) {
        var8.setFire(100);
      }

      p_77615_1_.damageItem(1, p_77615_3_);
      p_77615_2_.playSoundAtEntity(
          p_77615_3_,
          "random.bow",
          1.0F,
          1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + var7 * 0.5F);

      if (var5) {
        var8.canBePickedUp = 2;
      } else {
        p_77615_3_.inventory.consumeInventoryItem(Items.arrow);
      }

      if (!p_77615_2_.isClient) {
        p_77615_2_.spawnEntityInWorld(var8);
      }
    }
  }
Beispiel #21
0
  @Override
  public void onPlayerStoppedUsing(
      ItemStack stack, World world, EntityPlayer player, int p_77615_4_) {

    int j = this.getMaxItemUseDuration(stack) - p_77615_4_;

    stack.stackTagCompound = new NBTTagCompound();
    stack.stackTagCompound.setInteger("D", 0);
    stack.damageItem(1, player);
    player.worldObj.playSoundAtEntity(player, (Main.MODID + ":longbowRelease"), 0.8F, 1.0F);

    if ((player.inventory.getStackInSlot(player.inventory.currentItem - 1) != null)) {
      if ((player.inventory.getStackInSlot(player.inventory.currentItem - 1).getItem()
          == (ModItems.itemModelArrow))) {
        float f = j / 20.0F;
        f = (f * f + f * 2.0F) / 3.0F;

        if (f < 0.1D) {
          return;
        }

        if (f > 1.0F) {
          f = 1.0F;
        }

        player.inventory.consumeInventoryItem(ModItems.itemModelArrow);

        // EntityArrow arrow = new EntityArrow(world, player, f * 2.0F);

        if (!world.isRemote) {
          EntityModelArrow arrow = new EntityModelArrow(world, player, f * 2.0F);
          world.spawnEntityInWorld(arrow);
        }
      }
      if ((player.inventory.getStackInSlot(player.inventory.currentItem - 1).getItem()
          == (ModItems.itemIronTippedModelArrow))) {
        float f = j / 20.0F;
        f = (f * f + f * 2.0F) / 3.0F;

        if (f < 0.1D) {
          return;
        }

        if (f > 1.0F) {
          f = 1.0F;
        }

        player.inventory.consumeInventoryItem(ModItems.itemIronTippedModelArrow);

        // EntityArrow arrow = new EntityArrow(world, player, f * 2.0F);

        if (!world.isRemote) {
          EntityModelITArrow arrow = new EntityModelITArrow(world, player, f * 2.0F);
          world.spawnEntityInWorld(arrow);
        }
      }
    }
    bowUse = false;
  }
  @Override
  public boolean onItemUse(
      ItemStack itemStack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    if (!player.canPlayerEdit(x, y, z, side, itemStack)) return false;

    UseTrowelEvent event = new UseTrowelEvent(player, itemStack, world, x, y, z);
    if (MinecraftForge.EVENT_BUS.post(event)) return false;

    if (event.getResult() == Event.Result.ALLOW) {
      itemStack.damageItem(1, player);
      return true;
    }

    if (side == 0) return false;

    Block block = world.getBlock(x, y, z);

    if (block instanceof BlockGarden) {
      player.openGui(GardenCore.instance, GuiHandler.gardenLayoutGuiID, world, x, y, z);
      return true;
    } else if (block instanceof IPlantProxy) {
      IPlantProxy proxy = (IPlantProxy) block;
      TileEntityGarden te = proxy.getGardenEntity(world, x, y, z);

      if (te != null) {
        player.openGui(
            GardenCore.instance,
            GuiHandler.gardenLayoutGuiID,
            world,
            te.xCoord,
            te.yCoord,
            te.zCoord);
        return true;
      }
    }

    /*if (world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
        Block.SoundType stepSound = ModBlocks.gardenSoil.stepSound;
        world.playSoundEffect( + .5f, y + .5f, z + .5f, stepSound.getStepResourcePath(), (stepSound.getVolume() + .5f) / 2, stepSound.getPitch() * .8f);

        if (!world.isRemote) {
            world.setBlock(x, y, z, ModBlocks.gardenSoil);
            itemStack.damageItem(1, player);
        }

        return true;
    }*/

    return false;
  }
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    if (!par3EntityPlayer.capabilities.isCreativeMode) {
      par1ItemStack.damageItem(getMaxDamage() - 2, par3EntityPlayer);
    }

    return par1ItemStack;
  }
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLiving,
     EntityLivingBase par3EntityLiving) {
   par1ItemStack.damageItem(1, par3EntityLiving);
   par2EntityLiving.addPotionEffect(new PotionEffect(Potion.wither.id, 80, 0));
   return true;
 }
Beispiel #25
0
 /**
  * Current implementations of this method in child classes do not use the entry argument beside
  * ev. They just raise the damage on the stack.
  */
 public boolean hitEntity(
     ItemStack par1ItemStack,
     EntityLivingBase par2EntityLivingBase,
     EntityLivingBase par3EntityLivingBase) {
   par1ItemStack.damageItem(1, par3EntityLivingBase);
   par2EntityLivingBase.motionY = 0.6D;
   return true;
 }
 @Override
 public boolean hitEntity(ItemStack stack, EntityLivingBase entity, EntityLivingBase entity2) {
   entity.addPotionEffect(new PotionEffect(MPPotions.chemical.id, 20));
   entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 60));
   entity.addPotionEffect(new PotionEffect(MPPotions.icy_poison.id, 80));
   stack.damageItem(1, entity2);
   return true;
 }
  public boolean interact(EntityPlayer user, boolean leftClk) {
    boolean use = true;
    ItemStack held = user.getHeldItem();
    if (!worldObj.isRemote
        && held != null
        && held.getItem() != null
        && held.getItem() instanceof IUtensil) // BUILD SURFACE
    {
      String type = ((IUtensil) held.getItem()).getType(held);

      if (type.equalsIgnoreCase("mallet")
          && inv[0] != null
          && inv[0].getItem() instanceof ItemBlock) {
        held.damageItem(1, user);
        worldObj.playSoundEffect(
            xCoord + 0.5F,
            yCoord,
            zCoord + 0.5F,
            data_minefantasy.sound("mallet_build"),
            1.0F,
            0.8F + rand.nextFloat() * 0.2F);
        inv[1] = inv[0].copy();
        return true;
      }
    }

    if (!worldObj.isRemote && inv[0] == null && !leftClk) // PUT ITEM
    {
      if (held != null) {
        inv[0] = held.copy();
        inv[0].stackSize = 1;

        if (!user.capabilities.isCreativeMode) {
          held.stackSize--;
          time = 0;
          if (held.stackSize <= 0) {
            held = null;
          }
        }
      } else {
        use = false;
      }
    } else if (!worldObj.isRemote
        && UtensilManager.getTypeOfTool(held) == "Null"
        && !leftClk) // TAKE ITEM
    {
      if (!user.capabilities.isCreativeMode) {
        worldObj.spawnEntityInWorld(
            new EntityItem(worldObj, user.posX, user.posY, user.posZ, inv[0]));
      }
      time = 0;
      inv[0] = null;
    }

    tryToCraft(held, user);

    return use;
  }
  public static void func_92096_a(
      Entity par0Entity, EntityLivingBase par1EntityLivingBase, Random par2Random) {
    int i = EnchantmentHelper.func_92098_i(par1EntityLivingBase);
    ItemStack itemstack = EnchantmentHelper.func_92099_a(Enchantment.thorns, par1EntityLivingBase);

    if (func_92094_a(i, par2Random)) {
      par0Entity.attackEntityFrom(
          DamageSource.causeThornsDamage(par1EntityLivingBase),
          (float) func_92095_b(i, par2Random));
      par0Entity.playSound("damage.thorns", 0.5F, 1.0F);

      if (itemstack != null) {
        itemstack.damageItem(3, par1EntityLivingBase);
      }
    } else if (itemstack != null) {
      itemstack.damageItem(1, par1EntityLivingBase);
    }
  }
  public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
    PotionEffect potion = new PotionEffect(EldritchPotions.getPotion(0).id, 100);
    potion.setCurativeItems(null);
    target.addPotionEffect(potion);

    stack.damageItem(1, attacker);

    return false;
  }
Beispiel #30
0
  /**
   * Current implementations of this method in child classes do not use the entry argument beside
   * ev. They just raise the damage on the stack.
   */
  public boolean hitEntity(
      ItemStack par1ItemStack,
      EntityLivingBase par2EntityLiving,
      EntityLivingBase par3EntityLiving) {

    par2EntityLiving.addPotionEffect(new PotionEffect(Potion.weakness.id, 10 * 20, 6));
    par1ItemStack.damageItem(1, par3EntityLiving);
    return true;
  }