Examples of ILockable


Examples of net.mcft.copy.betterstorage.api.lock.ILockable

    if (fullColor >= 0) ItemBetterStorage.setFullColor(key, fullColor);
    return key;
  }
 
  private boolean attack(EntityPlayer player, ItemStack holding) {
    ILockable lockable = (ILockable)tileEntity;
    ItemStack lock = lockable.getLock();
    if (lock == null) return false;
   
    boolean canHurt = ((hit <= 0) && canHurtLock(holding));
    if (canHurt) {
      holding.damageItem(2, player);
      if (holding.stackSize <= 0)
        player.destroyCurrentEquippedItem();
    }
    if (!player.worldObj.isRemote) {
      if (canHurt) {
        hit = 10;
       
        int damage = (int)((AttributeModifier)holding.getAttributeModifiers().get(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName()).iterator().next()).getAmount();
        int sharpness = EnchantmentHelper.getEnchantmentLevel(Enchantment.sharpness.effectId, holding);
        int efficiency = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, holding);
        breakProgress += Math.min(damage, 10) / 2 + Math.min(Math.max(sharpness, efficiency), 5);
       
        int persistance = BetterStorageEnchantment.getLevel(lock, "persistance");
        if (breakProgress > 100 * (1 + persistance)) {
          int unbreaking = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, lock);
          lock.setItemDamage(lock.getItemDamage() + 10 / (1 + unbreaking));
          if (lock.getItemDamage() < lock.getMaxDamage()) {
            AxisAlignedBB box = getHighlightBox();
            double x = (box.minX + box.maxX) / 2;
            double y = (box.minY + box.maxY) / 2;
            double z = (box.minZ + box.maxZ) / 2;
            EntityItem item = WorldUtils.spawnItem(tileEntity.getWorldObj(), x, y, z, lock);
          }
          lockable.setLock(null);
          breakProgress = 0;
        }
       
        ((ILock)lock.getItem()).applyEffects(lock, lockable, player, EnumLockInteraction.ATTACK);
      }
View Full Code Here

Examples of net.mcft.copy.betterstorage.api.lock.ILockable

  }
 
  private boolean use(EntityPlayer player, ItemStack holding) {
    if (player.worldObj.isRemote) return false;
   
    ILockable lockable = (ILockable)tileEntity;
    ItemStack lock = lockable.getLock();
   
    if (lock == null) {
      if (StackUtils.isLock(holding) && lockable.isLockValid(holding)) {
        lockable.setLock(holding);
        player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
        return true;
      }
    } else if (StackUtils.isKey(holding)) {
      IKey keyType = (IKey)holding.getItem();
      ILock lockType = (ILock)lock.getItem();
     
      boolean success = keyType.unlock(holding, lock, true);
      lockType.onUnlock(lock, holding, lockable, player, success);
      if (!success) return true;
     
      if (player.isSneaking()) {
        AxisAlignedBB box = getHighlightBox();
        double x = (box.minX + box.maxX) / 2;
        double y = (box.minY + box.maxY) / 2;
        double z = (box.minZ + box.maxZ) / 2;
        EntityItem item = WorldUtils.spawnItem(player.worldObj, x, y, z, lock);
        lockable.setLock(null);
      } else lockable.useUnlocked(player);
     
      return true;
    }
   
    return false;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.