Started a major refactor of the trigger action system.
Triggers and actions are moving towards more factorization in statements. Actions will now accept parameters. Triggers and actions will accept up to 3 parameters. Parameters will not only be stacks, in particular for pipe wire. This is supporting in particular the emerald gate implementation, for #1880.
This commit is contained in:
parent
66bfac926b
commit
70c1cd0535
39 changed files with 546 additions and 371 deletions
73
api/buildcraft/api/gates/ActionParameter.java
Executable file
73
api/buildcraft/api/gates/ActionParameter.java
Executable file
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* 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 net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ActionParameter implements IActionParameter {
|
||||
|
||||
protected ItemStack stack;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItemStack()
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#set(net.minecraft.src.ItemStack)
|
||||
*/
|
||||
@Override
|
||||
public void set(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
this.stack = stack.copy();
|
||||
this.stack.stackSize = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#writeToNBT(net.minecraft.src.NBTTagCompound)
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
if (stack != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
stack.writeToNBT(tagCompound);
|
||||
compound.setTag("stack", tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#readFromNBT(net.minecraft.src.NBTTagCompound)
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
// Legacy code to prevent existing gates from losing their contents
|
||||
int itemID = compound.getInteger("itemID");
|
||||
if (itemID != 0) {
|
||||
stack = new ItemStack((Item) Item.itemRegistry.getObject(itemID), 1, compound.getInteger("itemDMG"));
|
||||
return;
|
||||
}
|
||||
|
||||
stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack"));
|
||||
}
|
||||
|
||||
}
|
20
api/buildcraft/api/gates/IAction.java
Normal file → Executable file
20
api/buildcraft/api/gates/IAction.java
Normal file → Executable file
|
@ -8,24 +8,6 @@
|
|||
*/
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
public interface IAction extends IStatement {
|
||||
|
||||
public interface IAction {
|
||||
|
||||
String getUniqueTag();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon getIcon();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void registerIcons(IIconRegister iconRegister);
|
||||
|
||||
boolean hasParameter();
|
||||
|
||||
String getDescription();
|
||||
|
||||
IAction rotateLeft();
|
||||
}
|
||||
|
|
13
api/buildcraft/api/gates/IActionParameter.java
Executable file
13
api/buildcraft/api/gates/IActionParameter.java
Executable file
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
public interface IActionParameter extends IStatementParameter {
|
||||
|
||||
}
|
59
api/buildcraft/api/gates/IStatement.java
Normal file
59
api/buildcraft/api/gates/IStatement.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* 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 net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IStatement {
|
||||
|
||||
/**
|
||||
* Every trigger 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)
|
||||
void registerIcons(IIconRegister iconRegister);
|
||||
|
||||
/**
|
||||
* Return the maximum number of parameter this trigger can have, 0 if none.
|
||||
*/
|
||||
int maxParameters();
|
||||
|
||||
/**
|
||||
* Return the minimum number of parameter this trigger can have, 0 if none.
|
||||
*/
|
||||
int minParameters();
|
||||
|
||||
/**
|
||||
* Return the trigger description in the UI
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Create parameters for the trigger. As for now, there is only one kind of
|
||||
* trigger parameter available so this subprogram is final.
|
||||
*/
|
||||
IStatementParameter createParameter(int index);
|
||||
|
||||
/**
|
||||
* This returns the trigger after a left rotation. Used in particular in
|
||||
* blueprints orientation.
|
||||
*/
|
||||
IStatement rotateLeft();
|
||||
}
|
24
api/buildcraft/api/gates/IStatementParameter.java
Executable file
24
api/buildcraft/api/gates/IStatementParameter.java
Executable file
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* 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 net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface IStatementParameter {
|
||||
|
||||
ItemStack getItemStack();
|
||||
|
||||
void set(ItemStack stack);
|
||||
|
||||
void writeToNBT(NBTTagCompound compound);
|
||||
|
||||
void readFromNBT(NBTTagCompound compound);
|
||||
|
||||
}
|
47
api/buildcraft/api/gates/ITrigger.java
Normal file → Executable file
47
api/buildcraft/api/gates/ITrigger.java
Normal file → Executable file
|
@ -8,51 +8,6 @@
|
|||
*/
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
public interface ITrigger extends IStatement {
|
||||
|
||||
public interface ITrigger {
|
||||
|
||||
/**
|
||||
* Every trigger 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)
|
||||
void registerIcons(IIconRegister iconRegister);
|
||||
|
||||
/**
|
||||
* Return true if this trigger can accept parameters
|
||||
*/
|
||||
boolean hasParameter();
|
||||
|
||||
/**
|
||||
* Return true if this trigger requires a parameter
|
||||
*/
|
||||
boolean requiresParameter();
|
||||
|
||||
/**
|
||||
* Return the trigger description in the UI
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Create parameters for the trigger. As for now, there is only one kind of
|
||||
* trigger parameter available so this subprogram is final.
|
||||
*/
|
||||
ITriggerParameter createParameter();
|
||||
|
||||
/**
|
||||
* This returns the trigger after a left rotation. Used in particular in
|
||||
* blueprints orientation.
|
||||
*/
|
||||
ITrigger rotateLeft();
|
||||
}
|
||||
|
|
|
@ -8,20 +8,6 @@
|
|||
*/
|
||||
package buildcraft.api.gates;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public interface ITriggerParameter {
|
||||
|
||||
ItemStack getItemStack();
|
||||
|
||||
void set(ItemStack stack);
|
||||
|
||||
void writeToNBT(NBTTagCompound compound);
|
||||
|
||||
void readFromNBT(NBTTagCompound compound);
|
||||
|
||||
@Deprecated
|
||||
ItemStack getItem();
|
||||
public interface ITriggerParameter extends IStatementParameter {
|
||||
|
||||
}
|
||||
|
|
|
@ -18,17 +18,16 @@ import net.minecraft.tileentity.TileEntity;
|
|||
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
||||
public final class ActionManager {
|
||||
public final class StatementManager {
|
||||
|
||||
public static Map<String, ITrigger> triggers = new HashMap<String, ITrigger>();
|
||||
public static Map<String, IAction> actions = new HashMap<String, IAction>();
|
||||
public static Map<String, IStatement> statements = new HashMap<String, IStatement>();
|
||||
private static List<ITriggerProvider> triggerProviders = new LinkedList<ITriggerProvider>();
|
||||
private static List<IActionProvider> actionProviders = new LinkedList<IActionProvider>();
|
||||
|
||||
/**
|
||||
* Deactivate constructor
|
||||
*/
|
||||
private ActionManager() {
|
||||
private StatementManager() {
|
||||
}
|
||||
|
||||
public static void registerTriggerProvider(ITriggerProvider provider) {
|
||||
|
@ -37,12 +36,8 @@ public final class ActionManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerTrigger(ITrigger trigger) {
|
||||
triggers.put(trigger.getUniqueTag(), trigger);
|
||||
}
|
||||
|
||||
public static void registerAction(IAction action) {
|
||||
actions.put(action.getUniqueTag(), action);
|
||||
public static void registerStatement(IStatement statement) {
|
||||
statements.put(statement.getUniqueTag(), statement);
|
||||
}
|
||||
|
||||
public static List<ITrigger> getNeighborTriggers(Block block, TileEntity entity) {
|
|
@ -70,10 +70,4 @@ public class TriggerParameter implements ITriggerParameter {
|
|||
stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ItemStack getItem() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 156 B |
Binary file not shown.
After Width: | Height: | Size: 527 B |
Binary file not shown.
After Width: | Height: | Size: 531 B |
BIN
buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_5.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_5.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 225 B |
Binary file not shown.
After Width: | Height: | Size: 274 B |
|
@ -49,7 +49,7 @@ import buildcraft.api.core.BCLog;
|
|||
import buildcraft.api.core.JavaTools;
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.StatementManager;
|
||||
import buildcraft.builders.BlockArchitect;
|
||||
import buildcraft.builders.BlockBlueprintLibrary;
|
||||
import buildcraft.builders.BlockBuildTool;
|
||||
|
@ -477,7 +477,7 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
|||
throw error;
|
||||
}
|
||||
|
||||
ActionManager.registerActionProvider(new BuildersActionProvider());
|
||||
StatementManager.registerActionProvider(new BuildersActionProvider());
|
||||
}
|
||||
|
||||
public static void loadRecipes() {
|
||||
|
|
|
@ -62,7 +62,7 @@ import buildcraft.api.core.BCLog;
|
|||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.JavaTools;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.StatementManager;
|
||||
import buildcraft.api.recipes.BuildcraftRecipeRegistry;
|
||||
import buildcraft.builders.urbanism.EntityRobotUrbanism;
|
||||
import buildcraft.core.BlockIndex;
|
||||
|
@ -307,8 +307,8 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
channels = NetworkRegistry.INSTANCE.newChannel
|
||||
(DefaultProps.NET_CHANNEL_NAME + "-CORE", new BuildCraftChannelHandler(), new PacketHandler());
|
||||
|
||||
ActionManager.registerTriggerProvider(new DefaultTriggerProvider());
|
||||
ActionManager.registerActionProvider(new DefaultActionProvider());
|
||||
StatementManager.registerTriggerProvider(new DefaultTriggerProvider());
|
||||
StatementManager.registerActionProvider(new DefaultActionProvider());
|
||||
|
||||
if (BuildCraftCore.modifyWorld) {
|
||||
MinecraftForge.EVENT_BUS.register(new SpringPopulate());
|
||||
|
|
|
@ -199,6 +199,8 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
Items.redstone, Items.quartz);
|
||||
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:compChipset", 60000, Chipset.COMP.getStack(),
|
||||
Items.redstone, Items.comparator);
|
||||
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:emeraldChipset", 120000,
|
||||
Chipset.EMERALD.getStack(), Items.redstone, Items.emerald);
|
||||
|
||||
// GATES
|
||||
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:simpleGate", 10000,
|
||||
|
@ -209,6 +211,8 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
addGateRecipe("Gold", 40000, GateMaterial.GOLD, Chipset.GOLD, PipeWire.RED, PipeWire.BLUE, PipeWire.GREEN);
|
||||
addGateRecipe("Diamond", 80000, GateMaterial.DIAMOND, Chipset.DIAMOND, PipeWire.RED, PipeWire.BLUE,
|
||||
PipeWire.GREEN, PipeWire.YELLOW);
|
||||
addGateRecipe("Emerald", 120000, GateMaterial.EMERALD, Chipset.DIAMOND, PipeWire.RED, PipeWire.BLUE,
|
||||
PipeWire.GREEN, PipeWire.YELLOW);
|
||||
|
||||
// ROBOTS AND BOARDS
|
||||
BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:redstoneCrystal", 1000000, new ItemStack(
|
||||
|
|
|
@ -35,8 +35,8 @@ import net.minecraftforge.oredict.RecipeSorter;
|
|||
import buildcraft.api.blueprints.SchematicRegistry;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.JavaTools;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.GateExpansions;
|
||||
import buildcraft.api.gates.StatementManager;
|
||||
import buildcraft.api.recipes.BuildcraftRecipeRegistry;
|
||||
import buildcraft.api.transport.IExtractionHandler;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
|
@ -443,7 +443,7 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
|
||||
new BptItemPipeFilters(pipeItemsDiamond);
|
||||
|
||||
ActionManager.registerTriggerProvider(new PipeTriggerProvider());
|
||||
StatementManager.registerTriggerProvider(new PipeTriggerProvider());
|
||||
|
||||
if (BuildCraftCore.loadDefaultRecipes) {
|
||||
loadRecipes();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
package buildcraft.builders.triggers;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.builders.filler.pattern.FillerPattern;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
|
@ -32,11 +33,6 @@ public class ActionFiller extends BCAction {
|
|||
return pattern.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextureMap() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAction rotateLeft() {
|
||||
return this;
|
||||
|
|
|
@ -8,59 +8,12 @@
|
|||
*/
|
||||
package buildcraft.core.triggers;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.IAction;
|
||||
|
||||
public abstract class BCAction implements IAction {
|
||||
public abstract class BCAction extends BCStatement implements IAction {
|
||||
|
||||
protected final String uniqueTag;
|
||||
|
||||
/**
|
||||
* UniqueTag accepts multiple possible tags, use this feature to migrate to
|
||||
* more standardized tags if needed, otherwise just pass a single string.
|
||||
* The first passed string will be the one used when saved to disk.
|
||||
*
|
||||
* @param uniqueTag
|
||||
*/
|
||||
public BCAction(String... uniqueTag) {
|
||||
this.uniqueTag = uniqueTag[0];
|
||||
for (String tag : uniqueTag) {
|
||||
ActionManager.actions.put(tag, this);
|
||||
}
|
||||
super(uniqueTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
return uniqueTag;
|
||||
}
|
||||
|
||||
public int getIconIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon() {
|
||||
return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex());
|
||||
}
|
||||
|
||||
public int getTextureMap() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
80
common/buildcraft/core/triggers/BCStatement.java
Executable file
80
common/buildcraft/core/triggers/BCStatement.java
Executable file
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* 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.core.triggers;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import buildcraft.api.gates.IStatement;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.api.gates.StatementManager;
|
||||
import buildcraft.api.gates.TriggerParameter;
|
||||
|
||||
public abstract class BCStatement implements IStatement {
|
||||
|
||||
protected final String uniqueTag;
|
||||
|
||||
/**
|
||||
* UniqueTag accepts multiple possible tags, use this feature to migrate to
|
||||
* more standardized tags if needed, otherwise just pass a single string.
|
||||
* The first passed string will be the one used when saved to disk.
|
||||
*
|
||||
* @param uniqueTag
|
||||
*/
|
||||
public BCStatement(String... uniqueTag) {
|
||||
this.uniqueTag = uniqueTag[0];
|
||||
for (String tag : uniqueTag) {
|
||||
StatementManager.statements.put(tag, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
return uniqueTag;
|
||||
}
|
||||
|
||||
public int getIconIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon() {
|
||||
return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxParameters() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minParameters() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ITriggerParameter createParameter(int index) {
|
||||
return new TriggerParameter();
|
||||
}
|
||||
|
||||
}
|
|
@ -8,77 +8,17 @@
|
|||
*/
|
||||
package buildcraft.core.triggers;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.api.gates.TriggerParameter;
|
||||
|
||||
/**
|
||||
* This class has to be implemented to create new triggers kinds to BuildCraft
|
||||
* gates. There is an instance per kind, which will get called wherever the
|
||||
* trigger can be active.
|
||||
*/
|
||||
public abstract class BCTrigger implements ITrigger {
|
||||
public abstract class BCTrigger extends BCStatement implements ITrigger {
|
||||
|
||||
protected final String uniqueTag;
|
||||
|
||||
/**
|
||||
* UniqueTag accepts multiple possible tags, use this feature to migrate to
|
||||
* more standardized tags if needed, otherwise just pass a single string.
|
||||
* The first passed string will be the one used when saved to disk.
|
||||
*
|
||||
* @param uniqueTag
|
||||
*/
|
||||
public BCTrigger(String... uniqueTag) {
|
||||
this.uniqueTag = uniqueTag[0];
|
||||
for (String tag : uniqueTag) {
|
||||
ActionManager.triggers.put(tag, this);
|
||||
}
|
||||
super(uniqueTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
return uniqueTag;
|
||||
}
|
||||
|
||||
public int getIconIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon() {
|
||||
return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresParameter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ITriggerParameter createParameter() {
|
||||
return new TriggerParameter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return state == State.Contains || state == State.Space;
|
||||
public int maxParameters() {
|
||||
return state == State.Contains || state == State.Space ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,8 +44,8 @@ public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigge
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return true;
|
||||
public int maxParameters() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,8 +39,8 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return state == State.Contains || state == State.Space;
|
||||
public int maxParameters() {
|
||||
return state == State.Contains || state == State.Space ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,13 +45,13 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return true;
|
||||
public int maxParameters() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresParameter() {
|
||||
return true;
|
||||
public int minParameters() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,8 @@ public class ItemRedstoneChipset extends ItemBuildCraft {
|
|||
DIAMOND,
|
||||
PULSATING,
|
||||
QUARTZ,
|
||||
COMP;
|
||||
COMP,
|
||||
EMERALD;
|
||||
public static final Chipset[] VALUES = values();
|
||||
private IIcon icon;
|
||||
|
||||
|
|
|
@ -27,14 +27,15 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.GateExpansionController;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionParameter;
|
||||
import buildcraft.api.gates.IActionReceptor;
|
||||
import buildcraft.api.gates.IGateExpansion;
|
||||
import buildcraft.api.gates.ITileTrigger;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.api.gates.StatementManager;
|
||||
import buildcraft.api.gates.TriggerParameter;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.core.GuiIds;
|
||||
|
@ -52,7 +53,8 @@ public final class Gate {
|
|||
public final GateLogic logic;
|
||||
public final BiMap<IGateExpansion, GateExpansionController> expansions = HashBiMap.create();
|
||||
public ITrigger[] triggers = new ITrigger[8];
|
||||
public ITriggerParameter[] triggerParameters = new ITriggerParameter[8];
|
||||
public ITriggerParameter[] triggerParameters = new ITriggerParameter[12];
|
||||
public IActionParameter[] actionParameters = new IActionParameter[12];
|
||||
public IAction[] actions = new IAction[8];
|
||||
public ActionState[] actionsState = new ActionState[8];
|
||||
|
||||
|
@ -103,6 +105,10 @@ public final class Gate {
|
|||
return triggerParameters[position];
|
||||
}
|
||||
|
||||
public IActionParameter getActionParameter(int position) {
|
||||
return actionParameters[position];
|
||||
}
|
||||
|
||||
public void addGateExpansion(IGateExpansion expansion) {
|
||||
if (!expansions.containsKey(expansion)) {
|
||||
expansions.put(expansion, expansion.makeController(pipe.container));
|
||||
|
@ -147,10 +153,10 @@ public final class Gate {
|
|||
public void readFromNBT(NBTTagCompound data) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
if (data.hasKey("trigger[" + i + "]")) {
|
||||
triggers[i] = ActionManager.triggers.get(data.getString("trigger[" + i + "]"));
|
||||
triggers[i] = (ITrigger) StatementManager.statements.get(data.getString("trigger[" + i + "]"));
|
||||
}
|
||||
if (data.hasKey("action[" + i + "]")) {
|
||||
actions[i] = ActionManager.actions.get(data.getString("action[" + i + "]"));
|
||||
actions[i] = (IAction) StatementManager.statements.get(data.getString("action[" + i + "]"));
|
||||
}
|
||||
if (data.hasKey("triggerParameters[" + i + "]")) {
|
||||
triggerParameters[i] = new TriggerParameter();
|
||||
|
|
|
@ -36,22 +36,29 @@ public final class GateDefinition {
|
|||
|
||||
public static enum GateMaterial {
|
||||
|
||||
REDSTONE("gate_interface_1.png", 146, 1, false), IRON("gate_interface_2.png", 164, 2, false), GOLD("gate_interface_3.png", 200, 4, true), DIAMOND("gate_interface_4.png", 200, 8, true);
|
||||
REDSTONE("gate_interface_1.png", 146, 1, 0, 0),
|
||||
IRON("gate_interface_2.png", 164, 2, 0, 0),
|
||||
GOLD("gate_interface_3.png", 200, 4, 1, 0),
|
||||
DIAMOND("gate_interface_4.png", 200, 8, 1, 0),
|
||||
EMERALD("gate_interface_5.png", 200, 4, 3, 3);
|
||||
public static final GateMaterial[] VALUES = values();
|
||||
public final ResourceLocation guiFile;
|
||||
public final int guiHeight;
|
||||
public final int numSlots;
|
||||
public final boolean hasParameterSlot;
|
||||
public final int numTriggerParameters;
|
||||
public final int numActionParameters;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconBlock;
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconItem;
|
||||
|
||||
private GateMaterial(String guiFile, int guiHeight, int numSlots, boolean hasParamterSlot) {
|
||||
private GateMaterial(String guiFile, int guiHeight, int numSlots, int triggerParameterSlots,
|
||||
int actionParameterSlots) {
|
||||
this.guiFile = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/" + guiFile);
|
||||
this.guiHeight = guiHeight;
|
||||
this.numSlots = numSlots;
|
||||
this.hasParameterSlot = hasParamterSlot;
|
||||
this.numTriggerParameters = triggerParameterSlots;
|
||||
this.numActionParameters = actionParameterSlots;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
|
@ -30,11 +30,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.GateExpansions;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IGateExpansion;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.IStatement;
|
||||
import buildcraft.api.gates.StatementManager;
|
||||
import buildcraft.core.ItemBuildCraft;
|
||||
import buildcraft.core.inventory.InvUtils;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
@ -257,12 +256,8 @@ public class ItemGate extends ItemBuildCraft {
|
|||
expansion.registerItemOverlay(iconRegister);
|
||||
}
|
||||
|
||||
for (IAction action : ActionManager.actions.values()) {
|
||||
action.registerIcons(iconRegister);
|
||||
}
|
||||
|
||||
for (ITrigger trigger : ActionManager.triggers.values()) {
|
||||
trigger.registerIcons(iconRegister);
|
||||
for (IStatement statement : StatementManager.statements.values()) {
|
||||
statement.registerIcons(iconRegister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,11 +27,11 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.api.gates.StatementManager;
|
||||
import buildcraft.api.gates.TriggerParameter;
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
import buildcraft.core.network.PacketCoordinates;
|
||||
|
@ -92,7 +92,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
// the client.
|
||||
if (!pipe.container.getWorldObj().isRemote) {
|
||||
potentialActions.addAll(pipe.getActions());
|
||||
potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe.container));
|
||||
potentialTriggers.addAll(StatementManager.getPipeTriggers(pipe.container));
|
||||
|
||||
if (pipe.container instanceof IOverrideDefaultTriggers) {
|
||||
potentialTriggers.addAll(((IOverrideDefaultTriggers) pipe.container).getTriggers());
|
||||
|
@ -102,18 +102,30 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
if (pipe.hasGate(o)) {
|
||||
TileEntity tile = pipe.container.getTile(o);
|
||||
Block block = pipe.container.getBlock(o);
|
||||
potentialTriggers.addAll(ActionManager.getNeighborTriggers(block, tile));
|
||||
potentialActions.addAll(ActionManager.getNeighborActions(block, tile));
|
||||
potentialTriggers.addAll(StatementManager.getNeighborTriggers(block, tile));
|
||||
potentialActions.addAll(StatementManager.getNeighborActions(block, tile));
|
||||
}
|
||||
}
|
||||
|
||||
if (!pipe.gate.material.hasParameterSlot) {
|
||||
if (pipe.gate.material.numTriggerParameters == 0) {
|
||||
Iterator<ITrigger> it = potentialTriggers.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
ITrigger trigger = it.next();
|
||||
|
||||
if (trigger.requiresParameter()) {
|
||||
if (trigger.minParameters() > 0) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pipe.gate.material.numActionParameters == 0) {
|
||||
Iterator<IAction> it = potentialActions.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
IAction action = it.next();
|
||||
|
||||
if (action.minParameters() > 0) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +160,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
|
||||
int length = payload.stream.readInt();
|
||||
for (int i = 0; i < length; i++) {
|
||||
potentialActions.add(ActionManager.actions.get(Utils.readUTF(payload.stream)));
|
||||
potentialActions.add((IAction) StatementManager.statements.get(Utils.readUTF(payload.stream)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +177,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
|
||||
for (int i = 0; i < length; i++) {
|
||||
String trigger = Utils.readUTF(payload.stream);
|
||||
potentialTriggers.add(ActionManager.triggers.get(trigger));
|
||||
potentialTriggers.add((ITrigger) StatementManager.statements.get(trigger));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,8 +192,8 @@ public class ContainerGateInterface extends BuildCraftContainer {
|
|||
|
||||
int position = data.readInt();
|
||||
|
||||
setTrigger(position, ActionManager.triggers.get(Utils.readUTF(data)), notify);
|
||||
setAction(position, ActionManager.actions.get(Utils.readUTF(data)), notify);
|
||||
setTrigger(position, (ITrigger) StatementManager.statements.get(Utils.readUTF(data)), notify);
|
||||
setAction(position, (IAction) StatementManager.statements.get(Utils.readUTF(data)), notify);
|
||||
|
||||
ItemStack parameter = Utils.readStack(data);
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
*/
|
||||
package buildcraft.transport.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
@ -22,14 +22,16 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IStatement;
|
||||
import buildcraft.api.gates.IStatementParameter;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
import buildcraft.core.gui.AdvancedSlot;
|
||||
import buildcraft.core.gui.GuiAdvancedInterface;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.ActionState;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.gates.GateDefinition.GateMaterial;
|
||||
|
||||
public class GuiGateInterface extends GuiAdvancedInterface {
|
||||
|
||||
|
@ -38,12 +40,13 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
private final Pipe pipe;
|
||||
private int numSlots;
|
||||
|
||||
class TriggerSlot extends AdvancedSlot {
|
||||
private abstract class StatementSlot extends AdvancedSlot {
|
||||
|
||||
Pipe pipe;
|
||||
int slot;
|
||||
public Pipe pipe;
|
||||
public int slot;
|
||||
public ArrayList<StatementParameterSlot> parameters = new ArrayList<StatementParameterSlot>();
|
||||
|
||||
public TriggerSlot(int x, int y, Pipe pipe, int slot) {
|
||||
public StatementSlot(int x, int y, Pipe pipe, int slot) {
|
||||
super(GuiGateInterface.this, x, y);
|
||||
|
||||
this.pipe = pipe;
|
||||
|
@ -78,80 +81,47 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
return pipe.gate.getTrigger(slot) != null;
|
||||
}
|
||||
|
||||
public ITrigger getTrigger() {
|
||||
public abstract IStatement getStatement();
|
||||
}
|
||||
|
||||
private class TriggerSlot extends StatementSlot {
|
||||
public TriggerSlot(int x, int y, Pipe pipe, int slot) {
|
||||
super(x, y, pipe, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStatement getStatement() {
|
||||
return pipe.gate.getTrigger(slot);
|
||||
}
|
||||
}
|
||||
|
||||
class ActionSlot extends AdvancedSlot {
|
||||
|
||||
Pipe pipe;
|
||||
int slot;
|
||||
|
||||
private class ActionSlot extends StatementSlot {
|
||||
public ActionSlot(int x, int y, Pipe pipe, int slot) {
|
||||
super(GuiGateInterface.this, x, y);
|
||||
|
||||
this.pipe = pipe;
|
||||
this.slot = slot;
|
||||
super(x, y, pipe, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
IAction action = pipe.gate.getAction(slot);
|
||||
if (action != null) {
|
||||
return action.getDescription();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon() {
|
||||
IAction action = pipe.gate.getAction(slot);
|
||||
|
||||
if (action != null) {
|
||||
return action.getIcon();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture() {
|
||||
IAction action = pipe.gate.getAction(slot);
|
||||
|
||||
if (action instanceof BCAction) {
|
||||
BCAction bcAction = (BCAction) action;
|
||||
|
||||
if (bcAction.getTextureMap() == 0) {
|
||||
return TextureMap.locationBlocksTexture;
|
||||
}
|
||||
}
|
||||
|
||||
return super.getTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefined() {
|
||||
return pipe.gate.getAction(slot) != null;
|
||||
}
|
||||
|
||||
public IAction getAction() {
|
||||
public IStatement getStatement() {
|
||||
return pipe.gate.getAction(slot);
|
||||
}
|
||||
}
|
||||
|
||||
class TriggerParameterSlot extends AdvancedSlot {
|
||||
private abstract class StatementParameterSlot extends AdvancedSlot {
|
||||
|
||||
Pipe pipe;
|
||||
int slot;
|
||||
public Pipe pipe;
|
||||
public int slot;
|
||||
public StatementSlot statementSlot;
|
||||
public int indexInStatement;
|
||||
|
||||
public TriggerParameterSlot(int x, int y, Pipe pipe, int slot) {
|
||||
public StatementParameterSlot(int x, int y, Pipe pipe, int slot, StatementSlot iStatementSlot,
|
||||
int iIIndexInStatement) {
|
||||
super(GuiGateInterface.this, x, y);
|
||||
|
||||
this.pipe = pipe;
|
||||
this.slot = slot;
|
||||
this.statementSlot = iStatementSlot;
|
||||
statementSlot.parameters.add(this);
|
||||
indexInStatement = iIIndexInStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -170,11 +140,41 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
}
|
||||
|
||||
public ITriggerParameter getTriggerParameter() {
|
||||
public abstract IStatementParameter getParameter();
|
||||
|
||||
public boolean isAllowed() {
|
||||
return indexInStatement < statementSlot.getStatement().maxParameters();
|
||||
}
|
||||
|
||||
public boolean isRequired() {
|
||||
return indexInStatement < statementSlot.getStatement().minParameters();
|
||||
}
|
||||
}
|
||||
|
||||
class TriggerParameterSlot extends StatementParameterSlot {
|
||||
public TriggerParameterSlot(int x, int y, Pipe pipe, int slot, StatementSlot iStatementSlot,
|
||||
int iIIndexInStatement) {
|
||||
super(x, y, pipe, slot, iStatementSlot, iIIndexInStatement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStatementParameter getParameter() {
|
||||
return pipe.gate.getTriggerParameter(slot);
|
||||
}
|
||||
}
|
||||
|
||||
class ActionParameterSlot extends StatementParameterSlot {
|
||||
public ActionParameterSlot(int x, int y, Pipe pipe, int slot, StatementSlot iStatementSlot,
|
||||
int iIIndexInStatement) {
|
||||
super(x, y, pipe, slot, iStatementSlot, iIIndexInStatement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStatementParameter getParameter() {
|
||||
return pipe.gate.getActionParameter(slot);
|
||||
}
|
||||
}
|
||||
|
||||
public GuiGateInterface(IInventory playerInventory, Pipe pipe) {
|
||||
super(new ContainerGateInterface(playerInventory, pipe), null, null);
|
||||
|
||||
|
@ -188,19 +188,19 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
int position = 0;
|
||||
numSlots = pipe.gate.material.numSlots;
|
||||
|
||||
if (numSlots == 1) {
|
||||
if (pipe.gate.material == GateMaterial.REDSTONE) {
|
||||
slots = new AdvancedSlot[2];
|
||||
|
||||
slots[0] = new TriggerSlot(62, 26, pipe, 0);
|
||||
slots[1] = new ActionSlot(98, 26, pipe, 0);
|
||||
} else if (numSlots == 2) {
|
||||
} else if (pipe.gate.material == GateMaterial.IRON) {
|
||||
slots = new AdvancedSlot[4];
|
||||
|
||||
slots[0] = new TriggerSlot(62, 26, pipe, 0);
|
||||
slots[1] = new TriggerSlot(62, 44, pipe, 1);
|
||||
slots[2] = new ActionSlot(98, 26, pipe, 0);
|
||||
slots[3] = new ActionSlot(98, 44, pipe, 1);
|
||||
} else if (numSlots == 4) {
|
||||
} else if (pipe.gate.material == GateMaterial.GOLD) {
|
||||
slots = new AdvancedSlot[12];
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
|
@ -214,11 +214,12 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
slots[position] = new TriggerParameterSlot(71, 26 + 18 * k, pipe, position - 8);
|
||||
slots[position] = new TriggerParameterSlot(71, 26 + 18 * k, pipe, position - 8, (TriggerSlot) slots[k],
|
||||
k);
|
||||
position++;
|
||||
|
||||
}
|
||||
} else if (numSlots == 8) {
|
||||
} else if (pipe.gate.material == GateMaterial.DIAMOND) {
|
||||
slots = new AdvancedSlot[24];
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
|
@ -236,11 +237,38 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
slots[position] = new TriggerParameterSlot(26, 26 + 18 * k, pipe, position - 16);
|
||||
slots[position] = new TriggerParameterSlot(26, 26 + 18 * k, pipe, position - 16,
|
||||
(TriggerSlot) slots[k], k);
|
||||
position++;
|
||||
slots[position] = new TriggerParameterSlot(116, 26 + 18 * k, pipe, position - 16);
|
||||
slots[position] = new TriggerParameterSlot(116, 26 + 18 * k, pipe, position - 16,
|
||||
(TriggerSlot) slots[k + 4], k);
|
||||
position++;
|
||||
}
|
||||
} else if (pipe.gate.material == GateMaterial.EMERALD) {
|
||||
slots = new AdvancedSlot[32];
|
||||
int lastPos;
|
||||
|
||||
for (int y = 0; y < 4; ++y) {
|
||||
slots[position] = new TriggerSlot(8, 26 + 18 * y, pipe, y);
|
||||
lastPos = position;
|
||||
position++;
|
||||
|
||||
for (int x = 0; x < 3; ++x) {
|
||||
slots[position] = new TriggerParameterSlot(8 + 18 * (x + 1), 26 + 18 * y, pipe, y * 3 + x,
|
||||
(TriggerSlot) slots[lastPos], x);
|
||||
position++;
|
||||
}
|
||||
|
||||
slots[position] = new ActionSlot(98, 26 + 18 * y, pipe, y);
|
||||
lastPos = position;
|
||||
position++;
|
||||
|
||||
for (int x = 0; x < 3; ++x) {
|
||||
slots[position] = new ActionParameterSlot(98 + 18 * (x + 1), 26 + 18 * y, pipe, y * 3 + x,
|
||||
(ActionSlot) slots[lastPos], x);
|
||||
position++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -257,7 +285,6 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
|
||||
container.synchronize();
|
||||
|
||||
ResourceLocation texture = container.getGateGuiFile();
|
||||
|
@ -272,25 +299,17 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
int actionTracker = 0;
|
||||
|
||||
actionTracker = 0;
|
||||
for (int s = 0; s < slots.length; ++s) {
|
||||
AdvancedSlot slot = slots[s];
|
||||
|
||||
for (AdvancedSlot slot : slots) {
|
||||
if (slot instanceof TriggerSlot) {
|
||||
ITrigger trigger = ((TriggerSlot) slot).getTrigger();
|
||||
ITrigger trigger = (ITrigger) ((TriggerSlot) slot).getStatement();
|
||||
boolean halfWidth = container.actionsState[actionTracker] == ActionState.Partial;
|
||||
|
||||
if (pipe.gate.material.hasParameterSlot) {
|
||||
if (pipe.gate.material.numTriggerParameters > 0) {
|
||||
if (container.actionsState[actionTracker] != ActionState.Deactivated) {
|
||||
mc.renderEngine.bindTexture(texture);
|
||||
|
||||
drawTexturedModalRect(cornerX + slot.x + 35, cornerY + slot.y + 6, 176, 18, halfWidth ? 9 : 18, 4);
|
||||
}
|
||||
|
||||
if (trigger == null || !trigger.hasParameter()) {
|
||||
mc.renderEngine.bindTexture(texture);
|
||||
|
||||
drawTexturedModalRect(cornerX + slot.x + 17, cornerY + slot.y - 1, 176, 0, 18, 18);
|
||||
}
|
||||
} else if (container.actionsState[actionTracker] != ActionState.Deactivated) {
|
||||
mc.renderEngine.bindTexture(texture);
|
||||
|
||||
|
@ -298,16 +317,20 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
|
||||
actionTracker++;
|
||||
} else if (slot instanceof TriggerParameterSlot) {
|
||||
TriggerParameterSlot paramSlot = (TriggerParameterSlot) slot;
|
||||
TriggerSlot trigger = (TriggerSlot) slots[s - numSlots * 2];
|
||||
} else if (slot instanceof StatementParameterSlot) {
|
||||
StatementParameterSlot paramSlot = (StatementParameterSlot) slot;
|
||||
StatementSlot trigger = paramSlot.statementSlot;
|
||||
|
||||
if (trigger.isDefined() && trigger.getTrigger().requiresParameter()) {
|
||||
if (paramSlot.getItemStack() == null) {
|
||||
mc.renderEngine.bindTexture(texture);
|
||||
mc.renderEngine.bindTexture(texture);
|
||||
|
||||
if (trigger.isDefined()) {
|
||||
if (!paramSlot.isAllowed()) {
|
||||
drawTexturedModalRect(cornerX + slot.x - 1, cornerY + slot.y - 1, 176, 0, 18, 18);
|
||||
} else if (paramSlot.isRequired() && paramSlot.getItemStack() == null) {
|
||||
drawTexturedModalRect(cornerX + slot.x - 1, cornerY + slot.y - 1, 176, 22, 18, 18);
|
||||
}
|
||||
} else {
|
||||
drawTexturedModalRect(cornerX + slot.x - 1, cornerY + slot.y - 1, 176, 0, 18, 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +359,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
TriggerSlot triggerSlot = (TriggerSlot) slot;
|
||||
|
||||
ITrigger changed = null;
|
||||
if (triggerSlot.getTrigger() == null) {
|
||||
if (triggerSlot.getStatement() == null) {
|
||||
|
||||
if (k == 0) {
|
||||
changed = container.getFirstTrigger();
|
||||
|
@ -355,23 +378,23 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
break;
|
||||
}
|
||||
|
||||
if (trigger == triggerSlot.getTrigger()) {
|
||||
if (trigger == triggerSlot.getStatement()) {
|
||||
changed = it.next();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
container.setTrigger(position, changed, true);
|
||||
container.setTrigger(triggerSlot.slot, changed, true);
|
||||
|
||||
if (pipe.gate.material.hasParameterSlot) {
|
||||
container.setTriggerParameter(position, null, true);
|
||||
for (StatementParameterSlot p : triggerSlot.parameters) {
|
||||
container.setTriggerParameter(p.slot, null, true);
|
||||
}
|
||||
} else if (slot instanceof ActionSlot) {
|
||||
ActionSlot actionSlot = (ActionSlot) slot;
|
||||
|
||||
IAction changed = null;
|
||||
if (actionSlot.getAction() == null) {
|
||||
if (actionSlot.getStatement() == null) {
|
||||
|
||||
if (k == 0) {
|
||||
changed = container.getFirstAction();
|
||||
|
@ -390,23 +413,25 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
break;
|
||||
}
|
||||
|
||||
if (action == actionSlot.getAction()) {
|
||||
if (action == actionSlot.getStatement()) {
|
||||
changed = it.next();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
container.setAction(position - numSlots, changed, true);
|
||||
container.setAction(actionSlot.slot, changed, true);
|
||||
} else if (slot instanceof TriggerParameterSlot) {
|
||||
TriggerSlot trigger = (TriggerSlot) slots[position - numSlots * 2];
|
||||
TriggerParameterSlot paramSlot = (TriggerParameterSlot) slot;
|
||||
TriggerSlot trigger = (TriggerSlot) paramSlot.statementSlot;
|
||||
|
||||
if (trigger.isDefined() && trigger.getTrigger().hasParameter()) {
|
||||
ITriggerParameter param = trigger.getTrigger().createParameter();
|
||||
if (trigger.isDefined() && trigger.getStatement().maxParameters() != 0) {
|
||||
ITriggerParameter param = (ITriggerParameter) trigger.getStatement().createParameter(
|
||||
paramSlot.indexInStatement);
|
||||
|
||||
if (param != null) {
|
||||
param.set(mc.thePlayer.inventory.getItemStack());
|
||||
container.setTriggerParameter(position - numSlots * 2, param, true);
|
||||
container.setTriggerParameter(((TriggerParameterSlot) slot).slot, param, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,8 @@ import buildcraft.api.blueprints.IBuilderContext;
|
|||
import buildcraft.api.blueprints.MappingNotFoundException;
|
||||
import buildcraft.api.blueprints.MappingRegistry;
|
||||
import buildcraft.api.blueprints.SchematicTile;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.IStatement;
|
||||
import buildcraft.api.gates.StatementManager;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.TileGenericPipe.SideProperties;
|
||||
|
@ -63,13 +62,13 @@ public class SchematicPipe extends SchematicTile {
|
|||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
if (gateNBT.hasKey("trigger[" + i + "]")) {
|
||||
ITrigger t = ActionManager.triggers.get(gateNBT.getString("trigger[" + i + "]"));
|
||||
IStatement t = StatementManager.statements.get(gateNBT.getString("trigger[" + i + "]"));
|
||||
t = t.rotateLeft ();
|
||||
gateNBT.setString("trigger[" + i + "]", t.getUniqueTag());
|
||||
}
|
||||
|
||||
if (gateNBT.hasKey("action[" + i + "]")) {
|
||||
IAction a = ActionManager.actions.get(gateNBT.getString("action[" + i + "]"));
|
||||
IStatement a = StatementManager.statements.get(gateNBT.getString("action[" + i + "]"));
|
||||
a = a.rotateLeft ();
|
||||
gateNBT.setString("action[" + i + "]", a.getUniqueTag());
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ package buildcraft.transport.triggers;
|
|||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
@ -41,5 +42,4 @@ public class ActionEnergyPulsar extends BCAction {
|
|||
public IAction rotateLeft() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ package buildcraft.transport.triggers;
|
|||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
|
75
common/buildcraft/transport/triggers/TriggerParameterSignal.java
Executable file
75
common/buildcraft/transport/triggers/TriggerParameterSignal.java
Executable file
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* 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.transport.triggers;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.api.gates.ITriggerParameter;
|
||||
|
||||
public class TriggerParameterSignal implements ITriggerParameter {
|
||||
|
||||
protected ItemStack stack;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItemStack()
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#set(net.minecraft.src.ItemStack)
|
||||
*/
|
||||
@Override
|
||||
public void set(ItemStack stack) {
|
||||
if (stack != null) {
|
||||
this.stack = stack.copy();
|
||||
this.stack.stackSize = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#writeToNBT(net.minecraft.src.NBTTagCompound)
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound compound) {
|
||||
if (stack != null) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
stack.writeToNBT(tagCompound);
|
||||
compound.setTag("stack", tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#readFromNBT(net.minecraft.src.NBTTagCompound)
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
// Legacy code to prevent existing gates from losing their contents
|
||||
int itemID = compound.getInteger("itemID");
|
||||
if (itemID != 0) {
|
||||
stack = new ItemStack((Item) Item.itemRegistry.getObject(itemID), 1, compound.getInteger("itemDMG"));
|
||||
return;
|
||||
}
|
||||
|
||||
stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack"));
|
||||
}
|
||||
|
||||
}
|
|
@ -55,13 +55,13 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
public int maxParameters() {
|
||||
switch (kind) {
|
||||
case containsItems:
|
||||
case containsFluids:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case containsItems:
|
||||
case containsFluids:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameter() {
|
||||
return false;
|
||||
public int maxParameters() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue