Beispiel #1
0
  public static boolean hasUpgrade(
      Class<? extends TurretUpgrades> tUpg, Map<Integer, ItemStack> upgMap) {
    if (upgMap == null || tUpg == null) return false;

    TurretUpgrades chkUpg = upgradeListCLT.get(tUpg);

    if (!upgMap.containsKey(chkUpg.getUpgradeID())
        || (upgMap.containsKey(chkUpg.getUpgradeID()) && upgMap.get(chkUpg.getUpgradeID()) == null))
      return false;

    if (upgMap.containsKey(chkUpg.getUpgradeID()) && upgMap.get(chkUpg.getUpgradeID()) != null) {
      ItemStack is = upgMap.get(chkUpg.getUpgradeID());
      if (CUS.areStacksEqualWithWCV(chkUpg.getItem(), is)) {
        if (is.isItemEnchanted() && chkUpg.getEnchantment() != null) {
          NBTTagList ench = is.getEnchantmentTagList();
          for (int j = 0; j < ench.tagCount(); ++j) {
            NBTTagCompound var4 = (NBTTagCompound) ench.tagAt(j);
            if (var4.getShort("id") == chkUpg.getEnchantment().effectId) {
              return true;
            }
          }
        } else if (chkUpg.getEnchantment() == null) {
          return true;
        }
      }
    }

    return false;
  }
  @Override
  public boolean hasEffect(ItemStack par1ItemStack) {
    if (isInfused) {
      return true;
    }

    return par1ItemStack.isItemEnchanted();
  }
 @Override
 @SideOnly(Side.CLIENT)
 public boolean hasEffect(ItemStack itemStack, int pass) {
   if (!itemStack.isItemEnchanted()) {
     itemStack.addEnchantment(Enchantment.efficiency, 3);
     itemStack.addEnchantment(Enchantment.sharpness, 3);
     itemStack.addEnchantment(Enchantment.unbreaking, 3);
   }
   return true;
 }
 public void onUpdate(
     ItemStack itemstack, World par2World, Entity par3Entity, int par4, boolean par5) {
   if (itemstack.isItemEnchanted() == false) {
     itemstack.addEnchantment(KingdomKeys.HarvestHearts, 2);
   }
   EntityPlayer player = (EntityPlayer) par3Entity;
   if (this.keyPressed) {
     Minecraft.getMinecraft().theWorld.playSoundAtEntity(player, "kk:summon", 1, 0);
     this.keyPressed = false;
   }
 }
 public void onUpdate(
     ItemStack itemstack, World par2World, Entity par3Entity, int par4, boolean par5) {
   if (itemstack.isItemEnchanted() == false) {
     itemstack.addEnchantment(KingdomKeys.HarvestHearts, 1);
   }
   EntityPlayer player = (EntityPlayer) par3Entity;
   if (this.keyPressed) {
     this.keyPressed = false;
     if (player.getHeldItem() != null && player.getHeldItem().itemID == AddedItems.K99.itemID) {}
   }
 }
Beispiel #6
0
  public static boolean itemIsEnchanted(ItemStack itemStack, Enchantment enchantment) {
    if (itemStack != null && itemStack.isItemEnchanted()) {
      NBTTagList enchantmentTagList = itemStack.getEnchantmentTagList();
      for (int i = enchantmentTagList.tagCount() - 1; i > -1; i--) {
        if (((NBTTagCompound) enchantmentTagList.tagAt(i)).getShort("id") == enchantment.effectId) {
          return true;
        }
      }
    }

    return false;
  }
 private EnumRarity rarity(ItemStack item, int lvl) {
   EnumRarity[] rarity =
       new EnumRarity[] {EnumRarity.common, EnumRarity.uncommon, EnumRarity.rare, EnumRarity.epic};
   if (item.isItemEnchanted()) {
     if (lvl == 0) {
       lvl++;
     }
     lvl++;
   }
   if (lvl >= rarity.length) {
     lvl = rarity.length - 1;
   }
   return rarity[lvl];
 }
Beispiel #8
0
  public static List<ItemEnchantment> getItemEnchantments(ItemStack itemStack) {
    if (!itemStack.isItemEnchanted()) {
      return Collections.EMPTY_LIST;
    }
    final List<ItemEnchantment> enchantments = Lists.newArrayList();
    final NBTTagList list = itemStack.getEnchantmentTagList();
    for (int i = 0; i < list.tagCount(); i++) {
      final NBTTagCompound compound = list.getCompoundTagAt(i);
      final short enchantmentId = compound.getShort(NbtDataUtil.ITEM_ENCHANTMENT_ID);
      final short level = compound.getShort(NbtDataUtil.ITEM_ENCHANTMENT_LEVEL);

      final Enchantment enchantment =
          (Enchantment) net.minecraft.enchantment.Enchantment.getEnchantmentById(enchantmentId);
      enchantments.add(new ItemEnchantment(enchantment, level));
    }
    return enchantments;
  }
