Search in sources :

Example 6 with ASoldierUpgrade

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

the class UpgradeHelperShearBlade method onPickup.

@Override
public void onPickup(EntityClayMan clayMan, SoldierUpgradeInst upgradeInst, ItemStack stack) {
    ASoldierUpgrade upgrade = null;
    ItemStack savedItem = null;
    if (stack.getItem() == RegistryItems.shearBlade) {
        if (!clayMan.hasUpgrade(AUpgradeLeftHanded.class)) {
            upgrade = SoldierUpgrades.getUpgrade(SoldierUpgrades.UPG_SHEARLEFT);
            savedItem = stack;
        } else if (!clayMan.hasUpgrade(AUpgradeRightHanded.class)) {
            upgrade = SoldierUpgrades.getUpgrade(SoldierUpgrades.UPG_SHEARRIGHT);
            savedItem = stack;
        }
    } else {
        if (!clayMan.hasUpgrade(AUpgradeLeftHanded.class)) {
            clayMan.entityDropItem(new ItemStack(RegistryItems.shearBlade, 1), 0.0F);
            upgrade = SoldierUpgrades.getUpgrade(SoldierUpgrades.UPG_SHEARLEFT);
            savedItem = new ItemStack(RegistryItems.shearBlade, 1);
        } else if (!clayMan.hasUpgrade(AUpgradeRightHanded.class)) {
            clayMan.entityDropItem(new ItemStack(RegistryItems.shearBlade, 1), 0.0F);
            upgrade = SoldierUpgrades.getUpgrade(SoldierUpgrades.UPG_SHEARRIGHT);
            savedItem = new ItemStack(RegistryItems.shearBlade, 1);
        }
    }
    if (upgrade != null) {
        if (savedItem != stack) {
            stack.setCount(stack.getCount() - 1);
        }
        SoldierUpgradeInst newUpgrade = clayMan.addUpgrade(upgrade);
        this.consumeItem(savedItem, newUpgrade);
        clayMan.playSound("random.pop", 1.0F, 1.0F);
    }
}
Also used : AUpgradeLeftHanded(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.lefthand.AUpgradeLeftHanded) ASoldierUpgrade(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade) SoldierUpgradeInst(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.SoldierUpgradeInst) ItemStack(net.minecraft.item.ItemStack)

Example 7 with ASoldierUpgrade

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

the class TileEntityClayNexus method setStackInSlot.

private void setStackInSlot(int slot, ItemStack stack) {
    switch(slot) {
        case SOLDIER_SLOT:
            this.p_soldierSlot = stack;
            this.p_tempClayTeam = ItemClayManDoll.getTeam(stack);
            break;
        case THROWABLE_SLOT:
            ASoldierUpgrade upg = SoldierUpgrades.getUpgrade(stack);
            this.p_tempThrowableCls = stack != null && upg instanceof IThrowableUpgrade ? ((IThrowableUpgrade) upg).getThrowableClass() : null;
            this.p_throwableSlot = stack;
            break;
        case MOUNT_SLOT:
            this.p_mountSlot = stack;
            break;
        default:
            this.p_upgradeItems[slot - 3] = stack;
    }
}
Also used : IThrowableUpgrade(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.IThrowableUpgrade) ASoldierUpgrade(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade)

Example 8 with ASoldierUpgrade

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

the class UpgradeDiamondBlock method onConstruct.

@Override
public void onConstruct(EntityClayMan clayMan, SoldierUpgradeInst upgradeInst) {
    IAttributeInstance attrib = clayMan.getEntityAttribute(SharedMonsterAttributes.maxHealth);
    attrib.setBaseValue(attrib.getBaseValue() * 80.0D);
    clayMan.heal(clayMan.getMaxHealth());
    ASoldierUpgrade[] upgrades = clayMan.getAvailableUpgrades();
    for (ASoldierUpgrade upgrade : upgrades) {
        NBTTagCompound upgNbt = clayMan.getUpgrade(upgrade).getNbtTag();
        if (upgNbt.hasKey(NBT_USES, NBT.TAG_COMPOUND)) {
            upgNbt.setShort(NBT_USES, (short) (upgNbt.getShort(NBT_USES) * 5));
        }
    }
    clayMan.addUpgrade(SoldierUpgrades.getUpgrade(SoldierUpgrades.UPG_SUGAR));
}
Also used : ASoldierUpgrade(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 9 with ASoldierUpgrade

use of de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade 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 10 with ASoldierUpgrade

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

the class RenderClayNexus method renderThrowableItem.

private static void renderThrowableItem(TileEntityClayNexus nexus, ItemStack stack, float partTicks) {
    float itmAngle = nexus.prevSpinAngle + (nexus.spinAngle - nexus.prevSpinAngle) * partTicks - 45.0F;
    ASoldierUpgrade upg = SoldierUpgrades.getUpgrade(stack);
    IThrowableUpgrade throwableUpg = upg instanceof IThrowableUpgrade ? (IThrowableUpgrade) upg : null;
    if (throwableUpg == null) {
        return;
    }
    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, 0.875F, 0.0F);
    GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(0.25F, 0.25F, 0.25F);
    GL11.glRotatef(-itmAngle, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, 0.0F, 0.0F);
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    throwableUpg.renderNexusThrowable(nexus, partTicks);
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}
Also used : IThrowableUpgrade(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.IThrowableUpgrade) ASoldierUpgrade(de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade)

Aggregations

ASoldierUpgrade (de.sanandrew.mods.claysoldiers.util.soldier.upgrade.ASoldierUpgrade)11 SoldierUpgradeInst (de.sanandrew.mods.claysoldiers.util.soldier.upgrade.SoldierUpgradeInst)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 IThrowableUpgrade (de.sanandrew.mods.claysoldiers.util.soldier.upgrade.IThrowableUpgrade)2 IAttributeInstance (net.minecraft.entity.ai.attributes.IAttributeInstance)2 MutableFloat (org.apache.commons.lang3.mutable.MutableFloat)2 Pair (de.sanandrew.core.manpack.util.javatuples.Pair)1 EntityClayMan (de.sanandrew.mods.claysoldiers.entity.EntityClayMan)1 IMount (de.sanandrew.mods.claysoldiers.entity.mount.IMount)1 ASoldierEffect (de.sanandrew.mods.claysoldiers.util.soldier.effect.ASoldierEffect)1 SoldierEffectInst (de.sanandrew.mods.claysoldiers.util.soldier.effect.SoldierEffectInst)1 AUpgradeLeftHanded (de.sanandrew.mods.claysoldiers.util.soldier.upgrade.lefthand.AUpgradeLeftHanded)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1