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