diff --git a/src/api/java/buildcraft/api/core/BCLog.java b/src/api/java/buildcraft/api/core/BCLog.java index 7f2896de1..1ba70725c 100644 --- a/src/api/java/buildcraft/api/core/BCLog.java +++ b/src/api/java/buildcraft/api/core/BCLog.java @@ -1,60 +1,42 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.Method; - import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public final class BCLog { + public static final Logger logger = LogManager.getLogger("BuildCraft"); - public static final Logger logger = LogManager.getLogger("BuildCraft"); - - /** - * Deactivate constructor - */ - private BCLog() { - } - - public static void initLog() { - - logger.info("Starting BuildCraft " + getVersion()); - logger.info("Copyright (c) SpaceToad, 2011-2015"); - logger.info("http://www.mod-buildcraft.com"); - } + /** Deactivate constructor */ + private BCLog() {} + @Deprecated public static void logErrorAPI(String mod, Throwable error, Class classFile) { - StringBuilder msg = new StringBuilder(mod); - msg.append(" API error, please update your mods. Error: ").append(error); - StackTraceElement[] stackTrace = error.getStackTrace(); - if (stackTrace.length > 0) { - msg.append(", ").append(stackTrace[0]); - } + logErrorAPI(error, classFile); + } - logger.log(Level.ERROR, msg.toString()); + public static void logErrorAPI(Throwable error, Class classFile) { + StringBuilder msg = new StringBuilder("API error! Please update your mods. Error: "); + msg.append(error); + StackTraceElement[] stackTrace = error.getStackTrace(); + if (stackTrace.length > 0) { + msg.append(", ").append(stackTrace[0]); + } - if (classFile != null) { - msg = new StringBuilder(mod); - msg.append(" API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain().getCodeSource().getLocation()); - logger.log(Level.ERROR, msg.toString()); - } - } + logger.log(Level.ERROR, msg.toString()); - public static String getVersion() { - try { - Class clazz = Class.forName("buildcraft.core.Version"); - Method method = clazz.getDeclaredMethod("getVersion"); - return String.valueOf(method.invoke(null)); - } catch (Exception e) { - return "UNKNOWN VERSION"; + if (classFile != null) { + msg.append("API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain().getCodeSource().getLocation()); + logger.log(Level.ERROR, msg.toString()); } } + + @Deprecated + public static String getVersion() { + return BuildCraftAPI.getVersion(); + } } diff --git a/src/api/java/buildcraft/api/core/BlockIndex.java b/src/api/java/buildcraft/api/core/BlockIndex.java deleted file mode 100644 index 8c295fa8f..000000000 --- a/src/api/java/buildcraft/api/core/BlockIndex.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. - * Please check the contents of the license, which should be located - * as "LICENSE.API" in the BuildCraft source code distribution. - */ -package buildcraft.api.core; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -/** - * This class is a comparable container for integer block positions. - */ -public class BlockIndex implements Comparable { - - public int x; - public int y; - public int z; - - public BlockIndex() { - - } - - /** - * Creates an index for a block located on x, y. z - */ - public BlockIndex(int x, int y, int z) { - - this.x = x; - this.y = y; - this.z = z; - } - - public BlockIndex(NBTTagCompound c) { - this.x = c.getInteger("i"); - this.y = c.getInteger("j"); - this.z = c.getInteger("k"); - } - - public BlockIndex(Entity entity) { - x = (int) Math.floor(entity.posX); - y = (int) Math.floor(entity.posY); - z = (int) Math.floor(entity.posZ); - } - - public BlockIndex(TileEntity entity) { - this(entity.xCoord, entity.yCoord, entity.zCoord); - } - - /** - * Provides a deterministic and complete ordering of block positions. - */ - @Override - public int compareTo(BlockIndex o) { - - 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("i", x); - c.setInteger("j", y); - c.setInteger("k", z); - } - - public Block getBlock(World world) { - return world.getBlock(x, y, z); - } - - @Override - public String toString() { - return "{" + x + ", " + y + ", " + z + "}"; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof BlockIndex) { - BlockIndex b = (BlockIndex) obj; - - return b.x == x && b.y == y && b.z == z; - } - - return false; - } - - @Override - public int hashCode() { - return (x * 37 + y) * 37 + z; - } - - public boolean nextTo(BlockIndex blockIndex) { - return (Math.abs(blockIndex.x - x) <= 1 && blockIndex.y == y && blockIndex.z == z) - || (blockIndex.x == x && Math.abs(blockIndex.y - y) <= 1 && blockIndex.z == z) - || (blockIndex.x == x && blockIndex.y == y && Math.abs(blockIndex.z - z) <= 1); - } -} diff --git a/src/api/java/buildcraft/api/core/BuildCraftAPI.java b/src/api/java/buildcraft/api/core/BuildCraftAPI.java index 9cb0b07e2..5e172ba18 100644 --- a/src/api/java/buildcraft/api/core/BuildCraftAPI.java +++ b/src/api/java/buildcraft/api/core/BuildCraftAPI.java @@ -1,45 +1,52 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.Method; import java.util.HashMap; -import java.util.HashSet; import java.util.Set; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + import net.minecraft.block.Block; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; public final class BuildCraftAPI { - public static ICoreProxy proxy; + public static ICoreProxy proxy; - public static final Set softBlocks = new HashSet(); - public static final HashMap worldProperties = new HashMap(); + public static final Set softBlocks = Sets.newHashSet(); + public static final HashMap worldProperties = Maps.newHashMap(); - /** - * Deactivate constructor - */ - private BuildCraftAPI() { - } + /** Deactivate constructor */ + 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() + "!"); + public static String getVersion() { + try { + Class clazz = Class.forName("buildcraft.core.Version"); + Method method = clazz.getDeclaredMethod("getVersion"); + return String.valueOf(method.invoke(null)); + } catch (Exception e) { + return "UNKNOWN VERSION"; } - worldProperties.put(name, property); } - public static boolean isSoftBlock(World world, int x, int y, int z) { - return worldProperties.get("soft").get(world, x, y, z); - } + 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, BlockPos pos) { + return worldProperties.get("soft").get(world, pos); + } } diff --git a/src/api/java/buildcraft/api/core/ConfigAccessor.java b/src/api/java/buildcraft/api/core/ConfigAccessor.java new file mode 100644 index 000000000..a66346ac5 --- /dev/null +++ b/src/api/java/buildcraft/api/core/ConfigAccessor.java @@ -0,0 +1,48 @@ +package buildcraft.api.core; + +import java.util.Map; + +import com.google.common.collect.Maps; + +import net.minecraftforge.common.config.Property; + +/** Use this to access the various config options. It is recommended that you use this as opposed to the variables in + * the mod, as users may only install the modules that they want, and not the one you may have refereed to. */ +@Deprecated +public final class ConfigAccessor { + public enum EMod { + CORE, + BUILDERS, + ENERGY, + FACTORY, + ROBITICS, + SILICON, + TRANSPORT + } + + private static Map mods = Maps.newHashMap(); + + private ConfigAccessor() {} + + public static Property getOption(EMod mod, String name) { + if (mods.containsKey(mod)) { + return mods.get(mod).getOption(name); + } else { + return null; + } + } + + public static boolean getBoolean(EMod mod, String name, boolean defaultBoolean) { + Property prop = getOption(mod, name); + if (prop == null) { + return defaultBoolean; + } else { + return prop.getBoolean(defaultBoolean); + } + } + + /** WARNING: INTERNAL USE ONLY! */ + public static void addMod(EMod mod, IBuildCraftMod actual) { + mods.put(mod, actual); + } +} diff --git a/src/api/java/buildcraft/api/core/EnumColor.java b/src/api/java/buildcraft/api/core/EnumColor.java index 2147e7261..852eea1ba 100644 --- a/src/api/java/buildcraft/api/core/EnumColor.java +++ b/src/api/java/buildcraft/api/core/EnumColor.java @@ -1,201 +1,147 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.util.IIcon; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.util.IStringSerializable; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public enum EnumColor { +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; - BLACK, - RED, - GREEN, - BROWN, - BLUE, - PURPLE, - CYAN, - LIGHT_GRAY, - GRAY, - PINK, - LIME, - YELLOW, - LIGHT_BLUE, - MAGENTA, - ORANGE, - WHITE; +/** Use minecraft's EnumDyeColor in as many places as possible. */ +@Deprecated +public enum EnumColor implements IStringSerializable { - public static final EnumColor[] VALUES = values(); - public static final String[] DYES = { - "dyeBlack", - "dyeRed", - "dyeGreen", - "dyeBrown", - "dyeBlue", - "dyePurple", - "dyeCyan", - "dyeLightGray", - "dyeGray", - "dyePink", - "dyeLime", - "dyeYellow", - "dyeLightBlue", - "dyeMagenta", - "dyeOrange", - "dyeWhite"}; - public static final String[] NAMES = { - "Black", - "Red", - "Green", - "Brown", - "Blue", - "Purple", - "Cyan", - "LightGray", - "Gray", - "Pink", - "Lime", - "Yellow", - "LightBlue", - "Magenta", - "Orange", - "White"}; - public static final int[] DARK_HEX = { - 0x2D2D2D, - 0xA33835, - 0x394C1E, - 0x5C3A24, - 0x3441A2, - 0x843FBF, - 0x36809E, - 0x888888, - 0x444444, - 0xE585A0, - 0x3FAA36, - 0xCFC231, - 0x7F9AD1, - 0xFF64FF, - 0xFF6A00, - 0xFFFFFF}; - public static final int[] LIGHT_HEX = { - 0x181414, - 0xBE2B27, - 0x007F0E, - 0x89502D, - 0x253193, - 0x7e34bf, - 0x299799, - 0xa0a7a7, - 0x7A7A7A, - 0xD97199, - 0x39D52E, - 0xFFD91C, - 0x66AAFF, - 0xD943C6, - 0xEA7835, - 0xe4e4e4}; + BLACK, + RED, + GREEN, + BROWN, + BLUE, + PURPLE, + CYAN, + LIGHT_GRAY, + GRAY, + PINK, + LIME, + YELLOW, + LIGHT_BLUE, + MAGENTA, + ORANGE, + WHITE; - @SideOnly(Side.CLIENT) - private static IIcon[] brushIcons; + public static final EnumColor[] VALUES = values(); + public static final String[] DYES = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", + "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" }; + public static final String[] NAMES = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", + "LightBlue", "Magenta", "Orange", "White" }; + public static final int[] DARK_HEX = { 0x2D2D2D, 0xA33835, 0x394C1E, 0x5C3A24, 0x3441A2, 0x843FBF, 0x36809E, 0x888888, 0x444444, 0xE585A0, + 0x3FAA36, 0xCFC231, 0x7F9AD1, 0xFF64FF, 0xFF6A00, 0xFFFFFF }; + public static final int[] LIGHT_HEX = { 0x181414, 0xBE2B27, 0x007F0E, 0x89502D, 0x253193, 0x7e34bf, 0x299799, 0xa0a7a7, 0x7A7A7A, 0xD97199, + 0x39D52E, 0xFFD91C, 0x66AAFF, 0xD943C6, 0xEA7835, 0xe4e4e4 }; - public int getDarkHex() { - return DARK_HEX[ordinal()]; - } + @SideOnly(Side.CLIENT) + private static ResourceLocation iconSheet; - public int getLightHex() { - return LIGHT_HEX[ordinal()]; - } + @SideOnly(Side.CLIENT) + private static TextureAtlasSprite[] brushSprites; - public static EnumColor fromId(int id) { - if (id < 0 || id >= VALUES.length) { - return WHITE; - } - return VALUES[id]; - } + public int getDarkHex() { + return DARK_HEX[ordinal()]; + } - public static EnumColor fromDye(String dyeTag) { - for (int id = 0; id < DYES.length; id++) { - if (DYES[id].equals(dyeTag)) { - return VALUES[id]; - } - } - return null; - } + public int getLightHex() { + return LIGHT_HEX[ordinal()]; + } - public static EnumColor fromName(String name) { - for (int id = 0; id < NAMES.length; id++) { - if (NAMES[id].equals(name)) { - return VALUES[id]; - } - } - return null; - } + public static EnumColor fromId(int id) { + if (id < 0 || id >= VALUES.length) { + return WHITE; + } + return VALUES[id]; + } - public static EnumColor getRand() { - return VALUES[new Random().nextInt(VALUES.length)]; - } + public static EnumColor fromDye(String dyeTag) { + for (int id = 0; id < DYES.length; id++) { + if (DYES[id].equals(dyeTag)) { + return VALUES[id]; + } + } + return null; + } - public EnumColor getNext() { - EnumColor next = VALUES[(ordinal() + 1) % VALUES.length]; - return next; - } + public static EnumColor fromName(String name) { + for (int id = 0; id < NAMES.length; id++) { + if (NAMES[id].equals(name)) { + return VALUES[id]; + } + } + return null; + } - public EnumColor getPrevious() { - EnumColor previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length]; - return previous; - } + public static EnumColor getRand() { + return VALUES[new Random().nextInt(VALUES.length)]; + } - public EnumColor inverse() { - return EnumColor.VALUES[15 - ordinal()]; - } + public EnumColor getNext() { + EnumColor next = VALUES[(ordinal() + 1) % VALUES.length]; + return next; + } - public String getTag() { - return "color." + name().replace("_", ".").toLowerCase(Locale.ENGLISH); - } + public EnumColor getPrevious() { + EnumColor previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length]; + return previous; + } - public String getBasicTag() { - return name().replace("_", ".").toLowerCase(Locale.ENGLISH); - } + public EnumColor inverse() { + return EnumColor.VALUES[15 - ordinal()]; + } - public String getName() { - return NAMES[ordinal()]; - } + public String getTag() { + return "color." + name().replace("_", ".").toLowerCase(Locale.ENGLISH); + } - public String getLocalizedName() { - return StatCollector.translateToLocal(getTag()); - } + public String getBasicTag() { + return name().replace("_", ".").toLowerCase(Locale.ENGLISH); + } - public String getDye() { - return DYES[ordinal()]; - } + @Override + public String getName() { + return NAMES[ordinal()]; + } - @Override - public String toString() { - String s = name().replace("_", " "); - String[] words = s.split(" "); - StringBuilder b = new StringBuilder(); - for (String word : words) { - b.append(word.charAt(0)).append(word.substring(1).toLowerCase(Locale.ENGLISH)).append(" "); - } - return b.toString().trim(); - } + public String getLocalizedName() { + return StatCollector.translateToLocal(getTag()); + } - public static void setIconArray(IIcon[] icons) { - brushIcons = icons; - } + public String getDye() { + return DYES[ordinal()]; + } - @SideOnly(Side.CLIENT) - public IIcon getIcon() { - return brushIcons [ordinal()]; - } + @Override + public String toString() { + String s = name().replace("_", " "); + String[] words = s.split(" "); + StringBuilder b = new StringBuilder(); + for (String word : words) { + b.append(word.charAt(0)).append(word.substring(1).toLowerCase(Locale.ENGLISH)).append(" "); + } + return b.toString().trim(); + } + + @SideOnly(Side.CLIENT) + public static void registerSprites(TextureAtlasSprite[] sprites) { + brushSprites = sprites; + } + + @SideOnly(Side.CLIENT) + public TextureAtlasSprite getSprite() { + return brushSprites[ordinal()]; + } } diff --git a/src/api/java/buildcraft/api/core/EnumPipePart.java b/src/api/java/buildcraft/api/core/EnumPipePart.java new file mode 100644 index 000000000..f3ea8d6fb --- /dev/null +++ b/src/api/java/buildcraft/api/core/EnumPipePart.java @@ -0,0 +1,118 @@ +package buildcraft.api.core; + +import java.util.Locale; +import java.util.Map; + +import com.google.common.collect.Maps; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTBase.NBTPrimitive; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.IStringSerializable; + +import io.netty.buffer.ByteBuf; + +public enum EnumPipePart implements IStringSerializable,INetworkLoadable_BC8 { + DOWN(EnumFacing.DOWN), + UP(EnumFacing.UP), + NORTH(EnumFacing.NORTH), + SOUTH(EnumFacing.SOUTH), + WEST(EnumFacing.WEST), + EAST(EnumFacing.EAST), + /** CENTER, UNKNOWN and ALL are all valid uses of this constant. */ + CENTER(null); + + private static final Map facingMap = Maps.newEnumMap(EnumFacing.class); + private static final Map nameMap = Maps.newHashMap(); + private static final int MAX_VALUES = values().length; + + public final EnumFacing face; + + static { + for (EnumPipePart part : values()) { + nameMap.put(part.name(), part); + if (part.face != null) facingMap.put(part.face, part); + } + } + + public static EnumPipePart fromFacing(EnumFacing face) { + if (face == null) return EnumPipePart.CENTER; + return facingMap.get(face); + } + + public static EnumPipePart[] validFaces() { + return new EnumPipePart[] { DOWN, UP, NORTH, SOUTH, WEST, EAST }; + } + + public static EnumPipePart fromMeta(int meta) { + if (meta < 0 || meta >= MAX_VALUES) return EnumPipePart.CENTER; + return values()[meta]; + } + + private EnumPipePart(EnumFacing face) { + this.face = face; + } + + public int getIndex() { + if (face == null) return 6; + return face.getIndex(); + } + + @Override + public String getName() { + return name().toLowerCase(Locale.ROOT); + } + + public EnumPipePart next() { + switch (this) { + case DOWN: + return EAST; + case EAST: + return NORTH; + case NORTH: + return SOUTH; + case SOUTH: + return UP; + case UP: + return WEST; + case WEST: + return DOWN; + default: + return DOWN; + } + } + + public EnumPipePart opposite() { + if (this == CENTER) return CENTER; + return fromFacing(face.getOpposite()); + } + + public static EnumPipePart readFromNBT(NBTBase base) { + if (base == null) return CENTER; + if (base instanceof NBTTagString) { + NBTTagString nbtString = (NBTTagString) base; + String string = nbtString.getString(); + return nameMap.containsKey(string) ? nameMap.get(string) : CENTER; + } else { + byte ord = ((NBTPrimitive) base).getByte(); + if (ord < 0 || ord > 6) return CENTER; + return values()[ord]; + } + } + + public NBTBase writeToNBT() { + return new NBTTagString(name()); + } + + @Override + public EnumPipePart readFromByteBuf(ByteBuf buf) { + byte ord = buf.readByte(); + return fromMeta(ord); + } + + @Override + public void writeToByteBuf(ByteBuf buf) { + buf.writeByte(ordinal()); + } +} diff --git a/src/api/java/buildcraft/api/core/IAreaProvider.java b/src/api/java/buildcraft/api/core/IAreaProvider.java index 4abcf6e95..e504694ba 100644 --- a/src/api/java/buildcraft/api/core/IAreaProvider.java +++ b/src/api/java/buildcraft/api/core/IAreaProvider.java @@ -1,31 +1,17 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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; -/** - * To be implemented by TileEntities able to provide a square area on the world, typically BuildCraft markers. - */ +import net.minecraft.util.BlockPos; + +/** To be implemented by TileEntities able to provide a square area on the world, typically BuildCraft markers. */ public interface IAreaProvider { - int xMin(); + BlockPos min(); - int yMin(); + BlockPos max(); - int zMin(); - - int xMax(); - - int yMax(); - - int zMax(); - - /** - * Remove from the world all objects used to define the area. - */ - void removeFromWorld(); + /** 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 e1e6f7d80..d7c11f4f4 100644 --- a/src/api/java/buildcraft/api/core/IBox.java +++ b/src/api/java/buildcraft/api/core/IBox.java @@ -1,23 +1,19 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.util.BlockPos; + public interface IBox extends IZone { + IBox expand(int amount); - IBox expand(int amount); + IBox contract(int amount); - IBox contract(int amount); + BlockPos min(); - Position pMin(); - - Position pMax(); - - void createLaserData(); + BlockPos max(); + void createLaserData(); } diff --git a/src/api/java/buildcraft/api/core/IBuildCraftMod.java b/src/api/java/buildcraft/api/core/IBuildCraftMod.java new file mode 100644 index 000000000..c287088b1 --- /dev/null +++ b/src/api/java/buildcraft/api/core/IBuildCraftMod.java @@ -0,0 +1,7 @@ +package buildcraft.api.core; + +import net.minecraftforge.common.config.Property; + +public interface IBuildCraftMod { + Property getOption(String name); +} diff --git a/src/api/java/buildcraft/api/core/ICoreProxy.java b/src/api/java/buildcraft/api/core/ICoreProxy.java index 272faebfd..fc10bc092 100755 --- a/src/api/java/buildcraft/api/core/ICoreProxy.java +++ b/src/api/java/buildcraft/api/core/ICoreProxy.java @@ -1,11 +1,7 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.ref.WeakReference; @@ -14,5 +10,5 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.WorldServer; public interface ICoreProxy { - WeakReference getBuildCraftPlayer(WorldServer world); + WeakReference getBuildCraftPlayer(WorldServer world); } diff --git a/src/api/java/buildcraft/api/core/IIconProvider.java b/src/api/java/buildcraft/api/core/IIconProvider.java index fa8657e64..418c08a00 100644 --- a/src/api/java/buildcraft/api/core/IIconProvider.java +++ b/src/api/java/buildcraft/api/core/IIconProvider.java @@ -1,31 +1,13 @@ -/** - * 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.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; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IIconProvider { + public TextureAtlasSprite getIcon(int iconIndex); - /** - * @param iconIndex - */ - @SideOnly(Side.CLIENT) - IIcon getIcon(int iconIndex); - - /** - * A call for the provider to register its Icons. This may be called multiple times but should only be executed once per provider - * @param iconRegister - */ - @SideOnly(Side.CLIENT) - void registerIcons(IIconRegister iconRegister); - + @SideOnly(Side.CLIENT) + public void registerIcons(TextureMap iconRegister); } diff --git a/src/api/java/buildcraft/api/core/IInvSlot.java b/src/api/java/buildcraft/api/core/IInvSlot.java index ea7a7fa30..a047a2f87 100644 --- a/src/api/java/buildcraft/api/core/IInvSlot.java +++ b/src/api/java/buildcraft/api/core/IInvSlot.java @@ -1,21 +1,15 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.item.ItemStack; public interface IInvSlot { - /** - * Returns the slot number of the underlying Inventory. + /** Returns the slot number of the underlying Inventory. * - * @return the slot number - */ + * @return the slot number */ int getIndex(); boolean canPutStackInSlot(ItemStack stack); @@ -24,7 +18,7 @@ public interface IInvSlot { boolean isItemValidForSlot(ItemStack stack); - ItemStack decreaseStackInSlot(int amount); + ItemStack decreaseStackInSlot(int amount); ItemStack getStackInSlot(); diff --git a/src/api/java/buildcraft/api/core/INBTLoadable_BC8.java b/src/api/java/buildcraft/api/core/INBTLoadable_BC8.java new file mode 100644 index 000000000..8005bcf53 --- /dev/null +++ b/src/api/java/buildcraft/api/core/INBTLoadable_BC8.java @@ -0,0 +1,14 @@ +package buildcraft.api.core; + +import net.minecraft.nbt.NBTBase; + +/** @param The type that will be loaded from and saved too. This essentially allows Immutable objects to be safely + * loaded without helper methods everywhere. However you are allowed to return this if you are a mutable + * object */ +public interface INBTLoadable_BC8 { + /** @return An object that has the properties loaded. WARNIG! This might be the same object as the one this method + * was called on! (You should always replace the object you have stored with whatever this returns) */ + T readFromNBT(NBTBase nbt); + + NBTBase writeToNBT(); +} diff --git a/src/api/java/buildcraft/api/core/INBTStoreable.java b/src/api/java/buildcraft/api/core/INBTStoreable.java index 669eed33c..c34c134ac 100644 --- a/src/api/java/buildcraft/api/core/INBTStoreable.java +++ b/src/api/java/buildcraft/api/core/INBTStoreable.java @@ -2,7 +2,11 @@ package buildcraft.api.core; import net.minecraft.nbt.NBTTagCompound; +/** Use {@link INBTLoadable_BC8} instead of this, as this gives you more control over what NBT goes where, and what + * objects are allowed to do. */ +@Deprecated public interface INBTStoreable { - void readFromNBT(NBTTagCompound tag); - void writeToNBT(NBTTagCompound tag); + void readFromNBT(NBTTagCompound tag); + + void writeToNBT(NBTTagCompound tag); } diff --git a/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java b/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java new file mode 100644 index 000000000..de0f99e95 --- /dev/null +++ b/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java @@ -0,0 +1,9 @@ +package buildcraft.api.core; + +import io.netty.buffer.ByteBuf; + +public interface INetworkLoadable_BC8 { + T readFromByteBuf(ByteBuf buf); + + void writeToByteBuf(ByteBuf buf); +} diff --git a/src/api/java/buildcraft/api/core/IPathProvider.java b/src/api/java/buildcraft/api/core/IPathProvider.java index 2ff392a92..899415227 100644 --- a/src/api/java/buildcraft/api/core/IPathProvider.java +++ b/src/api/java/buildcraft/api/core/IPathProvider.java @@ -2,9 +2,14 @@ package buildcraft.api.core; import java.util.List; -/** - * To be implemented by TileEntities able to provide a path on the world, typically BuildCraft path markers. - */ +import net.minecraft.util.BlockPos; + +/** To be implemented by TileEntities able to provide a path on the world, typically BuildCraft path markers. */ public interface IPathProvider { - List getPath(); + List getPath(); + + /** + * Remove from the world all objects used to define the path. + */ + void removeFromWorld(); } diff --git a/src/api/java/buildcraft/api/core/ISerializable.java b/src/api/java/buildcraft/api/core/ISerializable.java index a7d011ebb..77d56d541 100644 --- a/src/api/java/buildcraft/api/core/ISerializable.java +++ b/src/api/java/buildcraft/api/core/ISerializable.java @@ -1,30 +1,21 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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 - */ + * 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 - */ +/** Use {@link INetworkLoadable_BC8} instead, as that gives you more control over how you use objects */ +@Deprecated public interface ISerializable { - /** - * Serializes the state to the stream - * - * @param data - */ - void writeData(ByteBuf data); + /** Serializes the state to the stream + * + * @param data */ + void writeData(ByteBuf data); - /** - * Deserializes the state from the stream - * - * @param data - */ - void readData(ByteBuf data); + /** Deserializes the state from the stream + * + * @param data */ + void readData(ByteBuf data); } diff --git a/src/api/java/buildcraft/api/core/IWorldProperty.java b/src/api/java/buildcraft/api/core/IWorldProperty.java index a55bef1fc..ba440d7d3 100755 --- a/src/api/java/buildcraft/api/core/IWorldProperty.java +++ b/src/api/java/buildcraft/api/core/IWorldProperty.java @@ -1,17 +1,14 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.util.BlockPos; import net.minecraft.world.World; public interface IWorldProperty { - boolean get(World world, int x, int y, int z); + boolean get(World world, BlockPos pos); - void clear(); + void clear(); } diff --git a/src/api/java/buildcraft/api/core/IZone.java b/src/api/java/buildcraft/api/core/IZone.java index 55ef4f80e..5d722ffe6 100755 --- a/src/api/java/buildcraft/api/core/IZone.java +++ b/src/api/java/buildcraft/api/core/IZone.java @@ -1,23 +1,26 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.Random; +import net.minecraft.util.BlockPos; +import net.minecraft.util.Vec3; + public interface IZone { + /** Returns the smallest possible distance that the index would have to be changed by in order for + * {@link #contains(Vec3)} to return true. If the position is already inside then this will return 0 */ + double distanceTo(BlockPos index); - double distanceTo(BlockIndex index); + /** Returns {@link #distanceTo(BlockPos)} but squared. Usually this will be quicker to calculate. */ + double distanceToSquared(BlockPos index); - double distanceToSquared(BlockIndex index); - - boolean contains(double x, double y, double z); - - BlockIndex getRandomBlockIndex(Random rand); + /** Returns true if the point is enclosed by this zone, such that none of the coordinates lie outside the range + * specified by this zone. */ + boolean contains(Vec3 point); + /** Gets a random position that {@link #contains(Vec3)} will return true. */ + BlockPos getRandomBlockPos(Random rand); } diff --git a/src/api/java/buildcraft/api/core/JavaTools.java b/src/api/java/buildcraft/api/core/JavaTools.java index e8dd4d898..7b7eb513c 100755 --- a/src/api/java/buildcraft/api/core/JavaTools.java +++ b/src/api/java/buildcraft/api/core/JavaTools.java @@ -1,43 +1,39 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.Arrays; 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); - return result; - } + private JavaTools() { - public static int[] concat(int[] first, int[] second) { - int[] result = Arrays.copyOf(first, first.length + second.length); - System.arraycopy(second, 0, result, first.length, second.length); - return result; - } + } - public static float[] concat(float[] first, float[] second) { - float[] result = Arrays.copyOf(first, first.length + second.length); - System.arraycopy(second, 0, result, first.length, second.length); - return result; - } + 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); + return result; + } - public static String surroundWithQuotes(String stringToSurroundWithQuotes) { - return String.format("\"%s\"", stringToSurroundWithQuotes); - } + public static int[] concat(int[] first, int[] second) { + int[] result = Arrays.copyOf(first, first.length + second.length); + System.arraycopy(second, 0, result, first.length, second.length); + return result; + } - public static String stripSurroundingQuotes(String stringToStripQuotes) { - return stringToStripQuotes.replaceAll("^\"|\"$", ""); - } + public static float[] concat(float[] first, float[] second) { + float[] result = Arrays.copyOf(first, first.length + second.length); + System.arraycopy(second, 0, result, first.length, second.length); + return result; + } + + public static String surroundWithQuotes(String stringToSurroundWithQuotes) { + return String.format("\"%s\"", stringToSurroundWithQuotes); + } + + public static String stripSurroundingQuotes(String stringToStripQuotes) { + return stringToStripQuotes.replaceAll("^\"|\"$", ""); + } } diff --git a/src/api/java/buildcraft/api/core/Position.java b/src/api/java/buildcraft/api/core/Position.java deleted file mode 100644 index 426e09f40..000000000 --- a/src/api/java/buildcraft/api/core/Position.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. - * Please check the contents of the license, which should be located - * as "LICENSE.API" in the BuildCraft source code distribution. - */ -package buildcraft.api.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 implements ISerializable { - - public double x, y, z; - public ForgeDirection orientation; - - public Position() { - x = 0; - y = 0; - z = 0; - orientation = ForgeDirection.UNKNOWN; - } - - public Position(double ci, double cj, double ck) { - x = ci; - y = cj; - z = ck; - orientation = ForgeDirection.UNKNOWN; - } - - public Position(double ci, double cj, double ck, ForgeDirection corientation) { - x = ci; - y = cj; - z = ck; - orientation = corientation; - - if (orientation == null) { - orientation = ForgeDirection.UNKNOWN; - } - } - - public Position(Position p) { - x = p.x; - y = p.y; - z = p.z; - orientation = p.orientation; - } - - public Position(NBTTagCompound nbttagcompound) { - readFromNBT(nbttagcompound); - } - - public Position(TileEntity tile) { - x = tile.xCoord; - y = tile.yCoord; - z = tile.zCoord; - orientation = ForgeDirection.UNKNOWN; - } - - public Position(BlockIndex index) { - x = index.x; - y = index.y; - z = index.z; - orientation = ForgeDirection.UNKNOWN; - } - - public void moveRight(double step) { - switch (orientation) { - case SOUTH: - x = x - step; - break; - case NORTH: - x = x + step; - break; - case EAST: - z = z + step; - break; - case WEST: - z = z - step; - break; - default: - } - } - - public void moveLeft(double step) { - moveRight(-step); - } - - public void moveForwards(double step) { - switch (orientation) { - case UP: - y = y + step; - break; - case DOWN: - y = y - step; - break; - case SOUTH: - z = z + step; - break; - case NORTH: - z = z - step; - break; - case EAST: - x = x + step; - break; - case WEST: - x = x - step; - break; - default: - } - } - - public void moveBackwards(double step) { - moveForwards(-step); - } - - public void moveUp(double step) { - switch (orientation) { - case SOUTH: - case NORTH: - case EAST: - case WEST: - y = y + step; - break; - default: - } - - } - - public void moveDown(double step) { - moveUp(-step); - } - - public void writeToNBT(NBTTagCompound nbttagcompound) { - if (orientation == null) { - orientation = ForgeDirection.UNKNOWN; - } - - nbttagcompound.setDouble("i", x); - nbttagcompound.setDouble("j", y); - nbttagcompound.setDouble("k", z); - nbttagcompound.setByte("orientation", (byte) orientation.ordinal()); - } - - public void readFromNBT(NBTTagCompound nbttagcompound) { - x = nbttagcompound.getDouble("i"); - y = nbttagcompound.getDouble("j"); - z = nbttagcompound.getDouble("k"); - orientation = ForgeDirection.values() [nbttagcompound.getByte("orientation")]; - } - - @Override - public String toString() { - return "{" + x + ", " + y + ", " + z + "}"; - } - - public Position min(Position p) { - return new Position(p.x > x ? x : p.x, p.y > y ? y : p.y, p.z > z ? z : p.z); - } - - public Position max(Position p) { - return new Position(p.x < x ? x : p.x, p.y < y ? y : p.y, p.z < z ? z : p.z); - } - - public boolean isClose(Position newPosition, float f) { - double dx = x - newPosition.x; - double dy = y - newPosition.y; - double dz = z - newPosition.z; - - double sqrDis = dx * dx + dy * dy + dz * dz; - - 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 3e56ee989..9390d87e7 100644 --- a/src/api/java/buildcraft/api/core/SafeTimeTracker.java +++ b/src/api/java/buildcraft/api/core/SafeTimeTracker.java @@ -1,85 +1,68 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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 class SafeTimeTracker { - private long lastMark = Long.MIN_VALUE; - private long duration = -1; - private long randomRange = 0; - private long lastRandomDelay = 0; - private long internalDelay = 1; + private long lastMark = Long.MIN_VALUE; + private long duration = -1; + private long randomRange = 0; + private long lastRandomDelay = 0; + private long internalDelay = 1; - /** - * @deprecated should use constructors with parameters instead - */ - public SafeTimeTracker () { + /** Only use this if the delay time changes (say, if you use this to determine when a refining should be complete */ + public SafeTimeTracker() { - } + } - public SafeTimeTracker (long delay) { - internalDelay = delay; - } + public SafeTimeTracker(long delay) { + internalDelay = delay; + } - /** - * In many situations, it is a bad idea to have all objects of the same - * kind to be waiting for the exact same amount of time, as that can lead - * to some situation where they're all synchronized and got to work all - * at the same time. When created with a random range, the mark that is set - * when reaching the expect delay will be added with a random number - * between [0, range[, meaning that the event will take between 0 and range - * more tick to run. - */ - public SafeTimeTracker (long delay, long random) { - internalDelay = delay; - randomRange = random; - } + /** In many situations, it is a bad idea to have all objects of the same kind to be waiting for the exact same + * amount of time, as that can lead to some situation where they're all synchronized and got to work all at the same + * time. When created with a random range, the mark that is set when reaching the expect delay will be added with a + * random number between [0, range[, meaning that the event will take between 0 and range more tick to run. */ + public SafeTimeTracker(long delay, long random) { + internalDelay = delay; + randomRange = random; + } - public boolean markTimeIfDelay(World world) { - return markTimeIfDelay(world, internalDelay); - } + public boolean markTimeIfDelay(World world) { + return markTimeIfDelay(world, internalDelay); + } - /** - * Return true if a given delay has passed since last time marked was called - * successfully. - * - * @deprecated should use the constructor with a delay instead, and call - * this function without a parameter - */ - public boolean markTimeIfDelay(World world, long delay) { - if (world == null) { - return false; - } + /** Return true if a given delay has passed since last time marked was called successfully. */ + public boolean markTimeIfDelay(World world, long delay) { + if (world == null) { + return false; + } - long currentTime = world.getTotalWorldTime(); + long currentTime = world.getTotalWorldTime(); - if (currentTime < lastMark) { - lastMark = currentTime; - return false; - } else if (lastMark + delay + lastRandomDelay <= currentTime) { - duration = currentTime - lastMark; - lastMark = currentTime; - lastRandomDelay = (int) (Math.random() * randomRange); + if (currentTime < lastMark) { + lastMark = currentTime; + return false; + } else if (lastMark + delay + lastRandomDelay <= currentTime) { + duration = currentTime - lastMark; + lastMark = currentTime; + lastRandomDelay = (int) (Math.random() * randomRange); - return true; - } else { - return false; - } - } + return true; + } else { + return false; + } + } - public long durationOfLastDelay() { - return duration > 0 ? duration : 0; - } + public long durationOfLastDelay() { + return duration > 0 ? duration : 0; + } - public void markTime(World world) { - lastMark = world.getTotalWorldTime(); - } -} \ No newline at end of file + public void markTime(World world) { + lastMark = world.getTotalWorldTime(); + } +} diff --git a/src/api/java/buildcraft/api/core/StackKey.java b/src/api/java/buildcraft/api/core/StackKey.java index 776aaafdf..13a8e8989 100644 --- a/src/api/java/buildcraft/api/core/StackKey.java +++ b/src/api/java/buildcraft/api/core/StackKey.java @@ -1,11 +1,7 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.block.Block; @@ -15,120 +11,115 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; -/** - * This class is used whenever stacks needs to be stored as keys. - */ +/** This class is used whenever stacks needs to be stored as keys. */ public final class StackKey { - public final ItemStack stack; - public final FluidStack fluidStack; + public final ItemStack stack; + public final FluidStack fluidStack; - public StackKey(FluidStack fluidStack) { - this(null, fluidStack); - } + public StackKey(FluidStack fluidStack) { + this(null, fluidStack); + } - public StackKey(ItemStack stack) { - this(stack, null); - } + public StackKey(ItemStack stack) { + this(stack, null); + } - public StackKey(ItemStack stack, FluidStack fluidStack) { - this.stack = stack; - this.fluidStack = fluidStack; - } + public StackKey(ItemStack stack, FluidStack fluidStack) { + this.stack = stack; + this.fluidStack = fluidStack; + } - public static StackKey stack(Item item, int amount, int damage) { - return new StackKey(new ItemStack(item, amount, damage)); - } + public static StackKey stack(Item item, int amount, int damage) { + return new StackKey(new ItemStack(item, amount, damage)); + } - public static StackKey stack(Block block, int amount, int damage) { - return new StackKey(new ItemStack(block, amount, damage)); - } + public static StackKey stack(Block block, int amount, int damage) { + return new StackKey(new ItemStack(block, amount, damage)); + } - public static StackKey stack(Item item) { - return new StackKey(new ItemStack(item, 1, 0)); - } + public static StackKey stack(Item item) { + return new StackKey(new ItemStack(item, 1, 0)); + } - public static StackKey stack(Block block) { - return new StackKey(new ItemStack(block, 1, 0)); - } + public static StackKey stack(Block block) { + return new StackKey(new ItemStack(block, 1, 0)); + } - public static StackKey stack(ItemStack itemStack) { - return new StackKey(itemStack); - } + public static StackKey stack(ItemStack itemStack) { + return new StackKey(itemStack); + } - public static StackKey fluid(Fluid fluid, int amount) { - return new StackKey(new FluidStack(fluid, amount)); - } + public static StackKey fluid(Fluid fluid, int amount) { + return new StackKey(new FluidStack(fluid, amount)); + } - public static StackKey fluid(Fluid fluid) { - return new StackKey(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME)); - } + public static StackKey fluid(Fluid fluid) { + return new StackKey(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME)); + } - public static StackKey fluid(FluidStack fluidStack) { - return new StackKey(fluidStack); - } + public static StackKey fluid(FluidStack fluidStack) { + return new StackKey(fluidStack); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || o.getClass() != StackKey.class) { - return false; - } - StackKey k = (StackKey) o; - if ((stack == null ^ k.stack == null) || (fluidStack == null ^ k.fluidStack == null)) { - return false; - } - if (stack != null) { - if (stack.getItem() != k.stack.getItem() || - stack.getHasSubtypes() && stack.getItemDamage() != k.stack.getItemDamage() || - !objectsEqual(stack.getTagCompound(), k.stack.getTagCompound())) { - return false; - } - } - if (fluidStack != null) { - if (fluidStack.getFluid().getID() != k.fluidStack.getFluid().getID() || - fluidStack.amount != k.fluidStack.amount || - !objectsEqual(fluidStack.tag, k.fluidStack.tag)) { - return false; - } - } - return true; - } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || o.getClass() != StackKey.class) { + return false; + } + StackKey k = (StackKey) o; + if ((stack == null ^ k.stack == null) || (fluidStack == null ^ k.fluidStack == null)) { + return false; + } + if (stack != null) { + if (stack.getItem() != k.stack.getItem() || stack.getHasSubtypes() && stack.getItemDamage() != k.stack.getItemDamage() || !objectsEqual( + stack.getTagCompound(), k.stack.getTagCompound())) { + return false; + } + } + if (fluidStack != null) { + if (fluidStack.getFluid().getID() != k.fluidStack.getFluid().getID() || fluidStack.amount != k.fluidStack.amount || !objectsEqual( + fluidStack.tag, k.fluidStack.tag)) { + return false; + } + } + return true; + } - @Override - public int hashCode() { - int result = 7; - if (stack != null) { - result = 31 * result + stack.getItem().hashCode(); - result = 31 * result + stack.getItemDamage(); - result = 31 * result + objectHashCode(stack.getTagCompound()); - } - result = 31 * result + 7; - if (fluidStack != null) { - result = 31 * result + fluidStack.getFluid().getID(); - result = 31 * result + fluidStack.amount; - result = 31 * result + objectHashCode(fluidStack.tag); - } - return result; - } + @Override + public int hashCode() { + int result = 7; + if (stack != null) { + result = 31 * result + stack.getItem().hashCode(); + result = 31 * result + stack.getItemDamage(); + result = 31 * result + objectHashCode(stack.getTagCompound()); + } + result = 31 * result + 7; + if (fluidStack != null) { + result = 31 * result + fluidStack.getFluid().getID(); + result = 31 * result + fluidStack.amount; + result = 31 * result + objectHashCode(fluidStack.tag); + } + return result; + } - private boolean objectsEqual(Object o1, Object o2) { - if (o1 == null && o2 == null) { - return true; - } else if (o1 == null || o2 == null) { - return false; - } else { - return o1.equals(o2); - } - } - - private int objectHashCode(Object o) { - return o != null ? o.hashCode() : 0; - } + private boolean objectsEqual(Object o1, Object o2) { + if (o1 == null && o2 == null) { + return true; + } else if (o1 == null || o2 == null) { + return false; + } else { + return o1.equals(o2); + } + } - public StackKey copy() { - return new StackKey(stack != null ? stack.copy() : null, - fluidStack != null ? fluidStack.copy() : null); - } + private int objectHashCode(Object o) { + return o != null ? o.hashCode() : 0; + } + + public StackKey copy() { + return new StackKey(stack != null ? stack.copy() : null, fluidStack != null ? fluidStack.copy() : null); + } } diff --git a/src/api/java/buildcraft/api/core/package-info.java b/src/api/java/buildcraft/api/core/package-info.java index 0fc4db4cc..12cc9ea13 100644 --- a/src/api/java/buildcraft/api/core/package-info.java +++ b/src/api/java/buildcraft/api/core/package-info.java @@ -1,12 +1,10 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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.5", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core") +@API(apiVersion = "2.0", owner = "BuildCraft|Core", provides = "BuildCraftAPI|core") package buildcraft.api.core; -import cpw.mods.fml.common.API; +import net.minecraftforge.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 index b800c0851..ea4b1f444 100644 --- a/src/api/java/buildcraft/api/core/render/ICullable.java +++ b/src/api/java/buildcraft/api/core/render/ICullable.java @@ -1,32 +1,27 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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 - */ + * 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.util.BlockPos; +import net.minecraft.util.EnumFacing; 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 - */ +/* 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); - + // 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(EnumFacing side, boolean render); + + void setRenderAllSides(); + + boolean shouldSideBeRendered(IBlockAccess blockAccess, BlockPos pos, 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 index 8161d6b93..e401b3e2e 100644 --- a/src/api/java/buildcraft/api/core/render/ITextureStateManager.java +++ b/src/api/java/buildcraft/api/core/render/ITextureStateManager.java @@ -1,7 +1,7 @@ package buildcraft.api.core.render; -import net.minecraft.util.IIcon; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; public interface ITextureStateManager { - void set(IIcon icon); + void set(TextureAtlasSprite icon); } diff --git a/src/api/java/buildcraft/api/core/render/ITextureStates.java b/src/api/java/buildcraft/api/core/render/ITextureStates.java index 835caf7fe..593534f6c 100644 --- a/src/api/java/buildcraft/api/core/render/ITextureStates.java +++ b/src/api/java/buildcraft/api/core/render/ITextureStates.java @@ -1,22 +1,18 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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 - */ + * 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; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; public interface ITextureStates extends ICullable { - ITextureStateManager getTextureState(); - - IIcon getIcon(int side, int meta); - - Block getBlock(); - + ITextureStateManager getTextureState(); + + TextureAtlasSprite getIcon(int side, int meta); + + Block getBlock(); + } diff --git a/src/api/java/buildcraft/api/gates/GateExpansionController.java b/src/api/java/buildcraft/api/gates/GateExpansionController.java index e37ae20a5..749de86f7 100644 --- a/src/api/java/buildcraft/api/gates/GateExpansionController.java +++ b/src/api/java/buildcraft/api/gates/GateExpansionController.java @@ -1,11 +1,7 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.gates; import java.util.List; @@ -20,45 +16,39 @@ import buildcraft.api.statements.ITriggerInternal; public abstract class GateExpansionController { - public final IGateExpansion type; - public final TileEntity pipeTile; + public final IGateExpansion type; + public final TileEntity pipeTile; - public GateExpansionController(IGateExpansion type, TileEntity pipeTile) { - this.pipeTile = pipeTile; - this.type = type; - } + public GateExpansionController(IGateExpansion type, TileEntity pipeTile) { + this.pipeTile = pipeTile; + this.type = type; + } - public IGateExpansion getType() { - return type; - } + public IGateExpansion getType() { + return type; + } - public boolean isActive() { - return false; - } + public boolean isActive() { + return false; + } - public void tick(IGate gate) { - } + public void tick(IGate gate) {} - public void startResolution() { - } + public void startResolution() {} - public boolean resolveAction(IStatement action, int count) { - return false; - } + public boolean resolveAction(IStatement action, int count) { + return false; + } - public boolean isTriggerActive(IStatement trigger, IStatementParameter[] parameters) { - return false; - } + public boolean isTriggerActive(IStatement trigger, IStatementParameter[] parameters) { + return false; + } - public void addTriggers(List list) { - } + public void addTriggers(List list) {} - public void addActions(List list) { - } + public void addActions(List list) {} - public void writeToNBT(NBTTagCompound nbt) { - } + public void writeToNBT(NBTTagCompound nbt) {} - public void readFromNBT(NBTTagCompound nbt) { - } + public void readFromNBT(NBTTagCompound nbt) {} } diff --git a/src/api/java/buildcraft/api/gates/GateExpansions.java b/src/api/java/buildcraft/api/gates/GateExpansions.java index bc667f58e..b1e600371 100644 --- a/src/api/java/buildcraft/api/gates/GateExpansions.java +++ b/src/api/java/buildcraft/api/gates/GateExpansions.java @@ -1,11 +1,7 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.gates; import java.util.ArrayList; @@ -19,48 +15,47 @@ 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 static final Map expansions = new HashMap(); + private static final ArrayList expansionIDs = new ArrayList(); + private static final Map recipes = HashBiMap.create(); - private GateExpansions() { - } + private GateExpansions() {} - public static void registerExpansion(IGateExpansion expansion) { - registerExpansion(expansion.getUniqueIdentifier(), expansion); - } + public static void registerExpansion(IGateExpansion expansion) { + registerExpansion(expansion.getUniqueIdentifier(), expansion); + } - public static void registerExpansion(String identifier, IGateExpansion expansion) { - expansions.put(identifier, expansion); - expansionIDs.add(expansion); - } + public static void registerExpansion(String identifier, IGateExpansion expansion) { + expansions.put(identifier, expansion); + expansionIDs.add(expansion); + } - public static void registerExpansion(IGateExpansion expansion, ItemStack addedRecipe) { - registerExpansion(expansion.getUniqueIdentifier(), expansion); - recipes.put(expansion, addedRecipe); - } + public static void registerExpansion(IGateExpansion expansion, ItemStack addedRecipe) { + registerExpansion(expansion.getUniqueIdentifier(), expansion); + recipes.put(expansion, addedRecipe); + } - public static IGateExpansion getExpansion(String identifier) { - return expansions.get(identifier); - } + public static IGateExpansion getExpansion(String identifier) { + return expansions.get(identifier); + } - public static Set getExpansions() { - Set set = new HashSet(); - set.addAll(expansionIDs); - return set; - } + public static Set getExpansions() { + Set set = new HashSet(); + set.addAll(expansionIDs); + return set; + } - public static Map getRecipesForPostInit() { - return recipes; - } - - // The code below is used by networking. - - public static IGateExpansion getExpansionByID(int id) { - return expansionIDs.get(id); - } - - public static int getExpansionID(IGateExpansion expansion) { - return expansionIDs.indexOf(expansion); - } + public static Map getRecipesForPostInit() { + return recipes; + } + + // The code below is used by networking. + + public static IGateExpansion getExpansionByID(int id) { + return expansionIDs.get(id); + } + + public static int getExpansionID(IGateExpansion expansion) { + return expansionIDs.indexOf(expansion); + } } diff --git a/src/api/java/buildcraft/api/gates/IGate.java b/src/api/java/buildcraft/api/gates/IGate.java index 6127caadb..df2364937 100644 --- a/src/api/java/buildcraft/api/gates/IGate.java +++ b/src/api/java/buildcraft/api/gates/IGate.java @@ -1,11 +1,7 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.gates; import java.util.List; @@ -17,16 +13,18 @@ import buildcraft.api.statements.containers.ISidedStatementContainer; import buildcraft.api.transport.IPipe; public interface IGate extends ISidedStatementContainer { - @Deprecated - void setPulsing(boolean pulse); + @Deprecated + void setPulsing(boolean pulse); - IPipe getPipe(); + IPipe getPipe(); - List getTriggers(); - List getActions(); + List getTriggers(); - List getActiveActions(); + List getActions(); - List getTriggerParameters(int index); - List getActionParameters(int index); + 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 ad61fad66..f197c0ca7 100644 --- a/src/api/java/buildcraft/api/gates/IGateExpansion.java +++ b/src/api/java/buildcraft/api/gates/IGateExpansion.java @@ -1,30 +1,34 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.gates; -import net.minecraft.client.renderer.texture.IIconRegister; +import java.util.List; + +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IGateExpansion { - String getUniqueIdentifier(); + String getUniqueIdentifier(); - String getDisplayName(); + String getDisplayName(); - GateExpansionController makeController(TileEntity pipeTile); + GateExpansionController makeController(TileEntity pipeTile); - void registerBlockOverlay(IIconRegister iconRegister); + @SideOnly(Side.CLIENT) + void textureStitch(TextureMap map); - void registerItemOverlay(IIconRegister iconRegister); + @SideOnly(Side.CLIENT) + IGateStaticRenderState getRenderState(); - IIcon getOverlayBlock(); - - IIcon getOverlayItem(); + public interface IGateStaticRenderState { + List bake(VertexFormat format); + } } diff --git a/src/api/java/buildcraft/api/gates/package-info.java b/src/api/java/buildcraft/api/gates/package-info.java index 83cb2a2c4..b86ad48bd 100644 --- a/src/api/java/buildcraft/api/gates/package-info.java +++ b/src/api/java/buildcraft/api/gates/package-info.java @@ -1,12 +1,8 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ @API(apiVersion = "4.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates") package buildcraft.api.gates; -import cpw.mods.fml.common.API; +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/statements/ActionState.java b/src/api/java/buildcraft/api/statements/ActionState.java index 72e4d58ba..15f547c07 100755 --- a/src/api/java/buildcraft/api/statements/ActionState.java +++ b/src/api/java/buildcraft/api/statements/ActionState.java @@ -1,11 +1,7 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; public class ActionState { diff --git a/src/api/java/buildcraft/api/statements/IActionExternal.java b/src/api/java/buildcraft/api/statements/IActionExternal.java index 1d6e2eb54..21ffc92c4 100644 --- a/src/api/java/buildcraft/api/statements/IActionExternal.java +++ b/src/api/java/buildcraft/api/statements/IActionExternal.java @@ -1,16 +1,12 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; public interface IActionExternal extends IStatement { - void actionActivate(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters); + void actionActivate(TileEntity target, EnumFacing 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 6a019a459..c3c77a4b1 100644 --- a/src/api/java/buildcraft/api/statements/IActionInternal.java +++ b/src/api/java/buildcraft/api/statements/IActionInternal.java @@ -1,15 +1,11 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; public interface IActionInternal extends IStatement { - void actionActivate(IStatementContainer source, IStatementParameter[] parameters); - + void actionActivate(IStatementContainer source, IStatementParameter[] parameters); + } diff --git a/src/api/java/buildcraft/api/statements/IActionProvider.java b/src/api/java/buildcraft/api/statements/IActionProvider.java index 147d4d39d..63625b05a 100644 --- a/src/api/java/buildcraft/api/statements/IActionProvider.java +++ b/src/api/java/buildcraft/api/statements/IActionProvider.java @@ -1,28 +1,19 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; import java.util.Collection; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; public interface IActionProvider { - /** - * Returns the list of actions that are available from the statement container holding the - * gate. - */ - Collection getInternalActions(IStatementContainer container); + /** Returns the list of actions that are available from the statement container holding the gate. */ + Collection getInternalActions(IStatementContainer container); - /** - * Returns the list of actions available to a gate next to the given block. - */ - Collection getExternalActions(ForgeDirection side, TileEntity tile); + /** Returns the list of actions available to a gate next to the given block. */ + Collection getExternalActions(EnumFacing side, TileEntity tile); } diff --git a/src/api/java/buildcraft/api/statements/IActionReceptor.java b/src/api/java/buildcraft/api/statements/IActionReceptor.java index db7cea027..34155b86a 100644 --- a/src/api/java/buildcraft/api/statements/IActionReceptor.java +++ b/src/api/java/buildcraft/api/statements/IActionReceptor.java @@ -1,13 +1,9 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; public interface IActionReceptor { - void actionActivated(IStatement statement, IStatementParameter[] parameters); + void actionActivated(IStatement statement, IStatementParameter[] parameters); } diff --git a/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java b/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java index c9c7db8ed..cb2dc78e1 100644 --- a/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java +++ b/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java @@ -1,16 +1,13 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; import java.util.List; public interface IOverrideDefaultStatements { - List overrideTriggers(); - List overrideActions(); + List overrideTriggers(); + + List overrideActions(); } diff --git a/src/api/java/buildcraft/api/statements/IStatement.java b/src/api/java/buildcraft/api/statements/IStatement.java index e466efd2b..dc0254332 100644 --- a/src/api/java/buildcraft/api/statements/IStatement.java +++ b/src/api/java/buildcraft/api/statements/IStatement.java @@ -1,56 +1,36 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IStatement { - /** - * Every statement needs a unique tag, it should be in the format of - * "<modid>:<name>. - * - * @return the unique id - */ - String getUniqueTag(); + /** Every statement needs a unique tag, it should be in the format of "<modid>:<name>. + * + * @return the unique id */ + String getUniqueTag(); - @SideOnly(Side.CLIENT) - IIcon getIcon(); + /** Return the maximum number of parameter this statement can have, 0 if none. */ + int maxParameters(); - @SideOnly(Side.CLIENT) - void registerIcons(IIconRegister iconRegister); + /** Return the minimum number of parameter this statement can have, 0 if none. */ + int minParameters(); - /** - * Return the maximum number of parameter this statement can have, 0 if none. - */ - int maxParameters(); + /** Return the statement description in the UI */ + String getDescription(); - /** - * Return the minimum number of parameter this statement can have, 0 if none. - */ - int minParameters(); + /** Create parameters for the statement. */ + IStatementParameter createParameter(int index); - /** - * Return the statement description in the UI - */ - String getDescription(); + /** This returns the statement after a left rotation. Used in particular in blueprints orientation. */ + IStatement rotateLeft(); - /** - * Create parameters for the statement. - */ - IStatementParameter createParameter(int index); - - /** - * This returns the statement after a left rotation. Used in particular in - * blueprints orientation. - */ - IStatement rotateLeft(); + /** This should return the icon for this statement, suitable for rending directly into a GUI. This should refer to a + * texture on the map block texture map. */ + @SideOnly(Side.CLIENT) + TextureAtlasSprite getGuiSprite(); } diff --git a/src/api/java/buildcraft/api/statements/IStatementContainer.java b/src/api/java/buildcraft/api/statements/IStatementContainer.java index 43a4f51ef..f4a73465f 100644 --- a/src/api/java/buildcraft/api/statements/IStatementContainer.java +++ b/src/api/java/buildcraft/api/statements/IStatementContainer.java @@ -1,19 +1,12 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; import net.minecraft.tileentity.TileEntity; -/** - * This is implemented by objects containing Statements, such as - * Gates and TileEntities. - */ +/** This is implemented by objects containing Statements, such as Gates and TileEntities. */ public interface IStatementContainer { - TileEntity getTile(); + TileEntity getTile(); } diff --git a/src/api/java/buildcraft/api/statements/IStatementParameter.java b/src/api/java/buildcraft/api/statements/IStatementParameter.java index 9a9e397cd..7ef29c793 100755 --- a/src/api/java/buildcraft/api/statements/IStatementParameter.java +++ b/src/api/java/buildcraft/api/statements/IStatementParameter.java @@ -1,59 +1,36 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.client.renderer.texture.TextureAtlasSprite; 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; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public interface IStatementParameter { - - /** - * Every parameter needs a unique tag, it should be in the format of - * "<modi>:<name>". - * - * @return the unique id - */ - String getUniqueTag(); - - @SideOnly(Side.CLIENT) - IIcon getIcon(); - ItemStack getItemStack(); + /** Every parameter needs a unique tag, it should be in the format of "<modid>:<name>". + * + * @return the unique id */ + String getUniqueTag(); - /** - * Something that is initially unintuitive: you HAVE to - * keep your icons as static variables, due to the fact - * that every IStatementParameter is instantiated upon creation, - * in opposition to IStatements which are singletons (due to the - * fact that they, unlike Parameters, store no additional data) - */ - @SideOnly(Side.CLIENT) - void registerIcons(IIconRegister iconRegister); - - /** - * Return the parameter description in the UI - */ - String getDescription(); + @SideOnly(Side.CLIENT) + TextureAtlasSprite getIcon(); - void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse); + ItemStack getItemStack(); - void readFromNBT(NBTTagCompound compound); + /** Return the parameter description in the UI */ + String getDescription(); - void writeToNBT(NBTTagCompound compound); + void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse); - /** - * This returns the parameter after a left rotation. Used in particular in - * blueprints orientation. - */ - IStatementParameter rotateLeft(); + void readFromNBT(NBTTagCompound compound); + + void writeToNBT(NBTTagCompound compound); + + /** This returns the parameter after a left rotation. Used in particular in blueprints orientation. */ + IStatementParameter rotateLeft(); } diff --git a/src/api/java/buildcraft/api/statements/ITriggerExternal.java b/src/api/java/buildcraft/api/statements/ITriggerExternal.java index 532f67a5f..3db589cbc 100644 --- a/src/api/java/buildcraft/api/statements/ITriggerExternal.java +++ b/src/api/java/buildcraft/api/statements/ITriggerExternal.java @@ -1,18 +1,14 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; public interface ITriggerExternal extends IStatement { - boolean isTriggerActive(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters); - + boolean isTriggerActive(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); + } diff --git a/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java b/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java index 7103c06ac..b8628deec 100644 --- a/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java +++ b/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java @@ -1,17 +1,16 @@ package buildcraft.api.statements; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; -/** - * This interface can be used by tiles to override external trigger - * behaviour. +/** This interface can be used by tiles to override external trigger behaviour. * - * Please use wisely. - */ + * Please use wisely. */ public interface ITriggerExternalOverride { - public enum Result { - TRUE, FALSE, IGNORE - } + public enum Result { + TRUE, + FALSE, + IGNORE + } - Result override(ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters); + Result override(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); } diff --git a/src/api/java/buildcraft/api/statements/ITriggerInternal.java b/src/api/java/buildcraft/api/statements/ITriggerInternal.java index a4241d3da..610a5728b 100755 --- a/src/api/java/buildcraft/api/statements/ITriggerInternal.java +++ b/src/api/java/buildcraft/api/statements/ITriggerInternal.java @@ -1,15 +1,11 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; public interface ITriggerInternal extends IStatement { - boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters); + boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters); } diff --git a/src/api/java/buildcraft/api/statements/ITriggerProvider.java b/src/api/java/buildcraft/api/statements/ITriggerProvider.java index 548f107bf..d6ffbd42f 100644 --- a/src/api/java/buildcraft/api/statements/ITriggerProvider.java +++ b/src/api/java/buildcraft/api/statements/ITriggerProvider.java @@ -1,28 +1,20 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; import java.util.Collection; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; public interface ITriggerProvider { - /** - * Returns the list of triggers that are available from the object holding the gate. - */ - Collection getInternalTriggers(IStatementContainer container); + /** Returns the list of triggers that are available from the object holding the gate. */ + Collection getInternalTriggers(IStatementContainer container); - /** - * Returns the list of triggers available to a gate next to the given block. - */ - Collection getExternalTriggers(ForgeDirection side, TileEntity tile); + /** Returns the list of triggers available to a gate next to the given block. */ + Collection getExternalTriggers(EnumFacing side, TileEntity tile); } diff --git a/src/api/java/buildcraft/api/statements/StatementManager.java b/src/api/java/buildcraft/api/statements/StatementManager.java index fec7d9510..419ee1d07 100644 --- a/src/api/java/buildcraft/api/statements/StatementManager.java +++ b/src/api/java/buildcraft/api/statements/StatementManager.java @@ -1,11 +1,7 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; import java.util.Collection; @@ -14,169 +10,168 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; + +import buildcraft.api.core.BCLog; public final class StatementManager { - public static Map statements = new HashMap(); - public static Map> parameters = new HashMap>(); - private static List triggerProviders = new LinkedList(); - private static List actionProviders = new LinkedList(); + public static Map statements = new HashMap(); + public static Map> parameters = new HashMap>(); + private static List triggerProviders = new LinkedList(); + private static List actionProviders = new LinkedList(); - /** - * Deactivate constructor - */ - private StatementManager() { - } + /** Deactivate constructor */ + private StatementManager() {} - public static void registerTriggerProvider(ITriggerProvider provider) { - if (provider != null && !triggerProviders.contains(provider)) { - triggerProviders.add(provider); - } - } + public static void registerTriggerProvider(ITriggerProvider provider) { + if (provider != null && !triggerProviders.contains(provider)) { + triggerProviders.add(provider); + } + } - public static void registerActionProvider(IActionProvider provider) { - if (provider != null && !actionProviders.contains(provider)) { - actionProviders.add(provider); - } - } + public static void registerActionProvider(IActionProvider provider) { + if (provider != null && !actionProviders.contains(provider)) { + actionProviders.add(provider); + } + } - public static void registerStatement(IStatement statement) { - statements.put(statement.getUniqueTag(), statement); - } + public static void registerStatement(IStatement statement) { + statements.put(statement.getUniqueTag(), statement); + } - public static void registerParameterClass(Class param) { - parameters.put(createParameter(param).getUniqueTag(), param); - } - - @Deprecated - public static void registerParameterClass(String name, Class param) { - parameters.put(name, param); - } + public static void registerParameterClass(Class param) { + parameters.put(createParameter(param).getUniqueTag(), param); + } - public static List getExternalTriggers(ForgeDirection side, TileEntity entity) { - List result; + @Deprecated + public static void registerParameterClass(String name, Class param) { + parameters.put(name, param); + } - if (entity instanceof IOverrideDefaultStatements) { - result = ((IOverrideDefaultStatements) entity).overrideTriggers(); - if (result != null) { - return result; - } - } + public static List getExternalTriggers(EnumFacing side, TileEntity entity) { + List result; + + if (entity instanceof IOverrideDefaultStatements) { + result = ((IOverrideDefaultStatements) entity).overrideTriggers(); + if (result != null) { + return result; + } + } + + result = new LinkedList(); + + for (ITriggerProvider provider : triggerProviders) { + Collection toAdd = provider.getExternalTriggers(side, entity); + + if (toAdd != null) { + for (ITriggerExternal t : toAdd) { + if (!result.contains(t)) { + result.add(t); + } + } + } + } + + return result; + } + + public static List getExternalActions(EnumFacing side, TileEntity entity) { + List result = new LinkedList(); + + if (entity instanceof IOverrideDefaultStatements) { + result = ((IOverrideDefaultStatements) entity).overrideActions(); + if (result != null) { + return result; + } + } + + result = new LinkedList(); - result = new LinkedList(); - - for (ITriggerProvider provider : triggerProviders) { - Collection toAdd = provider.getExternalTriggers(side, entity); + for (IActionProvider provider : actionProviders) { + Collection toAdd = provider.getExternalActions(side, entity); - if (toAdd != null) { - for (ITriggerExternal t : toAdd) { - if (!result.contains(t)) { - result.add(t); - } - } - } - } + if (toAdd != null) { + for (IActionExternal t : toAdd) { + if (!result.contains(t)) { + result.add(t); + } + } + } + } - return result; - } + return result; + } - public static List getExternalActions(ForgeDirection side, TileEntity entity) { - List result = new LinkedList(); + public static List getInternalTriggers(IStatementContainer container) { + List result = new LinkedList(); - if (entity instanceof IOverrideDefaultStatements) { - result = ((IOverrideDefaultStatements) entity).overrideActions(); - if (result != null) { - return result; - } else { - result = new LinkedList(); - } - } - - for (IActionProvider provider : actionProviders) { - Collection toAdd = provider.getExternalActions(side, entity); + for (ITriggerProvider provider : triggerProviders) { + Collection toAdd = provider.getInternalTriggers(container); - if (toAdd != null) { - for (IActionExternal t : toAdd) { - if (!result.contains(t)) { - result.add(t); - } - } - } - } + if (toAdd != null) { + for (ITriggerInternal t : toAdd) { + if (!result.contains(t)) { + result.add(t); + } + } + } + } - return result; - } + return result; + } - public static List getInternalTriggers(IStatementContainer container) { - List result = new LinkedList(); + public static List getInternalActions(IStatementContainer container) { + List result = new LinkedList(); - for (ITriggerProvider provider : triggerProviders) { - Collection toAdd = provider.getInternalTriggers(container); + for (IActionProvider provider : actionProviders) { + Collection toAdd = provider.getInternalActions(container); - if (toAdd != null) { - for (ITriggerInternal t : toAdd) { - if (!result.contains(t)) { - result.add(t); - } - } - } - } + if (toAdd != null) { + for (IActionInternal t : toAdd) { + if (!result.contains(t)) { + result.add(t); + } + } + } + } - return result; - } + return result; + } - public static List getInternalActions(IStatementContainer container) { - List result = new LinkedList(); + public static IStatementParameter createParameter(String kind) { + return createParameter(parameters.get(kind)); + } - for (IActionProvider provider : actionProviders) { - Collection toAdd = provider.getInternalActions(container); + private static IStatementParameter createParameter(Class param) { + try { + return param.newInstance(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (Error error) { + BCLog.logErrorAPI(error, IStatementParameter.class); + throw error; + } - if (toAdd != null) { - for (IActionInternal t : toAdd) { - if (!result.contains(t)) { - result.add(t); - } - } - } - } + return null; + } - return result; - } - - public static IStatementParameter createParameter(String kind) { - return createParameter(parameters.get(kind)); - } - - private static IStatementParameter createParameter(Class param) { - try { - return param.newInstance(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - return null; - } - - /** - * Generally, this function should be called by every mod implementing - * the Statements API ***as a container*** (that is, adding its own gates) - * on the client side from a given Item of choice. - */ - @SideOnly(Side.CLIENT) - public static void registerIcons(IIconRegister register) { - for (IStatement statement : statements.values()) { - statement.registerIcons(register); - } - - for (Class parameter : parameters.values()) { - createParameter(parameter).registerIcons(register); - } - } + // /** + // * Generally, this function should be called by every mod implementing + // * the Statements API ***as a container*** (that is, adding its own gates) + // * on the client side from a given Item of choice. + // */ + // @SideOnly(Side.CLIENT) + // public static void registerIcons(TextureAtlasSpriteRegister register) { + // for (IStatement statement : statements.values()) { + // statement.registerIcons(register); + // } + // + // for (Class parameter : parameters.values()) { + // createParameter(parameter).registerIcons(register); + // } + // } } diff --git a/src/api/java/buildcraft/api/statements/StatementMouseClick.java b/src/api/java/buildcraft/api/statements/StatementMouseClick.java index 54688ebb8..c39ed336f 100644 --- a/src/api/java/buildcraft/api/statements/StatementMouseClick.java +++ b/src/api/java/buildcraft/api/statements/StatementMouseClick.java @@ -1,27 +1,23 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; public final class StatementMouseClick { - private int button; - private boolean shift; - - public StatementMouseClick(int button, boolean shift) { - this.button = button; - this.shift = shift; - } - - public boolean isShift() { - return shift; - } - - public int getButton() { - return button; - } + private int button; + private boolean shift; + + public StatementMouseClick(int button, boolean shift) { + this.button = button; + this.shift = shift; + } + + public boolean isShift() { + return shift; + } + + public int getButton() { + return button; + } } diff --git a/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java b/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java index 3bccda5d3..def3c36ac 100755 --- a/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java +++ b/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java @@ -1,88 +1,83 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.client.renderer.texture.TextureAtlasSprite; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.IIcon; public class StatementParameterItemStack implements IStatementParameter { - - protected ItemStack stack; - @Override - public IIcon getIcon() { - return null; - } + protected ItemStack stack; - @Override - public ItemStack getItemStack() { - return stack; - } + @Override + public TextureAtlasSprite getIcon() { + return null; + } - @Override - public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) { - if (stack != null) { - this.stack = stack.copy(); - this.stack.stackSize = 1; - } else { - this.stack = null; - } - } + @Override + public ItemStack getItemStack() { + return stack; + } - @Override - public void writeToNBT(NBTTagCompound compound) { - if (stack != null) { - NBTTagCompound tagCompound = new NBTTagCompound(); - stack.writeToNBT(tagCompound); - compound.setTag("stack", tagCompound); - } - } + @Override + public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) { + if (stack != null) { + this.stack = stack.copy(); + this.stack.stackSize = 1; + } else { + this.stack = null; + } + } - @Override - public void readFromNBT(NBTTagCompound compound) { - stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack")); - } + @Override + public void writeToNBT(NBTTagCompound compound) { + if (stack != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + stack.writeToNBT(tagCompound); + compound.setTag("stack", tagCompound); + } + } - @Override - public boolean equals(Object object) { - if (object instanceof StatementParameterItemStack) { - StatementParameterItemStack param = (StatementParameterItemStack) object; + @Override + public void readFromNBT(NBTTagCompound compound) { + stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack")); + } - return ItemStack.areItemStacksEqual(stack, param.stack) - && ItemStack.areItemStackTagsEqual(stack, param.stack); - } else { - return false; - } - } + @Override + public boolean equals(Object object) { + if (object instanceof StatementParameterItemStack) { + StatementParameterItemStack param = (StatementParameterItemStack) object; - @Override - public String getDescription() { - if (stack != null) { - return stack.getDisplayName(); - } else { - return ""; - } - } + return ItemStack.areItemStacksEqual(stack, param.stack) && ItemStack.areItemStackTagsEqual(stack, param.stack); + } else { + return false; + } + } - @Override - public String getUniqueTag() { - return "buildcraft:stack"; - } + @Override + public String getDescription() { + if (stack != null) { + return stack.getDisplayName(); + } else { + return ""; + } + } - @Override - public void registerIcons(IIconRegister iconRegister) { - - } + @Override + public String getUniqueTag() { + return "buildcraft:stack"; + } - @Override - public IStatementParameter rotateLeft() { - return this; - } + // @Override + // public void registerIcons(TextureAtlasSpriteRegister iconRegister) { + // + // } + + @Override + public IStatementParameter rotateLeft() { + return this; + } } diff --git a/src/api/java/buildcraft/api/statements/StatementSlot.java b/src/api/java/buildcraft/api/statements/StatementSlot.java old mode 100644 new mode 100755 index 6d8c1c2ce..11d5441fe --- a/src/api/java/buildcraft/api/statements/StatementSlot.java +++ b/src/api/java/buildcraft/api/statements/StatementSlot.java @@ -1,36 +1,32 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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 - */ + * 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; + 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; - } + @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 index 0856041cb..5b34bfd94 100644 --- a/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java +++ b/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java @@ -1,19 +1,17 @@ package buildcraft.api.statements.containers; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; 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); + /** 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(EnumFacing 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); + /** 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(EnumFacing 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 index 6262bf2f8..b65ace45a 100644 --- a/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java +++ b/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java @@ -1,12 +1,10 @@ package buildcraft.api.statements.containers; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; import buildcraft.api.statements.IStatementContainer; -/** - * Created by asie on 3/14/15. - */ +/** Created by asie on 3/14/15. */ public interface ISidedStatementContainer extends IStatementContainer { - ForgeDirection getSide(); + EnumFacing getSide(); } diff --git a/src/api/java/buildcraft/api/statements/package-info.java b/src/api/java/buildcraft/api/statements/package-info.java index ed7613ea2..7dd2c74e6 100644 --- a/src/api/java/buildcraft/api/statements/package-info.java +++ b/src/api/java/buildcraft/api/statements/package-info.java @@ -1,12 +1,8 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ @API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|statements") package buildcraft.api.statements; -import cpw.mods.fml.common.API; +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/transport/ICustomPipeConnection.java b/src/api/java/buildcraft/api/transport/ICustomPipeConnection.java new file mode 100644 index 000000000..c4cc1efdf --- /dev/null +++ b/src/api/java/buildcraft/api/transport/ICustomPipeConnection.java @@ -0,0 +1,12 @@ +package buildcraft.api.transport; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +public interface ICustomPipeConnection { + /** @return How long the connecting pipe should extend for. Values less than -4/16 indicate that the pipe will not + * connect at all, and will render as it it was not connected. */ + public float getExtension(World world, BlockPos pos, EnumFacing face, IBlockState state); +} diff --git a/src/api/java/buildcraft/api/transport/IInjectable.java b/src/api/java/buildcraft/api/transport/IInjectable.java index 6a05a688a..0de9e2005 100644 --- a/src/api/java/buildcraft/api/transport/IInjectable.java +++ b/src/api/java/buildcraft/api/transport/IInjectable.java @@ -1,23 +1,18 @@ package buildcraft.api.transport; +import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; - -import buildcraft.api.core.EnumColor; +import net.minecraft.util.EnumFacing; public interface IInjectable { - boolean canInjectItems(ForgeDirection from); + boolean canInjectItems(EnumFacing 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); + /** 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, EnumFacing from, EnumDyeColor color); } diff --git a/src/api/java/buildcraft/api/transport/IItemPipe.java b/src/api/java/buildcraft/api/transport/IItemPipe.java index f5f766775..c943a81a6 100644 --- a/src/api/java/buildcraft/api/transport/IItemPipe.java +++ b/src/api/java/buildcraft/api/transport/IItemPipe.java @@ -1,16 +1,11 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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 - */ + * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents + * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.transport; -/** - * To be implemented by the real item pipe in Transport mod, but leaves knowledge for classes that do not have direct dependency on transport. - */ +/** To be implemented by the real item pipe in Transport mod, but leaves knowledge for classes that do not have direct + * dependency on transport. */ public interface IItemPipe { } diff --git a/src/api/java/buildcraft/api/transport/IPipe.java b/src/api/java/buildcraft/api/transport/IPipe.java index 94b021d02..96a7a764c 100755 --- a/src/api/java/buildcraft/api/transport/IPipe.java +++ b/src/api/java/buildcraft/api/transport/IPipe.java @@ -1,25 +1,21 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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 net.minecraft.util.EnumFacing; import buildcraft.api.gates.IGate; public interface IPipe { - IPipeTile getTile(); + IPipeTile getTile(); - IGate getGate(ForgeDirection side); - - boolean hasGate(ForgeDirection side); - - boolean isWired(PipeWire wire); - - boolean isWireActive(PipeWire wire); + IGate getGate(EnumFacing side); + + boolean hasGate(EnumFacing side); + + boolean isWired(PipeWire wire); + + boolean isWireActive(PipeWire wire); } diff --git a/src/api/java/buildcraft/api/transport/IPipeConnection.java b/src/api/java/buildcraft/api/transport/IPipeConnection.java index 4899f24bd..0b25ec818 100644 --- a/src/api/java/buildcraft/api/transport/IPipeConnection.java +++ b/src/api/java/buildcraft/api/transport/IPipeConnection.java @@ -1,29 +1,24 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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 net.minecraft.util.EnumFacing; public interface IPipeConnection { - enum ConnectOverride { + enum ConnectOverride { - CONNECT, DISCONNECT, DEFAULT - } + CONNECT, + DISCONNECT, + DEFAULT + } - /** - * Allows you to override pipe connection logic. - * - * @param type - * @param with - * @return CONNECT to force a connection, DISCONNECT to force no connection, - * and DEFAULT to let the pipe decide. - */ - ConnectOverride overridePipeConnection(IPipeTile.PipeType type, ForgeDirection with); + /** Allows you to override pipe connection logic. + * + * @param type + * @param with + * @return CONNECT to force a connection, DISCONNECT to force no connection, and DEFAULT to let the pipe decide. */ + ConnectOverride overridePipeConnection(IPipeTile.PipeType type, EnumFacing with); } diff --git a/src/api/java/buildcraft/api/transport/IPipeTile.java b/src/api/java/buildcraft/api/transport/IPipeTile.java index 1bdd04f09..5ed528422 100644 --- a/src/api/java/buildcraft/api/transport/IPipeTile.java +++ b/src/api/java/buildcraft/api/transport/IPipeTile.java @@ -1,62 +1,51 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.util.EnumFacing; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.core.EnumColor; import buildcraft.api.transport.pluggable.PipePluggable; public interface IPipeTile extends IInjectable { - enum PipeType { - ITEM, FLUID, POWER, STRUCTURE - } + enum PipeType { + ITEM, + FLUID, + POWER, + STRUCTURE + } - PipeType getPipeType(); + PipeType getPipeType(); - World getWorld(); + World getWorldBC(); - int x(); + /** True if the pipe is connected to the block/pipe in the specific direction + * + * @param with + * @return true if connect */ + boolean isPipeConnected(EnumFacing with); - int y(); + Block getNeighborBlock(EnumFacing dir); - int z(); + TileEntity getNeighborTile(EnumFacing dir); - /** - * True if the pipe is connected to the block/pipe in the specific direction - * - * @param with - * @return true if connect - */ - boolean isPipeConnected(ForgeDirection with); + IPipe getNeighborPipe(EnumFacing dir); - Block getNeighborBlock(ForgeDirection dir); - TileEntity getNeighborTile(ForgeDirection dir); - IPipe getNeighborPipe(ForgeDirection dir); - - IPipe getPipe(); - int getPipeColor(); + IPipe getPipe(); - PipePluggable getPipePluggable(ForgeDirection direction); // Now in IPluggableProvider - boolean hasPipePluggable(ForgeDirection direction); // Now in IPluggableProvider - boolean hasBlockingPluggable(ForgeDirection direction); + int getPipeColor(); - void scheduleNeighborChange(); - void scheduleRenderUpdate(); + PipePluggable getPipePluggable(EnumFacing direction); // Now in IPluggableProvider - // For compatibility with BC 6.2.x and below - int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from, EnumColor color); + boolean hasPipePluggable(EnumFacing direction); // Now in IPluggableProvider - @Deprecated // Now in IInjectable - int injectItem(ItemStack stack, boolean doAdd, ForgeDirection from); + boolean hasBlockingPluggable(EnumFacing direction); + + void scheduleNeighborChange(); + + void scheduleRenderUpdate(); } diff --git a/src/api/java/buildcraft/api/transport/IStripesActivator.java b/src/api/java/buildcraft/api/transport/IStripesActivator.java index 47308ae0a..540346d7b 100644 --- a/src/api/java/buildcraft/api/transport/IStripesActivator.java +++ b/src/api/java/buildcraft/api/transport/IStripesActivator.java @@ -1,17 +1,14 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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; +import net.minecraft.util.EnumFacing; public interface IStripesActivator { - void sendItem(ItemStack itemStack, ForgeDirection direction); - void dropItem(ItemStack itemStack, ForgeDirection direction); + void sendItem(ItemStack itemStack, EnumFacing direction); + + void dropItem(ItemStack itemStack, EnumFacing direction); } diff --git a/src/api/java/buildcraft/api/transport/IStripesHandler.java b/src/api/java/buildcraft/api/transport/IStripesHandler.java index a9cc011f6..71f420552 100644 --- a/src/api/java/buildcraft/api/transport/IStripesHandler.java +++ b/src/api/java/buildcraft/api/transport/IStripesHandler.java @@ -1,28 +1,24 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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; import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public interface IStripesHandler { - enum StripesHandlerType { - ITEM_USE, - BLOCK_BREAK - } - - StripesHandlerType getType(); - - boolean shouldHandle(ItemStack stack); - - boolean handle(World world, int x, int y, int z, ForgeDirection direction, - ItemStack stack, EntityPlayer player, IStripesActivator activator); + enum StripesHandlerType { + ITEM_USE, + BLOCK_BREAK + } + + StripesHandlerType getType(); + + boolean shouldHandle(ItemStack stack); + + boolean handle(World world, BlockPos pos, EnumFacing direction, 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 30a8452d5..569c53954 100644 --- a/src/api/java/buildcraft/api/transport/IStripesPipe.java +++ b/src/api/java/buildcraft/api/transport/IStripesPipe.java @@ -1,12 +1,9 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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; -public interface IStripesPipe extends IPipe, IStripesActivator { -} +import cofh.api.energy.IEnergyHandler; + +public interface IStripesPipe extends IPipe, IStripesActivator, IEnergyHandler {} diff --git a/src/api/java/buildcraft/api/transport/PipeConnectionAPI.java b/src/api/java/buildcraft/api/transport/PipeConnectionAPI.java new file mode 100644 index 000000000..e79da2646 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/PipeConnectionAPI.java @@ -0,0 +1,48 @@ +package buildcraft.api.transport; + +import java.util.Map; + +import com.google.common.collect.Maps; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +/** Use this class to register blocks with custom block sizes so that pipes can connect to them properly. Note that you + * do not need to register a custom pipe connection if your block implements ICustomPipeConnection. The registered + * version does not override your own implementation. */ +public final class PipeConnectionAPI { + private static final Map connections = Maps.newHashMap(); + private static final ICustomPipeConnection NOTHING = new ICustomPipeConnection() { + @Override + public float getExtension(World world, BlockPos pos, EnumFacing face, IBlockState state) { + return 0; + } + }; + + /** Register a block with a custom connection. Useful if you don't own the block class or are adding it for some-one + * + * @param block The block instance + * @param connection The connection instance */ + public static void registerConnection(Block block, ICustomPipeConnection connection) { + connections.put(block, connection); + } + + public static void registerConnectionAsNothing(Block block) { + connections.put(block, NOTHING); + } + + /** Gets the current custom connection that the block uses. Will be null if nothing has been set. */ + public static ICustomPipeConnection getCustomConnection(Block block) { + if (block instanceof ICustomPipeConnection) { + return (ICustomPipeConnection) block; + } + ICustomPipeConnection connection = connections.get(block); + if (connection != null) { + return connection; + } + return null; + } +} diff --git a/src/api/java/buildcraft/api/transport/PipeManager.java b/src/api/java/buildcraft/api/transport/PipeManager.java index 896f08210..0fd0f8aad 100755 --- a/src/api/java/buildcraft/api/transport/PipeManager.java +++ b/src/api/java/buildcraft/api/transport/PipeManager.java @@ -1,11 +1,7 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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; @@ -15,64 +11,61 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; import buildcraft.api.transport.pluggable.PipePluggable; public abstract class PipeManager { - public static List stripesHandlers = new ArrayList(); - public static ArrayList> pipePluggables = new ArrayList>(); - private static Map> pipePluggableNames = - new HashMap>(); - private static Map, String> pipePluggableByNames = - new HashMap, String>(); - private static Map stripesHandlerPriorities = - new HashMap(); + public static List stripesHandlers = 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; - } + @Deprecated + public static boolean canExtractItems(Object extractor, World world, BlockPos pos) { + return true; + } - @Deprecated - public static boolean canExtractFluids(Object extractor, World world, int i, int j, int k) { - return true; - } + @Deprecated + public static boolean canExtractFluids(Object extractor, World world, BlockPos pos) { + return true; + } - @Deprecated - public static void registerStripesHandler(IStripesHandler handler) { - registerStripesHandler(handler, 0); - } + @Deprecated + public static void registerStripesHandler(IStripesHandler handler) { + registerStripesHandler(handler, 0); + } - /** - * Register a Stripes Pipe handler. - * @param handler The handler. - * @param priority The priority - 0 is normal, higher numbers have higher priority. - */ - public static void registerStripesHandler(IStripesHandler handler, int priority) { - stripesHandlers.add(handler); - stripesHandlerPriorities.put(handler, priority); + /** Register a Stripes Pipe handler. + * + * @param handler The handler. + * @param priority The priority - 0 is normal, higher numbers have higher priority. */ + public static void registerStripesHandler(IStripesHandler handler, int priority) { + stripesHandlers.add(handler); + stripesHandlerPriorities.put(handler, priority); - Collections.sort(stripesHandlers, new Comparator() { - @Override - public int compare(IStripesHandler o1, IStripesHandler o2) { - return stripesHandlerPriorities.get(o2) - stripesHandlerPriorities.get(o1); - } - }); - } + Collections.sort(stripesHandlers, new Comparator() { + @Override + public int compare(IStripesHandler o1, IStripesHandler o2) { + return stripesHandlerPriorities.get(o2) - stripesHandlerPriorities.get(o1); + } + }); + } - public static void registerPipePluggable(Class pluggable, String name) { - pipePluggables.add(pluggable); - pipePluggableNames.put(name, pluggable); - pipePluggableByNames.put(pluggable, name); - } + public static void registerPipePluggable(Class pluggable, String name) { + pipePluggables.add(pluggable); + pipePluggableNames.put(name, pluggable); + pipePluggableByNames.put(pluggable, name); + } - public static Class getPluggableByName(String pluggableName) { - return pipePluggableNames.get(pluggableName); - } + public static Class getPluggableByName(String pluggableName) { + return pipePluggableNames.get(pluggableName); + } - public static String getPluggableName(Class aClass) { - return pipePluggableByNames.get(aClass); - } + 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 eb8665e15..5864db9c3 100644 --- a/src/api/java/buildcraft/api/transport/PipeWire.java +++ b/src/api/java/buildcraft/api/transport/PipeWire.java @@ -1,11 +1,7 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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.Locale; @@ -15,60 +11,63 @@ import net.minecraft.item.ItemStack; public enum PipeWire { - RED, BLUE, GREEN, YELLOW; - public static Item item; - public static final PipeWire[] VALUES = values(); + RED, + BLUE, + GREEN, + YELLOW; + public static Item item; + public static final PipeWire[] VALUES = values(); - public PipeWire reverse() { - switch (this) { - case RED: - return YELLOW; - case BLUE: - return GREEN; - case GREEN: - return BLUE; - default: - return RED; - } - } + public PipeWire reverse() { + switch (this) { + case RED: + return YELLOW; + case BLUE: + return GREEN; + case GREEN: + return BLUE; + default: + return RED; + } + } - public String getTag() { - return name().toLowerCase(Locale.ENGLISH) + "PipeWire"; - } + public String getTag() { + return name().toLowerCase(Locale.ENGLISH) + "PipeWire"; + } - public String getColor() { - String name = this.toString().toLowerCase(Locale.ENGLISH); - char first = Character.toUpperCase(name.charAt(0)); - return first + name.substring(1); - } + public String getColor() { + String name = this.toString().toLowerCase(Locale.ENGLISH); + char first = Character.toUpperCase(name.charAt(0)); + return first + name.substring(1); + } - public ItemStack getStack() { - return getStack(1); - } + public ItemStack getStack() { + return getStack(1); + } - public ItemStack getStack(int qty) { - if (item == null) { - return null; - } else { - return new ItemStack(item, qty, ordinal()); - } - } + public ItemStack getStack(int qty) { + if (item == null) { + return null; + } else { + return new ItemStack(item, qty, ordinal()); + } + } - public boolean isPipeWire(ItemStack stack) { - if (stack == null) { - return false; - } else if (stack.getItem() != item) { - return false; - } else { - return stack.getItemDamage() == ordinal(); - } - } + public boolean isPipeWire(ItemStack stack) { + if (stack == null) { + return false; + } else if (stack.getItem() != item) { + return false; + } else { + return stack.getItemDamage() == ordinal(); + } + } - public static PipeWire fromOrdinal(int ordinal) { - if (ordinal < 0 || ordinal >= VALUES.length) { - return RED; - } else { - return VALUES[ordinal]; - } - } + public static PipeWire fromOrdinal(int ordinal) { + if (ordinal < 0 || ordinal >= VALUES.length) { + return RED; + } else { + return VALUES[ordinal]; + } + } } diff --git a/src/api/java/buildcraft/api/transport/package-info.java b/src/api/java/buildcraft/api/transport/package-info.java index b670143c6..7ab0064d3 100644 --- a/src/api/java/buildcraft/api/transport/package-info.java +++ b/src/api/java/buildcraft/api/transport/package-info.java @@ -1,12 +1,8 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ @API(apiVersion = "4.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|transport") package buildcraft.api.transport; -import cpw.mods.fml.common.API; +import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/transport/pluggable/IConnectionMatrix.java b/src/api/java/buildcraft/api/transport/pluggable/IConnectionMatrix.java new file mode 100644 index 000000000..4bede4d03 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IConnectionMatrix.java @@ -0,0 +1,7 @@ +package buildcraft.api.transport.pluggable; + +import net.minecraft.util.EnumFacing; + +public interface IConnectionMatrix { + boolean isConnected(EnumFacing face); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java b/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java index 6289714ac..a3ad9f329 100644 --- a/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java +++ b/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java @@ -1,13 +1,11 @@ package buildcraft.api.transport.pluggable; -import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; public interface IFacadePluggable { - Block getCurrentBlock(); + IBlockState getCurrentState(); - int getCurrentMetadata(); + boolean isTransparent(); - boolean isTransparent(); - - boolean isHollow(); + boolean isHollow(); } diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableDynamicRenderer.java b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableDynamicRenderer.java index 614c65ff9..2601a356d 100644 --- a/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableDynamicRenderer.java +++ b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableDynamicRenderer.java @@ -1,9 +1,9 @@ package buildcraft.api.transport.pluggable; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; import buildcraft.api.transport.IPipe; public interface IPipePluggableDynamicRenderer { - void renderPluggable(IPipe pipe, ForgeDirection side, PipePluggable pipePluggable, double x, double y, double z); + void renderDynamicPluggable(IPipe pipe, EnumFacing 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 index 0ac208905..b9295e5f0 100644 --- a/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableItem.java +++ b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableItem.java @@ -1,10 +1,10 @@ package buildcraft.api.transport.pluggable; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; import buildcraft.api.transport.IPipe; public interface IPipePluggableItem { - PipePluggable createPipePluggable(IPipe pipe, ForgeDirection side, ItemStack stack); + PipePluggable createPipePluggable(IPipe pipe, EnumFacing 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 deleted file mode 100644 index 2cd4bc276..000000000 --- a/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableRenderer.java +++ /dev/null @@ -1,13 +0,0 @@ -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/IPipePluggableState.java b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableState.java new file mode 100644 index 000000000..7b657dfd0 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableState.java @@ -0,0 +1,9 @@ +package buildcraft.api.transport.pluggable; + +import net.minecraft.util.EnumFacing; + +public interface IPipePluggableState { + IConnectionMatrix getPluggableConnections(); + + PipePluggable getPluggable(EnumFacing face); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableStaticRenderer.java b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableStaticRenderer.java new file mode 100644 index 000000000..e4bfc3f60 --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IPipePluggableStaticRenderer.java @@ -0,0 +1,19 @@ +package buildcraft.api.transport.pluggable; + +import java.util.List; + +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.util.EnumFacing; + +import buildcraft.api.transport.IPipe; + +public interface IPipePluggableStaticRenderer { + List bakeCutout(IPipeRenderState render, IPipePluggableState pluggableState, IPipe pipe, PipePluggable pluggable, EnumFacing face); + + /** Use this if you need to render in the translucent pass. */ + public interface Translucent extends IPipePluggableStaticRenderer { + /** For performance return a list that is as small as possible */ + List bakeTranslucent(IPipeRenderState render, IPipePluggableState pluggableState, IPipe pipe, PipePluggable pluggable, + EnumFacing face); + } +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPipeRenderState.java b/src/api/java/buildcraft/api/transport/pluggable/IPipeRenderState.java new file mode 100644 index 000000000..d923061fd --- /dev/null +++ b/src/api/java/buildcraft/api/transport/pluggable/IPipeRenderState.java @@ -0,0 +1,5 @@ +package buildcraft.api.transport.pluggable; + +public interface IPipeRenderState { + IConnectionMatrix getPipeConnectionMatrix(); +} diff --git a/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java b/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java old mode 100644 new mode 100755 index 223ce7096..02a0bd3ab --- a/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java +++ b/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java @@ -1,67 +1,60 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team - * http://www.mod-buildcraft.com +/** 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. - */ + * 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 net.minecraft.util.EnumFacing; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; 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! - */ +/** 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 abstract ItemStack[] getDropItems(IPipeTile pipe); - public void update(IPipeTile pipe, ForgeDirection direction) { + public void update(IPipeTile pipe, EnumFacing direction) { - } + } - public void onAttachedPipe(IPipeTile pipe, ForgeDirection direction) { - validate(pipe, direction); - } + public void onAttachedPipe(IPipeTile pipe, EnumFacing direction) { + validate(pipe, direction); + } - public void onDetachedPipe(IPipeTile pipe, ForgeDirection direction) { - invalidate(); - } + public void onDetachedPipe(IPipeTile pipe, EnumFacing direction) { + invalidate(); + } - public abstract boolean isBlocking(IPipeTile pipe, ForgeDirection direction); + public abstract boolean isBlocking(IPipeTile pipe, EnumFacing direction); - public void invalidate() { + public void invalidate() { - } + } - public void validate(IPipeTile pipe, ForgeDirection direction) { + public void validate(IPipeTile pipe, EnumFacing direction) { - } + } - public boolean isSolidOnSide(IPipeTile pipe, ForgeDirection direction) { - return false; - } + public boolean isSolidOnSide(IPipeTile pipe, EnumFacing direction) { + return false; + } - public abstract AxisAlignedBB getBoundingBox(ForgeDirection side); + public abstract AxisAlignedBB getBoundingBox(EnumFacing side); - @SideOnly(Side.CLIENT) - public abstract IPipePluggableRenderer getRenderer(); + @SideOnly(Side.CLIENT) + public abstract IPipePluggableStaticRenderer getRenderer(); - @SideOnly(Side.CLIENT) - public IPipePluggableDynamicRenderer getDynamicRenderer() { - return null; - } + @SideOnly(Side.CLIENT) + public IPipePluggableDynamicRenderer getDynamicRenderer() { + return null; + } - public boolean requiresRenderUpdate(PipePluggable old) { - return true; - } + public boolean requiresRenderUpdate(PipePluggable old) { + return true; + } } diff --git a/src/api/java/cofh/api/energy/IEnergyHandler.java b/src/api/java/cofh/api/energy/IEnergyHandler.java new file mode 100644 index 000000000..a25517c4a --- /dev/null +++ b/src/api/java/cofh/api/energy/IEnergyHandler.java @@ -0,0 +1,59 @@ +package cofh.api.energy; + +import net.minecraft.util.EnumFacing; + + +/** + * Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects. + *

