public ItemHammer(EnumHammerType hammerType) { super(blocksEffectiveAgainst); this.hammerType = hammerType; this.setMaxDamage(hammerType.getMaxUses()); this.efficiencyOnProperMaterial = hammerType.getEfficiencyOnProperMaterial(); switch (hammerType) { case CLAW: this.setUnlocalizedName("clawHammer"); break; case SLEDGE: this.setUnlocalizedName("sledgeHammer"); break; case POGO: // 10 Build Grist, 16 Shale this.setUnlocalizedName("pogoHammer"); break; case TELESCOPIC: this.setUnlocalizedName("telescopicSassacrusher"); break; case FEARNOANVIL: this.setUnlocalizedName("fearNoAnvil"); break; case ZILLYHOO: this.setUnlocalizedName("zillyhooHammer"); break; case POPAMATIC: this.setUnlocalizedName("popamaticVrillyhoo"); break; case SCARLET: this.setUnlocalizedName("scarletZillyhoo"); break; } this.weaponDamage = 3 + hammerType.getDamageVsEntity(); }
@Override public boolean hitEntity(ItemStack itemStack, EntityLivingBase target, EntityLivingBase player) { itemStack.damageItem(1, player); if (hammerType.equals(EnumHammerType.POGO)) { target.motionY = Math.abs(player.motionY) + target.motionY + 0.5; player.motionY = 0; player.fallDistance = 0; } else if (hammerType.equals(EnumHammerType.SCARLET)) target.setFire(50); else if (hammerType.equals(EnumHammerType.POPAMATIC)) target.attackEntityFrom( DamageSource.magic, (float) (player.worldObj.rand.nextInt(6) + 1) * (player.worldObj.rand.nextInt(6) + 1)); else if (hammerType.equals(EnumHammerType.FEARNOANVIL) && player.worldObj.rand.nextGaussian() > 0.9) // Just a suggestion, keep it if you like it. target.addPotionEffect( new PotionEffect( 2, 100, 3)); // Would prefer it being triggered by a critical hit instead, if it can. return true; }
public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (world.getBlock(x, y, z) != Blocks.air) { if (hammerType.equals(EnumHammerType.POGO)) { player.motionY = Math.abs(player.motionY) + 0.5; player.fallDistance = 0; stack.damageItem(1, player); return true; } } return false; }