diff --git a/src/api/java/buildcraft/api/core/BCLog.java b/src/api/java/buildcraft/api/core/BCLog.java index 4e5eada55..7f2896de1 100644 --- a/src/api/java/buildcraft/api/core/BCLog.java +++ b/src/api/java/buildcraft/api/core/BCLog.java @@ -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"); } diff --git a/src/api/java/buildcraft/api/core/BlockIndex.java b/src/api/java/buildcraft/api/core/BlockIndex.java index 87599bfa4..8c295fa8f 100644 --- a/src/api/java/buildcraft/api/core/BlockIndex.java +++ b/src/api/java/buildcraft/api/core/BlockIndex.java @@ -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 { @@ -99,7 +99,7 @@ public class BlockIndex implements Comparable { return b.x == x && b.y == y && b.z == z; } - return super.equals(obj); + return false; } @Override diff --git a/src/api/java/buildcraft/api/core/BlockMetaPair.java b/src/api/java/buildcraft/api/core/BlockMetaPair.java deleted file mode 100644 index d83c1da8e..000000000 --- a/src/api/java/buildcraft/api/core/BlockMetaPair.java +++ /dev/null @@ -1,53 +0,0 @@ -package buildcraft.api.core; - -import net.minecraft.block.Block; -import net.minecraftforge.oredict.OreDictionary; - -public class BlockMetaPair implements Comparable { - private int id, meta; - - public BlockMetaPair(Block block, int meta) { - this.id = Block.getIdFromBlock(block); - this.meta = meta; - } - - public Block getBlock() { - return Block.getBlockById(id); - } - - public int meta() { - return meta; - } - - @Override - public int hashCode() { - return 17 * meta + id; - } - - @Override - public boolean equals(Object other) { - if (other == null || !(other instanceof BlockMetaPair)) { - return false; - } - - return ((BlockMetaPair) other).id == id && ((BlockMetaPair) other).meta == meta; - } - - @Override - public int compareTo(BlockMetaPair arg) { - if (arg.id != id) { - return (id - arg.id) * 16; - } else { - return meta - arg.meta; - } - } - - @Override - public String toString() { - if (this.getBlock() == null) { - return "invalid"; - } - - return Block.blockRegistry.getNameForObject(this.getBlock()) + ":" + (this.meta == OreDictionary.WILDCARD_VALUE ? "*" : this.meta); - } -} diff --git a/src/api/java/buildcraft/api/core/BuildCraftAPI.java b/src/api/java/buildcraft/api/core/BuildCraftAPI.java index ce99d7ce6..9cb0b07e2 100644 --- a/src/api/java/buildcraft/api/core/BuildCraftAPI.java +++ b/src/api/java/buildcraft/api/core/BuildCraftAPI.java @@ -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 softBlocks = new HashSet(); - - 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 worldProperties = new HashMap(); /** * 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); } } diff --git a/src/api/java/buildcraft/api/core/EnumColor.java b/src/api/java/buildcraft/api/core/EnumColor.java index 1db68c6b0..2147e7261 100644 --- a/src/api/java/buildcraft/api/core/EnumColor.java +++ b/src/api/java/buildcraft/api/core/EnumColor.java @@ -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) diff --git a/src/api/java/buildcraft/api/core/IAreaProvider.java b/src/api/java/buildcraft/api/core/IAreaProvider.java index c0179caa1..4abcf6e95 100644 --- a/src/api/java/buildcraft/api/core/IAreaProvider.java +++ b/src/api/java/buildcraft/api/core/IAreaProvider.java @@ -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(); - } diff --git a/src/api/java/buildcraft/api/core/IBox.java b/src/api/java/buildcraft/api/core/IBox.java index 9b2798787..e1e6f7d80 100644 --- a/src/api/java/buildcraft/api/core/IBox.java +++ b/src/api/java/buildcraft/api/core/IBox.java @@ -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; diff --git a/src/api/java/buildcraft/api/core/ICoreProxy.java b/src/api/java/buildcraft/api/core/ICoreProxy.java index b5132df97..272faebfd 100755 --- a/src/api/java/buildcraft/api/core/ICoreProxy.java +++ b/src/api/java/buildcraft/api/core/ICoreProxy.java @@ -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; diff --git a/src/api/java/buildcraft/api/core/IIconProvider.java b/src/api/java/buildcraft/api/core/IIconProvider.java index 2734415d8..fa8657e64 100644 --- a/src/api/java/buildcraft/api/core/IIconProvider.java +++ b/src/api/java/buildcraft/api/core/IIconProvider.java @@ -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; diff --git a/src/api/java/buildcraft/api/core/IInvSlot.java b/src/api/java/buildcraft/api/core/IInvSlot.java index ec4918ce9..ea7a7fa30 100644 --- a/src/api/java/buildcraft/api/core/IInvSlot.java +++ b/src/api/java/buildcraft/api/core/IInvSlot.java @@ -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(); diff --git a/src/api/java/buildcraft/api/core/INBTStoreable.java b/src/api/java/buildcraft/api/core/INBTStoreable.java new file mode 100644 index 000000000..669eed33c --- /dev/null +++ b/src/api/java/buildcraft/api/core/INBTStoreable.java @@ -0,0 +1,8 @@ +package buildcraft.api.core; + +import net.minecraft.nbt.NBTTagCompound; + +public interface INBTStoreable { + void readFromNBT(NBTTagCompound tag); + void writeToNBT(NBTTagCompound tag); +} diff --git a/src/api/java/buildcraft/api/core/IPathProvider.java b/src/api/java/buildcraft/api/core/IPathProvider.java new file mode 100644 index 000000000..2ff392a92 --- /dev/null +++ b/src/api/java/buildcraft/api/core/IPathProvider.java @@ -0,0 +1,10 @@ +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 getPath(); +} diff --git a/src/api/java/buildcraft/api/core/ISerializable.java b/src/api/java/buildcraft/api/core/ISerializable.java new file mode 100644 index 000000000..a7d011ebb --- /dev/null +++ b/src/api/java/buildcraft/api/core/ISerializable.java @@ -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); +} diff --git a/src/api/java/buildcraft/api/core/IWorldProperty.java b/src/api/java/buildcraft/api/core/IWorldProperty.java index 4a900c621..a55bef1fc 100755 --- a/src/api/java/buildcraft/api/core/IWorldProperty.java +++ b/src/api/java/buildcraft/api/core/IWorldProperty.java @@ -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(); diff --git a/src/api/java/buildcraft/api/core/IZone.java b/src/api/java/buildcraft/api/core/IZone.java index a34bfd129..55ef4f80e 100755 --- a/src/api/java/buildcraft/api/core/IZone.java +++ b/src/api/java/buildcraft/api/core/IZone.java @@ -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); diff --git a/src/api/java/buildcraft/api/core/JavaTools.java b/src/api/java/buildcraft/api/core/JavaTools.java index e83a717df..e8dd4d898 100755 --- a/src/api/java/buildcraft/api/core/JavaTools.java +++ b/src/api/java/buildcraft/api/core/JavaTools.java @@ -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[] 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[] 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 getAllFields(Class clas) { - List result = new ArrayList(); - - 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 getAllMethods(Class clas) { - List result = new ArrayList(); - - 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); } diff --git a/src/api/java/buildcraft/api/core/NetworkData.java b/src/api/java/buildcraft/api/core/NetworkData.java deleted file mode 100644 index 5198f36d3..000000000 --- a/src/api/java/buildcraft/api/core/NetworkData.java +++ /dev/null @@ -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 { - -} diff --git a/src/api/java/buildcraft/api/core/Position.java b/src/api/java/buildcraft/api/core/Position.java index 4d9a7ea90..426e09f40 100644 --- a/src/api/java/buildcraft/api/core/Position.java +++ b/src/api/java/buildcraft/api/core/Position.java @@ -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; + } } diff --git a/src/api/java/buildcraft/api/core/SafeTimeTracker.java b/src/api/java/buildcraft/api/core/SafeTimeTracker.java index 9b60b86ec..3e56ee989 100644 --- a/src/api/java/buildcraft/api/core/SafeTimeTracker.java +++ b/src/api/java/buildcraft/api/core/SafeTimeTracker.java @@ -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(); } -} +} \ No newline at end of file diff --git a/src/api/java/buildcraft/api/core/StackKey.java b/src/api/java/buildcraft/api/core/StackKey.java index 092c173f0..776aaafdf 100644 --- a/src/api/java/buildcraft/api/core/StackKey.java +++ b/src/api/java/buildcraft/api/core/StackKey.java @@ -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; @@ -87,7 +87,7 @@ public final class StackKey { } } if (fluidStack != null) { - if (fluidStack.fluidID != k.fluidStack.fluidID || + if (fluidStack.getFluid().getID() != k.fluidStack.getFluid().getID() || fluidStack.amount != k.fluidStack.amount || !objectsEqual(fluidStack.tag, k.fluidStack.tag)) { return false; @@ -106,7 +106,7 @@ public final class StackKey { } result = 31 * result + 7; if (fluidStack != null) { - result = 31 * result + fluidStack.fluidID; + result = 31 * result + fluidStack.getFluid().getID(); result = 31 * result + fluidStack.amount; result = 31 * result + objectHashCode(fluidStack.tag); } diff --git a/src/api/java/buildcraft/api/core/WorldBlockIndex.java b/src/api/java/buildcraft/api/core/WorldBlockIndex.java deleted file mode 100755 index aedbeaf58..000000000 --- a/src/api/java/buildcraft/api/core/WorldBlockIndex.java +++ /dev/null @@ -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 { - - 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; - } -} diff --git a/src/api/java/buildcraft/api/core/package-info.java b/src/api/java/buildcraft/api/core/package-info.java index 5bc4a2fa9..0fc4db4cc 100644 --- a/src/api/java/buildcraft/api/core/package-info.java +++ b/src/api/java/buildcraft/api/core/package-info.java @@ -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; + diff --git a/src/api/java/buildcraft/api/core/render/ICullable.java b/src/api/java/buildcraft/api/core/render/ICullable.java new file mode 100644 index 000000000..b800c0851 --- /dev/null +++ b/src/api/java/buildcraft/api/core/render/ICullable.java @@ -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); + +} diff --git a/src/api/java/buildcraft/api/core/render/ITextureStateManager.java b/src/api/java/buildcraft/api/core/render/ITextureStateManager.java new file mode 100644 index 000000000..8161d6b93 --- /dev/null +++ b/src/api/java/buildcraft/api/core/render/ITextureStateManager.java @@ -0,0 +1,7 @@ +package buildcraft.api.core.render; + +import net.minecraft.util.IIcon; + +public interface ITextureStateManager { + void set(IIcon icon); +} diff --git a/src/api/java/buildcraft/api/core/render/ITextureStates.java b/src/api/java/buildcraft/api/core/render/ITextureStates.java new file mode 100644 index 000000000..835caf7fe --- /dev/null +++ b/src/api/java/buildcraft/api/core/render/ITextureStates.java @@ -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(); + +} diff --git a/src/api/java/buildcraft/api/gates/GateExpansionController.java b/src/api/java/buildcraft/api/gates/GateExpansionController.java index 5a9eca25d..e37ae20a5 100644 --- a/src/api/java/buildcraft/api/gates/GateExpansionController.java +++ b/src/api/java/buildcraft/api/gates/GateExpansionController.java @@ -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; } diff --git a/src/api/java/buildcraft/api/gates/GateExpansions.java b/src/api/java/buildcraft/api/gates/GateExpansions.java index c94b9b729..bc667f58e 100644 --- a/src/api/java/buildcraft/api/gates/GateExpansions.java +++ b/src/api/java/buildcraft/api/gates/GateExpansions.java @@ -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 expansions = new HashMap(); private static final ArrayList expansionIDs = new ArrayList(); + private static final Map 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 getRecipesForPostInit() { + return recipes; + } // The code below is used by networking. diff --git a/src/api/java/buildcraft/api/gates/IGate.java b/src/api/java/buildcraft/api/gates/IGate.java index 2018cb441..6127caadb 100644 --- a/src/api/java/buildcraft/api/gates/IGate.java +++ b/src/api/java/buildcraft/api/gates/IGate.java @@ -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 getTriggers(); + List getActions(); + + List getActiveActions(); + + List getTriggerParameters(int index); + List getActionParameters(int index); } diff --git a/src/api/java/buildcraft/api/gates/IGateExpansion.java b/src/api/java/buildcraft/api/gates/IGateExpansion.java index 361f0a4dd..ad61fad66 100644 --- a/src/api/java/buildcraft/api/gates/IGateExpansion.java +++ b/src/api/java/buildcraft/api/gates/IGateExpansion.java @@ -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; diff --git a/src/api/java/buildcraft/api/gates/package-info.java b/src/api/java/buildcraft/api/gates/package-info.java index 067e6edcf..83cb2a2c4 100644 --- a/src/api/java/buildcraft/api/gates/package-info.java +++ b/src/api/java/buildcraft/api/gates/package-info.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/ActionState.java b/src/api/java/buildcraft/api/statements/ActionState.java index 1a30beb4e..72e4d58ba 100755 --- a/src/api/java/buildcraft/api/statements/ActionState.java +++ b/src/api/java/buildcraft/api/statements/ActionState.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/IActionExternal.java b/src/api/java/buildcraft/api/statements/IActionExternal.java index 6bb0ad1bf..1d6e2eb54 100644 --- a/src/api/java/buildcraft/api/statements/IActionExternal.java +++ b/src/api/java/buildcraft/api/statements/IActionExternal.java @@ -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); - } diff --git a/src/api/java/buildcraft/api/statements/IActionInternal.java b/src/api/java/buildcraft/api/statements/IActionInternal.java index 21f2c7f86..6a019a459 100644 --- a/src/api/java/buildcraft/api/statements/IActionInternal.java +++ b/src/api/java/buildcraft/api/statements/IActionInternal.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/IActionProvider.java b/src/api/java/buildcraft/api/statements/IActionProvider.java index 761156f80..147d4d39d 100644 --- a/src/api/java/buildcraft/api/statements/IActionProvider.java +++ b/src/api/java/buildcraft/api/statements/IActionProvider.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/IActionReceptor.java b/src/api/java/buildcraft/api/statements/IActionReceptor.java index f4ef4968b..db7cea027 100644 --- a/src/api/java/buildcraft/api/statements/IActionReceptor.java +++ b/src/api/java/buildcraft/api/statements/IActionReceptor.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java b/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java index 22d86ebc6..c9c7db8ed 100644 --- a/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java +++ b/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/IStatement.java b/src/api/java/buildcraft/api/statements/IStatement.java index a05824d66..e466efd2b 100644 --- a/src/api/java/buildcraft/api/statements/IStatement.java +++ b/src/api/java/buildcraft/api/statements/IStatement.java @@ -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 - * ":". + * Every statement needs a unique tag, it should be in the format of + * "<modid>:<name>. * * @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(); diff --git a/src/api/java/buildcraft/api/statements/IStatementContainer.java b/src/api/java/buildcraft/api/statements/IStatementContainer.java index f258b3416..43a4f51ef 100644 --- a/src/api/java/buildcraft/api/statements/IStatementContainer.java +++ b/src/api/java/buildcraft/api/statements/IStatementContainer.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/IStatementParameter.java b/src/api/java/buildcraft/api/statements/IStatementParameter.java index 0bbc3dcb0..9a9e397cd 100755 --- a/src/api/java/buildcraft/api/statements/IStatementParameter.java +++ b/src/api/java/buildcraft/api/statements/IStatementParameter.java @@ -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 - * ":". + * "<modi>:<name>". * * @return the unique id */ diff --git a/src/api/java/buildcraft/api/statements/ITriggerExternal.java b/src/api/java/buildcraft/api/statements/ITriggerExternal.java index 9167761c4..532f67a5f 100644 --- a/src/api/java/buildcraft/api/statements/ITriggerExternal.java +++ b/src/api/java/buildcraft/api/statements/ITriggerExternal.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java b/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java new file mode 100644 index 000000000..7103c06ac --- /dev/null +++ b/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java @@ -0,0 +1,17 @@ +package buildcraft.api.statements; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * This interface can be used by tiles to override external trigger + * behaviour. + * + * Please use wisely. + */ +public interface ITriggerExternalOverride { + public enum Result { + TRUE, FALSE, IGNORE + } + + Result override(ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters); +} diff --git a/src/api/java/buildcraft/api/statements/ITriggerInternal.java b/src/api/java/buildcraft/api/statements/ITriggerInternal.java index 750331b5a..a4241d3da 100755 --- a/src/api/java/buildcraft/api/statements/ITriggerInternal.java +++ b/src/api/java/buildcraft/api/statements/ITriggerInternal.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/ITriggerProvider.java b/src/api/java/buildcraft/api/statements/ITriggerProvider.java index 92c154218..548f107bf 100644 --- a/src/api/java/buildcraft/api/statements/ITriggerProvider.java +++ b/src/api/java/buildcraft/api/statements/ITriggerProvider.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/StatementManager.java b/src/api/java/buildcraft/api/statements/StatementManager.java index 5718dc3b1..fec7d9510 100644 --- a/src/api/java/buildcraft/api/statements/StatementManager.java +++ b/src/api/java/buildcraft/api/statements/StatementManager.java @@ -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(); } } diff --git a/src/api/java/buildcraft/api/statements/StatementMouseClick.java b/src/api/java/buildcraft/api/statements/StatementMouseClick.java index d48ade5cd..54688ebb8 100644 --- a/src/api/java/buildcraft/api/statements/StatementMouseClick.java +++ b/src/api/java/buildcraft/api/statements/StatementMouseClick.java @@ -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; diff --git a/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java b/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java index 02c796dbe..3bccda5d3 100755 --- a/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java +++ b/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java @@ -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; } } diff --git a/src/api/java/buildcraft/api/statements/StatementSlot.java b/src/api/java/buildcraft/api/statements/StatementSlot.java new file mode 100644 index 000000000..6d8c1c2ce --- /dev/null +++ b/src/api/java/buildcraft/api/statements/StatementSlot.java @@ -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; + } +} diff --git a/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java b/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java new file mode 100644 index 000000000..0856041cb --- /dev/null +++ b/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java @@ -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); +} diff --git a/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java b/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java new file mode 100644 index 000000000..6262bf2f8 --- /dev/null +++ b/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java @@ -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(); +} diff --git a/src/api/java/buildcraft/api/statements/package-info.java b/src/api/java/buildcraft/api/statements/package-info.java index 94d36f68e..ed7613ea2 100644 --- a/src/api/java/buildcraft/api/statements/package-info.java +++ b/src/api/java/buildcraft/api/statements/package-info.java @@ -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; diff --git a/src/api/java/buildcraft/api/transport/IExtractionHandler.java b/src/api/java/buildcraft/api/transport/IExtractionHandler.java deleted file mode 100755 index 4d56659ed..000000000 --- a/src/api/java/buildcraft/api/transport/IExtractionHandler.java +++ /dev/null @@ -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); -} diff --git a/src/api/java/buildcraft/api/transport/IInjectable.java b/src/api/java/buildcraft/api/transport/IInjectable.java new file mode 100644 index 000000000..6a05a688a --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IInjectable.java @@ -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); +} diff --git a/src/api/java/buildcraft/api/transport/IItemPipe.java b/src/api/java/buildcraft/api/transport/IItemPipe.java new file mode 100644 index 000000000..f5f766775 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IItemPipe.java @@ -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 { + +} diff --git a/src/api/java/buildcraft/api/transport/IPipe.java b/src/api/java/buildcraft/api/transport/IPipe.java index e4a82a4c0..94b021d02 100755 --- a/src/api/java/buildcraft/api/transport/IPipe.java +++ b/src/api/java/buildcraft/api/transport/IPipe.java @@ -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); diff --git a/src/api/java/buildcraft/api/transport/IPipeConnection.java b/src/api/java/buildcraft/api/transport/IPipeConnection.java index 27ca26ff5..4899f24bd 100644 --- a/src/api/java/buildcraft/api/transport/IPipeConnection.java +++ b/src/api/java/buildcraft/api/transport/IPipeConnection.java @@ -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); } diff --git a/src/api/java/buildcraft/api/transport/IPipePluggable.java b/src/api/java/buildcraft/api/transport/IPipePluggable.java deleted file mode 100755 index b299d07f1..000000000 --- a/src/api/java/buildcraft/api/transport/IPipePluggable.java +++ /dev/null @@ -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); -} diff --git a/src/api/java/buildcraft/api/transport/IPipeTile.java b/src/api/java/buildcraft/api/transport/IPipeTile.java index a37db11ad..1bdd04f09 100644 --- a/src/api/java/buildcraft/api/transport/IPipeTile.java +++ b/src/api/java/buildcraft/api/transport/IPipeTile.java @@ -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); } diff --git a/src/api/java/buildcraft/api/transport/IStripesActivator.java b/src/api/java/buildcraft/api/transport/IStripesActivator.java new file mode 100644 index 000000000..47308ae0a --- /dev/null +++ b/src/api/java/buildcraft/api/transport/IStripesActivator.java @@ -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); +} diff --git a/src/api/java/buildcraft/api/transport/IStripesHandler.java b/src/api/java/buildcraft/api/transport/IStripesHandler.java index f8c36e364..a9cc011f6 100644 --- a/src/api/java/buildcraft/api/transport/IStripesHandler.java +++ b/src/api/java/buildcraft/api/transport/IStripesHandler.java @@ -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); } diff --git a/src/api/java/buildcraft/api/transport/IStripesPipe.java b/src/api/java/buildcraft/api/transport/IStripesPipe.java index e65750973..30a8452d5 100644 --- a/src/api/java/buildcraft/api/transport/IStripesPipe.java +++ b/src/api/java/buildcraft/api/transport/IStripesPipe.java @@ -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 { } diff --git a/src/api/java/buildcraft/api/transport/PipeManager.java b/src/api/java/buildcraft/api/transport/PipeManager.java index 6cc0e3429..896f08210 100755 --- a/src/api/java/buildcraft/api/transport/PipeManager.java +++ b/src/api/java/buildcraft/api/transport/PipeManager.java @@ -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 stripesHandlers = new ArrayList(); - public static List extractionHandlers = new ArrayList(); + public static ArrayList> pipePluggables = new ArrayList>(); + private static Map> pipePluggableNames = + new HashMap>(); + private static Map, String> pipePluggableByNames = + new HashMap, String>(); + private static Map stripesHandlerPriorities = + new HashMap(); - 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() { + @Override + public int compare(IStripesHandler o1, IStripesHandler o2) { + return stripesHandlerPriorities.get(o2) - stripesHandlerPriorities.get(o1); + } + }); + } + + public static void registerPipePluggable(Class 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 aClass) { + return pipePluggableByNames.get(aClass); + } } diff --git a/src/api/java/buildcraft/api/transport/PipeWire.java b/src/api/java/buildcraft/api/transport/PipeWire.java index e7551091a..eb8665e15 100644 --- a/src/api/java/buildcraft/api/transport/PipeWire.java +++ b/src/api/java/buildcraft/api/transport/PipeWire.java @@ -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; diff --git a/src/api/java/buildcraft/api/transport/package-info.java b/src/api/java/buildcraft/api/transport/package-info.java index 414098f2a..b670143c6 100644 --- a/src/api/java/buildcraft/api/transport/package-info.java +++ b/src/api/java/buildcraft/api/transport/package-info.java @@ -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; diff --git a/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java b/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java new file mode 100644 index 000000000..6289714ac --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java @@ -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(); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableDynamicRenderer.java b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableDynamicRenderer.java new file mode 100644 index 000000000..614c65ff9 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableDynamicRenderer.java @@ -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); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableItem.java b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableItem.java new file mode 100644 index 000000000..0ac208905 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableItem.java @@ -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); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableRenderer.java b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableRenderer.java new file mode 100644 index 000000000..2cd4bc276 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableRenderer.java @@ -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); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java b/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java new file mode 100644 index 000000000..223ce7096 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java @@ -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; + } +}