Search in sources :

Example 11 with SoldierUpgradeInst

use of de.sanandrew.mods.claysoldiers.util.soldier.upgrade.SoldierUpgradeInst in project ClaySoldiersMod by SanAndreasP.

the class UpgradeHelperGlass method onPickup.

@Override
public void onPickup(EntityClayMan clayMan, SoldierUpgradeInst upgradeInst, ItemStack stack) {
    ASoldierUpgrade mainUpgrade = SoldierUpgrades.getUpgrade(SoldierUpgrades.UPG_GLASS);
    SoldierUpgradeInst inst = clayMan.hasUpgrade(mainUpgrade) ? clayMan.getUpgrade(mainUpgrade) : clayMan.addUpgrade(mainUpgrade);
    if (inst.getNbtTag().hasKey("leftColor") && inst.getNbtTag().hasKey("rightColor")) {
        short dmg = (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) || stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass)) ? (short) stack.getItemDamage() : -1;
        inst.getNbtTag().setShort("rightColor", dmg);
        clayMan.playSound("dig.glass", 1.0F, 1.0F);
    } else {
        if (stack.getItem() == Items.glass_bottle || stack.getItem() == Item.getItemFromBlock(Blocks.glass_pane)) {
            this.consumeItem(stack, inst);
            clayMan.playSound("random.pop", 1.0F, 1.0F);
            inst.getNbtTag().setShort("leftColor", (short) -1);
            inst.getNbtTag().setShort("rightColor", (short) -1);
        } else if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
            this.consumeItem(stack, inst);
            clayMan.playSound("random.pop", 1.0F, 1.0F);
            inst.getNbtTag().setShort("leftColor", (short) stack.getItemDamage());
            inst.getNbtTag().setShort("rightColor", (short) stack.getItemDamage());
        } else if (stack.getItem() == Item.getItemFromBlock(Blocks.glass)) {
            clayMan.playSound("dig.glass", 1.0F, 1.0F);
            inst.getNbtTag().setShort("leftColor", (short) -1);
            inst.getNbtTag().setShort("rightColor", (short) -1);
        } else if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass)) {
            clayMan.playSound("dig.glass", 1.0F, 1.0F);
            inst.getNbtTag().setShort("leftColor", (short) stack.getItemDamage());
            inst.getNbtTag().setShort("rightColor", (short) stack.getItemDamage());
        }
    }
}
Also used : ASoldierUpgrade(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade) SoldierUpgradeInst(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.SoldierUpgradeInst)

Example 12 with SoldierUpgradeInst

use of de.sanandrew.mods.claysoldiers.util.soldier.upgrade.SoldierUpgradeInst in project ClaySoldiersMod by SanAndreasP.

the class UpgradeCoal method onConstruct.

@Override
public void onConstruct(EntityClayMan clayMan, SoldierUpgradeInst upgradeInst) {
    if (clayMan.hasUpgrade(SoldierUpgrades.UPG_BLAZE_POWDER)) {
        SoldierUpgradeInst bpUpgInst = clayMan.getUpgrade(SoldierUpgrades.getUpgrade(SoldierUpgrades.UPG_BLAZE_POWDER));
        bpUpgInst.getNbtTag().setShort(NBT_USES, (short) (bpUpgInst.getNbtTag().getShort(NBT_USES) + 1));
    }
}
Also used : SoldierUpgradeInst(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.SoldierUpgradeInst)

Aggregations

SoldierUpgradeInst (de.sanandrew.mods.claysoldiers.util.soldier.upgrade.SoldierUpgradeInst)12 ASoldierUpgrade (de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade)6 SoldierEffectInst (de.sanandrew.mods.claysoldiers.util.soldier.effect.SoldierEffectInst)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 ItemStack (net.minecraft.item.ItemStack)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 MutableFloat (org.apache.commons.lang3.mutable.MutableFloat)2 Pair (de.sanandrew.core.manpack.util.javatuples.Pair)1 IMount (de.sanandrew.mods.claysoldiers.entity.mount.IMount)1 ASoldierEffect (de.sanandrew.mods.claysoldiers.util.soldier.effect.ASoldierEffect)1 AUpgradeLeftHanded (de.sanandrew.mods.claysoldiers.util.soldier.upgrade.lefthand.AUpgradeLeftHanded)1 Entry (java.util.Map.Entry)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1