Allow modifying of entity sacrificial values
Done via API or Config. API values take precedence over Config values.
This commit is contained in:
parent
fa15499388
commit
073873960c
|
@ -1,9 +1,11 @@
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Version 2.0.0-7
|
Version 2.0.0-7
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
- [API] Method to easily get instances of Items and Blocks
|
|
||||||
- JEI now displays more information for Altar recipes. Hover over the Altar image to view it.
|
- JEI now displays more information for Altar recipes. Hover over the Altar image to view it.
|
||||||
- Added particles to the Blood Altar on the server-side.
|
- Added particles to the Blood Altar on the server-side.
|
||||||
|
- Allow configuration of entity sacrificial values
|
||||||
|
- [API] Allow setting of entity sacrificial values via API. Takes precedence over config values.
|
||||||
|
- [API] Method to easily get instances of Items and Blocks
|
||||||
|
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Version 2.0.0-6
|
Version 2.0.0-6
|
||||||
|
|
|
@ -15,9 +15,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ConfigHandler
|
public class ConfigHandler
|
||||||
{
|
{
|
||||||
|
@ -36,6 +34,10 @@ public class ConfigHandler
|
||||||
// Well of Suffering Blacklist
|
// Well of Suffering Blacklist
|
||||||
public static List<String> wellOfSufferingBlacklist;
|
public static List<String> wellOfSufferingBlacklist;
|
||||||
|
|
||||||
|
// Blood Altar Sacrificial Values
|
||||||
|
public static String[] entitySacrificeValuesList;
|
||||||
|
public static Map<String, Integer> entitySacrificeValues = new HashMap<String, Integer>();
|
||||||
|
|
||||||
// Potion ID's
|
// Potion ID's
|
||||||
public static int customPotionDrowningID;
|
public static int customPotionDrowningID;
|
||||||
public static int customPotionBoostID;
|
public static int customPotionBoostID;
|
||||||
|
@ -120,6 +122,11 @@ public class ConfigHandler
|
||||||
config.addCustomCategoryComment(category, "Entity blacklisting from WoS");
|
config.addCustomCategoryComment(category, "Entity blacklisting from WoS");
|
||||||
wellOfSufferingBlacklist = Arrays.asList(config.getStringList("wellOfSufferingBlacklist", category, new String[] {}, "Use the class name of the Entity to blacklist it from usage.\nIE: EntityWolf, EntityWitch, etc"));
|
wellOfSufferingBlacklist = Arrays.asList(config.getStringList("wellOfSufferingBlacklist", category, new String[] {}, "Use the class name of the Entity to blacklist it from usage.\nIE: EntityWolf, EntityWitch, etc"));
|
||||||
|
|
||||||
|
category = "Blood Altar Sacrificial Values";
|
||||||
|
config.addCustomCategoryComment(category, "Entity Sacrificial Value Settings");
|
||||||
|
entitySacrificeValuesList = config.getStringList("entitySacrificeValues", category, new String[] {"EntityVillager;2000", "EntitySlime;150", "EntityEnderman;200", "EntityCow;250", "EntityChicken;250", "EntityHorse;250", "EntitySheep;250", "EntityWolf;250", "EntityOcelot;250", "EntityPig;250", "EntityRabbit;250"}, "Used to edit the amount of LP gained per sacrifice of the given entity.\nSetting an entity to 0 effectively blacklists it.\nIf a mod modifies an entity via the API, it will take precedence over this config.\nSyntax: EntityClassName;LPPerSacrifice");
|
||||||
|
buildEntitySacrificeValues();
|
||||||
|
|
||||||
category = "Potions";
|
category = "Potions";
|
||||||
config.addCustomCategoryComment(category, "Potion settings");
|
config.addCustomCategoryComment(category, "Potion settings");
|
||||||
config.addCustomCategoryComment(category + ".id", "Potion ID settings");
|
config.addCustomCategoryComment(category + ".id", "Potion ID settings");
|
||||||
|
@ -224,6 +231,23 @@ public class ConfigHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void buildEntitySacrificeValues()
|
||||||
|
{
|
||||||
|
entitySacrificeValues.clear();
|
||||||
|
|
||||||
|
for (String entityData : entitySacrificeValuesList)
|
||||||
|
{
|
||||||
|
String[] split = entityData.split(";");
|
||||||
|
|
||||||
|
int amount = 500;
|
||||||
|
if (Utils.isInteger(split[1]))
|
||||||
|
amount = Integer.parseInt(split[1]);
|
||||||
|
|
||||||
|
if (!entitySacrificeValues.containsKey(split[0]))
|
||||||
|
entitySacrificeValues.put(split[0], amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void checkRituals()
|
public static void checkRituals()
|
||||||
{
|
{
|
||||||
RitualHelper.checkRituals(config, "WayofTime.bloodmagic.ritual", "Rituals");
|
RitualHelper.checkRituals(config, "WayofTime.bloodmagic.ritual", "Rituals");
|
||||||
|
|
|
@ -4,19 +4,26 @@ import WayofTime.bloodmagic.api.util.helper.LogHelper;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class BloodMagicAPI
|
public class BloodMagicAPI
|
||||||
{
|
{
|
||||||
@Getter
|
@Getter
|
||||||
private static final List<BlockStack> teleposerBlacklist = new ArrayList<BlockStack>();
|
private static final List<BlockStack> teleposerBlacklist = new ArrayList<BlockStack>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static final Map<String, Integer> entitySacrificeValues = new HashMap<String, Integer>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private static boolean loggingEnabled;
|
private static boolean loggingEnabled;
|
||||||
|
@ -119,4 +126,37 @@ public class BloodMagicAPI
|
||||||
{
|
{
|
||||||
addToTeleposerBlacklist(block, 0);
|
addToTeleposerBlacklist(block, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to set the sacrifice value of an Entity. The value provided is how much
|
||||||
|
* LP will be gained when the entity is sacrificed at a Blood Altar.
|
||||||
|
*
|
||||||
|
* Setting a sacrificeValue of 0 will effectively blacklist the entity.
|
||||||
|
*
|
||||||
|
* The default value for any unset Entity is 500 LP per sacrifice.
|
||||||
|
*
|
||||||
|
* @param entityClass
|
||||||
|
* - The class of the entity to blacklist.
|
||||||
|
* @param sacrificeValue
|
||||||
|
* - The Amount of LP to provide per each entity sacrificed.
|
||||||
|
*/
|
||||||
|
public static void setEntitySacrificeValue(Class<? extends EntityLivingBase> entityClass, int sacrificeValue)
|
||||||
|
{
|
||||||
|
if (!entitySacrificeValues.containsKey(entityClass.getSimpleName()))
|
||||||
|
entitySacrificeValues.put(entityClass.getSimpleName(), sacrificeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #setEntitySacrificeValue(Class, int)
|
||||||
|
*
|
||||||
|
* @param entityClassName
|
||||||
|
* - The name of the class of the entity to blacklist.
|
||||||
|
* @param sacrificeValue
|
||||||
|
* - The Amount of LP to provide per each entity sacrificed.
|
||||||
|
*/
|
||||||
|
public static void setEntitySacrificeValue(String entityClassName, int sacrificeValue)
|
||||||
|
{
|
||||||
|
if (!entitySacrificeValues.containsKey(entityClassName))
|
||||||
|
entitySacrificeValues.put(entityClassName, sacrificeValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package WayofTime.bloodmagic.item;
|
package WayofTime.bloodmagic.item;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
|
import WayofTime.bloodmagic.ConfigHandler;
|
||||||
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import WayofTime.bloodmagic.api.DamageSourceBloodMagic;
|
import WayofTime.bloodmagic.api.DamageSourceBloodMagic;
|
||||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||||
|
@ -42,16 +44,14 @@ public class ItemDaggerOfSacrifice extends Item
|
||||||
if (target.isDead || target.getHealth() < 0.5F)
|
if (target.isDead || target.getHealth() < 0.5F)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO Make these configurable
|
String entityName = target.getClass().getSimpleName();
|
||||||
int lifeEssence = 500;
|
int lifeEssence = 500;
|
||||||
if (target instanceof EntityVillager)
|
|
||||||
lifeEssence = 2000;
|
if (ConfigHandler.entitySacrificeValues.containsKey(entityName))
|
||||||
else if (target instanceof EntitySlime)
|
lifeEssence = ConfigHandler.entitySacrificeValues.get(entityName);
|
||||||
lifeEssence = 150;
|
|
||||||
else if (target instanceof EntityEnderman)
|
if (BloodMagicAPI.getEntitySacrificeValues().containsKey(entityName))
|
||||||
lifeEssence = 200;
|
lifeEssence = BloodMagicAPI.getEntitySacrificeValues().get(entityName);
|
||||||
else if (target instanceof EntityAnimal)
|
|
||||||
lifeEssence = 250;
|
|
||||||
|
|
||||||
if (findAndFillAltar(attacker.worldObj, target, lifeEssence))
|
if (findAndFillAltar(attacker.worldObj, target, lifeEssence))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue