BuildCraft API cleanup and update

This commit is contained in:
aidancbrady 2015-11-25 10:24:45 -07:00
parent 79483d1fa7
commit 0313e59b8f
68 changed files with 60 additions and 1000 deletions

30
src/api/java/buildcraft/api/core/BCLog.java Normal file → Executable file
View file

@ -8,32 +8,24 @@
*/
package buildcraft.api.core;
import java.lang.reflect.Method;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class BCLog {
public static final Logger logger = LogManager.getLogger("BuildCraft");
/**
* Deactivate constructor
*/
private BCLog() {
}
public static void initLog() {
logger.info("Starting BuildCraft " + getVersion());
logger.info("Copyright (c) SpaceToad, 2011-2015");
logger.info("http://www.mod-buildcraft.com");
@Deprecated
public static void logErrorAPI(String mod, Throwable error, Class<?> classFile) {
logErrorAPI(error, classFile);
}
public static void logErrorAPI(String mod, Throwable error, Class<?> classFile) {
StringBuilder msg = new StringBuilder(mod);
msg.append(" API error, please update your mods. Error: ").append(error);
public static void logErrorAPI(Throwable error, Class<?> classFile) {
StringBuilder msg = new StringBuilder("API error! Please update your mods. Error: ");
msg.append(error);
StackTraceElement[] stackTrace = error.getStackTrace();
if (stackTrace.length > 0) {
msg.append(", ").append(stackTrace[0]);
@ -42,19 +34,13 @@ public final class BCLog {
logger.log(Level.ERROR, msg.toString());
if (classFile != null) {
msg = new StringBuilder(mod);
msg.append("API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain().getCodeSource().getLocation());
logger.log(Level.ERROR, msg.toString());
}
}
@Deprecated
public static String getVersion() {
try {
Class<?> clazz = Class.forName("buildcraft.core.Version");
Method method = clazz.getDeclaredMethod("getVersion");
return String.valueOf(method.invoke(null));
} catch (Exception e) {
return "UNKNOWN VERSION";
}
return BuildCraftAPI.getVersion();
}
}

3
src/api/java/buildcraft/api/core/BlockIndex.java Normal file → Executable file
View file

@ -18,7 +18,6 @@ import net.minecraft.world.World;
* This class is a comparable container for integer block positions.
*/
public class BlockIndex implements Comparable<BlockIndex> {
public int x;
public int y;
public int z;
@ -31,7 +30,6 @@ public class BlockIndex implements Comparable<BlockIndex> {
* Creates an index for a block located on x, y. z
*/
public BlockIndex(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
@ -58,7 +56,6 @@ public class BlockIndex implements Comparable<BlockIndex> {
*/
@Override
public int compareTo(BlockIndex o) {
if (o.x < x) {
return 1;
} else if (o.x > x) {

11
src/api/java/buildcraft/api/core/BuildCraftAPI.java Normal file → Executable file
View file

@ -8,6 +8,7 @@
*/
package buildcraft.api.core;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@ -28,6 +29,16 @@ public final class BuildCraftAPI {
private BuildCraftAPI() {
}
public static String getVersion() {
try {
Class<?> clazz = Class.forName("buildcraft.core.Version");
Method method = clazz.getDeclaredMethod("getVersion");
return String.valueOf(method.invoke(null));
} catch (Exception e) {
return "UNKNOWN VERSION";
}
}
public static IWorldProperty getWorldProperty(String name) {
return worldProperties.get(name);
}

0
src/api/java/buildcraft/api/core/EnumColor.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/core/IAreaProvider.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/core/IBox.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/core/IIconProvider.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/core/IInvSlot.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/core/INBTStoreable.java Normal file → Executable file
View file

View file

@ -0,0 +1,15 @@
package buildcraft.api.core;
import java.util.List;
/**
* To be implemented by TileEntities able to provide a path on the world, typically BuildCraft path markers.
*/
public interface IPathProvider {
List<BlockIndex> getPath();
/**
* Remove from the world all objects used to define the path.
*/
void removeFromWorld();
}

0
src/api/java/buildcraft/api/core/ISerializable.java Normal file → Executable file
View file

1
src/api/java/buildcraft/api/core/Position.java Normal file → Executable file
View file

@ -15,7 +15,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class Position implements ISerializable {
public double x, y, z;
public ForgeDirection orientation;

0
src/api/java/buildcraft/api/core/SafeTimeTracker.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/core/StackKey.java Normal file → Executable file
View file

2
src/api/java/buildcraft/api/core/package-info.java Normal file → Executable file
View file

@ -6,7 +6,7 @@
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
@API(apiVersion = "1.5", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core")
@API(apiVersion = "2.0", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core")
package buildcraft.api.core;
import cpw.mods.fml.common.API;

0
src/api/java/buildcraft/api/core/render/ICullable.java Normal file → Executable file
View file

View file

View file

View file

0
src/api/java/buildcraft/api/fuels/ICoolant.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/fuels/ICoolantManager.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/fuels/IFuel.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/fuels/IFuelManager.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/fuels/ISolidCoolant.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/fuels/package-info.java Normal file → Executable file
View file

View file

@ -1,64 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.gates;
import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import buildcraft.api.statements.IActionInternal;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.ITriggerInternal;
public abstract class GateExpansionController {
public final IGateExpansion type;
public final TileEntity pipeTile;
public GateExpansionController(IGateExpansion type, TileEntity pipeTile) {
this.pipeTile = pipeTile;
this.type = type;
}
public IGateExpansion getType() {
return type;
}
public boolean isActive() {
return false;
}
public void tick(IGate gate) {
}
public void startResolution() {
}
public boolean resolveAction(IStatement action, int count) {
return false;
}
public boolean isTriggerActive(IStatement trigger, IStatementParameter[] parameters) {
return false;
}
public void addTriggers(List<ITriggerInternal> list) {
}
public void addActions(List<IActionInternal> list) {
}
public void writeToNBT(NBTTagCompound nbt) {
}
public void readFromNBT(NBTTagCompound nbt) {
}
}

View file

@ -1,66 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.gates;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.HashBiMap;
import net.minecraft.item.ItemStack;
public final class GateExpansions {
private static final Map<String, IGateExpansion> expansions = new HashMap<String, IGateExpansion>();
private static final ArrayList<IGateExpansion> expansionIDs = new ArrayList<IGateExpansion>();
private static final Map<IGateExpansion, ItemStack> recipes = HashBiMap.create();
private GateExpansions() {
}
public static void registerExpansion(IGateExpansion expansion) {
registerExpansion(expansion.getUniqueIdentifier(), expansion);
}
public static void registerExpansion(String identifier, IGateExpansion expansion) {
expansions.put(identifier, expansion);
expansionIDs.add(expansion);
}
public static void registerExpansion(IGateExpansion expansion, ItemStack addedRecipe) {
registerExpansion(expansion.getUniqueIdentifier(), expansion);
recipes.put(expansion, addedRecipe);
}
public static IGateExpansion getExpansion(String identifier) {
return expansions.get(identifier);
}
public static Set<IGateExpansion> getExpansions() {
Set<IGateExpansion> set = new HashSet<IGateExpansion>();
set.addAll(expansionIDs);
return set;
}
public static Map<IGateExpansion, ItemStack> getRecipesForPostInit() {
return recipes;
}
// The code below is used by networking.
public static IGateExpansion getExpansionByID(int id) {
return expansionIDs.get(id);
}
public static int getExpansionID(IGateExpansion expansion) {
return expansionIDs.indexOf(expansion);
}
}

View file

@ -1,32 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.gates;
import java.util.List;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.IStatementParameter;
import buildcraft.api.statements.StatementSlot;
import buildcraft.api.statements.containers.ISidedStatementContainer;
import buildcraft.api.transport.IPipe;
public interface IGate extends ISidedStatementContainer {
@Deprecated
void setPulsing(boolean pulse);
IPipe getPipe();
List<IStatement> getTriggers();
List<IStatement> getActions();
List<StatementSlot> getActiveActions();
List<IStatementParameter> getTriggerParameters(int index);
List<IStatementParameter> getActionParameters(int index);
}

View file

@ -1,30 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.gates;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
public interface IGateExpansion {
String getUniqueIdentifier();
String getDisplayName();
GateExpansionController makeController(TileEntity pipeTile);
void registerBlockOverlay(IIconRegister iconRegister);
void registerItemOverlay(IIconRegister iconRegister);
IIcon getOverlayBlock();
IIcon getOverlayItem();
}

View file

@ -1,12 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
@API(apiVersion = "4.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates")
package buildcraft.api.gates;
import cpw.mods.fml.common.API;

0
src/api/java/buildcraft/api/package-info.java Normal file → Executable file
View file

View file

@ -1,59 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.power;
/**
* This interface should be defined by any Tile which wants
* to receive energy from BuildCraft lasers.
*
* The respective Block MUST implement ILaserTargetBlock!
*/
public interface ILaserTarget {
/**
* Returns true if the target currently needs power. For example, if the Advanced
* Crafting Table has work to do.
*
* @return true if needs power
*/
boolean requiresLaserEnergy();
/**
* Transfers energy from the laser to the target.
*
* @param energy
*/
void receiveLaserEnergy(int energy);
/**
* Return true if the Tile Entity object is no longer a valid target. For
* example, if its been invalidated.
*
* @return true if no longer a valid target object
*/
boolean isInvalidTarget();
/**
* Get the X coordinate of the laser stream.
* @return
*/
double getXCoord();
/**
* Get the Y coordinate of the laser stream.
* @return
*/
double getYCoord();
/**
* Get the Z coordinate of the laser stream.
* @return
*/
double getZCoord();
}

View file

@ -1,19 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.power;
/**
* This is a marker interface for laser targets. Implement it on
* your Block.
*
* It is used by BuildCraft Lasers for optimization purposes.
*/
public interface ILaserTargetBlock {
}

View file

@ -1,12 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
@API(apiVersion = "1.3", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|power")
package buildcraft.api.power;
import cpw.mods.fml.common.API;

View file

@ -1,13 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
public class ActionState {
}

View file

@ -1,16 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public interface IActionExternal extends IStatement {
void actionActivate(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters);
}

View file

@ -1,15 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
public interface IActionInternal extends IStatement {
void actionActivate(IStatementContainer source, IStatementParameter[] parameters);
}

View file

@ -1,28 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
import java.util.Collection;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public interface IActionProvider {
/**
* Returns the list of actions that are available from the statement container holding the
* gate.
*/
Collection<IActionInternal> getInternalActions(IStatementContainer container);
/**
* Returns the list of actions available to a gate next to the given block.
*/
Collection<IActionExternal> getExternalActions(ForgeDirection side, TileEntity tile);
}

View file

@ -1,13 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
public interface IActionReceptor {
void actionActivated(IStatement statement, IStatementParameter[] parameters);
}

View file

@ -1,16 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
import java.util.List;
public interface IOverrideDefaultStatements {
List<ITriggerExternal> overrideTriggers();
List<IActionExternal> overrideActions();
}

View file

@ -1,56 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
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 statement needs a unique tag, it should be in the format of
* "&lt;modid&gt;:&lt;name&gt;.
*
* @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 statement can have, 0 if none.
*/
int maxParameters();
/**
* Return the minimum number of parameter this statement can have, 0 if none.
*/
int minParameters();
/**
* Return the statement description in the UI
*/
String getDescription();
/**
* Create parameters for the statement.
*/
IStatementParameter createParameter(int index);
/**
* This returns the statement after a left rotation. Used in particular in
* blueprints orientation.
*/
IStatement rotateLeft();
}

View file

@ -1,19 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
import net.minecraft.tileentity.TileEntity;
/**
* This is implemented by objects containing Statements, such as
* Gates and TileEntities.
*/
public interface IStatementContainer {
TileEntity getTile();
}

View file

@ -1,59 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public interface IStatementParameter {
/**
* Every parameter needs a unique tag, it should be in the format of
* "&lt;modi&gt;:&lt;name&gt;".
*
* @return the unique id
*/
String getUniqueTag();
@SideOnly(Side.CLIENT)
IIcon getIcon();
ItemStack getItemStack();
/**
* Something that is initially unintuitive: you HAVE to
* keep your icons as static variables, due to the fact
* that every IStatementParameter is instantiated upon creation,
* in opposition to IStatements which are singletons (due to the
* fact that they, unlike Parameters, store no additional data)
*/
@SideOnly(Side.CLIENT)
void registerIcons(IIconRegister iconRegister);
/**
* Return the parameter description in the UI
*/
String getDescription();
void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse);
void readFromNBT(NBTTagCompound compound);
void writeToNBT(NBTTagCompound compound);
/**
* This returns the parameter after a left rotation. Used in particular in
* blueprints orientation.
*/
IStatementParameter rotateLeft();
}

View file

@ -1,18 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public interface ITriggerExternal extends IStatement {
boolean isTriggerActive(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters);
}

View file

@ -1,15 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
public interface ITriggerInternal extends IStatement {
boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters);
}

View file

@ -1,28 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
import java.util.Collection;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public interface ITriggerProvider {
/**
* Returns the list of triggers that are available from the object holding the gate.
*/
Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container);
/**
* Returns the list of triggers available to a gate next to the given block.
*/
Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile);
}

View file

@ -1,182 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
public final class StatementManager {
public static Map<String, IStatement> statements = new HashMap<String, IStatement>();
public static Map<String, Class<? extends IStatementParameter>> parameters = new HashMap<String, Class<? extends IStatementParameter>>();
private static List<ITriggerProvider> triggerProviders = new LinkedList<ITriggerProvider>();
private static List<IActionProvider> actionProviders = new LinkedList<IActionProvider>();
/**
* Deactivate constructor
*/
private StatementManager() {
}
public static void registerTriggerProvider(ITriggerProvider provider) {
if (provider != null && !triggerProviders.contains(provider)) {
triggerProviders.add(provider);
}
}
public static void registerActionProvider(IActionProvider provider) {
if (provider != null && !actionProviders.contains(provider)) {
actionProviders.add(provider);
}
}
public static void registerStatement(IStatement statement) {
statements.put(statement.getUniqueTag(), statement);
}
public static void registerParameterClass(Class<? extends IStatementParameter> param) {
parameters.put(createParameter(param).getUniqueTag(), param);
}
@Deprecated
public static void registerParameterClass(String name, Class<? extends IStatementParameter> param) {
parameters.put(name, param);
}
public static List<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity entity) {
List<ITriggerExternal> result;
if (entity instanceof IOverrideDefaultStatements) {
result = ((IOverrideDefaultStatements) entity).overrideTriggers();
if (result != null) {
return result;
}
}
result = new LinkedList<ITriggerExternal>();
for (ITriggerProvider provider : triggerProviders) {
Collection<ITriggerExternal> toAdd = provider.getExternalTriggers(side, entity);
if (toAdd != null) {
for (ITriggerExternal t : toAdd) {
if (!result.contains(t)) {
result.add(t);
}
}
}
}
return result;
}
public static List<IActionExternal> getExternalActions(ForgeDirection side, TileEntity entity) {
List<IActionExternal> result = new LinkedList<IActionExternal>();
if (entity instanceof IOverrideDefaultStatements) {
result = ((IOverrideDefaultStatements) entity).overrideActions();
if (result != null) {
return result;
} else {
result = new LinkedList<IActionExternal>();
}
}
for (IActionProvider provider : actionProviders) {
Collection<IActionExternal> toAdd = provider.getExternalActions(side, entity);
if (toAdd != null) {
for (IActionExternal t : toAdd) {
if (!result.contains(t)) {
result.add(t);
}
}
}
}
return result;
}
public static List<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
List<ITriggerInternal> result = new LinkedList<ITriggerInternal>();
for (ITriggerProvider provider : triggerProviders) {
Collection<ITriggerInternal> toAdd = provider.getInternalTriggers(container);
if (toAdd != null) {
for (ITriggerInternal t : toAdd) {
if (!result.contains(t)) {
result.add(t);
}
}
}
}
return result;
}
public static List<IActionInternal> getInternalActions(IStatementContainer container) {
List<IActionInternal> result = new LinkedList<IActionInternal>();
for (IActionProvider provider : actionProviders) {
Collection<IActionInternal> toAdd = provider.getInternalActions(container);
if (toAdd != null) {
for (IActionInternal t : toAdd) {
if (!result.contains(t)) {
result.add(t);
}
}
}
}
return result;
}
public static IStatementParameter createParameter(String kind) {
return createParameter(parameters.get(kind));
}
private static IStatementParameter createParameter(Class<? extends IStatementParameter> param) {
try {
return param.newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return null;
}
/**
* Generally, this function should be called by every mod implementing
* the Statements API ***as a container*** (that is, adding its own gates)
* on the client side from a given Item of choice.
*/
@SideOnly(Side.CLIENT)
public static void registerIcons(IIconRegister register) {
for (IStatement statement : statements.values()) {
statement.registerIcons(register);
}
for (Class<? extends IStatementParameter> parameter : parameters.values()) {
createParameter(parameter).registerIcons(register);
}
}
}

View file

@ -1,27 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
public final class StatementMouseClick {
private int button;
private boolean shift;
public StatementMouseClick(int button, boolean shift) {
this.button = button;
this.shift = shift;
}
public boolean isShift() {
return shift;
}
public int getButton() {
return button;
}
}

View file

@ -1,88 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
package buildcraft.api.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
public class StatementParameterItemStack implements IStatementParameter {
protected ItemStack stack;
@Override
public IIcon getIcon() {
return null;
}
@Override
public ItemStack getItemStack() {
return stack;
}
@Override
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) {
if (stack != null) {
this.stack = stack.copy();
this.stack.stackSize = 1;
} else {
this.stack = null;
}
}
@Override
public void writeToNBT(NBTTagCompound compound) {
if (stack != null) {
NBTTagCompound tagCompound = new NBTTagCompound();
stack.writeToNBT(tagCompound);
compound.setTag("stack", tagCompound);
}
}
@Override
public void readFromNBT(NBTTagCompound compound) {
stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack"));
}
@Override
public boolean equals(Object object) {
if (object instanceof StatementParameterItemStack) {
StatementParameterItemStack param = (StatementParameterItemStack) object;
return ItemStack.areItemStacksEqual(stack, param.stack)
&& ItemStack.areItemStackTagsEqual(stack, param.stack);
} else {
return false;
}
}
@Override
public String getDescription() {
if (stack != null) {
return stack.getDisplayName();
} else {
return "";
}
}
@Override
public String getUniqueTag() {
return "buildcraft:stack";
}
@Override
public void registerIcons(IIconRegister iconRegister) {
}
@Override
public IStatementParameter rotateLeft() {
return this;
}
}

View file

@ -1,36 +0,0 @@
/**
* Copyright (c) 2011-2015, 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.statements;
public class StatementSlot {
public IStatement statement;
public IStatementParameter[] parameters;
@Override
public boolean equals(Object o) {
if (o == null || !(o instanceof StatementSlot)) {
return false;
}
StatementSlot s = (StatementSlot) o;
if (s.statement != statement || parameters.length != s.parameters.length) {
return false;
}
for (int i = 0; i < parameters.length; i++) {
IStatementParameter p1 = parameters[i];
IStatementParameter p2 = s.parameters[i];
if (p1 == null && p2 != null) {
return false;
}
if (!(p1.equals(p2))) {
return false;
}
}
return true;
}
}

View file

@ -1,19 +0,0 @@
package buildcraft.api.statements.containers;
import net.minecraftforge.common.util.ForgeDirection;
public interface IRedstoneStatementContainer {
/**
* Get the redstone input from a given side.
* @param side The side - use "UNKNOWN" for maximum input.
* @return The redstone input, from 0 to 15.
*/
int getRedstoneInput(ForgeDirection side);
/**
* Set the redstone input for a given side.
* @param side The side - use "UNKNOWN" for all sides.
* @return Whether the set was successful.
*/
boolean setRedstoneOutput(ForgeDirection side, int value);
}

View file

@ -1,12 +0,0 @@
package buildcraft.api.statements.containers;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.statements.IStatementContainer;
/**
* Created by asie on 3/14/15.
*/
public interface ISidedStatementContainer extends IStatementContainer {
ForgeDirection getSide();
}

View file

@ -1,12 +0,0 @@
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* The BuildCraft API is distributed under the terms of the MIT License.
* Please check the contents of the license, which should be located
* as "LICENSE.API" in the BuildCraft source code distribution.
*/
@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|statements")
package buildcraft.api.statements;
import cpw.mods.fml.common.API;

0
src/api/java/buildcraft/api/tools/IToolWrench.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/tools/package-info.java Normal file → Executable file
View file

0
src/api/java/buildcraft/api/transport/IInjectable.java Normal file → Executable file
View file

View file

@ -0,0 +1,16 @@
/**
* Copyright (c) 2011-2015, 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.transport;
/**
* To be implemented by the real item pipe in Transport mod, but leaves knowledge for classes that do not have direct dependency on transport.
*/
public interface IItemPipe {
}

View file

0
src/api/java/buildcraft/api/transport/IPipeTile.java Normal file → Executable file
View file

View file

View file

View file

@ -8,5 +8,7 @@
*/
package buildcraft.api.transport;
public interface IStripesPipe extends IPipe, IStripesActivator {
import cofh.api.energy.IEnergyHandler;
public interface IStripesPipe extends IPipe, IStripesActivator, IEnergyHandler {
}

0
src/api/java/buildcraft/api/transport/PipeWire.java Normal file → Executable file
View file

View file

View file