mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 20:52:42 +00:00
Updated RF / coflib API.
This commit is contained in:
1 parent
00b567c494
commit
8ec56a01d2
10 files changed
+93
-97
No files matched your search
@@ -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 {
|
||||
|
||||
public void setPowered(boolean isPowered);
|
||||
|
||||
public boolean isPowered();
|
||||
|
||||
}
|
||||
@@ -1,27 +1,57 @@
|
||||
package cofh.api.tileentity;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which have redstone control functionality.
|
||||
* 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 {
|
||||
public interface IRedstoneControl extends IRedstoneCache {
|
||||
|
||||
public boolean getControlDisable();
|
||||
public static enum ControlMode {
|
||||
DISABLED(true), LOW(false), HIGH(true);
|
||||
|
||||
public boolean getControlSetting();
|
||||
private final boolean state;
|
||||
|
||||
public boolean setControlDisable(boolean disable);
|
||||
private ControlMode(boolean state) {
|
||||
|
||||
public boolean setControlSetting(boolean state);
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public boolean setRedstoneConfig(boolean disable, boolean state);
|
||||
public boolean isDisabled() {
|
||||
|
||||
public boolean isPowered();
|
||||
return this == DISABLED;
|
||||
}
|
||||
|
||||
public void handlePowerUpdate(boolean powered);
|
||||
public boolean isLow() {
|
||||
|
||||
public void handleConfigUpdate(boolean disable, boolean state);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public void setControl(ControlMode control);
|
||||
|
||||
public ControlMode getControl();
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package cofh.api.transport;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface to explicitly control sided Item Conduit connections for a Tile Entity.
|
||||
*
|
||||
* @author Zeldo Kavira
|
||||
*
|
||||
*/
|
||||
public interface IItemConduitConnection {
|
||||
|
||||
public boolean canConduitConnect(ForgeDirection side);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import cofh.api.transport.IItemConduit;
|
||||
import cofh.api.transport.IItemDuct;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
@@ -16,7 +16,7 @@ import crazypants.enderio.conduit.geom.Offset;
|
||||
import crazypants.enderio.power.IInternalPowerReceptor;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler, IItemConduit {
|
||||
public interface IConduitBundle extends IInternalPowerReceptor, IFluidHandler, IItemDuct {
|
||||
|
||||
TileEntity getEntity();
|
||||
|
||||
|
||||
@@ -747,24 +747,6 @@ public class TileConduitBundle extends TileEntityEio implements IConduitBundle {
|
||||
|
||||
// ---- TE Item Conduits
|
||||
|
||||
@Override
|
||||
public ItemStack sendItems(ItemStack item, ForgeDirection side) {
|
||||
IItemConduit ic = getConduit(IItemConduit.class);
|
||||
if(ic != null) {
|
||||
return ic.sendItems(item, side);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(ForgeDirection from, ItemStack item, boolean simulate) {
|
||||
IItemConduit ic = getConduit(IItemConduit.class);
|
||||
if(ic != null) {
|
||||
return ic.insertItem(from, item, simulate);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(ForgeDirection from, ItemStack item) {
|
||||
IItemConduit ic = getConduit(IItemConduit.class);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package crazypants.enderio.conduit.item;
|
||||
|
||||
import cofh.api.transport.IItemDuct;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -7,7 +8,7 @@ import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.IExtractor;
|
||||
import crazypants.util.DyeColor;
|
||||
|
||||
public interface IItemConduit extends IConduit, cofh.api.transport.IItemConduit, IExtractor {
|
||||
public interface IItemConduit extends IConduit, IItemDuct, IExtractor {
|
||||
|
||||
IIcon getTextureForInputMode();
|
||||
|
||||
|
||||
@@ -162,12 +162,7 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack sendItems(ItemStack item, ForgeDirection side) {
|
||||
return insertItem(side, item, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(ForgeDirection from, ItemStack item, boolean simulate) {
|
||||
public ItemStack insertItem(ForgeDirection from, ItemStack item) {
|
||||
if(!externalConnections.contains(from)) {
|
||||
return item;
|
||||
} else if(!getConectionMode(from).acceptsInput()) {
|
||||
@@ -175,18 +170,10 @@ public class ItemConduit extends AbstractConduit implements IItemConduit {
|
||||
} else if(network == null) {
|
||||
return item;
|
||||
}
|
||||
if(simulate) {
|
||||
Log.error("Unsupported, deprecated method called. No item will transfer.");
|
||||
return item;
|
||||
}
|
||||
|
||||
return network.sendItems(this, item, from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack insertItem(ForgeDirection from, ItemStack item) {
|
||||
return insertItem(from, item, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputFilter(ForgeDirection dir, ItemFilter filter) {
|
||||
inputFilters.put(dir, filter);
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import cofh.api.transport.IItemConduit;
|
||||
import cofh.api.transport.IItemDuct;
|
||||
|
||||
public class ItemUtil {
|
||||
|
||||
@@ -34,15 +34,15 @@ public class ItemUtil {
|
||||
return ItemUtil.doInsertItem((ISidedInventory) into, item, side);
|
||||
} else if(into instanceof IInventory) {
|
||||
return ItemUtil.doInsertItem(getInventory((IInventory) into), item);
|
||||
} else if(into instanceof IItemConduit) {
|
||||
return ItemUtil.doInsertItem((IItemConduit) into, item, side);
|
||||
} else if(into instanceof IItemDuct) {
|
||||
return ItemUtil.doInsertItem((IItemDuct) into, item, side);
|
||||
} else if(into instanceof IPipeTile) {
|
||||
return ((IPipeTile) into).injectItem(item, true, side);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int doInsertItem(IItemConduit con, ItemStack item, ForgeDirection inventorySide) {
|
||||
public static int doInsertItem(IItemDuct con, ItemStack item, ForgeDirection inventorySide) {
|
||||
int startedWith = item.stackSize;
|
||||
ItemStack remaining = con.insertItem(inventorySide, item);
|
||||
if(remaining == null) {
|
||||
|
||||
Reference in new issue
Block a user