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);
}
}
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;
}
}
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));
}
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());
}
}
}
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();
}
Aggregations