diff --git a/src/api/java/buildcraft/api/core/BCLog.java b/src/api/java/buildcraft/api/core/BCLog.java index 4e5eada5535..7f2896de167 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 @@ private 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 87599bfa428..8c295fa8f1e 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.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 boolean equals(Object obj) { 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/BuildCraftAPI.java b/src/api/java/buildcraft/api/core/BuildCraftAPI.java index ce99d7ce65b..9cb0b07e229 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 1db68c6b0a3..2147e726132 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 String toString() { 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 c0179caa124..4abcf6e95c3 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 @@ * 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 9b279878740..e1e6f7d8071 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 old mode 100644 new mode 100755 index b5132df970b..272faebfda2 --- 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 2734415d8a4..fa8657e64fe 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 ec4918ce91d..ea7a7fa30cd 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 00000000000..669eed33cb1 --- /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/ISerializable.java b/src/api/java/buildcraft/api/core/ISerializable.java new file mode 100644 index 00000000000..a7d011ebb69 --- /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 old mode 100644 new mode 100755 index 4a900c621f7..a55bef1fce4 --- 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 old mode 100644 new mode 100755 index a34bfd12994..55ef4f80e3f --- 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 old mode 100644 new mode 100755 index e83a717df01..e8dd4d898cb --- 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 static float[] concat(float[] first, float[] second) { 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 5198f36d3f2..00000000000 --- 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 4d9a7ea90c3..426e09f40dd 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 boolean isClose(Position newPosition, float f) { 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 9b60b86ec22..3e56ee9898d 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 long durationOfLastDelay() { 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 68b990fef22..776aaafdfb2 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; diff --git a/src/api/java/buildcraft/api/core/WorldBlockIndex.java b/src/api/java/buildcraft/api/core/WorldBlockIndex.java deleted file mode 100644 index aedbeaf58d8..00000000000 --- 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 5bc4a2fa924..0fc4db4cccf 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 00000000000..b800c085127 --- /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 00000000000..8161d6b938b --- /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 00000000000..835caf7fe7d --- /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/fuels/BuildcraftFuelRegistry.java b/src/api/java/buildcraft/api/fuels/BuildcraftFuelRegistry.java index eda676ebc87..873f937680e 100644 --- a/src/api/java/buildcraft/api/fuels/BuildcraftFuelRegistry.java +++ b/src/api/java/buildcraft/api/fuels/BuildcraftFuelRegistry.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.fuels; diff --git a/src/api/java/buildcraft/api/fuels/ICoolant.java b/src/api/java/buildcraft/api/fuels/ICoolant.java index fd0e6d4df7d..17fdf09f225 100644 --- a/src/api/java/buildcraft/api/fuels/ICoolant.java +++ b/src/api/java/buildcraft/api/fuels/ICoolant.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.fuels; diff --git a/src/api/java/buildcraft/api/fuels/ICoolantManager.java b/src/api/java/buildcraft/api/fuels/ICoolantManager.java index 6e29c15c5f2..ccf98798d2f 100644 --- a/src/api/java/buildcraft/api/fuels/ICoolantManager.java +++ b/src/api/java/buildcraft/api/fuels/ICoolantManager.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.fuels; diff --git a/src/api/java/buildcraft/api/fuels/IFuel.java b/src/api/java/buildcraft/api/fuels/IFuel.java index c3e292802b7..6bb018becde 100644 --- a/src/api/java/buildcraft/api/fuels/IFuel.java +++ b/src/api/java/buildcraft/api/fuels/IFuel.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.fuels; diff --git a/src/api/java/buildcraft/api/fuels/IFuelManager.java b/src/api/java/buildcraft/api/fuels/IFuelManager.java index 50ac9341931..c280885fd65 100644 --- a/src/api/java/buildcraft/api/fuels/IFuelManager.java +++ b/src/api/java/buildcraft/api/fuels/IFuelManager.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.fuels; diff --git a/src/api/java/buildcraft/api/fuels/ISolidCoolant.java b/src/api/java/buildcraft/api/fuels/ISolidCoolant.java index 69e4871ed27..d8fd2d45d60 100644 --- a/src/api/java/buildcraft/api/fuels/ISolidCoolant.java +++ b/src/api/java/buildcraft/api/fuels/ISolidCoolant.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.fuels; diff --git a/src/api/java/buildcraft/api/fuels/package-info.java b/src/api/java/buildcraft/api/fuels/package-info.java index fe46ec34eef..eca72994c18 100644 --- a/src/api/java/buildcraft/api/fuels/package-info.java +++ b/src/api/java/buildcraft/api/fuels/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 = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|fuels") package buildcraft.api.fuels; import cpw.mods.fml.common.API; + diff --git a/src/api/java/buildcraft/api/gates/GateExpansionController.java b/src/api/java/buildcraft/api/gates/GateExpansionController.java index 5a9eca25d42..e37ae20a5f1 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 void tick(IGate gate) { 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 c94b9b72929..bc667f58e78 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.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 static void registerExpansion(String identifier, IGateExpansion expansion expansionIDs.add(expansion); } + public static void registerExpansion(IGateExpansion expansion, ItemStack addedRecipe) { + registerExpansion(expansion.getUniqueIdentifier(), expansion); + recipes.put(expansion, addedRecipe); + } + public static IGateExpansion getExpansion(String identifier) { return expansions.get(identifier); } @@ -40,6 +49,10 @@ public static Set getExpansions() { 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 2018cb4410a..6127caadb8f 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 361f0a4dd38..ad61fad6699 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 067e6edcf17..83cb2a2c41d 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/package-info.java b/src/api/java/buildcraft/api/package-info.java index d7f469fe975..81c35570fbc 100644 --- a/src/api/java/buildcraft/api/package-info.java +++ b/src/api/java/buildcraft/api/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") package buildcraft.api; import cpw.mods.fml.common.API; + diff --git a/src/api/java/buildcraft/api/power/ILaserTarget.java b/src/api/java/buildcraft/api/power/ILaserTarget.java index 8d896cb8098..8cc151e6c82 100644 --- a/src/api/java/buildcraft/api/power/ILaserTarget.java +++ b/src/api/java/buildcraft/api/power/ILaserTarget.java @@ -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(); } diff --git a/src/api/java/buildcraft/api/power/ILaserTargetBlock.java b/src/api/java/buildcraft/api/power/ILaserTargetBlock.java index 71298b14bd7..c2f658b7628 100644 --- a/src/api/java/buildcraft/api/power/ILaserTargetBlock.java +++ b/src/api/java/buildcraft/api/power/ILaserTargetBlock.java @@ -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 { } diff --git a/src/api/java/buildcraft/api/power/IPowerEmitter.java b/src/api/java/buildcraft/api/power/IPowerEmitter.java deleted file mode 100644 index bdac3e4b7e2..00000000000 --- a/src/api/java/buildcraft/api/power/IPowerEmitter.java +++ /dev/null @@ -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); -} diff --git a/src/api/java/buildcraft/api/power/IPowerReceptor.java b/src/api/java/buildcraft/api/power/IPowerReceptor.java deleted file mode 100644 index 5240ef7449f..00000000000 --- a/src/api/java/buildcraft/api/power/IPowerReceptor.java +++ /dev/null @@ -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(); -} diff --git a/src/api/java/buildcraft/api/power/PowerHandler.java b/src/api/java/buildcraft/api/power/PowerHandler.java deleted file mode 100644 index 8ae21ad5167..00000000000 --- a/src/api/java/buildcraft/api/power/PowerHandler.java +++ /dev/null @@ -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; - } - } -} diff --git a/src/api/java/buildcraft/api/power/package-info.java b/src/api/java/buildcraft/api/power/package-info.java index 0a95496b739..6ee4864dc5f 100644 --- a/src/api/java/buildcraft/api/power/package-info.java +++ b/src/api/java/buildcraft/api/power/package-info.java @@ -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; + diff --git a/src/api/java/buildcraft/api/statements/ActionState.java b/src/api/java/buildcraft/api/statements/ActionState.java old mode 100644 new mode 100755 index 1a30beb4ef9..72e4d58bab7 --- 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 6bb0ad1bfc3..1d6e2eb5495 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.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 21f2c7f86f7..6a019a45929 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 761156f801a..147d4d39df2 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 f4ef4968b8b..db7cea02785 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 22d86ebc66c..c9c7db8ed53 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 a05824d66a3..e466efd2bbd 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 f258b341610..43a4f51ef13 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 old mode 100644 new mode 100755 index 0bbc3dcb010..9a9e397cd37 --- 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.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 9167761c408..532f67a5fba 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/ITriggerInternal.java b/src/api/java/buildcraft/api/statements/ITriggerInternal.java old mode 100644 new mode 100755 index 750331b5ae8..a4241d3da65 --- 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 92c154218fe..548f107bf41 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 5718dc3b186..fec7d9510f2 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 static List getExternalActions(ForgeDirection side, Tile 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 d48ade5cd54..54688ebb8b2 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 old mode 100644 new mode 100755 index 02c796dbec6..3bccda5d34c --- 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 void onClick(IStatementContainer source, IStatement stmt, ItemStack stack 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 100755 index 00000000000..6d8c1c2cee4 --- /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 00000000000..0856041cb09 --- /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 00000000000..6262bf2f81a --- /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 94d36f68e72..ed7613ea255 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/tools/IToolWrench.java b/src/api/java/buildcraft/api/tools/IToolWrench.java index 3bd8dcea129..c5c9d86f443 100644 --- a/src/api/java/buildcraft/api/tools/IToolWrench.java +++ b/src/api/java/buildcraft/api/tools/IToolWrench.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.tools; diff --git a/src/api/java/buildcraft/api/tools/package-info.java b/src/api/java/buildcraft/api/tools/package-info.java index 6a2a363a942..538e11eaea7 100644 --- a/src/api/java/buildcraft/api/tools/package-info.java +++ b/src/api/java/buildcraft/api/tools/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 = "BuildCraftAPI|core", provides = "BuildCraftAPI|tools") package buildcraft.api.tools; 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 100644 index 4d56659ed92..00000000000 --- 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 00000000000..6a05a688ac8 --- /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/IPipe.java b/src/api/java/buildcraft/api/transport/IPipe.java old mode 100644 new mode 100755 index e4a82a4c04a..94b021d02b4 --- 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 27ca26ff5be..4899f24bdc5 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 @@ enum ConnectOverride { * @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 100644 index b299d07f135..00000000000 --- 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 a37db11ad8d..1bdd04f09a0 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; - -public interface IPipeTile { - public enum PipeType { +import buildcraft.api.core.EnumColor; +import buildcraft.api.transport.pluggable.PipePluggable; - 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 enum PipeType { */ 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 00000000000..47308ae0aeb --- /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 f8c36e36468..a9cc011f63b 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.minecraftforge.common.util.ForgeDirection; public interface IStripesHandler { - public static enum StripesHandlerType { + enum StripesHandlerType { ITEM_USE, BLOCK_BREAK } @@ -16,5 +24,5 @@ public static enum StripesHandlerType { 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 e657509733c..30a8452d5f9 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 old mode 100644 new mode 100755 index 6cc0e3429e0..896f0821082 --- 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(); + + @Deprecated + public static boolean canExtractItems(Object extractor, World world, int i, int j, int k) { + return true; + } - public static void registerExtractionHandler(IExtractionHandler handler) { - extractionHandlers.add(handler); + @Deprecated + public static boolean canExtractFluids(Object extractor, World world, int i, int j, int k) { + return true; } - + + @Deprecated public static void registerStripesHandler(IStripesHandler handler) { - stripesHandlers.add(handler); + registerStripesHandler(handler, 0); } /** - * param extractor can be null + * Register a Stripes Pipe handler. + * @param handler The handler. + * @param priority The priority - 0 is normal, higher numbers have higher priority. */ - 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; + 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); } - } + }); + } - return true; + public static void registerPipePluggable(Class pluggable, String name) { + pipePluggables.add(pluggable); + pipePluggableNames.put(name, pluggable); + pipePluggableByNames.put(pluggable, name); } - /** - * param extractor can be null - */ - 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; - } - } + public static Class getPluggableByName(String pluggableName) { + return pipePluggableNames.get(pluggableName); + } - return true; + 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 e7551091a49..eb8665e15fc 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 414098f2a2d..b670143c6ca 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 00000000000..6289714ac79 --- /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 00000000000..614c65ff9a6 --- /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 00000000000..0ac2089051a --- /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 00000000000..2cd4bc27699 --- /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 100755 index 00000000000..223ce70969d --- /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; + } +}