use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.
the class AlchemicalWizardryEventHooks method omegaUpdateReagentAndHpEvent.
@SubscribeEvent
public void omegaUpdateReagentAndHpEvent(LivingUpdateEvent event) {
if (event.entityLiving instanceof EntityPlayer && !event.entityLiving.worldObj.isRemote) {
EntityPlayer player = (EntityPlayer) event.entityLiving;
Reagent reagent = APISpellHelper.getPlayerReagentType(player);
float reagentAmount = APISpellHelper.getPlayerCurrentReagentAmount(player);
boolean hasReagentChanged = false;
if (reagentAmount > 0 && OmegaRegistry.hasParadigm(reagent)) {
int cooldown = APISpellHelper.getPlayerReagentRegenCooldownTag(player);
boolean canHealHPBar = true;
if (cooldown > 0) {
float extra = 0;
if (player.isPotionActive(AlchemicalWizardry.customPotionSoulHarden)) {
extra += 0.25f * (1 + player.getActivePotionEffect(AlchemicalWizardry.customPotionSoulHarden).getAmplifier());
}
if (player.isPotionActive(AlchemicalWizardry.customPotionSoulFray)) {
extra -= 0.25f * (1 + player.getActivePotionEffect(AlchemicalWizardry.customPotionSoulFray).getAmplifier());
}
int deduction = -1 - (extra >= 0 ? (rand.nextFloat() < extra ? 1 : 0) : (rand.nextFloat() < -extra / 2 ? -1 : 0));
APISpellHelper.setPlayerReagentRegenCooldownTag(player, Math.max(cooldown + deduction, 0));
canHealHPBar = false;
}
OmegaParadigm parad = OmegaRegistry.getParadigmForReagent(reagent);
ReagentRegenConfiguration config = parad.getRegenConfig(player);
if (parad.isPlayerWearingFullSet(player)) {
if (canHealHPBar) {
int tickRate = config.tickRate;
if (player.isPotionActive(Potion.regeneration)) {
int i = player.getActivePotionEffect(Potion.regeneration).getAmplifier();
double factor = Math.pow(1.5, i + 1);
tickRate = Math.max((int) (tickRate / factor), 1);
}
if (event.entityLiving.worldObj.getWorldTime() % tickRate == 0) {
boolean hasHealthChanged = false;
int maxHealth = parad.getMaxAdditionalHealth();
float health = APISpellHelper.getCurrentAdditionalHP(player);
if (health > maxHealth) {
health = maxHealth;
hasHealthChanged = true;
} else if (health < maxHealth) {
float addedAmount = Math.min(Math.min((reagentAmount / config.costPerPoint), config.healPerTick), maxHealth - health);
float drain = addedAmount * config.costPerPoint;
reagentAmount -= drain;
hasReagentChanged = true;
health += addedAmount;
hasHealthChanged = true;
}
if (player instanceof EntityPlayerMP) {
if (hasHealthChanged) {
APISpellHelper.setCurrentAdditionalHP(player, health);
NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getAddedHPPacket(health, maxHealth), (EntityPlayerMP) player);
}
}
}
}
} else {
reagentAmount = 0;
APISpellHelper.setPlayerMaxReagentAmount(player, 0);
NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getReagentBarPacket(null, 0, 0), (EntityPlayerMP) player);
APISpellHelper.setCurrentAdditionalHP(player, 0);
NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getAddedHPPacket(0, 0), (EntityPlayerMP) player);
}
// Consumes the amount
float costPerTick = parad.getCostPerTickOfUse(player);
if (parad.doDrainReagent(player)) {
if (reagentAmount > costPerTick) {
hasReagentChanged = true;
reagentAmount = Math.max(0, reagentAmount - costPerTick);
} else {
hasReagentChanged = true;
reagentAmount = 0;
}
}
hasReagentChanged = true;
}
if (reagentAmount <= 0) {
boolean hasRevertedArmour = false;
ItemStack[] armourInventory = player.inventory.armorInventory;
for (ItemStack stack : armourInventory) {
if (stack != null && stack.getItem() instanceof OmegaArmour) {
((OmegaArmour) stack.getItem()).revertArmour(player, stack);
hasRevertedArmour = true;
}
}
if (hasRevertedArmour) {
APISpellHelper.setCurrentAdditionalHP(player, 0);
NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getAddedHPPacket(0, 0), (EntityPlayerMP) player);
}
}
if (player instanceof EntityPlayerMP) {
if (hasReagentChanged) {
APISpellHelper.setPlayerCurrentReagentAmount(player, reagentAmount);
NewPacketHandler.INSTANCE.sendTo(NewPacketHandler.getReagentBarPacket(reagent, reagentAmount, APISpellHelper.getPlayerMaxReagentAmount(player)), (EntityPlayerMP) player);
}
}
}
}
use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.
the class OmegaParadigm method setOmegaStalling.
public boolean setOmegaStalling(EntityPlayer player, int duration) {
ItemStack[] armours = player.inventory.armorInventory;
ItemStack chestStack = armours[2];
if (chestStack != null && chestStack.getItem() == this.chestPiece) {
((OmegaArmour) chestStack.getItem()).setOmegaStallingDuration(chestStack, duration);
return true;
}
return false;
}
use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.
the class OmegaRegistry method getOmegaParadigmOfWeilder.
public static OmegaParadigm getOmegaParadigmOfWeilder(EntityPlayer player) {
ItemStack[] armours = player.inventory.armorInventory;
ItemStack chestStack = armours[2];
if (chestStack != null && chestStack.getItem() instanceof OmegaArmour) {
return ((OmegaArmour) chestStack.getItem()).getOmegaParadigm();
}
return null;
}
use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.
the class AlchemicalWizardry method initReagentRegistries.
public static void initReagentRegistries() {
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.sanctus), new ReagentStack(ReagentRegistry.sanctusReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.incendium), new ReagentStack(ReagentRegistry.incendiumReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.aquasalus), new ReagentStack(ReagentRegistry.aquasalusReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.magicales), new ReagentStack(ReagentRegistry.magicalesReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.aether), new ReagentStack(ReagentRegistry.aetherReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.crepitous), new ReagentStack(ReagentRegistry.crepitousReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.crystallos), new ReagentStack(ReagentRegistry.crystallosReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.terrae), new ReagentStack(ReagentRegistry.terraeReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.tennebrae), new ReagentStack(ReagentRegistry.tenebraeReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 0), new ReagentStack(ReagentRegistry.offensaReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 1), new ReagentStack(ReagentRegistry.praesidiumReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 2), new ReagentStack(ReagentRegistry.orbisTerraeReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 6), new ReagentStack(ReagentRegistry.virtusReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 7), new ReagentStack(ReagentRegistry.reductusReagent, 1000));
ReagentRegistry.registerItemAndReagent(new ItemStack(ModItems.baseAlchemyItems, 1, 8), new ReagentStack(ReagentRegistry.potentiaReagent, 1000));
OmegaRegistry.registerParadigm(ReagentRegistry.aquasalusReagent, new OmegaParadigmWater((OmegaArmour) ModItems.boundHelmetWater, (OmegaArmour) ModItems.boundPlateWater, (OmegaArmour) ModItems.boundLeggingsWater, (OmegaArmour) ModItems.boundBootsWater));
OmegaRegistry.registerParadigm(ReagentRegistry.terraeReagent, new OmegaParadigmEarth((OmegaArmour) ModItems.boundHelmetEarth, (OmegaArmour) ModItems.boundPlateEarth, (OmegaArmour) ModItems.boundLeggingsEarth, (OmegaArmour) ModItems.boundBootsEarth));
OmegaRegistry.registerParadigm(ReagentRegistry.aetherReagent, new OmegaParadigmWind((OmegaArmour) ModItems.boundHelmetWind, (OmegaArmour) ModItems.boundPlateWind, (OmegaArmour) ModItems.boundLeggingsWind, (OmegaArmour) ModItems.boundBootsWind));
OmegaRegistry.registerParadigm(ReagentRegistry.incendiumReagent, new OmegaParadigmFire((OmegaArmour) ModItems.boundHelmetFire, (OmegaArmour) ModItems.boundPlateFire, (OmegaArmour) ModItems.boundLeggingsFire, (OmegaArmour) ModItems.boundBootsFire));
}
use of WayofTime.alchemicalWizardry.common.items.armour.OmegaArmour in project BloodMagic by WayofTime.
the class RenderHelper method onTickInGame.
public static boolean onTickInGame(Minecraft mc) {
if (enabled && (mc.inGameHasFocus || mc.currentScreen == null || (mc.currentScreen instanceof GuiChat && showInChat)) && !mc.gameSettings.showDebugInfo) {
EntityPlayer player = mc.thePlayer;
player.getEntityData();
if (SpellHelper.canPlayerSeeAlchemy(player)) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
displayArmorStatus(mc);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
ItemStack stack = player.inventory.armorItemInSlot(2);
if (stack != null && stack.getItem() instanceof OmegaArmour) {
int maxAmount = (int) APISpellHelper.getPlayerMaxReagentAmount(player);
if (maxAmount > 0) {
float val = APISpellHelper.getPlayerCurrentReagentAmount(player);
ReagentStack reagentStack = new ReagentStack(APISpellHelper.getPlayerReagentType(player), (int) val);
if (reagentStack != null && reagentStack.amount > 0) {
renderTestHUD(mc, reagentStack, maxAmount);
}
}
}
if (SpellHelper.canPlayerSeeLPBar(player)) {
int max = APISpellHelper.getPlayerMaxLPTag(player);
if (max > 1) {
renderLPHUD(mc, APISpellHelper.getPlayerLPTag(player), max);
}
}
float maxHP = APISpellHelper.getCurrentAdditionalMaxHP(player);
// System.out.println("MaxHP: " + maxHP);
if (maxHP > 0) {
renderHPHUD(mc, APISpellHelper.getCurrentAdditionalHP(player), maxHP);
}
}
return true;
}
Aggregations