Merge pull request #1 from OneEyeMaker/RunesOverride

Added config options for amounts of life essence per sacrifice.
This commit is contained in:
Martin authored and GitHub committed 2016-06-17 18:04:44 +02:00
commit 80d0188212
7 files changed
+124 -74

No files matched your search

@@ -7,6 +7,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -307,6 +308,14 @@ public class AlchemicalWizardry
public static BlockStack[] sixthTierRunes = new BlockStack[10];
public static BlockStack[] specialAltarBlock = new BlockStack[7];
public static int lpPerSelfSacrifice = 200;
public static int lpPerSelfSacrificeSoulFray = 20;
public static int lpPerSelfSacrificeFeatheredKnife = 100;
public static int lpPerSacrificeBase = 500;
public static int lpPerSacrificeWellOfSuffering = 10;
public static double lpPerSacrificeIncense = 100.0D;
public static HashMap<Class<?>, Integer> lpPerSactificeCustom;
public static List<Class> wellBlacklist;
public static Logger logger = LogManager.getLogger("BloodMagic");
@@ -1140,6 +1149,7 @@ public class AlchemicalWizardry
BloodMagicConfiguration.loadBlacklist();
BloodMagicConfiguration.blacklistRituals();
BloodMagicConfiguration.loadCustomLPValues();
DemonVillageLootRegistry.init();
@@ -3,6 +3,7 @@ package WayofTime.alchemicalWizardry;
import java.io.File;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
@@ -21,11 +22,17 @@ import cpw.mods.fml.relauncher.Side;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.oredict.OreDictionary;
import static net.minecraft.entity.EntityList.stringToClassMapping;
/**
* Created with IntelliJ IDEA.
* User: Pokefenn
@@ -275,6 +282,13 @@ public class BloodMagicConfiguration
AlchemicalWizardry.ritualWeakCostThunderstorm = config.get(lpCosts, "[Weak Ritual] Thunderstorm", 5000).getInt();
AlchemicalWizardry.ritualWeakCostZombie = config.get(lpCosts, "[Weak Ritual] Zombie", 5000).getInt();
AlchemicalWizardry.lpPerSelfSacrifice = config.get("sacrifice", "LP per self-sacrifice", AlchemicalWizardry.lpPerSelfSacrifice).getInt(AlchemicalWizardry.lpPerSelfSacrifice);
AlchemicalWizardry.lpPerSelfSacrificeSoulFray = config.get("sacrifice", "LP per self-sacrifice (when Soul Fray potion is active)", AlchemicalWizardry.lpPerSelfSacrificeSoulFray).getInt(AlchemicalWizardry.lpPerSelfSacrificeSoulFray);
AlchemicalWizardry.lpPerSelfSacrificeFeatheredKnife = config.get("sacrifice", "LP per self-sacrifice with Ritual of Feathered Knife", AlchemicalWizardry.lpPerSelfSacrificeFeatheredKnife).getInt(AlchemicalWizardry.lpPerSelfSacrificeFeatheredKnife);
AlchemicalWizardry.lpPerSacrificeBase = config.get("sacrifice", "LP per sacrifice", AlchemicalWizardry.lpPerSacrificeBase).getInt(AlchemicalWizardry.lpPerSacrificeBase);
AlchemicalWizardry.lpPerSacrificeWellOfSuffering = config.get("sacrifice", "LP per sacrifice with Well of Suffering ritual", AlchemicalWizardry.lpPerSacrificeWellOfSuffering).getInt(AlchemicalWizardry.lpPerSacrificeWellOfSuffering);
AlchemicalWizardry.lpPerSacrificeIncense = config.get("sacrifice", "LP per (self-)sacrifice with incense", AlchemicalWizardry.lpPerSacrificeIncense).getDouble(AlchemicalWizardry.lpPerSacrificeIncense);
Side side = FMLCommonHandler.instance().getSide();
if (side == Side.CLIENT)
{
@@ -361,6 +375,39 @@ public class BloodMagicConfiguration
});
config.save();
}
public static void loadCustomLPValues()
{
AlchemicalWizardry.lpPerSactificeCustom = new HashMap<Class<?>, Integer>();
for (Object object : EntityList.stringToClassMapping.entrySet())
{
Entry entry = (Entry)object;
String entityName = (String) entry.getKey();
Class entityClass = (Class) entry.getValue();
if (EntityLivingBase.class.isAssignableFrom(entityClass) && !Modifier.isAbstract(entityClass.getModifiers()))
{
int lpAmount = 500;
if (EntityVillager.class.isAssignableFrom(entityClass))
{
lpAmount = 2000;
}
if (EntitySlime.class.isAssignableFrom(entityClass))
{
lpAmount = 150;
}
if (EntityEnderman.class.isAssignableFrom(entityClass))
{
lpAmount = 200;
}
if (EntityAnimal.class.isAssignableFrom(entityClass))
{
lpAmount = 250;
}
lpAmount = config.get("sacrifice.custom values", entityName, lpAmount).getInt(lpAmount);
AlchemicalWizardry.lpPerSactificeCustom.put(entityClass, lpAmount);
}
}
config.save();
}
public static void set(String categoryName, String propertyName, String newValue)
{
@@ -378,7 +425,7 @@ public class BloodMagicConfiguration
public static void loadBlacklist()
{
AlchemicalWizardry.wellBlacklist = new ArrayList<Class>();
for (Object o : EntityList.stringToClassMapping.entrySet())
for (Object o : stringToClassMapping.entrySet())
{
Entry entry = (Entry) o;
Class curClass = (Class) entry.getValue();
@@ -1,5 +1,6 @@
package WayofTime.alchemicalWizardry.api.sacrifice;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
@@ -8,7 +9,7 @@ import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
public class PlayerSacrificeHandler
public class PlayerSacrificeHandler
{
public static float scalingOfSacrifice = 0.001f;
public static int soulFrayDuration = 400;
@@ -17,12 +18,12 @@ public class PlayerSacrificeHandler
{
return APISpellHelper.getCurrentIncense(player);
}
public static void setPlayerIncense(EntityPlayer player, float amount)
{
APISpellHelper.setCurrentIncense(player, amount);
}
public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment)
{
float amount = getPlayerIncense(player);
@@ -30,52 +31,52 @@ public class PlayerSacrificeHandler
{
return false;
}
amount = amount + Math.min(increment, max - amount);
setPlayerIncense(player, amount);
// System.out.println("Amount of incense: " + amount + ", Increment: " + increment);
return true;
}
public static boolean sacrificePlayerHealth(EntityPlayer player)
{
if(player.isPotionActive(soulFrayId))
{
return false;
}
float amount = getPlayerIncense(player);
if(amount >= 0)
{
float health = player.getHealth();
float maxHealth = player.getMaxHealth();
if(health > maxHealth/10.0)
{
float sacrificedHealth = health - maxHealth/10.0f;
if(findAndFillAltar(player.getEntityWorld(), player, (int)(sacrificedHealth * 100f * getModifier(amount))))
if(findAndFillAltar(player.getEntityWorld(), player, (int)(sacrificedHealth * AlchemicalWizardry.lpPerSacrificeIncense * getModifier(amount))))
{
player.setHealth(maxHealth/10.0f);
setPlayerIncense(player, 0);
player.addPotionEffect(new PotionEffect(soulFrayId.id, soulFrayDuration));
return true;
}
}
}
return false;
}
public static float getModifier(float amount)
{
return 1 + amount*scalingOfSacrifice;
}
public static boolean findAndFillAltar(World world, EntityPlayer player, int amount)
{
int posX = (int) Math.round(player.posX - 0.5f);
@@ -90,7 +91,7 @@ public class PlayerSacrificeHandler
altarEntity.sacrificialDaggerCall(amount, false);
altarEntity.startCycle();
return true;
}
@@ -105,7 +106,7 @@ public class PlayerSacrificeHandler
for (int k = -2; k <= 1; k++)
{
tileEntity = world.getTileEntity(i + x, k + y, j + z);
if(tileEntity instanceof IBloodAltar)
{
return (IBloodAltar)tileEntity;
@@ -2,6 +2,14 @@ package WayofTime.alchemicalWizardry.common.items;
import java.util.List;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
import WayofTime.alchemicalWizardry.common.IDemon;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import com.google.common.collect.Multimap;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -9,10 +17,6 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -20,16 +24,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.IDemon;
import WayofTime.alchemicalWizardry.common.demonVillage.demonHoard.demon.IHoardDemon;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
import com.google.common.collect.Multimap;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class DaggerOfSacrifice extends EnergyItems
{
@@ -57,7 +51,7 @@ public class DaggerOfSacrifice extends EnergyItems
{
return false;
}
if(par2EntityLivingBase instanceof IHoardDemon)
{
return false;
@@ -81,11 +75,9 @@ public class DaggerOfSacrifice extends EnergyItems
this.findAndNotifyAltarOfDemon(world, par2EntityLivingBase);
}
int lifeEssence = 500;
if (par2EntityLivingBase instanceof EntityVillager) lifeEssence = 2000;
else if (par2EntityLivingBase instanceof EntitySlime) lifeEssence = 150;
else if (par2EntityLivingBase instanceof EntityEnderman) lifeEssence = 200;
else if (par2EntityLivingBase instanceof EntityAnimal) lifeEssence = 250;
int lifeEssence = AlchemicalWizardry.lpPerSactificeCustom.containsKey(par2EntityLivingBase.getClass()) ?
AlchemicalWizardry.lpPerSactificeCustom.get(par2EntityLivingBase.getClass()) :
AlchemicalWizardry.lpPerSacrificeBase;
if (findAndFillAltar(par2EntityLivingBase.worldObj, par2EntityLivingBase, lifeEssence))
{
@@ -157,10 +149,10 @@ public class DaggerOfSacrifice extends EnergyItems
}
altarEntity.addToDemonBloodDuration(50);
return true;
}
public boolean findAndFillAltar(World world, EntityLivingBase sacrifice, int amount)
{
int posX = (int) Math.round(sacrifice.posX - 0.5f);
@@ -58,7 +58,7 @@ public class SacrificialDagger extends Item
par3List.add(StatCollector.translateToLocal("tooltip.sacrificialdagger.desc3"));
}
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
@@ -72,13 +72,13 @@ public class SacrificialDagger extends Item
PlayerSacrificeHandler.sacrificePlayerHealth(player);
}
@Override
public int getMaxItemUseDuration(ItemStack stack)
{
return 72000;
}
/**
* returns the action that specifies what animation to play when the items is being used
*/
@@ -96,7 +96,7 @@ public class SacrificialDagger extends Item
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
return stack;
}
if (!player.capabilities.isCreativeMode)
{
SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2);
@@ -104,12 +104,12 @@ public class SacrificialDagger extends Item
{
return stack;
}
if(evt.shouldDrainHealth)
{
player.setHealth(player.getHealth() - 2);
}
if(!evt.shouldFillAltar)
{
return stack;
@@ -142,10 +142,10 @@ public class SacrificialDagger extends Item
if (player.isPotionActive(AlchemicalWizardry.customPotionSoulFray))
{
findAndFillAltar(world, player, 20);
findAndFillAltar(world, player, AlchemicalWizardry.lpPerSelfSacrificeSoulFray);
} else
{
findAndFillAltar(world, player, 200);
findAndFillAltar(world, player, AlchemicalWizardry.lpPerSelfSacrifice);
}
if (player.getHealth() <= 0.001f)
@@ -183,7 +183,7 @@ public class SacrificialDagger extends Item
for (int k = -2; k <= 1; k++)
{
tileEntity = world.getTileEntity(i + x, k + y, j + z);
if(tileEntity instanceof IBloodAltar)
{
return (IBloodAltar)tileEntity;
@@ -194,7 +194,7 @@ public class SacrificialDagger extends Item
return null;
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5)
{
@@ -203,7 +203,7 @@ public class SacrificialDagger extends Item
this.setUseForSacrifice(stack, this.isPlayerPreparedForSacrifice(world, (EntityPlayer)entity));
}
}
@Override
public String getItemStackDisplayName(ItemStack stack)
{
@@ -213,19 +213,19 @@ public class SacrificialDagger extends Item
}
return super.getItemStackDisplayName(stack);
}
public boolean isPlayerPreparedForSacrifice(World world, EntityPlayer player)
{
return !world.isRemote && (PlayerSacrificeHandler.getPlayerIncense(player) > 0);
}
public boolean canUseForSacrifice(ItemStack stack)
{
NBTTagCompound tag = stack.getTagCompound();
return tag != null && tag.getBoolean("sacrifice");
}
public void setUseForSacrifice(ItemStack stack, boolean sacrifice)
{
NBTTagCompound tag = stack.getTagCompound();
@@ -234,14 +234,14 @@ public class SacrificialDagger extends Item
tag = new NBTTagCompound();
stack.setTagCompound(tag);
}
tag.setBoolean("sacrifice", sacrifice);
}
@Override
@SideOnly(Side.CLIENT)
public boolean hasEffect(ItemStack stack, int pass)
{
return this.canUseForSacrifice(stack) || super.hasEffect(stack, pass);
}
}
}
@@ -1,22 +1,22 @@
package WayofTime.alchemicalWizardry.common.rituals;
import java.util.ArrayList;
import java.util.List;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class RitualEffectFeatheredKnife extends RitualEffect
{
public final int amount = 100;
public final int amount = AlchemicalWizardry.lpPerSelfSacrificeFeatheredKnife;
public static final int sanctusDrain = 5;
public static final int reductusDrain = 3;
@@ -1,5 +1,8 @@
package WayofTime.alchemicalWizardry.common.rituals;
import java.util.ArrayList;
import java.util.List;
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
@@ -13,14 +16,11 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class RitualEffectWellOfSuffering extends RitualEffect
{
public static final int timeDelay = 25;
public static final int amount = 10;
public static final int amount = AlchemicalWizardry.lpPerSacrificeWellOfSuffering;
private static final int tennebraeDrain = 5;
private static final int potentiaDrain = 10;
private static final int offensaDrain = 3;
@@ -63,7 +63,7 @@ public class RitualEffectWellOfSuffering extends RitualEffect
{
return;
}
boolean hasPotentia = this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, false);
int d0 = 10;
@@ -88,19 +88,19 @@ public class RitualEffectWellOfSuffering extends RitualEffect
}
hasOffensa = hasOffensa && this.canDrainReagent(ritualStone, ReagentRegistry.offensaReagent, offensaDrain, true);
if (livingEntity.attackEntityFrom(DamageSource.outOfWorld, hasOffensa ? 2 : 1))
{
hasTennebrae = hasTennebrae && this.canDrainReagent(ritualStone, ReagentRegistry.tenebraeReagent, tennebraeDrain, true);
entityCount++;
tileAltar.sacrificialDaggerCall(this.amount * (hasTennebrae ? 2 : 1) * (hasOffensa ? 2 : 1), true);
}
}
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh() * entityCount);
if(hasPotentia)
{
this.canDrainReagent(ritualStone, ReagentRegistry.potentiaReagent, potentiaDrain, true);