refactor and add functionality to gate API, for #2107
This commit is contained in:
parent
a5758d1bf1
commit
56dd1a6bdd
45 changed files with 313 additions and 225 deletions
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
@ -15,22 +16,21 @@ import buildcraft.api.core.NetworkData;
|
|||
import buildcraft.api.transport.IPipeTile;
|
||||
|
||||
public class ActionParameterItemStack implements IActionParameter {
|
||||
|
||||
@NetworkData
|
||||
protected ItemStack stack;
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackToDraw() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconToDraw() {
|
||||
public IIcon getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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) {
|
||||
this.stack = stack.copy();
|
||||
this.stack.stackSize = 1;
|
||||
|
@ -71,4 +71,19 @@ public class ActionParameterItemStack implements IActionParameter {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
return "buildcraft:stackAction";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStatementParameter rotateLeft() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Collection;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
||||
public interface IActionProvider {
|
||||
|
@ -26,5 +26,5 @@ public interface IActionProvider {
|
|||
/**
|
||||
* 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);
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
package buildcraft.api.gates;
|
||||
|
||||
public interface IActionReceptor {
|
||||
void actionActivated(IAction action);
|
||||
void actionActivated(IAction action, IActionParameter[] parameters);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
|
@ -46,8 +46,7 @@ public interface IStatement {
|
|||
String getDescription();
|
||||
|
||||
/**
|
||||
* Create parameters for the trigger. As for now, there is only one kind of
|
||||
* trigger parameter available so this subprogram is final.
|
||||
* Create parameters for the trigger.
|
||||
*/
|
||||
IStatementParameter createParameter(int index);
|
||||
|
||||
|
|
|
@ -8,24 +8,47 @@
|
|||
*/
|
||||
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.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
||||
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();
|
||||
|
||||
void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack, int mouseButton);
|
||||
|
||||
void writeToNBT(NBTTagCompound compound);
|
||||
void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton);
|
||||
|
||||
void readFromNBT(NBTTagCompound compound);
|
||||
|
||||
void writeToNBT(NBTTagCompound compound);
|
||||
|
||||
/**
|
||||
* This returns the parameter after a left rotation. Used in particular in
|
||||
* blueprints orientation.
|
||||
*/
|
||||
IStatementParameter rotateLeft();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Collection;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
||||
public interface ITriggerProvider {
|
||||
|
@ -25,6 +25,6 @@ public interface ITriggerProvider {
|
|||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.Map;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
||||
public final class StatementManager {
|
||||
|
@ -54,11 +54,11 @@ public final class StatementManager {
|
|||
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>();
|
||||
|
||||
for (ITriggerProvider provider : triggerProviders) {
|
||||
Collection<ITrigger> toAdd = provider.getNeighborTriggers(block, entity);
|
||||
Collection<ITrigger> toAdd = provider.getNeighborTriggers(side, block, entity);
|
||||
|
||||
if (toAdd != null) {
|
||||
for (ITrigger t : toAdd) {
|
||||
|
@ -72,11 +72,11 @@ public final class StatementManager {
|
|||
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>();
|
||||
|
||||
for (IActionProvider provider : actionProviders) {
|
||||
Collection<IAction> toAdd = provider.getNeighborActions(block, entity);
|
||||
Collection<IAction> toAdd = provider.getNeighborActions(side, block, entity);
|
||||
|
||||
if (toAdd != null) {
|
||||
for (IAction t : toAdd) {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -21,17 +22,17 @@ public class TriggerParameterItemStack implements ITriggerParameter {
|
|||
protected ItemStack stack;
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackToDraw() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconToDraw() {
|
||||
public IIcon getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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) {
|
||||
this.stack = stack.copy();
|
||||
this.stack.stackSize = 1;
|
||||
|
@ -59,6 +60,18 @@ public class TriggerParameterItemStack implements ITriggerParameter {
|
|||
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
|
||||
public String getDescription() {
|
||||
if (stack != null) {
|
||||
|
@ -67,4 +80,19 @@ public class TriggerParameterItemStack implements ITriggerParameter {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
return "buildcraft:stackTrigger";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStatementParameter rotateLeft() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* 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;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ import buildcraft.api.core.JavaTools;
|
|||
import buildcraft.api.core.StackKey;
|
||||
import buildcraft.api.fuels.BuildcraftFuelRegistry;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.StatementManager;
|
||||
import buildcraft.api.recipes.BuildcraftRecipeRegistry;
|
||||
import buildcraft.core.BlockSpring;
|
||||
import buildcraft.core.DefaultProps;
|
||||
|
@ -68,6 +69,7 @@ import buildcraft.energy.TileEnergyEmitter;
|
|||
import buildcraft.energy.TileEnergyReceiver;
|
||||
import buildcraft.energy.TileEngine;
|
||||
import buildcraft.energy.TileEngine.EnergyStage;
|
||||
import buildcraft.energy.statements.EnergyStatementProvider;
|
||||
import buildcraft.energy.statements.TriggerEngineHeat;
|
||||
import buildcraft.energy.worldgen.BiomeGenOilDesert;
|
||||
import buildcraft.energy.worldgen.BiomeGenOilOcean;
|
||||
|
@ -323,6 +325,8 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
|
||||
StatementManager.registerTriggerProvider(new EnergyStatementProvider());
|
||||
|
||||
BuilderAPI.schematicRegistry.registerSchematicBlock(engineBlock, SchematicEngine.class);
|
||||
|
||||
if (BuildCraftCore.loadDefaultRecipes) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import buildcraft.BuildCraftCore;
|
|||
import buildcraft.api.core.IAreaProvider;
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionParameter;
|
||||
import buildcraft.api.gates.IActionReceptor;
|
||||
import buildcraft.builders.statements.ActionFiller;
|
||||
import buildcraft.core.Box;
|
||||
|
@ -313,7 +314,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
|||
}
|
||||
|
||||
@Override
|
||||
public void actionActivated(IAction action) {
|
||||
public void actionActivated(IAction action, IActionParameter[] parameters) {
|
||||
if (action == BuildCraftCore.actionOn) {
|
||||
lastMode = ActionMachineControl.Mode.On;
|
||||
} else if (action == BuildCraftCore.actionOff) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.LinkedList;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.gates.IAction;
|
||||
|
@ -31,7 +32,7 @@ public class BuildersActionProvider implements IActionProvider {
|
|||
}
|
||||
|
||||
@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>();
|
||||
if (tile instanceof TileFiller) {
|
||||
for (IFillerPattern p : FillerManager.registry.getPatterns()) {
|
||||
|
|
|
@ -27,7 +27,7 @@ public class StatementParameterStackFilter extends ArrayStackOrListFilter {
|
|||
for (IStatementParameter s : parameters) {
|
||||
if (s != null) {
|
||||
if (s instanceof ActionParameterItemStack || s instanceof TriggerParameterItemStack) {
|
||||
tmp.add(s.getItemStackToDraw());
|
||||
tmp.add(s.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,10 +132,10 @@ public class AIRobotSearchStackRequest extends AIRobot {
|
|||
for (IStatementParameter p : s.parameters) {
|
||||
ActionParameterItemStack param = (ActionParameterItemStack) p;
|
||||
|
||||
if (param != null && !isBlacklisted(param.getItemStackToDraw())) {
|
||||
if (param != null && !isBlacklisted(param.getItemStack())) {
|
||||
StackRequest req = new StackRequest();
|
||||
req.station = station;
|
||||
req.stack = param.getItemStackToDraw();
|
||||
req.stack = param.getItemStack();
|
||||
|
||||
return req;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot {
|
|||
for (IActionParameter p : slot.parameters) {
|
||||
if (p != null && p instanceof ActionParameterItemStack) {
|
||||
ActionParameterItemStack param = (ActionParameterItemStack) p;
|
||||
ItemStack stack = param.getItemStackToDraw();
|
||||
ItemStack stack = param.getItemStack();
|
||||
|
||||
if (stack != null && stack.getItem() instanceof ItemBlock) {
|
||||
blockFilter.add(((ItemBlock) stack.getItem()).field_150939_a);
|
||||
|
|
|
@ -119,7 +119,7 @@ public class BoardRobotPump extends RedstoneBoardRobot {
|
|||
for (IActionParameter p : slot.parameters) {
|
||||
if (p != null && p instanceof ActionParameterItemStack) {
|
||||
ActionParameterItemStack param = (ActionParameterItemStack) p;
|
||||
ItemStack stack = param.getItemStackToDraw();
|
||||
ItemStack stack = param.getItemStack();
|
||||
|
||||
if (stack != null) {
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||
|
|
|
@ -15,9 +15,8 @@ import org.apache.logging.log4j.Level;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionProvider;
|
||||
|
@ -32,7 +31,7 @@ public class DefaultActionProvider implements IActionProvider {
|
|||
}
|
||||
|
||||
@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>();
|
||||
|
||||
res.add(BuildCraftCore.actionRedstone);
|
||||
|
|
|
@ -21,7 +21,6 @@ import net.minecraftforge.fluids.IFluidHandler;
|
|||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.ITriggerProvider;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
@ -30,11 +29,7 @@ import buildcraft.core.IMachine;
|
|||
public class DefaultTriggerProvider implements ITriggerProvider {
|
||||
|
||||
@Override
|
||||
public LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity tile) {
|
||||
if (tile instanceof IOverrideDefaultTriggers) {
|
||||
return ((IOverrideDefaultTriggers) tile).getTriggers();
|
||||
}
|
||||
|
||||
public LinkedList<ITrigger> getNeighborTriggers(ForgeDirection side, Block block, TileEntity tile) {
|
||||
LinkedList<ITrigger> res = new LinkedList<ITrigger>();
|
||||
|
||||
if (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0) {
|
||||
|
@ -48,7 +43,7 @@ public class DefaultTriggerProvider implements ITriggerProvider {
|
|||
}
|
||||
|
||||
if (tile instanceof IFluidHandler) {
|
||||
FluidTankInfo[] tanks = ((IFluidHandler) tile).getTankInfo(ForgeDirection.UNKNOWN);
|
||||
FluidTankInfo[] tanks = ((IFluidHandler) tile).getTankInfo(side.getOpposite());
|
||||
if (tanks != null && tanks.length > 0) {
|
||||
res.add(BuildCraftCore.triggerEmptyFluid);
|
||||
res.add(BuildCraftCore.triggerContainsFluid);
|
||||
|
@ -65,7 +60,7 @@ public class DefaultTriggerProvider implements ITriggerProvider {
|
|||
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.triggerEnergyLow);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package buildcraft.core.statements;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
@ -15,7 +16,9 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IActionParameter;
|
||||
import buildcraft.api.gates.IStatement;
|
||||
import buildcraft.api.gates.IStatementParameter;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
|
@ -24,29 +27,33 @@ public class StatementParameterDirection implements IActionParameter, ITriggerPa
|
|||
@NetworkData
|
||||
public ForgeDirection direction = ForgeDirection.UNKNOWN;
|
||||
|
||||
private IIcon[] icons;
|
||||
|
||||
public StatementParameterDirection() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackToDraw() {
|
||||
public ItemStack getItemStack() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconToDraw() {
|
||||
public IIcon getIcon() {
|
||||
if (direction == ForgeDirection.UNKNOWN) {
|
||||
return null;
|
||||
} else {
|
||||
return StatementIconProvider.INSTANCE.getIcon(StatementIconProvider.Action_Parameter_Direction_Down + direction.ordinal());
|
||||
return icons[direction.ordinal()];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clicked(IPipeTile pipe, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
do {
|
||||
direction = ForgeDirection.getOrientation((direction.ordinal() + (mouseButton > 0 ? -1 : 1)) % 6);
|
||||
} while (!pipe.isPipeConnected(direction));
|
||||
public void onClick(Object source, IStatement stmt, ItemStack stack, int mouseButton) {
|
||||
if (source instanceof IPipe) {
|
||||
do {
|
||||
direction = ForgeDirection.getOrientation((direction.ordinal() + (mouseButton > 0 ? -1 : 1)) % 6);
|
||||
} while (!((IPipe) source).getTile().isPipeConnected(direction));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,4 +87,26 @@ public class StatementParameterDirection implements IActionParameter, ITriggerPa
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package buildcraft.core.statements;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IActionParameter;
|
||||
import buildcraft.api.gates.IStatement;
|
||||
import buildcraft.api.gates.IStatementParameter;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
@ -15,17 +17,19 @@ public class StatementParameterRedstoneGateSideOnly implements
|
|||
@NetworkData
|
||||
public boolean isOn = false;
|
||||
|
||||
private IIcon icon;
|
||||
|
||||
public StatementParameterRedstoneGateSideOnly() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackToDraw() {
|
||||
public ItemStack getItemStack() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconToDraw() {
|
||||
public IIcon getIcon() {
|
||||
if (!isOn) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -34,7 +38,7 @@ public class StatementParameterRedstoneGateSideOnly implements
|
|||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
@ -54,4 +58,19 @@ public class StatementParameterRedstoneGateSideOnly implements
|
|||
public String getDescription() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public class TriggerFluidContainer extends BCTrigger {
|
|||
|
||||
FluidStack searchedFluid = null;
|
||||
|
||||
if (parameter != null && parameter.getItemStackToDraw() != null) {
|
||||
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStackToDraw());
|
||||
if (parameter != null && parameter.getItemStack() != null) {
|
||||
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
|
||||
}
|
||||
|
||||
if (searchedFluid != null) {
|
||||
|
|
|
@ -58,8 +58,8 @@ public class TriggerFluidContainerLevel extends BCTrigger {
|
|||
|
||||
FluidStack searchedFluid = null;
|
||||
|
||||
if (parameter != null && parameter.getItemStackToDraw() != null) {
|
||||
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStackToDraw());
|
||||
if (parameter != null && parameter.getItemStack() != null) {
|
||||
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
|
||||
}
|
||||
|
||||
if (searchedFluid != null) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TriggerInventory extends BCTrigger {
|
|||
ItemStack searchedStack = null;
|
||||
|
||||
if (parameter != null) {
|
||||
searchedStack = parameter.getItemStackToDraw();
|
||||
searchedStack = parameter.getItemStack();
|
||||
}
|
||||
|
||||
if (tile instanceof IInventory) {
|
||||
|
|
|
@ -65,7 +65,7 @@ public class TriggerInventoryLevel extends BCTrigger {
|
|||
}
|
||||
|
||||
if (tile instanceof IInventory) {
|
||||
ItemStack searchStack = parameter.getItemStackToDraw();
|
||||
ItemStack searchStack = parameter.getItemStack();
|
||||
|
||||
if (searchStack == null) {
|
||||
return false;
|
||||
|
|
|
@ -22,7 +22,6 @@ import cofh.api.energy.IEnergyHandler;
|
|||
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
|
@ -38,7 +37,7 @@ import buildcraft.core.TileBuildCraft;
|
|||
import buildcraft.energy.gui.ContainerEngine;
|
||||
|
||||
public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter,
|
||||
IOverrideDefaultTriggers, IPipeConnection, IEnergyHandler {
|
||||
IPipeConnection, IEnergyHandler {
|
||||
// Index corresponds to metadata
|
||||
public static final ResourceLocation[] BASE_TEXTURES = new ResourceLocation[]{
|
||||
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();
|
||||
|
||||
@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
|
||||
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with) {
|
||||
if (type == PipeType.POWER) {
|
||||
|
|
|
@ -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
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
|
|
|
@ -161,17 +161,6 @@ public class TileEngineStone extends TileEngineWithInventory {
|
|||
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
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,7 @@ import buildcraft.api.core.NetworkData;
|
|||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionParameter;
|
||||
import buildcraft.api.gates.IActionReceptor;
|
||||
import buildcraft.api.power.ILaserTarget;
|
||||
import buildcraft.api.power.ILaserTargetBlock;
|
||||
|
@ -298,7 +299,7 @@ public class TileLaser extends TileBuildCraft implements IActionReceptor, IMachi
|
|||
}
|
||||
|
||||
@Override
|
||||
public void actionActivated(IAction action) {
|
||||
public void actionActivated(IAction action, IActionParameter[] parameters) {
|
||||
if (action == BuildCraftCore.actionOn) {
|
||||
lastMode = ActionMachineControl.Mode.On;
|
||||
} else if (action == BuildCraftCore.actionOff) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionParameter;
|
||||
import buildcraft.api.gates.IActionReceptor;
|
||||
import buildcraft.api.power.ILaserTarget;
|
||||
import buildcraft.core.IMachine;
|
||||
|
@ -219,7 +220,7 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void actionActivated(IAction action) {
|
||||
public void actionActivated(IAction action, IActionParameter[] parameters) {
|
||||
if (action == BuildCraftCore.actionOn) {
|
||||
lastMode = ActionMachineControl.Mode.On;
|
||||
} else if (action == BuildCraftCore.actionOff) {
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ActionRobotFilter extends BCActionPassive {
|
|||
for (IActionParameter p : slot.parameters) {
|
||||
if (p != null && p instanceof ActionParameterItemStack) {
|
||||
ActionParameterItemStack param = (ActionParameterItemStack) p;
|
||||
ItemStack stack = param.getItemStackToDraw();
|
||||
ItemStack stack = param.getItemStack();
|
||||
|
||||
if (stack != null) {
|
||||
result.add(stack);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ActionRobotGotoStation extends BCActionActive {
|
|||
|
||||
if (parameters[0] != null) {
|
||||
ActionParameterItemStack stackParam = (ActionParameterItemStack) parameters[0];
|
||||
ItemStack item = stackParam.getItemStackToDraw();
|
||||
ItemStack item = stackParam.getItemStack();
|
||||
|
||||
if (item.getItem() instanceof ItemMapLocation) {
|
||||
BlockIndex index = ItemMapLocation.getBlockIndex(item);
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ActionRobotWorkInArea extends BCActionPassive {
|
|||
return null;
|
||||
}
|
||||
|
||||
ItemStack stack = ((ActionParameterItemStack) slot.parameters[0]).getItemStackToDraw();
|
||||
ItemStack stack = ((ActionParameterItemStack) slot.parameters[0]).getItemStack();
|
||||
|
||||
if (!(stack.getItem() instanceof ItemMapLocation)) {
|
||||
return null;
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ActionStationForbidRobot extends BCActionPassive {
|
|||
for (IActionParameter p : slot.parameters) {
|
||||
if (p != null) {
|
||||
ActionParameterItemStack actionStack = (ActionParameterItemStack) p;
|
||||
ItemStack stack = p.getItemStackToDraw();
|
||||
ItemStack stack = p.getItemStack();
|
||||
|
||||
if (stack != null && stack.getItem() instanceof ItemRobot) {
|
||||
return ItemRobot.getRobotNBT(stack) == robot.getBoard().getNBTHandler();
|
||||
|
|
|
@ -89,7 +89,7 @@ public class RobotsActionProvider implements IActionProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<IAction> getNeighborActions(Block block, TileEntity tile) {
|
||||
public Collection<IAction> getNeighborActions(ForgeDirection side, Block block, TileEntity tile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class RobotsTriggerProvider implements ITriggerProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ITrigger> getNeighborTriggers(Block block, TileEntity tile) {
|
||||
public Collection<ITrigger> getNeighborTriggers(ForgeDirection side, Block block, TileEntity tile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -472,7 +472,7 @@ public final class Gate implements IGate {
|
|||
TileEntity tile = pipe.container.getTile(side);
|
||||
if (tile instanceof IActionReceptor) {
|
||||
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) {
|
||||
TileEntity tile = pipe.container.getTile(o);
|
||||
Block block = pipe.container.getBlock(o);
|
||||
allTriggers.addAll(StatementManager.getNeighborTriggers(block, tile));
|
||||
allTriggers.addAll(StatementManager.getNeighborTriggers(o, block, tile));
|
||||
}
|
||||
|
||||
return allTriggers;
|
||||
|
@ -571,7 +571,7 @@ public final class Gate implements IGate {
|
|||
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
|
||||
TileEntity tile = pipe.container.getTile(o);
|
||||
Block block = pipe.container.getBlock(o);
|
||||
allActions.addAll(StatementManager.getNeighborActions(block, tile));
|
||||
allActions.addAll(StatementManager.getNeighborActions(o, block, tile));
|
||||
}
|
||||
|
||||
return allActions;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.LinkedList;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionProvider;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
@ -35,7 +36,7 @@ public class PipeActionProvider implements IActionProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<IAction> getNeighborActions(Block block, TileEntity tile) {
|
||||
public Collection<IAction> getNeighborActions(ForgeDirection side, Block block, TileEntity tile) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class PipeTriggerProvider implements ITriggerProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public LinkedList<ITrigger> getNeighborTriggers(Block block, TileEntity tile) {
|
||||
public LinkedList<ITrigger> getNeighborTriggers(ForgeDirection side, Block block, TileEntity tile) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,11 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
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 inventoryStorage = new SimpleInventory(9, "FilteredBufferStorage", 64);
|
||||
|
@ -137,15 +136,4 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory, IO
|
|||
public boolean hasCustomInventoryName() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
IStatementParameter parameter = getParameter();
|
||||
|
||||
if (parameter != null) {
|
||||
return parameter.getItemStackToDraw();
|
||||
return parameter.getItemStack();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
IStatementParameter parameter = getParameter();
|
||||
|
||||
if (parameter != null) {
|
||||
return parameter.getIconToDraw();
|
||||
return parameter.getIcon();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,15 @@ package buildcraft.transport.statements;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IActionParameter;
|
||||
import buildcraft.api.gates.IStatement;
|
||||
import buildcraft.api.gates.IStatementParameter;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.statements.StatementIconProvider;
|
||||
|
@ -25,44 +28,23 @@ public class ActionParameterSignal implements IActionParameter {
|
|||
|
||||
@NetworkData
|
||||
public PipeWire color = null;
|
||||
|
||||
private IIcon[] icons;
|
||||
|
||||
public ActionParameterSignal() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackToDraw() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconToDraw() {
|
||||
int id = 0;
|
||||
|
||||
public IIcon getIcon() {
|
||||
if (color == 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
|
||||
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) {
|
||||
color = mouseButton == 0 ? PipeWire.RED : PipeWire.YELLOW;
|
||||
} else if (color == (mouseButton == 0 ? PipeWire.YELLOW : PipeWire.RED)) {
|
||||
|
@ -101,4 +83,30 @@ public class ActionParameterSignal implements IActionParameter {
|
|||
public String getDescription() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,11 +10,13 @@ package buildcraft.transport.statements;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IStatement;
|
||||
import buildcraft.api.gates.IStatementParameter;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
|
@ -29,60 +31,30 @@ public class TriggerParameterSignal implements ITriggerParameter {
|
|||
@NetworkData
|
||||
public PipeWire color = null;
|
||||
|
||||
private IIcon[] icons;
|
||||
|
||||
public TriggerParameterSignal() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackToDraw() {
|
||||
public ItemStack getItemStack() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconToDraw() {
|
||||
public IIcon getIcon() {
|
||||
int id = 0;
|
||||
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (active) {
|
||||
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);
|
||||
return icons[color.ordinal() + (active ? 4 : 0)];
|
||||
}
|
||||
|
||||
@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 (color == null) {
|
||||
active = true;
|
||||
|
@ -133,4 +105,28 @@ public class TriggerParameterSignal implements ITriggerParameter {
|
|||
public String getDescription() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,9 +73,9 @@ public class TriggerPipeContents extends BCTrigger {
|
|||
if (kind == PipeContents.empty) {
|
||||
return transportItems.items.isEmpty();
|
||||
} else if (kind == PipeContents.containsItems) {
|
||||
if (parameter != null && parameter.getItemStackToDraw() != null) {
|
||||
if (parameter != null && parameter.getItemStack() != null) {
|
||||
for (TravelingItem item : transportItems.items) {
|
||||
if (StackHelper.isMatchingItemOrList(parameter.getItemStackToDraw(), item.getItemStack())) {
|
||||
if (StackHelper.isMatchingItemOrList(parameter.getItemStack(), item.getItemStack())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -88,8 +88,8 @@ public class TriggerPipeContents extends BCTrigger {
|
|||
|
||||
FluidStack searchedFluid = null;
|
||||
|
||||
if (parameter != null && parameter.getItemStackToDraw() != null) {
|
||||
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStackToDraw());
|
||||
if (parameter != null && parameter.getItemStack() != null) {
|
||||
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack());
|
||||
}
|
||||
|
||||
if (kind == PipeContents.empty) {
|
||||
|
|
Loading…
Reference in a new issue