2015-11-02 12:39:44 -08:00
|
|
|
package WayofTime.bloodmagic.api;
|
2015-10-29 20:22:14 -07:00
|
|
|
|
2016-02-25 08:54:18 -05:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2015-10-29 20:22:14 -07:00
|
|
|
import lombok.Getter;
|
|
|
|
import lombok.Setter;
|
2016-01-01 12:33:42 -08:00
|
|
|
import net.minecraft.block.Block;
|
2016-01-19 19:46:49 -08:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
2015-10-29 20:22:14 -07:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.util.DamageSource;
|
|
|
|
import net.minecraftforge.fluids.Fluid;
|
2015-12-23 09:42:52 -08:00
|
|
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
2016-02-25 08:54:18 -05:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.LogHelper;
|
2016-01-01 12:33:42 -08:00
|
|
|
|
2016-01-30 14:58:37 -08:00
|
|
|
/**
|
|
|
|
* The primary API class. Includes helper methods and blacklists.
|
|
|
|
*
|
|
|
|
* Some API methods can be used via IMC instead. The supported methods are:
|
|
|
|
*
|
|
|
|
* <ul>
|
|
|
|
* <li>{@link #addToTeleposerBlacklist(BlockStack)}</li>
|
|
|
|
* <li>{@link #blacklistFromGreenGrove(Block)}</li>
|
|
|
|
* <li>{@link #setEntitySacrificeValue(Class, int)}</li>
|
|
|
|
* </ul>
|
|
|
|
*/
|
2015-12-30 15:34:40 -05:00
|
|
|
public class BloodMagicAPI
|
|
|
|
{
|
2016-01-01 12:33:42 -08:00
|
|
|
@Getter
|
|
|
|
private static final List<BlockStack> teleposerBlacklist = new ArrayList<BlockStack>();
|
2016-01-19 19:46:49 -08:00
|
|
|
@Getter
|
|
|
|
private static final Map<String, Integer> entitySacrificeValues = new HashMap<String, Integer>();
|
2016-01-23 00:32:10 -08:00
|
|
|
@Getter
|
|
|
|
private static final ArrayList<Block> greenGroveBlacklist = new ArrayList<Block>();
|
2016-01-19 19:46:49 -08:00
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
@Getter
|
|
|
|
@Setter
|
2015-10-29 20:22:14 -07:00
|
|
|
private static boolean loggingEnabled;
|
|
|
|
|
|
|
|
@Getter
|
2015-11-02 12:39:44 -08:00
|
|
|
private static LogHelper logger = new LogHelper("BloodMagic|API");
|
2015-10-29 20:22:14 -07:00
|
|
|
|
|
|
|
@Getter
|
|
|
|
private static DamageSource damageSource = new DamageSourceBloodMagic();
|
|
|
|
|
2016-01-01 12:33:42 -08:00
|
|
|
@Getter
|
|
|
|
@Setter
|
|
|
|
private static Fluid lifeEssence;
|
|
|
|
|
2015-12-23 09:42:52 -08:00
|
|
|
/**
|
2016-01-18 22:34:12 -08:00
|
|
|
* Used to obtain Items from BloodMagic. Use
|
|
|
|
* {@link WayofTime.bloodmagic.api.Constants.BloodMagicItem} to get
|
|
|
|
* the registered name.
|
2015-12-30 15:34:40 -05:00
|
|
|
*
|
|
|
|
* @param name
|
2016-01-02 17:56:37 -05:00
|
|
|
* - The registered name of the item. Usually the same as the class
|
|
|
|
* name.
|
2015-12-23 09:42:52 -08:00
|
|
|
* @return - The requested Item
|
|
|
|
*/
|
2015-12-30 15:34:40 -05:00
|
|
|
public static Item getItem(String name)
|
|
|
|
{
|
2015-12-23 09:42:52 -08:00
|
|
|
return GameRegistry.findItem(Constants.Mod.MODID, name);
|
|
|
|
}
|
2015-12-02 00:55:32 -08:00
|
|
|
|
2016-01-18 22:34:12 -08:00
|
|
|
/**
|
|
|
|
* @see #getItem(String)
|
|
|
|
*
|
|
|
|
* @param bloodMagicItem
|
|
|
|
* - The {@link WayofTime.bloodmagic.api.Constants.BloodMagicItem} to get.
|
|
|
|
* @return - The requested Item
|
|
|
|
*/
|
|
|
|
public static Item getItem(Constants.BloodMagicItem bloodMagicItem) {
|
|
|
|
return getItem(bloodMagicItem.getRegName());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to obtain Blocks from BloodMagic. Use
|
|
|
|
* {@link WayofTime.bloodmagic.api.Constants.BloodMagicBlock} to get
|
|
|
|
* the registered name.
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* - The registered name of the block. Usually the same as the class
|
|
|
|
* name.
|
|
|
|
* @return - The requested Block
|
|
|
|
*/
|
|
|
|
public static Block getBlock(String name)
|
|
|
|
{
|
|
|
|
return GameRegistry.findBlock(Constants.Mod.MODID, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see #getBlock(String)
|
|
|
|
*
|
|
|
|
* @param bloodMagicBlock
|
|
|
|
* - The {@link WayofTime.bloodmagic.api.Constants.BloodMagicBlock} to get.
|
|
|
|
* @return - The requested Block
|
|
|
|
*/
|
|
|
|
public static Block getBlock(Constants.BloodMagicBlock bloodMagicBlock) {
|
|
|
|
return getBlock(bloodMagicBlock.getRegName());
|
|
|
|
}
|
|
|
|
|
2016-01-01 12:33:42 -08:00
|
|
|
/**
|
2016-01-02 17:56:37 -05:00
|
|
|
* Used to add a {@link BlockStack} to the Teleposer blacklist that cannot
|
|
|
|
* be changed via Configuration files.
|
2016-01-30 14:58:37 -08:00
|
|
|
*
|
|
|
|
* IMC: {@code FMLInterModComs.sendMessage("BloodMagic", "teleposerBlacklist", ItemStack)}
|
|
|
|
* Example: {@code FMLInterModComs.sendMessage("BloodMagic", "teleposerBlacklist", new ItemStack(Blocks.bedrock))}
|
2016-01-02 17:56:37 -05:00
|
|
|
*
|
2016-01-01 12:33:42 -08:00
|
|
|
* @param blockStack
|
2016-01-02 17:56:37 -05:00
|
|
|
* - The BlockStack to blacklist.
|
2016-01-01 12:33:42 -08:00
|
|
|
*/
|
|
|
|
public static void addToTeleposerBlacklist(BlockStack blockStack)
|
|
|
|
{
|
|
|
|
if (!teleposerBlacklist.contains(blockStack))
|
|
|
|
teleposerBlacklist.add(blockStack);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see #addToTeleposerBlacklist(BlockStack)
|
2016-01-02 17:56:37 -05:00
|
|
|
*
|
2016-01-01 12:33:42 -08:00
|
|
|
* @param block
|
2016-01-02 17:56:37 -05:00
|
|
|
* - The block to blacklist
|
2016-01-01 12:33:42 -08:00
|
|
|
* @param meta
|
2016-01-02 17:56:37 -05:00
|
|
|
* - The meta of the block to blacklist
|
2016-01-01 12:33:42 -08:00
|
|
|
*/
|
|
|
|
public static void addToTeleposerBlacklist(Block block, int meta)
|
|
|
|
{
|
|
|
|
addToTeleposerBlacklist(new BlockStack(block, meta));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see #addToTeleposerBlacklist(BlockStack)
|
2016-01-02 17:56:37 -05:00
|
|
|
*
|
2016-01-01 12:33:42 -08:00
|
|
|
* @param block
|
2016-01-02 17:56:37 -05:00
|
|
|
* - The block to blacklist
|
2016-01-01 12:33:42 -08:00
|
|
|
*/
|
|
|
|
public static void addToTeleposerBlacklist(Block block)
|
|
|
|
{
|
|
|
|
addToTeleposerBlacklist(block, 0);
|
|
|
|
}
|
2016-01-19 19:46:49 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2016-01-30 14:58:37 -08:00
|
|
|
* IMC: {@code FMLInterModComs.sendMessage("BloodMagic", "sacrificeValue", "ClassName;Value")}
|
|
|
|
* Example: {@code FMLInterModComs.sendMessage("BloodMagic", "sacrificeValue", "EntityVillager;2000")}
|
|
|
|
*
|
2016-01-19 19:46:49 -08:00
|
|
|
* @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);
|
|
|
|
}
|
2016-01-23 00:32:10 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Blacklists a block from the Green Grove Ritual and Sigil.
|
|
|
|
*
|
2016-01-30 14:58:37 -08:00
|
|
|
* IMC: {@code FMLInterModComs.sendMessage("BloodMagic", "greenGroveBlacklist", "domain:name")}
|
|
|
|
* Example: {@code FMLInterModComs.sendMessage("BloodMagic", "greenGroveBlacklist", "minecraft:wheat")}
|
|
|
|
*
|
2016-01-23 00:32:10 -08:00
|
|
|
* @param block - Block to blacklist
|
|
|
|
*/
|
|
|
|
public static void blacklistFromGreenGrove(Block block) {
|
|
|
|
if (!greenGroveBlacklist.contains(block))
|
|
|
|
greenGroveBlacklist.add(block);
|
|
|
|
}
|
2015-10-29 20:22:14 -07:00
|
|
|
}
|