Test with stuff + Forestry potential support

This commit is contained in:
WayofTime 2014-01-25 20:36:28 -05:00
parent 5b05cf651b
commit bd26e441cb
174 changed files with 5602 additions and 0 deletions

View file

@ -0,0 +1,18 @@
package forestry.api.storage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.event.Event;
public abstract class BackpackEvent extends Event {
public final EntityPlayer player;
public final IBackpackDefinition backpackDefinition;
public final IInventory backpackInventory;
public BackpackEvent(EntityPlayer player, IBackpackDefinition backpackDefinition, IInventory backpackInventory) {
this.player = player;
this.backpackDefinition = backpackDefinition;
this.backpackInventory = backpackInventory;
}
}

View file

@ -0,0 +1,22 @@
package forestry.api.storage;
import java.util.ArrayList;
import java.util.HashMap;
import net.minecraft.item.ItemStack;
public class BackpackManager {
/**
* 0 - Miner's Backpack 1 - Digger's Backpack 2 - Forester's Backpack 3 - Hunter's Backpack 4 - Adventurer's Backpack
*
* Use IMC messages to achieve the same effect!
*/
public static ArrayList<ItemStack>[] backpackItems;
public static IBackpackInterface backpackInterface;
/**
* Only use this if you know what you are doing. Prefer backpackInterface.
*/
public static HashMap<String, IBackpackDefinition> definitions = new HashMap<String, IBackpackDefinition>();
}

View file

@ -0,0 +1,18 @@
package forestry.api.storage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.event.Cancelable;
/**
* Use @ForgeSubscribe on a method taking this event as an argument. Will fire whenever a backpack tries to resupply to a player inventory. Processing will stop
* if the event is canceled.
*/
@Cancelable
public class BackpackResupplyEvent extends BackpackEvent {
public BackpackResupplyEvent(EntityPlayer player, IBackpackDefinition backpackDefinition, IInventory backpackInventory) {
super(player, backpackDefinition, backpackInventory);
}
}

View file

@ -0,0 +1,21 @@
package forestry.api.storage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.Cancelable;
/**
* Use @ForgeSubscribe on a method taking this event as an argument. Will fire whenever a backpack tries to store an item. Processing will stop if the stacksize
* of stackToStow drops to 0 or less or the event is canceled.
*/
@Cancelable
public class BackpackStowEvent extends BackpackEvent {
public final ItemStack stackToStow;
public BackpackStowEvent(EntityPlayer player, IBackpackDefinition backpackDefinition, IInventory backpackInventory, ItemStack stackToStow) {
super(player, backpackDefinition, backpackInventory);
this.stackToStow = stackToStow;
}
}

View file

@ -0,0 +1,5 @@
package forestry.api.storage;
public enum EnumBackpackType {
T1, T2
}

View file

@ -0,0 +1,54 @@
package forestry.api.storage;
import java.util.Collection;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface IBackpackDefinition {
/**
* @return A unique string identifier
*/
String getKey();
/**
* @return Human-readable name of the backpack.
*/
String getName();
/**
* @return Primary colour for the backpack icon.
*/
int getPrimaryColour();
/**
* @return Secondary colour for backpack icon.
*/
int getSecondaryColour();
/**
* Adds an item as valid for this backpack.
*
* @param validItem
*/
void addValidItem(ItemStack validItem);
/**
* Returns an arraylist of all items valid for this backpack type.
*
* @param player
* @return Collection of itemstack which are valid items for this backpack type. May be empty or null and does not necessarily include all valid items.
*/
Collection<ItemStack> getValidItems(EntityPlayer player);
/**
* Returns true if the itemstack is a valid item for this backpack type.
*
* @param player
* @param itemstack
* @return true if the given itemstack is valid for this backpack, false otherwise.
*/
boolean isValidItem(EntityPlayer player, ItemStack itemstack);
}

View file

@ -0,0 +1,19 @@
package forestry.api.storage;
import net.minecraft.item.Item;
public interface IBackpackInterface {
/**
* Adds a backpack with the given id, definition and type, returning the item.
*
* @param itemID
* Item id to use.
* @param definition
* Definition of backpack behaviour.
* @param type
* Type of backpack. (T1 or T2 (= Woven)
* @return Created backpack item.
*/
Item addBackpack(int itemID, IBackpackDefinition definition, EnumBackpackType type);
}

View file

@ -0,0 +1,3 @@
@API(apiVersion="1.0", owner="ForestryAPI|core", provides="ForestryAPI|storage")
package forestry.api.storage;
import cpw.mods.fml.common.API;