Search in sources :

Example 1 with ItemGemKatana

use of net.silentchaos512.gems.item.tool.ItemGemKatana in project SilentGems by SilentChaos512.

the class ToolRandomizer method randomize.

public ItemStack randomize(ItemStack tool, float superChance) {
    if (tool.getItem() instanceof IArmor)
        return randomizeArmor(tool, superChance);
    if (!(tool.getItem() instanceof ITool) || !ToolHelper.hasNoConstruction(tool))
        return tool;
    ITool itool = (ITool) tool.getItem();
    // Regular or super?
    boolean superTier = !itool.getValidTiers().contains(EnumMaterialTier.REGULAR) || (SilentGems.random.nextFloat() < superChance && itool.getValidTiers().contains(EnumMaterialTier.SUPER));
    // How many gems?
    boolean gem2 = SilentGems.random.nextFloat() < SECOND_GEM_CHANCE;
    boolean gem3 = gem2 && SilentGems.random.nextFloat() < THIRD_GEM_CHANCE;
    // Gem array
    EnumGem[] gems;
    if (gem3) {
        // 3 gems
        gems = new EnumGem[] { EnumGem.getRandom(), EnumGem.getRandom(), EnumGem.getRandom() };
    } else if (gem2) {
        // 2 gems (3rd = 1st)
        EnumGem g1 = EnumGem.getRandom();
        EnumGem g2 = EnumGem.getRandom();
        if (tool.getItem() == ModItems.sword)
            gems = new EnumGem[] { g1, g2 };
        else
            gems = new EnumGem[] { g1, g2, g1 };
    } else {
        // 1 gem
        EnumGem g1 = EnumGem.getRandom();
        gems = new EnumGem[] { g1, g1, g1 };
    }
    // Crafting stack array
    ItemStack[] craftingStacks = new ItemStack[gems.length];
    for (int i = 0; i < craftingStacks.length; ++i) {
        craftingStacks[i] = superTier ? gems[i].getItemSuper() : gems[i].getItem();
    }
    // Select rod
    ItemStack rod;
    if (superTier) {
        ItemStack[] choices = new ItemStack[] { ModItems.craftingMaterial.toolRodGold, ModItems.craftingMaterial.toolRodSilver, ModItems.craftingMaterial.toolRodIron };
        rod = choices[SilentGems.random.nextInt(choices.length)];
    } else {
        ItemStack[] choices = new ItemStack[] { new ItemStack(Items.STICK), new ItemStack(Items.BONE), ModItems.craftingMaterial.toolRodIron };
        rod = choices[SilentGems.random.nextInt(choices.length)];
    }
    ItemStack temp = ToolHelper.constructTool(tool.getItem(), rod, craftingStacks);
    if (temp.getItem() instanceof ItemGemKatana)
        temp = ((ItemGemKatana) temp.getItem()).addDefaultGrip(temp);
    // Set name
    String ownerName = nameAdjectives.get(SilentGems.random.nextInt(nameAdjectives.size())) + " " + nameNouns.get(SilentGems.random.nextInt(nameNouns.size()));
    ToolHelper.setOriginalOwner(temp, TextFormatting.AQUA + ownerName);
    tool.setTagCompound(temp.getTagCompound());
    return temp;
}
Also used : EnumGem(net.silentchaos512.gems.lib.EnumGem) ItemStack(net.minecraft.item.ItemStack) IArmor(net.silentchaos512.gems.api.IArmor) ITool(net.silentchaos512.gems.api.ITool) ItemGemKatana(net.silentchaos512.gems.item.tool.ItemGemKatana)

Example 2 with ItemGemKatana

use of net.silentchaos512.gems.item.tool.ItemGemKatana in project SilentGems by SilentChaos512.

the class ItemGemSword method getShots.

private List<EntityChaosProjectile> getShots(EntityPlayer player, ItemStack stack) {
    List<EntityChaosProjectile> list = Lists.newArrayList();
    if (ToolHelper.getToolTier(stack).ordinal() < EnumMaterialTier.SUPER.ordinal()) {
        return list;
    }
    EnumMagicType magicType = EnumMagicType.getMagicType(stack);
    int shotCount = magicType.getShotCount(stack);
    // Calculate magic damage.
    // Includes player "magic strength" (currently just a constant 1, might do something with it later).
    float damage = 1f + getMagicDamage(stack);
    // Magic damage enchantment
    int magicEnchLevel = EnchantmentHelper.getEnchantmentLevel(ModEnchantments.magicDamage, stack);
    if (magicEnchLevel > 0)
        damage += ModEnchantments.magicDamage.calcDamage(magicEnchLevel);
    damage *= magicType.getDamagePerShotMultiplier();
    Item item = stack.getItem();
    // Dagger
    if (item instanceof ItemGemDagger) {
        for (int i = 0; i < shotCount; ++i) {
            list.add(new EntityChaosProjectileHoming(player, stack, damage, false, 0.0325, 0.25));
        }
    } else // Scepter
    if (item instanceof ItemGemScepter) {
        for (int i = 0; i < shotCount; ++i) {
            list.add(new EntityChaosProjectileHoming(player, stack, damage, true, 0.075, 0.35));
        }
    } else // Katana
    if (item instanceof ItemGemKatana) {
        final float maxAngle = 0.05f;
        for (float angle = -maxAngle; angle <= maxAngle; angle += maxAngle / (shotCount / 2)) {
            list.add(new EntityChaosProjectileSweep(player, stack, damage, angle));
        }
    } else // Machete
    if (item instanceof ItemGemMachete) {
        for (int i = 0; i < shotCount; ++i) {
            list.add(new EntityChaosProjectileScatter(player, stack, damage));
        }
    } else // Classic sword (default)
    {
        for (int i = 0; i < shotCount; ++i) {
            EntityChaosProjectile e = new EntityChaosProjectile(player, stack, damage);
            e.motionY += 0.2 * i;
            list.add(e);
        }
    }
    return list;
}
Also used : EntityChaosProjectileScatter(net.silentchaos512.gems.entity.EntityChaosProjectileScatter) EntityChaosProjectileSweep(net.silentchaos512.gems.entity.EntityChaosProjectileSweep) EnumMagicType(net.silentchaos512.gems.util.EnumMagicType) EntityChaosProjectile(net.silentchaos512.gems.entity.EntityChaosProjectile) EntityChaosProjectileHoming(net.silentchaos512.gems.entity.EntityChaosProjectileHoming) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

EntityItem (net.minecraft.entity.item.EntityItem)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 IArmor (net.silentchaos512.gems.api.IArmor)1 ITool (net.silentchaos512.gems.api.ITool)1 EntityChaosProjectile (net.silentchaos512.gems.entity.EntityChaosProjectile)1 EntityChaosProjectileHoming (net.silentchaos512.gems.entity.EntityChaosProjectileHoming)1 EntityChaosProjectileScatter (net.silentchaos512.gems.entity.EntityChaosProjectileScatter)1 EntityChaosProjectileSweep (net.silentchaos512.gems.entity.EntityChaosProjectileSweep)1 ItemGemKatana (net.silentchaos512.gems.item.tool.ItemGemKatana)1 EnumGem (net.silentchaos512.gems.lib.EnumGem)1 EnumMagicType (net.silentchaos512.gems.util.EnumMagicType)1