Beispiel #9
0
  private void drawSlot(Minecraft mc, ItemStack stack, int x, int y) {
    RenderHelper.enableGUIStandardItemLighting();

    itemRender.renderItemIntoGUI(stack, x, y);
    RenderHelper.disableStandardItemLighting();
    //        itemRender.renderItemOverlayIntoGUI(mc.fontRendererObj, mc.getTextureManager(), stack,
    // x, y);
    //        GL11.glDisable(GL11.GL_LIGHTING);
    //        GL11.glEnable(GL11.GL_ALPHA_TEST);
    //        GL11.glEnable(GL11.GL_BLEND);

    if (stack.isItemEnchanted()) renderEffectSlot(mc.getTextureManager(), x - 1, y - 1);
    else {
      SAOGL.glBlend(true);
      SAOGL.glAlpha(true);
    }
  }
 @SideOnly(Side.CLIENT)
 @Deprecated // Render pass sensitive version below.
 public boolean hasEffect(ItemStack par1ItemStack) {
   return par1ItemStack.isItemEnchanted();
 }
 public void onUpdate(
     ItemStack itemstack, World par2World, Entity par3Entity, int par4, boolean par5) {
   if (itemstack.isItemEnchanted() == false) {
     itemstack.addEnchantment(Enchantment.knockback, 1);
   }
 }
  /** Queries whether should render the specified pass or not. */
  protected int shouldRenderPass(EntityLiving par1EntityLiving, int par2, float par3) {
    ItemStack itemstack = par1EntityLiving.getCurrentArmor(3 - par2);

    if (itemstack != null) {
      Item item = itemstack.getItem();

      if (item instanceof ItemArmor) {
        ItemArmor itemarmor = (ItemArmor) item;
        this.loadTexture(
            ForgeHooksClient.getArmorTexture(
                itemstack,
                "/armor/"
                    + bipedArmorFilenamePrefix[itemarmor.renderIndex]
                    + "_"
                    + (par2 == 2 ? 2 : 1)
                    + ".png"));
        ModelBiped modelbiped = par2 == 2 ? this.field_82425_h : this.field_82423_g;
        modelbiped.bipedHead.showModel = par2 == 0;
        modelbiped.bipedHeadwear.showModel = par2 == 0;
        modelbiped.bipedBody.showModel = par2 == 1 || par2 == 2;
        modelbiped.bipedRightArm.showModel = par2 == 1;
        modelbiped.bipedLeftArm.showModel = par2 == 1;
        modelbiped.bipedRightLeg.showModel = par2 == 2 || par2 == 3;
        modelbiped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3;
        this.setRenderPassModel(modelbiped);

        if (modelbiped != null) {
          modelbiped.onGround = this.mainModel.onGround;
        }

        if (modelbiped != null) {
          modelbiped.isRiding = this.mainModel.isRiding;
        }

        if (modelbiped != null) {
          modelbiped.isChild = this.mainModel.isChild;
        }

        float f1 = 1.0F;

        if (itemarmor.getArmorMaterial() == EnumArmorMaterial.CLOTH) {
          int j = itemarmor.getColor(itemstack);
          float f2 = (float) (j >> 16 & 255) / 255.0F;
          float f3 = (float) (j >> 8 & 255) / 255.0F;
          float f4 = (float) (j & 255) / 255.0F;
          GL11.glColor3f(f1 * f2, f1 * f3, f1 * f4);

          if (itemstack.isItemEnchanted()) {
            return 31;
          }

          return 16;
        }

        GL11.glColor3f(f1, f1, f1);

        if (itemstack.isItemEnchanted()) {
          return 15;
        }

        return 1;
      }
    }

    return -1;
  }
  /**
   * Called to tick armor in the armor slot. Override to do something
   *
   * @param world
   * @param player
   * @param itemStack
   */
  @Override
  public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack) {
    ItemStack item3 = player.inventory.armorInventory[3];
    ItemStack item0 = player.inventory.armorInventory[0];

    // snorkel stuff
    if (item3 != null && item3.itemID == TropicraftItems.snorkel.itemID) {
      outOfWater = !player.isInsideOfMaterial(Material.water) || !player.isInWater();

      if (outOfWaterLast && outOfWater) {
        player.setAir(300);
      }

      if (outOfWaterLast && !outOfWater) {
        player.setAir(1200);
        outOfWaterLast = false;
      }

      if (outOfWater) {
        outOfWaterLast = true;
      }
    } else if (player.getAir() > 300
        && (item3 == null || item3.itemID != TropicraftItems.snorkel.itemID)) {
      player.setAir(300);
    } else {
      outOfWater = true;
      outOfWaterLast = true;
    }

    // flippers stuff
    if (item0 != null && item0.itemID == TropicraftItems.flippers.itemID) {
      if (player.isInsideOfMaterial(Material.water)) {
        player.capabilities.isFlying = true;
        player.setAIMoveSpeed(player.capabilities.getWalkSpeed());
        if (item0.isItemEnchanted()) {
          player.moveFlying(1E-4F, 1E-4F, 0.00000000001f);
          player.motionX /= 1.06999999;
          player.motionZ /= 1.06999999;
          player.moveEntityWithHeading(-1E-4F, -1E-4F);
        } else {
          player.moveFlying(1E-4F, 1E-4F, 0.00000000001f);
          player.motionX /= 1.26999999;
          player.motionZ /= 1.26999999;
          player.moveEntityWithHeading(-1E-4F, -1E-4F);
        }

        int l =
            EnchantmentHelper.getEnchantmentLevel(EnchantmentManager.scubaSteve.effectId, item3);

        if (l > 0) player.moveEntityWithHeading(-1F, -1F);
        else player.moveEntityWithHeading(-1E-4F, -1E-4F);
      } else {
        player.setAIMoveSpeed((float) (player.getAIMoveSpeed() / 1.33333));
        player.capabilities.isFlying = false;
      }

      hasFlippers = true;
    }

    if ((item0 == null || item0.itemID != TropicraftItems.flippers.itemID) && hasFlippers) {
      if (!player.capabilities.isCreativeMode && player.capabilities.isFlying) {
        player.capabilities.isFlying = false;
      }

      hasFlippers = false;
    }
  }
  /** Set the specified armor model as the player model. Args: player, armorSlot, partialTick */
  @Override
  protected int setArmorModel(EntityPlayer par1EntityPlayer, int par2, float par3) {
    ItemStack itemstack = par1EntityPlayer.inventory.armorItemInSlot(3 - par2);
    RenderPlayerTFC.armorFilenamePrefix = RenderPlayer.armorFilenamePrefix;

    if (itemstack != null) {
      Item item = itemstack.getItem();

      if (item instanceof ItemArmor) {
        ItemArmor itemarmor = (ItemArmor) item;
        this.loadTexture(
            ForgeHooksClient.getArmorTexture(
                itemstack,
                "/armor/"
                    + armorFilenamePrefix[itemarmor.renderIndex]
                    + "_"
                    + (par2 == 2 ? 2 : 1)
                    + ".png"));
        ModelBiped modelbiped = par2 == 2 ? this.modelArmor : this.modelArmorChestplate;
        modelbiped.bipedHead.showModel = par2 == 0;
        plume.showModel = false; // (itemstack.getItem() == TFCItems.BronzeHelmet);
        plume2.showModel = false; // (itemstack.getItem() == TFCItems.BronzeHelmet);
        HornR1.showModel = false; // (itemstack.getItem() == TFCItems.WroughtIronHelmet);
        HornL1.showModel = false; // (itemstack.getItem() == TFCItems.WroughtIronHelmet);
        modelbiped.bipedHeadwear.showModel =
            par2 == 0
                && (itemstack.getItem() != TFCItems.BronzeHelmet
                    && itemstack.getItem() != TFCItems.WroughtIronHelmet);
        modelbiped.bipedBody.showModel = par2 == 1 || par2 == 2;
        modelbiped.bipedRightArm.showModel = par2 == 1;
        modelbiped.bipedLeftArm.showModel = par2 == 1;
        modelbiped.bipedRightLeg.showModel = par2 == 2 || par2 == 3;
        modelbiped.bipedLeftLeg.showModel = par2 == 2 || par2 == 3;
        this.setRenderPassModel(modelbiped);

        if (modelbiped != null) {
          modelbiped.onGround = this.mainModel.onGround;
        }

        if (modelbiped != null) {
          modelbiped.isRiding = this.mainModel.isRiding;
        }

        if (modelbiped != null) {
          modelbiped.isChild = this.mainModel.isChild;
        }

        float f1 = 1.0F;

        if (itemarmor.getArmorMaterial() == EnumArmorMaterial.CLOTH) {
          int j = itemarmor.getColor(itemstack);
          float f2 = (j >> 16 & 255) / 255.0F;
          float f3 = (j >> 8 & 255) / 255.0F;
          float f4 = (j & 255) / 255.0F;
          GL11.glColor3f(f1 * f2, f1 * f3, f1 * f4);

          if (itemstack.isItemEnchanted()) {
            return 31;
          }

          return 16;
        }

        GL11.glColor3f(f1, f1, f1);

        if (itemstack.isItemEnchanted()) {
          return 15;
        }

        return 1;
      }
    }

    return -1;
  }