refactor and add functionality to gate API, for #2107

This commit is contained in:
asiekierka 2014-10-28 06:56:49 +01:00
parent a5758d1bf1
commit 56dd1a6bdd
45 changed files with 313 additions and 225 deletions

View file

@ -8,6 +8,7 @@
*/ */
package buildcraft.api.gates; package buildcraft.api.gates;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
@ -15,22 +16,21 @@ import buildcraft.api.core.NetworkData;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
public class ActionParameterItemStack implements IActionParameter { public class ActionParameterItemStack implements IActionParameter {
@NetworkData @NetworkData
protected ItemStack stack; protected ItemStack stack;
@Override @Override
public ItemStack getItemStackToDraw() { public IIcon getIcon() {
return stack;
}
@Override
public IIcon getIconToDraw() {
return null; return null;
} }
@Override @Override
public void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack, int mouseButton) { public ItemStack getItemStack() {
return stack;
}
@Override
public void onClick(Object 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;
@ -71,4 +71,19 @@ public class ActionParameterItemStack implements IActionParameter {
return ""; return "";
} }
} }
@Override
public String getUniqueTag() {
return "buildcraft:stackAction";
}
@Override
public void registerIcons(IIconRegister iconRegister) {
}
@Override
public IStatementParameter rotateLeft() {
return this;
}
} }

View file

@ -12,7 +12,7 @@ import java.util.Collection;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
public interface IActionProvider { public interface IActionProvider {
@ -26,5 +26,5 @@ public interface IActionProvider {
/** /**
* Returns the list of actions available to a gate next to the given block. * Returns the list of actions available to a gate next to the given block.
*/ */
Collection<IAction> getNeighborActions(Block block, TileEntity tile); Collection<IAction> getNeighborActions(ForgeDirection side, Block block, TileEntity tile);
} }

View file

@ -9,5 +9,5 @@
package buildcraft.api.gates; package buildcraft.api.gates;
public interface IActionReceptor { public interface IActionReceptor {
void actionActivated(IAction action); void actionActivated(IAction action, IActionParameter[] parameters);
} }

View file

@ -1,20 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.gates;
import java.util.LinkedList;
/**
* This interface has to be implemented by a TileEntity or a Pipe that wants to provide triggers different from the ones installed by default with BuildCraft.
*/
public interface IOverrideDefaultTriggers {
LinkedList<ITrigger> getTriggers();
}

View file

@ -46,8 +46,7 @@ public interface IStatement {
String getDescription(); String getDescription();
/** /**
* Create parameters for the trigger. As for now, there is only one kind of * Create parameters for the trigger.
* trigger parameter available so this subprogram is final.
*/ */
IStatementParameter createParameter(int index); IStatementParameter createParameter(int index);

View file

@ -8,24 +8,47 @@
*/ */
package buildcraft.api.gates; package buildcraft.api.gates;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
public interface IStatementParameter { public interface IStatementParameter {
ItemStack getItemStackToDraw();
IIcon getIconToDraw();
/**
* Every parameter needs a unique tag, it should be in the format of
* "<modid>:<name>".
*
* @return the unique id
*/
String getUniqueTag();
@SideOnly(Side.CLIENT)
IIcon getIcon();
@SideOnly(Side.CLIENT)
ItemStack getItemStack();
@SideOnly(Side.CLIENT)
void registerIcons(IIconRegister iconRegister);
/**
* Return the parameter description in the UI
*/
String getDescription(); String getDescription();
void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack, int mouseButton); void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton);
void writeToNBT(NBTTagCompound compound);
void readFromNBT(NBTTagCompound compound); void readFromNBT(NBTTagCompound compound);
void writeToNBT(NBTTagCompound compound);
/**
* This returns the parameter after a left rotation. Used in particular in
* blueprints orientation.
*/
IStatementParameter rotateLeft();
} }

View file

