That's one heck of a commit you've got there...

I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
Electroblob77
2019-08-18 00:04:18 +01:00
parent 2680d02304
commit f37812be3e
1564 changed files with 47652 additions and 12984 deletions
@@ -1,30 +1,27 @@
package electroblob.wizardry.spell;
import electroblob.wizardry.WizardData;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.constants.Constants;
import electroblob.wizardry.constants.Element;
import electroblob.wizardry.constants.SpellType;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.data.WizardData;
import electroblob.wizardry.registry.WizardryEnchantments;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.*;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import java.util.Arrays;
public class ImbueWeapon extends Spell {
public ImbueWeapon(){
super("imbue_weapon", Tier.APPRENTICE, Element.SORCERY, SpellType.UTILITY, 20, 50, EnumAction.BOW, false);
super("imbue_weapon", EnumAction.BOW, false);
addProperties(EFFECT_DURATION);
}
@Override
@@ -35,29 +32,29 @@ public class ImbueWeapon extends Spell {
for(ItemStack stack : WizardryUtilities.getPrioritisedHotbarAndOffhand(caster)){
if(stack.getItem() instanceof ItemSword
if(isSword(stack.getItem())
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_sword)
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_sword) <= 0){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.magic_sword, modifiers.get(SpellModifiers.POTENCY) == 1.0f
? 1
: (int)((modifiers.get(SpellModifiers.POTENCY) - 1.0f) / Constants.DAMAGE_INCREASE_PER_TIER
: (int)((modifiers.get(SpellModifiers.POTENCY) - 1.0f) / Constants.POTENCY_INCREASE_PER_TIER
+ 0.5f));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_sword,
(int)(900 * modifiers.get(WizardryItems.duration_upgrade)));
(int)(getProperty(EFFECT_DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)));
}else if(stack.getItem() instanceof ItemBow
}else if(isBow(stack.getItem())
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.magic_bow)
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.magic_bow) <= 0){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.magic_bow, modifiers.get(SpellModifiers.POTENCY) == 1.0f
? 1
: (int)((modifiers.get(SpellModifiers.POTENCY) - 1.0f) / Constants.DAMAGE_INCREASE_PER_TIER
: (int)((modifiers.get(SpellModifiers.POTENCY) - 1.0f) / Constants.POTENCY_INCREASE_PER_TIER
+ 0.5f));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.magic_bow,
(int)(900 * modifiers.get(WizardryItems.duration_upgrade)));
(int)(getProperty(EFFECT_DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)));
}else{
continue;
@@ -72,11 +69,21 @@ public class ImbueWeapon extends Spell {
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1, 1);
this.playSound(world, caster, ticksInUse, -1, modifiers);
return true;
}
}
return false;
}
/** Returns true if the given item counts as a sword, i.e. it extends {@link ItemSword} or is in the whitelist. */
public static boolean isSword(Item item){
return item instanceof ItemSword || Arrays.asList(Wizardry.settings.swordItemWhitelist).contains(item.getRegistryName());
}
/** Returns true if the given item counts as a bow, i.e. it extends {@link ItemBow} or is in the whitelist. */
public static boolean isBow(Item item){
return item instanceof ItemBow || Arrays.asList(Wizardry.settings.bowItemWhitelist).contains(item.getRegistryName());
}
}