clean up Pipe/PipeTile APIs
This commit is contained in:
parent
c4b0c544cb
commit
bf17bd43fd
7 changed files with 41 additions and 35 deletions
|
@ -31,6 +31,13 @@ public interface IStatementParameter {
|
|||
|
||||
ItemStack getItemStack();
|
||||
|
||||
/**
|
||||
* Something that is initially unintuitive: you HAVE to
|
||||
* keep your icons as static variables, due to the fact
|
||||
* that every IStatementParameter is instantiated upon creation,
|
||||
* in opposition to IStatements which are singletons (due to the
|
||||
* fact that they, unlike Parameters, store no additional data)
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerIcons(IIconRegister iconRegister);
|
||||
|
||||
|
@ -39,7 +46,7 @@ public interface IStatementParameter {
|
|||
*/
|
||||
String getDescription();
|
||||
|
||||
void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton);
|
||||
void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton);
|
||||
|
||||
void readFromNBT(NBTTagCompound compound);
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
|
@ -158,4 +161,21 @@ public final class StatementManager {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generally, this function should be called by every mod implementing
|
||||
* the Statements API ***as a container*** (that is, adding its own gates)
|
||||
* on the client side from a given Item of choice.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerIcons(IIconRegister register) {
|
||||
for (IStatement statement : statements.values()) {
|
||||
statement.registerIcons(register);
|
||||
}
|
||||
|
||||
for (Class<? extends IStatementParameter> parameter : parameters.values()) {
|
||||
System.out.println("registring parameter icons: " + parameter.getCanonicalName());
|
||||
createParameter(parameter).registerIcons(register);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class StatementParameterItemStack implements IStatementParameter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
if (stack != null) {
|
||||
this.stack = stack.copy();
|
||||
this.stack.stackSize = 1;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
package buildcraft.api.transport;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.gates.IGate;
|
||||
|
||||
public interface IPipe {
|
||||
|
@ -24,4 +23,9 @@ public interface IPipe {
|
|||
|
||||
IGate getGate(ForgeDirection side);
|
||||
|
||||
boolean hasGate(ForgeDirection side);
|
||||
|
||||
boolean isWired(PipeWire wire);
|
||||
|
||||
boolean isWireActive(PipeWire wire);
|
||||
}
|
||||
|
|
|
@ -50,14 +50,6 @@ public interface IPipeTile {
|
|||
*/
|
||||
boolean isPipeConnected(ForgeDirection with);
|
||||
|
||||
/**
|
||||
* True if the pipe has a powered wire of the specified color.
|
||||
*
|
||||
* @param wire
|
||||
* @return true if powered
|
||||
*/
|
||||
boolean isWireActive(PipeWire wire);
|
||||
|
||||
TileEntity getAdjacentTile(ForgeDirection dir);
|
||||
|
||||
IPipe getPipe();
|
||||
|
|
|
@ -447,21 +447,16 @@ public abstract class Pipe<T extends PipeTransport> implements IDropControlInven
|
|||
public void randomDisplayTick(Random random) {
|
||||
}
|
||||
|
||||
// / @Override TODO: should be in IPipe
|
||||
public boolean isWired() {
|
||||
for (PipeWire color : PipeWire.values()) {
|
||||
if (isWired(color)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWired(PipeWire color) {
|
||||
return wireSet[color.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWireActive(PipeWire color) {
|
||||
return signalStrength[color.ordinal()] > 0;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean hasGate() {
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
|
|
|
@ -512,7 +512,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
defaultState = state;
|
||||
continue;
|
||||
}
|
||||
if (isWireActive(state.wire)) {
|
||||
if (pipe != null && pipe.isWireActive(state.wire)) {
|
||||
activeState = state;
|
||||
break;
|
||||
}
|
||||
|
@ -800,14 +800,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
return pipeConnectionsBuffer[with.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWireActive(PipeWire wire) {
|
||||
if (pipe == null) {
|
||||
return false;
|
||||
}
|
||||
return pipe.signalStrength[wire.ordinal()] > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDrop() {
|
||||
if (BlockGenericPipe.isValid(pipe)) {
|
||||
|
@ -947,10 +939,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
|||
ItemFacade.getFacade(((ItemFacade.FacadePluggable) pluggable).states) : null;
|
||||
}
|
||||
|
||||
public Gate getGate(ForgeDirection direction) {
|
||||
return pipe.gates[direction.ordinal()];
|
||||
}
|
||||
|
||||
public DockingStation getStation(ForgeDirection direction) {
|
||||
IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
|
||||
return pluggable instanceof ItemRobotStation.RobotStationPluggable ?
|
||||
|
|
Loading…
Reference in a new issue