Update BC API

This commit is contained in:
Ben Spiers committed 2015-07-21 20:45:05 +01:00
1 parent 7323a13e09
commit 22282fc838
80 files changed
+777 -1152

No files matched your search

+5 -5
View File
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
@@ -27,7 +27,7 @@ public final class BCLog {
public static void initLog() {
logger.info("Starting BuildCraft " + getVersion());
logger.info("Copyright (c) SpaceToad, 2011-2014");
logger.info("Copyright (c) SpaceToad, 2011-2015");
logger.info("http://www.mod-buildcraft.com");
}
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
@@ -15,7 +15,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/**
* This class is a comparable container for block positions. TODO: should this be merged with position?
* This class is a comparable container for integer block positions.
*/
public class BlockIndex implements Comparable<BlockIndex> {
@@ -99,7 +99,7 @@ public class BlockIndex implements Comparable<BlockIndex> {
return b.x == x && b.y == y && b.z == z;
}
return super.equals(obj);
return false;
}
@Override
@@ -1,13 +1,14 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@@ -19,16 +20,7 @@ public final class BuildCraftAPI {
public static ICoreProxy proxy;
public static final Set<Block> softBlocks = new HashSet<Block>();
public static IWorldProperty isSoftProperty;
public static IWorldProperty isWoodProperty;
public static IWorldProperty isLeavesProperty;
public static IWorldProperty[] isOreProperty;
public static IWorldProperty isHarvestableProperty;
public static IWorldProperty isFarmlandProperty;
public static IWorldProperty isDirtProperty;
public static IWorldProperty isShoveled;
public static IWorldProperty isFluidSource;
public static final HashMap<String, IWorldProperty> worldProperties = new HashMap<String, IWorldProperty>();
/**
* Deactivate constructor
@@ -36,7 +28,18 @@ public final class BuildCraftAPI {
private BuildCraftAPI() {
}
public static IWorldProperty getWorldProperty(String name) {
return worldProperties.get(name);
}
public static void registerWorldProperty(String name, IWorldProperty property) {
if (worldProperties.containsKey(name)) {
BCLog.logger.warn("The WorldProperty key '" + name + "' is being overidden with " + property.getClass().getSimpleName() + "!");
}
worldProperties.put(name, property);
}
public static boolean isSoftBlock(World world, int x, int y, int z) {
return isSoftProperty.get(world, x, y, z);
return worldProperties.get("soft").get(world, x, y, z);
}
}
@@ -1,20 +1,18 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
import java.util.Locale;
import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -36,6 +34,7 @@ public enum EnumColor {
MAGENTA,
ORANGE,
WHITE;
public static final EnumColor[] VALUES = values();
public static final String[] DYES = {
"dyeBlack",
@@ -191,13 +190,8 @@ public enum EnumColor {
return b.toString().trim();
}
@SideOnly(Side.CLIENT)
public static void registerIcons(IIconRegister iconRegister) {
brushIcons = new IIcon[16];
for (EnumColor c : values()) {
brushIcons[c.ordinal()] = iconRegister.registerIcon("buildcraft:triggers/color_"
+ c.name().toLowerCase(Locale.ENGLISH));
}
public static void setIconArray(IIcon[] icons) {
brushIcons = icons;
}
@SideOnly(Side.CLIENT)
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
@@ -12,7 +12,6 @@ package buildcraft.api.core;
* To be implemented by TileEntities able to provide a square area on the world, typically BuildCraft markers.
*/
public interface IAreaProvider {
int xMin();
int yMin();
@@ -29,5 +28,4 @@ public interface IAreaProvider {
* Remove from the world all objects used to define the area.
*/
void removeFromWorld();
}
+4 -4
View File
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
+4 -4
View File
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
@@ -1,16 +1,15 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
@@ -22,6 +22,8 @@ public interface IInvSlot {
boolean canTakeStackFromSlot(ItemStack stack);
boolean isItemValidForSlot(ItemStack stack);
ItemStack decreaseStackInSlot(int amount);
ItemStack getStackInSlot();
@@ -0,0 +1,8 @@
package buildcraft.api.core;
import net.minecraft.nbt.NBTTagCompound;
public interface INBTStoreable {
void readFromNBT(NBTTagCompound tag);
void writeToNBT(NBTTagCompound tag);
}
@@ -0,0 +1,30 @@
/**
* 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.core;
import io.netty.buffer.ByteBuf;
/**
* Implemented by classes representing serializable packet state
*/
public interface ISerializable {
/**
* Serializes the state to the stream
*
* @param data
*/
void writeData(ByteBuf data);
/**
* Deserializes the state from the stream
*
* @param data
*/
void readData(ByteBuf data);
}
+4 -5
View File
@@ -1,17 +1,16 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
import net.minecraft.world.World;
public interface IWorldProperty {
boolean get(World world, int x, int y, int z);
void clear();
+6 -4
View File
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
@@ -14,6 +14,8 @@ public interface IZone {
double distanceTo(BlockIndex index);
double distanceToSquared(BlockIndex index);
boolean contains(double x, double y, double z);
BlockIndex getRandomBlockIndex(Random rand);
+8 -57
View File
@@ -1,25 +1,20 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class JavaTools {
public static double bounds(double value, double min, double max) {
return Math.max(min, Math.min(value, max));
public final class JavaTools {
private JavaTools(){
}
public static <T> T[] concat(T[] first, T[] second) {
T[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
@@ -38,50 +33,6 @@ public class JavaTools {
return result;
}
public <T> T[] concatenate (T[] a, T[] b) {
int aLen = a.length;
int bLen = b.length;
@SuppressWarnings("unchecked")
T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen);
System.arraycopy(a, 0, c, 0, aLen);
System.arraycopy(b, 0, c, aLen, bLen);
return c;
}
public static List<Field> getAllFields(Class<?> clas) {
List<Field> result = new ArrayList<Field>();
Class<?> current = clas;
while (current != null && current != Object.class) {
for (Field f : current.getDeclaredFields()) {
result.add(f);
}
current = current.getSuperclass();
}
return result;
}
public static List<Method> getAllMethods(Class<?> clas) {
List<Method> result = new ArrayList<Method>();
Class<?> current = clas;
while (current != null && current != Object.class) {
for (Method m : current.getDeclaredMethods()) {
result.add(m);
}
current = current.getSuperclass();
}
return result;
}
public static String surroundWithQuotes(String stringToSurroundWithQuotes) {
return String.format("\"%s\"", stringToSurroundWithQuotes);
}
@@ -1,19 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.core;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface NetworkData {
}
+28 -9
View File
@@ -1,24 +1,22 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class Position {
public class Position implements ISerializable {
@NetworkData
public double x, y, z;
@NetworkData
public ForgeDirection orientation;
public Position() {
@@ -178,4 +176,25 @@ public class Position {
return !(sqrDis > f * f);
}
@Override
public void readData(ByteBuf stream) {
x = stream.readDouble();
y = stream.readDouble();
z = stream.readDouble();
orientation = ForgeDirection.getOrientation(stream.readByte());
}
@Override
public void writeData(ByteBuf stream) {
stream.writeDouble(x);
stream.writeDouble(y);
stream.writeDouble(z);
stream.writeByte(orientation.ordinal());
}
@Override
public int hashCode() {
return (51 * (int) x) + (13 * (int) y) + (int) z;
}
}
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
@@ -82,4 +82,4 @@ public class SafeTimeTracker {
public void markTime(World world) {
lastMark = world.getTotalWorldTime();
}
}
}
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.core;
@@ -1,108 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.core;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
/**
* This class is a comparable container for block positions. TODO: should this be merged with position?
*/
public class WorldBlockIndex implements Comparable<WorldBlockIndex> {
public int x;
public int y;
public int z;
public int dimension;
public WorldBlockIndex() {
}
/**
* Creates an index for a block located on x, y. z
*/
public WorldBlockIndex(World world, int x, int y, int z) {
dimension = world.provider.dimensionId;
this.x = x;
this.y = y;
this.z = z;
}
public WorldBlockIndex(NBTTagCompound c) {
dimension = c.getInteger("dimension");
x = c.getInteger("x");
y = c.getInteger("y");
z = c.getInteger("z");
}
public WorldBlockIndex(Entity entity) {
dimension = entity.worldObj.provider.dimensionId;
x = (int) Math.floor(entity.posX);
y = (int) Math.floor(entity.posY);
z = (int) Math.floor(entity.posZ);
}
/**
* Provides a deterministic and complete ordering of block positions.
*/
@Override
public int compareTo(WorldBlockIndex o) {
if (o.dimension < dimension) {
return 1;
} else if (o.dimension > dimension) {
return -1;
} else if (o.x < x) {
return 1;
} else if (o.x > x) {
return -1;
} else if (o.z < z) {
return 1;
} else if (o.z > z) {
return -1;
} else if (o.y < y) {
return 1;
} else if (o.y > y) {
return -1;
} else {
return 0;
}
}
public void writeTo(NBTTagCompound c) {
c.setInteger("dimension", dimension);
c.setInteger("x", x);
c.setInteger("y", y);
c.setInteger("z", z);
}
@Override
public String toString() {
return "{" + dimension + ":" + x + ", " + y + ", " + z + "}";
}
@Override
public boolean equals(Object obj) {
if (obj instanceof WorldBlockIndex) {
WorldBlockIndex b = (WorldBlockIndex) obj;
return b.dimension == dimension && b.x == x && b.y == y && b.z == z;
}
return super.equals(obj);
}
@Override
public int hashCode() {
return (dimension * 37 + (x * 37 + y)) * 37 + z;
}
}
@@ -1,11 +1,12 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.0", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core")
@API(apiVersion = "1.5", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core")
package buildcraft.api.core;
import cpw.mods.fml.common.API;
@@ -0,0 +1,32 @@
/**
* 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.core.render;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
/*
* This interface designates a block as a state machine responsible for culling
* For implementation details look into FakeBlock implementation
*/
public interface ICullable {
//Side Rendering States
//They are used to effectively cull obstructed sides while processing facades.
//Make sure your implementation is correct otherwise expect FPS drop
void setRenderSide(ForgeDirection side, boolean render);
void setRenderAllSides();
boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side);
void setRenderMask(int mask);
}
@@ -0,0 +1,7 @@
package buildcraft.api.core.render;
import net.minecraft.util.IIcon;
public interface ITextureStateManager {
void set(IIcon icon);
}
@@ -0,0 +1,22 @@
/**
* 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.core.render;
import net.minecraft.block.Block;
import net.minecraft.util.IIcon;
public interface ITextureStates extends ICullable {
ITextureStateManager getTextureState();
IIcon getIcon(int side, int meta);
Block getBlock();
}
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.fuels;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.fuels;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.fuels;
+4 -4
View File
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.fuels;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.fuels;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.fuels;
@@ -1,11 +1,12 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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 = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|fuels")
package buildcraft.api.fuels;
import cpw.mods.fml.common.API;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -42,7 +42,7 @@ public abstract class GateExpansionController {
public void startResolution() {
}
public boolean resolveAction(IStatement action) {
public boolean resolveAction(IStatement action, int count) {
return false;
}
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -14,10 +14,14 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public final class GateExpansions {
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() {
}
@@ -31,6 +35,11 @@ public final class GateExpansions {
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);
}
@@ -40,6 +49,10 @@ public final class GateExpansions {
set.addAll(expansionIDs);
return set;
}
public static Map<IGateExpansion, ItemStack> getRecipesForPostInit() {
return recipes;
}
// The code below is used by networking.
+18 -8
View File
@@ -1,22 +1,32 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.minecraftforge.common.util.ForgeDirection;
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 {
public interface IGate extends ISidedStatementContainer {
@Deprecated
void setPulsing(boolean pulse);
ForgeDirection getSide();
IPipe getPipe();
List<IStatement> getTriggers();
List<IStatement> getActions();
List<StatementSlot> getActiveActions();
List<IStatementParameter> getTriggerParameters(int index);
List<IStatementParameter> getActionParameters(int index);
}
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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 = "3.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates")
@API(apiVersion = "4.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates")
package buildcraft.api.gates;
import cpw.mods.fml.common.API;
@@ -1,11 +1,12 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.0", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core")
package buildcraft.api;
import cpw.mods.fml.common.API;
@@ -1,13 +1,19 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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 {
/**
@@ -33,9 +39,21 @@ public interface ILaserTarget {
*/
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();
}
@@ -1,13 +1,19 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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 {
}
@@ -1,23 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.power;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Essentially only used for Wooden Power Pipe connection rules.
*
* This Tile Entity interface allows you to indicate that a block can emit power
* from a specific side.
*/
@Deprecated
public interface IPowerEmitter {
boolean canEmitPowerFrom(ForgeDirection side);
}
@@ -1,47 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.power;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
* This interface should be implemented by any Tile Entity that wishes to be
* able to receive power.
*/
@Deprecated
public interface IPowerReceptor {
/**
* Get the PowerReceiver for this side of the block. You can return the same
* PowerReceiver for all sides or one for each side.
*
* You should NOT return null to this method unless you mean to NEVER
* receive power from that side. Returning null, after previous returning a
* PowerReceiver, will most likely cause pipe connections to derp out and
* engines to eventually explode.
*
* @param side
* @return
*/
PowerHandler.PowerReceiver getPowerReceiver(ForgeDirection side);
/**
* Call back from the PowerHandler that is called when the stored power
* exceeds the activation power.
*
* It can be triggered by update() calls or power modification calls.
*
* @param workProvider
*/
void doWork(PowerHandler workProvider);
World getWorld();
}
@@ -1,493 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.power;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.SafeTimeTracker;
/**
* The PowerHandler is similar to FluidTank in that it holds your power and
* allows standardized interaction between machines.
*
* To receive power to your machine you needs create an instance of PowerHandler
* and implement IPowerReceptor on the TileEntity.
*
* If you plan emit power, you need only implement IPowerEmitter. You do not
* need a PowerHandler. Engines have a PowerHandler because they can also
* receive power from other Engines.
*
* See TileRefinery for a simple example of a power using machine.
*
* @see IPowerReceptor
* @see IPowerEmitter
*/
@Deprecated
public final class PowerHandler {
public static enum Type {
ENGINE, GATE, MACHINE, PIPE, STORAGE;
public boolean canReceiveFromPipes() {
switch (this) {
case MACHINE:
case STORAGE:
return true;
default:
return false;
}
}
public boolean eatsEngineExcess() {
switch (this) {
case MACHINE:
case STORAGE:
return true;
default:
return false;
}
}
}
/**
* Extend this class to create custom Perdition algorithms (its not final).
*
* NOTE: It is not possible to create a Zero perdition algorithm.
*/
public static class PerditionCalculator {
public static final float DEFAULT_POWERLOSS = 1F;
public static final float MIN_POWERLOSS = 0.01F;
private final double powerLoss;
public PerditionCalculator() {
powerLoss = DEFAULT_POWERLOSS;
}
/**
* Simple constructor for simple Perdition per tick.
*
* @param powerLoss power loss per tick
*/
public PerditionCalculator(double iPowerLoss) {
if (iPowerLoss < MIN_POWERLOSS) {
powerLoss = iPowerLoss;
} else {
powerLoss = MIN_POWERLOSS;
}
}
/**
* Apply the perdition algorithm to the current stored energy. This
* function can only be called once per tick, but it might not be called
* every tick. It is triggered by any manipulation of the stored energy.
*
* @param powerHandler the PowerHandler requesting the perdition update
* @param current the current stored energy
* @param ticksPassed ticks since the last time this function was called
* @return
*/
public double applyPerdition(PowerHandler powerHandler, double current, long ticksPassed) {
double result = current;
result -= powerLoss * ticksPassed;
if (result < 0) {
result = 0;
}
return result;
}
/**
* Taxes a flat rate on all incoming power.
*
* Defaults to 0% tax rate.
*
* @return percent of input to tax
*/
public double getTaxPercent() {
return 0;
}
}
public static final PerditionCalculator DEFAULT_PERDITION = new PerditionCalculator();
public static final double ROLLING_AVERAGE_WEIGHT = 100.0;
public static final double ROLLING_AVERAGE_NUMERATOR = ROLLING_AVERAGE_WEIGHT - 1;
public static final double ROLLING_AVERAGE_DENOMINATOR = 1.0 / ROLLING_AVERAGE_WEIGHT;
public final int[] powerSources = new int[6];
public final IPowerReceptor receptor;
private double minEnergyReceived;
private double maxEnergyReceived;
private double maxEnergyStored;
private double activationEnergy;
private double energyStored = 0;
private final SafeTimeTracker doWorkTracker = new SafeTimeTracker();
private final SafeTimeTracker sourcesTracker = new SafeTimeTracker();
private final SafeTimeTracker perditionTracker = new SafeTimeTracker();
private PerditionCalculator perdition;
private final PowerReceiver receiver;
private final Type type;
// Tracking
private double averageLostPower = 0;
private double averageReceivedPower = 0;
private double averageUsedPower = 0;
public PowerHandler(IPowerReceptor receptor, Type type) {
this.receptor = receptor;
this.type = type;
this.receiver = new PowerReceiver();
this.perdition = DEFAULT_PERDITION;
}
public PowerReceiver getPowerReceiver() {
return receiver;
}
public double getMinEnergyReceived() {
return minEnergyReceived;
}
public double getMaxEnergyReceived() {
return maxEnergyReceived;
}
public double getMaxEnergyStored() {
return maxEnergyStored;
}
public double getActivationEnergy() {
return activationEnergy;
}
public double getEnergyStored() {
return energyStored;
}
/**
* Setup your PowerHandler's settings.
*
* @param minEnergyReceived
* This is the minimum about of power that will be accepted by
* the PowerHandler. This should generally be greater than the
* activationEnergy if you plan to use the doWork() callback.
* Anything greater than 1 will prevent Redstone Engines from
* powering this Provider.
* @param iMaxEnergyReceived
* The maximum amount of power accepted by the PowerHandler. This
* should generally be less than 500. Too low and larger engines
* will overheat while trying to power the machine. Too high, and
* the engines will never warm up. Greater values also place
* greater strain on the power net.
* @param activationEnergy
* If the stored energy is greater than this value, the doWork()
* callback is called (once per tick).
* @param maxStoredEnergy
* The maximum amount of power this PowerHandler can store.
* Values tend to range between 100 and 5000. With 1000 and 1500
* being common.
*/
public void configure(double iMinEnergyReceived, double iMaxEnergyReceived, double iActivationEnergy,
double iMaxStoredEnergy) {
if (iMinEnergyReceived > maxEnergyReceived) {
maxEnergyReceived = iMinEnergyReceived;
} else {
maxEnergyReceived = iMaxEnergyReceived;
}
minEnergyReceived = iMinEnergyReceived;
maxEnergyStored = iMaxStoredEnergy;
activationEnergy = iActivationEnergy;
}
/**
* Allows you define perdition in terms of loss/ticks.
*
* This function is mostly for legacy implementations. See
* PerditionCalculator for more complex perdition formulas.
*
* @param powerLoss
* @param powerLossRegularity
* @see PerditionCalculator
*/
public void configurePowerPerdition(int powerLoss, int powerLossRegularity) {
if (powerLoss == 0 || powerLossRegularity == 0) {
perdition = new PerditionCalculator(0);
return;
}
perdition = new PerditionCalculator((float) powerLoss / (float) powerLossRegularity);
}
/**
* Allows you to define a new PerditionCalculator class to handler perdition
* calculations.
*
* For example if you want exponentially increasing loss based on amount
* stored.
*
* @param iPerdition
*/
public void setPerdition(PerditionCalculator iPerdition) {
if (iPerdition == null) {
perdition = DEFAULT_PERDITION;
} else {
perdition = iPerdition;
}
}
public PerditionCalculator getPerdition() {
if (perdition == null) {
return DEFAULT_PERDITION;
}
return perdition;
}
/**
* Ticks the power handler. You should call this if you can, but its not
* required.
*
* If you don't call it, the possibility exists for some weirdness with the
* perdition algorithm and work callback as its possible they will not be
* called on every tick they otherwise would be. You should be able to
* design around this though if you are aware of the limitations.
*/
public void update() {
applyPerdition();
applyWork();
validateEnergy();
}
private void applyPerdition() {
if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0) {
double prev = energyStored;
double newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
if (newEnergy == 0 || newEnergy < energyStored) {
energyStored = newEnergy;
} else {
energyStored = DEFAULT_PERDITION.applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
}
validateEnergy();
averageLostPower = (averageLostPower * ROLLING_AVERAGE_NUMERATOR + (prev - energyStored)) * ROLLING_AVERAGE_DENOMINATOR;
}
}
private void applyWork() {
if (energyStored >= activationEnergy) {
if (doWorkTracker.markTimeIfDelay(receptor.getWorld(), 1)) {
receptor.doWork(this);
}
}
}
private void updateSources(ForgeDirection source) {
if (sourcesTracker.markTimeIfDelay(receptor.getWorld(), 1)) {
for (int i = 0; i < 6; ++i) {
powerSources[i] -= sourcesTracker.durationOfLastDelay();
if (powerSources[i] < 0) {
powerSources[i] = 0;
}
}
}
if (source != null) {
powerSources[source.ordinal()] = 10;
}
}
/**
* Extract energy from the PowerHandler. You must call this even if doWork()
* triggers.
*
* @param min
* @param max
* @param doUse
* @return amount used
*/
public double useEnergy(double min, double max, boolean doUse) {
applyPerdition();
double result = 0;
if (energyStored >= min) {
if (energyStored <= max) {
result = energyStored;
if (doUse) {
energyStored = 0;
}
} else {
result = max;
if (doUse) {
energyStored -= max;
}
}
}
validateEnergy();
if (doUse) {
averageUsedPower = (averageUsedPower * ROLLING_AVERAGE_NUMERATOR + result) * ROLLING_AVERAGE_DENOMINATOR;
}
return result;
}
public void readFromNBT(NBTTagCompound data) {
readFromNBT(data, "powerProvider");
}
public void readFromNBT(NBTTagCompound data, String tag) {
NBTTagCompound nbt = data.getCompoundTag(tag);
energyStored = nbt.getDouble("energyStored");
}
public void writeToNBT(NBTTagCompound data) {
writeToNBT(data, "powerProvider");
}
public void writeToNBT(NBTTagCompound data, String tag) {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setDouble("energyStored", energyStored);
data.setTag(tag, nbt);
}
public final class PowerReceiver {
private PowerReceiver() {
}
public double getMinEnergyReceived() {
return minEnergyReceived;
}
public double getMaxEnergyReceived() {
return maxEnergyReceived;
}
public double getMaxEnergyStored() {
return maxEnergyStored;
}
public double getActivationEnergy() {
return activationEnergy;
}
public double getEnergyStored() {
return energyStored;
}
public double getAveragePowerReceived() {
return averageReceivedPower;
}
public double getAveragePowerUsed() {
return averageUsedPower;
}
public double getAveragePowerLost() {
return averageLostPower;
}
public Type getType() {
return type;
}
public void update() {
PowerHandler.this.update();
}
/**
* The amount of power that this PowerHandler currently needs.
*
* @return
*/
public double powerRequest() {
update();
return Math.min(maxEnergyReceived, maxEnergyStored - energyStored);
}
/**
* Add power to the PowerReceiver from an external source.
*
* IPowerEmitters are responsible for calling this themselves.
*
* @param quantity
* @param from
* @return the amount of power used
*/
public double receiveEnergy(Type source, final double quantity, ForgeDirection from) {
double used = quantity;
if (source == Type.ENGINE) {
if (used < minEnergyReceived) {
return 0;
} else if (used > maxEnergyReceived) {
used = maxEnergyReceived;
}
}
updateSources(from);
used -= used * getPerdition().getTaxPercent();
used = addEnergy(used);
applyWork();
if (source == Type.ENGINE && type.eatsEngineExcess()) {
used = Math.min(quantity, maxEnergyReceived);
}
averageReceivedPower = (averageReceivedPower * ROLLING_AVERAGE_NUMERATOR + used) * ROLLING_AVERAGE_DENOMINATOR;
return used;
}
}
/**
*
* @return the amount the power changed by
*/
public double addEnergy(double iQuantity) {
energyStored += iQuantity;
double added = iQuantity;
if (energyStored > maxEnergyStored) {
added -= energyStored - maxEnergyStored;
energyStored = maxEnergyStored;
} else if (energyStored < 0) {
added -= energyStored;
energyStored = 0;
}
applyPerdition();
return added;
}
public void setEnergy(double quantity) {
this.energyStored = quantity;
validateEnergy();
}
public boolean isPowerSource(ForgeDirection from) {
return powerSources[from.ordinal()] != 0;
}
private void validateEnergy() {
if (energyStored < 0) {
energyStored = 0;
}
if (energyStored > maxEnergyStored) {
energyStored = maxEnergyStored;
}
}
}
@@ -1,3 +1,12 @@
@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|power")
/**
* 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;
+4 -4
View File
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -12,7 +12,5 @@ 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);
}
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -1,24 +1,22 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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 trigger needs a unique tag, it should be in the format of
* "<modid>:<name>".
* Every statement needs a unique tag, it should be in the format of
* "&lt;modid&gt;:&lt;name&gt;.
*
* @return the unique id
*/
@@ -31,27 +29,27 @@ public interface IStatement {
void registerIcons(IIconRegister iconRegister);
/**
* Return the maximum number of parameter this trigger can have, 0 if none.
* Return the maximum number of parameter this statement can have, 0 if none.
*/
int maxParameters();
/**
* Return the minimum number of parameter this trigger can have, 0 if none.
* Return the minimum number of parameter this statement can have, 0 if none.
*/
int minParameters();
/**
* Return the trigger description in the UI
* Return the statement description in the UI
*/
String getDescription();
/**
* Create parameters for the trigger.
* Create parameters for the statement.
*/
IStatementParameter createParameter(int index);
/**
* This returns the trigger after a left rotation. Used in particular in
* This returns the statement after a left rotation. Used in particular in
* blueprints orientation.
*/
IStatement rotateLeft();
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
+5 -6
View File
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -12,7 +12,6 @@ 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;
@@ -20,7 +19,7 @@ public interface IStatementParameter {
/**
* Every parameter needs a unique tag, it should be in the format of
* "<modid>:<name>".
* "&lt;modi&gt;:&lt;name&gt;".
*
* @return the unique id
*/
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
+4 -4
View File
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -92,6 +92,8 @@ public final class StatementManager {
result = ((IOverrideDefaultStatements) entity).overrideActions();
if (result != null) {
return result;
} else {
result = new LinkedList<IActionExternal>();
}
}
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
+6 -5
View File
@@ -1,13 +1,12 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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;
@@ -32,6 +31,8 @@ public class StatementParameterItemStack implements IStatementParameter {
if (stack != null) {
this.stack = stack.copy();
this.stack.stackSize = 1;
} else {
this.stack = null;
}
}
+36
View File
@@ -0,0 +1,36 @@
/**
* 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;
}
}
@@ -0,0 +1,19 @@
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);
}
@@ -0,0 +1,12 @@
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();
}
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|statements")
@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|statements")
package buildcraft.api.statements;
import cpw.mods.fml.common.API;
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.tools;
@@ -1,11 +1,12 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tools")
package buildcraft.api.tools;
import cpw.mods.fml.common.API;
@@ -1,29 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.transport;
import net.minecraft.world.World;
/**
* Implement and register with the PipeManager if you want to suppress connections from wooden pipes.
*/
public interface IExtractionHandler {
/**
* Can this pipe extract items from the block located at these coordinates?
* param extractor can be null
*/
boolean canExtractItems(Object extractor, World world, int i, int j, int k);
/**
* Can this pipe extract liquids from the block located at these coordinates?
* param extractor can be null
*/
boolean canExtractFluids(Object extractor, World world, int i, int j, int k);
}
@@ -0,0 +1,23 @@
package buildcraft.api.transport;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.EnumColor;
public interface IInjectable {
boolean canInjectItems(ForgeDirection from);
/**
* Offers an ItemStack for 3addition to the pipe. Will be rejected if the
* pipe doesn't accept items from that side.
*
* @param stack ItemStack offered for addition. Do not manipulate this!
* @param doAdd If false no actual addition should take place. Implementors
* should simulate.
* @param from Orientation the ItemStack is offered from.
* @param color The color of the item to be added to the pipe, or null for no color.
* @return Amount of items used from the passed stack.
*/
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from, EnumColor color);
}
+5 -11
View File
@@ -1,24 +1,18 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.transport;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.IGate;
public interface IPipe {
int x();
int y();
int z();
IPipeTile getTile();
IGate getGate(ForgeDirection side);
@@ -1,23 +1,21 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.transport;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.IPipeTile.PipeType;
public interface IPipeConnection {
enum ConnectOverride {
CONNECT, DISCONNECT, DEFAULT
};
}
/**
* Allows you to override pipe connection logic.
@@ -27,5 +25,5 @@ public interface IPipeConnection {
* @return CONNECT to force a connection, DISCONNECT to force no connection,
* and DEFAULT to let the pipe decide.
*/
ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with);
ConnectOverride overridePipeConnection(IPipeTile.PipeType type, ForgeDirection with);
}
@@ -1,32 +0,0 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.api.transport;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public interface IPipePluggable {
void writeToNBT(NBTTagCompound nbt);
void readFromNBT(NBTTagCompound nbt);
ItemStack[] getDropItems(IPipeTile pipe);
void onAttachedPipe(IPipeTile pipe, ForgeDirection direction);
void onDetachedPipe(IPipeTile pipe, ForgeDirection direction);
boolean blocking(IPipeTile pipe, ForgeDirection direction);
void invalidate();
void validate(IPipeTile pipe, ForgeDirection direction);
}
@@ -1,46 +1,36 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.transport;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.EnumColor;
import buildcraft.api.transport.pluggable.PipePluggable;
public interface IPipeTile {
public enum PipeType {
ITEM, FLUID, POWER, STRUCTURE;
public interface IPipeTile extends IInjectable {
enum PipeType {
ITEM, FLUID, POWER, STRUCTURE
}
PipeType getPipeType();
/**
* Offers an ItemStack for addition to the pipe. Will be rejected if the
* pipe doesn't accept items from that side.
*
* @param stack ItemStack offered for addition. Do not manipulate this!
* @param doAdd If false no actual addition should take place. Implementors
* should simulate.
* @param from Orientation the ItemStack is offered from.
* @param color The color of the item to be added to the pipe, or null for no color.
* @return Amount of items used from the passed stack.
*/
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from, EnumColor color);
World getWorld();
/**
* Same as
* {@link #injectItem(ItemStack, boolean, ForgeDirection, EnumColor)}
* but with no color attribute.
*/
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from);
int x();
int y();
int z();
/**
* True if the pipe is connected to the block/pipe in the specific direction
@@ -50,7 +40,23 @@ public interface IPipeTile {
*/
boolean isPipeConnected(ForgeDirection with);
TileEntity getAdjacentTile(ForgeDirection dir);
Block getNeighborBlock(ForgeDirection dir);
TileEntity getNeighborTile(ForgeDirection dir);
IPipe getNeighborPipe(ForgeDirection dir);
IPipe getPipe();
int getPipeColor();
PipePluggable getPipePluggable(ForgeDirection direction); // Now in IPluggableProvider
boolean hasPipePluggable(ForgeDirection direction); // Now in IPluggableProvider
boolean hasBlockingPluggable(ForgeDirection direction);
void scheduleNeighborChange();
void scheduleRenderUpdate();
// For compatibility with BC 6.2.x and below
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from, EnumColor color);
@Deprecated // Now in IInjectable
int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from);
}
@@ -0,0 +1,17 @@
/**
* 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.transport;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
public interface IStripesActivator {
void sendItem(ItemStack itemStack, ForgeDirection direction);
void dropItem(ItemStack itemStack, ForgeDirection direction);
}
@@ -1,3 +1,11 @@
/**
* 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.transport;
import net.minecraft.entity.player.EntityPlayer;
@@ -6,7 +14,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IStripesHandler {
public static enum StripesHandlerType {
enum StripesHandlerType {
ITEM_USE,
BLOCK_BREAK
}
@@ -16,5 +24,5 @@ public interface IStripesHandler {
boolean shouldHandle(ItemStack stack);
boolean handle(World world, int x, int y, int z, ForgeDirection direction,
ItemStack stack, EntityPlayer player, IStripesPipe pipe);
ItemStack stack, EntityPlayer player, IStripesActivator activator);
}
@@ -1,9 +1,12 @@
/**
* 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.transport;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
public interface IStripesPipe extends IPipe {
void sendItem(ItemStack itemStack, ForgeDirection direction);
void dropItem(ItemStack itemStack, ForgeDirection direction);
public interface IStripesPipe extends IPipe, IStripesActivator {
}
+55 -31
View File
@@ -1,54 +1,78 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.transport;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.world.World;
import buildcraft.api.transport.pluggable.PipePluggable;
public abstract class PipeManager {
public static List<IStripesHandler> stripesHandlers = new ArrayList<IStripesHandler>();
public static List<IExtractionHandler> extractionHandlers = new ArrayList<IExtractionHandler>();
public static ArrayList<Class<? extends PipePluggable>> pipePluggables = new ArrayList<Class<? extends PipePluggable>>();
private static Map<String, Class<? extends PipePluggable>> pipePluggableNames =
new HashMap<String, Class<? extends PipePluggable>>();
private static Map<Class<? extends PipePluggable>, String> pipePluggableByNames =
new HashMap<Class<? extends PipePluggable>, String>();
private static Map<IStripesHandler, Integer> stripesHandlerPriorities =
new HashMap<IStripesHandler, Integer>();
public static void registerExtractionHandler(IExtractionHandler handler) {
extractionHandlers.add(handler);
}
public static void registerStripesHandler(IStripesHandler handler) {
stripesHandlers.add(handler);
}
/**
* param extractor can be null
*/
@Deprecated
public static boolean canExtractItems(Object extractor, World world, int i, int j, int k) {
for (IExtractionHandler handler : extractionHandlers) {
if (!handler.canExtractItems(extractor, world, i, j, k)) {
return false;
}
}
return true;
}
/**
* param extractor can be null
*/
@Deprecated
public static boolean canExtractFluids(Object extractor, World world, int i, int j, int k) {
for (IExtractionHandler handler : extractionHandlers) {
if (!handler.canExtractFluids(extractor, world, i, j, k)) {
return false;
}
}
return true;
}
@Deprecated
public static void registerStripesHandler(IStripesHandler handler) {
registerStripesHandler(handler, 0);
}
/**
* Register a Stripes Pipe handler.
* @param handler The handler.
* @param priority The priority - 0 is normal, higher numbers have higher priority.
*/
public static void registerStripesHandler(IStripesHandler handler, int priority) {
stripesHandlers.add(handler);
stripesHandlerPriorities.put(handler, priority);
Collections.sort(stripesHandlers, new Comparator<IStripesHandler>() {
@Override
public int compare(IStripesHandler o1, IStripesHandler o2) {
return stripesHandlerPriorities.get(o2) - stripesHandlerPriorities.get(o1);
}
});
}
public static void registerPipePluggable(Class<? extends PipePluggable> pluggable, String name) {
pipePluggables.add(pluggable);
pipePluggableNames.put(name, pluggable);
pipePluggableByNames.put(pluggable, name);
}
public static Class<?> getPluggableByName(String pluggableName) {
return pipePluggableNames.get(pluggableName);
}
public static String getPluggableName(Class<? extends PipePluggable> aClass) {
return pipePluggableByNames.get(aClass);
}
}
@@ -1,10 +1,10 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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.transport;
@@ -1,12 +1,12 @@
/**
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
* 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
* 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 = "2.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|transport")
@API(apiVersion = "4.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|transport")
package buildcraft.api.transport;
import cpw.mods.fml.common.API;
@@ -0,0 +1,13 @@
package buildcraft.api.transport.pluggable;
import net.minecraft.block.Block;
public interface IFacadePluggable {
Block getCurrentBlock();
int getCurrentMetadata();
boolean isTransparent();
boolean isHollow();
}
@@ -0,0 +1,9 @@
package buildcraft.api.transport.pluggable;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.IPipe;
public interface IPipePluggableDynamicRenderer {
void renderPluggable(IPipe pipe, ForgeDirection side, PipePluggable pipePluggable, double x, double y, double z);
}
@@ -0,0 +1,10 @@
package buildcraft.api.transport.pluggable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.transport.IPipe;
public interface IPipePluggableItem {
PipePluggable createPipePluggable(IPipe pipe, ForgeDirection side, ItemStack stack);
}
@@ -0,0 +1,13 @@
package buildcraft.api.transport.pluggable;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.render.ITextureStates;
import buildcraft.api.transport.IPipe;
public interface IPipePluggableRenderer {
void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side,
PipePluggable pipePluggable, ITextureStates blockStateMachine,
int renderPass, int x, int y, int z);
}
@@ -0,0 +1,67 @@
/**
* 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.transport.pluggable;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.INBTStoreable;
import buildcraft.api.core.ISerializable;
import buildcraft.api.transport.IPipeTile;
/**
* An IPipePluggable MUST have an empty constructor for client-side
* rendering!
*/
public abstract class PipePluggable implements INBTStoreable, ISerializable {
public abstract ItemStack[] getDropItems(IPipeTile pipe);
public void update(IPipeTile pipe, ForgeDirection direction) {
}
public void onAttachedPipe(IPipeTile pipe, ForgeDirection direction) {
validate(pipe, direction);
}
public void onDetachedPipe(IPipeTile pipe, ForgeDirection direction) {
invalidate();
}
public abstract boolean isBlocking(IPipeTile pipe, ForgeDirection direction);
public void invalidate() {
}
public void validate(IPipeTile pipe, ForgeDirection direction) {
}
public boolean isSolidOnSide(IPipeTile pipe, ForgeDirection direction) {
return false;
}
public abstract AxisAlignedBB getBoundingBox(ForgeDirection side);
@SideOnly(Side.CLIENT)
public abstract IPipePluggableRenderer getRenderer();
@SideOnly(Side.CLIENT)
public IPipePluggableDynamicRenderer getDynamicRenderer() {
return null;
}
public boolean requiresRenderUpdate(PipePluggable old) {
return true;
}
}