Test with stuff + Forestry potential support
This commit is contained in:
parent
5b05cf651b
commit
bd26e441cb
174 changed files with 5602 additions and 0 deletions
18
BM_src/forestry/api/storage/BackpackEvent.java
Normal file
18
BM_src/forestry/api/storage/BackpackEvent.java
Normal 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;
|
||||
}
|
||||
}
|
22
BM_src/forestry/api/storage/BackpackManager.java
Normal file
22
BM_src/forestry/api/storage/BackpackManager.java
Normal 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>();
|
||||
}
|
18
BM_src/forestry/api/storage/BackpackResupplyEvent.java
Normal file
18
BM_src/forestry/api/storage/BackpackResupplyEvent.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
21
BM_src/forestry/api/storage/BackpackStowEvent.java
Normal file
21
BM_src/forestry/api/storage/BackpackStowEvent.java
Normal 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;
|
||||
}
|
||||
}
|
5
BM_src/forestry/api/storage/EnumBackpackType.java
Normal file
5
BM_src/forestry/api/storage/EnumBackpackType.java
Normal file
|
@ -0,0 +1,5 @@
|
|||
package forestry.api.storage;
|
||||
|
||||
public enum EnumBackpackType {
|
||||
T1, T2
|
||||
}
|
54
BM_src/forestry/api/storage/IBackpackDefinition.java
Normal file
54
BM_src/forestry/api/storage/IBackpackDefinition.java
Normal 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);
|
||||
|
||||
}
|
19
BM_src/forestry/api/storage/IBackpackInterface.java
Normal file
19
BM_src/forestry/api/storage/IBackpackInterface.java
Normal 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);
|
||||
}
|
3
BM_src/forestry/api/storage/package-info.java
Normal file
3
BM_src/forestry/api/storage/package-info.java
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue