Add support for charge-up modifiers
This commit is contained in:
@@ -14,6 +14,7 @@ import electroblob.wizardry.item.ISpellCastingItem;
|
||||
import electroblob.wizardry.registry.Spells;
|
||||
import electroblob.wizardry.registry.WizardryPotions;
|
||||
import electroblob.wizardry.spell.Spell;
|
||||
import electroblob.wizardry.util.SpellModifiers;
|
||||
import electroblob.wizardry.util.WandHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -154,12 +155,19 @@ public class GuiSpellDisplay {
|
||||
|
||||
Spell spell = WandHelper.getCurrentSpell(wand);
|
||||
|
||||
if(spell.getChargeup() <= 0) return;
|
||||
int chargeup = spell.getChargeup();
|
||||
|
||||
if(WizardData.get(player) != null){
|
||||
// Pretty sure this is accessible client-side since it's only assigned from common code
|
||||
chargeup = (int)(chargeup * WizardData.get(player).itemCastingModifiers.get(SpellModifiers.CHARGEUP));
|
||||
}
|
||||
|
||||
if(chargeup <= 0) return;
|
||||
|
||||
// WHY WHY WHY are these methods named so misleadingly?! Sort yourselves out MCP!
|
||||
// (getItemInUseCount returns the max count MINUS the use count, and getItemInUseMaxCount returns the use count)
|
||||
if(player.getItemInUseMaxCount() == 0) return; // Not charging
|
||||
float charge = (player.getItemInUseMaxCount() + partialTicks) / spell.getChargeup();
|
||||
float charge = (player.getItemInUseMaxCount() + partialTicks) / chargeup;
|
||||
if(charge > 1) return; // Done charging
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(CHARGE_METER);
|
||||
|
||||
@@ -355,8 +355,10 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
|
||||
SpellModifiers modifiers = this.calculateModifiers(stack, player, spell);
|
||||
|
||||
if(canCast(stack, spell, player, hand, 0, modifiers)){
|
||||
// Need to account for the modifier since it could be zero even if the original charge-up wasn't
|
||||
int chargeup = (int)(spell.getChargeup() * modifiers.get(SpellModifiers.CHARGEUP));
|
||||
|
||||
if(spell.isContinuous || spell.getChargeup() > 0){
|
||||
if(spell.isContinuous || chargeup > 0){
|
||||
// Spells that need the mouse to be held (continuous, charge-up or both)
|
||||
if(!player.isHandActive()){
|
||||
player.setActiveHand(hand);
|
||||
@@ -395,12 +397,13 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
|
||||
}
|
||||
|
||||
int useTick = stack.getMaxItemUseDuration() - count;
|
||||
int chargeup = (int)(spell.getChargeup() * modifiers.get(SpellModifiers.CHARGEUP));
|
||||
|
||||
if(spell.isContinuous){
|
||||
// Continuous spell charge-up is simple, just don't do anything until it's charged
|
||||
if(useTick >= spell.getChargeup()){
|
||||
if(useTick >= chargeup){
|
||||
// castingTick needs to be relative to when the spell actually started
|
||||
int castingTick = useTick - spell.getChargeup();
|
||||
int castingTick = useTick - chargeup;
|
||||
// Continuous spells (these must check if they can be cast each tick since the mana changes)
|
||||
// Don't call canCast when castingTick == 0 because we already did it in onItemRightClick - even
|
||||
// with charge-up times, because we don't want to trigger events twice
|
||||
@@ -413,7 +416,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
|
||||
}
|
||||
}else{
|
||||
// Non-continuous spells need to check they actually have a charge-up since ALL spells call setActiveHand
|
||||
if(spell.getChargeup() > 0 && useTick == spell.getChargeup()){
|
||||
if(chargeup > 0 && useTick == chargeup){
|
||||
// Once the spell is charged, it's exactly the same as in onItemRightClick
|
||||
cast(stack, spell, player, player.getActiveHand(), 0, modifiers);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ public final class SpellModifiers {
|
||||
public static final String POTENCY = "potency";
|
||||
/** Constant string identifier for the mana cost modifier. */
|
||||
public static final String COST = "cost";
|
||||
/** Constant string identifier for the wand charge-up modifier. */
|
||||
public static final String CHARGEUP = "chargeup";
|
||||
/** Constant string identifier for the wand progression modifier. */
|
||||
public static final String PROGRESSION = "progression";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user