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();
|
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)
|
@SideOnly(Side.CLIENT)
|
||||||
void registerIcons(IIconRegister iconRegister);
|
void registerIcons(IIconRegister iconRegister);
|
||||||
|
|
||||||
|
@ -39,7 +46,7 @@ public interface IStatementParameter {
|
||||||
*/
|
*/
|
||||||
String getDescription();
|
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);
|
void readFromNBT(NBTTagCompound compound);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
@ -158,4 +161,21 @@ public final class StatementManager {
|
||||||
|
|
||||||
return null;
|
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
|
@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) {
|
if (stack != null) {
|
||||||
this.stack = stack.copy();
|
this.stack = stack.copy();
|
||||||
this.stack.stackSize = 1;
|
this.stack.stackSize = 1;
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
package buildcraft.api.transport;
|
package buildcraft.api.transport;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import buildcraft.api.gates.IGate;
|
import buildcraft.api.gates.IGate;
|
||||||
|
|
||||||
public interface IPipe {
|
public interface IPipe {
|
||||||
|
@ -24,4 +23,9 @@ public interface IPipe {
|
||||||
|
|
||||||
IGate getGate(ForgeDirection side);
|
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);
|
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);
|
TileEntity getAdjacentTile(ForgeDirection dir);
|
||||||
|
|
||||||
IPipe getPipe();
|
IPipe getPipe();
|
||||||
|
|
|
@ -447,21 +447,16 @@ public abstract class Pipe<T extends PipeTransport> implements IDropControlInven
|
||||||
public void randomDisplayTick(Random random) {
|
public void randomDisplayTick(Random random) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// / @Override TODO: should be in IPipe
|
@Override
|
||||||
public boolean isWired() {
|
|
||||||
for (PipeWire color : PipeWire.values()) {
|
|
||||||
if (isWired(color)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWired(PipeWire color) {
|
public boolean isWired(PipeWire color) {
|
||||||
return wireSet[color.ordinal()];
|
return wireSet[color.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isWireActive(PipeWire color) {
|
||||||
|
return signalStrength[color.ordinal()] > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean hasGate() {
|
public boolean hasGate() {
|
||||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
|
|
|
@ -512,7 +512,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
||||||
defaultState = state;
|
defaultState = state;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (isWireActive(state.wire)) {
|
if (pipe != null && pipe.isWireActive(state.wire)) {
|
||||||
activeState = state;
|
activeState = state;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -800,14 +800,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
||||||
return pipeConnectionsBuffer[with.ordinal()];
|
return pipeConnectionsBuffer[with.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isWireActive(PipeWire wire) {
|
|
||||||
if (pipe == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return pipe.signalStrength[wire.ordinal()] > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doDrop() {
|
public boolean doDrop() {
|
||||||
if (BlockGenericPipe.isValid(pipe)) {
|
if (BlockGenericPipe.isValid(pipe)) {
|
||||||
|
@ -947,10 +939,6 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui
|
||||||
ItemFacade.getFacade(((ItemFacade.FacadePluggable) pluggable).states) : null;
|
ItemFacade.getFacade(((ItemFacade.FacadePluggable) pluggable).states) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gate getGate(ForgeDirection direction) {
|
|
||||||
return pipe.gates[direction.ordinal()];
|
|
||||||
}
|
|
||||||
|
|
||||||
public DockingStation getStation(ForgeDirection direction) {
|
public DockingStation getStation(ForgeDirection direction) {
|
||||||
IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
|
IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
|
||||||
return pluggable instanceof ItemRobotStation.RobotStationPluggable ?
|
return pluggable instanceof ItemRobotStation.RobotStationPluggable ?
|
||||||
|
|
Loading…
Reference in a new issue