@ -12,7 +12,7 @@ import java.util.Collection;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
public interface ITriggerProvider { public interface ITriggerProvider {
@ -25,6 +25,6 @@ public interface ITriggerProvider {
/** /**
* Returns the list of triggers available to a gate next to the given block. * Returns the list of triggers available to a gate next to the given block.
*/ */
Collection<ITrigger> getNeighborTriggers(Block block, TileEntity tile); Collection<ITrigger> getNeighborTriggers(ForgeDirection side, Block block, TileEntity tile);
} }

View file

@ -16,7 +16,7 @@ import java.util.Map;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
public final class StatementManager { public final class StatementManager {
@ -54,11 +54,11 @@ public final class StatementManager {
parameterToId.put(param, name); parameterToId.put(param, name);
} }
public static List<ITrigger> getNeighborTriggers(Block block, TileEntity entity) { public static List<ITrigger> getNeighborTriggers(ForgeDirection side, Block block, TileEntity entity) {
List<ITrigger> result = new LinkedList<ITrigger>(); List<ITrigger> result = new LinkedList<ITrigger>();
for (ITriggerProvider provider : triggerProviders) { for (ITriggerProvider provider : triggerProviders) {
Collection<ITrigger> toAdd = provider.getNeighborTriggers(block, entity); Collection<ITrigger> toAdd = provider.getNeighborTriggers(side, block, entity);
if (toAdd != null) { if (toAdd != null) {
for (ITrigger t : toAdd) { for (ITrigger t : toAdd) {
@ -72,11 +72,11 @@ public final class StatementManager {
return result; return result;
} }
public static List<IAction> getNeighborActions(Block block, TileEntity entity) { public static List<IAction> getNeighborActions(ForgeDirection side, Block block, TileEntity entity) {
List<IAction> result = new LinkedList<IAction>(); List<IAction> result = new LinkedList<IAction>();
for (IActionProvider provider : actionProviders) { for (IActionProvider provider : actionProviders) {
Collection<IAction> toAdd = provider.getNeighborActions(block, entity); Collection<IAction> toAdd = provider.getNeighborActions(side, block, entity);
if (toAdd != null) { if (toAdd != null) {
for (IAction t : toAdd) { for (IAction t : toAdd) {

View file

@ -8,6 +8,7 @@
*/ */
package buildcraft.api.gates; package buildcraft.api.gates;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -21,17 +22,17 @@ public class TriggerParameterItemStack implements ITriggerParameter {
protected ItemStack stack; protected ItemStack stack;
@Override @Override
public ItemStack getItemStackToDraw() { public IIcon getIcon() {
return stack;
}
@Override
public IIcon getIconToDraw() {
return null; return null;
} }
@Override @Override
public void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack, int mouseButton) { public ItemStack getItemStack() {
return stack;
}
@Override
public void onClick(Object 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;
@ -59,6 +60,18 @@ public class TriggerParameterItemStack implements ITriggerParameter {
stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack")); stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack"));
} }
@Override
public boolean equals(Object object) {
if (object instanceof TriggerParameterItemStack) {
TriggerParameterItemStack param = (TriggerParameterItemStack) object;
return ItemStack.areItemStacksEqual(stack, param.stack)
&& ItemStack.areItemStackTagsEqual(stack, param.stack);
} else {
return false;
}
}
@Override @Override
public String getDescription() { public String getDescription() {
if (stack != null) { if (stack != null) {
@ -67,4 +80,19 @@ public class TriggerParameterItemStack implements ITriggerParameter {
return ""; return "";
} }
} }
@Override
public String getUniqueTag() {
return "buildcraft:stackTrigger";
}
@Override
public void registerIcons(IIconRegister iconRegister) {
}
@Override
public IStatementParameter rotateLeft() {
return this;
}
} }

View file

@ -6,7 +6,7 @@
* License 1.0, or MMPL. Please check the contents of the license located in * License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt * http://www.mod-buildcraft.com/MMPL-1.0.txt
*/ */
@API(apiVersion = "2.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates") @API(apiVersion = "2.2", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates")
package buildcraft.api.gates; package buildcraft.api.gates;
import cpw.mods.fml.common.API; import cpw.mods.fml.common.API;

View file

@ -47,6 +47,7 @@ import buildcraft.api.core.JavaTools;
import buildcraft.api.core.StackKey; import buildcraft.api.core.StackKey;
import buildcraft.api.fuels.BuildcraftFuelRegistry; import buildcraft.api.fuels.BuildcraftFuelRegistry;
import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.StatementManager;
import buildcraft.api.recipes.BuildcraftRecipeRegistry; import buildcraft.api.recipes.BuildcraftRecipeRegistry;
import buildcraft.core.BlockSpring; import buildcraft.core.BlockSpring;
import buildcraft.core.DefaultProps; import buildcraft.core.DefaultProps;
@ -68,6 +69,7 @@ import buildcraft.energy.TileEnergyEmitter;
import buildcraft.energy.TileEnergyReceiver; import buildcraft.energy.TileEnergyReceiver;
import buildcraft.energy.TileEngine; import buildcraft.energy.TileEngine;
import buildcraft.energy.TileEngine.EnergyStage; import buildcraft.energy.TileEngine.EnergyStage;
import buildcraft.energy.statements.EnergyStatementProvider;
import buildcraft.energy.statements.TriggerEngineHeat; import buildcraft.energy.statements.TriggerEngineHeat;
import buildcraft.energy.worldgen.BiomeGenOilDesert; import buildcraft.energy.worldgen.BiomeGenOilDesert;
import buildcraft.energy.worldgen.BiomeGenOilOcean; import buildcraft.energy.worldgen.BiomeGenOilOcean;
@ -323,6 +325,8 @@ public class BuildCraftEnergy extends BuildCraftMod {
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
StatementManager.registerTriggerProvider(new EnergyStatementProvider());
BuilderAPI.schematicRegistry.registerSchematicBlock(engineBlock, SchematicEngine.class); BuilderAPI.schematicRegistry.registerSchematicBlock(engineBlock, SchematicEngine.class);
if (BuildCraftCore.loadDefaultRecipes) { if (BuildCraftCore.loadDefaultRecipes) {

View file

@ -19,6 +19,7 @@ import buildcraft.BuildCraftCore;
import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.IAreaProvider;
import buildcraft.api.filler.FillerManager; import buildcraft.api.filler.FillerManager;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionParameter;
import buildcraft.api.gates.IActionReceptor; import buildcraft.api.gates.IActionReceptor;
import buildcraft.builders.statements.ActionFiller; import buildcraft.builders.statements.ActionFiller;
import buildcraft.core.Box; import buildcraft.core.Box;
@ -313,7 +314,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
} }
@Override @Override
public void actionActivated(IAction action) { public void actionActivated(IAction action, IActionParameter[] parameters) {
if (action == BuildCraftCore.actionOn) { if (action == BuildCraftCore.actionOn) {
lastMode = ActionMachineControl.Mode.On; lastMode = ActionMachineControl.Mode.On;
} else if (action == BuildCraftCore.actionOff) { } else if (action == BuildCraftCore.actionOff) {

View file

@ -14,6 +14,7 @@ import java.util.LinkedList;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.filler.FillerManager; import buildcraft.api.filler.FillerManager;
import buildcraft.api.filler.IFillerPattern; import buildcraft.api.filler.IFillerPattern;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
@ -31,7 +32,7 @@ public class BuildersActionProvider implements IActionProvider {
} }
@Override @Override
public Collection<IAction> getNeighborActions(Block block, TileEntity tile) { public Collection<IAction> getNeighborActions(ForgeDirection side, Block block, TileEntity tile) {
LinkedList<IAction> actions = new LinkedList<IAction>(); LinkedList<IAction> actions = new LinkedList<IAction>();
if (tile instanceof TileFiller) { if (tile instanceof TileFiller) {
for (IFillerPattern p : FillerManager.registry.getPatterns()) { for (IFillerPattern p : FillerManager.registry.getPatterns()) {

View file

@ -27,7 +27,7 @@ public class StatementParameterStackFilter extends ArrayStackOrListFilter {
for (IStatementParameter s : parameters) { for (IStatementParameter s : parameters) {
if (s != null) { if (s != null) {
if (s instanceof ActionParameterItemStack || s instanceof TriggerParameterItemStack) { if (s instanceof ActionParameterItemStack || s instanceof TriggerParameterItemStack) {
tmp.add(s.getItemStackToDraw()); tmp.add(s.getItemStack());
} }
} }
} }

View file

@ -132,10 +132,10 @@ public class AIRobotSearchStackRequest extends AIRobot {
for (IStatementParameter p : s.parameters) { for (IStatementParameter p : s.parameters) {
ActionParameterItemStack param = (ActionParameterItemStack) p; ActionParameterItemStack param = (ActionParameterItemStack) p;
if (param != null && !isBlacklisted(param.getItemStackToDraw())) { if (param != null && !isBlacklisted(param.getItemStack())) {
StackRequest req = new StackRequest(); StackRequest req = new StackRequest();
req.station = station; req.station = station;
req.stack = param.getItemStackToDraw(); req.stack = param.getItemStack();
return req; return req;
} }

View file

@ -132,7 +132,7 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
for (IActionParameter p : slot.parameters) { for (IActionParameter p : slot.parameters) {
if (p != null && p instanceof ActionParameterItemStack) { if (p != null && p instanceof ActionParameterItemStack) {
ActionParameterItemStack param = (ActionParameterItemStack) p; ActionParameterItemStack param = (ActionParameterItemStack) p;
ItemStack stack = param.getItemStackToDraw(); ItemStack stack = param.getItemStack();
if (stack != null && stack.getItem() instanceof ItemBlock) { if (stack != null && stack.getItem() instanceof ItemBlock) {
blockFilter.add(((ItemBlock) stack.getItem()).field_150939_a); blockFilter.add(((ItemBlock) stack.getItem()).field_150939_a);

View file

@ -119,7 +119,7 @@ public class BoardRobotPump extends RedstoneBoardRobot {
for (IActionParameter p : slot.parameters) { for (IActionParameter p : slot.parameters) {
if (p != null && p instanceof ActionParameterItemStack) { if (p != null && p instanceof ActionParameterItemStack) {
ActionParameterItemStack param = (ActionParameterItemStack) p; ActionParameterItemStack param = (ActionParameterItemStack) p;
ItemStack stack = param.getItemStackToDraw(); ItemStack stack = param.getItemStack();
if (stack != null) { if (stack != null) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack); FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);

View file

@ -15,9 +15,8 @@ import org.apache.logging.log4j.Level;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionProvider; import buildcraft.api.gates.IActionProvider;
@ -32,7 +31,7 @@ public class DefaultActionProvider implements IActionProvider {
} }
@Override @Override
public Collection<IAction> getNeighborActions(Block block, TileEntity tile) { public Collection<IAction> getNeighborActions(ForgeDirection side, Block block, TileEntity tile) {
LinkedList<IAction> res = new LinkedList<IAction>(); LinkedList<IAction> res = new LinkedList<IAction>();
res.add(BuildCraftCore.actionRedstone); res.add(BuildCraftCore.actionRedstone);

View file

@ -21,7 +21,6 @@ import net.minecraftforge.fluids.IFluidHandler;
import cofh.api.energy.IEnergyHandler; import cofh.api.energy.IEnergyHandler;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.api.gates.IOverrideDefaultTriggers;
import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerProvider; import buildcraft.api.gates.ITriggerProvider;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
@ -30,11 +29,7 @@ import buildcraft.core.IMachine;
public class DefaultTriggerProvider implements ITriggerProvider { public class DefaultTriggerProvider implements ITriggerProvider {
@Override @Override
public LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity tile) { public LinkedList<ITrigger> getNeighborTriggers(ForgeDirection side, Block block, TileEntity tile) {
if (tile instanceof IOverrideDefaultTriggers) {
return ((IOverrideDefaultTriggers) tile).getTriggers();
}
LinkedList<ITrigger> res = new LinkedList<ITrigger>(); LinkedList<ITrigger> res = new LinkedList<ITrigger>();
if (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0) { if (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0) {
@ -48,7 +43,7 @@ public class DefaultTriggerProvider implements ITriggerProvider {
} }
if (tile instanceof IFluidHandler) { if (tile instanceof IFluidHandler) {
FluidTankInfo[] tanks = ((IFluidHandler) tile).getTankInfo(ForgeDirection.UNKNOWN); FluidTankInfo[] tanks = ((IFluidHandler) tile).getTankInfo(side.getOpposite());
if (tanks != null && tanks.length > 0) { if (tanks != null && tanks.length > 0) {
res.add(BuildCraftCore.triggerEmptyFluid); res.add(BuildCraftCore.triggerEmptyFluid);
res.add(BuildCraftCore.triggerContainsFluid); res.add(BuildCraftCore.triggerContainsFluid);
@ -65,7 +60,7 @@ public class DefaultTriggerProvider implements ITriggerProvider {
res.add(BuildCraftCore.triggerMachineInactive); res.add(BuildCraftCore.triggerMachineInactive);
} }
if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0) { if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(side.getOpposite()) > 0) {
res.add(BuildCraftCore.triggerEnergyHigh); res.add(BuildCraftCore.triggerEnergyHigh);
res.add(BuildCraftCore.triggerEnergyLow); res.add(BuildCraftCore.triggerEnergyLow);
} }

View file

@ -8,6 +8,7 @@
*/ */
package buildcraft.core.statements; package buildcraft.core.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
@ -15,7 +16,9 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.NetworkData; import buildcraft.api.core.NetworkData;
import buildcraft.api.gates.IActionParameter; import buildcraft.api.gates.IActionParameter;
import buildcraft.api.gates.IStatement; import buildcraft.api.gates.IStatement;
import buildcraft.api.gates.IStatementParameter;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
@ -24,29 +27,33 @@ public class StatementParameterDirection implements IActionParameter, ITriggerPa
@NetworkData @NetworkData
public ForgeDirection direction = ForgeDirection.UNKNOWN; public ForgeDirection direction = ForgeDirection.UNKNOWN;
private IIcon[] icons;
public StatementParameterDirection() { public StatementParameterDirection() {
} }
@Override @Override
public ItemStack getItemStackToDraw() { public ItemStack getItemStack() {
return null; return null;
} }
@Override @Override
public IIcon getIconToDraw() { public IIcon getIcon() {
if (direction == ForgeDirection.UNKNOWN) { if (direction == ForgeDirection.UNKNOWN) {
return null; return null;
} else { } else {
return StatementIconProvider.INSTANCE.getIcon(StatementIconProvider.Action_Parameter_Direction_Down + direction.ordinal()); return icons[direction.ordinal()];
} }
} }
@Override @Override
public void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack, int mouseButton) { public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
do { if (source instanceof IPipe) {
direction = ForgeDirection.getOrientation((direction.ordinal() + (mouseButton > 0 ? -1 : 1)) % 6); do {
} while (!pipe.isPipeConnected(direction)); direction = ForgeDirection.getOrientation((direction.ordinal() + (mouseButton > 0 ? -1 : 1)) % 6);
} while (!((IPipe) source).getTile().isPipeConnected(direction));
}
} }
@Override @Override
@ -80,4 +87,26 @@ public class StatementParameterDirection implements IActionParameter, ITriggerPa
return StringUtils.localize("direction." + direction.name().toLowerCase()); return StringUtils.localize("direction." + direction.name().toLowerCase());
} }
} }
@Override
public String getUniqueTag() {
return "buildcraft:pipeActionDirection";
}
@Override
public void registerIcons(IIconRegister iconRegister) {
icons = new IIcon[] {
iconRegister.registerIcon("buildcraft:triggers/trigger_dir_down"),
iconRegister.registerIcon("buildcraft:triggers/trigger_dir_up"),
iconRegister.registerIcon("buildcraft:triggers/trigger_dir_north"),
iconRegister.registerIcon("buildcraft:triggers/trigger_dir_south"),
iconRegister.registerIcon("buildcraft:triggers/trigger_dir_west"),
iconRegister.registerIcon("buildcraft:triggers/trigger_dir_east")
};
}
@Override
public IStatementParameter rotateLeft() {
return this;
}
} }

View file

@ -1,11 +1,13 @@
package buildcraft.core.statements; package buildcraft.core.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import buildcraft.api.core.NetworkData; import buildcraft.api.core.NetworkData;
import buildcraft.api.gates.IActionParameter; import buildcraft.api.gates.IActionParameter;
import buildcraft.api.gates.IStatement; import buildcraft.api.gates.IStatement;
import buildcraft.api.gates.IStatementParameter;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.StringUtils;
@ -15,17 +17,19 @@ public class StatementParameterRedstoneGateSideOnly implements
@NetworkData @NetworkData
public boolean isOn = false; public boolean isOn = false;
private IIcon icon;
public StatementParameterRedstoneGateSideOnly() { public StatementParameterRedstoneGateSideOnly() {
} }
@Override @Override
public ItemStack getItemStackToDraw() { public ItemStack getItemStack() {
return null; return null;
} }
@Override @Override
public IIcon getIconToDraw() { public IIcon getIcon() {
if (!isOn) { if (!isOn) {
return null; return null;
} else { } else {
@ -34,7 +38,7 @@ public class StatementParameterRedstoneGateSideOnly implements
} }
@Override @Override
public void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack, int mouseButton) { public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
isOn = !isOn; isOn = !isOn;
} }
@ -54,4 +58,19 @@ public class StatementParameterRedstoneGateSideOnly implements
public String getDescription() { public String getDescription() {
return isOn ? StringUtils.localize("gate.parameter.redstone.gateSideOnly") : ""; return isOn ? StringUtils.localize("gate.parameter.redstone.gateSideOnly") : "";
} }
@Override
public String getUniqueTag() {
return "buildcraft:redstoneGateSideOnly";
}
@Override
public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/redstone_gate_side_only");
}
@Override
public IStatementParameter rotateLeft() {
return this;
}
} }

View file

@ -51,8 +51,8 @@ public class TriggerFluidContainer extends BCTrigger {
FluidStack searchedFluid = null; FluidStack searchedFluid = null;
if (parameter != null && parameter.getItemStackToDraw() != null) { if (parameter != null && parameter.getItemStack() != null) {
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStackToDraw()); searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
} }
if (searchedFluid != null) { if (searchedFluid != null) {

View file

@ -58,8 +58,8 @@ public class TriggerFluidContainerLevel extends BCTrigger {
FluidStack searchedFluid = null; FluidStack searchedFluid = null;
if (parameter != null && parameter.getItemStackToDraw() != null) { if (parameter != null && parameter.getItemStack() != null) {
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStackToDraw()); searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
} }
if (searchedFluid != null) { if (searchedFluid != null) {

View file

@ -52,7 +52,7 @@ public class TriggerInventory extends BCTrigger {
ItemStack searchedStack = null; ItemStack searchedStack = null;
if (parameter != null) { if (parameter != null) {
searchedStack = parameter.getItemStackToDraw(); searchedStack = parameter.getItemStack();
} }
if (tile instanceof IInventory) { if (tile instanceof IInventory) {

View file

@ -65,7 +65,7 @@ public class TriggerInventoryLevel extends BCTrigger {
} }
if (tile instanceof IInventory) { if (tile instanceof IInventory) {
ItemStack searchStack = parameter.getItemStackToDraw(); ItemStack searchStack = parameter.getItemStack();
if (searchStack == null) { if (searchStack == null) {
return false; return false;

View file

@ -22,7 +22,6 @@ import cofh.api.energy.IEnergyHandler;
import buildcraft.BuildCraftEnergy; import buildcraft.BuildCraftEnergy;
import buildcraft.api.core.NetworkData; import buildcraft.api.core.NetworkData;
import buildcraft.api.gates.IOverrideDefaultTriggers;
import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITrigger;
import buildcraft.api.power.IPowerEmitter; import buildcraft.api.power.IPowerEmitter;
import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.IPowerReceptor;
@ -38,7 +37,7 @@ import buildcraft.core.TileBuildCraft;
import buildcraft.energy.gui.ContainerEngine; import buildcraft.energy.gui.ContainerEngine;
public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter,
IOverrideDefaultTriggers, IPipeConnection, IEnergyHandler { IPipeConnection, IEnergyHandler {
// Index corresponds to metadata // Index corresponds to metadata
public static final ResourceLocation[] BASE_TEXTURES = new ResourceLocation[]{ public static final ResourceLocation[] BASE_TEXTURES = new ResourceLocation[]{
new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"), new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"),
@ -544,18 +543,6 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto
public abstract int calculateCurrentOutput(); public abstract int calculateCurrentOutput();
@Override
public LinkedList<ITrigger> getTriggers() {
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
triggers.add(BuildCraftEnergy.triggerBlueEngineHeat);
triggers.add(BuildCraftEnergy.triggerGreenEngineHeat);
triggers.add(BuildCraftEnergy.triggerYellowEngineHeat);
triggers.add(BuildCraftEnergy.triggerRedEngineHeat);
return triggers;
}
@Override @Override
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with) { public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with) {
if (type == PipeType.POWER) { if (type == PipeType.POWER) {

View file

@ -427,20 +427,6 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan
} }
} }
@Override
public LinkedList<ITrigger> getTriggers() {
LinkedList<ITrigger> triggers = super.getTriggers();
triggers.add(BuildCraftCore.triggerEmptyFluid);
triggers.add(BuildCraftCore.triggerContainsFluid);
triggers.add(BuildCraftCore.triggerSpaceFluid);
triggers.add(BuildCraftCore.triggerFullFluid);
triggers.add(BuildCraftCore.triggerFluidContainerBelow25);
triggers.add(BuildCraftCore.triggerFluidContainerBelow50);
triggers.add(BuildCraftCore.triggerFluidContainerBelow75);
return triggers;
}
@Override @Override
public boolean hasCustomInventoryName() { public boolean hasCustomInventoryName() {
return false; return false;

View file

@ -161,17 +161,6 @@ public class TileEngineStone extends TileEngineWithInventory {
return (int) Math.round(MathUtils.clamp(e * kp + esum * ki, MIN_OUTPUT, MAX_OUTPUT)); return (int) Math.round(MathUtils.clamp(e * kp + esum * ki, MIN_OUTPUT, MAX_OUTPUT));
} }
@Override
public LinkedList<ITrigger> getTriggers() {
LinkedList<ITrigger> triggers = super.getTriggers();
triggers.add(BuildCraftCore.triggerEmptyInventory);
triggers.add(BuildCraftCore.triggerContainsInventory);
triggers.add(BuildCraftCore.triggerSpaceInventory);
triggers.add(BuildCraftCore.triggerFullInventory);
return triggers;
}
@Override @Override
public boolean hasCustomInventoryName() { public boolean hasCustomInventoryName() {
return false; return false;

View file

@ -0,0 +1,38 @@
package buildcraft.energy.statements;
import java.util.Collection;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.BuildCraftEnergy;
import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionProvider;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.gates.ITriggerProvider;
import buildcraft.api.transport.IPipeTile;
import buildcraft.energy.TileEngine;
public class EnergyStatementProvider implements ITriggerProvider {
@Override
public Collection<ITrigger> getPipeTriggers(IPipeTile pipe) {
return null;
}
@Override
public Collection<ITrigger> getNeighborTriggers(ForgeDirection side, Block block, TileEntity tile) {
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
if (tile instanceof TileEngine) {
triggers.add(BuildCraftEnergy.triggerBlueEngineHeat);
triggers.add(BuildCraftEnergy.triggerGreenEngineHeat);
triggers.add(BuildCraftEnergy.triggerYellowEngineHeat);
triggers.add(BuildCraftEnergy.triggerRedEngineHeat);
}
return triggers;
}
}

View file

@ -21,6 +21,7 @@ import buildcraft.api.core.NetworkData;
import buildcraft.api.core.Position; import buildcraft.api.core.Position;
import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionParameter;
import buildcraft.api.gates.IActionReceptor; import buildcraft.api.gates.IActionReceptor;
import buildcraft.api.power.ILaserTarget; import buildcraft.api.power.ILaserTarget;
import buildcraft.api.power.ILaserTargetBlock; import buildcraft.api.power.ILaserTargetBlock;
@ -298,7 +299,7 @@ public class TileLaser extends TileBuildCraft implements IActionReceptor, IMachi
} }
@Override @Override
public void actionActivated(IAction action) { public void actionActivated(IAction action, IActionParameter[] parameters) {
if (action == BuildCraftCore.actionOn) { if (action == BuildCraftCore.actionOn) {
lastMode = ActionMachineControl.Mode.On; lastMode = ActionMachineControl.Mode.On;
} else if (action == BuildCraftCore.actionOff) { } else if (action == BuildCraftCore.actionOff) {

View file

@ -16,6 +16,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionParameter;
import buildcraft.api.gates.IActionReceptor; import buildcraft.api.gates.IActionReceptor;
import buildcraft.api.power.ILaserTarget; import buildcraft.api.power.ILaserTarget;
import buildcraft.core.IMachine; import buildcraft.core.IMachine;
@ -219,7 +220,7 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase
} }
@Override @Override
public void actionActivated(IAction action) { public void actionActivated(IAction action, IActionParameter[] parameters) {
if (action == BuildCraftCore.actionOn) { if (action == BuildCraftCore.actionOn) {
lastMode = ActionMachineControl.Mode.On; lastMode = ActionMachineControl.Mode.On;
} else if (action == BuildCraftCore.actionOff) { } else if (action == BuildCraftCore.actionOff) {

View file

@ -71,7 +71,7 @@ public class ActionRobotFilter extends BCActionPassive {
for (IActionParameter p : slot.parameters) { for (IActionParameter p : slot.parameters) {
if (p != null && p instanceof ActionParameterItemStack) { if (p != null && p instanceof ActionParameterItemStack) {
ActionParameterItemStack param = (ActionParameterItemStack) p; ActionParameterItemStack param = (ActionParameterItemStack) p;
ItemStack stack = param.getItemStackToDraw(); ItemStack stack = param.getItemStack();
if (stack != null) { if (stack != null) {
result.add(stack); result.add(stack);

View file

@ -63,7 +63,7 @@ public class ActionRobotGotoStation extends BCActionActive {
if (parameters[0] != null) { if (parameters[0] != null) {
ActionParameterItemStack stackParam = (ActionParameterItemStack) parameters[0]; ActionParameterItemStack stackParam = (ActionParameterItemStack) parameters[0];
ItemStack item = stackParam.getItemStackToDraw(); ItemStack item = stackParam.getItemStack();
if (item.getItem() instanceof ItemMapLocation) { if (item.getItem() instanceof ItemMapLocation) {
BlockIndex index = ItemMapLocation.getBlockIndex(item); BlockIndex index = ItemMapLocation.getBlockIndex(item);

View file

@ -39,7 +39,7 @@ public class ActionRobotWorkInArea extends BCActionPassive {
return null; return null;
} }
ItemStack stack = ((ActionParameterItemStack) slot.parameters[0]).getItemStackToDraw(); ItemStack stack = ((ActionParameterItemStack) slot.parameters[0]).getItemStack();
if (!(stack.getItem() instanceof ItemMapLocation)) { if (!(stack.getItem() instanceof ItemMapLocation)) {
return null; return null;

View file

@ -67,7 +67,7 @@ public class ActionStationForbidRobot extends BCActionPassive {
for (IActionParameter p : slot.parameters) { for (IActionParameter p : slot.parameters) {
if (p != null) { if (p != null) {
ActionParameterItemStack actionStack = (ActionParameterItemStack) p; ActionParameterItemStack actionStack = (ActionParameterItemStack) p;
ItemStack stack = p.getItemStackToDraw(); ItemStack stack = p.getItemStack();
if (stack != null && stack.getItem() instanceof ItemRobot) { if (stack != null && stack.getItem() instanceof ItemRobot) {
return ItemRobot.getRobotNBT(stack) == robot.getBoard().getNBTHandler(); return ItemRobot.getRobotNBT(stack) == robot.getBoard().getNBTHandler();

View file

@ -89,7 +89,7 @@ public class RobotsActionProvider implements IActionProvider {
} }
@Override @Override
public Collection<IAction> getNeighborActions(Block block, TileEntity tile) { public Collection<IAction> getNeighborActions(ForgeDirection side, Block block, TileEntity tile) {
return null; return null;
} }

View file

@ -47,7 +47,7 @@ public class RobotsTriggerProvider implements ITriggerProvider {
} }
@Override @Override
public Collection<ITrigger> getNeighborTriggers(Block block, TileEntity tile) { public Collection<ITrigger> getNeighborTriggers(ForgeDirection side, Block block, TileEntity tile) {
return null; return null;
} }

View file

@ -472,7 +472,7 @@ public final class Gate implements IGate {
TileEntity tile = pipe.container.getTile(side); TileEntity tile = pipe.container.getTile(side);
if (tile instanceof IActionReceptor) { if (tile instanceof IActionReceptor) {
IActionReceptor recept = (IActionReceptor) tile; IActionReceptor recept = (IActionReceptor) tile;
recept.actionActivated(action); recept.actionActivated(action, slot.parameters);
} }
} }
} }
@ -545,7 +545,7 @@ public final class Gate implements IGate {
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = pipe.container.getTile(o); TileEntity tile = pipe.container.getTile(o);
Block block = pipe.container.getBlock(o); Block block = pipe.container.getBlock(o);
allTriggers.addAll(StatementManager.getNeighborTriggers(block, tile)); allTriggers.addAll(StatementManager.getNeighborTriggers(o, block, tile));
} }
return allTriggers; return allTriggers;
@ -571,7 +571,7 @@ public final class Gate implements IGate {
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = pipe.container.getTile(o); TileEntity tile = pipe.container.getTile(o);
Block block = pipe.container.getBlock(o); Block block = pipe.container.getBlock(o);
allActions.addAll(StatementManager.getNeighborActions(block, tile)); allActions.addAll(StatementManager.getNeighborActions(o, block, tile));
} }
return allActions; return allActions;

View file

@ -5,6 +5,7 @@ import java.util.LinkedList;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.IAction; import buildcraft.api.gates.IAction;
import buildcraft.api.gates.IActionProvider; import buildcraft.api.gates.IActionProvider;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
@ -35,7 +36,7 @@ public class PipeActionProvider implements IActionProvider {
} }
@Override @Override
public Collection<IAction> getNeighborActions(Block block, TileEntity tile) { public Collection<IAction> getNeighborActions(ForgeDirection side, Block block, TileEntity tile) {
return null; return null;
} }

View file

@ -74,7 +74,7 @@ public class PipeTriggerProvider implements ITriggerProvider {
} }
@Override @Override
public LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity tile) { public LinkedList<ITrigger> getNeighborTriggers(ForgeDirection side, Block block, TileEntity tile) {
return null; return null;
} }
} }

View file

@ -16,12 +16,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore;
import buildcraft.api.gates.IOverrideDefaultTriggers;
import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITrigger;
import buildcraft.core.TileBuildCraft; import buildcraft.core.TileBuildCraft;
import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.inventory.SimpleInventory;
public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IOverrideDefaultTriggers { public class TileFilteredBuffer extends TileBuildCraft implements IInventory {
private final SimpleInventory inventoryFilters = new SimpleInventory(9, "FilteredBufferFilters", 1); private final SimpleInventory inventoryFilters = new SimpleInventory(9, "FilteredBufferFilters", 1);
private final SimpleInventory inventoryStorage = new SimpleInventory(9, "FilteredBufferStorage", 64); private final SimpleInventory inventoryStorage = new SimpleInventory(9, "FilteredBufferStorage", 64);
@ -137,15 +136,4 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IO
public boolean hasCustomInventoryName() { public boolean hasCustomInventoryName() {
return false; return false;
} }
@Override
public LinkedList<ITrigger> getTriggers() {
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
triggers.add(BuildCraftCore.triggerInventoryBelow25);
triggers.add(BuildCraftCore.triggerInventoryBelow50);
triggers.add(BuildCraftCore.triggerInventoryBelow75);
return triggers;
}
} }

View file

@ -141,7 +141,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
IStatementParameter parameter = getParameter(); IStatementParameter parameter = getParameter();
if (parameter != null) { if (parameter != null) {
return parameter.getItemStackToDraw(); return parameter.getItemStack();
} else { } else {
return null; return null;
} }
@ -152,7 +152,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
IStatementParameter parameter = getParameter(); IStatementParameter parameter = getParameter();
if (parameter != null) { if (parameter != null) {
return parameter.getIconToDraw(); return parameter.getIcon();
} else { } else {
return null; return null;
} }
@ -474,7 +474,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
} }
if (param != null) { if (param != null) {
param.clicked(pipe.container, statement.getStatement(), mc.thePlayer.inventory.getItemStack(), k); param.onClick(pipe.container, statement.getStatement(), mc.thePlayer.inventory.getItemStack(), k);
paramSlot.setParameter(param, true); paramSlot.setParameter(param, true);
} }
} }

View file

@ -10,12 +10,15 @@ package buildcraft.transport.statements;
import java.util.Locale; import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import buildcraft.api.core.NetworkData; import buildcraft.api.core.NetworkData;
import buildcraft.api.gates.IActionParameter; import buildcraft.api.gates.IActionParameter;
import buildcraft.api.gates.IStatement; import buildcraft.api.gates.IStatement;
import buildcraft.api.gates.IStatementParameter;
import buildcraft.api.transport.IPipe;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.PipeWire; import buildcraft.api.transport.PipeWire;
import buildcraft.core.statements.StatementIconProvider; import buildcraft.core.statements.StatementIconProvider;
@ -25,44 +28,23 @@ public class ActionParameterSignal implements IActionParameter {
@NetworkData @NetworkData
public PipeWire color = null; public PipeWire color = null;
private IIcon[] icons;
public ActionParameterSignal() { public ActionParameterSignal() {
} }
@Override @Override
public ItemStack getItemStackToDraw() { public IIcon getIcon() {
return null;
}
@Override
public IIcon getIconToDraw() {
int id = 0;
if (color == null) { if (color == null) {
return null; return null;
} else {
return icons[color.ordinal() & 3];
} }
switch (color) {
case RED:
id = StatementIconProvider.Trigger_PipeSignal_Red_Active;
break;
case BLUE:
id = StatementIconProvider.Trigger_PipeSignal_Blue_Active;
break;
case GREEN:
id = StatementIconProvider.Trigger_PipeSignal_Green_Active;
break;
case YELLOW:
id = StatementIconProvider.Trigger_PipeSignal_Yellow_Active;
break;
}
return StatementIconProvider.INSTANCE.getIcon(id);
} }
@Override @Override
public void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack, int mouseButton) { public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
if (color == null) { if (color == null) {
color = mouseButton == 0 ? PipeWire.RED : PipeWire.YELLOW; color = mouseButton == 0 ? PipeWire.RED : PipeWire.YELLOW;
} else if (color == (mouseButton == 0 ? PipeWire.YELLOW : PipeWire.RED)) { } else if (color == (mouseButton == 0 ? PipeWire.YELLOW : PipeWire.RED)) {
@ -101,4 +83,30 @@ public class ActionParameterSignal implements IActionParameter {
public String getDescription() { public String getDescription() {
return String.format(StringUtils.localize("gate.action.pipe.wire"), StringUtils.localize("color." + color.name().toLowerCase(Locale.ENGLISH))); return String.format(StringUtils.localize("gate.action.pipe.wire"), StringUtils.localize("color." + color.name().toLowerCase(Locale.ENGLISH)));
} }
@Override
public String getUniqueTag() {
return "buildcraft:pipeWireAction";
}
@Override
public void registerIcons(IIconRegister iconRegister) {
icons = new IIcon[] {
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_red_active"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_blue_active"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_green_active"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_yellow_active")
};
}
@Override
public IStatementParameter rotateLeft() {
return this;
}
@Override
public ItemStack getItemStack() {
return null;
}
} }

View file

@ -10,11 +10,13 @@ package buildcraft.transport.statements;
import java.util.Locale; import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import buildcraft.api.core.NetworkData; import buildcraft.api.core.NetworkData;
import buildcraft.api.gates.IStatement; import buildcraft.api.gates.IStatement;
import buildcraft.api.gates.IStatementParameter;
import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile;
import buildcraft.api.transport.PipeWire; import buildcraft.api.transport.PipeWire;
@ -29,60 +31,30 @@ public class TriggerParameterSignal implements ITriggerParameter {
@NetworkData @NetworkData
public PipeWire color = null; public PipeWire color = null;
private IIcon[] icons;
public TriggerParameterSignal() { public TriggerParameterSignal() {
} }
@Override @Override
public ItemStack getItemStackToDraw() { public ItemStack getItemStack() {
return null; return null;
} }
@Override @Override
public IIcon getIconToDraw() { public IIcon getIcon() {
int id = 0; int id = 0;
if (color == null) { if (color == null) {
return null; return null;
} }
if (active) { return icons[color.ordinal() + (active ? 4 : 0)];
switch (color) {
case RED:
id = StatementIconProvider.Trigger_PipeSignal_Red_Active;
break;
case BLUE:
id = StatementIconProvider.Trigger_PipeSignal_Blue_Active;
break;
case GREEN:
id = StatementIconProvider.Trigger_PipeSignal_Green_Active;
break;
case YELLOW:
id = StatementIconProvider.Trigger_PipeSignal_Yellow_Active;
break;
}
} else {
switch (color) {
case RED:
id = StatementIconProvider.Trigger_PipeSignal_Red_Inactive;
break;
case BLUE:
id = StatementIconProvider.Trigger_PipeSignal_Blue_Inactive;
break;
case GREEN:
id = StatementIconProvider.Trigger_PipeSignal_Green_Inactive;
break;
case YELLOW:
id = StatementIconProvider.Trigger_PipeSignal_Yellow_Inactive;
break;
}
}
return StatementIconProvider.INSTANCE.getIcon(id);
} }
@Override @Override
public void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack, int mouseButton) { public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
if (mouseButton == 0) { if (mouseButton == 0) {
if (color == null) { if (color == null) {
active = true; active = true;
@ -133,4 +105,28 @@ public class TriggerParameterSignal implements ITriggerParameter {
public String getDescription() { public String getDescription() {
return String.format(StringUtils.localize("gate.trigger.pipe.wire." + (active ? "active" : "inactive")), StringUtils.localize("color." + color.name().toLowerCase(Locale.ENGLISH))); return String.format(StringUtils.localize("gate.trigger.pipe.wire." + (active ? "active" : "inactive")), StringUtils.localize("color." + color.name().toLowerCase(Locale.ENGLISH)));
} }
@Override
public String getUniqueTag() {
return "buildcraft:pipeWireTrigger";
}
@Override
public void registerIcons(IIconRegister iconRegister) {
icons = new IIcon[]{
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_red_inactive"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_blue_inactive"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_green_inactive"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_yellow_inactive"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_red_active"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_blue_active"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_green_active"),
iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_yellow_active")
};
}
@Override
public IStatementParameter rotateLeft() {
return this;
}
} }

View file

@ -73,9 +73,9 @@ public class TriggerPipeContents extends BCTrigger {
if (kind == PipeContents.empty) { if (kind == PipeContents.empty) {
return transportItems.items.isEmpty(); return transportItems.items.isEmpty();
} else if (kind == PipeContents.containsItems) { } else if (kind == PipeContents.containsItems) {
if (parameter != null && parameter.getItemStackToDraw() != null) { if (parameter != null && parameter.getItemStack() != null) {
for (TravelingItem item : transportItems.items) { for (TravelingItem item : transportItems.items) {
if (StackHelper.isMatchingItemOrList(parameter.getItemStackToDraw(), item.getItemStack())) { if (StackHelper.isMatchingItemOrList(parameter.getItemStack(), item.getItemStack())) {
return true; return true;
} }
} }
@ -88,8 +88,8 @@ public class TriggerPipeContents extends BCTrigger {
FluidStack searchedFluid = null; FluidStack searchedFluid = null;
if (parameter != null && parameter.getItemStackToDraw() != null) { if (parameter != null && parameter.getItemStack() != null) {
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStackToDraw()); searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
} }
if (kind == PipeContents.empty) { if (kind == PipeContents.empty) {