2018-02-06 01:04:38 +00:00
|
|
|
package WayofTime.bloodmagic.apibutnotreally.registry;
|
2016-01-08 08:32:03 +00:00
|
|
|
|
2018-02-06 01:04:38 +00:00
|
|
|
import WayofTime.bloodmagic.apibutnotreally.BlockStack;
|
|
|
|
import WayofTime.bloodmagic.apibutnotreally.iface.IHarvestHandler;
|
2016-03-17 20:00:44 +00:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.BlockStem;
|
|
|
|
|
|
|
|
import java.util.*;
|
2016-01-08 08:32:03 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public class HarvestRegistry {
|
2016-01-08 08:32:03 +00:00
|
|
|
private static List<IHarvestHandler> handlerList = new ArrayList<IHarvestHandler>();
|
2016-01-09 09:54:25 +00:00
|
|
|
private static Map<Block, Integer> standardCrops = new HashMap<Block, Integer>();
|
|
|
|
private static Set<BlockStack> tallCrops = new HashSet<BlockStack>();
|
|
|
|
private static Map<BlockStack, BlockStack> stemCrops = new HashMap<BlockStack, BlockStack>();
|
2016-01-08 08:32:03 +00:00
|
|
|
private static Map<BlockStack, Integer> amplifierMap = new HashMap<BlockStack, Integer>();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a handler for the Harvest Ritual to call.
|
2017-08-16 04:30:48 +00:00
|
|
|
*
|
|
|
|
* @param handler - The custom handler to register
|
2016-01-08 08:32:03 +00:00
|
|
|
*/
|
2017-08-16 04:30:48 +00:00
|
|
|
public static void registerHandler(IHarvestHandler handler) {
|
2016-01-08 08:32:03 +00:00
|
|
|
if (!handlerList.contains(handler))
|
|
|
|
handlerList.add(handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-16 22:41:06 +00:00
|
|
|
* Registers a standard crop (IE: Wheat, Carrots, Potatoes, Netherwart, etc)
|
|
|
|
* for the
|
|
|
|
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerPlantable}
|
|
|
|
* handler to handle.
|
2017-08-16 04:30:48 +00:00
|
|
|
*
|
|
|
|
* @param crop - The crop block to handle.
|
|
|
|
* @param matureMeta - The meta value at which the crop is considered mature and ready
|
|
|
|
* to be harvested.
|
2016-01-08 08:32:03 +00:00
|
|
|
*/
|
2017-08-16 04:30:48 +00:00
|
|
|
public static void registerStandardCrop(Block crop, int matureMeta) {
|
2016-01-09 09:54:25 +00:00
|
|
|
if (!standardCrops.containsKey(crop))
|
|
|
|
standardCrops.put(crop, matureMeta);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a tall crop (Sugar Cane and Cactus) for the
|
2016-03-16 22:41:06 +00:00
|
|
|
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerTall} handler to
|
|
|
|
* handle.
|
2017-08-16 04:30:48 +00:00
|
|
|
*
|
|
|
|
* @param crop - The crop block to handle.
|
2016-01-09 09:54:25 +00:00
|
|
|
*/
|
2017-08-16 04:30:48 +00:00
|
|
|
public static void registerTallCrop(BlockStack crop) {
|
2016-01-09 09:54:25 +00:00
|
|
|
if (!tallCrops.contains(crop))
|
|
|
|
tallCrops.add(crop);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a stem crop (Melon and Pumpkin) for the
|
2016-03-16 22:41:06 +00:00
|
|
|
* {@link WayofTime.bloodmagic.ritual.harvest.HarvestHandlerStem} handler to
|
|
|
|
* handle.
|
2017-08-16 04:30:48 +00:00
|
|
|
* <p>
|
2016-03-16 22:41:06 +00:00
|
|
|
* Use {@link net.minecraftforge.oredict.OreDictionary#WILDCARD_VALUE} to
|
|
|
|
* accept any meta for the crop block.
|
2017-08-16 04:30:48 +00:00
|
|
|
* <p>
|
2016-01-09 09:54:25 +00:00
|
|
|
* The Stem must be instanceof {@link BlockStem}
|
2017-08-16 04:30:48 +00:00
|
|
|
*
|
|
|
|
* @param crop - The crop block to handle.
|
|
|
|
* @param stem - The stem of the crop
|
2016-01-09 09:54:25 +00:00
|
|
|
*/
|
2017-08-16 04:30:48 +00:00
|
|
|
public static void registerStemCrop(BlockStack crop, BlockStack stem) {
|
2016-01-09 09:54:25 +00:00
|
|
|
if (!stemCrops.containsKey(crop) && stem.getBlock() instanceof BlockStem)
|
|
|
|
stemCrops.put(stem, crop);
|
2016-01-08 08:32:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a range amplifier for the Harvest Ritual.
|
2017-08-16 04:30:48 +00:00
|
|
|
*
|
|
|
|
* @param blockStack - The block for the amplifier.
|
|
|
|
* @param range - The range the amplifier provides.
|
2016-01-08 08:32:03 +00:00
|
|
|
*/
|
2017-08-16 04:30:48 +00:00
|
|
|
public static void registerRangeAmplifier(BlockStack blockStack, int range) {
|
2016-01-08 08:32:03 +00:00
|
|
|
if (!amplifierMap.containsKey(blockStack))
|
|
|
|
amplifierMap.put(blockStack, range);
|
|
|
|
}
|
2016-02-18 17:49:12 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public static List<IHarvestHandler> getHandlerList() {
|
2016-02-18 17:49:12 +00:00
|
|
|
return new ArrayList<IHarvestHandler>(handlerList);
|
|
|
|
}
|
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public static Map<Block, Integer> getStandardCrops() {
|
2016-02-18 17:49:12 +00:00
|
|
|
return new HashMap<Block, Integer>(standardCrops);
|
|
|
|
}
|
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public static Set<BlockStack> getTallCrops() {
|
2016-02-18 17:49:12 +00:00
|
|
|
return new HashSet<BlockStack>(tallCrops);
|
|
|
|
}
|
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public static Map<BlockStack, BlockStack> getStemCrops() {
|
2016-02-18 17:49:12 +00:00
|
|
|
return new HashMap<BlockStack, BlockStack>(stemCrops);
|
|
|
|
}
|
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public static Map<BlockStack, Integer> getAmplifierMap() {
|
2016-02-18 17:49:12 +00:00
|
|
|
return new HashMap<BlockStack, Integer>(amplifierMap);
|
|
|
|
}
|
2016-01-08 08:32:03 +00:00
|
|
|
}
|