コード例 #1
0
ファイル: ItemHammer.java プロジェクト: trielt1/Minestuck
 @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;
 }
コード例 #2
0
ファイル: ItemHammer.java プロジェクト: trielt1/Minestuck
 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;
 }