Re-implemented all plugins

Updated to new Pulsar system, and to reflect various API changes (by TCon and others). Also reformatted build.gradle and bumped Gradle wrapper, Mantle, CCL, CCC, and Waila.
This commit is contained in:
Parker committed 2014-08-05 22:09:57 -04:00
1 parent a4ea930882
commit bff893221e
42 files changed
+939 -619

No files matched your search

@@ -10,43 +10,43 @@ import net.minecraft.item.ItemStack;
* @author King Lemming
*
*/
public interface IEnergyContainerItem
{
public interface IEnergyContainerItem {
/**
* Adds energy to an item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged.
*
* @param container
* ItemStack to be charged.
* @param maxReceive
* Maximum amount of energy to be sent into the item.
* @param simulate
* If TRUE, the charge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) received by the item.
*/
int receiveEnergy (ItemStack container, int maxReceive, boolean simulate);
/**
* Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged.
*
* @param container
* ItemStack to be charged.
* @param maxReceive
* Maximum amount of energy to be sent into the item.
* @param simulate
* If TRUE, the charge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) received by the item.
*/
int receiveEnergy(ItemStack container, int maxReceive, boolean simulate);
/**
* Removes energy from an item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally discharged.
*
* @param container
* ItemStack to be discharged.
* @param maxExtract
* Maximum amount of energy to be extracted from the item.
* @param simulate
* If TRUE, the discharge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted from the item.
*/
int extractEnergy (ItemStack container, int maxExtract, boolean simulate);
/**
* Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally
* discharged.
*
* @param container
* ItemStack to be discharged.
* @param maxExtract
* Maximum amount of energy to be extracted from the item.
* @param simulate
* If TRUE, the discharge will only be simulated.
* @return Amount of energy that was (or would have been, if simulated) extracted from the item.
*/
int extractEnergy(ItemStack container, int maxExtract, boolean simulate);
/**
* Get the amount of energy currently stored in the item.
*/
int getEnergyStored (ItemStack container);
/**
* Get the amount of energy currently stored in the container item.
*/
int getEnergyStored(ItemStack container);
/**
* Get the max amount of energy that can be stored in the item.
*/
int getMaxEnergyStored (ItemStack container);
/**
* Get the max amount of energy that can be stored in the container item.
*/
int getMaxEnergyStored(ItemStack container);
}
}
+10 -76
View File
@@ -193,82 +193,16 @@ public abstract class Ability
}
/**
* The following are helper functions to create abilities packaged with Morph.
* Use these to ability instances for mapping vanilla abilities to mobs.
* Self explanatory.
* Creates an ability by type.
* Check out AbilityHandler to see each Ability type and the parse function in their respective classes for the arguments.
* @return
*/
public static Ability getNewAbilityClimb()
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("getNewAbilityClimb").invoke(null);
} catch (Exception e) {
return null;
}
}//TODO add new abilities
public static Ability getNewAbilityFireImmunity()
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("getNewAbilityFireImmunity").invoke(null);
} catch (Exception e) {
return null;
}
}
public static Ability getNewAbilityFloat(float terminalVelocity, boolean negateFallDamage)
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("getNewAbilityFloat", float.class, boolean.class).invoke(null, terminalVelocity, negateFallDamage);
} catch (Exception e) {
return null;
}
}
public static Ability getNewAbilityFly(boolean slowdownInWater)
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("getNewAbilityFly", boolean.class).invoke(null, slowdownInWater);
} catch (Exception e) {
return null;
}
}
public static Ability getNewAbilityFly()
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("getNewAbilityFly", boolean.class).invoke(null, true);
} catch (Exception e) {
return null;
}
}
public static Ability getNewAbilityHostile()
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("getNewAbilityHostile").invoke(null);
} catch (Exception e) {
return null;
}
}
public static Ability getNewAbilitySunburn()
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("getNewAbilitySunburn").invoke(null);
} catch (Exception e) {
return null;
}
}
public static Ability getNewAbilitySwim(boolean canBreatheOnLand)
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("getNewAbilitySwim", boolean.class).invoke(null, canBreatheOnLand);
} catch (Exception e) {
return null;
}
}
public static Ability getNewAbilityWaterAllergy()
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("getNewAbilityWaterAllergy").invoke(null);
} catch (Exception e) {
return null;
}
}
public static Ability createNewAbilityByType(String type, String[] arguments)
{
try {
return (Ability)Class.forName("morph.common.ability.AbilityHandler").getDeclaredMethod("createNewAbilityByType", String.class, String[].class).invoke(null, type, arguments);
} catch (Exception e) {
return null;
}
}
}
@@ -0,0 +1,113 @@
package powercrystals.minefactoryreloaded.api;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
/**
* @author PowerCrystals
*
* Class used to register plants and other farming-related things with MFR. Will do nothing if MFR does not exist.
*
*/
public class FactoryRegistry
{
/*
* This may be called at any time during pre-init, init or post-init, assuming all blocks and items
* that are being accessed from the registry have been appropriately registered.
* Possible messages:
*
* // Registration:
* addLaserPreferredOre | NBTTag with an ItemStack saved on it, with the color on the "value" attribute,
* | A ValuedItem with item and value set.
* registerAutoSpawnerBlacklist | The String identifier of an entity,
* | A subclass of EntityLivingBase.
* registerFertilizable | An instance of IFactoryFertilizable.
* registerFertilizer | An instance of IFactoryFertilizer.
* registerFruitLog | The String identifier of a block.
* registerGrindable | An instance of IFactoryGrindable.
* registerGrinderBlacklist | A subclass of EntityLivingBase.
* registerHarvestable | An instance of IFactoryHarvestable.
* registerLaserOre | NBTTag with an ItemStack saved on it, with the weight on the "value" attribute,
* | A ValuedItem with item and value set.
* registerLiquidDrinkHandler | A ValuedItem with key and object set; ILiquidDrinkHandler expected.
* registerMobEggHandler | An instance of IMobEggHandler.
* registerPickableFruit | An instance of IFactoryFruit.
* registerPlantable | An instance of IFactoryPlantable.
* registerRanchable | An instance of IFactoryRanchable.
* registerRedNetLogicCircuit | An instance of IRedNetLogicCircuit.
* registerRubberTreeBiome | The biomeName field of a biome to white list for rubber trees to spawn in.
* registerSafariNetBlacklist | A subclass of EntityLivingBase.
* registerSafariNetHandler | An instance of ISafariNetHandler.
* registerSludgeDrop | NBTTag with an ItemStack saved on it, with the weight on the "value" attribute,
* | A ValuedItem with item and value set.
* registerSpawnHandler | An instance of IMobSpawnHandler.
* registerVillagerTradeMob | An instance of IRandomMobProvider.
*
* // Simple implementations:
* { Harvestables
* registerHarvestable_Standard | The String identifier of a block.
* registerHarvestable_Log | The String identifier of a block.
* registerHarvestable_Leaves | The String identifier of a block.
* registerHarvestable_Vine | The String identifier of a block.
* registerHarvestable_Shrub | The String identifier of a block.
* registerHarvestable_Mushroom | The String identifier of a block.
* registerHarvestable_Crop | An ItemStack of a block, with a damage value indicating the meta value to harvest at.
* | A ValuedItem with value and object set; Block expected.
* registerHarvestable_Gourd | An NBTTag with the stem and fruit attributes, both String identifiers of blocks.
* }
* { Plantables
* registerPlantable_Standard | An NBTTag with the seed (Item, String identifier), and
* crop (Block, String identifier) attributes set, optionally
* also having the meta (Integer, placed metadata value) attribute set.
* No special checks for location, just sustainability.
* registerPlantable_Crop | An NBTTag with the seed (Item, String identifier), and
* crop (Block, String identifier) attributes set, optionally
* also having the meta (Integer, placed metadata value) attribute set.
* Will automatically hoe dirt and grass into farmland when planting.
* registerPlantable_Sapling | An NBTTag with the sapling (Block, String identifier), and optionally
* the seed (Item, String identifier) attributes set.
* }
* { Fertilizer
* registerFertilizer | An NBTTag with the fert (Item, String identifier), meta (Integer), and
* type (Integer, index into FertilizerType.values()) attributes set.
* }
* { Fertilizables
* registerFertilizable_Grass | The String identifier of a block. Will bonemeal the block and expect
* tall grass be planted above and around it, must be IGrowable. Works with
* the GrowPlant and Grass type fertilizers, not recommended for crop plants.
* registerFertilizable_Gourd | The String identifier of a block. Must be IGrowable, and expects identical
* behavior to vanilla stems. Works with the GrowPlant fertilizers.
* registerFertilizable_Crop | An NBTTag with the plant (Block, String identifier, IGrowable), and
* meta (Integer, max growth phase) attributes set, optionally also having
* the type (Integer, index into FertilizerType) attribute set.
* registerFertilizable_Cocoa | An NBTTag with the plant (Block, String identifier), and optionally also
* the type (Integer, index into FertilizerType) attributes set.
* Expects metadata of the block to exactly match cocoa pods.
* registerFertilizable_Standard | An NBTTag with the plant (Block, String identifier, IGrowable), and
* optionally also the type (Integer, index into FertilizerType) attributes set.
* Expects the block to change when successfully grown (e.g., saplings).
* }
*/
public static void sendMessage(String message, Object value)
{
if (!Loader.isModLoaded("MineFactoryReloaded") ||
Loader.instance().activeModContainer() == null)
return;
try
{
Method m = FMLInterModComms.class.getDeclaredMethod("enqueueMessage", Object.class, String.class, IMCMessage.class);
m.setAccessible(true);
Constructor<IMCMessage> c = IMCMessage.class.getDeclaredConstructor(String.class, Object.class);
c.setAccessible(true);
m.invoke(null, Loader.instance().activeModContainer(), "MineFactoryReloaded", c.newInstance(message, value));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
@@ -0,0 +1,44 @@
package powercrystals.minefactoryreloaded.api;
/**
* @author PowerCrystals
*
* Determines what algorithm the Harvester uses when it encounters this IFactoryHarvestable in the world.
*/
public enum HarvestType
{
/**
* Just break the single block - no special action needed. e.g. Carrots, flowers, wheat.
*/
Normal,
/**
* Search for harvestable blocks adjacent to this block but leave this block. e.g. Pumpkin, melon
*/
Gourd,
/**
* Search for identical blocks above.
*/
Column,
/**
* Search for identical blocks above but leave the bottom one for the future. e.g. Cactus, sugarcane.
*/
LeaveBottom,
/**
* This block is the base of a tree and the harvester should enter tree-cutting mode.
*/
Tree,
/**
* This block is the base of the tree and the harvester should enter tree-cutting mode.
* The tree is searched for in the negative y axis instead.
*/
TreeFlipped,
/**
* This block is part of a tree as above.
*/
TreeLeaf,
/**
* This block is part of a tree as above, but fruits are cut before logs. e.g. cocoa
* The tree is not searched for.
*/
TreeFruit
}
@@ -0,0 +1,35 @@
package powercrystals.minefactoryreloaded.api;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World;
/**
* @author PowerCrystals
*
* Defines a grindable entity for the Grinder.
*/
public interface IFactoryGrindable
{
/**
* @return The class that this grindable instance is handling. This must be a subtype of EntityLivingBase or the entity will never
* be noticed by the Grinder.
*/
public Class<? extends EntityLivingBase> getGrindableEntity();
/**
* @param world The world this entity is in.
* @param entity The entity instance being ground.
* @param random A Random instance.
* @return The drops generated when this entity is killed.
*/
public List<MobDrop> grind(World world, EntityLivingBase entity, Random random);
/**
* @param entity The entity instance being ground.
* @return Whether this entity has been fully processed or not.
*/
public boolean processEntity(EntityLivingBase entity);
}
@@ -0,0 +1,71 @@
package powercrystals.minefactoryreloaded.api;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* @author PowerCrystals
*
* Defines a harvestable block for the Harvester.
*/
public interface IFactoryHarvestable
{
/**
* @return The block this harvestable instance is managing.
*/
public Block getPlant();
/**
* @return The type of harvest the Harvester should perform on this block.
*/
public HarvestType getHarvestType();
/**
* @return Whether or not the Harvester should break the block when harvesting. If false, no changes will be performed by the Harvester itself.
*/
public boolean breakBlock();
/**
* @param world The world this block is in.
* @param harvesterSettings The harvester's current settings. Do not modify these.
* @param x The X coordinate of the block being harvested.
* @param y The Y coordinate of the block being harvested.
* @param z The Z coordinate of the block being harvested.
* @return True if this block can be harvested.
*/
public boolean canBeHarvested(World world, Map<String, Boolean> harvesterSettings, int x, int y, int z);
/**
* @param world The world this block is in.
* @param rand A Random instance to use when generating drops.
* @param harvesterSettings The harvester's current settings. Do not modify these.
* @param x The X coordinate of the block being harvested.
* @param y The Y coordinate of the block being harvested.
* @param z The Z coordinate of the block being harvested.
* @return The drops generated by breaking this block. For a default implementation, calling Block.getBlockDropped() is usually sufficient.
*/
public List<ItemStack> getDrops(World world, Random rand, Map<String, Boolean> harvesterSettings, int x, int y, int z);
/**
* Called before the block is going to be harvested. Usually empty.
* @param world The world this block is in.
* @param x The X coordinate of the block being harvested.
* @param y The Y coordinate of the block being harvested.
* @param z The Z coordinate of the block being harvested.
*/
public void preHarvest(World world, int x, int y, int z);
/**
* Called after the block is going to be harvested. Used to re-till soil, for example.
* @param world The world this block is in.
* @param x The X coordinate of the block being harvested.
* @param y The Y coordinate of the block being harvested.
* @param z The Z coordinate of the block being harvested.
*/
public void postHarvest(World world, int x, int y, int z);
}
@@ -0,0 +1,8 @@
package powercrystals.minefactoryreloaded.api;
import net.minecraft.entity.EntityLivingBase;
public interface ILiquidDrinkHandler
{
public void onDrink(EntityLivingBase player);
}
@@ -0,0 +1,21 @@
package powercrystals.minefactoryreloaded.api;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
public class MobDrop extends WeightedRandom.Item
{
private ItemStack _stack;
public MobDrop(int weight, ItemStack stack)
{
super(weight);
_stack = stack;
}
public ItemStack getStack()
{
if(_stack == null) return null;
return _stack.copy();
}
}
@@ -0,0 +1,72 @@
package powercrystals.minefactoryreloaded.api;
import net.minecraft.item.ItemStack;
public class ValuedItem
{
public final int value;
public final ItemStack item;
public final String key;
public final Object object;
public ValuedItem(int v, ItemStack i)
{
value = v;
item = i;
key = null;
object = null;
}
public ValuedItem(String v, Object i)
{
value = -1;
item = null;
key = v;
object = i;
}
/**
* Presently unused but included so that if they do get used in the future,
* people including this in their jar and loading before MFR don't destroy everyone
*/
public ValuedItem(int v, Object i)
{
value = v;
item = null;
key = null;
object = i;
}
public ValuedItem(String v, ItemStack i)
{
value = -1;
item = i;
key = v;
object = null;
}
public ValuedItem(int v, String k, ItemStack i)
{
value = v;
item = i;
key = k;
object = null;
}
public ValuedItem(int v, String k, Object i)
{
value = v;
item = null;
key = k;
object = i;
}
public ValuedItem(int v, String k, ItemStack i, Object o)
{
value = v;
item = i;
key = k;
object = o;
}
}