Split up and reorganise WizardryUtilities

This commit is contained in:
Electroblob77
2020-06-13 23:29:01 +01:00
parent 57e96458d5
commit 238b9d04bb
189 changed files with 1724 additions and 1731 deletions
@@ -2,6 +2,7 @@ package electroblob.wizardry.item;
import electroblob.wizardry.data.WizardData;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
@@ -18,7 +19,7 @@ import javax.annotation.Nonnull;
* this interface if appropriate.</i>
* <p></p>
* This interface is used for the following:<br>
* - General-purpose detection of continuous spell casting (see {@link electroblob.wizardry.util.WizardryUtilities#isCasting(EntityLivingBase, Spell)})<br>
* - General-purpose detection of continuous spell casting (see {@link EntityUtils#isCasting(EntityLivingBase, Spell)})<br>
* - Display of the arcane workbench tooltip (in conjunction with {@link IManaStoringItem})<br>
* - Spell HUD visibility<br>
* - Spell switching controls (they won't do anything unless the player is holding an {@code ISpellCastingItem})<br>
@@ -179,7 +179,7 @@ public class ItemArtefact extends Item {
}else{
// To find out if the given artefact is one of the first n on the player's hotbar (where n is the maximum
// number of that kind of artefact that can be active at once):
return WizardryUtilities.getPrioritisedHotbarAndOffhand(player).stream() // Retrieve the stacks in question
return InventoryUtils.getPrioritisedHotbarAndOffhand(player).stream() // Retrieve the stacks in question
// Filter out all except artefacts of the same type as the given one (preserving order)
.filter(s -> s.getItem() instanceof ItemArtefact && ((ItemArtefact)s.getItem()).type == ((ItemArtefact)artefact).type)
.limit(((ItemArtefact)artefact).type.maxAtOnce) // Ignore all but the first n
@@ -213,7 +213,7 @@ public class ItemArtefact extends Item {
List<ItemArtefact> artefacts = new ArrayList<>();
for(Type type : types){
artefacts.addAll(WizardryUtilities.getPrioritisedHotbarAndOffhand(player).stream()
artefacts.addAll(InventoryUtils.getPrioritisedHotbarAndOffhand(player).stream()
.filter(s -> s.getItem() instanceof ItemArtefact)
.map(s -> (ItemArtefact)s.getItem())
.filter(i -> type == i.type && i.enabled)
@@ -237,7 +237,7 @@ public class ItemArtefact extends Item {
*/
public static boolean findMatchingWandAndExecute(EntityPlayer player, Spell spell, Consumer<? super ItemStack> action){
List<ItemStack> hotbar = WizardryUtilities.getPrioritisedHotbarAndOffhand(player);
List<ItemStack> hotbar = InventoryUtils.getPrioritisedHotbarAndOffhand(player);
Optional<ItemStack> stack = hotbar.stream().filter(s -> s.getItem() instanceof ISpellCastingItem
&& Arrays.asList(((ISpellCastingItem)s.getItem()).getSpells(s)).contains(spell)).findFirst();
@@ -281,7 +281,7 @@ public class ItemArtefact extends Item {
if(artefact == WizardryItems.ring_condensing){
if(player.ticksExisted % 150 == 0){
for(ItemStack stack : WizardryUtilities.getHotbar(player)){
for(ItemStack stack : InventoryUtils.getHotbar(player)){
// Needs to be both of these interfaces because this ring only recharges wands
// (or more accurately, chargeable spellcasting items)
if(stack.getItem() instanceof ISpellCastingItem && stack.getItem() instanceof IManaStoringItem)
@@ -342,7 +342,7 @@ public class ItemArtefact extends Item {
findMatchingWandAndExecute(player, Spells.shield, wand -> {
List<Entity> projectiles = WizardryUtilities.getEntitiesWithinRadius(5, player.posX, player.posY, player.posZ, world, Entity.class);
List<Entity> projectiles = EntityUtils.getEntitiesWithinRadius(5, player.posX, player.posY, player.posZ, world, Entity.class);
projectiles.removeIf(e -> !(e instanceof IProjectile));
Vec3d look = player.getLookVec();
Vec3d playerPos = player.getPositionVector().add(0, player.height/2, 0);
@@ -480,7 +480,7 @@ public class ItemArtefact extends Item {
// Spell properties allow all three of the above spells to be dealt with the same way - neat!
float healthGained = event.getSpell().getProperty(Spell.HEALTH).floatValue() * event.getModifiers().get(SpellModifiers.POTENCY);
List<EntityLivingBase> nearby = WizardryUtilities.getEntitiesWithinRadius(4, player.posX, player.posY, player.posZ, event.getWorld());
List<EntityLivingBase> nearby = EntityUtils.getEntitiesWithinRadius(4, player.posX, player.posY, player.posZ, event.getWorld());
for(EntityLivingBase entity : nearby){
if(AllyDesignationSystem.isAllied(player, entity) && entity.getHealth() > 0 && entity.getHealth() < entity.getMaxHealth()){
@@ -505,13 +505,13 @@ public class ItemArtefact extends Item {
if(entityNBT.hasUniqueId(MindControl.NBT_KEY)){
Entity caster = WizardryUtilities.getEntityByUUID(entity.world, entityNBT.getUniqueId(MindControl.NBT_KEY));
Entity caster = EntityUtils.getEntityByUUID(entity.world, entityNBT.getUniqueId(MindControl.NBT_KEY));
if(caster instanceof EntityPlayer){
if(isArtefactActive((EntityPlayer)caster, WizardryItems.ring_mind_control)){
WizardryUtilities.getEntitiesWithinRadius(3, entity.posX, entity.posY, entity.posZ, entity.world, EntityLiving.class).stream()
EntityUtils.getEntitiesWithinRadius(3, entity.posX, entity.posY, entity.posZ, entity.world, EntityLiving.class).stream()
.filter(e -> e.world.rand.nextInt(10) == 0)
.filter(MindControl::canControl)
.filter(e -> AllyDesignationSystem.isValidTarget(caster, e))
@@ -573,7 +573,7 @@ public class ItemArtefact extends Item {
}else if(artefact == WizardryItems.amulet_potential){
if(player.world.rand.nextFloat() < 0.2f && WizardryUtilities.isMeleeDamage(event.getSource())
if(player.world.rand.nextFloat() < 0.2f && EntityUtils.isMeleeDamage(event.getSource())
&& event.getSource().getTrueSource() instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase)event.getSource().getTrueSource();
@@ -597,7 +597,7 @@ public class ItemArtefact extends Item {
if(!event.getSource().isUnblockable() && player.world.rand.nextFloat() < 0.15f){
List<EntityLiving> nearbyMobs = WizardryUtilities.getEntitiesWithinRadius(5, player.posX, player.posY, player.posZ, player.world, EntityLiving.class);
List<EntityLiving> nearbyMobs = EntityUtils.getEntitiesWithinRadius(5, player.posX, player.posY, player.posZ, player.world, EntityLiving.class);
nearbyMobs.removeIf(e -> !(e instanceof ISummonedCreature && ((ISummonedCreature)e).getCaster() == player));
if(!nearbyMobs.isEmpty()){
@@ -611,7 +611,7 @@ public class ItemArtefact extends Item {
}else if(artefact == WizardryItems.amulet_banishing){
if(player.world.rand.nextFloat() < 0.2f && WizardryUtilities.isMeleeDamage(event.getSource())
if(player.world.rand.nextFloat() < 0.2f && EntityUtils.isMeleeDamage(event.getSource())
&& event.getSource().getTrueSource() instanceof EntityLivingBase){
EntityLivingBase target = (EntityLivingBase)event.getSource().getTrueSource();
@@ -639,25 +639,25 @@ public class ItemArtefact extends Item {
if(artefact == WizardryItems.ring_fire_melee){
// Used ItemWand intentionally because we need the element
// Other mods can always make their own events if they want their own spellcasting items to do this
if(WizardryUtilities.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
if(EntityUtils.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
&& ((ItemWand)mainhandItem.getItem()).element == Element.FIRE){
event.getEntity().setFire(5);
}
}else if(artefact == WizardryItems.ring_ice_melee){
if(WizardryUtilities.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
if(EntityUtils.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
&& ((ItemWand)mainhandItem.getItem()).element == Element.ICE){
event.getEntityLiving().addPotionEffect(new PotionEffect(WizardryPotions.frost, 200, 0));
}
}else if(artefact == WizardryItems.ring_lightning_melee){
if(WizardryUtilities.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
if(EntityUtils.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
&& ((ItemWand)mainhandItem.getItem()).element == Element.LIGHTNING){
WizardryUtilities.getEntitiesWithinRadius(3, player.posX, player.posY, player.posZ, world).stream()
.filter(WizardryUtilities::isLiving)
EntityUtils.getEntitiesWithinRadius(3, player.posX, player.posY, player.posZ, world).stream()
.filter(EntityUtils::isLiving)
.filter(e -> e != player)
.min(Comparator.comparingDouble(player::getDistanceSq))
.ifPresent(target -> {
@@ -679,14 +679,14 @@ public class ItemArtefact extends Item {
}else if(artefact == WizardryItems.ring_necromancy_melee){
if(WizardryUtilities.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
if(EntityUtils.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
&& ((ItemWand)mainhandItem.getItem()).element == Element.NECROMANCY){
event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.WITHER, 200, 0));
}
}else if(artefact == WizardryItems.ring_earth_melee){
if(WizardryUtilities.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
if(EntityUtils.isMeleeDamage(event.getSource()) && mainhandItem.getItem() instanceof ItemWand
&& ((ItemWand)mainhandItem.getItem()).element == Element.EARTH){
event.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.POISON, 200, 0));
}
@@ -696,7 +696,7 @@ public class ItemArtefact extends Item {
if(!player.world.isRemote && player.world.rand.nextFloat() < 0.15f
&& event.getEntityLiving().getHealth() < 12f // Otherwise it's a bit overpowered!
&& event.getEntityLiving().isPotionActive(WizardryPotions.frost)
&& WizardryUtilities.isMeleeDamage(event.getSource())){
&& EntityUtils.isMeleeDamage(event.getSource())){
event.setAmount(12f);
@@ -722,7 +722,7 @@ public class ItemArtefact extends Item {
if((event.getSource() instanceof IElementalDamage
&& (((IElementalDamage)event.getSource()).getType() == MagicDamage.DamageType.WITHER))
// or it's direct, non-melee damage and the player is holding a wand with a necromancy spell selected
|| (event.getSource().getImmediateSource() == player && !WizardryUtilities.isMeleeDamage(event.getSource())
|| (event.getSource().getImmediateSource() == player && !EntityUtils.isMeleeDamage(event.getSource())
&& Streams.stream(player.getHeldEquipment()).anyMatch(s -> s.getItem() instanceof ISpellCastingItem
&& ((ISpellCastingItem)s.getItem()).getCurrentSpell(s).getElement() == Element.NECROMANCY))){
@@ -735,7 +735,7 @@ public class ItemArtefact extends Item {
if(player.world.rand.nextFloat() < 0.3f && ((event.getSource() instanceof IElementalDamage
&& (((IElementalDamage)event.getSource()).getType() == MagicDamage.DamageType.WITHER))
// ...or it's direct, non-melee damage and the player is holding a wand with a necromancy spell selected
|| (event.getSource().getImmediateSource() == player && !WizardryUtilities.isMeleeDamage(event.getSource())
|| (event.getSource().getImmediateSource() == player && !EntityUtils.isMeleeDamage(event.getSource())
&& Streams.stream(player.getHeldEquipment()).anyMatch(s -> s.getItem() instanceof ISpellCastingItem
&& ((ISpellCastingItem)s.getItem()).getCurrentSpell(s).getElement() == Element.NECROMANCY
&& ((ISpellCastingItem)s.getItem()).getCurrentSpell(s) != Spells.life_drain)))){
@@ -753,7 +753,7 @@ public class ItemArtefact extends Item {
// ...or it was from a dart...
|| event.getSource().getImmediateSource() instanceof EntityDart
// ...or it's direct, non-melee damage and the player is holding a wand with an earth spell selected
|| (event.getSource().getImmediateSource() == player && !WizardryUtilities.isMeleeDamage(event.getSource())
|| (event.getSource().getImmediateSource() == player && !EntityUtils.isMeleeDamage(event.getSource())
&& Streams.stream(player.getHeldEquipment()).anyMatch(s -> s.getItem() instanceof ISpellCastingItem
&& ((ISpellCastingItem)s.getItem()).getCurrentSpell(s).getElement() == Element.EARTH))){
@@ -768,11 +768,11 @@ public class ItemArtefact extends Item {
// ...or it was from a force orb...
|| event.getSource().getImmediateSource() instanceof EntityForceOrb
// ...or it's direct, non-melee damage and the player is holding a wand with a sorcery spell selected
|| (event.getSource().getImmediateSource() == player && !WizardryUtilities.isMeleeDamage(event.getSource())
|| (event.getSource().getImmediateSource() == player && !EntityUtils.isMeleeDamage(event.getSource())
&& Streams.stream(player.getHeldEquipment()).anyMatch(s -> s.getItem() instanceof ISpellCastingItem
&& ((ISpellCastingItem)s.getItem()).getCurrentSpell(s).getElement() == Element.SORCERY))){
WizardryUtilities.getPrioritisedHotbarAndOffhand(player).stream()
InventoryUtils.getPrioritisedHotbarAndOffhand(player).stream()
.filter(s -> s.getItem() instanceof ISpellCastingItem && s.getItem() instanceof IManaStoringItem
&& !((IManaStoringItem)s.getItem()).isManaFull(s))
.findFirst()
@@ -845,7 +845,7 @@ public class ItemArtefact extends Item {
.findFirst().orElse(null);
if(item == null) return; // The player didn't have a wand with resurrection on it
if(!WizardryUtilities.getHotbar(event.getEntityPlayer()).contains(ItemStack.EMPTY)) return; // No space on hotbar
if(!InventoryUtils.getHotbar(event.getEntityPlayer()).contains(ItemStack.EMPTY)) return; // No space on hotbar
event.getDrops().remove(item);
// At this point the player probably has nothing in their hand, but if not just find a free space somewhere
@@ -3,9 +3,9 @@ package electroblob.wizardry.item;
import com.google.common.collect.Multimap;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.MagicDamage;
import electroblob.wizardry.util.MagicDamage.DamageType;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
@@ -39,7 +39,7 @@ public class ItemFlamingAxe extends ItemAxe implements IConjuredItem {
if(slot == EntityEquipmentSlot.MAINHAND){
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(POTENCY_MODIFIER,
"Potency modifier", IConjuredItem.getDamageMultiplier(stack) - 1, WizardryUtilities.Operations.MULTIPLY_CUMULATIVE));
"Potency modifier", IConjuredItem.getDamageMultiplier(stack) - 1, EntityUtils.Operations.MULTIPLY_CUMULATIVE));
}
return multimap;
@@ -4,9 +4,9 @@ import com.google.common.collect.Multimap;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.registry.WizardryPotions;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.MagicDamage;
import electroblob.wizardry.util.MagicDamage.DamageType;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
@@ -41,7 +41,7 @@ public class ItemFrostAxe extends ItemAxe implements IConjuredItem {
if(slot == EntityEquipmentSlot.MAINHAND){
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(POTENCY_MODIFIER,
"Potency modifier", IConjuredItem.getDamageMultiplier(stack) - 1, WizardryUtilities.Operations.MULTIPLY_CUMULATIVE));
"Potency modifier", IConjuredItem.getDamageMultiplier(stack) - 1, EntityUtils.Operations.MULTIPLY_CUMULATIVE));
}
return multimap;
@@ -6,7 +6,7 @@ import electroblob.wizardry.event.DiscoverSpellEvent;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.registry.WizardryTabs;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.WizardryUtilities;
import electroblob.wizardry.util.InventoryUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
@@ -56,7 +56,7 @@ public class ItemIdentificationScroll extends Item {
WizardData data = WizardData.get(player);
for(ItemStack stack1 : WizardryUtilities.getPrioritisedHotbarAndOffhand(player)){
for(ItemStack stack1 : InventoryUtils.getPrioritisedHotbarAndOffhand(player)){
if(!stack1.isEmpty()){
Spell spell = Spell.byMetadata(stack1.getItemDamage());
@@ -6,11 +6,11 @@ import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.spell.LightningHammer;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.MagicDamage;
import electroblob.wizardry.util.MagicDamage.DamageType;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
@@ -83,9 +83,9 @@ public class ItemLightningHammer extends Item implements IConjuredItem {
if(slot == EntityEquipmentSlot.MAINHAND){
float attackDamage = Spells.lightning_hammer.arePropertiesInitialised() ?
Spells.lightning_hammer.getProperty(Spell.DIRECT_DAMAGE).floatValue() : 10; // Fallback for search tree init, value doesn't really matter
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", attackDamage, WizardryUtilities.Operations.ADD));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", ATTACK_SPEED, WizardryUtilities.Operations.ADD));
multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(MOVEMENT_SPEED_MODIFIER, "Weapon modifier", MOVEMENT_SPEED_REDUCTION, WizardryUtilities.Operations.MULTIPLY_FLAT));
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", attackDamage, EntityUtils.Operations.ADD));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", ATTACK_SPEED, EntityUtils.Operations.ADD));
multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(MOVEMENT_SPEED_MODIFIER, "Weapon modifier", MOVEMENT_SPEED_REDUCTION, EntityUtils.Operations.MULTIPLY_FLAT));
}
return multimap;
@@ -135,7 +135,7 @@ public class ItemLightningHammer extends Item implements IConjuredItem {
world.spawnEntity(hammer);
}
WizardryUtilities.playSoundAtPlayer(player, WizardrySounds.ENTITY_HAMMER_THROW, 1.0F, 0.8f);
EntityUtils.playSoundAtPlayer(player, WizardrySounds.ENTITY_HAMMER_THROW, 1.0F, 0.8f);
//player.swingArm(hand);
@@ -195,7 +195,7 @@ public class ItemLightningHammer extends Item implements IConjuredItem {
if(attackStrength == 1){ // Only chains when the attack meter is full
List<EntityLivingBase> nearby = WizardryUtilities.getEntitiesWithinRadius(CHAINING_RANGE, hit.posX, hit.posY, hit.posZ, hit.world);
List<EntityLivingBase> nearby = EntityUtils.getEntitiesWithinRadius(CHAINING_RANGE, hit.posX, hit.posY, hit.posZ, hit.world);
nearby.remove(hit);
nearby.remove(wielder);
@@ -3,7 +3,8 @@ package electroblob.wizardry.item;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.registry.WizardrySounds;
import electroblob.wizardry.registry.WizardryTabs;
import electroblob.wizardry.util.WizardryUtilities;
import electroblob.wizardry.util.EntityUtils;
import electroblob.wizardry.util.InventoryUtils;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
@@ -61,7 +62,7 @@ public class ItemManaFlask extends Item {
ItemStack flask = player.getHeldItem(hand);
List<ItemStack> stacks = WizardryUtilities.getPrioritisedHotbarAndOffhand(player);
List<ItemStack> stacks = InventoryUtils.getPrioritisedHotbarAndOffhand(player);
stacks.addAll(player.inventory.armorInventory); // player#getArmorInventoryList() only returns an Iterable
// Find the chargeable item with the least mana
@@ -73,8 +74,8 @@ public class ItemManaFlask extends Item {
((IManaStoringItem)toCharge.getItem()).rechargeMana(toCharge, size.capacity);
WizardryUtilities.playSoundAtPlayer(player, WizardrySounds.ITEM_MANA_FLASK_USE, 1, 1);
WizardryUtilities.playSoundAtPlayer(player, WizardrySounds.ITEM_MANA_FLASK_RECHARGE, 0.7f, 1.1f);
EntityUtils.playSoundAtPlayer(player, WizardrySounds.ITEM_MANA_FLASK_USE, 1, 1);
EntityUtils.playSoundAtPlayer(player, WizardrySounds.ITEM_MANA_FLASK_RECHARGE, 0.7f, 1.1f);
if(!player.isCreative()) flask.shrink(1);
player.getCooldownTracker().setCooldown(this, 20);
@@ -2,7 +2,7 @@ package electroblob.wizardry.item;
import com.google.common.collect.Multimap;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.util.WizardryUtilities;
import electroblob.wizardry.util.EntityUtils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
@@ -35,7 +35,7 @@ public class ItemSpectralSword extends ItemSword implements IConjuredItem {
if(slot == EntityEquipmentSlot.MAINHAND){
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(POTENCY_MODIFIER,
"Potency modifier", IConjuredItem.getDamageMultiplier(stack) - 1, WizardryUtilities.Operations.MULTIPLY_CUMULATIVE));
"Potency modifier", IConjuredItem.getDamageMultiplier(stack) - 1, EntityUtils.Operations.MULTIPLY_CUMULATIVE));
}
return multimap;
@@ -632,7 +632,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
RayTraceResult rayTrace = RayTracer.standardEntityRayTrace(world, player, 16, false);
if(rayTrace != null && WizardryUtilities.isLiving(rayTrace.entityHit)){
if(rayTrace != null && EntityUtils.isLiving(rayTrace.entityHit)){
EntityLivingBase entity = (EntityLivingBase)rayTrace.entityHit;
@@ -12,8 +12,8 @@ import electroblob.wizardry.registry.WizardryAdvancementTriggers;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.registry.WizardryRecipes;
import electroblob.wizardry.registry.WizardryTabs;
import electroblob.wizardry.util.InventoryUtils;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentMending;
import net.minecraft.entity.Entity;
@@ -271,13 +271,13 @@ public class ItemWizardArmour extends ItemArmor implements IWorkbenchItem, IMana
if(event.getCaster() == null) return;
int armourPieces = getMatchingArmourCount(event.getCaster(), event.getSpell().getElement());
float multiplier = 1f - armourPieces * Constants.COST_REDUCTION_PER_ARMOUR;
if(armourPieces == WizardryUtilities.ARMOUR_SLOTS.length) multiplier -= Constants.FULL_ARMOUR_SET_BONUS;
if(armourPieces == InventoryUtils.ARMOUR_SLOTS.length) multiplier -= Constants.FULL_ARMOUR_SET_BONUS;
event.getModifiers().set(SpellModifiers.COST, event.getModifiers().get(SpellModifiers.COST) * multiplier, false);
}
/** Counts the number of armour pieces the given entity is wearing that match the given element. */
public static int getMatchingArmourCount(EntityLivingBase entity, Element element){
return (int)Arrays.stream(WizardryUtilities.ARMOUR_SLOTS)
return (int)Arrays.stream(InventoryUtils.ARMOUR_SLOTS)
.map(s -> entity.getItemStackFromSlot(s).getItem())
.filter(i -> i instanceof ItemWizardArmour && ((ItemWizardArmour)i).element == element)
.count();