Updated Cofh API
This commit is contained in:
parent
6cd3ae4fea
commit
90c1c690a9
37 changed files with 1026 additions and 100 deletions
|
@ -1,11 +1,14 @@
|
||||||
package cofh.api.block;
|
package cofh.api.block;
|
||||||
|
|
||||||
|
import cofh.api.tileentity.ITileDebug;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement this interface on blocks which have some debug method which can be activated via a tool or other means.
|
* Implement this interface on blocks which have some debug method which can be activated via a tool or other means. If the block contains Tile Entities, then
|
||||||
|
* it is recommended that this function serve as a passthrough for {@link ITileDebug}.
|
||||||
*
|
*
|
||||||
* @author King Lemming
|
* @author King Lemming
|
||||||
*
|
*
|
||||||
|
@ -28,6 +31,6 @@ public interface IBlockDebug {
|
||||||
* @param player
|
* @param player
|
||||||
* Player doing the debugging.
|
* Player doing the debugging.
|
||||||
*/
|
*/
|
||||||
public void debugBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side, EntityPlayer player);
|
void debugBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side, EntityPlayer player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package cofh.api.block;
|
package cofh.api.block;
|
||||||
|
|
||||||
|
import cofh.api.tileentity.ITileInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -7,7 +9,8 @@ import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement this interface on blocks which can provide information about themselves.
|
* Implement this interface on blocks which can provide information about themselves. If the block contains Tile Entities, then it is recommended that this
|
||||||
|
* function serve as a passthrough for {@link ITileInfo}.
|
||||||
*
|
*
|
||||||
* @author King Lemming
|
* @author King Lemming
|
||||||
*
|
*
|
||||||
|
@ -32,8 +35,8 @@ public interface IBlockInfo {
|
||||||
* @param info
|
* @param info
|
||||||
* The list that the information should be appended to.
|
* The list that the information should be appended to.
|
||||||
* @param debug
|
* @param debug
|
||||||
* If true, the Block should return "debug" information.
|
* If true, the block should return "debug" information.
|
||||||
*/
|
*/
|
||||||
public void getBlockInfo(IBlockAccess world, int x, int y, int z, ForgeDirection side, EntityPlayer player, List<String> info, boolean debug);
|
void getBlockInfo(IBlockAccess world, int x, int y, int z, ForgeDirection side, EntityPlayer player, List<String> info, boolean debug);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,11 @@ public interface IDismantleable {
|
||||||
/**
|
/**
|
||||||
* Dismantles the block. If returnBlock is true, the drop(s) should be placed into the player's inventory.
|
* Dismantles the block. If returnBlock is true, the drop(s) should be placed into the player's inventory.
|
||||||
*/
|
*/
|
||||||
public ItemStack dismantleBlock(EntityPlayer player, World world, int x, int y, int z, boolean returnBlock);
|
ItemStack dismantleBlock(EntityPlayer player, World world, int x, int y, int z, boolean returnBlock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the block can be dismantled. The criteria for this is entirely up to the block.
|
* Return true if the block can be dismantled. The criteria for this is entirely up to the block.
|
||||||
*/
|
*/
|
||||||
public boolean canDismantle(EntityPlayer player, World world, int x, int y, int z);
|
boolean canDismantle(EntityPlayer player, World world, int x, int y, int z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
17
src/main/java/cofh/api/core/IInitializer.java
Normal file
17
src/main/java/cofh/api/core/IInitializer.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package cofh.api.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface which can be put on just about anything to allow for iteration during initialization.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IInitializer {
|
||||||
|
|
||||||
|
boolean preInit();
|
||||||
|
|
||||||
|
boolean initialize();
|
||||||
|
|
||||||
|
boolean postInit();
|
||||||
|
|
||||||
|
}
|
21
src/main/java/cofh/api/energy/IEnergyConnection.java
Normal file
21
src/main/java/cofh/api/energy/IEnergyConnection.java
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package cofh.api.energy;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
|
||||||
|
* accept it; otherwise just use IEnergyHandler.
|
||||||
|
*
|
||||||
|
* Note that {@link IEnergyHandler} is an extension of this.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IEnergyConnection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if the TileEntity can connect on a given side.
|
||||||
|
*/
|
||||||
|
boolean canConnectEnergy(ForgeDirection from);
|
||||||
|
|
||||||
|
}
|
|
@ -3,14 +3,14 @@ package cofh.api.energy;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement this interface on TileEntities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
* Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||||
*
|
*
|
||||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||||
*
|
*
|
||||||
* @author King Lemming
|
* @author King Lemming
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IEnergyHandler {
|
public interface IEnergyHandler extends IEnergyConnection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
* Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
||||||
|
@ -38,11 +38,6 @@ public interface IEnergyHandler {
|
||||||
*/
|
*/
|
||||||
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
|
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the Handler functions on a given side - if a Tile Entity can receive or send energy on a given side, this should return true.
|
|
||||||
*/
|
|
||||||
boolean canInterface(ForgeDirection from);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount of energy currently stored.
|
* Returns the amount of energy currently stored.
|
||||||
*/
|
*/
|
||||||
|
|
110
src/main/java/cofh/api/energy/ItemEnergyContainer.java
Normal file
110
src/main/java/cofh/api/energy/ItemEnergyContainer.java
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
package cofh.api.energy;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||||
|
|
||||||
|
protected int capacity;
|
||||||
|
protected int maxReceive;
|
||||||
|
protected int maxExtract;
|
||||||
|
|
||||||
|
public ItemEnergyContainer() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemEnergyContainer(int capacity) {
|
||||||
|
|
||||||
|
this(capacity, capacity, capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemEnergyContainer(int capacity, int maxTransfer) {
|
||||||
|
|
||||||
|
this(capacity, maxTransfer, maxTransfer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {
|
||||||
|
|
||||||
|
this.capacity = capacity;
|
||||||
|
this.maxReceive = maxReceive;
|
||||||
|
this.maxExtract = maxExtract;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemEnergyContainer setCapacity(int capacity) {
|
||||||
|
|
||||||
|
this.capacity = capacity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxTransfer(int maxTransfer) {
|
||||||
|
|
||||||
|
setMaxReceive(maxTransfer);
|
||||||
|
setMaxExtract(maxTransfer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxReceive(int maxReceive) {
|
||||||
|
|
||||||
|
this.maxReceive = maxReceive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxExtract(int maxExtract) {
|
||||||
|
|
||||||
|
this.maxExtract = maxExtract;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IEnergyContainerItem */
|
||||||
|
@Override
|
||||||
|
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||||
|
|
||||||
|
if (container.stackTagCompound == null) {
|
||||||
|
container.stackTagCompound = new NBTTagCompound();
|
||||||
|
}
|
||||||
|
int energy = container.stackTagCompound.getInteger("Energy");
|
||||||
|
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||||
|
|
||||||
|
if (!simulate) {
|
||||||
|
energy += energyReceived;
|
||||||
|
container.stackTagCompound.setInteger("Energy", energy);
|
||||||
|
}
|
||||||
|
return energyReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||||
|
|
||||||
|
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int energy = container.stackTagCompound.getInteger("Energy");
|
||||||
|
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||||
|
|
||||||
|
if (!simulate) {
|
||||||
|
energy -= energyExtracted;
|
||||||
|
container.stackTagCompound.setInteger("Energy", energy);
|
||||||
|
}
|
||||||
|
return energyExtracted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnergyStored(ItemStack container) {
|
||||||
|
|
||||||
|
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return container.stackTagCompound.getInteger("Energy");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxEnergyStored(ItemStack container) {
|
||||||
|
|
||||||
|
return capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -29,6 +29,12 @@ public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IEnergyHandler */
|
/* IEnergyHandler */
|
||||||
|
@Override
|
||||||
|
public boolean canConnectEnergy(ForgeDirection from) {
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||||
|
|
||||||
|
@ -41,12 +47,6 @@ public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
|
||||||
return storage.extractEnergy(maxExtract, simulate);
|
return storage.extractEnergy(maxExtract, simulate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInterface(ForgeDirection from) {
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyStored(ForgeDirection from) {
|
public int getEnergyStored(ForgeDirection from) {
|
||||||
|
|
||||||
|
|
41
src/main/java/cofh/api/item/IEmpowerableItem.java
Normal file
41
src/main/java/cofh/api/item/IEmpowerableItem.java
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
package cofh.api.item;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Item classes which may be "Empowered" - what that means is completely up to you. This just provides a uniform way of dealing with
|
||||||
|
* them.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IEmpowerableItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether or not a given item is currently in an empowered state.
|
||||||
|
*/
|
||||||
|
boolean isEmpowered(ItemStack stack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to set the empowered state of the item.
|
||||||
|
*
|
||||||
|
* @param stack
|
||||||
|
* ItemStack to be empowered/disempowered.
|
||||||
|
* @param state
|
||||||
|
* Desired state.
|
||||||
|
* @return TRUE if the operation was successful, FALSE if it was not.
|
||||||
|
*/
|
||||||
|
boolean setEmpoweredState(ItemStack stack, boolean state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback method for reacting to a state change. Useful in KeyBinding handlers.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* Player holding the item, if applicable.
|
||||||
|
* @param stack
|
||||||
|
* The item being held.
|
||||||
|
*/
|
||||||
|
void onStateChange(EntityPlayer player, ItemStack stack);
|
||||||
|
|
||||||
|
}
|
20
src/main/java/cofh/api/item/IInventoryConnection.java
Normal file
20
src/main/java/cofh/api/item/IInventoryConnection.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package cofh.api.item;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on TileEntities which should connect to item transportation blocks.
|
||||||
|
*
|
||||||
|
* Note that {@link IInventoryHandler} is an extension of this.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IInventoryConnection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns TRUE if the TileEntity can connect on a given side.
|
||||||
|
*/
|
||||||
|
boolean canConnectInventory(ForgeDirection from);
|
||||||
|
|
||||||
|
}
|
78
src/main/java/cofh/api/item/IInventoryContainerItem.java
Normal file
78
src/main/java/cofh/api/item/IInventoryContainerItem.java
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
package cofh.api.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Item classes that are themselves inventories.
|
||||||
|
*
|
||||||
|
* A reference implementation is provided {@link ItemInventoryContainer}.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IInventoryContainerItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an ItemStack to the inventory of this container item. This returns what is remaining of the original stack - a null return means that the entire
|
||||||
|
* stack was accepted!
|
||||||
|
*
|
||||||
|
* @param container
|
||||||
|
* ItemStack with the inventory.
|
||||||
|
* @param item
|
||||||
|
* ItemStack to be inserted. The size of this stack corresponds to the maximum amount to insert.
|
||||||
|
* @param simulate
|
||||||
|
* If TRUE, the insertion will only be simulated.
|
||||||
|
* @return An ItemStack representing how much is remaining after the item was inserted (or would have been, if simulated) into the container inventory.
|
||||||
|
*/
|
||||||
|
ItemStack insertItem(ItemStack container, ItemStack item, boolean simulate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract an ItemStack from the inventory of this container item. This returns the resulting stack - a null return means that nothing was extracted!
|
||||||
|
*
|
||||||
|
* @param container
|
||||||
|
* ItemStack with the inventory.
|
||||||
|
* @param item
|
||||||
|
* ItemStack to be extracted. The size of this stack corresponds to the maximum amount to extract. If this is null, then a null ItemStack should
|
||||||
|
* immediately be returned.
|
||||||
|
* @param simulate
|
||||||
|
* If TRUE, the extraction will only be simulated.
|
||||||
|
* @return An ItemStack representing how much was extracted (or would have been, if simulated) from the container inventory.
|
||||||
|
*/
|
||||||
|
ItemStack extractItem(ItemStack container, ItemStack item, boolean simulate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract an ItemStack from the inventory of this container item. This returns the resulting stack - a null return means that nothing was extracted!
|
||||||
|
*
|
||||||
|
* @param container
|
||||||
|
* ItemStack with the inventory.
|
||||||
|
* @param maxExtract
|
||||||
|
* Maximum number of items to extract. (The returned ItemStack should have a stackSize no higher than this.)
|
||||||
|
* @param simulate
|
||||||
|
* If TRUE, the extraction will only be simulated.
|
||||||
|
* @return An ItemStack representing how much was extracted (or would have been, if simulated) from the container inventory.
|
||||||
|
*/
|
||||||
|
ItemStack extractItem(ItemStack container, int maxExtract, boolean simulate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of the container item's inventory. This should only return non-null ItemStacks, and an empty List if the inventory has nothing.
|
||||||
|
*/
|
||||||
|
List<ItemStack> getInventoryContents(ItemStack container);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the size of this inventory of this container item.
|
||||||
|
*/
|
||||||
|
int getSizeInventory(ItemStack container);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the container item's inventory is empty.
|
||||||
|
*/
|
||||||
|
boolean isEmpty(ItemStack container);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the container item's inventory is full.
|
||||||
|
*/
|
||||||
|
boolean isFull(ItemStack container);
|
||||||
|
|
||||||
|
}
|
82
src/main/java/cofh/api/item/IInventoryHandler.java
Normal file
82
src/main/java/cofh/api/item/IInventoryHandler.java
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
package cofh.api.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on TileEntities which should handle items.
|
||||||
|
*
|
||||||
|
* A reference implementation is provided {@link TileInventoryHandler}.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IInventoryHandler extends IInventoryConnection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert an ItemStack into the IInventoryHandler, internal distribution is left entirely to the IInventoryHandler. This returns what is remaining of the
|
||||||
|
* original stack - a null return means that the entire stack was accepted!
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
* Orientation the item is inserted from.
|
||||||
|
* @param item
|
||||||
|
* ItemStack to be inserted. The size of this stack corresponds to the maximum amount to insert.
|
||||||
|
* @param simulate
|
||||||
|
* If TRUE, the insertion will only be simulated.
|
||||||
|
* @return An ItemStack representing how much is remaining after the item was inserted (or would have been, if simulated) into the container inventory.
|
||||||
|
*/
|
||||||
|
ItemStack insertItem(ForgeDirection from, ItemStack item, boolean simulate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract an ItemStack from an IInventoryHandler, internal distribution is left entirely to the IInventoryHandler. This returns the resulting stack - a
|
||||||
|
* null return means that nothing was extracted!
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
* Orientation the item is extracted from.
|
||||||
|
* @param item
|
||||||
|
* ItemStack to be extracted. The size of this stack corresponds to the maximum amount to extract. If this is null, then a null ItemStack should
|
||||||
|
* immediately be returned.
|
||||||
|
* @param simulate
|
||||||
|
* If TRUE, the extraction will only be simulated.
|
||||||
|
* @return An ItemStack representing how much was extracted (or would have been, if simulated) from the container inventory.
|
||||||
|
*/
|
||||||
|
ItemStack extractItem(ForgeDirection from, ItemStack item, boolean simulate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract an ItemStack from an IInventoryHandler, internal distribution is left entirely to the IInventoryHandler. This returns the resulting stack - a
|
||||||
|
* null return means that nothing was extracted!
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
* Orientation the item is extracted from.
|
||||||
|
* @param maxExtract
|
||||||
|
* Maximum number of items to extract. (The returned ItemStack should have a stackSize no higher than this.)
|
||||||
|
* @param simulate
|
||||||
|
* If TRUE, the extraction will only be simulated.
|
||||||
|
* @return An ItemStack representing how much was extracted (or would have been, if simulated) from the container inventory.
|
||||||
|
*/
|
||||||
|
ItemStack extractItem(ForgeDirection from, int maxExtract, boolean simulate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the contents of the IInventoryHandler's inventory. This returns a COPY. This should only return non-null ItemStacks, and an empty List if the
|
||||||
|
* inventory has nothing.
|
||||||
|
*/
|
||||||
|
List<ItemStack> getInventoryContents(ForgeDirection from);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the size (number of internal slots) of the IInventoryHandler's inventory.
|
||||||
|
*/
|
||||||
|
int getSizeInventory(ForgeDirection from);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the IInventoryHandler's inventory is empty (for a given side).
|
||||||
|
*/
|
||||||
|
boolean isEmpty(ForgeDirection from);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the IInventoryHandler's inventory is full (for a given side).
|
||||||
|
*/
|
||||||
|
boolean isFull(ForgeDirection from);
|
||||||
|
|
||||||
|
}
|
26
src/main/java/cofh/api/item/ISecureItem.java
Normal file
26
src/main/java/cofh/api/item/ISecureItem.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package cofh.api.item;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Item classes which are Secure - linked to a specific player or group of players.
|
||||||
|
*
|
||||||
|
* Obviously, this relies on people using this interface properly. The Wheaton Rule is in effect here - don't be a jerk.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ISecureItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether or not a given player can use this item.
|
||||||
|
*/
|
||||||
|
boolean canPlayerAccess(ItemStack stack, EntityPlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Owner of this item. This function is intentionally nebulous and is not guaranteed to be a player name.
|
||||||
|
*/
|
||||||
|
String getOwnerString();
|
||||||
|
|
||||||
|
}
|
33
src/main/java/cofh/api/item/ITinkerableItem.java
Normal file
33
src/main/java/cofh/api/item/ITinkerableItem.java
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
package cofh.api.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Item classes which can be externally modified through tinkering.
|
||||||
|
*
|
||||||
|
* Basically a catch all for "upgrading" a given ItemStack, which may represent an Item or a Block.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ITinkerableItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of valid ItemStacks which may be used to upgrade this Tinkerable.
|
||||||
|
*/
|
||||||
|
List<ItemStack> getValidTinkers(ItemStack container);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a tinker to this item.
|
||||||
|
*
|
||||||
|
* @param container
|
||||||
|
* The ItemStack (Tinkerable) to which the tinker is being applied.
|
||||||
|
* @param tinker
|
||||||
|
* The ItemStack representing the upgrade.
|
||||||
|
* @return True if the application was successful, false if it was not.
|
||||||
|
*/
|
||||||
|
boolean applyTinker(ItemStack container, ItemStack tinker);
|
||||||
|
|
||||||
|
}
|
28
src/main/java/cofh/api/tileentity/IAugmentableTile.java
Normal file
28
src/main/java/cofh/api/tileentity/IAugmentableTile.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implemented on TileEntities which support Augments.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IAugmentableTile {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to reconfigure the tile based on the Augmentations present. Return TRUE if it was successful; FALSE if a condition was not met.
|
||||||
|
*/
|
||||||
|
boolean augmentTile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of the Augment slots for this Tile Entity.
|
||||||
|
*/
|
||||||
|
ItemStack[] getAugmentSlots();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a status array for the Augmentations installed in the Tile Entity.
|
||||||
|
*/
|
||||||
|
boolean[] getAugmentStatus();
|
||||||
|
|
||||||
|
}
|
33
src/main/java/cofh/api/tileentity/IEnergyInfo.java
Normal file
33
src/main/java/cofh/api/tileentity/IEnergyInfo.java
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Tile Entities which can report information about their energy usage.
|
||||||
|
*
|
||||||
|
* This is used for reporting purposes - Energy transactions are handled through IEnergyHandler!
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IEnergyInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns energy usage/generation per tick (RF/t).
|
||||||
|
*/
|
||||||
|
int getInfoEnergyPerTick();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns maximum energy usage/generation per tick (RF/t).
|
||||||
|
*/
|
||||||
|
int getInfoMaxEnergyPerTick();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns energy stored (RF).
|
||||||
|
*/
|
||||||
|
int getInfoEnergyStored();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns maximum energy stored (RF).
|
||||||
|
*/
|
||||||
|
int getInfoMaxEnergyStored();
|
||||||
|
|
||||||
|
}
|
39
src/main/java/cofh/api/tileentity/IReconfigurableFacing.java
Normal file
39
src/main/java/cofh/api/tileentity/IReconfigurableFacing.java
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Tile Entities which allow for reconfiguration of their facing.
|
||||||
|
*
|
||||||
|
* Coordination with the containing block is required.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IReconfigurableFacing {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current facing of the block.
|
||||||
|
*/
|
||||||
|
int getFacing();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not the block's face can be aligned with the Y Axis.
|
||||||
|
*/
|
||||||
|
boolean allowYAxisFacing();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to rotate the block. Arbitrary based on implementation.
|
||||||
|
*
|
||||||
|
* @return True if rotation was successful, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean rotateBlock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the facing of the block.
|
||||||
|
*
|
||||||
|
* @param side
|
||||||
|
* The side to set the facing to.
|
||||||
|
* @return True if the facing was set, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean setFacing(int side);
|
||||||
|
|
||||||
|
}
|
54
src/main/java/cofh/api/tileentity/IReconfigurableSides.java
Normal file
54
src/main/java/cofh/api/tileentity/IReconfigurableSides.java
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Tile Entities which allow for reconfiguration of their sides.
|
||||||
|
*
|
||||||
|
* Coordination with the containing block is required.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IReconfigurableSides {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrement the config for a given side.
|
||||||
|
*
|
||||||
|
* @param side
|
||||||
|
* The side to decrement.
|
||||||
|
* @return True if config was changed, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean decrSide(int side);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increment the config for a given side.
|
||||||
|
*
|
||||||
|
* @param side
|
||||||
|
* The side to decrement.
|
||||||
|
* @return True if config was changed, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean incrSide(int side);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the config for a given side.
|
||||||
|
*
|
||||||
|
* @param side
|
||||||
|
* The side to set.
|
||||||
|
* @param config
|
||||||
|
* The config value to use.
|
||||||
|
* @return True of config was set, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean setSide(int side, int config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset configs on all sides to their base values.
|
||||||
|
*
|
||||||
|
* @return True if reset was successful, false otherwise.
|
||||||
|
*/
|
||||||
|
boolean resetSides();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of possible config settings for a given side.
|
||||||
|
*/
|
||||||
|
int getNumConfig(int side);
|
||||||
|
|
||||||
|
}
|
17
src/main/java/cofh/api/tileentity/IRedstoneCache.java
Normal file
17
src/main/java/cofh/api/tileentity/IRedstoneCache.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Tile Entities which cache their redstone status.
|
||||||
|
*
|
||||||
|
* Note that {@link IRedstoneControl} is an extension of this.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IRedstoneCache {
|
||||||
|
|
||||||
|
void setPowered(boolean isPowered);
|
||||||
|
|
||||||
|
boolean isPowered();
|
||||||
|
|
||||||
|
}
|
57
src/main/java/cofh/api/tileentity/IRedstoneControl.java
Normal file
57
src/main/java/cofh/api/tileentity/IRedstoneControl.java
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Tile Entities which have Redstone Control functionality. This means that a tile can be set to ignore redstone entirely, or
|
||||||
|
* respond to a low or high redstone state.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IRedstoneControl extends IRedstoneCache {
|
||||||
|
|
||||||
|
public static enum ControlMode {
|
||||||
|
DISABLED(true), LOW(false), HIGH(true);
|
||||||
|
|
||||||
|
private final boolean state;
|
||||||
|
|
||||||
|
private ControlMode(boolean state) {
|
||||||
|
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisabled() {
|
||||||
|
|
||||||
|
return this == DISABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLow() {
|
||||||
|
|
||||||
|
return this == LOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHigh() {
|
||||||
|
|
||||||
|
return this == HIGH;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getState() {
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ControlMode stepForward(ControlMode curControl) {
|
||||||
|
|
||||||
|
return curControl == DISABLED ? LOW : curControl == HIGH ? DISABLED : HIGH;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ControlMode stepBackward(ControlMode curControl) {
|
||||||
|
|
||||||
|
return curControl == DISABLED ? HIGH : curControl == HIGH ? LOW : DISABLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setControl(ControlMode control);
|
||||||
|
|
||||||
|
ControlMode getControl();
|
||||||
|
|
||||||
|
}
|
56
src/main/java/cofh/api/tileentity/ISecureTile.java
Normal file
56
src/main/java/cofh/api/tileentity/ISecureTile.java
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Tile Entities which have access restrictions.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ISecureTile {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum for Access Modes - Restricted is Friends Only, Private is Owner only.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static enum AccessMode {
|
||||||
|
PUBLIC, RESTRICTED, PRIVATE;
|
||||||
|
|
||||||
|
public boolean isPublic() {
|
||||||
|
|
||||||
|
return this == PUBLIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRestricted() {
|
||||||
|
|
||||||
|
return this == RESTRICTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPrivate() {
|
||||||
|
|
||||||
|
return this == PRIVATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AccessMode stepForward(AccessMode curAccess) {
|
||||||
|
|
||||||
|
return curAccess == PUBLIC ? RESTRICTED : curAccess == PRIVATE ? PUBLIC : PRIVATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AccessMode stepBackward(AccessMode curAccess) {
|
||||||
|
|
||||||
|
return curAccess == PUBLIC ? PRIVATE : curAccess == PRIVATE ? RESTRICTED : PUBLIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean setAccess(AccessMode access);
|
||||||
|
|
||||||
|
boolean setOwnerName(String name);
|
||||||
|
|
||||||
|
AccessMode getAccess();
|
||||||
|
|
||||||
|
String getOwnerName();
|
||||||
|
|
||||||
|
boolean canPlayerAccess(String name);
|
||||||
|
|
||||||
|
}
|
25
src/main/java/cofh/api/tileentity/ISidedTexture.java
Normal file
25
src/main/java/cofh/api/tileentity/ISidedTexture.java
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Tile Entities which can change their block's texture based on the current render pass. The block must defer the call to its Tile
|
||||||
|
* Entity.
|
||||||
|
*
|
||||||
|
* @author Zeldo Kavira
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ISidedTexture {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the icon to use for a given side and render pass.
|
||||||
|
*
|
||||||
|
* @param side
|
||||||
|
* Block side to get the texture for.
|
||||||
|
* @param pass
|
||||||
|
* Render pass.
|
||||||
|
* @return The icon to use.
|
||||||
|
*/
|
||||||
|
IIcon getTexture(int side, int pass);
|
||||||
|
|
||||||
|
}
|
27
src/main/java/cofh/api/tileentity/ITileDebug.java
Normal file
27
src/main/java/cofh/api/tileentity/ITileDebug.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
import cofh.api.block.IBlockDebug;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Tile Entities which can be debugged via some in-game method, such as a tool. The containing block should be an instance of
|
||||||
|
* {@link IBlockDebug} and defer the call to the tile.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ITileDebug {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function debugs a tile entity.
|
||||||
|
*
|
||||||
|
* @param side
|
||||||
|
* The side of the block.
|
||||||
|
* @param player
|
||||||
|
* Player doing the debugging.
|
||||||
|
*/
|
||||||
|
void debugTile(ForgeDirection side, EntityPlayer player);
|
||||||
|
|
||||||
|
}
|
33
src/main/java/cofh/api/tileentity/ITileInfo.java
Normal file
33
src/main/java/cofh/api/tileentity/ITileInfo.java
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
package cofh.api.tileentity;
|
||||||
|
|
||||||
|
import cofh.api.block.IBlockInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface on Tile Entities which can provide information about themselves. The containing block should be an instance of {@link IBlockInfo}
|
||||||
|
* and defer the call to the tile.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ITileInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function appends information to a list provided to it.
|
||||||
|
*
|
||||||
|
* @param info
|
||||||
|
* The list that the information should be appended to.
|
||||||
|
* @param side
|
||||||
|
* The side of the block that is being queried.
|
||||||
|
* @param player
|
||||||
|
* Player doing the querying - this can be NULL.
|
||||||
|
* @param debug
|
||||||
|
* If true, the tile should return "debug" information.
|
||||||
|
*/
|
||||||
|
void getTileInfo(List<String> info, ForgeDirection side, EntityPlayer player, boolean debug);
|
||||||
|
|
||||||
|
}
|
|
@ -1,50 +1,13 @@
|
||||||
package cofh.api.transport;
|
package cofh.api.transport;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
interface IEnderAttuned {
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
|
|
||||||
public interface IEnderAttuned {
|
public String getOwnerString();
|
||||||
|
|
||||||
public enum EnderTypes {
|
public int getFrequency();
|
||||||
ITEM, FLUID, REDSTONE_FLUX
|
|
||||||
}
|
|
||||||
|
|
||||||
String getOwnerString();
|
|
||||||
|
|
||||||
int getFrequency();
|
|
||||||
|
|
||||||
public boolean setFrequency(int frequency);
|
public boolean setFrequency(int frequency);
|
||||||
|
|
||||||
public boolean clearFrequency();
|
public boolean clearFrequency();
|
||||||
|
|
||||||
boolean canSendItems();
|
|
||||||
|
|
||||||
boolean canSendFluid();
|
|
||||||
|
|
||||||
boolean canSendEnergy();
|
|
||||||
|
|
||||||
boolean canReceiveItems();
|
|
||||||
|
|
||||||
boolean canReceiveFluid();
|
|
||||||
|
|
||||||
boolean canReceiveEnergy();
|
|
||||||
|
|
||||||
boolean currentlyValidToReceiveItems(IEnderAttuned asker);
|
|
||||||
|
|
||||||
boolean currentlyValidToReceiveFluid(IEnderAttuned asker);
|
|
||||||
|
|
||||||
boolean currentlyValidToReceiveEnergy(IEnderAttuned asker);
|
|
||||||
|
|
||||||
boolean currentlyValidToSendItems(IEnderAttuned asker);
|
|
||||||
|
|
||||||
boolean currentlyValidToSendFluid(IEnderAttuned asker);
|
|
||||||
|
|
||||||
boolean currentlyValidToSendEnergy(IEnderAttuned asker);
|
|
||||||
|
|
||||||
ItemStack receiveItem(ItemStack item);
|
|
||||||
|
|
||||||
FluidStack receiveFluid(FluidStack fluid, boolean doFill);
|
|
||||||
|
|
||||||
int receiveEnergy(int energy, boolean simulate);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
35
src/main/java/cofh/api/transport/IEnderEnergyHandler.java
Normal file
35
src/main/java/cofh/api/transport/IEnderEnergyHandler.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package cofh.api.transport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface is implemented on Ender Attuned objects which can receive Energy (Redstone Flux).
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IEnderEnergyHandler extends IEnderAttuned {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether or not the Ender Attuned object can currently send energy (Redstone Flux).
|
||||||
|
*/
|
||||||
|
boolean canSendEnergy();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should be checked to see if the Ender Attuned object can currently receive energy (Redstone Flux).
|
||||||
|
*
|
||||||
|
* Note: In practice, this can (and should) be used to ensure that something does not send to itself.
|
||||||
|
*/
|
||||||
|
boolean canReceiveEnergy();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This tells the Ender Attuned object to receive energy. This returns the amount remaining, *not* the amount received - a return of 0 means that all energy
|
||||||
|
* was received!
|
||||||
|
*
|
||||||
|
* @param energy
|
||||||
|
* Amount of energy to be received.
|
||||||
|
* @param simulate
|
||||||
|
* If TRUE, the result will only be simulated.
|
||||||
|
* @return Amount of energy that is remaining (or would be remaining, if simulated).
|
||||||
|
*/
|
||||||
|
int receiveEnergy(int energy, boolean simulate);
|
||||||
|
|
||||||
|
}
|
37
src/main/java/cofh/api/transport/IEnderFluidHandler.java
Normal file
37
src/main/java/cofh/api/transport/IEnderFluidHandler.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package cofh.api.transport;
|
||||||
|
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface is implemented on Ender Attuned objects which can receive Fluid.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IEnderFluidHandler extends IEnderAttuned {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether or not the Ender Attuned object can currently send FluidStacks.
|
||||||
|
*/
|
||||||
|
boolean canSendFluid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should be checked to see if the Ender Attuned object can currently receive a FluidStack.
|
||||||
|
*
|
||||||
|
* Note: In practice, this can (and should) be used to ensure that something does not send to itself.
|
||||||
|
*/
|
||||||
|
boolean canReceiveFluid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This tells the Ender Attuned object to receive a FluidStack. This returns what remains of the original stack, *not* the amount received - a null return
|
||||||
|
* means that the entire stack was received!
|
||||||
|
*
|
||||||
|
* @param fluid
|
||||||
|
* FluidStack to be received.
|
||||||
|
* @param simulate
|
||||||
|
* If TRUE, the result will only be simulated.
|
||||||
|
* @return FluidStack representing how much fluid is remaining (or would be remaining, if simulated).
|
||||||
|
*/
|
||||||
|
FluidStack receiveFluid(FluidStack fluid, boolean simulate);
|
||||||
|
|
||||||
|
}
|
38
src/main/java/cofh/api/transport/IEnderItemHandler.java
Normal file
38
src/main/java/cofh/api/transport/IEnderItemHandler.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package cofh.api.transport;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface is implemented on Ender Attuned objects which can receive Items.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IEnderItemHandler extends IEnderAttuned {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether or not the Ender Attuned object can currently send ItemStacks.
|
||||||
|
*/
|
||||||
|
boolean canSendItems();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should be checked to see if the Ender Attuned object can currently receive an ItemStack.
|
||||||
|
*
|
||||||
|
* Note: In practice, this can (and should) be used to ensure that something does not send to itself.
|
||||||
|
*/
|
||||||
|
boolean canReceiveItems();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This tells the Ender Attuned object to receive an ItemStack. This returns what remains of the original stack, *not* the amount received - a null return
|
||||||
|
* means that the entire stack was received!
|
||||||
|
*
|
||||||
|
* This function does not support simulation because Inventory manipulation in Minecraft is an absolute mess and it would be a computational liability to do
|
||||||
|
* so.
|
||||||
|
*
|
||||||
|
* @param item
|
||||||
|
* ItemStack to be received.
|
||||||
|
* @return An ItemStack representing how much is remaining.
|
||||||
|
*/
|
||||||
|
ItemStack receiveItem(ItemStack item);
|
||||||
|
|
||||||
|
}
|
|
@ -1,32 +0,0 @@
|
||||||
package cofh.api.transport;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface is implemented on Item Conduits. Use it to attempt to eject items into an entry point.
|
|
||||||
*
|
|
||||||
* @author Zeldo Kavira, King Lemming
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface IItemConduit {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Insert an ItemStack into the IItemConduit. Will only accept items if there is a valid destination. This returns what is remaining of the original stack -
|
|
||||||
* a null return means that the entire stack was accepted/routed!
|
|
||||||
*
|
|
||||||
* @param from
|
|
||||||
* Orientation the item is inserted from.
|
|
||||||
* @param item
|
|
||||||
* ItemStack to be inserted. The size of this stack corresponds to the maximum amount to insert.
|
|
||||||
* @return An ItemStack representing how much is remaining after the item was inserted (or would have been, if simulated) into the Conduit.
|
|
||||||
*/
|
|
||||||
public ItemStack insertItem(ForgeDirection from, ItemStack item);
|
|
||||||
|
|
||||||
/* THE FOLLOWING WILL BE REMOVED IN 3.0.1.X */
|
|
||||||
@Deprecated
|
|
||||||
public ItemStack insertItem(ForgeDirection from, ItemStack item, boolean simulate);
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public ItemStack sendItems(ItemStack item, ForgeDirection from);
|
|
||||||
}
|
|
26
src/main/java/cofh/api/transport/IItemDuct.java
Normal file
26
src/main/java/cofh/api/transport/IItemDuct.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
package cofh.api.transport;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface is implemented on ItemDucts. Use it to attempt to eject items into an entry point.
|
||||||
|
*
|
||||||
|
* @author Zeldo Kavira, King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IItemDuct {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert an ItemStack into the IItemDuct. Will only accept items if there is a valid destination. This returns what is remaining of the original stack - a
|
||||||
|
* null return means that the entire stack was accepted/routed!
|
||||||
|
*
|
||||||
|
* @param from
|
||||||
|
* Orientation the item is inserted from.
|
||||||
|
* @param item
|
||||||
|
* ItemStack to be inserted. The size of this stack corresponds to the maximum amount to insert.
|
||||||
|
* @return An ItemStack representing how much is remaining after the item was inserted into the Duct.
|
||||||
|
*/
|
||||||
|
public ItemStack insertItem(ForgeDirection from, ItemStack item);
|
||||||
|
|
||||||
|
}
|
39
src/main/java/cofh/api/world/IFeatureGenerator.java
Normal file
39
src/main/java/cofh/api/world/IFeatureGenerator.java
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package cofh.api.world;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface should be implemented on classes which define a world feature to be generated in a {@link IFeatureHandler}. It is essentially a more robust
|
||||||
|
* version of {@link WorldGenerator}, and may include one or more WorldGenerators should you wish.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IFeatureGenerator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the feature, used for displaying in the World.cfg file.
|
||||||
|
*/
|
||||||
|
public String getFeatureName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the world feature.
|
||||||
|
*
|
||||||
|
* @param random
|
||||||
|
* Random derived from the world seed.
|
||||||
|
* @param chunkX
|
||||||
|
* Minimum X chunk-coordinate of the chunk. (x16 for block coordinate)
|
||||||
|
* @param chunkZ
|
||||||
|
* Minimum Z chunk-coordinate of the chunk. (x16 for block coordinate)
|
||||||
|
* @param world
|
||||||
|
* The world to generate in.
|
||||||
|
* @param newGen
|
||||||
|
* True on initial generation, false on retrogen.
|
||||||
|
* @return True if generation happened, false otherwise.
|
||||||
|
*/
|
||||||
|
public boolean generateFeature(Random random, int chunkX, int chunkZ, World world, boolean newGen);
|
||||||
|
|
||||||
|
}
|
22
src/main/java/cofh/api/world/IFeatureHandler.java
Normal file
22
src/main/java/cofh/api/world/IFeatureHandler.java
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package cofh.api.world;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an interface to allow for the addition of Features to world generation.
|
||||||
|
*
|
||||||
|
* See {@link IFeatureGenerator}.
|
||||||
|
*
|
||||||
|
* @author King Lemming
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IFeatureHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a feature with an IFeatureHandler.
|
||||||
|
*
|
||||||
|
* @param feature
|
||||||
|
* The feature to register.
|
||||||
|
* @return True if the registration was successful, false if a feature with that name existed.
|
||||||
|
*/
|
||||||
|
public boolean registerFeature(IFeatureGenerator feature);
|
||||||
|
|
||||||
|
}
|
|
@ -267,7 +267,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
||||||
{
|
{
|
||||||
IEnergyHandler handler = (IEnergyHandler)acceptor;
|
IEnergyHandler handler = (IEnergyHandler)acceptor;
|
||||||
|
|
||||||
if(handler.canInterface(side.getOpposite()))
|
if(handler.canConnectEnergy(side.getOpposite()))
|
||||||
{
|
{
|
||||||
if(handler.getMaxEnergyStored(side.getOpposite()) - handler.getEnergyStored(side.getOpposite()) > 0 || handler.receiveEnergy(side.getOpposite(), 1, true) > 0)
|
if(handler.getMaxEnergyStored(side.getOpposite()) - handler.getEnergyStored(side.getOpposite()) > 0 || handler.receiveEnergy(side.getOpposite(), 1, true) > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -269,7 +269,7 @@ public class PartUniversalCable extends PartTransmitter<EnergyNetwork> implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInterface(ForgeDirection from)
|
public boolean canConnectEnergy(ForgeDirection from)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,14 +219,14 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInterface(ForgeDirection from)
|
public boolean canConnectEnergy(ForgeDirection from)
|
||||||
{
|
{
|
||||||
if(getInv() == null)
|
if(getInv() == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getInv().canInterface(from);
|
return getInv().canConnectEnergy(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -258,7 +258,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInterface(ForgeDirection from)
|
public boolean canConnectEnergy(ForgeDirection from)
|
||||||
{
|
{
|
||||||
return getConsumingSides().contains(from) || getOutputtingSides().contains(from);
|
return getConsumingSides().contains(from) || getOutputtingSides().contains(from);
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ public final class CableUtils
|
||||||
{
|
{
|
||||||
return (tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) ||
|
return (tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) ||
|
||||||
(tileEntity instanceof IEnergySource && ((IEnergySource)tileEntity).emitsEnergyTo(tileEntity, side.getOpposite())) ||
|
(tileEntity instanceof IEnergySource && ((IEnergySource)tileEntity).emitsEnergyTo(tileEntity, side.getOpposite())) ||
|
||||||
(tileEntity instanceof IEnergyHandler && ((IEnergyHandler)tileEntity).canInterface(side.getOpposite())) ||
|
(tileEntity instanceof IEnergyHandler && ((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite())) ||
|
||||||
(tileEntity instanceof IPowerEmitter && ((IPowerEmitter)tileEntity).canEmitPowerFrom(side.getOpposite()));
|
(tileEntity instanceof IPowerEmitter && ((IPowerEmitter)tileEntity).canEmitPowerFrom(side.getOpposite()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ public final class CableUtils
|
||||||
}
|
}
|
||||||
else if(tileEntity instanceof IEnergyHandler)
|
else if(tileEntity instanceof IEnergyHandler)
|
||||||
{
|
{
|
||||||
if(((IEnergyHandler)tileEntity).canInterface(side.getOpposite()))
|
if(((IEnergyHandler)tileEntity).canConnectEnergy(side.getOpposite()))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ public final class CableUtils
|
||||||
{
|
{
|
||||||
IEnergyHandler handler = (IEnergyHandler)tileEntity;
|
IEnergyHandler handler = (IEnergyHandler)tileEntity;
|
||||||
|
|
||||||
if(handler.canInterface(side.getOpposite()))
|
if(handler.canConnectEnergy(side.getOpposite()))
|
||||||
{
|
{
|
||||||
int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(sendingEnergy*Mekanism.TO_TE), false);
|
int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(sendingEnergy*Mekanism.TO_TE), false);
|
||||||
sent += used*Mekanism.FROM_TE;
|
sent += used*Mekanism.FROM_TE;
|
||||||
|
|
Loading…
Reference in a new issue