Refactored action and trigger API to use interfaces.

This commit is contained in:
SirSengir 2012-07-20 20:13:05 +02:00
parent 372d090a67
commit 52c807b8fd
44 changed files with 493 additions and 268 deletions

View file

@ -13,9 +13,11 @@ import java.util.Iterator;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.api.gates.IAction;
import net.minecraft.src.buildcraft.api.gates.ITrigger;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.core.GuiAdvancedInterface;
import net.minecraft.src.buildcraft.core.utils.StringUtil;
import net.minecraft.src.buildcraft.transport.Gate.GateKind;
@ -44,7 +46,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@Override
public String getDescription() {
Trigger trigger = pipe.getTrigger(slot);
ITrigger trigger = pipe.getTrigger(slot);
if (trigger != null)
return trigger.getDescription();
else
@ -53,7 +55,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@Override
public String getTexture() {
Trigger trigger = pipe.getTrigger(slot);
ITrigger trigger = pipe.getTrigger(slot);
if (trigger != null)
return trigger.getTextureFile();
else
@ -62,7 +64,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@Override
public int getTextureIndex() {
Trigger trigger = pipe.getTrigger(slot);
ITrigger trigger = pipe.getTrigger(slot);
if (trigger != null)
return trigger.getIndexInTexture();
else
@ -74,7 +76,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
return pipe.getTrigger(slot) != null;
}
public Trigger getTrigger() {
public ITrigger getTrigger() {
return pipe.getTrigger(slot);
}
}
@ -93,7 +95,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@Override
public String getDescription() {
Action action = pipe.getAction(slot);
IAction action = pipe.getAction(slot);
if (action != null)
return action.getDescription();
else
@ -102,7 +104,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@Override
public String getTexture() {
Action action = pipe.getAction(slot);
IAction action = pipe.getAction(slot);
if (action != null)
return action.getTexture();
else
@ -111,7 +113,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@Override
public int getTextureIndex() {
Action action = pipe.getAction(slot);
IAction action = pipe.getAction(slot);
if (action != null)
return action.getIndexInTexture();
else
@ -123,7 +125,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
return pipe.getAction(slot) != null;
}
public Action getAction() {
public IAction getAction() {
return pipe.getAction(slot);
}
}
@ -147,14 +149,14 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@Override
public ItemStack getItemStack() {
TriggerParameter parameter = pipe.getTriggerParameter(slot);
ITriggerParameter parameter = pipe.getTriggerParameter(slot);
if (parameter != null)
return parameter.getItem();
else
return null;
}
public TriggerParameter getTriggerParameter() {
public ITriggerParameter getTriggerParameter() {
return pipe.getTriggerParameter(slot);
}
}
@ -262,10 +264,10 @@ public class GuiGateInterface extends GuiAdvancedInterface {
AdvancedSlot slot = slots[s];
if (slot instanceof TriggerSlot) {
Trigger trigger = ((TriggerSlot) slot).getTrigger();
ITrigger trigger = ((TriggerSlot) slot).getTrigger();
if (_container.getGateOrdinal() >= GateKind.AND_3.ordinal()) {
TriggerParameter parameter = null;
ITriggerParameter parameter = null;
if (slots[s + nbEntries * 2] != null && slots[s + nbEntries * 2].isDefined())
parameter = ((TriggerParameterSlot) slots[s + nbEntries * 2]).getTriggerParameter();
@ -311,7 +313,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
if (slot instanceof TriggerSlot && _container.hasTriggers()) {
TriggerSlot triggerSlot = (TriggerSlot) slot;
Trigger changed = null;
ITrigger changed = null;
if (triggerSlot.getTrigger() == null) {
if (k == 0)
@ -320,10 +322,10 @@ public class GuiGateInterface extends GuiAdvancedInterface {
changed = _container.getLastTrigger();
} else {
Iterator<Trigger> it = _container.getTriggerIterator(k != 0);
Iterator<ITrigger> it = _container.getTriggerIterator(k != 0);
for (; it.hasNext();) {
Trigger trigger = it.next();
ITrigger trigger = it.next();
if (!it.hasNext()) {
changed = null;
@ -345,7 +347,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
} else if (slot instanceof ActionSlot) {
ActionSlot actionSlot = (ActionSlot) slot;
Action changed = null;
IAction changed = null;
if (actionSlot.getAction() == null) {
if (k == 0)
@ -354,10 +356,10 @@ public class GuiGateInterface extends GuiAdvancedInterface {
changed = _container.getLastAction();
} else {
Iterator<Action> it = _container.getActionIterator(k != 0);
Iterator<IAction> it = _container.getActionIterator(k != 0);
for (; it.hasNext();) {
Action action = it.next();
IAction action = it.next();
if (!it.hasNext()) {
changed = null;
@ -376,7 +378,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
TriggerSlot trigger = (TriggerSlot) slots[position - nbEntries * 2];
if (trigger.isDefined() && trigger.getTrigger().hasParameter()) {
TriggerParameter param = trigger.getTrigger().createParameter();
ITriggerParameter param = trigger.getTrigger().createParameter();
if (param != null) {
param.set(mc.thePlayer.inventory.getItemStack());

View file

@ -11,9 +11,10 @@ package net.minecraft.src;
import java.io.File;
import java.util.TreeMap;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.api.gates.ActionManager;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.liquids.LiquidData;
import net.minecraft.src.buildcraft.api.liquids.LiquidManager;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;
@ -288,8 +289,8 @@ public class BuildCraftCore {
BuildCraftCore.mainConfiguration.save();
BuildCraftAPI.registerTriggerProvider(new DefaultTriggerProvider());
BuildCraftAPI.registerActionProvider(new DefaultActionProvider());
ActionManager.registerTriggerProvider(new DefaultTriggerProvider());
ActionManager.registerActionProvider(new DefaultActionProvider());
}
public static void initializeModel(BaseMod mod) {

View file

@ -12,8 +12,8 @@ import java.util.Random;
import java.util.TreeMap;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.fuels.IronEngineFuel;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.liquids.LiquidData;
import net.minecraft.src.buildcraft.api.liquids.LiquidManager;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;

View file

@ -10,10 +10,11 @@ package net.minecraft.src;
import java.util.LinkedList;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.api.gates.ActionManager;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.recipes.AssemblyRecipe;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
@ -314,7 +315,7 @@ public class BuildCraftTransport {
BuildCraftCore.itemBptProps[pipeLiquidsIron.shiftedIndex] = new BptItemPipeIron();
BuildCraftCore.itemBptProps[pipeItemsDiamond.shiftedIndex] = new BptItemPipeDiamond();
BuildCraftAPI.registerTriggerProvider(new PipeTriggerProvider());
ActionManager.registerTriggerProvider(new PipeTriggerProvider());
if (BuildCraftCore.loadDefaultRecipes)
loadRecipes();

View file

@ -18,6 +18,10 @@ import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.api.gates.IActionProvider;
import net.minecraft.src.buildcraft.api.gates.ITriggerProvider;
import net.minecraft.src.buildcraft.api.gates.Trigger;
public class BuildCraftAPI {
@ -35,21 +39,18 @@ public class BuildCraftAPI {
/**
* This does not do anything anymore. Use buildcraft.api.liquids.LiquidManager!
*/
//@Deprecated public static LinkedList<LiquidData> liquids = new LinkedList<LiquidData>();
@Deprecated public static LinkedList<LiquidData> liquids = new LinkedList<LiquidData>();
/**
* This does not do anything anymore. Use buildcraft.api.fuels.IronEngineFuel!
*/
@Deprecated public static HashMap<Integer, IronEngineFuel> ironEngineFuel = new HashMap<Integer, IronEngineFuel>();
public static Trigger[] triggers = new Trigger[1024];
public static Action[] actions = new Action[1024];
private static EntityPlayer buildCraftPlayer;
/**
* This does not do anything anymore. Use buildcraft.api.recipes.RefineryRecipe!
*/
//@Deprecated private static LinkedList<RefineryRecipe> refineryRecipe = new LinkedList<RefineryRecipe>();
private static LinkedList<ITriggerProvider> triggerProviders = new LinkedList<ITriggerProvider>();
private static LinkedList<IActionProvider> actionProviders = new LinkedList<IActionProvider>();
@Deprecated private static LinkedList<RefineryRecipe> refineryRecipe = new LinkedList<RefineryRecipe>();
@Deprecated public static Trigger[] triggers = new Trigger[1024];
@Deprecated public static Action[] actions = new Action[1024];
/**
* This does not do anything anymore. Use buildcraft.api.liquids.LiquidManager!
@ -142,13 +143,12 @@ public class BuildCraftAPI {
/**
* This does not do anything anymore. Use buildcraft.api.recipes.RefineryRecipe!
*/
/*
@Deprecated
public static void registerRefineryRecipe(RefineryRecipe recipe) {
if (!refineryRecipe.contains(recipe)) {
refineryRecipe.add(recipe);
}
} */
}
/**
* This does not do anything anymore. Use buildcraft.api.recipes.RefineryRecipe!
@ -200,12 +200,17 @@ public class BuildCraftAPI {
return sig;
}
@Deprecated private static LinkedList<ITriggerProvider> triggerProviders = new LinkedList<ITriggerProvider>();
@Deprecated private static LinkedList<IActionProvider> actionProviders = new LinkedList<IActionProvider>();
@Deprecated
public static void registerTriggerProvider(ITriggerProvider provider) {
if (provider != null && !triggerProviders.contains(provider)) {
triggerProviders.add(provider);
}
}
@Deprecated
public static LinkedList<Trigger> getNeighborTriggers(Block block, TileEntity entity) {
LinkedList<Trigger> triggers = new LinkedList<Trigger>();
@ -224,12 +229,14 @@ public class BuildCraftAPI {
return triggers;
}
@Deprecated
public static void registerActionProvider(IActionProvider provider) {
if (provider != null && !actionProviders.contains(provider)) {
actionProviders.add(provider);
}
}
@Deprecated
public static LinkedList<Action> getNeighborActions(Block block, TileEntity entity) {
LinkedList<Action> actions = new LinkedList<Action>();
@ -248,6 +255,7 @@ public class BuildCraftAPI {
return actions;
}
@Deprecated
public static LinkedList<Trigger> getPipeTriggers(IPipe pipe) {
LinkedList<Trigger> triggers = new LinkedList<Trigger>();

View file

@ -11,6 +11,7 @@ package net.minecraft.src.buildcraft.api;
import net.minecraft.src.IBlockAccess;
@Deprecated
public interface ILegacyPipeConnection {
public boolean isPipeConnected(IBlockAccess blockAccess, int x1, int y1, int z1, int x2, int y2, int z2);

View file

@ -1,72 +0,0 @@
/**
* Copyright (c) SpaceToad, 2011
* 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 net.minecraft.src.buildcraft.api;
import net.minecraft.src.TileEntity;
/**
* 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 Trigger {
public int id;
/**
* Creates a new triggers, and stores it in the trigger list
*/
public Trigger(int id) {
this.id = id;
BuildCraftAPI.triggers[id] = this;
}
/**
* Return the texture file for this trigger icon
*/
public abstract String getTextureFile();
/**
* Return the icon id in the texture file
*/
public int getIndexInTexture() {
return 0;
}
/**
* Return true if this trigger can accept parameters
*/
public boolean hasParameter() {
return false;
}
/**
* Return the trigger description in the UI
*/
public String getDescription() {
return "";
}
/**
* Return true if the tile given in parameter activates the trigger, given
* the parameters.
*/
public boolean isTriggerActive(TileEntity tile, TriggerParameter parameter) {
return false;
}
/**
* Create parameters for the trigger. As for now, there is only one kind of
* trigger parameter available so this subprogram is final.
*/
public final TriggerParameter createParameter() {
return new TriggerParameter();
}
}

View file

@ -7,27 +7,37 @@
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api;
package net.minecraft.src.buildcraft.api.gates;
public abstract class Action {
public int id;
public abstract class Action implements IAction {
protected int id;
public Action(int id) {
this.id = id;
BuildCraftAPI.actions[id] = this;
ActionManager.actions[id] = this;
}
@Override
public int getId() {
return this.id;
}
@Override
public abstract String getTexture();
@Override
public int getIndexInTexture() {
return 0;
}
@Override
public boolean hasParameter() {
return false;
}
@Override
public String getDescription() {
return "";
}

View file

@ -0,0 +1,84 @@
package net.minecraft.src.buildcraft.api.gates;
import java.util.LinkedList;
import net.minecraft.src.Block;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.IPipe;
public class ActionManager {
public static Trigger[] triggers = new Trigger[1024];
public static Action[] actions = new Action[1024];
private static LinkedList<ITriggerProvider> triggerProviders = new LinkedList<ITriggerProvider>();
private static LinkedList<IActionProvider> actionProviders = new LinkedList<IActionProvider>();
public static void registerTriggerProvider(ITriggerProvider provider) {
if (provider != null && !triggerProviders.contains(provider)) {
triggerProviders.add(provider);
}
}
public static LinkedList<Trigger> getNeighborTriggers(Block block, TileEntity entity) {
LinkedList<Trigger> triggers = new LinkedList<Trigger>();
for (ITriggerProvider provider : triggerProviders) {
LinkedList<Trigger> toAdd = provider.getNeighborTriggers(block, entity);
if (toAdd != null) {
for (Trigger t : toAdd) {
if (!triggers.contains(t)) {
triggers.add(t);
}
}
}
}
return triggers;
}
public static void registerActionProvider(IActionProvider provider) {
if (provider != null && !actionProviders.contains(provider)) {
actionProviders.add(provider);
}
}
public static LinkedList<Action> getNeighborActions(Block block, TileEntity entity) {
LinkedList<Action> actions = new LinkedList<Action>();
for (IActionProvider provider : actionProviders) {
LinkedList<Action> toAdd = provider.getNeighborActions(block, entity);
if (toAdd != null) {
for (Action t : toAdd) {
if (!actions.contains(t)) {
actions.add(t);
}
}
}
}
return actions;
}
public static LinkedList<Trigger> getPipeTriggers(IPipe pipe) {
LinkedList<Trigger> triggers = new LinkedList<Trigger>();
for (ITriggerProvider provider : triggerProviders) {
LinkedList<Trigger> toAdd = provider.getPipeTriggers(pipe);
if (toAdd != null) {
for (Trigger t : toAdd) {
if (!triggers.contains(t)) {
triggers.add(t);
}
}
}
}
return triggers;
}
}

View file

@ -0,0 +1,11 @@
package net.minecraft.src.buildcraft.api.gates;
public interface IAction {
int getId();
String getTexture();
int getIndexInTexture();
boolean hasParameter();
String getDescription();
}

View file

@ -7,7 +7,7 @@
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api;
package net.minecraft.src.buildcraft.api.gates;
import java.util.LinkedList;

View file

@ -7,10 +7,11 @@
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api;
package net.minecraft.src.buildcraft.api.gates;
public interface IActionReceptor {
public void actionActivated(Action action);
public void actionActivated(IAction action);
}

View file

@ -7,10 +7,11 @@
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api;
package net.minecraft.src.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

View file

@ -0,0 +1,41 @@
package net.minecraft.src.buildcraft.api.gates;
import net.minecraft.src.TileEntity;
public interface ITrigger {
public abstract int getId();
/**
* Return the texture file for this trigger icon
*/
public abstract String getTextureFile();
/**
* Return the icon id in the texture file
*/
public abstract int getIndexInTexture();
/**
* Return true if this trigger can accept parameters
*/
public abstract boolean hasParameter();
/**
* Return the trigger description in the UI
*/
public abstract String getDescription();
/**
* Return true if the tile given in parameter activates the trigger, given
* the parameters.
*/
public abstract boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter);
/**
* Create parameters for the trigger. As for now, there is only one kind of
* trigger parameter available so this subprogram is final.
*/
public abstract ITriggerParameter createParameter();
}

View file

@ -0,0 +1,18 @@
package net.minecraft.src.buildcraft.api.gates;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
public interface ITriggerParameter {
public abstract ItemStack getItemStack();
public abstract void set(ItemStack stack);
public abstract void writeToNBT(NBTTagCompound compound);
public abstract void readFromNBT(NBTTagCompound compound);
public abstract ItemStack getItem();
}

View file

@ -7,12 +7,13 @@
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api;
package net.minecraft.src.buildcraft.api.gates;
import java.util.LinkedList;
import net.minecraft.src.Block;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.IPipe;
public interface ITriggerProvider {

View file

@ -0,0 +1,84 @@
/**
* Copyright (c) SpaceToad, 2011
* 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 net.minecraft.src.buildcraft.api.gates;
import net.minecraft.src.TileEntity;
/**
* 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 Trigger implements ITrigger {
protected int id;
/**
* Creates a new triggers, and stores it in the trigger list
*/
public Trigger(int id) {
this.id = id;
ActionManager.triggers[id] = this;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getId()
*/
@Override
public int getId() {
return this.id;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getTextureFile()
*/
@Override
public abstract String getTextureFile();
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getIndexInTexture()
*/
@Override
public int getIndexInTexture() {
return 0;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#hasParameter()
*/
@Override
public boolean hasParameter() {
return false;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#getDescription()
*/
@Override
public String getDescription() {
return "";
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#isTriggerActive(net.minecraft.src.TileEntity, net.minecraft.src.buildcraft.api.gates.TriggerParameter)
*/
@Override
public boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter) {
return false;
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITrigger#createParameter()
*/
@Override
public final ITriggerParameter createParameter() {
return new TriggerParameter();
}
}

View file

@ -7,15 +7,27 @@
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package net.minecraft.src.buildcraft.api;
package net.minecraft.src.buildcraft.api.gates;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
public class TriggerParameter {
public class TriggerParameter implements ITriggerParameter {
public ItemStack stack;
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();
@ -23,6 +35,10 @@ public class TriggerParameter {
}
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#writeToNBT(net.minecraft.src.NBTTagCompound)
*/
@Override
public void writeToNBT(NBTTagCompound compound) {
if (stack != null) {
compound.setInteger("itemID", stack.itemID);
@ -30,6 +46,10 @@ public class TriggerParameter {
}
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#readFromNBT(net.minecraft.src.NBTTagCompound)
*/
@Override
public void readFromNBT(NBTTagCompound compound) {
int itemID = compound.getInteger("itemID");
@ -38,6 +58,10 @@ public class TriggerParameter {
}
}
/* (non-Javadoc)
* @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItem()
*/
@Override
public ItemStack getItem() {
return stack;
}

View file

@ -14,14 +14,14 @@ import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.IActionReceptor;
import net.minecraft.src.buildcraft.api.IAreaProvider;
import net.minecraft.src.buildcraft.api.LaserKind;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.TileNetworkData;
import net.minecraft.src.buildcraft.api.filler.FillerManager;
import net.minecraft.src.buildcraft.api.filler.IFillerPattern;
import net.minecraft.src.buildcraft.api.gates.IAction;
import net.minecraft.src.buildcraft.api.gates.IActionReceptor;
import net.minecraft.src.buildcraft.api.inventory.ISpecialInventory;
import net.minecraft.src.buildcraft.api.power.IPowerProvider;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
@ -375,7 +375,7 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo
}
@Override
public void actionActivated(Action action) {
public void actionActivated(IAction action) {
if (action == BuildCraftCore.actionOn) {
lastMode = ActionMachineControl.Mode.On;
} else if (action == BuildCraftCore.actionOff) {

View file

@ -1,6 +1,6 @@
package net.minecraft.src.buildcraft.core;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.gates.Action;
public class ActionMachineControl extends Action {

View file

@ -9,7 +9,7 @@
package net.minecraft.src.buildcraft.core;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.gates.Action;
public class ActionRedstoneOutput extends Action {

View file

@ -5,8 +5,8 @@ import java.util.LinkedList;
import net.minecraft.src.Block;
import net.minecraft.src.BuildCraftCore;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.IActionProvider;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.api.gates.IActionProvider;
public class DefaultActionProvider implements IActionProvider {

View file

@ -6,11 +6,11 @@ import net.minecraft.src.Block;
import net.minecraft.src.BuildCraftCore;
import net.minecraft.src.IInventory;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.gates.IOverrideDefaultTriggers;
import net.minecraft.src.buildcraft.api.gates.ITriggerProvider;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.liquids.ITankContainer;
import net.minecraft.src.buildcraft.api.IOverrideDefaultTriggers;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.ITriggerProvider;
import net.minecraft.src.buildcraft.api.Trigger;
public class DefaultTriggerProvider implements ITriggerProvider {

View file

@ -12,8 +12,8 @@ package net.minecraft.src.buildcraft.core;
import net.minecraft.src.IInventory;
import net.minecraft.src.ItemStack;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
public class TriggerInventory extends Trigger {
@ -66,7 +66,7 @@ public class TriggerInventory extends Trigger {
}
@Override
public boolean isTriggerActive(TileEntity tile, TriggerParameter parameter) {
public boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter) {
ItemStack searchedStack = null;
if (parameter != null)
@ -81,11 +81,11 @@ public class TriggerInventory extends Trigger {
for (int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack stack = inv.getStackInSlot(i);
if (parameter == null || parameter.stack == null)
if (parameter == null || parameter.getItemStack() == null)
foundItems = foundItems || stack != null && stack.stackSize > 0;
else if (stack != null && stack.stackSize > 0)
foundItems = foundItems
|| (stack.itemID == parameter.stack.itemID && stack.getItemDamage() == parameter.stack
|| (stack.itemID == parameter.getItemStack().itemID && stack.getItemDamage() == parameter.getItemStack()
.getItemDamage());
if (stack == null || stack.stackSize == 0)

View file

@ -11,8 +11,8 @@ package net.minecraft.src.buildcraft.core;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.liquids.ILiquidTank;
import net.minecraft.src.buildcraft.api.liquids.ITankContainer;
import net.minecraft.src.buildcraft.api.liquids.LiquidManager;
@ -67,7 +67,7 @@ public class TriggerLiquidContainer extends Trigger {
}
@Override
public boolean isTriggerActive(TileEntity tile, TriggerParameter parameter) {
public boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter) {
if (tile instanceof ITankContainer) {
ITankContainer container = (ITankContainer) tile;

View file

@ -10,8 +10,8 @@
package net.minecraft.src.buildcraft.core;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
public class TriggerMachine extends Trigger {
@ -40,7 +40,7 @@ public class TriggerMachine extends Trigger {
}
@Override
public boolean isTriggerActive(TileEntity tile, TriggerParameter parameter) {
public boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter) {
if (tile instanceof IMachine) {
IMachine machine = (IMachine) tile;

View file

@ -20,12 +20,12 @@ import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.Packet;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.IOverrideDefaultTriggers;
import net.minecraft.src.buildcraft.api.IPipeConnection;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.TileNetworkData;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.IOverrideDefaultTriggers;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.liquids.ILiquidTank;
import net.minecraft.src.buildcraft.api.liquids.ITankContainer;
import net.minecraft.src.buildcraft.api.liquids.LiquidStack;

View file

@ -10,8 +10,8 @@
package net.minecraft.src.buildcraft.energy;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.core.DefaultProps;
public class TriggerEngineHeat extends Trigger {
@ -53,7 +53,7 @@ public class TriggerEngineHeat extends Trigger {
}
@Override
public boolean isTriggerActive(TileEntity tile, TriggerParameter parameter) {
public boolean isTriggerActive(TileEntity tile, ITriggerParameter parameter) {
if (tile instanceof TileEngine) {
Engine engine = ((TileEngine) tile).engine;

View file

@ -1,6 +1,6 @@
package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.core.DefaultProps;
public class ActionEnergyPulser extends Action {

View file

@ -9,8 +9,8 @@
package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.core.DefaultProps;
public class ActionSignalOutput extends Action {

View file

@ -20,9 +20,9 @@ import net.minecraft.src.mod_BuildCraftTransport;
import net.minecraft.src.buildcraft.api.BlockSignature;
import net.minecraft.src.buildcraft.api.BptBlock;
import net.minecraft.src.buildcraft.api.BptSlotInfo;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.IBptContext;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.ActionManager;
import net.minecraft.src.buildcraft.api.gates.TriggerParameter;
public class BptBlockPipe extends BptBlock {
@ -93,7 +93,7 @@ public class BptBlockPipe extends BptBlock {
for (int i = 0; i < 8; ++i) {
if (slot.cpt.hasKey("trigger" + i))
pipe.activatedTriggers[i] = BuildCraftAPI.triggers[slot.cpt.getInteger("trigger" + i)];
pipe.activatedTriggers[i] = ActionManager.triggers[slot.cpt.getInteger("trigger" + i)];
if (slot.cpt.hasKey("triggerParameter" + i)) {
ItemStack s = ItemStack.loadItemStackFromNBT((NBTTagCompound) slot.cpt.getTag("triggerParameter" + i));
@ -105,7 +105,7 @@ public class BptBlockPipe extends BptBlock {
}
if (slot.cpt.hasKey("action" + i))
pipe.activatedActions[i] = BuildCraftAPI.actions[slot.cpt.getInteger("action" + i)];
pipe.activatedActions[i] = ActionManager.actions[slot.cpt.getInteger("action" + i)];
}
}
@ -132,17 +132,17 @@ public class BptBlockPipe extends BptBlock {
for (int i = 0; i < 8; ++i) {
if (pipe.activatedTriggers[i] != null)
bptSlot.cpt.setInteger("trigger" + i, pipe.activatedTriggers[i].id);
bptSlot.cpt.setInteger("trigger" + i, pipe.activatedTriggers[i].getId());
if (pipe.triggerParameters[i] != null) {
NBTTagCompound subCpt = new NBTTagCompound();
pipe.triggerParameters[i].stack.writeToNBT(subCpt);
pipe.triggerParameters[i].getItemStack().writeToNBT(subCpt);
bptSlot.cpt.setTag("triggerParameter" + i, subCpt);
}
if (pipe.activatedActions[i] != null)
bptSlot.cpt.setInteger("action" + i, pipe.activatedActions[i].id);
bptSlot.cpt.setInteger("action" + i, pipe.activatedActions[i].getId());
}
}

View file

@ -19,12 +19,16 @@ import net.minecraft.src.ItemStack;
import net.minecraft.src.Slot;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.api.gates.ActionManager;
import net.minecraft.src.buildcraft.api.gates.IAction;
import net.minecraft.src.buildcraft.api.gates.ITrigger;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.gates.TriggerParameter;
import net.minecraft.src.buildcraft.core.BuildCraftContainer;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.network.PacketCoordinates;
@ -37,8 +41,8 @@ public class CraftingGateInterface extends BuildCraftContainer {
IInventory playerIInventory;
Pipe pipe;
private final LinkedList<Trigger> _potentialTriggers = new LinkedList<Trigger>();
private final LinkedList<Action> _potentialActions = new LinkedList<Action>();
private final LinkedList<ITrigger> _potentialTriggers = new LinkedList<ITrigger>();
private final LinkedList<IAction> _potentialActions = new LinkedList<IAction>();
private boolean isSynchronized = false;
private boolean isNetInitialized = false;
@ -60,7 +64,7 @@ public class CraftingGateInterface extends BuildCraftContainer {
// the client.
if (!APIProxy.isRemote()) {
_potentialActions.addAll(pipe.getActions());
_potentialTriggers.addAll(BuildCraftAPI.getPipeTriggers(pipe));
_potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe));
for (Orientations o : Orientations.dirs()) {
Position pos = new Position(pipe.xCoord, pipe.yCoord, pipe.zCoord, o);
@ -69,13 +73,13 @@ public class CraftingGateInterface extends BuildCraftContainer {
int blockID = pipe.worldObj.getBlockId((int) pos.x, (int) pos.y, (int) pos.z);
Block block = Block.blocksList[blockID];
LinkedList<Trigger> nearbyTriggers = BuildCraftAPI.getNeighborTriggers(block, tile);
LinkedList<Trigger> nearbyTriggers = ActionManager.getNeighborTriggers(block, tile);
for (Trigger t : nearbyTriggers)
if (!_potentialTriggers.contains(t))
_potentialTriggers.add(t);
LinkedList<Action> nearbyActions = BuildCraftAPI.getNeighborActions(block, tile);
LinkedList<Action> nearbyActions = ActionManager.getNeighborActions(block, tile);
for (Action a : nearbyActions)
if (!_potentialActions.contains(a))
@ -110,7 +114,7 @@ public class CraftingGateInterface extends BuildCraftContainer {
int length = packet.payload.intPayload[0];
for (int i = 0; i < length; i++)
_potentialActions.add(BuildCraftAPI.actions[packet.payload.intPayload[i + 1]]);
_potentialActions.add(ActionManager.actions[packet.payload.intPayload[i + 1]]);
}
@ -124,7 +128,7 @@ public class CraftingGateInterface extends BuildCraftContainer {
int length = packet.payload.intPayload[0];
for (int i = 0; i < length; i++)
_potentialTriggers.add(BuildCraftAPI.triggers[packet.payload.intPayload[i + 1]]);
_potentialTriggers.add(ActionManager.triggers[packet.payload.intPayload[i + 1]]);
}
/**
@ -136,8 +140,8 @@ public class CraftingGateInterface extends BuildCraftContainer {
PacketPayload payload = packet.payload;
int position = payload.intPayload[0];
if (payload.intPayload[1] >= 0 && payload.intPayload[1] < BuildCraftAPI.triggers.length) {
setTrigger(position, BuildCraftAPI.triggers[payload.intPayload[1]], false);
if (payload.intPayload[1] >= 0 && payload.intPayload[1] < ActionManager.triggers.length) {
setTrigger(position, ActionManager.triggers[payload.intPayload[1]], false);
// System.out.println("Trigger["+ position + "]: " +
// pipe.activatedTriggers[position].getDescription());
} else {
@ -145,8 +149,8 @@ public class CraftingGateInterface extends BuildCraftContainer {
// System.out.println("Trigger["+ position + "] clear!");
}
if (payload.intPayload[2] >= 0 && payload.intPayload[2] < BuildCraftAPI.actions.length) {
setAction(position, BuildCraftAPI.actions[payload.intPayload[2]], false);
if (payload.intPayload[2] >= 0 && payload.intPayload[2] < ActionManager.actions.length) {
setAction(position, ActionManager.actions[payload.intPayload[2]], false);
// System.out.println("Action["+ position + "]: " +
// pipe.activatedActions[position].getDescription());
} else {
@ -160,7 +164,7 @@ public class CraftingGateInterface extends BuildCraftContainer {
return;
}
TriggerParameter param = new TriggerParameter();
ITriggerParameter param = new TriggerParameter();
param.set(new ItemStack(itemID, payload.intPayload[4], payload.intPayload[5]));
setTriggerParameter(position, param, false);
}
@ -171,19 +175,19 @@ public class CraftingGateInterface extends BuildCraftContainer {
payload.intPayload[0] = position;
if (pipe.activatedTriggers[position] != null)
payload.intPayload[1] = pipe.activatedTriggers[position].id;
payload.intPayload[1] = pipe.activatedTriggers[position].getId();
else
payload.intPayload[1] = -1;
if (pipe.activatedActions[position] != null)
payload.intPayload[2] = pipe.activatedActions[position].id;
payload.intPayload[2] = pipe.activatedActions[position].getId();
else
payload.intPayload[2] = -1;
if (pipe.triggerParameters[position] != null && pipe.triggerParameters[position].stack != null) {
payload.intPayload[3] = pipe.triggerParameters[position].stack.itemID;
payload.intPayload[4] = pipe.triggerParameters[position].stack.stackSize;
payload.intPayload[5] = pipe.triggerParameters[position].stack.getItemDamage();
if (pipe.triggerParameters[position] != null && pipe.triggerParameters[position].getItemStack() != null) {
payload.intPayload[3] = pipe.triggerParameters[position].getItemStack().itemID;
payload.intPayload[4] = pipe.triggerParameters[position].getItemStack().stackSize;
payload.intPayload[5] = pipe.triggerParameters[position].getItemStack().getItemDamage();
}
CoreProxy.sendToServer(new PacketUpdate(PacketIds.GATE_SELECTION_CHANGE, pipe.xCoord, pipe.yCoord, pipe.zCoord, payload)
@ -222,8 +226,8 @@ public class CraftingGateInterface extends BuildCraftContainer {
PacketPayload payload = packet.payload;
int position = payload.intPayload[0];
if (payload.intPayload[1] >= 0 && payload.intPayload[1] < BuildCraftAPI.triggers.length) {
setTrigger(position, BuildCraftAPI.triggers[payload.intPayload[1]], true);
if (payload.intPayload[1] >= 0 && payload.intPayload[1] < ActionManager.triggers.length) {
setTrigger(position, ActionManager.triggers[payload.intPayload[1]], true);
// System.out.println("Trigger["+ position + "]: " +
// pipe.activatedTriggers[position].getDescription());
} else {
@ -231,8 +235,8 @@ public class CraftingGateInterface extends BuildCraftContainer {
// System.out.println("Trigger["+ position + "] clear!");
}
if (payload.intPayload[2] >= 0 && payload.intPayload[2] < BuildCraftAPI.actions.length) {
setAction(position, BuildCraftAPI.actions[payload.intPayload[2]], true);
if (payload.intPayload[2] >= 0 && payload.intPayload[2] < ActionManager.actions.length) {
setAction(position, ActionManager.actions[payload.intPayload[2]], true);
// System.out.println("Action["+ position + "]: " +
// pipe.activatedActions[position].getDescription());
} else {
@ -246,7 +250,7 @@ public class CraftingGateInterface extends BuildCraftContainer {
return;
}
TriggerParameter param = new TriggerParameter();
ITriggerParameter param = new TriggerParameter();
param.set(new ItemStack(itemID, payload.intPayload[4], payload.intPayload[5]));
setTriggerParameter(position, param, true);
}
@ -264,7 +268,7 @@ public class CraftingGateInterface extends BuildCraftContainer {
payload.intPayload[0] = length;
for (int i = 0; i < length; i++)
payload.intPayload[i + 1] = _potentialActions.get(i).id;
payload.intPayload[i + 1] = _potentialActions.get(i).getId();
PacketUpdate packet = new PacketUpdate(PacketIds.GATE_ACTIONS, pipe.xCoord, pipe.yCoord, pipe.zCoord, payload);
@ -285,7 +289,7 @@ public class CraftingGateInterface extends BuildCraftContainer {
payload.intPayload[0] = length;
for (int i = 0; i < length; i++)
payload.intPayload[i + 1] = _potentialTriggers.get(i).id;
payload.intPayload[i + 1] = _potentialTriggers.get(i).getId();
PacketUpdate packet = new PacketUpdate(PacketIds.GATE_TRIGGERS, pipe.xCoord, pipe.yCoord, pipe.zCoord, payload);
@ -326,19 +330,19 @@ public class CraftingGateInterface extends BuildCraftContainer {
payload.intPayload[0] = position;
if (pipe.activatedTriggers[position] != null)
payload.intPayload[1] = pipe.activatedTriggers[position].id;
payload.intPayload[1] = pipe.activatedTriggers[position].getId();
else
payload.intPayload[1] = -1;
if (pipe.activatedActions[position] != null)
payload.intPayload[2] = pipe.activatedActions[position].id;
payload.intPayload[2] = pipe.activatedActions[position].getId();
else
payload.intPayload[2] = -1;
if (pipe.triggerParameters[position] != null && pipe.triggerParameters[position].stack != null) {
payload.intPayload[3] = pipe.triggerParameters[position].stack.itemID;
payload.intPayload[4] = pipe.triggerParameters[position].stack.stackSize;
payload.intPayload[5] = pipe.triggerParameters[position].stack.getItemDamage();
if (pipe.triggerParameters[position] != null && pipe.triggerParameters[position].getItemStack() != null) {
payload.intPayload[3] = pipe.triggerParameters[position].getItemStack().itemID;
payload.intPayload[4] = pipe.triggerParameters[position].getItemStack().stackSize;
payload.intPayload[5] = pipe.triggerParameters[position].getItemStack().getItemDamage();
}
CoreProxy.sendToPlayer(player, new PacketUpdate(PacketIds.GATE_SELECTION, pipe.xCoord, pipe.yCoord, pipe.zCoord,
@ -353,29 +357,29 @@ public class CraftingGateInterface extends BuildCraftContainer {
return _potentialTriggers.size() > 0;
}
public Trigger getFirstTrigger() {
public ITrigger getFirstTrigger() {
return _potentialTriggers.size() > 0 ? _potentialTriggers.getFirst() : null;
}
public Trigger getLastTrigger() {
public ITrigger getLastTrigger() {
return _potentialTriggers.size() > 0 ? _potentialTriggers.getLast() : null;
}
public Iterator<Trigger> getTriggerIterator(boolean descending) {
public Iterator<ITrigger> getTriggerIterator(boolean descending) {
return descending ? _potentialTriggers.descendingIterator() : _potentialTriggers.iterator();
}
public boolean isNearbyTriggerActive(Trigger trigger, TriggerParameter parameter) {
public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) {
return pipe.isNearbyTriggerActive(trigger, parameter);
}
public void setTrigger(int position, Trigger trigger, boolean notify) {
public void setTrigger(int position, ITrigger trigger, boolean notify) {
pipe.setTrigger(position, trigger);
if (APIProxy.isRemote() && notify)
sendSelectionChange(position);
}
public void setTriggerParameter(int position, TriggerParameter parameter, boolean notify) {
public void setTriggerParameter(int position, ITriggerParameter parameter, boolean notify) {
pipe.setTriggerParameter(position, parameter);
if (APIProxy.isRemote() && notify)
sendSelectionChange(position);
@ -386,19 +390,19 @@ public class CraftingGateInterface extends BuildCraftContainer {
return _potentialActions.size() > 0;
}
public Action getFirstAction() {
public IAction getFirstAction() {
return _potentialActions.size() > 0 ? _potentialActions.getFirst() : null;
}
public Action getLastAction() {
public IAction getLastAction() {
return _potentialActions.size() > 0 ? _potentialActions.getLast() : null;
}
public Iterator<Action> getActionIterator(boolean descending) {
public Iterator<IAction> getActionIterator(boolean descending) {
return descending ? _potentialActions.descendingIterator() : _potentialActions.iterator();
}
public void setAction(int position, Action action, boolean notify) {
public void setAction(int position, IAction action, boolean notify) {
pipe.setAction(position, action);
if (APIProxy.isRemote() && notify)
sendSelectionChange(position);

View file

@ -7,8 +7,9 @@ import net.minecraft.src.EntityPlayer;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.api.gates.IAction;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.core.network.IndexInPayload;
import net.minecraft.src.buildcraft.core.network.PacketPayload;
@ -91,11 +92,11 @@ public abstract class Gate {
public abstract GateConditional getConditional();
// / ACTIONS
public abstract void addActions(LinkedList<Action> list);
public abstract void addActions(LinkedList<IAction> list);
public abstract void startResolution();
public abstract boolean resolveAction(Action action);
public abstract boolean resolveAction(IAction action);
// / TRIGGERS
public abstract void addTrigger(LinkedList<Trigger> list);

View file

@ -10,9 +10,10 @@ import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.World;
import net.minecraft.src.mod_BuildCraftTransport;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.api.gates.IAction;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.GuiIds;
@ -174,7 +175,7 @@ public class GateVanilla extends Gate {
// / ACTIONS
@Override
public void addActions(LinkedList<Action> list) {
public void addActions(LinkedList<IAction> list) {
if (pipe.wireSet[IPipe.WireColor.Red.ordinal()] && kind.ordinal() >= Gate.GateKind.AND_2.ordinal())
list.add(BuildCraftTransport.actionRedSignal);
@ -200,7 +201,7 @@ public class GateVanilla extends Gate {
}
@Override
public boolean resolveAction(Action action) {
public boolean resolveAction(IAction action) {
if (action instanceof ActionEnergyPulser) {
pulser.enablePulse();

View file

@ -9,10 +9,10 @@
package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
public interface ITriggerPipe {
public boolean isTriggerActive(Pipe pipe, TriggerParameter parameter);
public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter);
}

View file

@ -22,15 +22,18 @@ import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraft.src.buildcraft.api.Action;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.IActionReceptor;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
import net.minecraft.src.buildcraft.api.TileNetworkData;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Action;
import net.minecraft.src.buildcraft.api.gates.ActionManager;
import net.minecraft.src.buildcraft.api.gates.IAction;
import net.minecraft.src.buildcraft.api.gates.IActionReceptor;
import net.minecraft.src.buildcraft.api.gates.ITrigger;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.gates.TriggerParameter;
import net.minecraft.src.buildcraft.core.ActionRedstoneOutput;
import net.minecraft.src.buildcraft.core.IDropControlInventory;
import net.minecraft.src.buildcraft.core.Utils;
@ -66,9 +69,9 @@ public class Pipe implements IPipe, IDropControlInventory {
@SuppressWarnings("rawtypes")
private static Map<Class, TilePacketWrapper> networkWrappers = new HashMap<Class, TilePacketWrapper>();
Trigger[] activatedTriggers = new Trigger[8];
TriggerParameter[] triggerParameters = new TriggerParameter[8];
Action[] activatedActions = new Action[8];
ITrigger[] activatedTriggers = new Trigger[8];
ITriggerParameter[] triggerParameters = new ITriggerParameter[8];
IAction[] activatedActions = new Action[8];
@TileNetworkData(intKind = TileNetworkData.UNSIGNED_BYTE)
public boolean broadcastSignal[] = new boolean[] { false, false, false, false };
@ -222,8 +225,8 @@ public class Pipe implements IPipe, IDropControlInventory {
nbttagcompound.setBoolean("wireSet[" + i + "]", wireSet[i]);
for (int i = 0; i < 8; ++i) {
nbttagcompound.setInteger("action[" + i + "]", activatedActions[i] != null ? activatedActions[i].id : 0);
nbttagcompound.setInteger("trigger[" + i + "]", activatedTriggers[i] != null ? activatedTriggers[i].id : 0);
nbttagcompound.setInteger("action[" + i + "]", activatedActions[i] != null ? activatedActions[i].getId() : 0);
nbttagcompound.setInteger("trigger[" + i + "]", activatedTriggers[i] != null ? activatedTriggers[i].getId() : 0);
}
for (int i = 0; i < 8; ++i)
@ -256,8 +259,8 @@ public class Pipe implements IPipe, IDropControlInventory {
wireSet[i] = nbttagcompound.getBoolean("wireSet[" + i + "]");
for (int i = 0; i < 8; ++i) {
activatedActions[i] = BuildCraftAPI.actions[nbttagcompound.getInteger("action[" + i + "]")];
activatedTriggers[i] = BuildCraftAPI.triggers[nbttagcompound.getInteger("trigger[" + i + "]")];
activatedActions[i] = ActionManager.actions[nbttagcompound.getInteger("action[" + i + "]")];
activatedTriggers[i] = ActionManager.triggers[nbttagcompound.getInteger("trigger[" + i + "]")];
}
for (int i = 0; i < 8; ++i)
@ -479,23 +482,23 @@ public class Pipe implements IPipe, IDropControlInventory {
gate.dropGate(worldObj, xCoord, yCoord, zCoord);
}
public void setTrigger(int position, Trigger trigger) {
public void setTrigger(int position, ITrigger trigger) {
activatedTriggers[position] = trigger;
}
public Trigger getTrigger(int position) {
public ITrigger getTrigger(int position) {
return activatedTriggers[position];
}
public void setTriggerParameter(int position, TriggerParameter p) {
public void setTriggerParameter(int position, ITriggerParameter p) {
triggerParameters[position] = p;
}
public TriggerParameter getTriggerParameter(int position) {
public ITriggerParameter getTriggerParameter(int position) {
return triggerParameters[position];
}
public boolean isNearbyTriggerActive(Trigger trigger, TriggerParameter parameter) {
public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) {
if (trigger instanceof ITriggerPipe)
return ((ITriggerPipe) trigger).isTriggerActive(this, parameter);
else if (trigger != null)
@ -509,12 +512,12 @@ public class Pipe implements IPipe, IDropControlInventory {
return false;
}
public boolean isTriggerActive(Trigger trigger) {
public boolean isTriggerActive(ITrigger trigger) {
return false;
}
public LinkedList<Action> getActions() {
LinkedList<Action> result = new LinkedList<Action>();
public LinkedList<IAction> getActions() {
LinkedList<IAction> result = new LinkedList<IAction>();
if (hasGate())
gate.addActions(result);
@ -522,18 +525,18 @@ public class Pipe implements IPipe, IDropControlInventory {
return result;
}
public Action getAction(int position) {
public IAction getAction(int position) {
return activatedActions[position];
}
public void setAction(int position, Action action) {
public void setAction(int position, IAction action) {
activatedActions[position] = action;
}
public void resetGate() {
gate = null;
activatedTriggers = new Trigger[activatedTriggers.length];
triggerParameters = new TriggerParameter[triggerParameters.length];
triggerParameters = new ITriggerParameter[triggerParameters.length];
activatedActions = new Action[activatedActions.length];
broadcastSignal = new boolean[] { false, false, false, false };
broadcastRedstone = false;
@ -558,17 +561,17 @@ public class Pipe implements IPipe, IDropControlInventory {
// Computes the actions depending on the triggers
for (int it = 0; it < 8; ++it) {
Trigger trigger = activatedTriggers[it];
Action action = activatedActions[it];
TriggerParameter parameter = triggerParameters[it];
ITrigger trigger = activatedTriggers[it];
IAction action = activatedActions[it];
ITriggerParameter parameter = triggerParameters[it];
if (trigger != null && action != null)
if (!actions.containsKey(action.id))
actions.put(action.id, isNearbyTriggerActive(trigger, parameter));
if (!actions.containsKey(action.getId()))
actions.put(action.getId(), isNearbyTriggerActive(trigger, parameter));
else if (gate.getConditional() == GateConditional.AND)
actions.put(action.id, actions.get(action.id) && isNearbyTriggerActive(trigger, parameter));
actions.put(action.getId(), actions.get(action.getId()) && isNearbyTriggerActive(trigger, parameter));
else
actions.put(action.id, actions.get(action.id) || isNearbyTriggerActive(trigger, parameter));
actions.put(action.getId(), actions.get(action.getId()) || isNearbyTriggerActive(trigger, parameter));
}
// Activate the actions
@ -576,18 +579,18 @@ public class Pipe implements IPipe, IDropControlInventory {
if (actions.get(i)) {
// Custom gate actions take precedence over defaults.
if (gate.resolveAction(BuildCraftAPI.actions[i]))
if (gate.resolveAction(ActionManager.actions[i]))
continue;
if (BuildCraftAPI.actions[i] instanceof ActionRedstoneOutput)
if (ActionManager.actions[i] instanceof ActionRedstoneOutput)
broadcastRedstone = true;
else if (BuildCraftAPI.actions[i] instanceof ActionSignalOutput)
broadcastSignal[((ActionSignalOutput) BuildCraftAPI.actions[i]).color.ordinal()] = true;
else if (ActionManager.actions[i] instanceof ActionSignalOutput)
broadcastSignal[((ActionSignalOutput) ActionManager.actions[i]).color.ordinal()] = true;
else
for (int a = 0; a < container.tileBuffer.length; ++a)
if (container.tileBuffer[a].getTile() instanceof IActionReceptor) {
IActionReceptor recept = (IActionReceptor) container.tileBuffer[a].getTile();
recept.actionActivated(BuildCraftAPI.actions[i]);
recept.actionActivated(ActionManager.actions[i]);
}
}

View file

@ -30,7 +30,7 @@ import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.IPipeEntry;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.ITrigger;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.core.IMachine;
@ -437,7 +437,7 @@ public class PipeTransportItems extends PipeTransport {
return true;
}
public boolean isTriggerActive(Trigger trigger) {
public boolean isTriggerActive(ITrigger trigger) {
return false;
}

View file

@ -22,7 +22,7 @@ import net.minecraft.src.buildcraft.api.LiquidSlot;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.TileNetworkData;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.ITrigger;
import net.minecraft.src.buildcraft.core.IMachine;
import net.minecraft.src.buildcraft.core.Utils;
@ -488,7 +488,7 @@ public class PipeTransportLiquids extends PipeTransport implements ILiquidContai
return splitVector;
}
public boolean isTriggerActive(Trigger trigger) {
public boolean isTriggerActive(ITrigger trigger) {
return false;
}

View file

@ -17,7 +17,7 @@ import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
import net.minecraft.src.buildcraft.api.TileNetworkData;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.ITrigger;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
import net.minecraft.src.buildcraft.core.CoreProxy;
import net.minecraft.src.buildcraft.core.DefaultProps;
@ -221,7 +221,7 @@ public class PipeTransportPower extends PipeTransport {
}
}
public boolean isTriggerActive(Trigger trigger) {
public boolean isTriggerActive(ITrigger trigger) {
return false;
}

View file

@ -5,10 +5,10 @@ import java.util.LinkedList;
import net.minecraft.src.Block;
import net.minecraft.src.BuildCraftTransport;
import net.minecraft.src.TileEntity;
import net.minecraft.src.buildcraft.api.IOverrideDefaultTriggers;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.ITriggerProvider;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.IOverrideDefaultTriggers;
import net.minecraft.src.buildcraft.api.gates.ITriggerProvider;
import net.minecraft.src.buildcraft.api.gates.Trigger;
public class PipeTriggerProvider implements ITriggerProvider {

View file

@ -22,7 +22,6 @@ import net.minecraft.src.mod_BuildCraftCore;
import net.minecraft.src.buildcraft.api.APIProxy;
import net.minecraft.src.buildcraft.api.EntityPassiveItem;
import net.minecraft.src.buildcraft.api.ILiquidContainer;
import net.minecraft.src.buildcraft.api.IOverrideDefaultTriggers;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.IPipeConnection;
import net.minecraft.src.buildcraft.api.IPipeEntry;
@ -33,7 +32,8 @@ import net.minecraft.src.buildcraft.api.Orientations;
import net.minecraft.src.buildcraft.api.Position;
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
import net.minecraft.src.buildcraft.api.TileNetworkData;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.gates.IOverrideDefaultTriggers;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.power.IPowerProvider;
import net.minecraft.src.buildcraft.api.power.IPowerReceptor;
import net.minecraft.src.buildcraft.api.power.PowerProvider;

View file

@ -10,8 +10,8 @@
package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.buildcraft.api.BuildCraftAPI;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.api.liquids.LiquidManager;
import net.minecraft.src.buildcraft.core.DefaultProps;
import net.minecraft.src.buildcraft.transport.PipeTransportLiquids.LiquidBuffer;
@ -73,7 +73,7 @@ public class TriggerPipeContents extends Trigger implements ITriggerPipe {
}
@Override
public boolean isTriggerActive(Pipe pipe, TriggerParameter parameter) {
public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) {
if (pipe.transport instanceof PipeTransportItems) {
PipeTransportItems transportItems = (PipeTransportItems) pipe.transport;

View file

@ -10,8 +10,8 @@
package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.buildcraft.api.IPipe;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.core.DefaultProps;
public class TriggerPipeSignal extends Trigger implements ITriggerPipe {
@ -88,7 +88,7 @@ public class TriggerPipeSignal extends Trigger implements ITriggerPipe {
}
@Override
public boolean isTriggerActive(Pipe pipe, TriggerParameter parameter) {
public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) {
if (active)
return pipe.signalStrength[color.ordinal()] > 0;
else

View file

@ -9,8 +9,8 @@
package net.minecraft.src.buildcraft.transport;
import net.minecraft.src.buildcraft.api.Trigger;
import net.minecraft.src.buildcraft.api.TriggerParameter;
import net.minecraft.src.buildcraft.api.gates.ITriggerParameter;
import net.minecraft.src.buildcraft.api.gates.Trigger;
import net.minecraft.src.buildcraft.core.DefaultProps;
public class TriggerRedstoneInput extends Trigger implements ITriggerPipe {
@ -40,7 +40,7 @@ public class TriggerRedstoneInput extends Trigger implements ITriggerPipe {
}
@Override
public boolean isTriggerActive(Pipe pipe, TriggerParameter parameter) {
public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) {
if (active)
return pipe.worldObj.isBlockIndirectlyGettingPowered(pipe.xCoord, pipe.yCoord, pipe.zCoord);
else