2015-11-02 12:39:44 -08:00
|
|
|
package WayofTime.bloodmagic.api;
|
2015-10-29 20:22:14 -07:00
|
|
|
|
2017-02-12 01:18:16 -08:00
|
|
|
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
2016-03-17 13:00:44 -07:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.LogHelper;
|
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;
|
2017-02-12 01:18:16 -08:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
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;
|
2016-06-28 15:18:35 -07:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-10-29 20:22:14 -07:00
|
|
|
import net.minecraft.util.DamageSource;
|
2016-04-24 10:06:28 -07:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-06-28 15:18:35 -07:00
|
|
|
import net.minecraftforge.common.ForgeModContainer;
|
2015-10-29 20:22:14 -07:00
|
|
|
import net.minecraftforge.fluids.Fluid;
|
2016-06-28 15:18:35 -07:00
|
|
|
import net.minecraftforge.fluids.UniversalBucket;
|
2016-04-24 10:06:28 -07:00
|
|
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
2016-03-17 13:00:44 -07:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
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.
|
2016-03-16 18:41:06 -04:00
|
|
|
*
|
2016-01-30 14:58:37 -08:00
|
|
|
* Some API methods can be used via IMC instead. The supported methods are:
|
2016-03-16 18:41:06 -04:00
|
|
|
*
|
2016-01-30 14:58:37 -08:00
|
|
|
* <ul>
|
2016-03-16 18:41:06 -04:00
|
|
|
* <li>{@link #addToTeleposerBlacklist(BlockStack)}</li>
|
|
|
|
* <li>{@link #blacklistFromGreenGrove(Block)}</li>
|
|
|
|
* <li>{@link #setEntitySacrificeValue(Class, int)}</li>
|
2017-02-12 01:36:01 -08:00
|
|
|
* <li>{@link #addAltarComponent(IBlockState, EnumAltarComponent)}</li>
|
2016-01-30 14:58:37 -08:00
|
|
|
* </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
|
2016-06-09 16:01:32 -07:00
|
|
|
private static final List<BlockStack> transpositionBlacklist = new ArrayList<BlockStack>();
|
|
|
|
@Getter
|
2016-01-19 19:46:49 -08:00
|
|
|
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>();
|
2017-02-12 01:18:16 -08:00
|
|
|
@Getter
|
|
|
|
private static final Map<IBlockState, EnumAltarComponent> altarComponents = new HashMap<IBlockState, EnumAltarComponent>();
|
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;
|
2016-06-28 15:18:35 -07:00
|
|
|
private static ItemStack lifeEssenceBucket;
|
|
|
|
|
|
|
|
public static ItemStack getLifeEssenceBucket()
|
|
|
|
{
|
|
|
|
if (lifeEssenceBucket != null)
|
|
|
|
return lifeEssenceBucket;
|
|
|
|
|
|
|
|
lifeEssenceBucket = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, getLifeEssence());
|
|
|
|
return lifeEssenceBucket;
|
|
|
|
}
|
2016-01-01 12:33:42 -08:00
|
|
|
|
2015-12-23 09:42:52 -08:00
|
|
|
/**
|
2016-01-18 22:34:12 -08:00
|
|
|
* Used to obtain Items from BloodMagic. Use
|
2016-03-16 18:41:06 -04:00
|
|
|
* {@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)
|
|
|
|
{
|
2016-04-24 10:06:28 -07:00
|
|
|
return ForgeRegistries.ITEMS.getValue(new ResourceLocation(Constants.Mod.MODID, name));
|
2015-12-23 09:42:52 -08:00
|
|
|
}
|
2015-12-02 00:55:32 -08:00
|
|
|
|
2016-01-18 22:34:12 -08:00
|
|
|
/**
|
|
|
|
* @see #getItem(String)
|
2016-03-16 18:41:06 -04:00
|
|
|
*
|
2016-01-18 22:34:12 -08:00
|
|
|
* @param bloodMagicItem
|
2016-03-16 18:41:06 -04:00
|
|
|
* - The {@link WayofTime.bloodmagic.api.Constants.BloodMagicItem} to
|
|
|
|
* get.
|
2016-01-18 22:34:12 -08:00
|
|
|
* @return - The requested Item
|
|
|
|
*/
|
2016-03-16 18:41:06 -04:00
|
|
|
public static Item getItem(Constants.BloodMagicItem bloodMagicItem)
|
|
|
|
{
|
2016-01-18 22:34:12 -08:00
|
|
|
return getItem(bloodMagicItem.getRegName());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Used to obtain Blocks from BloodMagic. Use
|
2016-03-16 18:41:06 -04:00
|
|
|
* {@link WayofTime.bloodmagic.api.Constants.BloodMagicBlock} to get the
|
|
|
|
* registered name.
|
|
|
|
*
|
2016-01-18 22:34:12 -08:00
|
|
|
* @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)
|
|
|
|
{
|
2016-04-24 10:06:28 -07:00
|
|
|
return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Constants.Mod.MODID, name));
|
2016-01-18 22:34:12 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see #getBlock(String)
|
2016-03-16 18:41:06 -04:00
|
|
|
*
|
2016-01-18 22:34:12 -08:00
|
|
|
* @param bloodMagicBlock
|
2016-03-16 18:41:06 -04:00
|
|
|
* - The {@link WayofTime.bloodmagic.api.Constants.BloodMagicBlock}
|
|
|
|
* to get.
|
2016-01-18 22:34:12 -08:00
|
|
|
* @return - The requested Block
|
|
|
|
*/
|
2016-03-16 18:41:06 -04:00
|
|
|
public static Block getBlock(Constants.BloodMagicBlock bloodMagicBlock)
|
|
|
|
{
|
2016-01-18 22:34:12 -08:00
|
|
|
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-03-16 18:41:06 -04:00
|
|
|
*
|
|
|
|
* IMC:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@code FMLInterModComs.sendMessage("bloodmagic", "teleposerBlacklist", ItemStack)}
|
2016-03-16 18:41:06 -04:00
|
|
|
* Example:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@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
|
|
|
|
2016-06-09 16:01:32 -07:00
|
|
|
/**
|
2016-06-23 21:43:27 -04:00
|
|
|
* Used to add a {@link BlockStack} to the Transposition blacklist that
|
|
|
|
* cannot be changed via Configuration files.
|
|
|
|
*
|
2016-06-09 16:01:32 -07:00
|
|
|
* IMC:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@code FMLInterModComs.sendMessage("bloodmagic", "transpositionBlacklist", ItemStack)}
|
2016-06-09 16:01:32 -07:00
|
|
|
* Example:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@code FMLInterModComs.sendMessage("bloodmagic", "transpositionBlacklist", new ItemStack(Blocks.bedrock))}
|
2016-06-23 21:43:27 -04:00
|
|
|
*
|
2016-06-09 16:01:32 -07:00
|
|
|
* @param blockStack
|
|
|
|
* - The BlockStack to blacklist.
|
|
|
|
*/
|
|
|
|
public static void addToTranspositionBlacklist(BlockStack blockStack)
|
|
|
|
{
|
|
|
|
if (!transpositionBlacklist.contains(blockStack))
|
|
|
|
transpositionBlacklist.add(blockStack);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see #addToTranspositionBlacklist(BlockStack)
|
2016-06-23 21:43:27 -04:00
|
|
|
*
|
2016-06-09 16:01:32 -07:00
|
|
|
* @param block
|
|
|
|
* - The block to blacklist
|
|
|
|
* @param meta
|
|
|
|
* - The meta of the block to blacklist
|
|
|
|
*/
|
|
|
|
public static void addToTranspositionBlacklist(Block block, int meta)
|
|
|
|
{
|
|
|
|
addToTranspositionBlacklist(new BlockStack(block, meta));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see #addToTranspositionBlacklist(BlockStack)
|
2016-06-23 21:43:27 -04:00
|
|
|
*
|
2016-06-09 16:01:32 -07:00
|
|
|
* @param block
|
|
|
|
* - The block to blacklist
|
|
|
|
*/
|
|
|
|
public static void addToTranspositionBlacklist(Block block)
|
|
|
|
{
|
|
|
|
addToTranspositionBlacklist(block, 0);
|
|
|
|
}
|
|
|
|
|
2016-01-19 19:46:49 -08:00
|
|
|
/**
|
2016-03-16 18:41:06 -04: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.
|
|
|
|
*
|
2016-01-19 19:46:49 -08:00
|
|
|
* Setting a sacrificeValue of 0 will effectively blacklist the entity.
|
2016-03-16 18:41:06 -04:00
|
|
|
*
|
2016-01-19 19:46:49 -08:00
|
|
|
* The default value for any unset Entity is 500 LP per sacrifice.
|
2016-03-16 18:41:06 -04:00
|
|
|
*
|
|
|
|
* IMC:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@code FMLInterModComs.sendMessage("bloodmagic", "sacrificeValue", "ClassName;Value")}
|
2016-03-16 18:41:06 -04:00
|
|
|
* Example:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@code FMLInterModComs.sendMessage("bloodmagic", "sacrificeValue", "EntityVillager;2000")}
|
2016-03-16 18:41:06 -04:00
|
|
|
*
|
2016-01-19 19:46:49 -08:00
|
|
|
* @param entityClass
|
|
|
|
* - The class of the entity to blacklist.
|
|
|
|
* @param sacrificeValue
|
2016-11-05 11:14:56 -04:00
|
|
|
* - The Amount of LP to provide per each HP of the entity
|
|
|
|
* sacrificed.
|
2016-01-19 19:46:49 -08:00
|
|
|
*/
|
|
|
|
public static void setEntitySacrificeValue(Class<? extends EntityLivingBase> entityClass, int sacrificeValue)
|
|
|
|
{
|
|
|
|
if (!entitySacrificeValues.containsKey(entityClass.getSimpleName()))
|
|
|
|
entitySacrificeValues.put(entityClass.getSimpleName(), sacrificeValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see #setEntitySacrificeValue(Class, int)
|
2016-03-16 18:41:06 -04:00
|
|
|
*
|
2016-01-19 19:46:49 -08:00
|
|
|
* @param entityClassName
|
|
|
|
* - The name of the class of the entity to blacklist.
|
|
|
|
* @param sacrificeValue
|
2016-11-05 11:14:56 -04:00
|
|
|
* - The Amount of LP to provide per each HP of the entity
|
|
|
|
* sacrificed.
|
2016-01-19 19:46:49 -08:00
|
|
|
*/
|
|
|
|
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-03-16 18:41:06 -04:00
|
|
|
*
|
|
|
|
* IMC:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@code FMLInterModComs.sendMessage("bloodmagic", "greenGroveBlacklist", "domain:name")}
|
2016-03-16 18:41:06 -04:00
|
|
|
* Example:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@code FMLInterModComs.sendMessage("bloodmagic", "greenGroveBlacklist", "minecraft:wheat")}
|
2016-03-16 18:41:06 -04:00
|
|
|
*
|
|
|
|
* @param block
|
|
|
|
* - Block to blacklist
|
2016-01-23 00:32:10 -08:00
|
|
|
*/
|
2016-03-16 18:41:06 -04:00
|
|
|
public static void blacklistFromGreenGrove(Block block)
|
|
|
|
{
|
2016-01-23 00:32:10 -08:00
|
|
|
if (!greenGroveBlacklist.contains(block))
|
|
|
|
greenGroveBlacklist.add(block);
|
|
|
|
}
|
2017-02-12 01:18:16 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Marks an IBlockState as a specific {@link EnumAltarComponent} without needing to implement
|
|
|
|
* {@link WayofTime.bloodmagic.api.altar.IAltarComponent} on the block.
|
|
|
|
*
|
|
|
|
* IMC:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@code FMLInterModComs.sendMessage("bloodmagic", "altarComponent", "domain:name:meta:component")}
|
2017-02-12 01:18:16 -08:00
|
|
|
* Example:
|
2017-02-12 01:36:01 -08:00
|
|
|
* {@code FMLInterModComs.sendMessage("bloodmagic", "altarComponent", "minecraft:glowstone:0:GLOWSTONE")}
|
2017-02-12 01:18:16 -08:00
|
|
|
*
|
|
|
|
* @param state
|
|
|
|
* - The IBlockState for this component
|
|
|
|
* @param altarComponent
|
|
|
|
* - The EnumAltarComponent for this state
|
|
|
|
*/
|
|
|
|
public static void addAltarComponent(IBlockState state, EnumAltarComponent altarComponent)
|
|
|
|
{
|
|
|
|
if (!altarComponents.containsKey(state))
|
|
|
|
altarComponents.put(state, altarComponent);
|
|
|
|
}
|
2015-10-29 20:22:14 -07:00
|
|
|
}
|