+ * A reference implementation is provided {@link TileEnergyHandler}. + * + * @author King Lemming + * + */ +public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver { + + // merely a convenience interface (remove these methods in 1.8; provided here for back-compat via compiler doing things) + + /** + * Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver. + * + * @param from + * Orientation the energy is received from. + * @param maxReceive + * Maximum amount of energy to receive. + * @param simulate + * If TRUE, the charge will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) received. + */ + @Override + int receiveEnergy(EnumFacing facing, int maxReceive, boolean simulate); + + /** + * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider. + * + * @param from + * Orientation the energy is extracted from. + * @param maxExtract + * Maximum amount of energy to extract. + * @param simulate + * If TRUE, the extraction will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) extracted. + */ + @Override + int extractEnergy(EnumFacing facing, int maxExtract, boolean simulate); + + + /** + * Returns the amount of energy currently stored. + */ + @Override + int getEnergyStored(EnumFacing facing); + + /** + * Returns the maximum amount of energy that can be stored. + */ + @Override + int getMaxEnergyStored(EnumFacing facing); + +} diff --git a/src/api/java/cofh/api/energy/IEnergyProvider.java b/src/api/java/cofh/api/energy/IEnergyProvider.java new file mode 100644 index 000000000..12ec6f4aa --- /dev/null +++ b/src/api/java/cofh/api/energy/IEnergyProvider.java @@ -0,0 +1,39 @@ +package cofh.api.energy; + +import net.minecraft.util.EnumFacing; + + +/** + * Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects. + *

+ * A reference implementation is provided {@link TileEnergyHandler}. + * + * @author King Lemming + * + */ +public interface IEnergyProvider extends IEnergyConnection { + + /** + * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider. + * + * @param from + * Orientation the energy is extracted from. + * @param maxExtract + * Maximum amount of energy to extract. + * @param simulate + * If TRUE, the extraction will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) extracted. + */ + int extractEnergy(EnumFacing facing, int maxExtract, boolean simulate); + + /** + * Returns the amount of energy currently stored. + */ + int getEnergyStored(EnumFacing facing); + + /** + * Returns the maximum amount of energy that can be stored. + */ + int getMaxEnergyStored(EnumFacing facing); + +} diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java index 49b424d97..2f2bc4d34 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementAPIPlugin.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.Collection; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; import vazkii.botania.api.mana.IManaBlock; import vazkii.botania.api.mana.IManaReceiver; import vazkii.botania.common.block.tile.TileRuneAltar; @@ -44,7 +44,7 @@ public class StatementAPIPlugin implements ITriggerProvider { } @Override - public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { + public Collection getExternalTriggers(EnumFacing side, TileEntity tile) { ArrayList list = new ArrayList(); if (tile instanceof IManaBlock) { diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java index cbf799357..ab08cb575 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/StatementBase.java @@ -1,14 +1,14 @@ package vazkii.botania.common.integration.buildcraft; -import net.minecraft.util.IIcon; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import buildcraft.api.statements.IStatement; import buildcraft.api.statements.IStatementParameter; public abstract class StatementBase implements IStatement { - protected IIcon icon; + protected TextureAtlasSprite icon; @Override - public IIcon getIcon() { + public TextureAtlasSprite getGuiSprite() { return icon; } diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java index 1b6dda0bd..68737cac2 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaDetector.java @@ -1,6 +1,8 @@ package vazkii.botania.common.integration.buildcraft; -import net.minecraft.client.renderer.texture.IIconRegister; +import com.google.common.base.Predicates; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; import net.minecraft.world.World; @@ -20,7 +22,7 @@ public class TriggerManaDetector extends StatementBase implements ITriggerIntern } @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(TextureMap iconRegister) { icon = IconHelper.forName(iconRegister, "triggers/manaDetector"); } @@ -32,9 +34,9 @@ public class TriggerManaDetector extends StatementBase implements ITriggerIntern @Override public boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters) { World world = source.getTile().getWorld(); - int x = source.getTile().xCoord, y = source.getTile().yCoord, z = source.getTile().zCoord; + int x = source.getTile().getPos().getX(), y = source.getTile().getPos().getY(), z = source.getTile().getPos().getZ(); - boolean output = world.getEntitiesWithinAABB(IManaBurst.class, new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1)).size() != 0; + boolean output = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1), Predicates.instanceOf(IManaBurst.class)).size() != 0; if(output) for(int i = 0; i < 4; i++) Botania.proxy.sparkleFX(world, x + Math.random(), y + Math.random(), z + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5); diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java index f655d56af..4361e9773 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerManaLevel.java @@ -1,9 +1,9 @@ package vazkii.botania.common.integration.buildcraft; -import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.util.StatCollector; -import net.minecraftforge.common.util.ForgeDirection; import org.apache.commons.lang3.text.WordUtils; @@ -35,7 +35,7 @@ public class TriggerManaLevel extends StatementBase implements ITriggerExternal } @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(TextureMap iconRegister) { icon = IconHelper.forName(iconRegister, "triggers/mana" + WordUtils.capitalizeFully(state.name())); } @@ -45,7 +45,7 @@ public class TriggerManaLevel extends StatementBase implements ITriggerExternal } @Override - public boolean isTriggerActive(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { + public boolean isTriggerActive(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { if(target instanceof IManaBlock) { if(state == State.EMPTY) return ((IManaBlock) target).getCurrentMana() == 0; else if(state == State.CONTAINS) return ((IManaBlock) target).getCurrentMana() > 0; diff --git a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java index cbad8aa76..9ec63f7bf 100644 --- a/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java +++ b/src/main/java/vazkii/botania/common/integration/buildcraft/TriggerRuneAltarCanCraft.java @@ -1,9 +1,9 @@ package vazkii.botania.common.integration.buildcraft; -import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.util.StatCollector; -import net.minecraftforge.common.util.ForgeDirection; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.block.tile.TileRuneAltar; import vazkii.botania.common.lib.LibTriggerNames; @@ -19,7 +19,7 @@ public class TriggerRuneAltarCanCraft extends StatementBase implements ITriggerE } @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(TextureMap iconRegister) { icon = IconHelper.forName(iconRegister, "triggers/runeAltarCanCraft"); } @@ -29,7 +29,7 @@ public class TriggerRuneAltarCanCraft extends StatementBase implements ITriggerE } @Override - public boolean isTriggerActive(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) { + public boolean isTriggerActive(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) { if(target instanceof TileRuneAltar) return ((TileRuneAltar) target).hasValidRecipe(); return false; }