diff --git a/src/main/java/erogenousbeef/coreTR/common/BeefCoreLog.java b/src/main/java/erogenousbeef/coreTR/common/BeefCoreLog.java index 54216555c..96debaced 100644 --- a/src/main/java/erogenousbeef/coreTR/common/BeefCoreLog.java +++ b/src/main/java/erogenousbeef/coreTR/common/BeefCoreLog.java @@ -5,41 +5,41 @@ import org.apache.logging.log4j.Level; import cpw.mods.fml.common.FMLLog; public class BeefCoreLog { - + private static final String CHANNEL = "BeefCore"; - public static void log(Level level, String format, Object... data) - { - FMLLog.log(level, format, data); - } + public static void log(Level level, String format, Object... data) + { + FMLLog.log(level, format, data); + } - public static void fatal(String format, Object... data) - { - log(Level.FATAL, format, data); - } + public static void fatal(String format, Object... data) + { + log(Level.FATAL, format, data); + } - public static void error(String format, Object... data) - { - log(Level.ERROR, format, data); - } + public static void error(String format, Object... data) + { + log(Level.ERROR, format, data); + } - public static void warning(String format, Object... data) - { - log(Level.WARN, format, data); - } + public static void warning(String format, Object... data) + { + log(Level.WARN, format, data); + } - public static void info(String format, Object... data) - { - log(Level.INFO, format, data); - } + public static void info(String format, Object... data) + { + log(Level.INFO, format, data); + } - public static void debug(String format, Object... data) - { - log(Level.DEBUG, format, data); - } + public static void debug(String format, Object... data) + { + log(Level.DEBUG, format, data); + } - public static void trace(String format, Object... data) - { - log(Level.TRACE, format, data); - } + public static void trace(String format, Object... data) + { + log(Level.TRACE, format, data); + } } diff --git a/src/main/java/erogenousbeef/coreTR/common/CoordTriplet.java b/src/main/java/erogenousbeef/coreTR/common/CoordTriplet.java index 08f689c7f..c5a821fc7 100644 --- a/src/main/java/erogenousbeef/coreTR/common/CoordTriplet.java +++ b/src/main/java/erogenousbeef/coreTR/common/CoordTriplet.java @@ -9,41 +9,60 @@ import net.minecraftforge.common.util.ForgeDirection; public class CoordTriplet implements Comparable { public int x, y, z; - public CoordTriplet(int x, int y, int z) { + public CoordTriplet(int x, int y, int z) + { this.x = x; this.y = y; this.z = z; } - - public int getChunkX() { return x >> 4; } - public int getChunkZ() { return z >> 4; } - public long getChunkXZHash() { return ChunkCoordIntPair.chunkXZ2Int(x >> 4, z >> 4); } - + + public int getChunkX() + { + return x >> 4; + } + + public int getChunkZ() + { + return z >> 4; + } + + public long getChunkXZHash() + { + return ChunkCoordIntPair.chunkXZ2Int(x >> 4, z >> 4); + } + @Override - public boolean equals(Object other) { - if(other == null) - { return false; } - else if(other instanceof CoordTriplet) { - CoordTriplet otherTriplet = (CoordTriplet)other; - return this.x == otherTriplet.x && this.y == otherTriplet.y && this.z == otherTriplet.z; - } - else { + public boolean equals(Object other) + { + if (other == null) + { + return false; + } else if (other instanceof CoordTriplet) + { + CoordTriplet otherTriplet = (CoordTriplet) other; + return this.x == otherTriplet.x && this.y == otherTriplet.y + && this.z == otherTriplet.z; + } else + { return false; } } - - public void translate(ForgeDirection dir) { + + public void translate(ForgeDirection dir) + { this.x += dir.offsetX; this.y += dir.offsetY; this.z += dir.offsetZ; } - - public boolean equals(int x, int y, int z) { + + public boolean equals(int x, int y, int z) + { return this.x == x && this.y == y && this.z == z; } - + // Suggested implementation from NetBeans 7.1 - public int hashCode() { + public int hashCode() + { int hash = 7; hash = 71 * hash + this.x; hash = 71 * hash + this.y; @@ -51,78 +70,144 @@ public class CoordTriplet implements Comparable { return hash; } - public CoordTriplet copy() { + public CoordTriplet copy() + { return new CoordTriplet(x, y, z); } - - public void copy(CoordTriplet other) { + + public void copy(CoordTriplet other) + { this.x = other.x; this.y = other.y; this.z = other.z; } - public CoordTriplet[] getNeighbors() { - return new CoordTriplet[]{ - new CoordTriplet(x + 1, y, z), - new CoordTriplet(x - 1, y, z), - new CoordTriplet(x, y + 1, z), - new CoordTriplet(x, y - 1, z), - new CoordTriplet(x, y, z + 1), - new CoordTriplet(x, y, z - 1) - }; + public CoordTriplet[] getNeighbors() + { + return new CoordTriplet[] + { new CoordTriplet(x + 1, y, z), new CoordTriplet(x - 1, y, z), + new CoordTriplet(x, y + 1, z), new CoordTriplet(x, y - 1, z), + new CoordTriplet(x, y, z + 1), new CoordTriplet(x, y, z - 1) }; } - - ///// IComparable - + + // /// IComparable + @Override - public int compareTo(Object o) { - if(o instanceof CoordTriplet) { - CoordTriplet other = (CoordTriplet)o; - if(this.x < other.x) { return -1; } - else if(this.x > other.x) { return 1; } - else if(this.y < other.y) { return -1; } - else if(this.y > other.y) { return 1; } - else if(this.z < other.z) { return -1; } - else if(this.z > other.z) { return 1; } - else { return 0; } + public int compareTo(Object o) + { + if (o instanceof CoordTriplet) + { + CoordTriplet other = (CoordTriplet) o; + if (this.x < other.x) + { + return -1; + } else if (this.x > other.x) + { + return 1; + } else if (this.y < other.y) + { + return -1; + } else if (this.y > other.y) + { + return 1; + } else if (this.z < other.z) + { + return -1; + } else if (this.z > other.z) + { + return 1; + } else + { + return 0; + } } return 0; } - - ///// Really confusing code that should be cleaned up - - public ForgeDirection getDirectionFromSourceCoords(int x, int y, int z) { - if(this.x < x) { return ForgeDirection.WEST; } - else if(this.x > x) { return ForgeDirection.EAST; } - else if(this.y < y) { return ForgeDirection.DOWN; } - else if(this.y > y) { return ForgeDirection.UP; } - else if(this.z < z) { return ForgeDirection.SOUTH; } - else if(this.z > z) { return ForgeDirection.NORTH; } - else { return ForgeDirection.UNKNOWN; } + + // /// Really confusing code that should be cleaned up + + public ForgeDirection getDirectionFromSourceCoords(int x, int y, int z) + { + if (this.x < x) + { + return ForgeDirection.WEST; + } else if (this.x > x) + { + return ForgeDirection.EAST; + } else if (this.y < y) + { + return ForgeDirection.DOWN; + } else if (this.y > y) + { + return ForgeDirection.UP; + } else if (this.z < z) + { + return ForgeDirection.SOUTH; + } else if (this.z > z) + { + return ForgeDirection.NORTH; + } else + { + return ForgeDirection.UNKNOWN; + } } - - public ForgeDirection getOppositeDirectionFromSourceCoords(int x, int y, int z) { - if(this.x < x) { return ForgeDirection.EAST; } - else if(this.x > x) { return ForgeDirection.WEST; } - else if(this.y < y) { return ForgeDirection.UP; } - else if(this.y > y) { return ForgeDirection.DOWN; } - else if(this.z < z) { return ForgeDirection.NORTH; } - else if(this.z > z) { return ForgeDirection.SOUTH; } - else { return ForgeDirection.UNKNOWN; } + + public ForgeDirection getOppositeDirectionFromSourceCoords(int x, int y, + int z) + { + if (this.x < x) + { + return ForgeDirection.EAST; + } else if (this.x > x) + { + return ForgeDirection.WEST; + } else if (this.y < y) + { + return ForgeDirection.UP; + } else if (this.y > y) + { + return ForgeDirection.DOWN; + } else if (this.z < z) + { + return ForgeDirection.NORTH; + } else if (this.z > z) + { + return ForgeDirection.SOUTH; + } else + { + return ForgeDirection.UNKNOWN; + } } - + @Override - public String toString() { + public String toString() + { return String.format("(%d, %d, %d)", this.x, this.y, this.z); } - public int compareTo(int xCoord, int yCoord, int zCoord) { - if(this.x < xCoord) { return -1; } - else if(this.x > xCoord) { return 1; } - else if(this.y < yCoord) { return -1; } - else if(this.y > yCoord) { return 1; } - else if(this.z < zCoord) { return -1; } - else if(this.z > zCoord) { return 1; } - else { return 0; } + public int compareTo(int xCoord, int yCoord, int zCoord) + { + if (this.x < xCoord) + { + return -1; + } else if (this.x > xCoord) + { + return 1; + } else if (this.y < yCoord) + { + return -1; + } else if (this.y > yCoord) + { + return 1; + } else if (this.z < zCoord) + { + return -1; + } else if (this.z > zCoord) + { + return 1; + } else + { + return 0; + } } } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/BlockMultiblockBase.java b/src/main/java/erogenousbeef/coreTR/multiblock/BlockMultiblockBase.java index 78fdcd698..f9263c542 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/BlockMultiblockBase.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/BlockMultiblockBase.java @@ -9,7 +9,8 @@ import net.minecraft.block.material.Material; */ public abstract class BlockMultiblockBase extends BlockContainer { - protected BlockMultiblockBase(Material material) { + protected BlockMultiblockBase(Material material) + { super(material); } } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/IMultiblockPart.java b/src/main/java/erogenousbeef/coreTR/multiblock/IMultiblockPart.java index 263b7ca6a..93b5506fe 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/IMultiblockPart.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/IMultiblockPart.java @@ -7,106 +7,132 @@ import net.minecraft.tileentity.TileEntity; import erogenousbeef.coreTR.common.CoordTriplet; /** - * Basic interface for a multiblock machine part. This is defined as an abstract class - * as we need the basic functionality of a TileEntity as well. - * Preferably, you should derive from MultiblockTileEntityBase, - * which does all the hard work for you. + * Basic interface for a multiblock machine part. This is defined as an abstract + * class as we need the basic functionality of a TileEntity as well. Preferably, + * you should derive from MultiblockTileEntityBase, which does all the hard work + * for you. * * {@link erogenousbeef.coreTR.multiblock.MultiblockTileEntityBase} */ public abstract class IMultiblockPart extends TileEntity { public static final int INVALID_DISTANCE = Integer.MAX_VALUE; - + /** - * @return True if this block is connected to a multiblock controller. False otherwise. + * @return True if this block is connected to a multiblock controller. False + * otherwise. */ public abstract boolean isConnected(); - + /** - * @return The attached multiblock controller for this tile entity. + * @return The attached multiblock controller for this tile entity. */ public abstract MultiblockControllerBase getMultiblockController(); - + /** - * Returns the location of this tile entity in the world, in CoordTriplet form. - * @return A CoordTriplet with its x,y,z members set to the location of this tile entity in the world. + * Returns the location of this tile entity in the world, in CoordTriplet + * form. + * + * @return A CoordTriplet with its x,y,z members set to the location of this + * tile entity in the world. */ public abstract CoordTriplet getWorldLocation(); - + // Multiblock connection-logic callbacks - + /** * Called after this block has been attached to a new multiblock controller. - * @param newController The new multiblock controller to which this tile entity is attached. + * + * @param newController + * The new multiblock controller to which this tile entity is + * attached. */ public abstract void onAttached(MultiblockControllerBase newController); - + /** * Called after this block has been detached from a multiblock controller. - * @param multiblockController The multiblock controller that no longer controls this tile entity. + * + * @param multiblockController + * The multiblock controller that no longer controls this tile + * entity. */ - public abstract void onDetached(MultiblockControllerBase multiblockController); - + public abstract void onDetached( + MultiblockControllerBase multiblockController); + /** - * Called when this block is being orphaned. Use this to copy game-data values that - * should persist despite a machine being broken. - * This should NOT mark the part as disconnected. onDetached will be called immediately afterwards. + * Called when this block is being orphaned. Use this to copy game-data + * values that should persist despite a machine being broken. This should + * NOT mark the part as disconnected. onDetached will be called immediately + * afterwards. + * * @see #onDetached(MultiblockControllerBase) - * @param oldController The controller which is orphaning this block. - * @param oldControllerSize The number of connected blocks in the controller prior to shedding orphans. - * @param newControllerSize The number of connected blocks in the controller after shedding orphans. + * @param oldController + * The controller which is orphaning this block. + * @param oldControllerSize + * The number of connected blocks in the controller prior to + * shedding orphans. + * @param newControllerSize + * The number of connected blocks in the controller after + * shedding orphans. */ - public abstract void onOrphaned(MultiblockControllerBase oldController, int oldControllerSize, int newControllerSize); - + public abstract void onOrphaned(MultiblockControllerBase oldController, + int oldControllerSize, int newControllerSize); + // Multiblock fuse/split helper methods. Here there be dragons. /** - * Factory method. Creates a new multiblock controller and returns it. - * Does not attach this tile entity to it. - * Override this in your game code! - * @return A new Multiblock Controller, derived from MultiblockControllerBase. + * Factory method. Creates a new multiblock controller and returns it. Does + * not attach this tile entity to it. Override this in your game code! + * + * @return A new Multiblock Controller, derived from + * MultiblockControllerBase. */ public abstract MultiblockControllerBase createNewMultiblock(); /** - * Retrieve the type of multiblock controller which governs this part. - * Used to ensure that incompatible multiblocks are not merged. - * @return The class/type of the multiblock controller which governs this type of part. + * Retrieve the type of multiblock controller which governs this part. Used + * to ensure that incompatible multiblocks are not merged. + * + * @return The class/type of the multiblock controller which governs this + * type of part. */ public abstract Class getMultiblockControllerType(); - + /** - * Called when this block is moved from its current controller into a new controller. - * A special case of attach/detach, done here for efficiency to avoid triggering - * lots of recalculation logic. - * @param newController The new controller into which this tile entity is being merged. + * Called when this block is moved from its current controller into a new + * controller. A special case of attach/detach, done here for efficiency to + * avoid triggering lots of recalculation logic. + * + * @param newController + * The new controller into which this tile entity is being + * merged. */ public abstract void onAssimilated(MultiblockControllerBase newController); // Multiblock connection data access. // You generally shouldn't toy with these! // They're for use by Multiblock Controllers. - + /** * Set that this block has been visited by your validation algorithms. */ public abstract void setVisited(); - + /** * Set that this block has not been visited by your validation algorithms; */ public abstract void setUnvisited(); - + /** - * @return True if this block has been visited by your validation algorithms since the last reset. + * @return True if this block has been visited by your validation algorithms + * since the last reset. */ public abstract boolean isVisited(); - + /** * Called when this block becomes the designated block for saving data and * transmitting data across the wire. */ public abstract void becomeMultiblockSaveDelegate(); - + /** * Called when this block is no longer the designated block for saving data * and transmitting data across the wire. @@ -116,60 +142,72 @@ public abstract class IMultiblockPart extends TileEntity { /** * Is this block the designated save/load & network delegate? */ - public abstract boolean isMultiblockSaveDelegate(); + public abstract boolean isMultiblockSaveDelegate(); /** - * Returns an array containing references to neighboring IMultiblockPart tile entities. - * Primarily a utility method. Only works after tileentity construction, so it cannot be used in + * Returns an array containing references to neighboring IMultiblockPart + * tile entities. Primarily a utility method. Only works after tileentity + * construction, so it cannot be used in * MultiblockControllerBase::attachBlock. * - * This method is chunk-safe on the server; it will not query for parts in chunks that are unloaded. - * Note that no method is chunk-safe on the client, because ChunkProviderClient is stupid. - * @return An array of references to neighboring IMultiblockPart tile entities. + * This method is chunk-safe on the server; it will not query for parts in + * chunks that are unloaded. Note that no method is chunk-safe on the + * client, because ChunkProviderClient is stupid. + * + * @return An array of references to neighboring IMultiblockPart tile + * entities. */ public abstract IMultiblockPart[] getNeighboringParts(); // Multiblock business-logic callbacks - implement these! /** - * Called when a machine is fully assembled from the disassembled state, meaning - * it was broken by a player/entity action, not by chunk unloads. - * Note that, for non-square machines, the min/max coordinates may not actually be part - * of the machine! They form an outer bounding box for the whole machine itself. - * @param multiblockControllerBase The controller to which this part is being assembled. + * Called when a machine is fully assembled from the disassembled state, + * meaning it was broken by a player/entity action, not by chunk unloads. + * Note that, for non-square machines, the min/max coordinates may not + * actually be part of the machine! They form an outer bounding box for the + * whole machine itself. + * + * @param multiblockControllerBase + * The controller to which this part is being assembled. */ - public abstract void onMachineAssembled(MultiblockControllerBase multiblockControllerBase); - + public abstract void onMachineAssembled( + MultiblockControllerBase multiblockControllerBase); + /** - * Called when the machine is broken for game reasons, e.g. a player removed a block - * or an explosion occurred. + * Called when the machine is broken for game reasons, e.g. a player removed + * a block or an explosion occurred. */ public abstract void onMachineBroken(); - + /** - * Called when the user activates the machine. This is not called by default, but is included - * as most machines have this game-logical concept. + * Called when the user activates the machine. This is not called by + * default, but is included as most machines have this game-logical concept. */ public abstract void onMachineActivated(); /** - * Called when the user deactivates the machine. This is not called by default, but is included - * as most machines have this game-logical concept. + * Called when the user deactivates the machine. This is not called by + * default, but is included as most machines have this game-logical concept. */ public abstract void onMachineDeactivated(); // Block events /** - * Called when this part should check its neighbors. - * This method MUST NOT cause additional chunks to load. - * ALWAYS check to see if a chunk is loaded before querying for its tile entity - * This part should inform the controller that it is attaching at this time. - * @return A Set of multiblock controllers to which this object would like to attach. It should have attached to one of the controllers in this list. Return null if there are no compatible controllers nearby. + * Called when this part should check its neighbors. This method MUST NOT + * cause additional chunks to load. ALWAYS check to see if a chunk is loaded + * before querying for its tile entity This part should inform the + * controller that it is attaching at this time. + * + * @return A Set of multiblock controllers to which this object would like + * to attach. It should have attached to one of the controllers in + * this list. Return null if there are no compatible controllers + * nearby. */ public abstract Set attachToNeighbors(); /** - * Assert that this part is detached. If not, log a warning and set the part's controller to null. - * Do NOT fire the full disconnection logic. + * Assert that this part is detached. If not, log a warning and set the + * part's controller to null. Do NOT fire the full disconnection logic. */ public abstract void assertDetached(); @@ -177,15 +215,17 @@ public abstract class IMultiblockPart extends TileEntity { * @return True if a part has multiblock game-data saved inside it. */ public abstract boolean hasMultiblockSaveData(); - + /** - * @return The part's saved multiblock game-data in NBT format, or null if there isn't any. + * @return The part's saved multiblock game-data in NBT format, or null if + * there isn't any. */ public abstract NBTTagCompound getMultiblockSaveData(); /** - * Called after a block is added and the controller has incorporated the part's saved - * multiblock game-data into itself. Generally, you should clear the saved data here. + * Called after a block is added and the controller has incorporated the + * part's saved multiblock game-data into itself. Generally, you should + * clear the saved data here. */ public abstract void onMultiblockDataAssimilated(); } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockClientTickHandler.java b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockClientTickHandler.java index 88fec3c3d..6ba022277 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockClientTickHandler.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockClientTickHandler.java @@ -6,10 +6,12 @@ import cpw.mods.fml.common.gameevent.TickEvent; public class MultiblockClientTickHandler { - @SubscribeEvent - public void onClientTick(TickEvent.ClientTickEvent event) { - if(event.phase == TickEvent.Phase.START) { - MultiblockRegistry.tickStart(Minecraft.getMinecraft().theWorld); - } - } + @SubscribeEvent + public void onClientTick(TickEvent.ClientTickEvent event) + { + if (event.phase == TickEvent.Phase.START) + { + MultiblockRegistry.tickStart(Minecraft.getMinecraft().theWorld); + } + } } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockControllerBase.java b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockControllerBase.java index 9b76c4c4e..d73f74fbf 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockControllerBase.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockControllerBase.java @@ -13,59 +13,69 @@ import erogenousbeef.coreTR.common.BeefCoreLog; import erogenousbeef.coreTR.common.CoordTriplet; /** - * This class contains the base logic for "multiblock controllers". Conceptually, they are - * meta-TileEntities. They govern the logic for an associated group of TileEntities. + * This class contains the base logic for "multiblock controllers". + * Conceptually, they are meta-TileEntities. They govern the logic for an + * associated group of TileEntities. * - * Subordinate TileEntities implement the IMultiblockPart class and, generally, should not have an update() loop. + * Subordinate TileEntities implement the IMultiblockPart class and, generally, + * should not have an update() loop. */ public abstract class MultiblockControllerBase { public static final short DIMENSION_UNBOUNDED = -1; // Multiblock stuff - do not mess with protected World worldObj; - - // Disassembled -> Assembled; Assembled -> Disassembled OR Paused; Paused -> Assembled - protected enum AssemblyState { Disassembled, Assembled, Paused }; + + // Disassembled -> Assembled; Assembled -> Disassembled OR Paused; Paused -> + // Assembled + protected enum AssemblyState + { + Disassembled, Assembled, Paused + }; + protected AssemblyState assemblyState; protected HashSet connectedParts; - - /** This is a deterministically-picked coordinate that identifies this - * multiblock uniquely in its dimension. - * Currently, this is the coord with the lowest X, Y and Z coordinates, in that order of evaluation. - * i.e. If something has a lower X but higher Y/Z coordinates, it will still be the reference. - * If something has the same X but a lower Y coordinate, it will be the reference. Etc. + + /** + * This is a deterministically-picked coordinate that identifies this + * multiblock uniquely in its dimension. Currently, this is the coord with + * the lowest X, Y and Z coordinates, in that order of evaluation. i.e. If + * something has a lower X but higher Y/Z coordinates, it will still be the + * reference. If something has the same X but a lower Y coordinate, it will + * be the reference. Etc. */ private CoordTriplet referenceCoord; /** - * Minimum bounding box coordinate. Blocks do not necessarily exist at this coord if your machine - * is not a cube/rectangular prism. + * Minimum bounding box coordinate. Blocks do not necessarily exist at this + * coord if your machine is not a cube/rectangular prism. */ private CoordTriplet minimumCoord; /** - * Maximum bounding box coordinate. Blocks do not necessarily exist at this coord if your machine - * is not a cube/rectangular prism. + * Maximum bounding box coordinate. Blocks do not necessarily exist at this + * coord if your machine is not a cube/rectangular prism. */ private CoordTriplet maximumCoord; - + /** * Set to true whenever a part is removed from this controller. */ private boolean shouldCheckForDisconnections; - + /** * Set whenever we validate the multiblock */ private MultiblockValidationException lastValidationException; - + protected boolean debugMode; - - protected MultiblockControllerBase(World world) { + + protected MultiblockControllerBase(World world) + { // Multiblock stuff worldObj = world; - connectedParts = new HashSet(); + connectedParts = new HashSet(); referenceCoord = null; assemblyState = AssemblyState.Disassembled; @@ -75,314 +85,429 @@ public abstract class MultiblockControllerBase { shouldCheckForDisconnections = true; lastValidationException = null; - + debugMode = false; } - public void setDebugMode(boolean active) { + public void setDebugMode(boolean active) + { debugMode = active; } - - public boolean isDebugMode() { return debugMode; } - + + public boolean isDebugMode() + { + return debugMode; + } + /** - * Call when a block with cached save-delegate data is added to the multiblock. - * The part will be notified that the data has been used after this call completes. - * @param part The NBT tag containing this controller's data. + * Call when a block with cached save-delegate data is added to the + * multiblock. The part will be notified that the data has been used after + * this call completes. + * + * @param part + * The NBT tag containing this controller's data. */ - public abstract void onAttachedPartWithMultiblockData(IMultiblockPart part, NBTTagCompound data); - + public abstract void onAttachedPartWithMultiblockData(IMultiblockPart part, + NBTTagCompound data); + /** * Check if a block is being tracked by this machine. - * @param blockCoord Coordinate to check. - * @return True if the tile entity at blockCoord is being tracked by this machine, false otherwise. + * + * @param blockCoord + * Coordinate to check. + * @return True if the tile entity at blockCoord is being tracked by this + * machine, false otherwise. */ - public boolean hasBlock(CoordTriplet blockCoord) { + public boolean hasBlock(CoordTriplet blockCoord) + { return connectedParts.contains(blockCoord); } - + /** * Attach a new part to this machine. - * @param part The part to add. + * + * @param part + * The part to add. */ - public void attachBlock(IMultiblockPart part) { + public void attachBlock(IMultiblockPart part) + { IMultiblockPart candidate; CoordTriplet coord = part.getWorldLocation(); - if(!connectedParts.add(part)) { - BeefCoreLog.warning("[%s] Controller %s is double-adding part %d @ %s. This is unusual. If you encounter odd behavior, please tear down the machine and rebuild it.", (worldObj.isRemote?"CLIENT":"SERVER"), hashCode(), part.hashCode(), coord); + if (!connectedParts.add(part)) + { + BeefCoreLog + .warning( + "[%s] Controller %s is double-adding part %d @ %s. This is unusual. If you encounter odd behavior, please tear down the machine and rebuild it.", + (worldObj.isRemote ? "CLIENT" : "SERVER"), + hashCode(), part.hashCode(), coord); } - + part.onAttached(this); this.onBlockAdded(part); - if(part.hasMultiblockSaveData()) { + if (part.hasMultiblockSaveData()) + { NBTTagCompound savedData = part.getMultiblockSaveData(); onAttachedPartWithMultiblockData(part, savedData); part.onMultiblockDataAssimilated(); } - - if(this.referenceCoord == null) { + + if (this.referenceCoord == null) + { referenceCoord = coord; part.becomeMultiblockSaveDelegate(); - } - else if(coord.compareTo(referenceCoord) < 0) { - TileEntity te = this.worldObj.getTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z); - ((IMultiblockPart)te).forfeitMultiblockSaveDelegate(); - + } else if (coord.compareTo(referenceCoord) < 0) + { + TileEntity te = this.worldObj.getTileEntity(referenceCoord.x, + referenceCoord.y, referenceCoord.z); + ((IMultiblockPart) te).forfeitMultiblockSaveDelegate(); + referenceCoord = coord; part.becomeMultiblockSaveDelegate(); - } - else { + } else + { part.forfeitMultiblockSaveDelegate(); } - - if(minimumCoord != null) { - if(part.xCoord < minimumCoord.x) { minimumCoord.x = part.xCoord; } - if(part.yCoord < minimumCoord.y) { minimumCoord.y = part.yCoord; } - if(part.zCoord < minimumCoord.z) { minimumCoord.z = part.zCoord; } + + if (minimumCoord != null) + { + if (part.xCoord < minimumCoord.x) + { + minimumCoord.x = part.xCoord; + } + if (part.yCoord < minimumCoord.y) + { + minimumCoord.y = part.yCoord; + } + if (part.zCoord < minimumCoord.z) + { + minimumCoord.z = part.zCoord; + } } - - if(maximumCoord != null) { - if(part.xCoord > maximumCoord.x) { maximumCoord.x = part.xCoord; } - if(part.yCoord > maximumCoord.y) { maximumCoord.y = part.yCoord; } - if(part.zCoord > maximumCoord.z) { maximumCoord.z = part.zCoord; } + + if (maximumCoord != null) + { + if (part.xCoord > maximumCoord.x) + { + maximumCoord.x = part.xCoord; + } + if (part.yCoord > maximumCoord.y) + { + maximumCoord.y = part.yCoord; + } + if (part.zCoord > maximumCoord.z) + { + maximumCoord.z = part.zCoord; + } } - + MultiblockRegistry.addDirtyController(worldObj, this); } /** - * Called when a new part is added to the machine. Good time to register things into lists. - * @param newPart The part being added. + * Called when a new part is added to the machine. Good time to register + * things into lists. + * + * @param newPart + * The part being added. */ protected abstract void onBlockAdded(IMultiblockPart newPart); /** - * Called when a part is removed from the machine. Good time to clean up lists. - * @param oldPart The part being removed. + * Called when a part is removed from the machine. Good time to clean up + * lists. + * + * @param oldPart + * The part being removed. */ protected abstract void onBlockRemoved(IMultiblockPart oldPart); - + /** * Called when a machine is assembled from a disassembled state. */ protected abstract void onMachineAssembled(); - + /** - * Called when a machine is restored to the assembled state from a paused state. + * Called when a machine is restored to the assembled state from a paused + * state. */ protected abstract void onMachineRestored(); /** - * Called when a machine is paused from an assembled state - * This generally only happens due to chunk-loads and other "system" events. + * Called when a machine is paused from an assembled state This generally + * only happens due to chunk-loads and other "system" events. */ protected abstract void onMachinePaused(); - + /** - * Called when a machine is disassembled from an assembled state. - * This happens due to user or in-game actions (e.g. explosions) + * Called when a machine is disassembled from an assembled state. This + * happens due to user or in-game actions (e.g. explosions) */ protected abstract void onMachineDisassembled(); - + /** - * Callback whenever a part is removed (or will very shortly be removed) from a controller. - * Do housekeeping/callbacks, also nulls min/max coords. - * @param part The part being removed. + * Callback whenever a part is removed (or will very shortly be removed) + * from a controller. Do housekeeping/callbacks, also nulls min/max coords. + * + * @param part + * The part being removed. */ - private void onDetachBlock(IMultiblockPart part) { + private void onDetachBlock(IMultiblockPart part) + { // Strip out this part part.onDetached(this); this.onBlockRemoved(part); part.forfeitMultiblockSaveDelegate(); minimumCoord = maximumCoord = null; - - if(referenceCoord != null && referenceCoord.equals(part.xCoord, part.yCoord, part.zCoord)) { + + if (referenceCoord != null + && referenceCoord.equals(part.xCoord, part.yCoord, part.zCoord)) + { referenceCoord = null; } - + shouldCheckForDisconnections = true; } - + /** - * Call to detach a block from this machine. Generally, this should be called - * when the tile entity is being released, e.g. on block destruction. - * @param part The part to detach from this machine. - * @param chunkUnloading Is this entity detaching due to the chunk unloading? If true, the multiblock will be paused instead of broken. + * Call to detach a block from this machine. Generally, this should be + * called when the tile entity is being released, e.g. on block destruction. + * + * @param part + * The part to detach from this machine. + * @param chunkUnloading + * Is this entity detaching due to the chunk unloading? If true, + * the multiblock will be paused instead of broken. */ - public void detachBlock(IMultiblockPart part, boolean chunkUnloading) { - if(chunkUnloading && this.assemblyState == AssemblyState.Assembled) { + public void detachBlock(IMultiblockPart part, boolean chunkUnloading) + { + if (chunkUnloading && this.assemblyState == AssemblyState.Assembled) + { this.assemblyState = AssemblyState.Paused; this.onMachinePaused(); } // Strip out this part onDetachBlock(part); - if(!connectedParts.remove(part)) { - BeefCoreLog.warning("[%s] Double-removing part (%d) @ %d, %d, %d, this is unexpected and may cause problems. If you encounter anomalies, please tear down the reactor and rebuild it.", worldObj.isRemote?"CLIENT":"SERVER", part.hashCode(), part.xCoord, part.yCoord, part.zCoord); + if (!connectedParts.remove(part)) + { + BeefCoreLog + .warning( + "[%s] Double-removing part (%d) @ %d, %d, %d, this is unexpected and may cause problems. If you encounter anomalies, please tear down the reactor and rebuild it.", + worldObj.isRemote ? "CLIENT" : "SERVER", + part.hashCode(), part.xCoord, part.yCoord, + part.zCoord); } - if(connectedParts.isEmpty()) { + if (connectedParts.isEmpty()) + { // Destroy/unregister MultiblockRegistry.addDeadController(this.worldObj, this); return; } - MultiblockRegistry.addDirtyController(this.worldObj, this); + MultiblockRegistry.addDirtyController(this.worldObj, this); // Find new save delegate if we need to. - if(referenceCoord == null) { + if (referenceCoord == null) + { selectNewReferenceCoord(); } } /** - * Helper method so we don't check for a whole machine until we have enough blocks - * to actually assemble it. This isn't as simple as xmax*ymax*zmax for non-cubic machines - * or for machines with hollow/complex interiors. - * @return The minimum number of blocks connected to the machine for it to be assembled. + * Helper method so we don't check for a whole machine until we have enough + * blocks to actually assemble it. This isn't as simple as xmax*ymax*zmax + * for non-cubic machines or for machines with hollow/complex interiors. + * + * @return The minimum number of blocks connected to the machine for it to + * be assembled. */ protected abstract int getMinimumNumberOfBlocksForAssembledMachine(); /** - * Returns the maximum X dimension size of the machine, or -1 (DIMENSION_UNBOUNDED) to disable - * dimension checking in X. (This is not recommended.) - * @return The maximum X dimension size of the machine, or -1 + * Returns the maximum X dimension size of the machine, or -1 + * (DIMENSION_UNBOUNDED) to disable dimension checking in X. (This is not + * recommended.) + * + * @return The maximum X dimension size of the machine, or -1 */ protected abstract int getMaximumXSize(); /** - * Returns the maximum Z dimension size of the machine, or -1 (DIMENSION_UNBOUNDED) to disable - * dimension checking in X. (This is not recommended.) - * @return The maximum Z dimension size of the machine, or -1 + * Returns the maximum Z dimension size of the machine, or -1 + * (DIMENSION_UNBOUNDED) to disable dimension checking in X. (This is not + * recommended.) + * + * @return The maximum Z dimension size of the machine, or -1 */ protected abstract int getMaximumZSize(); /** - * Returns the maximum Y dimension size of the machine, or -1 (DIMENSION_UNBOUNDED) to disable - * dimension checking in X. (This is not recommended.) - * @return The maximum Y dimension size of the machine, or -1 + * Returns the maximum Y dimension size of the machine, or -1 + * (DIMENSION_UNBOUNDED) to disable dimension checking in X. (This is not + * recommended.) + * + * @return The maximum Y dimension size of the machine, or -1 */ protected abstract int getMaximumYSize(); - + /** - * Returns the minimum X dimension size of the machine. Must be at least 1, because nothing else makes sense. + * Returns the minimum X dimension size of the machine. Must be at least 1, + * because nothing else makes sense. + * * @return The minimum X dimension size of the machine */ - protected int getMinimumXSize() { return 1; } + protected int getMinimumXSize() + { + return 1; + } /** - * Returns the minimum Y dimension size of the machine. Must be at least 1, because nothing else makes sense. + * Returns the minimum Y dimension size of the machine. Must be at least 1, + * because nothing else makes sense. + * * @return The minimum Y dimension size of the machine */ - protected int getMinimumYSize() { return 1; } + protected int getMinimumYSize() + { + return 1; + } /** - * Returns the minimum Z dimension size of the machine. Must be at least 1, because nothing else makes sense. + * Returns the minimum Z dimension size of the machine. Must be at least 1, + * because nothing else makes sense. + * * @return The minimum Z dimension size of the machine */ - protected int getMinimumZSize() { return 1; } - - + protected int getMinimumZSize() + { + return 1; + } + /** - * @return An exception representing the last error encountered when trying to assemble this - * multiblock, or null if there is no error. + * @return An exception representing the last error encountered when trying + * to assemble this multiblock, or null if there is no error. */ - public MultiblockValidationException getLastValidationException() { return lastValidationException; } - + public MultiblockValidationException getLastValidationException() + { + return lastValidationException; + } + /** - * Checks if a machine is whole. If not, throws an exception with the reason why. + * Checks if a machine is whole. If not, throws an exception with the reason + * why. */ - protected abstract void isMachineWhole() throws MultiblockValidationException; - + protected abstract void isMachineWhole() + throws MultiblockValidationException; + /** - * Check if the machine is whole or not. - * If the machine was not whole, but now is, assemble the machine. - * If the machine was whole, but no longer is, disassemble the machine. - * @return + * Check if the machine is whole or not. If the machine was not whole, but + * now is, assemble the machine. If the machine was whole, but no longer is, + * disassemble the machine. + * + * @return */ - public void checkIfMachineIsWhole() { + public void checkIfMachineIsWhole() + { AssemblyState oldState = this.assemblyState; boolean isWhole; lastValidationException = null; - try { + try + { isMachineWhole(); isWhole = true; - } catch (MultiblockValidationException e) { + } catch (MultiblockValidationException e) + { lastValidationException = e; isWhole = false; } - - if(isWhole) { + + if (isWhole) + { // This will alter assembly state assembleMachine(oldState); - } - else if(oldState == AssemblyState.Assembled) { + } else if (oldState == AssemblyState.Assembled) + { // This will alter assembly state disassembleMachine(); } // Else Paused, do nothing } - + /** - * Called when a machine becomes "whole" and should begin - * functioning as a game-logically finished machine. - * Calls onMachineAssembled on all attached parts. + * Called when a machine becomes "whole" and should begin functioning as a + * game-logically finished machine. Calls onMachineAssembled on all attached + * parts. */ - private void assembleMachine(AssemblyState oldState) { - for(IMultiblockPart part : connectedParts) { + private void assembleMachine(AssemblyState oldState) + { + for (IMultiblockPart part : connectedParts) + { part.onMachineAssembled(this); } - + this.assemblyState = AssemblyState.Assembled; - if(oldState == assemblyState.Paused) { + if (oldState == assemblyState.Paused) + { onMachineRestored(); - } - else { + } else + { onMachineAssembled(); } } - + /** - * Called when the machine needs to be disassembled. - * It is not longer "whole" and should not be functional, usually - * as a result of a block being removed. - * Calls onMachineBroken on all attached parts. + * Called when the machine needs to be disassembled. It is not longer + * "whole" and should not be functional, usually as a result of a block + * being removed. Calls onMachineBroken on all attached parts. */ - private void disassembleMachine() { - for(IMultiblockPart part : connectedParts) { + private void disassembleMachine() + { + for (IMultiblockPart part : connectedParts) + { part.onMachineBroken(); } - + this.assemblyState = AssemblyState.Disassembled; onMachineDisassembled(); } - + /** - * Assimilate another controller into this controller. - * Acquire all of the other controller's blocks and attach them - * to this one. + * Assimilate another controller into this controller. Acquire all of the + * other controller's blocks and attach them to this one. * - * @param other The controller to merge into this one. + * @param other + * The controller to merge into this one. */ - public void assimilate(MultiblockControllerBase other) { + public void assimilate(MultiblockControllerBase other) + { CoordTriplet otherReferenceCoord = other.getReferenceCoord(); - if(otherReferenceCoord != null && getReferenceCoord().compareTo(otherReferenceCoord) >= 0) { - throw new IllegalArgumentException("The controller with the lowest minimum-coord value must consume the one with the higher coords"); + if (otherReferenceCoord != null + && getReferenceCoord().compareTo(otherReferenceCoord) >= 0) + { + throw new IllegalArgumentException( + "The controller with the lowest minimum-coord value must consume the one with the higher coords"); } TileEntity te; - Set partsToAcquire = new HashSet(other.connectedParts); + Set partsToAcquire = new HashSet( + other.connectedParts); - // releases all blocks and references gently so they can be incorporated into another multiblock + // releases all blocks and references gently so they can be incorporated + // into another multiblock other._onAssimilated(this); - - for(IMultiblockPart acquiredPart : partsToAcquire) { + + for (IMultiblockPart acquiredPart : partsToAcquire) + { // By definition, none of these can be the minimum block. - if(acquiredPart.isInvalid()) { continue; } - + if (acquiredPart.isInvalid()) + { + continue; + } + connectedParts.add(acquiredPart); acquiredPart.onAssimilated(this); this.onBlockAdded(acquiredPart); @@ -391,18 +516,26 @@ public abstract class MultiblockControllerBase { this.onAssimilate(other); other.onAssimilated(this); } - + /** - * Called when this machine is consumed by another controller. - * Essentially, forcibly tear down this object. - * @param otherController The controller consuming this controller. + * Called when this machine is consumed by another controller. Essentially, + * forcibly tear down this object. + * + * @param otherController + * The controller consuming this controller. */ - private void _onAssimilated(MultiblockControllerBase otherController) { - if(referenceCoord != null) { - if(worldObj.getChunkProvider().chunkExists(referenceCoord.getChunkX(), referenceCoord.getChunkZ())) { - TileEntity te = this.worldObj.getTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z); - if(te instanceof IMultiblockPart) { - ((IMultiblockPart)te).forfeitMultiblockSaveDelegate(); + private void _onAssimilated(MultiblockControllerBase otherController) + { + if (referenceCoord != null) + { + if (worldObj.getChunkProvider().chunkExists( + referenceCoord.getChunkX(), referenceCoord.getChunkZ())) + { + TileEntity te = this.worldObj.getTileEntity(referenceCoord.x, + referenceCoord.y, referenceCoord.z); + if (te instanceof IMultiblockPart) + { + ((IMultiblockPart) te).forfeitMultiblockSaveDelegate(); } } this.referenceCoord = null; @@ -410,59 +543,75 @@ public abstract class MultiblockControllerBase { connectedParts.clear(); } - + /** - * Callback. Called after this controller assimilates all the blocks - * from another controller. - * Use this to absorb that controller's game data. - * @param assimilated The controller whose uniqueness was added to our own. + * Callback. Called after this controller assimilates all the blocks from + * another controller. Use this to absorb that controller's game data. + * + * @param assimilated + * The controller whose uniqueness was added to our own. */ protected abstract void onAssimilate(MultiblockControllerBase assimilated); - + /** - * Callback. Called after this controller is assimilated into another controller. - * All blocks have been stripped out of this object and handed over to the - * other controller. - * This is intended primarily for cleanup. - * @param assimilator The controller which has assimilated this controller. + * Callback. Called after this controller is assimilated into another + * controller. All blocks have been stripped out of this object and handed + * over to the other controller. This is intended primarily for cleanup. + * + * @param assimilator + * The controller which has assimilated this controller. */ protected abstract void onAssimilated(MultiblockControllerBase assimilator); - + /** - * Driver for the update loop. If the machine is assembled, runs - * the game logic update method. - * @see erogenousbeef.coreTR.multiblock.MultiblockControllerBase#update() //TODO Fix this Javadoc + * Driver for the update loop. If the machine is assembled, runs the game + * logic update method. + * + * @see erogenousbeef.coreTR.multiblock.MultiblockControllerBase#update() + * //TODO Fix this Javadoc */ - public final void updateMultiblockEntity() { - if(connectedParts.isEmpty()) { + public final void updateMultiblockEntity() + { + if (connectedParts.isEmpty()) + { // This shouldn't happen, but just in case... MultiblockRegistry.addDeadController(this.worldObj, this); return; } - if(this.assemblyState != AssemblyState.Assembled) { + if (this.assemblyState != AssemblyState.Assembled) + { // Not assembled - don't run game logic return; } - if(worldObj.isRemote) { + if (worldObj.isRemote) + { updateClient(); - } - else if(updateServer()) { - // If this returns true, the server has changed its internal data. - // If our chunks are loaded (they should be), we must mark our chunks as dirty. - if(minimumCoord != null && maximumCoord != null && - this.worldObj.checkChunksExist(minimumCoord.x, minimumCoord.y, minimumCoord.z, - maximumCoord.x, maximumCoord.y, maximumCoord.z)) { + } else if (updateServer()) + { + // If this returns true, the server has changed its internal data. + // If our chunks are loaded (they should be), we must mark our + // chunks as dirty. + if (minimumCoord != null + && maximumCoord != null + && this.worldObj.checkChunksExist(minimumCoord.x, + minimumCoord.y, minimumCoord.z, maximumCoord.x, + maximumCoord.y, maximumCoord.z)) + { int minChunkX = minimumCoord.x >> 4; int minChunkZ = minimumCoord.z >> 4; int maxChunkX = maximumCoord.x >> 4; int maxChunkZ = maximumCoord.z >> 4; - - for(int x = minChunkX; x <= maxChunkX; x++) { - for(int z = minChunkZ; z <= maxChunkZ; z++) { - // Ensure that we save our data, even if the our save delegate is in has no TEs. - Chunk chunkToSave = this.worldObj.getChunkFromChunkCoords(x, z); + + for (int x = minChunkX; x <= maxChunkX; x++) + { + for (int z = minChunkZ; z <= maxChunkZ; z++) + { + // Ensure that we save our data, even if the our save + // delegate is in has no TEs. + Chunk chunkToSave = this.worldObj + .getChunkFromChunkCoords(x, z); chunkToSave.setChunkModified(); } } @@ -470,248 +619,416 @@ public abstract class MultiblockControllerBase { } // Else: Server, but no need to save data. } - + /** - * The server-side update loop! Use this similarly to a TileEntity's update loop. - * You do not need to call your superclass' update() if you're directly - * derived from MultiblockControllerBase. This is a callback. - * Note that this will only be called when the machine is assembled. - * @return True if the multiblock should save data, i.e. its internal game state has changed. False otherwise. + * The server-side update loop! Use this similarly to a TileEntity's update + * loop. You do not need to call your superclass' update() if you're + * directly derived from MultiblockControllerBase. This is a callback. Note + * that this will only be called when the machine is assembled. + * + * @return True if the multiblock should save data, i.e. its internal game + * state has changed. False otherwise. */ protected abstract boolean updateServer(); - + /** - * Client-side update loop. Generally, this shouldn't do anything, but if you want - * to do some interpolation or something, do it here. + * Client-side update loop. Generally, this shouldn't do anything, but if + * you want to do some interpolation or something, do it here. */ protected abstract void updateClient(); - + // Validation helpers /** * The "frame" consists of the outer edges of the machine, plus the corners. * - * @param world World object for the world in which this controller is located. - * @param x X coordinate of the block being tested - * @param y Y coordinate of the block being tested - * @param z Z coordinate of the block being tested - * @throws MultiblockValidationException if the tested block is not allowed on the machine's frame + * @param world + * World object for the world in which this controller is + * located. + * @param x + * X coordinate of the block being tested + * @param y + * Y coordinate of the block being tested + * @param z + * Z coordinate of the block being tested + * @throws MultiblockValidationException + * if the tested block is not allowed on the machine's frame */ - protected void isBlockGoodForFrame(World world, int x, int y, int z) throws MultiblockValidationException { - throw new MultiblockValidationException(String.format("%d, %d, %d - Block is not valid for use in the machine's interior", x, y, z)); + protected void isBlockGoodForFrame(World world, int x, int y, int z) + throws MultiblockValidationException + { + throw new MultiblockValidationException( + String.format( + "%d, %d, %d - Block is not valid for use in the machine's interior", + x, y, z)); } /** * The top consists of the top face, minus the edges. - * @param world World object for the world in which this controller is located. - * @param x X coordinate of the block being tested - * @param y Y coordinate of the block being tested - * @param z Z coordinate of the block being tested - * @throws MultiblockValidationException if the tested block is not allowed on the machine's top face + * + * @param world + * World object for the world in which this controller is + * located. + * @param x + * X coordinate of the block being tested + * @param y + * Y coordinate of the block being tested + * @param z + * Z coordinate of the block being tested + * @throws MultiblockValidationException + * if the tested block is not allowed on the machine's top face */ - protected void isBlockGoodForTop(World world, int x, int y, int z) throws MultiblockValidationException { - throw new MultiblockValidationException(String.format("%d, %d, %d - Block is not valid for use in the machine's interior", x, y, z)); + protected void isBlockGoodForTop(World world, int x, int y, int z) + throws MultiblockValidationException + { + throw new MultiblockValidationException( + String.format( + "%d, %d, %d - Block is not valid for use in the machine's interior", + x, y, z)); } - + /** * The bottom consists of the bottom face, minus the edges. - * @param world World object for the world in which this controller is located. - * @param x X coordinate of the block being tested - * @param y Y coordinate of the block being tested - * @param z Z coordinate of the block being tested - * @throws MultiblockValidationException if the tested block is not allowed on the machine's bottom face + * + * @param world + * World object for the world in which this controller is + * located. + * @param x + * X coordinate of the block being tested + * @param y + * Y coordinate of the block being tested + * @param z + * Z coordinate of the block being tested + * @throws MultiblockValidationException + * if the tested block is not allowed on the machine's bottom + * face */ - protected void isBlockGoodForBottom(World world, int x, int y, int z) throws MultiblockValidationException { - throw new MultiblockValidationException(String.format("%d, %d, %d - Block is not valid for use in the machine's interior", x, y, z)); + protected void isBlockGoodForBottom(World world, int x, int y, int z) + throws MultiblockValidationException + { + throw new MultiblockValidationException( + String.format( + "%d, %d, %d - Block is not valid for use in the machine's interior", + x, y, z)); } - + /** * The sides consists of the N/E/S/W-facing faces, minus the edges. - * @param world World object for the world in which this controller is located. - * @param x X coordinate of the block being tested - * @param y Y coordinate of the block being tested - * @param z Z coordinate of the block being tested - * @throws MultiblockValidationException if the tested block is not allowed on the machine's side faces + * + * @param world + * World object for the world in which this controller is + * located. + * @param x + * X coordinate of the block being tested + * @param y + * Y coordinate of the block being tested + * @param z + * Z coordinate of the block being tested + * @throws MultiblockValidationException + * if the tested block is not allowed on the machine's side + * faces */ - protected void isBlockGoodForSides(World world, int x, int y, int z) throws MultiblockValidationException { - throw new MultiblockValidationException(String.format("%d, %d, %d - Block is not valid for use in the machine's interior", x, y, z)); + protected void isBlockGoodForSides(World world, int x, int y, int z) + throws MultiblockValidationException + { + throw new MultiblockValidationException( + String.format( + "%d, %d, %d - Block is not valid for use in the machine's interior", + x, y, z)); } - + /** * The interior is any block that does not touch blocks outside the machine. - * @param world World object for the world in which this controller is located. - * @param x X coordinate of the block being tested - * @param y Y coordinate of the block being tested - * @param z Z coordinate of the block being tested - * @throws MultiblockValidationException if the tested block is not allowed in the machine's interior + * + * @param world + * World object for the world in which this controller is + * located. + * @param x + * X coordinate of the block being tested + * @param y + * Y coordinate of the block being tested + * @param z + * Z coordinate of the block being tested + * @throws MultiblockValidationException + * if the tested block is not allowed in the machine's interior */ - protected void isBlockGoodForInterior(World world, int x, int y, int z) throws MultiblockValidationException { - throw new MultiblockValidationException(String.format("%d, %d, %d - Block is not valid for use in the machine's interior", x, y, z)); + protected void isBlockGoodForInterior(World world, int x, int y, int z) + throws MultiblockValidationException + { + throw new MultiblockValidationException( + String.format( + "%d, %d, %d - Block is not valid for use in the machine's interior", + x, y, z)); } - + /** - * @return The reference coordinate, the block with the lowest x, y, z coordinates, evaluated in that order. + * @return The reference coordinate, the block with the lowest x, y, z + * coordinates, evaluated in that order. */ - public CoordTriplet getReferenceCoord() { - if(referenceCoord == null) { selectNewReferenceCoord(); } + public CoordTriplet getReferenceCoord() + { + if (referenceCoord == null) + { + selectNewReferenceCoord(); + } return referenceCoord; } - + /** * @return The number of blocks connected to this controller. */ - public int getNumConnectedBlocks() { return connectedParts.size(); } + public int getNumConnectedBlocks() + { + return connectedParts.size(); + } public abstract void writeToNBT(NBTTagCompound data); + public abstract void readFromNBT(NBTTagCompound data); /** * Force this multiblock to recalculate its minimum and maximum coordinates * from the list of connected parts. */ - public void recalculateMinMaxCoords() { - minimumCoord = new CoordTriplet(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - maximumCoord = new CoordTriplet(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE); + public void recalculateMinMaxCoords() + { + minimumCoord = new CoordTriplet(Integer.MAX_VALUE, Integer.MAX_VALUE, + Integer.MAX_VALUE); + maximumCoord = new CoordTriplet(Integer.MIN_VALUE, Integer.MIN_VALUE, + Integer.MIN_VALUE); - for(IMultiblockPart part : connectedParts) { - if(part.xCoord < minimumCoord.x) { minimumCoord.x = part.xCoord; } - if(part.xCoord > maximumCoord.x) { maximumCoord.x = part.xCoord; } - if(part.yCoord < minimumCoord.y) { minimumCoord.y = part.yCoord; } - if(part.yCoord > maximumCoord.y) { maximumCoord.y = part.yCoord; } - if(part.zCoord < minimumCoord.z) { minimumCoord.z = part.zCoord; } - if(part.zCoord > maximumCoord.z) { maximumCoord.z = part.zCoord; } + for (IMultiblockPart part : connectedParts) + { + if (part.xCoord < minimumCoord.x) + { + minimumCoord.x = part.xCoord; + } + if (part.xCoord > maximumCoord.x) + { + maximumCoord.x = part.xCoord; + } + if (part.yCoord < minimumCoord.y) + { + minimumCoord.y = part.yCoord; + } + if (part.yCoord > maximumCoord.y) + { + maximumCoord.y = part.yCoord; + } + if (part.zCoord < minimumCoord.z) + { + minimumCoord.z = part.zCoord; + } + if (part.zCoord > maximumCoord.z) + { + maximumCoord.z = part.zCoord; + } } } - + /** - * @return The minimum bounding-box coordinate containing this machine's blocks. + * @return The minimum bounding-box coordinate containing this machine's + * blocks. */ - public CoordTriplet getMinimumCoord() { - if(minimumCoord == null) { recalculateMinMaxCoords(); } + public CoordTriplet getMinimumCoord() + { + if (minimumCoord == null) + { + recalculateMinMaxCoords(); + } return minimumCoord.copy(); } /** - * @return The maximum bounding-box coordinate containing this machine's blocks. + * @return The maximum bounding-box coordinate containing this machine's + * blocks. */ - public CoordTriplet getMaximumCoord() { - if(maximumCoord == null) { recalculateMinMaxCoords(); } + public CoordTriplet getMaximumCoord() + { + if (maximumCoord == null) + { + recalculateMinMaxCoords(); + } return maximumCoord.copy(); } /** - * Called when the save delegate's tile entity is being asked for its description packet - * @param data A fresh compound tag to write your multiblock data into + * Called when the save delegate's tile entity is being asked for its + * description packet + * + * @param data + * A fresh compound tag to write your multiblock data into */ public abstract void formatDescriptionPacket(NBTTagCompound data); /** - * Called when the save delegate's tile entity receiving a description packet - * @param data A compound tag containing multiblock data to import + * Called when the save delegate's tile entity receiving a description + * packet + * + * @param data + * A compound tag containing multiblock data to import */ public abstract void decodeDescriptionPacket(NBTTagCompound data); /** * @return True if this controller has no associated blocks, false otherwise */ - public boolean isEmpty() { + public boolean isEmpty() + { return connectedParts.isEmpty(); } /** - * Tests whether this multiblock should consume the other multiblock - * and become the new multiblock master when the two multiblocks - * are adjacent. Assumes both multiblocks are the same type. - * @param otherController The other multiblock controller. - * @return True if this multiblock should consume the other, false otherwise. + * Tests whether this multiblock should consume the other multiblock and + * become the new multiblock master when the two multiblocks are adjacent. + * Assumes both multiblocks are the same type. + * + * @param otherController + * The other multiblock controller. + * @return True if this multiblock should consume the other, false + * otherwise. */ - public boolean shouldConsume(MultiblockControllerBase otherController) { - if(!otherController.getClass().equals(getClass())) { - throw new IllegalArgumentException("Attempting to merge two multiblocks with different master classes - this should never happen!"); + public boolean shouldConsume(MultiblockControllerBase otherController) + { + if (!otherController.getClass().equals(getClass())) + { + throw new IllegalArgumentException( + "Attempting to merge two multiblocks with different master classes - this should never happen!"); } - - if(otherController == this) { return false; } // Don't be silly, don't eat yourself. - + + if (otherController == this) + { + return false; + } // Don't be silly, don't eat yourself. + int res = _shouldConsume(otherController); - if(res < 0) { return true; } - else if(res > 0) { return false; } - else { + if (res < 0) + { + return true; + } else if (res > 0) + { + return false; + } else + { // Strip dead parts from both and retry - BeefCoreLog.warning("[%s] Encountered two controllers with the same reference coordinate. Auditing connected parts and retrying.", worldObj.isRemote?"CLIENT":"SERVER"); + BeefCoreLog + .warning( + "[%s] Encountered two controllers with the same reference coordinate. Auditing connected parts and retrying.", + worldObj.isRemote ? "CLIENT" : "SERVER"); auditParts(); otherController.auditParts(); - + res = _shouldConsume(otherController); - if(res < 0) { return true; } - else if(res > 0) { return false; } - else { - BeefCoreLog.error("My Controller (%d): size (%d), parts: %s", hashCode(), connectedParts.size(), getPartsListString()); - BeefCoreLog.error("Other Controller (%d): size (%d), coords: %s", otherController.hashCode(), otherController.connectedParts.size(), otherController.getPartsListString()); - throw new IllegalArgumentException("[" + (worldObj.isRemote?"CLIENT":"SERVER") + "] Two controllers with the same reference coord that somehow both have valid parts - this should never happen!"); + if (res < 0) + { + return true; + } else if (res > 0) + { + return false; + } else + { + BeefCoreLog + .error("My Controller (%d): size (%d), parts: %s", + hashCode(), connectedParts.size(), + getPartsListString()); + BeefCoreLog.error( + "Other Controller (%d): size (%d), coords: %s", + otherController.hashCode(), + otherController.connectedParts.size(), + otherController.getPartsListString()); + throw new IllegalArgumentException( + "[" + + (worldObj.isRemote ? "CLIENT" : "SERVER") + + "] Two controllers with the same reference coord that somehow both have valid parts - this should never happen!"); } } } - - private int _shouldConsume(MultiblockControllerBase otherController) { + + private int _shouldConsume(MultiblockControllerBase otherController) + { CoordTriplet myCoord = getReferenceCoord(); CoordTriplet theirCoord = otherController.getReferenceCoord(); - - // Always consume other controllers if their reference coordinate is null - this means they're empty and can be assimilated on the cheap - if(theirCoord == null) { return -1; } - else { return myCoord.compareTo(theirCoord); } + + // Always consume other controllers if their reference coordinate is + // null - this means they're empty and can be assimilated on the cheap + if (theirCoord == null) + { + return -1; + } else + { + return myCoord.compareTo(theirCoord); + } } - - private String getPartsListString() { + + private String getPartsListString() + { StringBuilder sb = new StringBuilder(); boolean first = true; - for(IMultiblockPart part : connectedParts) { - if(!first) { + for (IMultiblockPart part : connectedParts) + { + if (!first) + { sb.append(", "); } - sb.append(String.format("(%d: %d, %d, %d)", part.hashCode(), part.xCoord, part.yCoord, part.zCoord)); + sb.append(String.format("(%d: %d, %d, %d)", part.hashCode(), + part.xCoord, part.yCoord, part.zCoord)); first = false; } - + return sb.toString(); } - + /** - * Checks all of the parts in the controller. If any are dead or do not exist in the world, they are removed. + * Checks all of the parts in the controller. If any are dead or do not + * exist in the world, they are removed. */ - private void auditParts() { + private void auditParts() + { HashSet deadParts = new HashSet(); - for(IMultiblockPart part : connectedParts) { - if(part.isInvalid() || worldObj.getTileEntity(part.xCoord, part.yCoord, part.zCoord) != part) { + for (IMultiblockPart part : connectedParts) + { + if (part.isInvalid() + || worldObj.getTileEntity(part.xCoord, part.yCoord, + part.zCoord) != part) + { onDetachBlock(part); deadParts.add(part); } } - + connectedParts.removeAll(deadParts); - BeefCoreLog.warning("[%s] Controller found %d dead parts during an audit, %d parts remain attached", worldObj.isRemote?"CLIENT":"SERVER", deadParts.size(), connectedParts.size()); + BeefCoreLog + .warning( + "[%s] Controller found %d dead parts during an audit, %d parts remain attached", + worldObj.isRemote ? "CLIENT" : "SERVER", + deadParts.size(), connectedParts.size()); } /** - * Called when this machine may need to check for blocks that are no - * longer physically connected to the reference coordinate. + * Called when this machine may need to check for blocks that are no longer + * physically connected to the reference coordinate. + * * @return */ - public Set checkForDisconnections() { - if(!this.shouldCheckForDisconnections) { + public Set checkForDisconnections() + { + if (!this.shouldCheckForDisconnections) + { return null; } - - if(this.isEmpty()) { + + if (this.isEmpty()) + { MultiblockRegistry.addDeadController(worldObj, this); return null; } - + TileEntity te; IChunkProvider chunkProvider = worldObj.getChunkProvider(); // Invalidate our reference coord, we'll recalculate it shortly referenceCoord = null; - + // Reset visitations and find the minimum coordinate Set deadParts = new HashSet(); CoordTriplet c; @@ -719,15 +1036,19 @@ public abstract class MultiblockControllerBase { int originalSize = connectedParts.size(); - for(IMultiblockPart part : connectedParts) { + for (IMultiblockPart part : connectedParts) + { // This happens during chunk unload. - if(!chunkProvider.chunkExists(part.xCoord >> 4, part.zCoord >> 4) || part.isInvalid()) { + if (!chunkProvider.chunkExists(part.xCoord >> 4, part.zCoord >> 4) + || part.isInvalid()) + { deadParts.add(part); onDetachBlock(part); continue; } - - if(worldObj.getTileEntity(part.xCoord, part.yCoord, part.zCoord) != part) { + + if (worldObj.getTileEntity(part.xCoord, part.yCoord, part.zCoord) != part) + { deadParts.add(part); onDetachBlock(part); continue; @@ -735,62 +1056,73 @@ public abstract class MultiblockControllerBase { part.setUnvisited(); part.forfeitMultiblockSaveDelegate(); - + c = part.getWorldLocation(); - if(referenceCoord == null) { + if (referenceCoord == null) + { referenceCoord = c; referencePart = part; - } - else if(c.compareTo(referenceCoord) < 0) { + } else if (c.compareTo(referenceCoord) < 0) + { referenceCoord = c; referencePart = part; } } - + connectedParts.removeAll(deadParts); deadParts.clear(); - - if(referencePart == null || isEmpty()) { - // There are no valid parts remaining. The entire multiblock was unloaded during a chunk unload. Halt. + + if (referencePart == null || isEmpty()) + { + // There are no valid parts remaining. The entire multiblock was + // unloaded during a chunk unload. Halt. shouldCheckForDisconnections = false; MultiblockRegistry.addDeadController(worldObj, this); return null; - } - else { + } else + { referencePart.becomeMultiblockSaveDelegate(); } - // Now visit all connected parts, breadth-first, starting from reference coord's part + // Now visit all connected parts, breadth-first, starting from reference + // coord's part IMultiblockPart part; LinkedList partsToCheck = new LinkedList(); IMultiblockPart[] nearbyParts = null; int visitedParts = 0; partsToCheck.add(referencePart); - - while(!partsToCheck.isEmpty()) { + + while (!partsToCheck.isEmpty()) + { part = partsToCheck.removeFirst(); part.setVisited(); visitedParts++; - nearbyParts = part.getNeighboringParts(); // Chunk-safe on server, but not on client - for(IMultiblockPart nearbyPart : nearbyParts) { + nearbyParts = part.getNeighboringParts(); // Chunk-safe on server, + // but not on client + for (IMultiblockPart nearbyPart : nearbyParts) + { // Ignore different machines - if(nearbyPart.getMultiblockController() != this) { + if (nearbyPart.getMultiblockController() != this) + { continue; } - if(!nearbyPart.isVisited()) { + if (!nearbyPart.isVisited()) + { nearbyPart.setVisited(); partsToCheck.add(nearbyPart); } } } - + // Finally, remove all parts that remain disconnected. Set removedParts = new HashSet(); - for(IMultiblockPart orphanCandidate : connectedParts) { - if (!orphanCandidate.isVisited()) { + for (IMultiblockPart orphanCandidate : connectedParts) + { + if (!orphanCandidate.isVisited()) + { deadParts.add(orphanCandidate); orphanCandidate.onOrphaned(this, originalSize, visitedParts); onDetachBlock(orphanCandidate); @@ -800,32 +1132,40 @@ public abstract class MultiblockControllerBase { // Trim any blocks that were invalid, or were removed. connectedParts.removeAll(deadParts); - + // Cleanup. Not necessary, really. deadParts.clear(); - + // Juuuust in case. - if(referenceCoord == null) { + if (referenceCoord == null) + { selectNewReferenceCoord(); } - + // We've run the checks from here on out. shouldCheckForDisconnections = false; - + return removedParts; } /** - * Detach all parts. Return a set of all parts which still - * have a valid tile entity. Chunk-safe. + * Detach all parts. Return a set of all parts which still have a valid tile + * entity. Chunk-safe. + * * @return A set of all parts which still have a valid tile entity. */ - public Set detachAllBlocks() { - if(worldObj == null) { return new HashSet(); } - + public Set detachAllBlocks() + { + if (worldObj == null) + { + return new HashSet(); + } + IChunkProvider chunkProvider = worldObj.getChunkProvider(); - for(IMultiblockPart part : connectedParts) { - if(chunkProvider.chunkExists(part.xCoord >> 4, part.zCoord >> 4)) { + for (IMultiblockPart part : connectedParts) + { + if (chunkProvider.chunkExists(part.xCoord >> 4, part.zCoord >> 4)) + { onDetachBlock(part); } } @@ -836,70 +1176,93 @@ public abstract class MultiblockControllerBase { } /** - * @return True if this multiblock machine is considered assembled and ready to go. + * @return True if this multiblock machine is considered assembled and ready + * to go. */ - public boolean isAssembled() { + public boolean isAssembled() + { return this.assemblyState == AssemblyState.Assembled; } - - private void selectNewReferenceCoord() { + + private void selectNewReferenceCoord() + { IChunkProvider chunkProvider = worldObj.getChunkProvider(); TileEntity theChosenOne = null; referenceCoord = null; - for(IMultiblockPart part : connectedParts) { - if(part.isInvalid() || !chunkProvider.chunkExists(part.xCoord >> 4, part.zCoord >> 4)) { - // Chunk is unloading, skip this coord to prevent chunk thrashing + for (IMultiblockPart part : connectedParts) + { + if (part.isInvalid() + || !chunkProvider.chunkExists(part.xCoord >> 4, + part.zCoord >> 4)) + { + // Chunk is unloading, skip this coord to prevent chunk + // thrashing continue; } - if(referenceCoord == null || referenceCoord.compareTo(part.xCoord, part.yCoord, part.zCoord) > 0) { + if (referenceCoord == null + || referenceCoord.compareTo(part.xCoord, part.yCoord, + part.zCoord) > 0) + { referenceCoord = part.getWorldLocation(); theChosenOne = part; } } - if(theChosenOne != null) { - ((IMultiblockPart)theChosenOne).becomeMultiblockSaveDelegate(); + if (theChosenOne != null) + { + ((IMultiblockPart) theChosenOne).becomeMultiblockSaveDelegate(); } } - + /** * Marks the reference coord dirty & updateable. * - * On the server, this will mark the for a data-update, so that - * nearby clients will receive an updated description packet from the server - * after a short time. The block's chunk will also be marked dirty and the - * block's chunk will be saved to disk the next time chunks are saved. + * On the server, this will mark the for a data-update, so that nearby + * clients will receive an updated description packet from the server after + * a short time. The block's chunk will also be marked dirty and the block's + * chunk will be saved to disk the next time chunks are saved. * * On the client, this will mark the block for a rendering update. */ - protected void markReferenceCoordForUpdate() { + protected void markReferenceCoordForUpdate() + { CoordTriplet rc = getReferenceCoord(); - if(worldObj != null && rc != null) { + if (worldObj != null && rc != null) + { worldObj.markBlockForUpdate(rc.x, rc.y, rc.z); } } - + /** * Marks the reference coord dirty. * - * On the server, this marks the reference coord's chunk as dirty; the block (and chunk) - * will be saved to disk the next time chunks are saved. This does NOT mark it dirty for - * a description-packet update. + * On the server, this marks the reference coord's chunk as dirty; the block + * (and chunk) will be saved to disk the next time chunks are saved. This + * does NOT mark it dirty for a description-packet update. * * On the client, does nothing. + * * @see MultiblockControllerBase#markReferenceCoordForUpdate() */ - protected void markReferenceCoordDirty() { - if(worldObj == null || worldObj.isRemote) { return; } + protected void markReferenceCoordDirty() + { + if (worldObj == null || worldObj.isRemote) + { + return; + } CoordTriplet referenceCoord = getReferenceCoord(); - if(referenceCoord == null) { return; } + if (referenceCoord == null) + { + return; + } - TileEntity saveTe = worldObj.getTileEntity(referenceCoord.x, referenceCoord.y, referenceCoord.z); - worldObj.markTileEntityChunkModified(referenceCoord.x, referenceCoord.y, referenceCoord.z, saveTe); + TileEntity saveTe = worldObj.getTileEntity(referenceCoord.x, + referenceCoord.y, referenceCoord.z); + worldObj.markTileEntityChunkModified(referenceCoord.x, + referenceCoord.y, referenceCoord.z, saveTe); } - } \ No newline at end of file diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockEventHandler.java b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockEventHandler.java index 10560258b..b188eeeda 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockEventHandler.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockEventHandler.java @@ -8,22 +8,25 @@ import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; /** - * In your mod, subscribe this on both the client and server sides side to handle chunk - * load events for your multiblock machines. - * Chunks can load asynchronously in environments like MCPC+, so we cannot - * process any blocks that are in chunks which are still loading. + * In your mod, subscribe this on both the client and server sides side to + * handle chunk load events for your multiblock machines. Chunks can load + * asynchronously in environments like MCPC+, so we cannot process any blocks + * that are in chunks which are still loading. */ public class MultiblockEventHandler { @SubscribeEvent(priority = EventPriority.NORMAL) - public void onChunkLoad(ChunkEvent.Load loadEvent) { + public void onChunkLoad(ChunkEvent.Load loadEvent) + { Chunk chunk = loadEvent.getChunk(); World world = loadEvent.world; - MultiblockRegistry.onChunkLoaded(world, chunk.xPosition, chunk.zPosition); + MultiblockRegistry.onChunkLoaded(world, chunk.xPosition, + chunk.zPosition); } // Cleanup, for nice memory usageness @SubscribeEvent(priority = EventPriority.NORMAL) - public void onWorldUnload(WorldEvent.Unload unloadWorldEvent) { + public void onWorldUnload(WorldEvent.Unload unloadWorldEvent) + { MultiblockRegistry.onWorldUnloaded(unloadWorldEvent.world); } } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockRegistry.java b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockRegistry.java index 899d03696..9559b0a54 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockRegistry.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockRegistry.java @@ -7,122 +7,170 @@ import net.minecraft.world.World; import erogenousbeef.coreTR.common.BeefCoreLog; /** - * This is a very static singleton registry class which directs incoming events to sub-objects, which - * actually manage each individual world's multiblocks. + * This is a very static singleton registry class which directs incoming events + * to sub-objects, which actually manage each individual world's multiblocks. + * * @author Erogenous Beef */ public class MultiblockRegistry { // World > WorldRegistry map private static HashMap registries = new HashMap(); - + /** * Called before Tile Entities are ticked in the world. Do bookkeeping here. - * @param world The world being ticked + * + * @param world + * The world being ticked */ - public static void tickStart(World world) { - if(registries.containsKey(world)) { + public static void tickStart(World world) + { + if (registries.containsKey(world)) + { MultiblockWorldRegistry registry = registries.get(world); registry.processMultiblockChanges(); registry.tickStart(); } } - + /** * Called when the world has finished loading a chunk. - * @param world The world which has finished loading a chunk - * @param chunkX The X coordinate of the chunk - * @param chunkZ The Z coordinate of the chunk + * + * @param world + * The world which has finished loading a chunk + * @param chunkX + * The X coordinate of the chunk + * @param chunkZ + * The Z coordinate of the chunk */ - public static void onChunkLoaded(World world, int chunkX, int chunkZ) { - if(registries.containsKey(world)) { + public static void onChunkLoaded(World world, int chunkX, int chunkZ) + { + if (registries.containsKey(world)) + { registries.get(world).onChunkLoaded(chunkX, chunkZ); } } /** - * Register a new part in the system. The part has been created either through user action or via a chunk loading. - * @param world The world into which this part is loading. - * @param part The part being loaded. + * Register a new part in the system. The part has been created either + * through user action or via a chunk loading. + * + * @param world + * The world into which this part is loading. + * @param part + * The part being loaded. */ - public static void onPartAdded(World world, IMultiblockPart part) { + public static void onPartAdded(World world, IMultiblockPart part) + { MultiblockWorldRegistry registry = getOrCreateRegistry(world); registry.onPartAdded(part); } - + /** * Call to remove a part from world lists. - * @param world The world from which a multiblock part is being removed. - * @param part The part being removed. + * + * @param world + * The world from which a multiblock part is being removed. + * @param part + * The part being removed. */ - public static void onPartRemovedFromWorld(World world, IMultiblockPart part) { - if(registries.containsKey(world)) { + public static void onPartRemovedFromWorld(World world, IMultiblockPart part) + { + if (registries.containsKey(world)) + { registries.get(world).onPartRemovedFromWorld(part); } - + } - /** - * Called whenever a world is unloaded. Unload the relevant registry, if we have one. - * @param world The world being unloaded. + * Called whenever a world is unloaded. Unload the relevant registry, if we + * have one. + * + * @param world + * The world being unloaded. */ - public static void onWorldUnloaded(World world) { - if(registries.containsKey(world)) { + public static void onWorldUnloaded(World world) + { + if (registries.containsKey(world)) + { registries.get(world).onWorldUnloaded(); registries.remove(world); } } /** - * Call to mark a controller as dirty. Dirty means that parts have - * been added or removed this tick. - * @param world The world containing the multiblock - * @param controller The dirty controller + * Call to mark a controller as dirty. Dirty means that parts have been + * added or removed this tick. + * + * @param world + * The world containing the multiblock + * @param controller + * The dirty controller */ public static void addDirtyController(World world, - MultiblockControllerBase controller) { - if(registries.containsKey(world)) { + MultiblockControllerBase controller) + { + if (registries.containsKey(world)) + { registries.get(world).addDirtyController(controller); - } - else { - throw new IllegalArgumentException("Adding a dirty controller to a world that has no registered controllers!"); - } - } - - /** - * Call to mark a controller as dead. It should only be marked as dead - * when it has no connected parts. It will be removed after the next world tick. - * @param world The world formerly containing the multiblock - * @param controller The dead controller - */ - public static void addDeadController(World world, MultiblockControllerBase controller) { - if(registries.containsKey(world)) { - registries.get(world).addDeadController(controller); - } - else { - BeefCoreLog.warning("Controller %d in world %s marked as dead, but that world is not tracked! Controller is being ignored.", controller.hashCode(), world); + } else + { + throw new IllegalArgumentException( + "Adding a dirty controller to a world that has no registered controllers!"); } } /** - * @param world The world whose controllers you wish to retrieve. - * @return An unmodifiable set of controllers active in the given world, or null if there are none. + * Call to mark a controller as dead. It should only be marked as dead when + * it has no connected parts. It will be removed after the next world tick. + * + * @param world + * The world formerly containing the multiblock + * @param controller + * The dead controller */ - public static Set getControllersFromWorld(World world) { - if(registries.containsKey(world)) { + public static void addDeadController(World world, + MultiblockControllerBase controller) + { + if (registries.containsKey(world)) + { + registries.get(world).addDeadController(controller); + } else + { + BeefCoreLog + .warning( + "Controller %d in world %s marked as dead, but that world is not tracked! Controller is being ignored.", + controller.hashCode(), world); + } + } + + /** + * @param world + * The world whose controllers you wish to retrieve. + * @return An unmodifiable set of controllers active in the given world, or + * null if there are none. + */ + public static Set getControllersFromWorld( + World world) + { + if (registries.containsKey(world)) + { return registries.get(world).getControllers(); } return null; } - - /// *** PRIVATE HELPERS *** /// - - private static MultiblockWorldRegistry getOrCreateRegistry(World world) { - if(registries.containsKey(world)) { + + // / *** PRIVATE HELPERS *** /// + + private static MultiblockWorldRegistry getOrCreateRegistry(World world) + { + if (registries.containsKey(world)) + { return registries.get(world); - } - else { - MultiblockWorldRegistry newRegistry = new MultiblockWorldRegistry(world); + } else + { + MultiblockWorldRegistry newRegistry = new MultiblockWorldRegistry( + world); registries.put(world, newRegistry); return newRegistry; } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockServerTickHandler.java b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockServerTickHandler.java index 2dd726d8d..4d7f185df 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockServerTickHandler.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockServerTickHandler.java @@ -4,20 +4,21 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; /** - * This is a generic multiblock tick handler. If you are using this code on your own, - * you will need to register this with the Forge TickRegistry on both the - * client AND server sides. - * Note that different types of ticks run on different parts of the system. - * CLIENT ticks only run on the client, at the start/end of each game loop. - * SERVER and WORLD ticks only run on the server. - * WORLDLOAD ticks run only on the server, and only when worlds are loaded. + * This is a generic multiblock tick handler. If you are using this code on your + * own, you will need to register this with the Forge TickRegistry on both the + * client AND server sides. Note that different types of ticks run on different + * parts of the system. CLIENT ticks only run on the client, at the start/end of + * each game loop. SERVER and WORLD ticks only run on the server. WORLDLOAD + * ticks run only on the server, and only when worlds are loaded. */ public class MultiblockServerTickHandler { - @SubscribeEvent - public void onWorldTick(TickEvent.WorldTickEvent event) { - if(event.phase == TickEvent.Phase.START) { - MultiblockRegistry.tickStart(event.world); - } - } + @SubscribeEvent + public void onWorldTick(TickEvent.WorldTickEvent event) + { + if (event.phase == TickEvent.Phase.START) + { + MultiblockRegistry.tickStart(event.world); + } + } } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockTileEntityBase.java b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockTileEntityBase.java index ac7396fc8..b59668420 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockTileEntityBase.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockTileEntityBase.java @@ -15,18 +15,20 @@ import erogenousbeef.coreTR.common.BeefCoreLog; import erogenousbeef.coreTR.common.CoordTriplet; /** - * Base logic class for Multiblock-connected tile entities. Most multiblock machines - * should derive from this and implement their game logic in certain abstract methods. + * Base logic class for Multiblock-connected tile entities. Most multiblock + * machines should derive from this and implement their game logic in certain + * abstract methods. */ public abstract class MultiblockTileEntityBase extends IMultiblockPart { private MultiblockControllerBase controller; private boolean visited; - + private boolean saveMultiblockData; private NBTTagCompound cachedMultiblockData; private boolean paused; - public MultiblockTileEntityBase() { + public MultiblockTileEntityBase() + { super(); controller = null; visited = false; @@ -35,36 +37,45 @@ public abstract class MultiblockTileEntityBase extends IMultiblockPart { cachedMultiblockData = null; } - ///// Multiblock Connection Base Logic + // /// Multiblock Connection Base Logic @Override - public Set attachToNeighbors() { + public Set attachToNeighbors() + { Set controllers = null; MultiblockControllerBase bestController = null; - + // Look for a compatible controller in our neighboring parts. IMultiblockPart[] partsToCheck = getNeighboringParts(); - for(IMultiblockPart neighborPart : partsToCheck) { - if(neighborPart.isConnected()) { - MultiblockControllerBase candidate = neighborPart.getMultiblockController(); - if(!candidate.getClass().equals(this.getMultiblockControllerType())) { + for (IMultiblockPart neighborPart : partsToCheck) + { + if (neighborPart.isConnected()) + { + MultiblockControllerBase candidate = neighborPart + .getMultiblockController(); + if (!candidate.getClass().equals( + this.getMultiblockControllerType())) + { // Skip multiblocks with incompatible types continue; } - - if(controllers == null) { + + if (controllers == null) + { controllers = new HashSet(); bestController = candidate; - } - else if(!controllers.contains(candidate) && candidate.shouldConsume(bestController)) { + } else if (!controllers.contains(candidate) + && candidate.shouldConsume(bestController)) + { bestController = candidate; } controllers.add(candidate); } } - + // If we've located a valid neighboring controller, attach to it. - if(bestController != null) { + if (bestController != null) + { // attachBlock will call onAttached, which will set the controller. this.controller = bestController; bestController.attachBlock(this); @@ -74,152 +85,193 @@ public abstract class MultiblockTileEntityBase extends IMultiblockPart { } @Override - public void assertDetached() { - if(this.controller != null) { - BeefCoreLog.info("[assert] Part @ (%d, %d, %d) should be detached already, but detected that it was not. This is not a fatal error, and will be repaired, but is unusual.", xCoord, yCoord, zCoord); + public void assertDetached() + { + if (this.controller != null) + { + BeefCoreLog + .info("[assert] Part @ (%d, %d, %d) should be detached already, but detected that it was not. This is not a fatal error, and will be repaired, but is unusual.", + xCoord, yCoord, zCoord); this.controller = null; } } - - ///// Overrides from base TileEntity methods - + + // /// Overrides from base TileEntity methods + @Override - public void readFromNBT(NBTTagCompound data) { + public void readFromNBT(NBTTagCompound data) + { super.readFromNBT(data); - - // We can't directly initialize a multiblock controller yet, so we cache the data here until - // we receive a validate() call, which creates the controller and hands off the cached data. - if(data.hasKey("multiblockData")) { + + // We can't directly initialize a multiblock controller yet, so we cache + // the data here until + // we receive a validate() call, which creates the controller and hands + // off the cached data. + if (data.hasKey("multiblockData")) + { this.cachedMultiblockData = data.getCompoundTag("multiblockData"); } } - + @Override - public void writeToNBT(NBTTagCompound data) { + public void writeToNBT(NBTTagCompound data) + { super.writeToNBT(data); - if(isMultiblockSaveDelegate() && isConnected()) { + if (isMultiblockSaveDelegate() && isConnected()) + { NBTTagCompound multiblockData = new NBTTagCompound(); this.controller.writeToNBT(multiblockData); data.setTag("multiblockData", multiblockData); } } - + /** - * Generally, TileEntities that are part of a multiblock should not subscribe to updates - * from the main game loop. Instead, you should have lists of TileEntities which need to - * be notified during an update() in your Controller and perform callbacks from there. + * Generally, TileEntities that are part of a multiblock should not + * subscribe to updates from the main game loop. Instead, you should have + * lists of TileEntities which need to be notified during an update() in + * your Controller and perform callbacks from there. + * * @see net.minecraft.tileentity.TileEntity#canUpdate() */ @Override - public boolean canUpdate() { return false; } - + public boolean canUpdate() + { + return false; + } + /** - * Called when a block is removed by game actions, such as a player breaking the block - * or the block being changed into another block. + * Called when a block is removed by game actions, such as a player breaking + * the block or the block being changed into another block. + * * @see net.minecraft.tileentity.TileEntity#invalidate() */ @Override - public void invalidate() { + public void invalidate() + { super.invalidate(); detachSelf(false); } - + /** - * Called from Minecraft's tile entity loop, after all tile entities have been ticked, - * as the chunk in which this tile entity is contained is unloading. - * Happens before the Forge TickEnd event. + * Called from Minecraft's tile entity loop, after all tile entities have + * been ticked, as the chunk in which this tile entity is contained is + * unloading. Happens before the Forge TickEnd event. + * * @see net.minecraft.tileentity.TileEntity#onChunkUnload() */ @Override - public void onChunkUnload() { + public void onChunkUnload() + { super.onChunkUnload(); detachSelf(true); } /** - * This is called when a block is being marked as valid by the chunk, but has not yet fully - * been placed into the world's TileEntity cache. this.worldObj, xCoord, yCoord and zCoord have - * been initialized, but any attempts to read data about the world can cause infinite loops - - * if you call getTileEntity on this TileEntity's coordinate from within validate(), you will - * blow your call stack. + * This is called when a block is being marked as valid by the chunk, but + * has not yet fully been placed into the world's TileEntity cache. + * this.worldObj, xCoord, yCoord and zCoord have been initialized, but any + * attempts to read data about the world can cause infinite loops - if you + * call getTileEntity on this TileEntity's coordinate from within + * validate(), you will blow your call stack. * * TL;DR: Here there be dragons. + * * @see net.minecraft.tileentity.TileEntity#validate() */ @Override - public void validate() { + public void validate() + { super.validate(); MultiblockRegistry.onPartAdded(this.worldObj, this); } // Network Communication @Override - public Packet getDescriptionPacket() { + public Packet getDescriptionPacket() + { NBTTagCompound packetData = new NBTTagCompound(); encodeDescriptionPacket(packetData); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, packetData); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, + packetData); } - + @Override - public void onDataPacket(NetworkManager network, S35PacketUpdateTileEntity packet) { + public void onDataPacket(NetworkManager network, + S35PacketUpdateTileEntity packet) + { decodeDescriptionPacket(packet.func_148857_g()); } - - ///// Things to override in most implementations (IMultiblockPart) + + // /// Things to override in most implementations (IMultiblockPart) /** - * Override this to easily modify the description packet's data without having - * to worry about sending the packet itself. - * Decode this data in decodeDescriptionPacket. - * @param packetData An NBT compound tag into which you should write your custom description data. + * Override this to easily modify the description packet's data without + * having to worry about sending the packet itself. Decode this data in + * decodeDescriptionPacket. + * + * @param packetData + * An NBT compound tag into which you should write your custom + * description data. * @see erogenousbeef.coreTR.multiblock.MultiblockTileEntityBase#decodeDescriptionPacket(NBTTagCompound) */ - protected void encodeDescriptionPacket(NBTTagCompound packetData) { - if(this.isMultiblockSaveDelegate() && isConnected()) { + protected void encodeDescriptionPacket(NBTTagCompound packetData) + { + if (this.isMultiblockSaveDelegate() && isConnected()) + { NBTTagCompound tag = new NBTTagCompound(); getMultiblockController().formatDescriptionPacket(tag); packetData.setTag("multiblockData", tag); } } - + /** - * Override this to easily read in data from a TileEntity's description packet. - * Encoded in encodeDescriptionPacket. - * @param packetData The NBT data from the tile entity's description packet. + * Override this to easily read in data from a TileEntity's description + * packet. Encoded in encodeDescriptionPacket. + * + * @param packetData + * The NBT data from the tile entity's description packet. * @see erogenousbeef.coreTR.multiblock.MultiblockTileEntityBase#encodeDescriptionPacket(NBTTagCompound) */ - protected void decodeDescriptionPacket(NBTTagCompound packetData) { - if(packetData.hasKey("multiblockData")) { + protected void decodeDescriptionPacket(NBTTagCompound packetData) + { + if (packetData.hasKey("multiblockData")) + { NBTTagCompound tag = packetData.getCompoundTag("multiblockData"); - if(isConnected()) { + if (isConnected()) + { getMultiblockController().decodeDescriptionPacket(tag); - } - else { - // This part hasn't been added to a machine yet, so cache the data. + } else + { + // This part hasn't been added to a machine yet, so cache the + // data. this.cachedMultiblockData = tag; } } } @Override - public boolean hasMultiblockSaveData() { + public boolean hasMultiblockSaveData() + { return this.cachedMultiblockData != null; } - + @Override - public NBTTagCompound getMultiblockSaveData() { + public NBTTagCompound getMultiblockSaveData() + { return this.cachedMultiblockData; } - + @Override - public void onMultiblockDataAssimilated() { + public void onMultiblockDataAssimilated() + { this.cachedMultiblockData = null; } - ///// Game logic callbacks (IMultiblockPart) - + // /// Game logic callbacks (IMultiblockPart) + @Override - public abstract void onMachineAssembled(MultiblockControllerBase multiblockControllerBase); + public abstract void onMachineAssembled( + MultiblockControllerBase multiblockControllerBase); @Override public abstract void onMachineBroken(); @@ -230,120 +282,148 @@ public abstract class MultiblockTileEntityBase extends IMultiblockPart { @Override public abstract void onMachineDeactivated(); - ///// Miscellaneous multiblock-assembly callbacks and support methods (IMultiblockPart) - + // /// Miscellaneous multiblock-assembly callbacks and support methods + // (IMultiblockPart) + @Override - public boolean isConnected() { + public boolean isConnected() + { return (controller != null); } @Override - public MultiblockControllerBase getMultiblockController() { + public MultiblockControllerBase getMultiblockController() + { return controller; } @Override - public CoordTriplet getWorldLocation() { + public CoordTriplet getWorldLocation() + { return new CoordTriplet(this.xCoord, this.yCoord, this.zCoord); } - + @Override - public void becomeMultiblockSaveDelegate() { + public void becomeMultiblockSaveDelegate() + { this.saveMultiblockData = true; } @Override - public void forfeitMultiblockSaveDelegate() { + public void forfeitMultiblockSaveDelegate() + { this.saveMultiblockData = false; } - - @Override - public boolean isMultiblockSaveDelegate() { return this.saveMultiblockData; } @Override - public void setUnvisited() { + public boolean isMultiblockSaveDelegate() + { + return this.saveMultiblockData; + } + + @Override + public void setUnvisited() + { this.visited = false; } - + @Override - public void setVisited() { + public void setVisited() + { this.visited = true; } - + @Override - public boolean isVisited() { + public boolean isVisited() + { return this.visited; } @Override - public void onAssimilated(MultiblockControllerBase newController) { - assert(this.controller != newController); + public void onAssimilated(MultiblockControllerBase newController) + { + assert (this.controller != newController); this.controller = newController; } - + @Override - public void onAttached(MultiblockControllerBase newController) { + public void onAttached(MultiblockControllerBase newController) + { this.controller = newController; } - + @Override - public void onDetached(MultiblockControllerBase oldController) { + public void onDetached(MultiblockControllerBase oldController) + { this.controller = null; } @Override public abstract MultiblockControllerBase createNewMultiblock(); - + @Override - public IMultiblockPart[] getNeighboringParts() { - CoordTriplet[] neighbors = new CoordTriplet[] { - new CoordTriplet(this.xCoord-1, this.yCoord, this.zCoord), - new CoordTriplet(this.xCoord, this.yCoord-1, this.zCoord), - new CoordTriplet(this.xCoord, this.yCoord, this.zCoord-1), - new CoordTriplet(this.xCoord, this.yCoord, this.zCoord+1), - new CoordTriplet(this.xCoord, this.yCoord+1, this.zCoord), - new CoordTriplet(this.xCoord+1, this.yCoord, this.zCoord) - }; + public IMultiblockPart[] getNeighboringParts() + { + CoordTriplet[] neighbors = new CoordTriplet[] + { new CoordTriplet(this.xCoord - 1, this.yCoord, this.zCoord), + new CoordTriplet(this.xCoord, this.yCoord - 1, this.zCoord), + new CoordTriplet(this.xCoord, this.yCoord, this.zCoord - 1), + new CoordTriplet(this.xCoord, this.yCoord, this.zCoord + 1), + new CoordTriplet(this.xCoord, this.yCoord + 1, this.zCoord), + new CoordTriplet(this.xCoord + 1, this.yCoord, this.zCoord) }; TileEntity te; List neighborParts = new ArrayList(); IChunkProvider chunkProvider = worldObj.getChunkProvider(); - for(CoordTriplet neighbor : neighbors) { - if(!chunkProvider.chunkExists(neighbor.getChunkX(), neighbor.getChunkZ())) { + for (CoordTriplet neighbor : neighbors) + { + if (!chunkProvider.chunkExists(neighbor.getChunkX(), + neighbor.getChunkZ())) + { // Chunk not loaded, skip it. continue; } - te = this.worldObj.getTileEntity(neighbor.x, neighbor.y, neighbor.z); - if(te instanceof IMultiblockPart) { - neighborParts.add((IMultiblockPart)te); + te = this.worldObj + .getTileEntity(neighbor.x, neighbor.y, neighbor.z); + if (te instanceof IMultiblockPart) + { + neighborParts.add((IMultiblockPart) te); } } IMultiblockPart[] tmp = new IMultiblockPart[neighborParts.size()]; return neighborParts.toArray(tmp); } - + @Override - public void onOrphaned(MultiblockControllerBase controller, int oldSize, int newSize) { + public void onOrphaned(MultiblockControllerBase controller, int oldSize, + int newSize) + { this.markDirty(); worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); } - - //// Helper functions for notifying neighboring blocks - protected void notifyNeighborsOfBlockChange() { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); + + // // Helper functions for notifying neighboring blocks + protected void notifyNeighborsOfBlockChange() + { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, + getBlockType()); } - - protected void notifyNeighborsOfTileChange() { + + protected void notifyNeighborsOfTileChange() + { worldObj.func_147453_f(xCoord, yCoord, zCoord, getBlockType()); } - ///// Private/Protected Logic Helpers + // /// Private/Protected Logic Helpers /* - * Detaches this block from its controller. Calls detachBlock() and clears the controller member. + * Detaches this block from its controller. Calls detachBlock() and clears + * the controller member. */ - protected void detachSelf(boolean chunkUnloading) { - if(this.controller != null) { + protected void detachSelf(boolean chunkUnloading) + { + if (this.controller != null) + { // Clean part out of controller this.controller.detachBlock(this, chunkUnloading); diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockValidationException.java b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockValidationException.java index 05fd53b00..3ad0b29c5 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockValidationException.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockValidationException.java @@ -1,13 +1,15 @@ package erogenousbeef.coreTR.multiblock; /** - * An exception thrown when trying to validate a multiblock. Requires a string describing why the multiblock - * could not assemble. + * An exception thrown when trying to validate a multiblock. Requires a string + * describing why the multiblock could not assemble. + * * @author Erogenous Beef */ public class MultiblockValidationException extends Exception { - public MultiblockValidationException(String reason) { + public MultiblockValidationException(String reason) + { super(reason); } } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockWorldRegistry.java b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockWorldRegistry.java index 506929326..2b0e903b2 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockWorldRegistry.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/MultiblockWorldRegistry.java @@ -15,45 +15,51 @@ import erogenousbeef.coreTR.common.BeefCoreLog; import erogenousbeef.coreTR.common.CoordTriplet; /** - * This class manages all the multiblock controllers that exist in a given world, - * either client- or server-side. - * You must create different registries for server and client worlds. + * This class manages all the multiblock controllers that exist in a given + * world, either client- or server-side. You must create different registries + * for server and client worlds. * * @author Erogenous Beef */ public class MultiblockWorldRegistry { private World worldObj; - - private Set controllers; // Active controllers - private Set dirtyControllers; // Controllers whose parts lists have changed - private Set deadControllers; // Controllers which are empty - // A list of orphan parts - parts which currently have no master, but should seek one this tick + private Set controllers; // Active controllers + private Set dirtyControllers; // Controllers whose + // parts lists have + // changed + private Set deadControllers; // Controllers which + // are empty + + // A list of orphan parts - parts which currently have no master, but should + // seek one this tick // Indexed by the hashed chunk coordinate // This can be added-to asynchronously via chunk loads! private Set orphanedParts; // A list of parts which have been detached during internal operations private Set detachedParts; - + // A list of parts whose chunks have not yet finished loading // They will be added to the orphan list when they are finished loading. // Indexed by the hashed chunk coordinate // This can be added-to asynchronously via chunk loads! private HashMap> partsAwaitingChunkLoad; - - // Mutexes to protect lists which may be changed due to asynchronous events, such as chunk loads + + // Mutexes to protect lists which may be changed due to asynchronous events, + // such as chunk loads private Object partsAwaitingChunkLoadMutex; private Object orphanedPartsMutex; - - public MultiblockWorldRegistry(World world) { + + public MultiblockWorldRegistry(World world) + { worldObj = world; - + controllers = new HashSet(); deadControllers = new HashSet(); dirtyControllers = new HashSet(); - + detachedParts = new HashSet(); orphanedParts = new HashSet(); @@ -61,20 +67,27 @@ public class MultiblockWorldRegistry { partsAwaitingChunkLoadMutex = new Object(); orphanedPartsMutex = new Object(); } - + /** * Called before Tile Entities are ticked in the world. Run game logic. */ - public void tickStart() { - if(controllers.size() > 0) { - for(MultiblockControllerBase controller : controllers) { - if(controller.worldObj == worldObj && controller.worldObj.isRemote == worldObj.isRemote) { - if(controller.isEmpty()) { - // This happens on the server when the user breaks the last block. It's fine. + public void tickStart() + { + if (controllers.size() > 0) + { + for (MultiblockControllerBase controller : controllers) + { + if (controller.worldObj == worldObj + && controller.worldObj.isRemote == worldObj.isRemote) + { + if (controller.isEmpty()) + { + // This happens on the server when the user breaks the + // last block. It's fine. // Mark 'er dead and move on. deadControllers.add(controller); - } - else { + } else + { // Run the game logic for this world controller.updateMultiblockEntity(); } @@ -82,87 +95,119 @@ public class MultiblockWorldRegistry { } } } - + /** * Called prior to processing multiblock controllers. Do bookkeeping. */ - public void processMultiblockChanges() { + public void processMultiblockChanges() + { IChunkProvider chunkProvider = worldObj.getChunkProvider(); CoordTriplet coord; - // Merge pools - sets of adjacent machines which should be merged later on in processing + // Merge pools - sets of adjacent machines which should be merged later + // on in processing List> mergePools = null; - if(orphanedParts.size() > 0) { + if (orphanedParts.size() > 0) + { Set orphansToProcess = null; - - // Keep the synchronized block small. We can't iterate over orphanedParts directly - // because the client does not know which chunks are actually loaded, so attachToNeighbors() + + // Keep the synchronized block small. We can't iterate over + // orphanedParts directly + // because the client does not know which chunks are actually + // loaded, so attachToNeighbors() // is not chunk-safe on the client, because Minecraft is stupid. - // It's possible to polyfill this, but the polyfill is too slow for comfort. - synchronized(orphanedPartsMutex) { - if(orphanedParts.size() > 0) { + // It's possible to polyfill this, but the polyfill is too slow for + // comfort. + synchronized (orphanedPartsMutex) + { + if (orphanedParts.size() > 0) + { orphansToProcess = orphanedParts; orphanedParts = new HashSet(); } } - - if(orphansToProcess != null && orphansToProcess.size() > 0) { + + if (orphansToProcess != null && orphansToProcess.size() > 0) + { Set compatibleControllers; - + // Process orphaned blocks - // These are blocks that exist in a valid chunk and require a controller - for(IMultiblockPart orphan : orphansToProcess) { + // These are blocks that exist in a valid chunk and require a + // controller + for (IMultiblockPart orphan : orphansToProcess) + { coord = orphan.getWorldLocation(); - if(!chunkProvider.chunkExists(coord.getChunkX(), coord.getChunkZ())) { + if (!chunkProvider.chunkExists(coord.getChunkX(), + coord.getChunkZ())) + { continue; } // This can occur on slow machines. - if(orphan.isInvalid()) { continue; } + if (orphan.isInvalid()) + { + continue; + } - if(worldObj.getTileEntity(coord.x, coord.y, coord.z) != orphan) { + if (worldObj.getTileEntity(coord.x, coord.y, coord.z) != orphan) + { // This block has been replaced by another. continue; } - + // THIS IS THE ONLY PLACE WHERE PARTS ATTACH TO MACHINES // Try to attach to a neighbor's master controller compatibleControllers = orphan.attachToNeighbors(); - if(compatibleControllers == null) { + if (compatibleControllers == null) + { // FOREVER ALONE! Create and register a new controller. - // THIS IS THE ONLY PLACE WHERE NEW CONTROLLERS ARE CREATED. - MultiblockControllerBase newController = orphan.createNewMultiblock(); + // THIS IS THE ONLY PLACE WHERE NEW CONTROLLERS ARE + // CREATED. + MultiblockControllerBase newController = orphan + .createNewMultiblock(); newController.attachBlock(orphan); this.controllers.add(newController); - } - else if(compatibleControllers.size() > 1) { - if(mergePools == null) { mergePools = new ArrayList>(); } + } else if (compatibleControllers.size() > 1) + { + if (mergePools == null) + { + mergePools = new ArrayList>(); + } // THIS IS THE ONLY PLACE WHERE MERGES ARE DETECTED - // Multiple compatible controllers indicates an impending merge. + // Multiple compatible controllers indicates an + // impending merge. // Locate the appropriate merge pool(s) boolean hasAddedToPool = false; List> candidatePools = new ArrayList>(); - for(Set candidatePool : mergePools) { - if(!Collections.disjoint(candidatePool, compatibleControllers)) { - // They share at least one element, so that means they will all touch after the merge + for (Set candidatePool : mergePools) + { + if (!Collections.disjoint(candidatePool, + compatibleControllers)) + { + // They share at least one element, so that + // means they will all touch after the merge candidatePools.add(candidatePool); } } - - if(candidatePools.size() <= 0) { + + if (candidatePools.size() <= 0) + { // No pools nearby, create a new merge pool mergePools.add(compatibleControllers); - } - else if(candidatePools.size() == 1) { + } else if (candidatePools.size() == 1) + { // Only one pool nearby, simply add to that one candidatePools.get(0).addAll(compatibleControllers); - } - else { - // Multiple pools- merge into one, then add the compatible controllers - Set masterPool = candidatePools.get(0); + } else + { + // Multiple pools- merge into one, then add the + // compatible controllers + Set masterPool = candidatePools + .get(0); Set consumedPool; - for(int i = 1; i < candidatePools.size(); i++) { + for (int i = 1; i < candidatePools.size(); i++) + { consumedPool = candidatePools.get(i); masterPool.addAll(consumedPool); mergePools.remove(consumedPool); @@ -174,28 +219,42 @@ public class MultiblockWorldRegistry { } } - if(mergePools != null && mergePools.size() > 0) { - // Process merges - any machines that have been marked for merge should be merged + if (mergePools != null && mergePools.size() > 0) + { + // Process merges - any machines that have been marked for merge + // should be merged // into the "master" machine. - // To do this, we combine lists of machines that are touching one another and therefore + // To do this, we combine lists of machines that are touching one + // another and therefore // should voltron the fuck up. - for(Set mergePool : mergePools) { - // Search for the new master machine, which will take over all the blocks contained in the other machines + for (Set mergePool : mergePools) + { + // Search for the new master machine, which will take over all + // the blocks contained in the other machines MultiblockControllerBase newMaster = null; - for(MultiblockControllerBase controller : mergePool) { - if(newMaster == null || controller.shouldConsume(newMaster)) { + for (MultiblockControllerBase controller : mergePool) + { + if (newMaster == null + || controller.shouldConsume(newMaster)) + { newMaster = controller; } } - - if(newMaster == null) { - BeefCoreLog.fatal("Multiblock system checked a merge pool of size %d, found no master candidates. This should never happen.", mergePool.size()); - } - else { - // Merge all the other machines into the master machine, then unregister them + + if (newMaster == null) + { + BeefCoreLog + .fatal("Multiblock system checked a merge pool of size %d, found no master candidates. This should never happen.", + mergePool.size()); + } else + { + // Merge all the other machines into the master machine, + // then unregister them addDirtyController(newMaster); - for(MultiblockControllerBase controller : mergePool) { - if(controller != newMaster) { + for (MultiblockControllerBase controller : mergePool) + { + if (controller != newMaster) + { newMaster.assimilate(controller); addDeadController(controller); addDirtyController(newMaster); @@ -206,109 +265,142 @@ public class MultiblockWorldRegistry { } // Process splits and assembly - // Any controllers which have had parts removed must be checked to see if some parts are no longer + // Any controllers which have had parts removed must be checked to see + // if some parts are no longer // physically connected to their master. - if(dirtyControllers.size() > 0) { + if (dirtyControllers.size() > 0) + { Set newlyDetachedParts = null; - for(MultiblockControllerBase controller : dirtyControllers) { + for (MultiblockControllerBase controller : dirtyControllers) + { // Tell the machine to check if any parts are disconnected. - // It should return a set of parts which are no longer connected. - // POSTCONDITION: The controller must have informed those parts that + // It should return a set of parts which are no longer + // connected. + // POSTCONDITION: The controller must have informed those parts + // that // they are no longer connected to this machine. newlyDetachedParts = controller.checkForDisconnections(); - - if(!controller.isEmpty()) { + + if (!controller.isEmpty()) + { controller.recalculateMinMaxCoords(); controller.checkIfMachineIsWhole(); - } - else { + } else + { addDeadController(controller); } - - if(newlyDetachedParts != null && newlyDetachedParts.size() > 0) { - // Controller has shed some parts - add them to the detached list for delayed processing + + if (newlyDetachedParts != null && newlyDetachedParts.size() > 0) + { + // Controller has shed some parts - add them to the detached + // list for delayed processing detachedParts.addAll(newlyDetachedParts); } } - + dirtyControllers.clear(); } - + // Unregister dead controllers - if(deadControllers.size() > 0) { - for(MultiblockControllerBase controller : deadControllers) { - // Go through any controllers which have marked themselves as potentially dead. + if (deadControllers.size() > 0) + { + for (MultiblockControllerBase controller : deadControllers) + { + // Go through any controllers which have marked themselves as + // potentially dead. // Validate that they are empty/dead, then unregister them. - if(!controller.isEmpty()) { - BeefCoreLog.fatal("Found a non-empty controller. Forcing it to shed its blocks and die. This should never happen!"); + if (!controller.isEmpty()) + { + BeefCoreLog + .fatal("Found a non-empty controller. Forcing it to shed its blocks and die. This should never happen!"); detachedParts.addAll(controller.detachAllBlocks()); } // THIS IS THE ONLY PLACE WHERE CONTROLLERS ARE UNREGISTERED. this.controllers.remove(controller); } - + deadControllers.clear(); } - + // Process detached blocks - // Any blocks which have been detached this tick should be moved to the orphaned - // list, and will be checked next tick to see if their chunk is still loaded. - for(IMultiblockPart part : detachedParts) { + // Any blocks which have been detached this tick should be moved to the + // orphaned + // list, and will be checked next tick to see if their chunk is still + // loaded. + for (IMultiblockPart part : detachedParts) + { // Ensure parts know they're detached part.assertDetached(); } - + addAllOrphanedPartsThreadsafe(detachedParts); detachedParts.clear(); } /** - * Called when a multiblock part is added to the world, either via chunk-load or user action. - * If its chunk is loaded, it will be processed during the next tick. - * If the chunk is not loaded, it will be added to a list of objects waiting for a chunkload. - * @param part The part which is being added to this world. + * Called when a multiblock part is added to the world, either via + * chunk-load or user action. If its chunk is loaded, it will be processed + * during the next tick. If the chunk is not loaded, it will be added to a + * list of objects waiting for a chunkload. + * + * @param part + * The part which is being added to this world. */ - public void onPartAdded(IMultiblockPart part) { + public void onPartAdded(IMultiblockPart part) + { CoordTriplet worldLocation = part.getWorldLocation(); - - if(!worldObj.getChunkProvider().chunkExists(worldLocation.getChunkX(), worldLocation.getChunkZ())) { + + if (!worldObj.getChunkProvider().chunkExists(worldLocation.getChunkX(), + worldLocation.getChunkZ())) + { // Part goes into the waiting-for-chunk-load list Set partSet; long chunkHash = worldLocation.getChunkXZHash(); - synchronized(partsAwaitingChunkLoadMutex) { - if(!partsAwaitingChunkLoad.containsKey(chunkHash)) { + synchronized (partsAwaitingChunkLoadMutex) + { + if (!partsAwaitingChunkLoad.containsKey(chunkHash)) + { partSet = new HashSet(); partsAwaitingChunkLoad.put(chunkHash, partSet); - } - else { + } else + { partSet = partsAwaitingChunkLoad.get(chunkHash); } - + partSet.add(part); } - } - else { + } else + { // Part goes into the orphan queue, to be checked this tick addOrphanedPartThreadsafe(part); } } - + /** - * Called when a part is removed from the world, via user action or via chunk unloads. - * This part is removed from any lists in which it may be, and its machine is marked for recalculation. - * @param part The part which is being removed. + * Called when a part is removed from the world, via user action or via + * chunk unloads. This part is removed from any lists in which it may be, + * and its machine is marked for recalculation. + * + * @param part + * The part which is being removed. */ - public void onPartRemovedFromWorld(IMultiblockPart part) { + public void onPartRemovedFromWorld(IMultiblockPart part) + { CoordTriplet coord = part.getWorldLocation(); - if(coord != null) { + if (coord != null) + { long hash = coord.getChunkXZHash(); - - if(partsAwaitingChunkLoad.containsKey(hash)) { - synchronized(partsAwaitingChunkLoadMutex) { - if(partsAwaitingChunkLoad.containsKey(hash)) { + + if (partsAwaitingChunkLoad.containsKey(hash)) + { + synchronized (partsAwaitingChunkLoadMutex) + { + if (partsAwaitingChunkLoad.containsKey(hash)) + { partsAwaitingChunkLoad.get(hash).remove(part); - if(partsAwaitingChunkLoad.get(hash).size() <= 0) { + if (partsAwaitingChunkLoad.get(hash).size() <= 0) + { partsAwaitingChunkLoad.remove(hash); } } @@ -317,51 +409,65 @@ public class MultiblockWorldRegistry { } detachedParts.remove(part); - if(orphanedParts.contains(part)) { - synchronized(orphanedPartsMutex) { + if (orphanedParts.contains(part)) + { + synchronized (orphanedPartsMutex) + { orphanedParts.remove(part); } } - + part.assertDetached(); } /** - * Called when the world which this World Registry represents is fully unloaded from the system. - * Does some housekeeping just to be nice. + * Called when the world which this World Registry represents is fully + * unloaded from the system. Does some housekeeping just to be nice. */ - public void onWorldUnloaded() { + public void onWorldUnloaded() + { controllers.clear(); deadControllers.clear(); dirtyControllers.clear(); - + detachedParts.clear(); - - synchronized(partsAwaitingChunkLoadMutex) { + + synchronized (partsAwaitingChunkLoadMutex) + { partsAwaitingChunkLoad.clear(); } - - synchronized(orphanedPartsMutex) { + + synchronized (orphanedPartsMutex) + { orphanedParts.clear(); } - + worldObj = null; } /** - * Called when a chunk has finished loading. Adds all of the parts which are awaiting - * load to the list of parts which are orphans and therefore will be added to machines - * after the next world tick. + * Called when a chunk has finished loading. Adds all of the parts which are + * awaiting load to the list of parts which are orphans and therefore will + * be added to machines after the next world tick. * - * @param chunkX Chunk X coordinate (world coordate >> 4) of the chunk that was loaded - * @param chunkZ Chunk Z coordinate (world coordate >> 4) of the chunk that was loaded + * @param chunkX + * Chunk X coordinate (world coordate >> 4) of the chunk that was + * loaded + * @param chunkZ + * Chunk Z coordinate (world coordate >> 4) of the chunk that was + * loaded */ - public void onChunkLoaded(int chunkX, int chunkZ) { + public void onChunkLoaded(int chunkX, int chunkZ) + { long chunkHash = ChunkCoordIntPair.chunkXZ2Int(chunkX, chunkZ); - if(partsAwaitingChunkLoad.containsKey(chunkHash)) { - synchronized(partsAwaitingChunkLoadMutex) { - if(partsAwaitingChunkLoad.containsKey(chunkHash)) { - addAllOrphanedPartsThreadsafe(partsAwaitingChunkLoad.get(chunkHash)); + if (partsAwaitingChunkLoad.containsKey(chunkHash)) + { + synchronized (partsAwaitingChunkLoadMutex) + { + if (partsAwaitingChunkLoad.containsKey(chunkHash)) + { + addAllOrphanedPartsThreadsafe(partsAwaitingChunkLoad + .get(chunkHash)); partsAwaitingChunkLoad.remove(chunkHash); } } @@ -369,49 +475,64 @@ public class MultiblockWorldRegistry { } /** - * Registers a controller as dead. It will be cleaned up at the end of the next world tick. - * Note that a controller must shed all of its blocks before being marked as dead, or the system - * will complain at you. + * Registers a controller as dead. It will be cleaned up at the end of the + * next world tick. Note that a controller must shed all of its blocks + * before being marked as dead, or the system will complain at you. * - * @param deadController The controller which is dead. + * @param deadController + * The controller which is dead. */ - public void addDeadController(MultiblockControllerBase deadController) { + public void addDeadController(MultiblockControllerBase deadController) + { this.deadControllers.add(deadController); } /** - * Registers a controller as dirty - its list of attached blocks has changed, and it - * must be re-checked for assembly and, possibly, for orphans. + * Registers a controller as dirty - its list of attached blocks has + * changed, and it must be re-checked for assembly and, possibly, for + * orphans. * - * @param dirtyController The dirty controller. + * @param dirtyController + * The dirty controller. */ - public void addDirtyController(MultiblockControllerBase dirtyController) { + public void addDirtyController(MultiblockControllerBase dirtyController) + { this.dirtyControllers.add(dirtyController); } - + /** - * Use this only if you know what you're doing. You should rarely need to iterate - * over all controllers in a world! + * Use this only if you know what you're doing. You should rarely need to + * iterate over all controllers in a world! * - * @return An (unmodifiable) set of controllers which are active in this world. + * @return An (unmodifiable) set of controllers which are active in this + * world. */ - public Set getControllers() { + public Set getControllers() + { return Collections.unmodifiableSet(controllers); } /* *** PRIVATE HELPERS *** */ - - private void addOrphanedPartThreadsafe(IMultiblockPart part) { - synchronized(orphanedPartsMutex) { + + private void addOrphanedPartThreadsafe(IMultiblockPart part) + { + synchronized (orphanedPartsMutex) + { orphanedParts.add(part); } } - - private void addAllOrphanedPartsThreadsafe(Collection parts) { - synchronized(orphanedPartsMutex) { + + private void addAllOrphanedPartsThreadsafe( + Collection parts) + { + synchronized (orphanedPartsMutex) + { orphanedParts.addAll(parts); } } - - private String clientOrServer() { return worldObj.isRemote ? "CLIENT" : "SERVER"; } + + private String clientOrServer() + { + return worldObj.isRemote ? "CLIENT" : "SERVER"; + } } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/PartPosition.java b/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/PartPosition.java index 706f04981..f53be9f26 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/PartPosition.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/PartPosition.java @@ -1,28 +1,22 @@ package erogenousbeef.coreTR.multiblock.rectangular; -public enum PartPosition { - Unknown, - Interior, - FrameCorner, - Frame, - TopFace, - BottomFace, - NorthFace, - SouthFace, - EastFace, - WestFace; - - public boolean isFace(PartPosition position) { - switch(position) { - case TopFace: - case BottomFace: - case NorthFace: - case SouthFace: - case EastFace: - case WestFace: - return true; - default: - return false; +public enum PartPosition +{ + Unknown, Interior, FrameCorner, Frame, TopFace, BottomFace, NorthFace, SouthFace, EastFace, WestFace; + + public boolean isFace(PartPosition position) + { + switch (position) + { + case TopFace: + case BottomFace: + case NorthFace: + case SouthFace: + case EastFace: + case WestFace: + return true; + default: + return false; } } } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/RectangularMultiblockControllerBase.java b/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/RectangularMultiblockControllerBase.java index bcfcef229..ff82677d4 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/RectangularMultiblockControllerBase.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/RectangularMultiblockControllerBase.java @@ -9,122 +9,198 @@ import erogenousbeef.coreTR.multiblock.MultiblockValidationException; public abstract class RectangularMultiblockControllerBase extends MultiblockControllerBase { - protected RectangularMultiblockControllerBase(World world) { + protected RectangularMultiblockControllerBase(World world) + { super(world); } /** - * @return True if the machine is "whole" and should be assembled. False otherwise. + * @return True if the machine is "whole" and should be assembled. False + * otherwise. */ - protected void isMachineWhole() throws MultiblockValidationException { - if(connectedParts.size() < getMinimumNumberOfBlocksForAssembledMachine()) { + protected void isMachineWhole() throws MultiblockValidationException + { + if (connectedParts.size() < getMinimumNumberOfBlocksForAssembledMachine()) + { throw new MultiblockValidationException("Machine is too small."); } - + CoordTriplet maximumCoord = getMaximumCoord(); CoordTriplet minimumCoord = getMinimumCoord(); - + // Quickly check for exceeded dimensions int deltaX = maximumCoord.x - minimumCoord.x + 1; int deltaY = maximumCoord.y - minimumCoord.y + 1; int deltaZ = maximumCoord.z - minimumCoord.z + 1; - + int maxX = getMaximumXSize(); int maxY = getMaximumYSize(); int maxZ = getMaximumZSize(); int minX = getMinimumXSize(); int minY = getMinimumYSize(); int minZ = getMinimumZSize(); - - if(maxX > 0 && deltaX > maxX) { throw new MultiblockValidationException(String.format("Machine is too large, it may be at most %d blocks in the X dimension", maxX)); } - if(maxY > 0 && deltaY > maxY) { throw new MultiblockValidationException(String.format("Machine is too large, it may be at most %d blocks in the Y dimension", maxY)); } - if(maxZ > 0 && deltaZ > maxZ) { throw new MultiblockValidationException(String.format("Machine is too large, it may be at most %d blocks in the Z dimension", maxZ)); } - if(deltaX < minX) { throw new MultiblockValidationException(String.format("Machine is too small, it must be at least %d blocks in the X dimension", minX)); } - if(deltaY < minY) { throw new MultiblockValidationException(String.format("Machine is too small, it must be at least %d blocks in the Y dimension", minY)); } - if(deltaZ < minZ) { throw new MultiblockValidationException(String.format("Machine is too small, it must be at least %d blocks in the Z dimension", minZ)); } + + if (maxX > 0 && deltaX > maxX) + { + throw new MultiblockValidationException( + String.format( + "Machine is too large, it may be at most %d blocks in the X dimension", + maxX)); + } + if (maxY > 0 && deltaY > maxY) + { + throw new MultiblockValidationException( + String.format( + "Machine is too large, it may be at most %d blocks in the Y dimension", + maxY)); + } + if (maxZ > 0 && deltaZ > maxZ) + { + throw new MultiblockValidationException( + String.format( + "Machine is too large, it may be at most %d blocks in the Z dimension", + maxZ)); + } + if (deltaX < minX) + { + throw new MultiblockValidationException( + String.format( + "Machine is too small, it must be at least %d blocks in the X dimension", + minX)); + } + if (deltaY < minY) + { + throw new MultiblockValidationException( + String.format( + "Machine is too small, it must be at least %d blocks in the Y dimension", + minY)); + } + if (deltaZ < minZ) + { + throw new MultiblockValidationException( + String.format( + "Machine is too small, it must be at least %d blocks in the Z dimension", + minZ)); + } // Now we run a simple check on each block within that volume. // Any block deviating = NO DEAL SIR TileEntity te; RectangularMultiblockTileEntityBase part; - Class myClass = this.getClass(); + Class myClass = this + .getClass(); - for(int x = minimumCoord.x; x <= maximumCoord.x; x++) { - for(int y = minimumCoord.y; y <= maximumCoord.y; y++) { - for(int z = minimumCoord.z; z <= maximumCoord.z; z++) { + for (int x = minimumCoord.x; x <= maximumCoord.x; x++) + { + for (int y = minimumCoord.y; y <= maximumCoord.y; y++) + { + for (int z = minimumCoord.z; z <= maximumCoord.z; z++) + { // Okay, figure out what sort of block this should be. - + te = this.worldObj.getTileEntity(x, y, z); - if(te instanceof RectangularMultiblockTileEntityBase) { - part = (RectangularMultiblockTileEntityBase)te; - - // Ensure this part should actually be allowed within a cube of this controller's type - if(!myClass.equals(part.getMultiblockControllerType())) + if (te instanceof RectangularMultiblockTileEntityBase) + { + part = (RectangularMultiblockTileEntityBase) te; + + // Ensure this part should actually be allowed within a + // cube of this controller's type + if (!myClass.equals(part.getMultiblockControllerType())) { - throw new MultiblockValidationException(String.format("Part @ %d, %d, %d is incompatible with machines of type %s", x, y, z, myClass.getSimpleName())); + throw new MultiblockValidationException( + String.format( + "Part @ %d, %d, %d is incompatible with machines of type %s", + x, y, z, myClass.getSimpleName())); } - } - else { - // This is permitted so that we can incorporate certain non-multiblock parts inside interiors + } else + { + // This is permitted so that we can incorporate certain + // non-multiblock parts inside interiors part = null; } - // Validate block type against both part-level and material-level validators. + // Validate block type against both part-level and + // material-level validators. int extremes = 0; - if(x == minimumCoord.x) { extremes++; } - if(y == minimumCoord.y) { extremes++; } - if(z == minimumCoord.z) { extremes++; } - - if(x == maximumCoord.x) { extremes++; } - if(y == maximumCoord.y) { extremes++; } - if(z == maximumCoord.z) { extremes++; } - - if(extremes >= 2) { - if(part != null) { + if (x == minimumCoord.x) + { + extremes++; + } + if (y == minimumCoord.y) + { + extremes++; + } + if (z == minimumCoord.z) + { + extremes++; + } + + if (x == maximumCoord.x) + { + extremes++; + } + if (y == maximumCoord.y) + { + extremes++; + } + if (z == maximumCoord.z) + { + extremes++; + } + + if (extremes >= 2) + { + if (part != null) + { part.isGoodForFrame(); - } - else { + } else + { isBlockGoodForFrame(this.worldObj, x, y, z); } - } - else if(extremes == 1) { - if(y == maximumCoord.y) { - if(part != null) { + } else if (extremes == 1) + { + if (y == maximumCoord.y) + { + if (part != null) + { part.isGoodForTop(); - } - else { + } else + { isBlockGoodForTop(this.worldObj, x, y, z); } - } - else if(y == minimumCoord.y) { - if(part != null) { + } else if (y == minimumCoord.y) + { + if (part != null) + { part.isGoodForBottom(); - } - else { + } else + { isBlockGoodForBottom(this.worldObj, x, y, z); } - } - else { + } else + { // Side - if(part != null) { + if (part != null) + { part.isGoodForSides(); - } - else { + } else + { isBlockGoodForSides(this.worldObj, x, y, z); } } - } - else { - if(part != null) { + } else + { + if (part != null) + { part.isGoodForInterior(); - } - else { + } else + { isBlockGoodForInterior(this.worldObj, x, y, z); } } } } } - } - + } + } diff --git a/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/RectangularMultiblockTileEntityBase.java b/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/RectangularMultiblockTileEntityBase.java index d8fd62b4f..fb9b70f75 100644 --- a/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/RectangularMultiblockTileEntityBase.java +++ b/src/main/java/erogenousbeef/coreTR/multiblock/rectangular/RectangularMultiblockTileEntityBase.java @@ -11,89 +11,114 @@ public abstract class RectangularMultiblockTileEntityBase extends PartPosition position; ForgeDirection outwards; - - public RectangularMultiblockTileEntityBase() { + + public RectangularMultiblockTileEntityBase() + { super(); - + position = PartPosition.Unknown; outwards = ForgeDirection.UNKNOWN; } // Positional Data - public ForgeDirection getOutwardsDir() { + public ForgeDirection getOutwardsDir() + { return outwards; } - - public PartPosition getPartPosition() { + + public PartPosition getPartPosition() + { return position; } - // Handlers from MultiblockTileEntityBase + // Handlers from MultiblockTileEntityBase @Override - public void onAttached(MultiblockControllerBase newController) { + public void onAttached(MultiblockControllerBase newController) + { super.onAttached(newController); - recalculateOutwardsDirection(newController.getMinimumCoord(), newController.getMaximumCoord()); + recalculateOutwardsDirection(newController.getMinimumCoord(), + newController.getMaximumCoord()); } - - + @Override - public void onMachineAssembled(MultiblockControllerBase controller) { + public void onMachineAssembled(MultiblockControllerBase controller) + { CoordTriplet maxCoord = controller.getMaximumCoord(); CoordTriplet minCoord = controller.getMinimumCoord(); - + // Discover where I am on the reactor recalculateOutwardsDirection(minCoord, maxCoord); } @Override - public void onMachineBroken() { + public void onMachineBroken() + { position = PartPosition.Unknown; outwards = ForgeDirection.UNKNOWN; } - + // Positional helpers - public void recalculateOutwardsDirection(CoordTriplet minCoord, CoordTriplet maxCoord) { + public void recalculateOutwardsDirection(CoordTriplet minCoord, + CoordTriplet maxCoord) + { outwards = ForgeDirection.UNKNOWN; position = PartPosition.Unknown; int facesMatching = 0; - if(maxCoord.x == this.xCoord || minCoord.x == this.xCoord) { facesMatching++; } - if(maxCoord.y == this.yCoord || minCoord.y == this.yCoord) { facesMatching++; } - if(maxCoord.z == this.zCoord || minCoord.z == this.zCoord) { facesMatching++; } - - if(facesMatching <= 0) { position = PartPosition.Interior; } - else if(facesMatching >= 3) { position = PartPosition.FrameCorner; } - else if(facesMatching == 2) { position = PartPosition.Frame; } - else { + if (maxCoord.x == this.xCoord || minCoord.x == this.xCoord) + { + facesMatching++; + } + if (maxCoord.y == this.yCoord || minCoord.y == this.yCoord) + { + facesMatching++; + } + if (maxCoord.z == this.zCoord || minCoord.z == this.zCoord) + { + facesMatching++; + } + + if (facesMatching <= 0) + { + position = PartPosition.Interior; + } else if (facesMatching >= 3) + { + position = PartPosition.FrameCorner; + } else if (facesMatching == 2) + { + position = PartPosition.Frame; + } else + { // 1 face matches - if(maxCoord.x == this.xCoord) { + if (maxCoord.x == this.xCoord) + { position = PartPosition.EastFace; outwards = ForgeDirection.EAST; - } - else if(minCoord.x == this.xCoord) { + } else if (minCoord.x == this.xCoord) + { position = PartPosition.WestFace; outwards = ForgeDirection.WEST; - } - else if(maxCoord.z == this.zCoord) { + } else if (maxCoord.z == this.zCoord) + { position = PartPosition.SouthFace; outwards = ForgeDirection.SOUTH; - } - else if(minCoord.z == this.zCoord) { + } else if (minCoord.z == this.zCoord) + { position = PartPosition.NorthFace; outwards = ForgeDirection.NORTH; - } - else if(maxCoord.y == this.yCoord) { + } else if (maxCoord.y == this.yCoord) + { position = PartPosition.TopFace; outwards = ForgeDirection.UP; - } - else { + } else + { position = PartPosition.BottomFace; outwards = ForgeDirection.DOWN; } } } - - ///// Validation Helpers (IMultiblockPart) + + // /// Validation Helpers (IMultiblockPart) public abstract void isGoodForFrame() throws MultiblockValidationException; public abstract void isGoodForSides() throws MultiblockValidationException; @@ -102,5 +127,6 @@ public abstract class RectangularMultiblockTileEntityBase extends public abstract void isGoodForBottom() throws MultiblockValidationException; - public abstract void isGoodForInterior() throws MultiblockValidationException; + public abstract void isGoodForInterior() + throws MultiblockValidationException; } diff --git a/src/main/java/techreborn/Core.java b/src/main/java/techreborn/Core.java index e1d732250..0a5701023 100644 --- a/src/main/java/techreborn/Core.java +++ b/src/main/java/techreborn/Core.java @@ -1,15 +1,7 @@ package techreborn; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.GameRegistry; -import erogenousbeef.coreTR.multiblock.MultiblockEventHandler; -import erogenousbeef.coreTR.multiblock.MultiblockServerTickHandler; +import java.io.File; + import net.minecraftforge.common.MinecraftForge; import techreborn.achievement.TRAchievements; import techreborn.client.GuiHandler; @@ -25,59 +17,73 @@ import techreborn.packets.PacketHandler; import techreborn.proxies.CommonProxy; import techreborn.util.LogHelper; import techreborn.world.TROreGen; - -import java.io.File; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import erogenousbeef.coreTR.multiblock.MultiblockEventHandler; +import erogenousbeef.coreTR.multiblock.MultiblockServerTickHandler; @Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCUIES, guiFactory = ModInfo.GUI_FACTORY_CLASS) public class Core { - public static ConfigTechReborn config; - + public static ConfigTechReborn config; + @SidedProxy(clientSide = ModInfo.CLIENT_PROXY_CLASS, serverSide = ModInfo.SERVER_PROXY_CLASS) public static CommonProxy proxy; - @Mod.Instance - public static Core INSTANCE; + @Mod.Instance + public static Core INSTANCE; - @Mod.EventHandler - public void preinit(FMLPreInitializationEvent event) { - INSTANCE = this; - String path = event.getSuggestedConfigurationFile().getAbsolutePath() - .replace(ModInfo.MOD_ID, "TechReborn"); + @Mod.EventHandler + public void preinit(FMLPreInitializationEvent event) + { + INSTANCE = this; + String path = event.getSuggestedConfigurationFile().getAbsolutePath() + .replace(ModInfo.MOD_ID, "TechReborn"); - config = ConfigTechReborn.initialize(new File(path)); - LogHelper.info("PreInitialization Compleate"); - } + config = ConfigTechReborn.initialize(new File(path)); + LogHelper.info("PreInitialization Compleate"); + } - @Mod.EventHandler - public void init(FMLInitializationEvent event) { - //Register ModBlocks - ModBlocks.init(); - //Register ModItems - ModItems.init(); - //Register Multiparts + @Mod.EventHandler + public void init(FMLInitializationEvent event) + { + // Register ModBlocks + ModBlocks.init(); + // Register ModItems + ModItems.init(); + // Register Multiparts ModParts.init(); - // Recipes - ModRecipes.init(); - //Compat - CompatManager.init(event); - // WorldGen - GameRegistry.registerWorldGenerator(new TROreGen(), 0); - //Register Gui Handler - NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler()); - //packets - PacketHandler.setChannels(NetworkRegistry.INSTANCE.newChannel(ModInfo.MOD_ID + "_packets", new PacketHandler())); - //Achievements - TRAchievements.init(); - //Multiblock events - MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler()); - FMLCommonHandler.instance().bus().register(new MultiblockServerTickHandler()); - LogHelper.info("Initialization Compleate"); - } - - @Mod.EventHandler - public void postinit(FMLPostInitializationEvent event) - { - RecipeManager.init(); - } + // Recipes + ModRecipes.init(); + // Compat + CompatManager.init(event); + // WorldGen + GameRegistry.registerWorldGenerator(new TROreGen(), 0); + // Register Gui Handler + NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler()); + // packets + PacketHandler.setChannels(NetworkRegistry.INSTANCE.newChannel( + ModInfo.MOD_ID + "_packets", new PacketHandler())); + // Achievements + TRAchievements.init(); + // Multiblock events + MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler()); + FMLCommonHandler.instance().bus() + .register(new MultiblockServerTickHandler()); + + LogHelper.info("Initialization Compleate"); + } + + @Mod.EventHandler + public void postinit(FMLPostInitializationEvent event) + { + // Has to be done here as buildcraft registers there recipes late + RecipeManager.init(); + } } diff --git a/src/main/java/techreborn/achievement/AchievementMod.java b/src/main/java/techreborn/achievement/AchievementMod.java index 79d2093f5..ac9a99a7a 100644 --- a/src/main/java/techreborn/achievement/AchievementMod.java +++ b/src/main/java/techreborn/achievement/AchievementMod.java @@ -8,23 +8,27 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; -public class AchievementMod extends Achievement{ - +public class AchievementMod extends Achievement { + public static List achievements = new ArrayList(); - public AchievementMod(String name, int x, int y, ItemStack icon, Achievement parent) + public AchievementMod(String name, int x, int y, ItemStack icon, + Achievement parent) { - super("achievement.techreborn:" + name, "TechReborn:" + name, x, y, icon, parent); + super("achievement.techreborn:" + name, "TechReborn:" + name, x, y, + icon, parent); achievements.add(this); registerStat(); } - public AchievementMod(String name, int x, int y, Item icon, Achievement parent) + public AchievementMod(String name, int x, int y, Item icon, + Achievement parent) { this(name, x, y, new ItemStack(icon), parent); } - public AchievementMod(String name, int x, int y, Block icon, Achievement parent) + public AchievementMod(String name, int x, int y, Block icon, + Achievement parent) { this(name, x, y, new ItemStack(icon), parent); } diff --git a/src/main/java/techreborn/achievement/AchievementTriggerer.java b/src/main/java/techreborn/achievement/AchievementTriggerer.java index 15db75f46..d69d93ad6 100644 --- a/src/main/java/techreborn/achievement/AchievementTriggerer.java +++ b/src/main/java/techreborn/achievement/AchievementTriggerer.java @@ -7,22 +7,30 @@ import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent; public class AchievementTriggerer { - + @SubscribeEvent - public void onItemPickedUp(ItemPickupEvent event) { + public void onItemPickedUp(ItemPickupEvent event) + { ItemStack stack = event.pickedUp.getEntityItem(); - if(stack != null && stack.getItem() instanceof IPickupAchievement) { - Achievement achievement = ((IPickupAchievement) stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp); - if(achievement != null) + if (stack != null && stack.getItem() instanceof IPickupAchievement) + { + Achievement achievement = ((IPickupAchievement) stack.getItem()) + .getAchievementOnPickup(stack, event.player, event.pickedUp); + if (achievement != null) event.player.addStat(achievement, 1); } } @SubscribeEvent - public void onItemCrafted(ItemCraftedEvent event) { - if(event.crafting != null && event.crafting.getItem() instanceof ICraftAchievement) { - Achievement achievement = ((ICraftAchievement) event.crafting.getItem()).getAchievementOnCraft(event.crafting, event.player, event.craftMatrix); - if(achievement != null) + public void onItemCrafted(ItemCraftedEvent event) + { + if (event.crafting != null + && event.crafting.getItem() instanceof ICraftAchievement) + { + Achievement achievement = ((ICraftAchievement) event.crafting + .getItem()).getAchievementOnCraft(event.crafting, + event.player, event.craftMatrix); + if (achievement != null) event.player.addStat(achievement, 1); } } diff --git a/src/main/java/techreborn/achievement/ICraftAchievement.java b/src/main/java/techreborn/achievement/ICraftAchievement.java index e2a03ef04..56c7ee2ca 100644 --- a/src/main/java/techreborn/achievement/ICraftAchievement.java +++ b/src/main/java/techreborn/achievement/ICraftAchievement.java @@ -6,7 +6,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; public interface ICraftAchievement { - - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix); + + public Achievement getAchievementOnCraft(ItemStack stack, + EntityPlayer player, IInventory matrix); } diff --git a/src/main/java/techreborn/achievement/IPickupAchievement.java b/src/main/java/techreborn/achievement/IPickupAchievement.java index 75cc7d719..978c00dc0 100644 --- a/src/main/java/techreborn/achievement/IPickupAchievement.java +++ b/src/main/java/techreborn/achievement/IPickupAchievement.java @@ -6,7 +6,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; public interface IPickupAchievement { - - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item); + + public Achievement getAchievementOnPickup(ItemStack stack, + EntityPlayer player, EntityItem item); } diff --git a/src/main/java/techreborn/achievement/TRAchievements.java b/src/main/java/techreborn/achievement/TRAchievements.java index c4793a9e6..6368c2181 100644 --- a/src/main/java/techreborn/achievement/TRAchievements.java +++ b/src/main/java/techreborn/achievement/TRAchievements.java @@ -1,33 +1,39 @@ package techreborn.achievement; -import cpw.mods.fml.common.FMLCommonHandler; -import techreborn.init.ModBlocks; -import techreborn.lib.ModInfo; import net.minecraft.item.ItemStack; import net.minecraft.stats.Achievement; import net.minecraftforge.common.AchievementPage; +import techreborn.init.ModBlocks; +import techreborn.lib.ModInfo; +import cpw.mods.fml.common.FMLCommonHandler; public class TRAchievements { - + public static AchievementPage techrebornPage; public static int pageIndex; - + public static Achievement ore_PickUp; public static Achievement thermalgen_Craft; public static Achievement centrifuge_Craft; - + public static void init() { - ore_PickUp = new AchievementMod("ore_PickUp", 0, 0, new ItemStack(ModBlocks.ore, 1, 0), null); - centrifuge_Craft = new AchievementMod("centrifuge_Craft", 1, 1, ModBlocks.centrifuge, ore_PickUp); - thermalgen_Craft = new AchievementMod("thermalgen_Craft", 2, 1, ModBlocks.thermalGenerator, ore_PickUp); + ore_PickUp = new AchievementMod("ore_PickUp", 0, 0, new ItemStack( + ModBlocks.ore, 1, 0), null); + centrifuge_Craft = new AchievementMod("centrifuge_Craft", 1, 1, + ModBlocks.centrifuge, ore_PickUp); + thermalgen_Craft = new AchievementMod("thermalgen_Craft", 2, 1, + ModBlocks.thermalGenerator, ore_PickUp); pageIndex = AchievementPage.getAchievementPages().size(); - techrebornPage = new AchievementPage(ModInfo.MOD_NAME, AchievementMod.achievements.toArray(new Achievement[AchievementMod.achievements.size()])); + techrebornPage = new AchievementPage(ModInfo.MOD_NAME, + AchievementMod.achievements + .toArray(new Achievement[AchievementMod.achievements + .size()])); AchievementPage.registerAchievementPage(techrebornPage); FMLCommonHandler.instance().bus().register(new AchievementTriggerer()); - + } } diff --git a/src/main/java/techreborn/api/CentrifugeRecipie.java b/src/main/java/techreborn/api/CentrifugeRecipie.java index a836634ee..b46f86db8 100644 --- a/src/main/java/techreborn/api/CentrifugeRecipie.java +++ b/src/main/java/techreborn/api/CentrifugeRecipie.java @@ -4,72 +4,83 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class CentrifugeRecipie { - ItemStack inputItem; - ItemStack output1, output2, output3, output4; - int tickTime; - int cells; + ItemStack inputItem; + ItemStack output1, output2, output3, output4; + int tickTime; + int cells; - public CentrifugeRecipie(ItemStack inputItem, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int cells) { - this.inputItem = inputItem; - this.output1 = output1; - this.output2 = output2; - this.output3 = output3; - this.output4 = output4; - this.tickTime = tickTime; - this.cells = cells; - } + public CentrifugeRecipie(ItemStack inputItem, ItemStack output1, + ItemStack output2, ItemStack output3, ItemStack output4, + int tickTime, int cells) + { + this.inputItem = inputItem; + this.output1 = output1; + this.output2 = output2; + this.output3 = output3; + this.output4 = output4; + this.tickTime = tickTime; + this.cells = cells; + } - public CentrifugeRecipie(Item inputItem, int inputAmount, Item output1, Item output2, Item output3, Item output4, int tickTime, int cells) { - this.inputItem = new ItemStack(inputItem, inputAmount); - if (output1 != null) - this.output1 = new ItemStack(output1); - if (output2 != null) - this.output2 = new ItemStack(output2); - if (output3 != null) - this.output3 = new ItemStack(output3); - if (output4 != null) - this.output4 = new ItemStack(output4); - this.tickTime = tickTime; - this.cells = cells; - } + public CentrifugeRecipie(Item inputItem, int inputAmount, Item output1, + Item output2, Item output3, Item output4, int tickTime, int cells) + { + this.inputItem = new ItemStack(inputItem, inputAmount); + if (output1 != null) + this.output1 = new ItemStack(output1); + if (output2 != null) + this.output2 = new ItemStack(output2); + if (output3 != null) + this.output3 = new ItemStack(output3); + if (output4 != null) + this.output4 = new ItemStack(output4); + this.tickTime = tickTime; + this.cells = cells; + } - public CentrifugeRecipie(CentrifugeRecipie centrifugeRecipie) { - this.inputItem = centrifugeRecipie.getInputItem(); - this.output1 = centrifugeRecipie.getOutput1(); - this.output2 = centrifugeRecipie.getOutput2(); - this.output3 = centrifugeRecipie.getOutput3(); - this.output4 = centrifugeRecipie.getOutput4(); - this.tickTime = centrifugeRecipie.getTickTime(); - this.cells = centrifugeRecipie.getCells(); - } + public CentrifugeRecipie(CentrifugeRecipie centrifugeRecipie) + { + this.inputItem = centrifugeRecipie.getInputItem(); + this.output1 = centrifugeRecipie.getOutput1(); + this.output2 = centrifugeRecipie.getOutput2(); + this.output3 = centrifugeRecipie.getOutput3(); + this.output4 = centrifugeRecipie.getOutput4(); + this.tickTime = centrifugeRecipie.getTickTime(); + this.cells = centrifugeRecipie.getCells(); + } - public ItemStack getInputItem() { - return inputItem; - } + public ItemStack getInputItem() + { + return inputItem; + } - public ItemStack getOutput1() { - return output1; - } + public ItemStack getOutput1() + { + return output1; + } - public ItemStack getOutput2() { - return output2; - } + public ItemStack getOutput2() + { + return output2; + } - public ItemStack getOutput3() { - return output3; - } + public ItemStack getOutput3() + { + return output3; + } - public ItemStack getOutput4() { - return output4; - } + public ItemStack getOutput4() + { + return output4; + } - public int getTickTime() { - return tickTime; - } + public int getTickTime() + { + return tickTime; + } - public int getCells() { - return cells; - } + public int getCells() + { + return cells; + } } - - diff --git a/src/main/java/techreborn/api/RollingMachineRecipe.java b/src/main/java/techreborn/api/RollingMachineRecipe.java index 723160a02..bba9a1b7c 100644 --- a/src/main/java/techreborn/api/RollingMachineRecipe.java +++ b/src/main/java/techreborn/api/RollingMachineRecipe.java @@ -1,5 +1,9 @@ package techreborn.api; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; @@ -9,104 +13,118 @@ import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.world.World; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - public class RollingMachineRecipe { - private final List recipes = new ArrayList(); + private final List recipes = new ArrayList(); - public static final RollingMachineRecipe instance = new RollingMachineRecipe(); + public static final RollingMachineRecipe instance = new RollingMachineRecipe(); - public void addRecipe(ItemStack output, Object... components) { - String s = ""; - int i = 0; - int j = 0; - int k = 0; - if(components[i] instanceof String[]) { - String as[] = (String[])components[i++]; - for(int l = 0; l < as.length; l++) { - String s2 = as[l]; - k++; - j = s2.length(); - s = (new StringBuilder()).append(s).append(s2).toString(); - } - } else { - while(components[i] instanceof String) { - String s1 = (String)components[i++]; - k++; - j = s1.length(); - s = (new StringBuilder()).append(s).append(s1).toString(); - } - } - HashMap hashmap = new HashMap(); - for(; i < components.length; i += 2) { - Character character = (Character)components[i]; - ItemStack itemstack1 = null; - if(components[i + 1] instanceof Item) { - itemstack1 = new ItemStack((Item)components[i + 1]); - } else if(components[i + 1] instanceof Block) { - itemstack1 = new ItemStack((Block)components[i + 1], 1, -1); - } else if(components[i + 1] instanceof ItemStack) { - itemstack1 = (ItemStack)components[i + 1]; - } - hashmap.put(character, itemstack1); - } + public void addRecipe(ItemStack output, Object... components) + { + String s = ""; + int i = 0; + int j = 0; + int k = 0; + if (components[i] instanceof String[]) + { + String as[] = (String[]) components[i++]; + for (int l = 0; l < as.length; l++) + { + String s2 = as[l]; + k++; + j = s2.length(); + s = (new StringBuilder()).append(s).append(s2).toString(); + } + } else + { + while (components[i] instanceof String) + { + String s1 = (String) components[i++]; + k++; + j = s1.length(); + s = (new StringBuilder()).append(s).append(s1).toString(); + } + } + HashMap hashmap = new HashMap(); + for (; i < components.length; i += 2) + { + Character character = (Character) components[i]; + ItemStack itemstack1 = null; + if (components[i + 1] instanceof Item) + { + itemstack1 = new ItemStack((Item) components[i + 1]); + } else if (components[i + 1] instanceof Block) + { + itemstack1 = new ItemStack((Block) components[i + 1], 1, -1); + } else if (components[i + 1] instanceof ItemStack) + { + itemstack1 = (ItemStack) components[i + 1]; + } + hashmap.put(character, itemstack1); + } - ItemStack recipeArray[] = new ItemStack[j * k]; - for(int i1 = 0; i1 < j * k; i1++) { - char c = s.charAt(i1); - if(hashmap.containsKey(Character.valueOf(c))) { - recipeArray[i1] = ((ItemStack)hashmap.get(Character.valueOf(c))).copy(); - } else { - recipeArray[i1] = null; - } - } + ItemStack recipeArray[] = new ItemStack[j * k]; + for (int i1 = 0; i1 < j * k; i1++) + { + char c = s.charAt(i1); + if (hashmap.containsKey(Character.valueOf(c))) + { + recipeArray[i1] = ((ItemStack) hashmap + .get(Character.valueOf(c))).copy(); + } else + { + recipeArray[i1] = null; + } + } - recipes.add(new ShapedRecipes(j, k, recipeArray, output)); - } + recipes.add(new ShapedRecipes(j, k, recipeArray, output)); + } - public void addShapelessRecipe(ItemStack output, Object... components) { - List ingredients = new ArrayList(); - for(int j = 0; j < components.length; j++) { - Object obj = components[j]; - if(obj instanceof ItemStack) { - ingredients.add(((ItemStack)obj).copy()); - continue; - } - if(obj instanceof Item) { - ingredients.add(new ItemStack((Item)obj)); - continue; - } - if(obj instanceof Block) { - ingredients.add(new ItemStack((Block)obj)); - } else { - throw new RuntimeException("Invalid shapeless recipe!"); - } - } + public void addShapelessRecipe(ItemStack output, Object... components) + { + List ingredients = new ArrayList(); + for (int j = 0; j < components.length; j++) + { + Object obj = components[j]; + if (obj instanceof ItemStack) + { + ingredients.add(((ItemStack) obj).copy()); + continue; + } + if (obj instanceof Item) + { + ingredients.add(new ItemStack((Item) obj)); + continue; + } + if (obj instanceof Block) + { + ingredients.add(new ItemStack((Block) obj)); + } else + { + throw new RuntimeException("Invalid shapeless recipe!"); + } + } - recipes.add(new ShapelessRecipes(output, ingredients)); - } + recipes.add(new ShapelessRecipes(output, ingredients)); + } + public ItemStack findMatchingRecipe(InventoryCrafting inv, World world) + { + for (int k = 0; k < recipes.size(); k++) + { + IRecipe irecipe = (IRecipe) recipes.get(k); + if (irecipe.matches(inv, world)) + { + return irecipe.getCraftingResult(inv); + } + } - public ItemStack findMatchingRecipe(InventoryCrafting inv, World world) { - for(int k = 0; k < recipes.size(); k++) { - IRecipe irecipe = (IRecipe)recipes.get(k); - if(irecipe.matches(inv, world)) { - return irecipe.getCraftingResult(inv); - } - } - - return null; - } - - - public List getRecipeList() { - return recipes; - } + return null; + } + public List getRecipeList() + { + return recipes; + } } - - diff --git a/src/main/java/techreborn/api/TechRebornAPI.java b/src/main/java/techreborn/api/TechRebornAPI.java index 99c163b96..3c3526225 100644 --- a/src/main/java/techreborn/api/TechRebornAPI.java +++ b/src/main/java/techreborn/api/TechRebornAPI.java @@ -1,45 +1,58 @@ package techreborn.api; +import java.util.ArrayList; + import net.minecraft.item.ItemStack; import techreborn.util.ItemUtils; -import java.util.ArrayList; - public final class TechRebornAPI { - public static ArrayList centrifugeRecipies = new ArrayList(); - public static ArrayList rollingmachineRecipes = new ArrayList(); + public static ArrayList centrifugeRecipies = new ArrayList(); + public static ArrayList rollingmachineRecipes = new ArrayList(); + public static void registerCentrifugeRecipe(CentrifugeRecipie recipie) + { + boolean shouldAdd = true; + for (CentrifugeRecipie centrifugeRecipie : centrifugeRecipies) + { + if (ItemUtils.isItemEqual(centrifugeRecipie.getInputItem(), + recipie.getInputItem(), false, true)) + { + try + { + throw new RegisteredItemRecipe( + "Item " + + recipie.getInputItem() + .getUnlocalizedName() + + " is already being used in a recipe for the Centrifuge"); + } catch (RegisteredItemRecipe registeredItemRecipe) + { + registeredItemRecipe.printStackTrace(); + shouldAdd = false; + } + } + } + if (shouldAdd) + centrifugeRecipies.add(recipie); + } - public static void registerCentrifugeRecipe(CentrifugeRecipie recipie) { - boolean shouldAdd = true; - for (CentrifugeRecipie centrifugeRecipie : centrifugeRecipies) { - if (ItemUtils.isItemEqual(centrifugeRecipie.getInputItem(), recipie.getInputItem(), false, true)) { - try { - throw new RegisteredItemRecipe("Item " + recipie.getInputItem().getUnlocalizedName() + " is already being used in a recipe for the Centrifuge"); - } catch (RegisteredItemRecipe registeredItemRecipe) { - registeredItemRecipe.printStackTrace(); - shouldAdd = false; - } - } - } - if (shouldAdd) - centrifugeRecipies.add(recipie); - } + public static void addRollingMachinceRecipe(ItemStack output, + Object... components) + { + RollingMachineRecipe.instance.addRecipe(output, components); + } - public static void addRollingMachinceRecipe(ItemStack output, Object... components) { - RollingMachineRecipe.instance.addRecipe(output, components); - } - - public void addShapelessRollingMachinceRecipe(ItemStack output, Object... components) { - RollingMachineRecipe.instance.addShapelessRecipe(output, components); - } + public void addShapelessRollingMachinceRecipe(ItemStack output, + Object... components) + { + RollingMachineRecipe.instance.addShapelessRecipe(output, components); + } } - class RegisteredItemRecipe extends Exception { - public RegisteredItemRecipe(String message) { - super(message); - } + public RegisteredItemRecipe(String message) + { + super(message); + } } diff --git a/src/main/java/techreborn/api/package-info.java b/src/main/java/techreborn/api/package-info.java index 12307306f..ea40dd072 100644 --- a/src/main/java/techreborn/api/package-info.java +++ b/src/main/java/techreborn/api/package-info.java @@ -1,3 +1,5 @@ -@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") package techreborn.api; +@API(apiVersion = "@MODVERSION@", owner = "techreborn", provides = "techrebornAPI") +package techreborn.api; import cpw.mods.fml.common.API; + diff --git a/src/main/java/techreborn/blocks/BlockBlastFurnace.java b/src/main/java/techreborn/blocks/BlockBlastFurnace.java index 0ad19bfed..faa6b401b 100644 --- a/src/main/java/techreborn/blocks/BlockBlastFurnace.java +++ b/src/main/java/techreborn/blocks/BlockBlastFurnace.java @@ -1,7 +1,5 @@ package techreborn.blocks; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -19,115 +17,146 @@ import techreborn.client.GuiHandler; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileBlastFurnace; import techreborn.tiles.TileMachineCasing; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public class BlockBlastFurnace extends BlockContainer { -public class BlockBlastFurnace extends BlockContainer{ - @SideOnly(Side.CLIENT) private IIcon iconFront; - + @SideOnly(Side.CLIENT) private IIcon iconTop; - + @SideOnly(Side.CLIENT) private IIcon iconBottom; - - public BlockBlastFurnace(Material material) + + public BlockBlastFurnace(Material material) { super(material); setCreativeTab(TechRebornCreativeTab.instance); setBlockName("techreborn.blastfurnace"); setHardness(2F); } - - @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { - return new TileBlastFurnace(); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if (!player.isSneaking()) - for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){ - if(world.getTileEntity(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ) instanceof TileMachineCasing){ - TileMachineCasing casing = (TileMachineCasing) world.getTileEntity(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ); - if(casing.getMultiblockController() != null && casing.getMultiblockController().isAssembled()){ - player.openGui(Core.INSTANCE, GuiHandler.blastFurnaceID, world, x, y, z); - } - } - } - return true; - } - - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister icon) { - this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); - this.iconFront = icon.registerIcon("techreborn:machine/industrial_blast_furnace_front_off"); - this.iconTop = icon.registerIcon("techreborn:machine/machine_side"); - this.iconBottom = icon.registerIcon("techreborn:machine/machine_side"); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop: (side == metadata ? this.iconFront : this.blockIcon)); + @Override + public TileEntity createNewTileEntity(World world, int p_149915_2_) + { + return new TileBlastFurnace(); + } - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, + EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + if (!player.isSneaking()) + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) + { + if (world.getTileEntity(x + direction.offsetX, y + + direction.offsetY, z + direction.offsetZ) instanceof TileMachineCasing) + { + TileMachineCasing casing = (TileMachineCasing) world + .getTileEntity(x + direction.offsetX, y + + direction.offsetY, z + direction.offsetZ); + if (casing.getMultiblockController() != null + && casing.getMultiblockController().isAssembled()) + { + player.openGui(Core.INSTANCE, + GuiHandler.blastFurnaceID, world, x, y, z); + } + } + } + return true; + } - public void onBlockAdded(World world, int x, int y, int z) { + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); + this.iconFront = icon + .registerIcon("techreborn:machine/industrial_blast_furnace_front_off"); + this.iconTop = icon.registerIcon("techreborn:machine/machine_side"); + this.iconBottom = icon.registerIcon("techreborn:machine/machine_side"); + } - super.onBlockAdded(world, x, y, z); - this.setDefaultDirection(world, x, y, z); + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metadata) + { - } - - private void setDefaultDirection(World world, int x, int y, int z) { + return metadata == 0 && side == 3 ? this.iconFront + : side == 1 ? this.iconTop : (side == 0 ? this.iconTop + : (side == metadata ? this.iconFront : this.blockIcon)); - if(!world.isRemote) { - Block block1 = world.getBlock(x, y, z - 1); - Block block2 = world.getBlock(x, y, z + 1); - Block block3 = world.getBlock(x - 1, y, z); - Block block4 = world.getBlock(x + 1, y, z); + } - byte b = 3; + public void onBlockAdded(World world, int x, int y, int z) + { - if(block1.func_149730_j() && !block2.func_149730_j()) { - b = 3; - } - if(block2.func_149730_j() && !block1.func_149730_j()) { - b = 2; - } - if(block3.func_149730_j() && !block4.func_149730_j()) { - b = 5; - } - if(block4.func_149730_j() && !block3.func_149730_j()) { - b = 4; - } + super.onBlockAdded(world, x, y, z); + this.setDefaultDirection(world, x, y, z); - world.setBlockMetadataWithNotify(x, y, z, b, 2); + } - } + private void setDefaultDirection(World world, int x, int y, int z) + { - } - - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { + if (!world.isRemote) + { + Block block1 = world.getBlock(x, y, z - 1); + Block block2 = world.getBlock(x, y, z + 1); + Block block3 = world.getBlock(x - 1, y, z); + Block block4 = world.getBlock(x + 1, y, z); - int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3; + byte b = 3; - if(l == 0) { - world.setBlockMetadataWithNotify(x, y, z, 2, 2); - } - if(l == 1) { - world.setBlockMetadataWithNotify(x, y, z, 5, 2); - } - if(l == 2) { - world.setBlockMetadataWithNotify(x, y, z, 3, 2); - } - if(l == 3) { - world.setBlockMetadataWithNotify(x, y, z, 4, 2); - } + if (block1.func_149730_j() && !block2.func_149730_j()) + { + b = 3; + } + if (block2.func_149730_j() && !block1.func_149730_j()) + { + b = 2; + } + if (block3.func_149730_j() && !block4.func_149730_j()) + { + b = 5; + } + if (block4.func_149730_j() && !block3.func_149730_j()) + { + b = 4; + } - } + world.setBlockMetadataWithNotify(x, y, z, b, 2); + + } + + } + + public void onBlockPlacedBy(World world, int x, int y, int z, + EntityLivingBase player, ItemStack itemstack) + { + + int l = MathHelper + .floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3; + + if (l == 0) + { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + } + if (l == 1) + { + world.setBlockMetadataWithNotify(x, y, z, 5, 2); + } + if (l == 2) + { + world.setBlockMetadataWithNotify(x, y, z, 3, 2); + } + if (l == 3) + { + world.setBlockMetadataWithNotify(x, y, z, 4, 2); + } + + } } diff --git a/src/main/java/techreborn/blocks/BlockCentrifuge.java b/src/main/java/techreborn/blocks/BlockCentrifuge.java index 6f2e56edc..4945dc908 100644 --- a/src/main/java/techreborn/blocks/BlockCentrifuge.java +++ b/src/main/java/techreborn/blocks/BlockCentrifuge.java @@ -1,7 +1,5 @@ package techreborn.blocks; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -16,104 +14,131 @@ import net.minecraft.world.World; import techreborn.Core; import techreborn.client.GuiHandler; import techreborn.tiles.TileCentrifuge; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockCentrifuge extends BlockContainer { @SideOnly(Side.CLIENT) private IIcon iconFront; - + @SideOnly(Side.CLIENT) private IIcon iconTop; - + @SideOnly(Side.CLIENT) private IIcon iconBottom; - - public BlockCentrifuge() { - super(Material.piston); - setHardness(2F); - } - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileCentrifuge(); - } + public BlockCentrifuge() + { + super(Material.piston); + setHardness(2F); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.centrifugeID, world, x, y, z); - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister icon) { - this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); - this.iconFront = icon.registerIcon("techreborn:machine/industrial_blast_furnace_front_off"); - this.iconTop = icon.registerIcon("techreborn:machine/industrial_grinder_top_on"); - this.iconBottom = icon.registerIcon("techreborn:machine/machine_side"); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileCentrifuge(); + } - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop: (side == metadata ? this.iconFront : this.blockIcon)); + @Override + public boolean onBlockActivated(World world, int x, int y, int z, + EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + if (!player.isSneaking()) + player.openGui(Core.INSTANCE, GuiHandler.centrifugeID, world, x, y, + z); + return true; + } - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); + this.iconFront = icon + .registerIcon("techreborn:machine/industrial_blast_furnace_front_off"); + this.iconTop = icon + .registerIcon("techreborn:machine/industrial_grinder_top_on"); + this.iconBottom = icon.registerIcon("techreborn:machine/machine_side"); + } - public void onBlockAdded(World world, int x, int y, int z) { + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metadata) + { - super.onBlockAdded(world, x, y, z); - this.setDefaultDirection(world, x, y, z); + return metadata == 0 && side == 3 ? this.iconFront + : side == 1 ? this.iconTop : (side == 0 ? this.iconTop + : (side == metadata ? this.iconFront : this.blockIcon)); - } - - private void setDefaultDirection(World world, int x, int y, int z) { + } - if(!world.isRemote) { - Block block1 = world.getBlock(x, y, z - 1); - Block block2 = world.getBlock(x, y, z + 1); - Block block3 = world.getBlock(x - 1, y, z); - Block block4 = world.getBlock(x + 1, y, z); + public void onBlockAdded(World world, int x, int y, int z) + { - byte b = 3; + super.onBlockAdded(world, x, y, z); + this.setDefaultDirection(world, x, y, z); - if(block1.func_149730_j() && !block2.func_149730_j()) { - b = 3; - } - if(block2.func_149730_j() && !block1.func_149730_j()) { - b = 2; - } - if(block3.func_149730_j() && !block4.func_149730_j()) { - b = 5; - } - if(block4.func_149730_j() && !block3.func_149730_j()) { - b = 4; - } + } - world.setBlockMetadataWithNotify(x, y, z, b, 2); + private void setDefaultDirection(World world, int x, int y, int z) + { - } + if (!world.isRemote) + { + Block block1 = world.getBlock(x, y, z - 1); + Block block2 = world.getBlock(x, y, z + 1); + Block block3 = world.getBlock(x - 1, y, z); + Block block4 = world.getBlock(x + 1, y, z); - } - - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { + byte b = 3; - int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3; + if (block1.func_149730_j() && !block2.func_149730_j()) + { + b = 3; + } + if (block2.func_149730_j() && !block1.func_149730_j()) + { + b = 2; + } + if (block3.func_149730_j() && !block4.func_149730_j()) + { + b = 5; + } + if (block4.func_149730_j() && !block3.func_149730_j()) + { + b = 4; + } - if(l == 0) { - world.setBlockMetadataWithNotify(x, y, z, 2, 2); - } - if(l == 1) { - world.setBlockMetadataWithNotify(x, y, z, 5, 2); - } - if(l == 2) { - world.setBlockMetadataWithNotify(x, y, z, 3, 2); - } - if(l == 3) { - world.setBlockMetadataWithNotify(x, y, z, 4, 2); - } + world.setBlockMetadataWithNotify(x, y, z, b, 2); - } + } + + } + + public void onBlockPlacedBy(World world, int x, int y, int z, + EntityLivingBase player, ItemStack itemstack) + { + + int l = MathHelper + .floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3; + + if (l == 0) + { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + } + if (l == 1) + { + world.setBlockMetadataWithNotify(x, y, z, 5, 2); + } + if (l == 2) + { + world.setBlockMetadataWithNotify(x, y, z, 3, 2); + } + if (l == 3) + { + world.setBlockMetadataWithNotify(x, y, z, 4, 2); + } + + } } diff --git a/src/main/java/techreborn/blocks/BlockMachineCasing.java b/src/main/java/techreborn/blocks/BlockMachineCasing.java index e8f0537eb..b115f625b 100644 --- a/src/main/java/techreborn/blocks/BlockMachineCasing.java +++ b/src/main/java/techreborn/blocks/BlockMachineCasing.java @@ -1,8 +1,8 @@ package techreborn.blocks; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import erogenousbeef.coreTR.multiblock.BlockMultiblockBase; +import java.util.List; +import java.util.Random; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -15,67 +15,79 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileMachineCasing; - -import java.util.List; -import java.util.Random; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import erogenousbeef.coreTR.multiblock.BlockMultiblockBase; public class BlockMachineCasing extends BlockMultiblockBase { - - public static final String[] types = new String[] {"Standard", "Reinforced", "Advanced"}; - private IIcon[] textures; - public BlockMachineCasing(Material material) + public static final String[] types = new String[] + { "Standard", "Reinforced", "Advanced" }; + private IIcon[] textures; + + public BlockMachineCasing(Material material) { super(material); setCreativeTab(TechRebornCreativeTab.instance); setBlockName("techreborn.machineCasing"); setHardness(2F); } - - @Override - public Item getItemDropped(int meta, Random random, int fortune) { - return Item.getItemFromBlock(this); - } - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { - for (int meta = 0; meta < types.length; meta++) { - list.add(new ItemStack(item, 1, meta)); - } - } + @Override + public Item getItemDropped(int meta, Random random, int fortune) + { + return Item.getItemFromBlock(this); + } - @Override - public int damageDropped(int metaData) { - //TODO RubyOre Returns Rubys - return metaData; - } + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; meta++) + { + list.add(new ItemStack(item, 1, meta)); + } + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - this.textures = new IIcon[types.length]; + @Override + public int damageDropped(int metaData) + { + // TODO RubyOre Returns Rubys + return metaData; + } - for (int i = 0; i < types.length; i++) { - textures[i] = iconRegister.registerIcon("techreborn:" + "machine/casing" + types[i]); - } - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) + { + this.textures = new IIcon[types.length]; - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metaData) { - metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); + for (int i = 0; i < types.length; i++) + { + textures[i] = iconRegister.registerIcon("techreborn:" + + "machine/casing" + types[i]); + } + } - if (ForgeDirection.getOrientation(side) == ForgeDirection.UP - || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) { - return textures[metaData]; - } else { - return textures[metaData]; - } - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metaData) + { + metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileMachineCasing(); - } + if (ForgeDirection.getOrientation(side) == ForgeDirection.UP + || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) + { + return textures[metaData]; + } else + { + return textures[metaData]; + } + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileMachineCasing(); + } } diff --git a/src/main/java/techreborn/blocks/BlockOre.java b/src/main/java/techreborn/blocks/BlockOre.java index c45fb7e9e..9a73e1c76 100644 --- a/src/main/java/techreborn/blocks/BlockOre.java +++ b/src/main/java/techreborn/blocks/BlockOre.java @@ -18,61 +18,71 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockOre extends Block { - public static final String[] types = new String[] - { - "Galena", "Iridium", "Ruby", "Sapphire", "Bauxite", "Pyrite", "Cinnabar", "Sphalerite", - "Tungston", "Sheldonite", "Olivine", "Sodalite", "Copper", "Tin", "Lead", "Silver" - }; + public static final String[] types = new String[] + { "Galena", "Iridium", "Ruby", "Sapphire", "Bauxite", "Pyrite", "Cinnabar", + "Sphalerite", "Tungston", "Sheldonite", "Olivine", "Sodalite", + "Copper", "Tin", "Lead", "Silver" }; - private IIcon[] textures; + private IIcon[] textures; - public BlockOre(Material material) { - super(material); - setBlockName("techreborn.ore"); - setCreativeTab(TechRebornCreativeTabMisc.instance); - setHardness(1f); - } + public BlockOre(Material material) + { + super(material); + setBlockName("techreborn.ore"); + setCreativeTab(TechRebornCreativeTabMisc.instance); + setHardness(1f); + } - @Override - public Item getItemDropped(int meta, Random random, int fortune) { - return Item.getItemFromBlock(this); - } + @Override + public Item getItemDropped(int meta, Random random, int fortune) + { + return Item.getItemFromBlock(this); + } - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { - for (int meta = 0; meta < types.length; meta++) { - list.add(new ItemStack(item, 1, meta)); - } - } + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; meta++) + { + list.add(new ItemStack(item, 1, meta)); + } + } - @Override - public int damageDropped(int metaData) { - //TODO RubyOre Returns Rubys - return metaData; - } + @Override + public int damageDropped(int metaData) + { + // TODO RubyOre Returns Rubys + return metaData; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - this.textures = new IIcon[types.length]; + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) + { + this.textures = new IIcon[types.length]; - for (int i = 0; i < types.length; i++) { - textures[i] = iconRegister.registerIcon("techreborn:" + "ore/ore" + types[i]); - } - } + for (int i = 0; i < types.length; i++) + { + textures[i] = iconRegister.registerIcon("techreborn:" + "ore/ore" + + types[i]); + } + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metaData) { - metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metaData) + { + metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); - if (ForgeDirection.getOrientation(side) == ForgeDirection.UP - || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) { - return textures[metaData]; - } else { - return textures[metaData]; - } - } + if (ForgeDirection.getOrientation(side) == ForgeDirection.UP + || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) + { + return textures[metaData]; + } else + { + return textures[metaData]; + } + } } diff --git a/src/main/java/techreborn/blocks/BlockQuantumChest.java b/src/main/java/techreborn/blocks/BlockQuantumChest.java index d5e3b558e..d4bdbbe43 100644 --- a/src/main/java/techreborn/blocks/BlockQuantumChest.java +++ b/src/main/java/techreborn/blocks/BlockQuantumChest.java @@ -1,7 +1,5 @@ package techreborn.blocks; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -12,47 +10,57 @@ import net.minecraft.world.World; import techreborn.Core; import techreborn.client.GuiHandler; import techreborn.tiles.TileQuantumChest; - +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockQuantumChest extends BlockContainer { - @SideOnly(Side.CLIENT) - private IIcon top; - @SideOnly(Side.CLIENT) - private IIcon other; + @SideOnly(Side.CLIENT) + private IIcon top; + @SideOnly(Side.CLIENT) + private IIcon other; - public BlockQuantumChest() { - super(Material.piston); - setHardness(2f); - } + public BlockQuantumChest() + { + super(Material.piston); + setHardness(2f); + } - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileQuantumChest(); - } + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileQuantumChest(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.quantumChestID, world, x, y, z); - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, + EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + if (!player.isSneaking()) + player.openGui(Core.INSTANCE, GuiHandler.quantumChestID, world, x, + y, z); + return true; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister icon) { - top = icon.registerIcon("techreborn:machine/quantum_top"); - other = icon.registerIcon("techreborn:machine/quantum_chest"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister icon) + { + top = icon.registerIcon("techreborn:machine/quantum_top"); + other = icon.registerIcon("techreborn:machine/quantum_chest"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int currentSide, int meta) { - //TODO chest rotation - if (currentSide == 1) { - return top; - } else { - return other; - } - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int currentSide, int meta) + { + // TODO chest rotation + if (currentSide == 1) + { + return top; + } else + { + return other; + } + } } diff --git a/src/main/java/techreborn/blocks/BlockQuantumTank.java b/src/main/java/techreborn/blocks/BlockQuantumTank.java index fdb93121f..7e6092085 100644 --- a/src/main/java/techreborn/blocks/BlockQuantumTank.java +++ b/src/main/java/techreborn/blocks/BlockQuantumTank.java @@ -1,7 +1,5 @@ package techreborn.blocks; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -12,45 +10,56 @@ import net.minecraft.world.World; import techreborn.Core; import techreborn.client.GuiHandler; import techreborn.tiles.TileQuantumTank; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockQuantumTank extends BlockContainer { - @SideOnly(Side.CLIENT) - private IIcon top; - @SideOnly(Side.CLIENT) - private IIcon other; + @SideOnly(Side.CLIENT) + private IIcon top; + @SideOnly(Side.CLIENT) + private IIcon other; - public BlockQuantumTank() { - super(Material.piston); - setHardness(2f); - } + public BlockQuantumTank() + { + super(Material.piston); + setHardness(2f); + } - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileQuantumTank(); - } + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileQuantumTank(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.quantumTankID, world, x, y, z); - return true; - } + @Override + public boolean onBlockActivated(World world, int x, int y, int z, + EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + if (!player.isSneaking()) + player.openGui(Core.INSTANCE, GuiHandler.quantumTankID, world, x, + y, z); + return true; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister icon) { - top = icon.registerIcon("techreborn:machine/quantum_top"); - other = icon.registerIcon("techreborn:machine/ThermalGenerator_other"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister icon) + { + top = icon.registerIcon("techreborn:machine/quantum_top"); + other = icon.registerIcon("techreborn:machine/ThermalGenerator_other"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int currentSide, int meta) { - if (currentSide == 1) { - return top; - } else { - return other; - } - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int currentSide, int meta) + { + if (currentSide == 1) + { + return top; + } else + { + return other; + } + } } diff --git a/src/main/java/techreborn/blocks/BlockRollingMachine.java b/src/main/java/techreborn/blocks/BlockRollingMachine.java index 11eb683ab..dcc1936e3 100644 --- a/src/main/java/techreborn/blocks/BlockRollingMachine.java +++ b/src/main/java/techreborn/blocks/BlockRollingMachine.java @@ -1,7 +1,5 @@ package techreborn.blocks; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -17,106 +15,132 @@ import techreborn.Core; import techreborn.client.GuiHandler; import techreborn.client.TechRebornCreativeTab; import techreborn.tiles.TileRollingMachine; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockRollingMachine extends BlockContainer { @SideOnly(Side.CLIENT) private IIcon iconFront; - + @SideOnly(Side.CLIENT) private IIcon iconTop; - + @SideOnly(Side.CLIENT) private IIcon iconBottom; - public BlockRollingMachine(Material material) { - super(material.piston); - setCreativeTab(TechRebornCreativeTab.instance); - setBlockName("techreborn.rollingmachine"); - setHardness(2f); - } + public BlockRollingMachine(Material material) + { + super(material.piston); + setCreativeTab(TechRebornCreativeTab.instance); + setBlockName("techreborn.rollingmachine"); + setHardness(2f); + } - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileRollingMachine(); - } + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileRollingMachine(); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.rollingMachineID, world, x, y, z); - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister icon) { - this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); - this.iconFront = icon.registerIcon("techreborn:machine/machine_side"); - this.iconTop = icon.registerIcon("techreborn:machine/rollingmachine_top"); - this.iconBottom = icon.registerIcon("techreborn:machine/machine_side"); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { + @Override + public boolean onBlockActivated(World world, int x, int y, int z, + EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + if (!player.isSneaking()) + player.openGui(Core.INSTANCE, GuiHandler.rollingMachineID, world, + x, y, z); + return true; + } - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop: (side == metadata ? this.iconFront : this.blockIcon)); + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); + this.iconFront = icon.registerIcon("techreborn:machine/machine_side"); + this.iconTop = icon + .registerIcon("techreborn:machine/rollingmachine_top"); + this.iconBottom = icon.registerIcon("techreborn:machine/machine_side"); + } - } + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metadata) + { - public void onBlockAdded(World world, int x, int y, int z) { + return metadata == 0 && side == 3 ? this.iconFront + : side == 1 ? this.iconTop : (side == 0 ? this.iconTop + : (side == metadata ? this.iconFront : this.blockIcon)); - super.onBlockAdded(world, x, y, z); - this.setDefaultDirection(world, x, y, z); + } - } - - private void setDefaultDirection(World world, int x, int y, int z) { + public void onBlockAdded(World world, int x, int y, int z) + { - if(!world.isRemote) { - Block block1 = world.getBlock(x, y, z - 1); - Block block2 = world.getBlock(x, y, z + 1); - Block block3 = world.getBlock(x - 1, y, z); - Block block4 = world.getBlock(x + 1, y, z); + super.onBlockAdded(world, x, y, z); + this.setDefaultDirection(world, x, y, z); - byte b = 3; + } - if(block1.func_149730_j() && !block2.func_149730_j()) { - b = 3; - } - if(block2.func_149730_j() && !block1.func_149730_j()) { - b = 2; - } - if(block3.func_149730_j() && !block4.func_149730_j()) { - b = 5; - } - if(block4.func_149730_j() && !block3.func_149730_j()) { - b = 4; - } + private void setDefaultDirection(World world, int x, int y, int z) + { - world.setBlockMetadataWithNotify(x, y, z, b, 2); + if (!world.isRemote) + { + Block block1 = world.getBlock(x, y, z - 1); + Block block2 = world.getBlock(x, y, z + 1); + Block block3 = world.getBlock(x - 1, y, z); + Block block4 = world.getBlock(x + 1, y, z); - } + byte b = 3; - } - - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { + if (block1.func_149730_j() && !block2.func_149730_j()) + { + b = 3; + } + if (block2.func_149730_j() && !block1.func_149730_j()) + { + b = 2; + } + if (block3.func_149730_j() && !block4.func_149730_j()) + { + b = 5; + } + if (block4.func_149730_j() && !block3.func_149730_j()) + { + b = 4; + } - int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3; + world.setBlockMetadataWithNotify(x, y, z, b, 2); - if(l == 0) { - world.setBlockMetadataWithNotify(x, y, z, 2, 2); - } - if(l == 1) { - world.setBlockMetadataWithNotify(x, y, z, 5, 2); - } - if(l == 2) { - world.setBlockMetadataWithNotify(x, y, z, 3, 2); - } - if(l == 3) { - world.setBlockMetadataWithNotify(x, y, z, 4, 2); - } + } - } + } + + public void onBlockPlacedBy(World world, int x, int y, int z, + EntityLivingBase player, ItemStack itemstack) + { + + int l = MathHelper + .floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3; + + if (l == 0) + { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + } + if (l == 1) + { + world.setBlockMetadataWithNotify(x, y, z, 5, 2); + } + if (l == 2) + { + world.setBlockMetadataWithNotify(x, y, z, 3, 2); + } + if (l == 3) + { + world.setBlockMetadataWithNotify(x, y, z, 4, 2); + } + + } } diff --git a/src/main/java/techreborn/blocks/BlockStorage.java b/src/main/java/techreborn/blocks/BlockStorage.java index 3f554bdd9..f96bfa686 100644 --- a/src/main/java/techreborn/blocks/BlockStorage.java +++ b/src/main/java/techreborn/blocks/BlockStorage.java @@ -18,60 +18,70 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockStorage extends Block { - public static final String[] types = new String[] - { - "Silver", "Aluminium", "Titanium", "Sapphire", "Ruby", "GreenSapphire", "Chrome", "Electrum", "Tungsten", - "Lead", "Zinc", "Brass", "Steel", "Platinum", "Nickel", "Invar", - }; + public static final String[] types = new String[] + { "Silver", "Aluminium", "Titanium", "Sapphire", "Ruby", "GreenSapphire", + "Chrome", "Electrum", "Tungsten", "Lead", "Zinc", "Brass", "Steel", + "Platinum", "Nickel", "Invar", }; - private IIcon[] textures; + private IIcon[] textures; - public BlockStorage(Material material) { - super(material); - setBlockName("techreborn.storage"); - setCreativeTab(TechRebornCreativeTabMisc.instance); - setHardness(2f); - } + public BlockStorage(Material material) + { + super(material); + setBlockName("techreborn.storage"); + setCreativeTab(TechRebornCreativeTabMisc.instance); + setHardness(2f); + } - @Override - public Item getItemDropped(int par1, Random random, int par2) { - return Item.getItemFromBlock(this); - } + @Override + public Item getItemDropped(int par1, Random random, int par2) + { + return Item.getItemFromBlock(this); + } - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { - for (int meta = 0; meta < types.length; meta++) { - list.add(new ItemStack(item, 1, meta)); - } - } + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; meta++) + { + list.add(new ItemStack(item, 1, meta)); + } + } - @Override - public int damageDropped(int metaData) { - return metaData; - } + @Override + public int damageDropped(int metaData) + { + return metaData; + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - this.textures = new IIcon[types.length]; + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) + { + this.textures = new IIcon[types.length]; - for (int i = 0; i < types.length; i++) { - textures[i] = iconRegister.registerIcon("techreborn:" + "storage/storage" + types[i]); - } - } + for (int i = 0; i < types.length; i++) + { + textures[i] = iconRegister.registerIcon("techreborn:" + + "storage/storage" + types[i]); + } + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metaData) { - metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metaData) + { + metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); - if (ForgeDirection.getOrientation(side) == ForgeDirection.UP - || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) { - return textures[metaData]; - } else { - return textures[metaData]; - } - } + if (ForgeDirection.getOrientation(side) == ForgeDirection.UP + || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) + { + return textures[metaData]; + } else + { + return textures[metaData]; + } + } } diff --git a/src/main/java/techreborn/blocks/BlockThermalGenerator.java b/src/main/java/techreborn/blocks/BlockThermalGenerator.java index f79a01f06..134dbb5da 100644 --- a/src/main/java/techreborn/blocks/BlockThermalGenerator.java +++ b/src/main/java/techreborn/blocks/BlockThermalGenerator.java @@ -1,7 +1,7 @@ package techreborn.blocks; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -18,113 +18,137 @@ import net.minecraft.world.World; import techreborn.Core; import techreborn.client.GuiHandler; import techreborn.tiles.TileThermalGenerator; - -import java.util.Random; - +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockThermalGenerator extends BlockContainer { @SideOnly(Side.CLIENT) private IIcon iconFront; - + @SideOnly(Side.CLIENT) private IIcon iconTop; - + @SideOnly(Side.CLIENT) private IIcon iconBottom; - public BlockThermalGenerator() { - super(Material.piston); - setHardness(2f); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister icon) { - this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); - this.iconFront = icon.registerIcon("techreborn:machine/machine_side"); - this.iconTop = icon.registerIcon("techreborn:machine/ThermalGenerator_top"); - this.iconBottom = icon.registerIcon("techreborn:machine/machine_side"); - } - - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int metadata) { + public BlockThermalGenerator() + { + super(Material.piston); + setHardness(2f); + } - return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop: (side == metadata ? this.iconFront : this.blockIcon)); + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister icon) + { + this.blockIcon = icon.registerIcon("techreborn:machine/machine_side"); + this.iconFront = icon.registerIcon("techreborn:machine/machine_side"); + this.iconTop = icon + .registerIcon("techreborn:machine/ThermalGenerator_top"); + this.iconBottom = icon.registerIcon("techreborn:machine/machine_side"); + } - } + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int metadata) + { - public void onBlockAdded(World world, int x, int y, int z) { + return metadata == 0 && side == 3 ? this.iconFront + : side == 1 ? this.iconTop : (side == 0 ? this.iconTop + : (side == metadata ? this.iconFront : this.blockIcon)); - super.onBlockAdded(world, x, y, z); - this.setDefaultDirection(world, x, y, z); + } - } - - private void setDefaultDirection(World world, int x, int y, int z) { + public void onBlockAdded(World world, int x, int y, int z) + { - if(!world.isRemote) { - Block block1 = world.getBlock(x, y, z - 1); - Block block2 = world.getBlock(x, y, z + 1); - Block block3 = world.getBlock(x - 1, y, z); - Block block4 = world.getBlock(x + 1, y, z); + super.onBlockAdded(world, x, y, z); + this.setDefaultDirection(world, x, y, z); - byte b = 3; + } - if(block1.func_149730_j() && !block2.func_149730_j()) { - b = 3; - } - if(block2.func_149730_j() && !block1.func_149730_j()) { - b = 2; - } - if(block3.func_149730_j() && !block4.func_149730_j()) { - b = 5; - } - if(block4.func_149730_j() && !block3.func_149730_j()) { - b = 4; - } + private void setDefaultDirection(World world, int x, int y, int z) + { - world.setBlockMetadataWithNotify(x, y, z, b, 2); + if (!world.isRemote) + { + Block block1 = world.getBlock(x, y, z - 1); + Block block2 = world.getBlock(x, y, z + 1); + Block block3 = world.getBlock(x - 1, y, z); + Block block4 = world.getBlock(x + 1, y, z); - } + byte b = 3; - } - - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { + if (block1.func_149730_j() && !block2.func_149730_j()) + { + b = 3; + } + if (block2.func_149730_j() && !block1.func_149730_j()) + { + b = 2; + } + if (block3.func_149730_j() && !block4.func_149730_j()) + { + b = 5; + } + if (block4.func_149730_j() && !block3.func_149730_j()) + { + b = 4; + } - int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3; + world.setBlockMetadataWithNotify(x, y, z, b, 2); - if(l == 0) { - world.setBlockMetadataWithNotify(x, y, z, 2, 2); - } - if(l == 1) { - world.setBlockMetadataWithNotify(x, y, z, 5, 2); - } - if(l == 2) { - world.setBlockMetadataWithNotify(x, y, z, 3, 2); - } - if(l == 3) { - world.setBlockMetadataWithNotify(x, y, z, 4, 2); - } + } - } + } - @Override - public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { - return new TileThermalGenerator(); - } + public void onBlockPlacedBy(World world, int x, int y, int z, + EntityLivingBase player, ItemStack itemstack) + { + int l = MathHelper + .floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3; - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - if (!player.isSneaking()) - player.openGui(Core.INSTANCE, GuiHandler.thermalGeneratorID, world, x, y, z); - return true; - } + if (l == 0) + { + world.setBlockMetadataWithNotify(x, y, z, 2, 2); + } + if (l == 1) + { + world.setBlockMetadataWithNotify(x, y, z, 5, 2); + } + if (l == 2) + { + world.setBlockMetadataWithNotify(x, y, z, 3, 2); + } + if (l == 3) + { + world.setBlockMetadataWithNotify(x, y, z, 4, 2); + } - @Override - public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { - //TODO change when added crafting - return Item.getItemFromBlock(Blocks.furnace); - } + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) + { + return new TileThermalGenerator(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, + EntityPlayer player, int side, float hitX, float hitY, float hitZ) + { + if (!player.isSneaking()) + player.openGui(Core.INSTANCE, GuiHandler.thermalGeneratorID, world, + x, y, z); + return true; + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, + int p_149650_3_) + { + // TODO change when added crafting + return Item.getItemFromBlock(Blocks.furnace); + } } diff --git a/src/main/java/techreborn/client/GuiHandler.java b/src/main/java/techreborn/client/GuiHandler.java index 3e394c9f4..ca5aa6c73 100644 --- a/src/main/java/techreborn/client/GuiHandler.java +++ b/src/main/java/techreborn/client/GuiHandler.java @@ -1,63 +1,106 @@ package techreborn.client; - -import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import techreborn.client.container.*; -import techreborn.client.gui.*; +import techreborn.client.container.ContainerBlastFurnace; +import techreborn.client.container.ContainerCentrifuge; +import techreborn.client.container.ContainerQuantumChest; +import techreborn.client.container.ContainerQuantumTank; +import techreborn.client.container.ContainerRollingMachine; +import techreborn.client.container.ContainerThermalGenerator; +import techreborn.client.gui.GuiBlastFurnace; +import techreborn.client.gui.GuiCentrifuge; +import techreborn.client.gui.GuiQuantumChest; +import techreborn.client.gui.GuiQuantumTank; +import techreborn.client.gui.GuiRollingMachine; +import techreborn.client.gui.GuiThermalGenerator; import techreborn.pda.GuiPda; -import techreborn.tiles.*; +import techreborn.tiles.TileBlastFurnace; +import techreborn.tiles.TileCentrifuge; +import techreborn.tiles.TileQuantumChest; +import techreborn.tiles.TileQuantumTank; +import techreborn.tiles.TileRollingMachine; +import techreborn.tiles.TileThermalGenerator; +import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { - public static final int thermalGeneratorID = 0; - public static final int quantumTankID = 1; - public static final int quantumChestID = 2; - public static final int centrifugeID = 3; - public static final int rollingMachineID = 4; - public static final int blastFurnaceID = 5; - public static final int pdaID = 6; + public static final int thermalGeneratorID = 0; + public static final int quantumTankID = 1; + public static final int quantumChestID = 2; + public static final int centrifugeID = 3; + public static final int rollingMachineID = 4; + public static final int blastFurnaceID = 5; + public static final int pdaID = 6; + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, + int x, int y, int z) + { + if (ID == thermalGeneratorID) + { + return new ContainerThermalGenerator( + (TileThermalGenerator) world.getTileEntity(x, y, z), player); + } else if (ID == quantumTankID) + { + return new ContainerQuantumTank( + (TileQuantumTank) world.getTileEntity(x, y, z), player); + } else if (ID == quantumChestID) + { + return new ContainerQuantumChest( + (TileQuantumChest) world.getTileEntity(x, y, z), player); + } else if (ID == centrifugeID) + { + return new ContainerCentrifuge( + (TileCentrifuge) world.getTileEntity(x, y, z), player); + } else if (ID == rollingMachineID) + { + return new ContainerRollingMachine( + (TileRollingMachine) world.getTileEntity(x, y, z), player); + } else if (ID == blastFurnaceID) + { + return new ContainerBlastFurnace( + (TileBlastFurnace) world.getTileEntity(x, y, z), player); + } else if (ID == pdaID) + { + return null; + } - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - if (ID == thermalGeneratorID) { - return new ContainerThermalGenerator((TileThermalGenerator) world.getTileEntity(x, y, z), player); - } else if (ID == quantumTankID) { - return new ContainerQuantumTank((TileQuantumTank) world.getTileEntity(x, y, z), player); - } else if (ID == quantumChestID) { - return new ContainerQuantumChest((TileQuantumChest) world.getTileEntity(x, y, z), player); - } else if (ID == centrifugeID) { - return new ContainerCentrifuge((TileCentrifuge) world.getTileEntity(x, y, z), player); - } else if (ID == rollingMachineID) { - return new ContainerRollingMachine((TileRollingMachine) world.getTileEntity(x, y, z), player); - } else if (ID == blastFurnaceID) { - return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(x, y, z), player); - } else if (ID == pdaID) { - return null; - } - - return null; - } + return null; + } - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - if (ID == thermalGeneratorID) { - return new GuiThermalGenerator(player, (TileThermalGenerator) world.getTileEntity(x, y, z)); - } else if (ID == quantumTankID) { - return new GuiQuantumTank(player, (TileQuantumTank) world.getTileEntity(x, y, z)); - } else if (ID == quantumChestID) { - return new GuiQuantumChest(player, (TileQuantumChest) world.getTileEntity(x, y, z)); - } else if (ID == centrifugeID) { - return new GuiCentrifuge(player, (TileCentrifuge) world.getTileEntity(x, y, z)); - } else if (ID == rollingMachineID) { - return new GuiRollingMachine(player, (TileRollingMachine) world.getTileEntity(x, y, z)); - } else if (ID == blastFurnaceID) { - return new GuiBlastFurnace(player, (TileBlastFurnace) world.getTileEntity(x, y, z)); - } else if (ID == pdaID) { - return new GuiPda(player); - } - return null; - } + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, + int x, int y, int z) + { + if (ID == thermalGeneratorID) + { + return new GuiThermalGenerator(player, + (TileThermalGenerator) world.getTileEntity(x, y, z)); + } else if (ID == quantumTankID) + { + return new GuiQuantumTank(player, + (TileQuantumTank) world.getTileEntity(x, y, z)); + } else if (ID == quantumChestID) + { + return new GuiQuantumChest(player, + (TileQuantumChest) world.getTileEntity(x, y, z)); + } else if (ID == centrifugeID) + { + return new GuiCentrifuge(player, + (TileCentrifuge) world.getTileEntity(x, y, z)); + } else if (ID == rollingMachineID) + { + return new GuiRollingMachine(player, + (TileRollingMachine) world.getTileEntity(x, y, z)); + } else if (ID == blastFurnaceID) + { + return new GuiBlastFurnace(player, + (TileBlastFurnace) world.getTileEntity(x, y, z)); + } else if (ID == pdaID) + { + return new GuiPda(player); + } + return null; + } } diff --git a/src/main/java/techreborn/client/SlotFake.java b/src/main/java/techreborn/client/SlotFake.java index ad7a5e443..ab23bcfdf 100644 --- a/src/main/java/techreborn/client/SlotFake.java +++ b/src/main/java/techreborn/client/SlotFake.java @@ -4,34 +4,38 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - public class SlotFake extends Slot { - public boolean mCanInsertItem; - public boolean mCanStackItem; - public int mMaxStacksize = 127; + public boolean mCanInsertItem; + public boolean mCanStackItem; + public int mMaxStacksize = 127; + public SlotFake(IInventory par1iInventory, int par2, int par3, int par4, + boolean aCanInsertItem, boolean aCanStackItem, int aMaxStacksize) + { + super(par1iInventory, par2, par3, par4); + this.mCanInsertItem = aCanInsertItem; + this.mCanStackItem = aCanStackItem; + this.mMaxStacksize = aMaxStacksize; + } - public SlotFake(IInventory par1iInventory, int par2, int par3, int par4, boolean aCanInsertItem, boolean aCanStackItem, int aMaxStacksize) { - super(par1iInventory, par2, par3, par4); - this.mCanInsertItem = aCanInsertItem; - this.mCanStackItem = aCanStackItem; - this.mMaxStacksize = aMaxStacksize; - } + public boolean isItemValid(ItemStack par1ItemStack) + { + return this.mCanInsertItem; + } - public boolean isItemValid(ItemStack par1ItemStack) { - return this.mCanInsertItem; - } + public int getSlotStackLimit() + { + return this.mMaxStacksize; + } - public int getSlotStackLimit() { - return this.mMaxStacksize; - } + public boolean getHasStack() + { + return false; + } - public boolean getHasStack() { - return false; - } - - public ItemStack decrStackSize(int par1) { - return !this.mCanStackItem ? null : super.decrStackSize(par1); - } + public ItemStack decrStackSize(int par1) + { + return !this.mCanStackItem ? null : super.decrStackSize(par1); + } } diff --git a/src/main/java/techreborn/client/SlotInput.java b/src/main/java/techreborn/client/SlotInput.java index 576b89f6f..862951e04 100644 --- a/src/main/java/techreborn/client/SlotInput.java +++ b/src/main/java/techreborn/client/SlotInput.java @@ -6,15 +6,18 @@ import net.minecraft.item.ItemStack; public class SlotInput extends Slot { - public SlotInput(IInventory par1iInventory, int par2, int par3, int par4) { - super(par1iInventory, par2, par3, par4); - } + public SlotInput(IInventory par1iInventory, int par2, int par3, int par4) + { + super(par1iInventory, par2, par3, par4); + } - public boolean isItemValid(ItemStack par1ItemStack) { - return false; - } + public boolean isItemValid(ItemStack par1ItemStack) + { + return false; + } - public int getSlotStackLimit() { - return 64; - } + public int getSlotStackLimit() + { + return 64; + } } \ No newline at end of file diff --git a/src/main/java/techreborn/client/SlotOutput.java b/src/main/java/techreborn/client/SlotOutput.java index 39be3da1e..b91a5b569 100644 --- a/src/main/java/techreborn/client/SlotOutput.java +++ b/src/main/java/techreborn/client/SlotOutput.java @@ -6,15 +6,18 @@ import net.minecraft.item.ItemStack; public class SlotOutput extends Slot { - public SlotOutput(IInventory par1iInventory, int par2, int par3, int par4) { - super(par1iInventory, par2, par3, par4); - } + public SlotOutput(IInventory par1iInventory, int par2, int par3, int par4) + { + super(par1iInventory, par2, par3, par4); + } - public boolean isItemValid(ItemStack par1ItemStack) { - return false; - } + public boolean isItemValid(ItemStack par1ItemStack) + { + return false; + } - public int getSlotStackLimit() { - return 64; - } + public int getSlotStackLimit() + { + return 64; + } } \ No newline at end of file diff --git a/src/main/java/techreborn/client/TechRebornCreativeTab.java b/src/main/java/techreborn/client/TechRebornCreativeTab.java index c05e2a489..9b57cccc0 100644 --- a/src/main/java/techreborn/client/TechRebornCreativeTab.java +++ b/src/main/java/techreborn/client/TechRebornCreativeTab.java @@ -6,14 +6,16 @@ import techreborn.init.ModBlocks; public class TechRebornCreativeTab extends CreativeTabs { - public static TechRebornCreativeTab instance = new TechRebornCreativeTab(); + public static TechRebornCreativeTab instance = new TechRebornCreativeTab(); - public TechRebornCreativeTab() { - super("techreborn"); - } + public TechRebornCreativeTab() + { + super("techreborn"); + } - @Override - public Item getTabIconItem() { - return Item.getItemFromBlock(ModBlocks.thermalGenerator); - } + @Override + public Item getTabIconItem() + { + return Item.getItemFromBlock(ModBlocks.thermalGenerator); + } } diff --git a/src/main/java/techreborn/client/TechRebornCreativeTabMisc.java b/src/main/java/techreborn/client/TechRebornCreativeTabMisc.java index e62d34422..0be9f1275 100644 --- a/src/main/java/techreborn/client/TechRebornCreativeTabMisc.java +++ b/src/main/java/techreborn/client/TechRebornCreativeTabMisc.java @@ -4,19 +4,19 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import techreborn.init.ModItems; -public class TechRebornCreativeTabMisc extends CreativeTabs{ - - public static TechRebornCreativeTabMisc instance = new TechRebornCreativeTabMisc(); +public class TechRebornCreativeTabMisc extends CreativeTabs { - public TechRebornCreativeTabMisc() - { - super("techreborn"); - } + public static TechRebornCreativeTabMisc instance = new TechRebornCreativeTabMisc(); - @Override - public Item getTabIconItem() - { - return ModItems.cells; - } + public TechRebornCreativeTabMisc() + { + super("techreborn"); + } + + @Override + public Item getTabIconItem() + { + return ModItems.cells; + } } diff --git a/src/main/java/techreborn/client/container/ContainerBlastFurnace.java b/src/main/java/techreborn/client/container/ContainerBlastFurnace.java index eed205809..cad01ea32 100644 --- a/src/main/java/techreborn/client/container/ContainerBlastFurnace.java +++ b/src/main/java/techreborn/client/container/ContainerBlastFurnace.java @@ -1,48 +1,53 @@ package techreborn.client.container; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import techreborn.client.SlotOutput; import techreborn.tiles.TileBlastFurnace; -import techreborn.tiles.TileCentrifuge; public class ContainerBlastFurnace extends TechRebornContainer { - EntityPlayer player; + EntityPlayer player; + + TileBlastFurnace tile; - TileBlastFurnace tile; - @Override - public boolean canInteractWith(EntityPlayer player) + public boolean canInteractWith(EntityPlayer player) { return true; } - public int tickTime; + public int tickTime; - public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace, EntityPlayer player) { - tile = tileblastfurnace; - this.player = player; + public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace, + EntityPlayer player) + { + tile = tileblastfurnace; + this.player = player; - //input - this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 0, 56, 25)); - this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 1, 56, 43)); - //outputs - this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2, 116, 35)); + // input + this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 0, 56, 25)); + this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 1, 56, 43)); + // outputs + this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2, + 116, 35)); + int i; - int i; + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + + 9, 8 + j * 18, 84 + i * 18)); + } + } - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); - } - } + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, + 142)); + } + } } diff --git a/src/main/java/techreborn/client/container/ContainerCentrifuge.java b/src/main/java/techreborn/client/container/ContainerCentrifuge.java index 9747098a4..da2afe31d 100644 --- a/src/main/java/techreborn/client/container/ContainerCentrifuge.java +++ b/src/main/java/techreborn/client/container/ContainerCentrifuge.java @@ -8,61 +8,77 @@ import techreborn.tiles.TileCentrifuge; public class ContainerCentrifuge extends TechRebornContainer { - EntityPlayer player; + EntityPlayer player; - TileCentrifuge tile; + TileCentrifuge tile; - public int tickTime; + public int tickTime; - public ContainerCentrifuge(TileCentrifuge tileCentrifuge, EntityPlayer player) { - tile = tileCentrifuge; - this.player = player; + public ContainerCentrifuge(TileCentrifuge tileCentrifuge, + EntityPlayer player) + { + tile = tileCentrifuge; + this.player = player; - //input - this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 0, 80, 35)); - //cells - this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 1, 50, 5)); - //outputs - this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80, 5)); - this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3, 110, 35)); - this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 4, 80, 65)); - this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 5, 50, 35)); + // input + this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 0, 80, 35)); + // cells + this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 1, 50, 5)); + // outputs + this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80, + 5)); + this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3, + 110, 35)); + this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 4, 80, + 65)); + this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 5, 50, + 35)); - int i; + int i; - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + + 9, 8 + j * 18, 84 + i * 18)); + } + } - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); - } - } + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, + 142)); + } + } - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } + @Override + public boolean canInteractWith(EntityPlayer player) + { + return true; + } - @Override - public void addCraftingToCrafters(ICrafting crafting) { - super.addCraftingToCrafters(crafting); - crafting.sendProgressBarUpdate(this, 0, tile.tickTime); - } + @Override + public void addCraftingToCrafters(ICrafting crafting) + { + super.addCraftingToCrafters(crafting); + crafting.sendProgressBarUpdate(this, 0, tile.tickTime); + } - /** - * Looks for changes made in the container, sends them to every listener. - */ - public void detectAndSendChanges() { - super.detectAndSendChanges(); - for (int i = 0; i < this.crafters.size(); ++i) { - ICrafting icrafting = (ICrafting) this.crafters.get(i); - if (this.tickTime != this.tile.tickTime) { - icrafting.sendProgressBarUpdate(this, 0, this.tile.tickTime); - } - } - this.tickTime = this.tile.tickTime; - } + /** + * Looks for changes made in the container, sends them to every listener. + */ + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting) this.crafters.get(i); + if (this.tickTime != this.tile.tickTime) + { + icrafting.sendProgressBarUpdate(this, 0, this.tile.tickTime); + } + } + this.tickTime = this.tile.tickTime; + } } diff --git a/src/main/java/techreborn/client/container/ContainerQuantumChest.java b/src/main/java/techreborn/client/container/ContainerQuantumChest.java index 2bf608be4..b7644f98f 100644 --- a/src/main/java/techreborn/client/container/ContainerQuantumChest.java +++ b/src/main/java/techreborn/client/container/ContainerQuantumChest.java @@ -7,34 +7,44 @@ import techreborn.client.SlotOutput; import techreborn.tiles.TileQuantumChest; public class ContainerQuantumChest extends TechRebornContainer { - public TileQuantumChest tileQuantumChest; - public EntityPlayer player; + public TileQuantumChest tileQuantumChest; + public EntityPlayer player; - public ContainerQuantumChest(TileQuantumChest tileQuantumChest, EntityPlayer player) { - super(); - this.tileQuantumChest = tileQuantumChest; - this.player = player; + public ContainerQuantumChest(TileQuantumChest tileQuantumChest, + EntityPlayer player) + { + super(); + this.tileQuantumChest = tileQuantumChest; + this.player = player; - this.addSlotToContainer(new Slot(tileQuantumChest.inventory, 0, 80, 17)); - this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1, 80, 53)); - this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59, 42, false, false, Integer.MAX_VALUE)); + this.addSlotToContainer(new Slot(tileQuantumChest.inventory, 0, 80, 17)); + this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1, + 80, 53)); + this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59, + 42, false, false, Integer.MAX_VALUE)); - int i; + int i; - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + + 9, 8 + j * 18, 84 + i * 18)); + } + } - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); - } - } + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, + 142)); + } + } - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } + @Override + public boolean canInteractWith(EntityPlayer player) + { + return true; + } } diff --git a/src/main/java/techreborn/client/container/ContainerQuantumTank.java b/src/main/java/techreborn/client/container/ContainerQuantumTank.java index 8a6f97801..6a2851563 100644 --- a/src/main/java/techreborn/client/container/ContainerQuantumTank.java +++ b/src/main/java/techreborn/client/container/ContainerQuantumTank.java @@ -7,33 +7,43 @@ import techreborn.client.SlotOutput; import techreborn.tiles.TileQuantumTank; public class ContainerQuantumTank extends TechRebornContainer { - public TileQuantumTank tileQuantumTank; - public EntityPlayer player; + public TileQuantumTank tileQuantumTank; + public EntityPlayer player; - public ContainerQuantumTank(TileQuantumTank tileQuantumTank, EntityPlayer player) { - super(); - this.tileQuantumTank = tileQuantumTank; - this.player = player; + public ContainerQuantumTank(TileQuantumTank tileQuantumTank, + EntityPlayer player) + { + super(); + this.tileQuantumTank = tileQuantumTank; + this.player = player; - this.addSlotToContainer(new Slot(tileQuantumTank.inventory, 0, 80, 17)); - this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1, 80, 53)); - this.addSlotToContainer(new SlotFake(tileQuantumTank.inventory, 2, 59, 42, false, false, 1)); + this.addSlotToContainer(new Slot(tileQuantumTank.inventory, 0, 80, 17)); + this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1, + 80, 53)); + this.addSlotToContainer(new SlotFake(tileQuantumTank.inventory, 2, 59, + 42, false, false, 1)); - int i; + int i; - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + + 9, 8 + j * 18, 84 + i * 18)); + } + } - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); - } - } + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, + 142)); + } + } - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } + @Override + public boolean canInteractWith(EntityPlayer player) + { + return true; + } } diff --git a/src/main/java/techreborn/client/container/ContainerRollingMachine.java b/src/main/java/techreborn/client/container/ContainerRollingMachine.java index 73c014ad4..30869a3db 100644 --- a/src/main/java/techreborn/client/container/ContainerRollingMachine.java +++ b/src/main/java/techreborn/client/container/ContainerRollingMachine.java @@ -11,50 +11,63 @@ import techreborn.tiles.TileRollingMachine; public class ContainerRollingMachine extends TechRebornContainer { - EntityPlayer player; - TileRollingMachine tile; + EntityPlayer player; + TileRollingMachine tile; - public ContainerRollingMachine(TileRollingMachine tileRollingmachine, EntityPlayer player) { - tile = tileRollingmachine; - this.player = player; + public ContainerRollingMachine(TileRollingMachine tileRollingmachine, + EntityPlayer player) + { + tile = tileRollingmachine; + this.player = player; + for (int l = 0; l < 3; l++) + { + for (int k1 = 0; k1 < 3; k1++) + { + this.addSlotToContainer(new Slot( + tileRollingmachine.craftMatrix, k1 + l * 3, + 30 + k1 * 18, 17 + l * 18)); + } + } - for (int l = 0; l < 3; l++) { - for (int k1 = 0; k1 < 3; k1++) { - this.addSlotToContainer(new Slot(tileRollingmachine.craftMatrix, k1 + l * 3, 30 + k1 * 18, 17 + l * 18)); - } - } + // output + this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 0, + 124, 35)); - //output - this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 0, 124, 35)); + // fakeOutput + this.addSlotToContainer(new SlotFake(tileRollingmachine.inventory, 1, + 124, 10, false, false, 1)); - //fakeOutput - this.addSlotToContainer(new SlotFake(tileRollingmachine.inventory, 1, 124, 10, false, false, 1)); + int i; + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + + 9, 8 + j * 18, 84 + i * 18)); + } + } - int i; + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, + 142)); + } + } - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); - } - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } - - @Override - public final void onCraftMatrixChanged(IInventory inv) { - ItemStack output = RollingMachineRecipe.instance.findMatchingRecipe(tile.craftMatrix, tile.getWorldObj()); - tile.inventory.setInventorySlotContents(1, output); - } + @Override + public boolean canInteractWith(EntityPlayer player) + { + return true; + } + @Override + public final void onCraftMatrixChanged(IInventory inv) + { + ItemStack output = RollingMachineRecipe.instance.findMatchingRecipe( + tile.craftMatrix, tile.getWorldObj()); + tile.inventory.setInventorySlotContents(1, output); + } } diff --git a/src/main/java/techreborn/client/container/ContainerThermalGenerator.java b/src/main/java/techreborn/client/container/ContainerThermalGenerator.java index 248c3ab2f..650469032 100644 --- a/src/main/java/techreborn/client/container/ContainerThermalGenerator.java +++ b/src/main/java/techreborn/client/container/ContainerThermalGenerator.java @@ -7,33 +7,44 @@ import techreborn.client.SlotOutput; import techreborn.tiles.TileThermalGenerator; public class ContainerThermalGenerator extends TechRebornContainer { - public TileThermalGenerator tileThermalGenerator; - public EntityPlayer player; + public TileThermalGenerator tileThermalGenerator; + public EntityPlayer player; - public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator, EntityPlayer player) { - super(); - this.tileThermalGenerator = tileThermalGenerator; - this.player = player; + public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator, + EntityPlayer player) + { + super(); + this.tileThermalGenerator = tileThermalGenerator; + this.player = player; - this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80, 17)); - this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory, 1, 80, 53)); - this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2, 59, 42, false, false, 1)); + this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80, + 17)); + this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory, + 1, 80, 53)); + this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2, + 59, 42, false, false, 1)); - int i; + int i; - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } + for (i = 0; i < 3; ++i) + { + for (int j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + + 9, 8 + j * 18, 84 + i * 18)); + } + } - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); - } - } + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, + 142)); + } + } - @Override - public boolean canInteractWith(EntityPlayer player) { - return true; - } + @Override + public boolean canInteractWith(EntityPlayer player) + { + return true; + } } diff --git a/src/main/java/techreborn/client/container/TechRebornContainer.java b/src/main/java/techreborn/client/container/TechRebornContainer.java index b4e290c9e..8699ab864 100644 --- a/src/main/java/techreborn/client/container/TechRebornContainer.java +++ b/src/main/java/techreborn/client/container/TechRebornContainer.java @@ -7,88 +7,112 @@ import net.minecraft.item.ItemStack; import techreborn.client.SlotFake; import techreborn.util.ItemUtils; - public abstract class TechRebornContainer extends Container { - public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { - ItemStack originalStack = null; - Slot slot = (Slot) inventorySlots.get(slotIndex); - int numSlots = inventorySlots.size(); - if (slot != null && slot.getHasStack()) { - ItemStack stackInSlot = slot.getStack(); - originalStack = stackInSlot.copy(); - if (slotIndex >= numSlots - 9 * 4 && tryShiftItem(stackInSlot, numSlots)) { - // NOOP - } else if (slotIndex >= numSlots - 9 * 4 && slotIndex < numSlots - 9) { - if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots)) - return null; - } else if (slotIndex >= numSlots - 9 && slotIndex < numSlots) { - if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9)) - return null; - } else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots)) - return null; - slot.onSlotChange(stackInSlot, originalStack); - if (stackInSlot.stackSize <= 0) - slot.putStack(null); - else - slot.onSlotChanged(); - if (stackInSlot.stackSize == originalStack.stackSize) - return null; - slot.onPickupFromSlot(player, stackInSlot); - } - return originalStack; - } + public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) + { + ItemStack originalStack = null; + Slot slot = (Slot) inventorySlots.get(slotIndex); + int numSlots = inventorySlots.size(); + if (slot != null && slot.getHasStack()) + { + ItemStack stackInSlot = slot.getStack(); + originalStack = stackInSlot.copy(); + if (slotIndex >= numSlots - 9 * 4 + && tryShiftItem(stackInSlot, numSlots)) + { + // NOOP + } else if (slotIndex >= numSlots - 9 * 4 + && slotIndex < numSlots - 9) + { + if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots)) + return null; + } else if (slotIndex >= numSlots - 9 && slotIndex < numSlots) + { + if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9)) + return null; + } else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots)) + return null; + slot.onSlotChange(stackInSlot, originalStack); + if (stackInSlot.stackSize <= 0) + slot.putStack(null); + else + slot.onSlotChanged(); + if (stackInSlot.stackSize == originalStack.stackSize) + return null; + slot.onPickupFromSlot(player, stackInSlot); + } + return originalStack; + } - protected boolean shiftItemStack(ItemStack stackToShift, int start, int end) { - boolean changed = false; - if (stackToShift.isStackable()) - for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) { - Slot slot = (Slot) inventorySlots.get(slotIndex); - ItemStack stackInSlot = slot.getStack(); - if (stackInSlot != null && ItemUtils.isItemEqual(stackInSlot, stackToShift, true, true)) { - int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize; - int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit()); - if (resultingStackSize <= max) { - stackToShift.stackSize = 0; - stackInSlot.stackSize = resultingStackSize; - slot.onSlotChanged(); - changed = true; - } else if (stackInSlot.stackSize < max) { - stackToShift.stackSize -= max - stackInSlot.stackSize; - stackInSlot.stackSize = max; - slot.onSlotChanged(); - changed = true; - } - } - } - if (stackToShift.stackSize > 0) - for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) { - Slot slot = (Slot) inventorySlots.get(slotIndex); - ItemStack stackInSlot = slot.getStack(); - if (stackInSlot == null) { - int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit()); - stackInSlot = stackToShift.copy(); - stackInSlot.stackSize = Math.min(stackToShift.stackSize, max); - stackToShift.stackSize -= stackInSlot.stackSize; - slot.putStack(stackInSlot); - slot.onSlotChanged(); - changed = true; - } - } - return changed; - } + protected boolean shiftItemStack(ItemStack stackToShift, int start, int end) + { + boolean changed = false; + if (stackToShift.isStackable()) + for (int slotIndex = start; stackToShift.stackSize > 0 + && slotIndex < end; slotIndex++) + { + Slot slot = (Slot) inventorySlots.get(slotIndex); + ItemStack stackInSlot = slot.getStack(); + if (stackInSlot != null + && ItemUtils.isItemEqual(stackInSlot, stackToShift, + true, true)) + { + int resultingStackSize = stackInSlot.stackSize + + stackToShift.stackSize; + int max = Math.min(stackToShift.getMaxStackSize(), + slot.getSlotStackLimit()); + if (resultingStackSize <= max) + { + stackToShift.stackSize = 0; + stackInSlot.stackSize = resultingStackSize; + slot.onSlotChanged(); + changed = true; + } else if (stackInSlot.stackSize < max) + { + stackToShift.stackSize -= max - stackInSlot.stackSize; + stackInSlot.stackSize = max; + slot.onSlotChanged(); + changed = true; + } + } + } + if (stackToShift.stackSize > 0) + for (int slotIndex = start; stackToShift.stackSize > 0 + && slotIndex < end; slotIndex++) + { + Slot slot = (Slot) inventorySlots.get(slotIndex); + ItemStack stackInSlot = slot.getStack(); + if (stackInSlot == null) + { + int max = Math.min(stackToShift.getMaxStackSize(), + slot.getSlotStackLimit()); + stackInSlot = stackToShift.copy(); + stackInSlot.stackSize = Math.min(stackToShift.stackSize, + max); + stackToShift.stackSize -= stackInSlot.stackSize; + slot.putStack(stackInSlot); + slot.onSlotChanged(); + changed = true; + } + } + return changed; + } - private boolean tryShiftItem(ItemStack stackToShift, int numSlots) { - for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++) { - Slot slot = (Slot) inventorySlots.get(machineIndex); - if (slot instanceof SlotFake) { - continue; - } - if (!slot.isItemValid(stackToShift)) - continue; - if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1)) - return true; - } - return false; - } + private boolean tryShiftItem(ItemStack stackToShift, int numSlots) + { + for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++) + { + Slot slot = (Slot) inventorySlots.get(machineIndex); + if (slot instanceof SlotFake) + { + continue; + } + if (!slot.isItemValid(stackToShift)) + continue; + if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1)) + return true; + } + return false; + } } diff --git a/src/main/java/techreborn/client/gui/GuiBlastFurnace.java b/src/main/java/techreborn/client/gui/GuiBlastFurnace.java index 05a9bd5e0..0fcf5e73d 100644 --- a/src/main/java/techreborn/client/gui/GuiBlastFurnace.java +++ b/src/main/java/techreborn/client/gui/GuiBlastFurnace.java @@ -5,33 +5,40 @@ import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import techreborn.client.container.ContainerBlastFurnace; -import techreborn.client.container.ContainerCentrifuge; import techreborn.tiles.TileBlastFurnace; -import techreborn.tiles.TileCentrifuge; public class GuiBlastFurnace extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_blast_furnace.png"); + private static final ResourceLocation texture = new ResourceLocation( + "techreborn", "textures/gui/industrial_blast_furnace.png"); - TileBlastFurnace blastfurnace; + TileBlastFurnace blastfurnace; - public GuiBlastFurnace(EntityPlayer player, TileBlastFurnace tileblastfurnace) { - super(new ContainerBlastFurnace(tileblastfurnace, player)); - this.xSize = 176; - this.ySize = 167; - blastfurnace = tileblastfurnace; - } + public GuiBlastFurnace(EntityPlayer player, + TileBlastFurnace tileblastfurnace) + { + super(new ContainerBlastFurnace(tileblastfurnace, player)); + this.xSize = 176; + this.ySize = 167; + blastfurnace = tileblastfurnace; + } - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - this.mc.getTextureManager().bindTexture(texture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, + int p_146976_2_, int p_146976_3_) + { + this.mc.getTextureManager().bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - this.fontRendererObj.drawString("Blastfurnace", 60, 6, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - } + protected void drawGuiContainerForegroundLayer(int p_146979_1_, + int p_146979_2_) + { + this.fontRendererObj.drawString("Blastfurnace", 60, 6, 4210752); + this.fontRendererObj.drawString( + I18n.format("container.inventory", new Object[0]), 8, + this.ySize - 96 + 2, 4210752); + } } diff --git a/src/main/java/techreborn/client/gui/GuiCentrifuge.java b/src/main/java/techreborn/client/gui/GuiCentrifuge.java index 975ff5ea2..2799b72be 100644 --- a/src/main/java/techreborn/client/gui/GuiCentrifuge.java +++ b/src/main/java/techreborn/client/gui/GuiCentrifuge.java @@ -9,28 +9,37 @@ import techreborn.tiles.TileCentrifuge; public class GuiCentrifuge extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/centrifuge.png"); + private static final ResourceLocation texture = new ResourceLocation( + "techreborn", "textures/gui/centrifuge.png"); - TileCentrifuge centrifuge; + TileCentrifuge centrifuge; - public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge) { - super(new ContainerCentrifuge(tileCentrifuge, player)); - this.xSize = 176; - this.ySize = 167; - centrifuge = tileCentrifuge; - } + public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge) + { + super(new ContainerCentrifuge(tileCentrifuge, player)); + this.xSize = 176; + this.ySize = 167; + centrifuge = tileCentrifuge; + } - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - this.mc.getTextureManager().bindTexture(texture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, + int p_146976_2_, int p_146976_3_) + { + this.mc.getTextureManager().bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - this.fontRendererObj.drawString("Centrifuge", 110, 6, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - this.fontRendererObj.drawString(centrifuge.tickTime + " " + centrifuge.isRunning, 110, this.ySize - 96 + 2, 4210752); - } + protected void drawGuiContainerForegroundLayer(int p_146979_1_, + int p_146979_2_) + { + this.fontRendererObj.drawString("Centrifuge", 110, 6, 4210752); + this.fontRendererObj.drawString( + I18n.format("container.inventory", new Object[0]), 8, + this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString(centrifuge.tickTime + " " + + centrifuge.isRunning, 110, this.ySize - 96 + 2, 4210752); + } } diff --git a/src/main/java/techreborn/client/gui/GuiQuantumChest.java b/src/main/java/techreborn/client/gui/GuiQuantumChest.java index 74e195646..db0e0e3ca 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumChest.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumChest.java @@ -1,6 +1,5 @@ package techreborn.client.gui; - import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; @@ -10,31 +9,39 @@ import techreborn.tiles.TileQuantumChest; public class GuiQuantumChest extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png"); + private static final ResourceLocation texture = new ResourceLocation( + "techreborn", "textures/gui/ThermalGenerator.png"); - TileQuantumChest tile; + TileQuantumChest tile; - public GuiQuantumChest(EntityPlayer player, TileQuantumChest tile) { - super(new ContainerQuantumChest(tile, player)); - this.xSize = 176; - this.ySize = 167; - this.tile = tile; - } + public GuiQuantumChest(EntityPlayer player, TileQuantumChest tile) + { + super(new ContainerQuantumChest(tile, player)); + this.xSize = 176; + this.ySize = 167; + this.tile = tile; + } - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - this.mc.getTextureManager().bindTexture(texture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, + int p_146976_2_, int p_146976_3_) + { + this.mc.getTextureManager().bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - this.fontRendererObj.drawString("Quantum Chest", 8, 6, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - this.fontRendererObj.drawString("Amount", 10, 20, 16448255); - if (tile.storedItem != null) - this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10, 30, 16448255); - } + protected void drawGuiContainerForegroundLayer(int p_146979_1_, + int p_146979_2_) + { + this.fontRendererObj.drawString("Quantum Chest", 8, 6, 4210752); + this.fontRendererObj.drawString( + I18n.format("container.inventory", new Object[0]), 8, + this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString("Amount", 10, 20, 16448255); + if (tile.storedItem != null) + this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10, + 30, 16448255); + } } - diff --git a/src/main/java/techreborn/client/gui/GuiQuantumTank.java b/src/main/java/techreborn/client/gui/GuiQuantumTank.java index 2430b17e2..4e13d9fea 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumTank.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumTank.java @@ -9,30 +9,38 @@ import techreborn.tiles.TileQuantumTank; public class GuiQuantumTank extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png"); + private static final ResourceLocation texture = new ResourceLocation( + "techreborn", "textures/gui/ThermalGenerator.png"); - TileQuantumTank tile; + TileQuantumTank tile; - public GuiQuantumTank(EntityPlayer player, TileQuantumTank tile) { - super(new ContainerQuantumTank(tile, player)); - this.xSize = 176; - this.ySize = 167; - this.tile = tile; - } + public GuiQuantumTank(EntityPlayer player, TileQuantumTank tile) + { + super(new ContainerQuantumTank(tile, player)); + this.xSize = 176; + this.ySize = 167; + this.tile = tile; + } - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - this.mc.getTextureManager().bindTexture(texture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, + int p_146976_2_, int p_146976_3_) + { + this.mc.getTextureManager().bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - this.fontRendererObj.drawString("Quantum Tank", 8, 6, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255); - this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255); - } + protected void drawGuiContainerForegroundLayer(int p_146979_1_, + int p_146979_2_) + { + this.fontRendererObj.drawString("Quantum Tank", 8, 6, 4210752); + this.fontRendererObj.drawString( + I18n.format("container.inventory", new Object[0]), 8, + this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255); + this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, + 30, 16448255); + } } - diff --git a/src/main/java/techreborn/client/gui/GuiRollingMachine.java b/src/main/java/techreborn/client/gui/GuiRollingMachine.java index 67c747c5a..ee1a8c8af 100644 --- a/src/main/java/techreborn/client/gui/GuiRollingMachine.java +++ b/src/main/java/techreborn/client/gui/GuiRollingMachine.java @@ -8,22 +8,27 @@ import techreborn.tiles.TileRollingMachine; public class GuiRollingMachine extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/rollingmachine.png"); - TileRollingMachine rollingMachine; + private static final ResourceLocation texture = new ResourceLocation( + "techreborn", "textures/gui/rollingmachine.png"); + TileRollingMachine rollingMachine; - public GuiRollingMachine(EntityPlayer player, TileRollingMachine tileRollingmachine) { - super(new ContainerRollingMachine(tileRollingmachine, player)); - this.xSize = 176; - this.ySize = 167; - rollingMachine = tileRollingmachine; - } + public GuiRollingMachine(EntityPlayer player, + TileRollingMachine tileRollingmachine) + { + super(new ContainerRollingMachine(tileRollingmachine, player)); + this.xSize = 176; + this.ySize = 167; + rollingMachine = tileRollingmachine; + } - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - this.mc.getTextureManager().bindTexture(texture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, + int p_146976_2_, int p_146976_3_) + { + this.mc.getTextureManager().bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/techreborn/client/gui/GuiThermalGenerator.java b/src/main/java/techreborn/client/gui/GuiThermalGenerator.java index 0cdf30fed..b44a4db7a 100644 --- a/src/main/java/techreborn/client/gui/GuiThermalGenerator.java +++ b/src/main/java/techreborn/client/gui/GuiThermalGenerator.java @@ -9,29 +9,38 @@ import techreborn.tiles.TileThermalGenerator; public class GuiThermalGenerator extends GuiContainer { - private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png"); + private static final ResourceLocation texture = new ResourceLocation( + "techreborn", "textures/gui/ThermalGenerator.png"); - TileThermalGenerator tile; + TileThermalGenerator tile; - public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile) { - super(new ContainerThermalGenerator(tile, player)); - this.xSize = 176; - this.ySize = 167; - this.tile = tile; - } + public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile) + { + super(new ContainerThermalGenerator(tile, player)); + this.xSize = 176; + this.ySize = 167; + this.tile = tile; + } - @Override - protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { - this.mc.getTextureManager().bindTexture(texture); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - } + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, + int p_146976_2_, int p_146976_3_) + { + this.mc.getTextureManager().bindTexture(texture); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + } - protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { - this.fontRendererObj.drawString("Thermal Generator", 8, 6, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); - this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255); - this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255); - } + protected void drawGuiContainerForegroundLayer(int p_146979_1_, + int p_146979_2_) + { + this.fontRendererObj.drawString("Thermal Generator", 8, 6, 4210752); + this.fontRendererObj.drawString( + I18n.format("container.inventory", new Object[0]), 8, + this.ySize - 96 + 2, 4210752); + this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255); + this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, + 30, 16448255); + } } diff --git a/src/main/java/techreborn/compat/CompatManager.java b/src/main/java/techreborn/compat/CompatManager.java index 7cf46919e..471b77a9b 100644 --- a/src/main/java/techreborn/compat/CompatManager.java +++ b/src/main/java/techreborn/compat/CompatManager.java @@ -1,16 +1,16 @@ package techreborn.compat; +import techreborn.compat.waila.CompatModuleWaila; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.event.FMLInitializationEvent; -import techreborn.compat.waila.CompatModuleWaila; public class CompatManager { - public static void init(FMLInitializationEvent event) - { - if (Loader.isModLoaded("Waila")) - { - new CompatModuleWaila().init(event); - } - } + public static void init(FMLInitializationEvent event) + { + if (Loader.isModLoaded("Waila")) + { + new CompatModuleWaila().init(event); + } + } } diff --git a/src/main/java/techreborn/compat/nei/CentrifugeRecipeHandler.java b/src/main/java/techreborn/compat/nei/CentrifugeRecipeHandler.java index d7980c0a5..adc657685 100644 --- a/src/main/java/techreborn/compat/nei/CentrifugeRecipeHandler.java +++ b/src/main/java/techreborn/compat/nei/CentrifugeRecipeHandler.java @@ -1,157 +1,206 @@ package techreborn.compat.nei; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; import ic2.api.item.IC2Items; + +import java.awt.Point; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; + import org.lwjgl.opengl.GL11; + import techreborn.api.CentrifugeRecipie; import techreborn.api.TechRebornAPI; import techreborn.client.gui.GuiCentrifuge; import techreborn.config.ConfigTechReborn; - -import java.awt.*; -import java.util.ArrayList; -import java.util.List; - +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; public class CentrifugeRecipeHandler extends TemplateRecipeHandler { - public class CachedCentrifugeRecipe extends CachedRecipe { + public class CachedCentrifugeRecipe extends CachedRecipe { - private List input = new ArrayList(); - private List outputs = new ArrayList(); - public Point focus; - public CentrifugeRecipie centrifugeRecipie; + private List input = new ArrayList(); + private List outputs = new ArrayList(); + public Point focus; + public CentrifugeRecipie centrifugeRecipie; + public CachedCentrifugeRecipe(CentrifugeRecipie recipie) + { + this.centrifugeRecipie = recipie; + int offset = 4; + PositionedStack pStack = new PositionedStack( + recipie.getInputItem(), 80 - offset, 35 - offset); + pStack.setMaxSize(1); + this.input.add(pStack); - public CachedCentrifugeRecipe(CentrifugeRecipie recipie) { - this.centrifugeRecipie = recipie; - int offset = 4; - PositionedStack pStack = new PositionedStack(recipie.getInputItem(), 80 - offset, 35 - offset); - pStack.setMaxSize(1); - this.input.add(pStack); + if (recipie.getOutput1() != null) + { + this.outputs.add(new PositionedStack(recipie.getOutput1(), + 80 - offset, 5 - offset)); + } + if (recipie.getOutput2() != null) + { + this.outputs.add(new PositionedStack(recipie.getOutput2(), + 110 - offset, 35 - offset)); + } + if (recipie.getOutput3() != null) + { + this.outputs.add(new PositionedStack(recipie.getOutput3(), + 80 - offset, 65 - offset)); + } + if (recipie.getOutput4() != null) + { + this.outputs.add(new PositionedStack(recipie.getOutput4(), + 50 - offset, 35 - offset)); + } + ItemStack cellStack = IC2Items.getItem("cell"); + cellStack.stackSize = recipie.getCells(); + this.outputs.add(new PositionedStack(cellStack, 50 - offset, + 5 - offset)); - if (recipie.getOutput1() != null) { - this.outputs.add(new PositionedStack(recipie.getOutput1(), 80 - offset, 5 - offset)); - } - if (recipie.getOutput2() != null) { - this.outputs.add(new PositionedStack(recipie.getOutput2(), 110 - offset, 35 - offset)); - } - if (recipie.getOutput3() != null) { - this.outputs.add(new PositionedStack(recipie.getOutput3(), 80 - offset, 65 - offset)); - } - if (recipie.getOutput4() != null) { - this.outputs.add(new PositionedStack(recipie.getOutput4(), 50 - offset, 35 - offset)); - } + } - ItemStack cellStack = IC2Items.getItem("cell"); - cellStack.stackSize = recipie.getCells(); - this.outputs.add(new PositionedStack(cellStack, 50 - offset, 5 - offset)); + @Override + public List getIngredients() + { + return this.getCycledIngredients(cycleticks / 20, this.input); + } - } + @Override + public List getOtherStacks() + { + return this.outputs; + } - @Override - public List getIngredients() { - return this.getCycledIngredients(cycleticks / 20, this.input); - } + @Override + public PositionedStack getResult() + { + return null; + } + } - @Override - public List getOtherStacks() { - return this.outputs; - } + @Override + public String getRecipeName() + { + return "Centrifuge"; + } - @Override - public PositionedStack getResult() { - return null; - } - } + @Override + public String getGuiTexture() + { + return "techreborn:textures/gui/centrifuge.png"; + } - @Override - public String getRecipeName() { - return "Centrifuge"; - } + @Override + public Class getGuiClass() + { + return GuiCentrifuge.class; + } - @Override - public String getGuiTexture() { - return "techreborn:textures/gui/centrifuge.png"; - } + @Override + public void drawBackground(int recipeIndex) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78); + GuiDraw.drawTooltipBox(10, 80, 145, 50); + GuiDraw.drawString("Info:", 14, 84, -1); + CachedRecipe recipe = arecipes.get(recipeIndex); + if (recipe instanceof CachedCentrifugeRecipe) + { + CachedCentrifugeRecipe centrifugeRecipie = (CachedCentrifugeRecipe) recipe; + GuiDraw.drawString( + "EU needed: " + + (ConfigTechReborn.CentrifugeInputTick * centrifugeRecipie.centrifugeRecipie + .getTickTime()), 14, 94, -1); + GuiDraw.drawString("Ticks to smelt: " + + centrifugeRecipie.centrifugeRecipie.getTickTime(), 14, + 104, -1); + GuiDraw.drawString("Time to smelt: " + + centrifugeRecipie.centrifugeRecipie.getTickTime() / 20 + + " seconds", 14, 114, -1); + } - @Override - public Class getGuiClass() { - return GuiCentrifuge.class; - } + } - @Override - public void drawBackground(int recipeIndex) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78); - GuiDraw.drawTooltipBox(10, 80, 145, 50); - GuiDraw.drawString("Info:", 14, 84, -1); - CachedRecipe recipe = arecipes.get(recipeIndex); - if (recipe instanceof CachedCentrifugeRecipe) { - CachedCentrifugeRecipe centrifugeRecipie = (CachedCentrifugeRecipe) recipe; - GuiDraw.drawString("EU needed: " + (ConfigTechReborn.CentrifugeInputTick * centrifugeRecipie.centrifugeRecipie.getTickTime()), 14, 94, -1); - GuiDraw.drawString("Ticks to smelt: " + centrifugeRecipie.centrifugeRecipie.getTickTime(), 14, 104, -1); - GuiDraw.drawString("Time to smelt: " + centrifugeRecipie.centrifugeRecipie.getTickTime() / 20 + " seconds", 14, 114, -1); - } + @Override + public int recipiesPerPage() + { + return 1; + } - } + @Override + public void loadTransferRects() + { + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(75, 22, 15, 13), "tr.centrifuge", new Object[0])); + } - @Override - public int recipiesPerPage() { - return 1; - } + public void loadCraftingRecipes(String outputId, Object... results) + { + if (outputId.equals("tr.centrifuge")) + { + for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) + { + addCached(centrifugeRecipie); + } + } else + { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadTransferRects() { - this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(75, 22, 15, 13), "tr.centrifuge", new Object[0])); - } + @Override + public void loadCraftingRecipes(ItemStack result) + { + for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) + { + if (NEIServerUtils.areStacksSameTypeCrafting( + centrifugeRecipie.getOutput1(), result)) + { + addCached(centrifugeRecipie); + } + if (NEIServerUtils.areStacksSameTypeCrafting( + centrifugeRecipie.getOutput2(), result)) + { + addCached(centrifugeRecipie); + } + if (NEIServerUtils.areStacksSameTypeCrafting( + centrifugeRecipie.getOutput3(), result)) + { + addCached(centrifugeRecipie); + } + if (NEIServerUtils.areStacksSameTypeCrafting( + centrifugeRecipie.getOutput4(), result)) + { + addCached(centrifugeRecipie); + } + } + } - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals("tr.centrifuge")) { - for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) { - addCached(centrifugeRecipie); - } - } else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void loadUsageRecipes(ItemStack ingredient) + { + for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) + { + if (NEIServerUtils.areStacksSameTypeCrafting( + centrifugeRecipie.getInputItem(), ingredient)) + { + addCached(centrifugeRecipie); + } + } + } - @Override - public void loadCraftingRecipes(ItemStack result) { - for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) { - if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getOutput1(), result)) { - addCached(centrifugeRecipie); - } - if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getOutput2(), result)) { - addCached(centrifugeRecipie); - } - if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getOutput3(), result)) { - addCached(centrifugeRecipie); - } - if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getOutput4(), result)) { - addCached(centrifugeRecipie); - } - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) { - if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getInputItem(), ingredient)) { - addCached(centrifugeRecipie); - } - } - } - - private void addCached(CentrifugeRecipie recipie) { - this.arecipes.add(new CachedCentrifugeRecipe(recipie)); - } + private void addCached(CentrifugeRecipie recipie) + { + this.arecipes.add(new CachedCentrifugeRecipe(recipie)); + } } \ No newline at end of file diff --git a/src/main/java/techreborn/compat/nei/NEIConfig.java b/src/main/java/techreborn/compat/nei/NEIConfig.java index 5c8683a97..403134239 100644 --- a/src/main/java/techreborn/compat/nei/NEIConfig.java +++ b/src/main/java/techreborn/compat/nei/NEIConfig.java @@ -1,35 +1,38 @@ package techreborn.compat.nei; +import techreborn.lib.ModInfo; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; -import techreborn.lib.ModInfo; public class NEIConfig implements IConfigureNEI { - @Override - public String getName() { - return ModInfo.MOD_ID; - } + @Override + public String getName() + { + return ModInfo.MOD_ID; + } - @Override - public String getVersion() { - return ModInfo.MOD_VERSION; - } + @Override + public String getVersion() + { + return ModInfo.MOD_VERSION; + } - @Override - public void loadConfig() { - CentrifugeRecipeHandler centrifugeRecipeHandler = new CentrifugeRecipeHandler(); - ShapedRollingMachineHandler shapedRollingMachineHandler = new ShapedRollingMachineHandler(); - ShapelessRollingMachineHandler shapelessRollingMachineHandler = new ShapelessRollingMachineHandler(); + @Override + public void loadConfig() + { + CentrifugeRecipeHandler centrifugeRecipeHandler = new CentrifugeRecipeHandler(); + ShapedRollingMachineHandler shapedRollingMachineHandler = new ShapedRollingMachineHandler(); + ShapelessRollingMachineHandler shapelessRollingMachineHandler = new ShapelessRollingMachineHandler(); - API.registerRecipeHandler(centrifugeRecipeHandler); - API.registerUsageHandler(centrifugeRecipeHandler); + API.registerRecipeHandler(centrifugeRecipeHandler); + API.registerUsageHandler(centrifugeRecipeHandler); - API.registerUsageHandler(shapedRollingMachineHandler); - API.registerRecipeHandler(shapedRollingMachineHandler); + API.registerUsageHandler(shapedRollingMachineHandler); + API.registerRecipeHandler(shapedRollingMachineHandler); - API.registerUsageHandler(shapelessRollingMachineHandler); - API.registerRecipeHandler(shapelessRollingMachineHandler); - } + API.registerUsageHandler(shapelessRollingMachineHandler); + API.registerRecipeHandler(shapelessRollingMachineHandler); + } } diff --git a/src/main/java/techreborn/compat/nei/ShapedRollingMachineHandler.java b/src/main/java/techreborn/compat/nei/ShapedRollingMachineHandler.java index b760836e8..534065395 100644 --- a/src/main/java/techreborn/compat/nei/ShapedRollingMachineHandler.java +++ b/src/main/java/techreborn/compat/nei/ShapedRollingMachineHandler.java @@ -1,8 +1,9 @@ //Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapedRecipeHandler.java package techreborn.compat.nei; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.recipe.ShapedRecipeHandler; +import java.awt.Rectangle; +import java.util.List; + import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -10,89 +11,110 @@ import net.minecraft.item.crafting.ShapedRecipes; import net.minecraftforge.oredict.ShapedOreRecipe; import techreborn.api.RollingMachineRecipe; import techreborn.client.gui.GuiRollingMachine; - -import java.awt.*; -import java.util.List; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.recipe.ShapedRecipeHandler; public class ShapedRollingMachineHandler extends ShapedRecipeHandler { - @Override - public Class getGuiClass() { - return GuiRollingMachine.class; - } + @Override + public Class getGuiClass() + { + return GuiRollingMachine.class; + } - @Override - public void loadTransferRects() { - this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "rollingcrafting", new Object[0])); - } + @Override + public void loadTransferRects() + { + this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, + 18), "rollingcrafting", new Object[0])); + } - @Override - public String getRecipeName() { - return "rollingcrafting"; - } + @Override + public String getRecipeName() + { + return "rollingcrafting"; + } - @Override - public String getOverlayIdentifier() { - return "rollingcrafting"; - } + @Override + public String getOverlayIdentifier() + { + return "rollingcrafting"; + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals("rollingcrafting") && getClass() == ShapedRollingMachineHandler.class) { - for (IRecipe irecipe : (List) RollingMachineRecipe.instance.getRecipeList()) { - CachedShapedRecipe recipe = null; - if (irecipe instanceof ShapedRecipes) - recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); - else if (irecipe instanceof ShapedOreRecipe) - recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); + @Override + public void loadCraftingRecipes(String outputId, Object... results) + { + if (outputId.equals("rollingcrafting") + && getClass() == ShapedRollingMachineHandler.class) + { + for (IRecipe irecipe : (List) RollingMachineRecipe.instance + .getRecipeList()) + { + CachedShapedRecipe recipe = null; + if (irecipe instanceof ShapedRecipes) + recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); + else if (irecipe instanceof ShapedOreRecipe) + recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - recipe.computeVisuals(); - arecipes.add(recipe); - } - } else { - super.loadCraftingRecipes(outputId, results); - } - } + recipe.computeVisuals(); + arecipes.add(recipe); + } + } else + { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) { - for (IRecipe irecipe : (List) RollingMachineRecipe.instance.getRecipeList()) { - if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) { - CachedShapedRecipe recipe = null; - if (irecipe instanceof ShapedRecipes) - recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); - else if (irecipe instanceof ShapedOreRecipe) - recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); + @Override + public void loadCraftingRecipes(ItemStack result) + { + for (IRecipe irecipe : (List) RollingMachineRecipe.instance + .getRecipeList()) + { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getRecipeOutput(), result)) + { + CachedShapedRecipe recipe = null; + if (irecipe instanceof ShapedRecipes) + recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); + else if (irecipe instanceof ShapedOreRecipe) + recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - recipe.computeVisuals(); - arecipes.add(recipe); - } - } - } + recipe.computeVisuals(); + arecipes.add(recipe); + } + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for (IRecipe irecipe : (List) RollingMachineRecipe.instance.getRecipeList()) { - CachedShapedRecipe recipe = null; - if (irecipe instanceof ShapedRecipes) - recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); - else if (irecipe instanceof ShapedOreRecipe) - recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); + @Override + public void loadUsageRecipes(ItemStack ingredient) + { + for (IRecipe irecipe : (List) RollingMachineRecipe.instance + .getRecipeList()) + { + CachedShapedRecipe recipe = null; + if (irecipe instanceof ShapedRecipes) + recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); + else if (irecipe instanceof ShapedOreRecipe) + recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); - if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem())) - continue; + if (recipe == null + || !recipe.contains(recipe.ingredients, + ingredient.getItem())) + continue; - recipe.computeVisuals(); - if (recipe.contains(recipe.ingredients, ingredient)) { - recipe.setIngredientPermutation(recipe.ingredients, ingredient); - arecipes.add(recipe); - } - } - } + recipe.computeVisuals(); + if (recipe.contains(recipe.ingredients, ingredient)) + { + recipe.setIngredientPermutation(recipe.ingredients, ingredient); + arecipes.add(recipe); + } + } + } } diff --git a/src/main/java/techreborn/compat/nei/ShapelessRollingMachineHandler.java b/src/main/java/techreborn/compat/nei/ShapelessRollingMachineHandler.java index b18182d60..0d565715f 100644 --- a/src/main/java/techreborn/compat/nei/ShapelessRollingMachineHandler.java +++ b/src/main/java/techreborn/compat/nei/ShapelessRollingMachineHandler.java @@ -1,8 +1,9 @@ //Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapelessRecipeHandler.java package techreborn.compat.nei; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.recipe.ShapelessRecipeHandler; +import java.awt.Rectangle; +import java.util.List; + import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -10,95 +11,116 @@ import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraftforge.oredict.ShapelessOreRecipe; import techreborn.api.RollingMachineRecipe; import techreborn.client.gui.GuiRollingMachine; - -import java.awt.*; -import java.util.List; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.recipe.ShapelessRecipeHandler; public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler { - @Override - public Class getGuiClass() { - return GuiRollingMachine.class; - } + @Override + public Class getGuiClass() + { + return GuiRollingMachine.class; + } - public String getRecipeName() { - return "Shapeless Rolling Machine"; - } + public String getRecipeName() + { + return "Shapeless Rolling Machine"; + } - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "rollingcraftingnoshape")); - } + @Override + public void loadTransferRects() + { + transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), + "rollingcraftingnoshape")); + } - @Override - public String getOverlayIdentifier() { - return "rollingcraftingnoshape"; - } + @Override + public String getOverlayIdentifier() + { + return "rollingcraftingnoshape"; + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals("rollingcraftingnoshape") && getClass() == ShapelessRollingMachineHandler.class) { - List allrecipes = RollingMachineRecipe.instance.getRecipeList(); - for (IRecipe irecipe : allrecipes) { - CachedShapelessRecipe recipe = null; - if (irecipe instanceof ShapelessRecipes) - recipe = shapelessRecipe((ShapelessRecipes) irecipe); - else if (irecipe instanceof ShapelessOreRecipe) - recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); + @Override + public void loadCraftingRecipes(String outputId, Object... results) + { + if (outputId.equals("rollingcraftingnoshape") + && getClass() == ShapelessRollingMachineHandler.class) + { + List allrecipes = RollingMachineRecipe.instance + .getRecipeList(); + for (IRecipe irecipe : allrecipes) + { + CachedShapelessRecipe recipe = null; + if (irecipe instanceof ShapelessRecipes) + recipe = shapelessRecipe((ShapelessRecipes) irecipe); + else if (irecipe instanceof ShapelessOreRecipe) + recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - arecipes.add(recipe); - } - } else { - super.loadCraftingRecipes(outputId, results); - } - } + arecipes.add(recipe); + } + } else + { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) { - List allrecipes = RollingMachineRecipe.instance.getRecipeList(); - for (IRecipe irecipe : allrecipes) { - if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) { - CachedShapelessRecipe recipe = null; - if (irecipe instanceof ShapelessRecipes) - recipe = shapelessRecipe((ShapelessRecipes) irecipe); - else if (irecipe instanceof ShapelessOreRecipe) - recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); + @Override + public void loadCraftingRecipes(ItemStack result) + { + List allrecipes = RollingMachineRecipe.instance + .getRecipeList(); + for (IRecipe irecipe : allrecipes) + { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getRecipeOutput(), result)) + { + CachedShapelessRecipe recipe = null; + if (irecipe instanceof ShapelessRecipes) + recipe = shapelessRecipe((ShapelessRecipes) irecipe); + else if (irecipe instanceof ShapelessOreRecipe) + recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - arecipes.add(recipe); - } - } - } + arecipes.add(recipe); + } + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) { - List allrecipes = RollingMachineRecipe.instance.getRecipeList(); - for (IRecipe irecipe : allrecipes) { - CachedShapelessRecipe recipe = null; - if (irecipe instanceof ShapelessRecipes) - recipe = shapelessRecipe((ShapelessRecipes) irecipe); - else if (irecipe instanceof ShapelessOreRecipe) - recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); + @Override + public void loadUsageRecipes(ItemStack ingredient) + { + List allrecipes = RollingMachineRecipe.instance + .getRecipeList(); + for (IRecipe irecipe : allrecipes) + { + CachedShapelessRecipe recipe = null; + if (irecipe instanceof ShapelessRecipes) + recipe = shapelessRecipe((ShapelessRecipes) irecipe); + else if (irecipe instanceof ShapelessOreRecipe) + recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); - if (recipe == null) - continue; + if (recipe == null) + continue; - if (recipe.contains(recipe.ingredients, ingredient)) { - recipe.setIngredientPermutation(recipe.ingredients, ingredient); - arecipes.add(recipe); - } - } - } + if (recipe.contains(recipe.ingredients, ingredient)) + { + recipe.setIngredientPermutation(recipe.ingredients, ingredient); + arecipes.add(recipe); + } + } + } - private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) { - if(recipe.recipeItems == null) - return null; + private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) + { + if (recipe.recipeItems == null) + return null; - return new CachedShapelessRecipe(recipe.recipeItems, recipe.getRecipeOutput()); - } + return new CachedShapelessRecipe(recipe.recipeItems, + recipe.getRecipeOutput()); + } } diff --git a/src/main/java/techreborn/compat/recipes/RecipeManager.java b/src/main/java/techreborn/compat/recipes/RecipeManager.java index 7b546fd72..9355ed355 100644 --- a/src/main/java/techreborn/compat/recipes/RecipeManager.java +++ b/src/main/java/techreborn/compat/recipes/RecipeManager.java @@ -1,12 +1,10 @@ package techreborn.compat.recipes; -import techreborn.compat.waila.CompatModuleWaila; import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.event.FMLInitializationEvent; public class RecipeManager { - - public static void init() + + public static void init() { if (Loader.isModLoaded("BuildCraft|Factory")) { diff --git a/src/main/java/techreborn/compat/recipes/RecipesBuildcraft.java b/src/main/java/techreborn/compat/recipes/RecipesBuildcraft.java index 02efd1bdd..62216283d 100644 --- a/src/main/java/techreborn/compat/recipes/RecipesBuildcraft.java +++ b/src/main/java/techreborn/compat/recipes/RecipesBuildcraft.java @@ -1,25 +1,26 @@ package techreborn.compat.recipes; import net.minecraft.item.ItemStack; -import buildcraft.BuildCraftFactory; import techreborn.util.RecipeRemover; +import buildcraft.BuildCraftFactory; public class RecipesBuildcraft { - + public static void init() { removeRecipes(); addRecipies(); } - + public static void removeRecipes() { - RecipeRemover.removeAnyRecipe(new ItemStack(BuildCraftFactory.quarryBlock)); + RecipeRemover.removeAnyRecipe(new ItemStack( + BuildCraftFactory.quarryBlock)); } - + public static void addRecipies() { - + } } diff --git a/src/main/java/techreborn/compat/recipes/RecipesThermalExpansion.java b/src/main/java/techreborn/compat/recipes/RecipesThermalExpansion.java index e67c71ae9..97116f518 100644 --- a/src/main/java/techreborn/compat/recipes/RecipesThermalExpansion.java +++ b/src/main/java/techreborn/compat/recipes/RecipesThermalExpansion.java @@ -1,7 +1,7 @@ package techreborn.compat.recipes; public class RecipesThermalExpansion { - //TODO remove basic machine frame recipe - //TODO replace iron in recipe to steel + // TODO remove basic machine frame recipe + // TODO replace iron in recipe to steel } diff --git a/src/main/java/techreborn/compat/waila/CompatModuleWaila.java b/src/main/java/techreborn/compat/waila/CompatModuleWaila.java index 3a6e4e37c..fc0f6c0a9 100644 --- a/src/main/java/techreborn/compat/waila/CompatModuleWaila.java +++ b/src/main/java/techreborn/compat/waila/CompatModuleWaila.java @@ -1,17 +1,21 @@ package techreborn.compat.waila; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLInterModComms; import mcp.mobius.waila.api.IWailaRegistrar; import techreborn.tiles.TileMachineBase; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLInterModComms; public class CompatModuleWaila { - public void init(FMLInitializationEvent event) { - FMLInterModComms.sendMessage("Waila", "register", getClass().getName() + ".callbackRegister"); - } + public void init(FMLInitializationEvent event) + { + FMLInterModComms.sendMessage("Waila", "register", getClass().getName() + + ".callbackRegister"); + } - public static void callbackRegister(IWailaRegistrar registrar) { - registrar.registerBodyProvider(new WailaProviderMachines(), TileMachineBase.class); - } + public static void callbackRegister(IWailaRegistrar registrar) + { + registrar.registerBodyProvider(new WailaProviderMachines(), + TileMachineBase.class); + } } diff --git a/src/main/java/techreborn/compat/waila/WailaProviderMachines.java b/src/main/java/techreborn/compat/waila/WailaProviderMachines.java index 3b0a913c8..6c0dd3336 100644 --- a/src/main/java/techreborn/compat/waila/WailaProviderMachines.java +++ b/src/main/java/techreborn/compat/waila/WailaProviderMachines.java @@ -1,5 +1,8 @@ package techreborn.compat.waila; +import java.util.ArrayList; +import java.util.List; + import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; @@ -10,46 +13,53 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import techreborn.tiles.TileMachineBase; -import java.util.ArrayList; -import java.util.List; - public class WailaProviderMachines implements IWailaDataProvider { - private List info = new ArrayList(); + private List info = new ArrayList(); - @Override - public List getWailaBody(ItemStack item, List tip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + @Override + public List getWailaBody(ItemStack item, List tip, + IWailaDataAccessor accessor, IWailaConfigHandler config) + { - TileMachineBase machine = (TileMachineBase) accessor.getTileEntity(); + TileMachineBase machine = (TileMachineBase) accessor.getTileEntity(); - machine.addWailaInfo(info); - tip.addAll(info); - info.clear(); + machine.addWailaInfo(info); + tip.addAll(info); + info.clear(); - return tip; - } + return tip; + } - @Override - public List getWailaHead(ItemStack item, List tip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + @Override + public List getWailaHead(ItemStack item, List tip, + IWailaDataAccessor accessor, IWailaConfigHandler config) + { - return tip; - } + return tip; + } - @Override - public List getWailaTail(ItemStack item, List tip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + @Override + public List getWailaTail(ItemStack item, List tip, + IWailaDataAccessor accessor, IWailaConfigHandler config) + { - return tip; - } + return tip; + } - @Override - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { + @Override + public ItemStack getWailaStack(IWailaDataAccessor accessor, + IWailaConfigHandler config) + { - return null; - } + return null; + } - @Override - public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World w, int x, int y, int z) { + @Override + public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, + NBTTagCompound tag, World w, int x, int y, int z) + { - return tag; - } + return tag; + } } diff --git a/src/main/java/techreborn/config/ConfigTechReborn.java b/src/main/java/techreborn/config/ConfigTechReborn.java index cb1d6f45e..d8afafe08 100644 --- a/src/main/java/techreborn/config/ConfigTechReborn.java +++ b/src/main/java/techreborn/config/ConfigTechReborn.java @@ -1,260 +1,415 @@ package techreborn.config; +import java.io.File; + import net.minecraft.util.StatCollector; import net.minecraftforge.common.config.Configuration; -import java.io.File; - public class ConfigTechReborn { - private static ConfigTechReborn instance = null; - public static String CATEGORY_WORLD = "world"; - public static String CATEGORY_POWER = "power"; - public static String CATEGORY_CRAFTING = "crafting"; + private static ConfigTechReborn instance = null; + public static String CATEGORY_WORLD = "world"; + public static String CATEGORY_POWER = "power"; + public static String CATEGORY_CRAFTING = "crafting"; - //WORLDGEN - public static boolean GalenaOreTrue; - public static boolean IridiumOreTrue; - public static boolean RubyOreTrue; - public static boolean SapphireOreTrue; - public static boolean BauxiteOreTrue; - public static boolean CopperOreTrue; - public static boolean TinOreTrue; - public static boolean LeadOreTrue; - public static boolean SilverOreTrue; + // WORLDGEN + public static boolean GalenaOreTrue; + public static boolean IridiumOreTrue; + public static boolean RubyOreTrue; + public static boolean SapphireOreTrue; + public static boolean BauxiteOreTrue; + public static boolean CopperOreTrue; + public static boolean TinOreTrue; + public static boolean LeadOreTrue; + public static boolean SilverOreTrue; - public static boolean PyriteOreTrue; - public static boolean CinnabarOreTrue; - public static boolean SphaleriteOreTrue; - public static boolean TungstenOreTrue; - public static boolean SheldoniteOreTrue; - public static boolean OlivineOreTrue; - public static boolean SodaliteOreTrue; + public static boolean PyriteOreTrue; + public static boolean CinnabarOreTrue; + public static boolean SphaleriteOreTrue; + public static boolean TungstenOreTrue; + public static boolean SheldoniteOreTrue; + public static boolean OlivineOreTrue; + public static boolean SodaliteOreTrue; - //Power - public static int ThermalGenertaorOutput; - public static int CentrifugeInputTick; - //Charge - public static int AdvancedDrillCharge; - public static int LapotronPackCharge; - public static int LithiumBatpackCharge; - public static int OmniToolCharge; - public static int RockCutterCharge; - public static int GravityCharge; - public static int CentrifugeCharge; - public static int ThermalGeneratorCharge; - //Tier - public static int AdvancedDrillTier; - public static int LapotronPackTier; - public static int LithiumBatpackTier; - public static int OmniToolTier; - public static int RockCutterTier; - public static int GravityTier; - public static int CentrifugeTier; - public static int ThermalGeneratorTier; - //Crafting - public static boolean ExpensiveMacerator; - public static boolean ExpensiveDrill; - public static boolean ExpensiveDiamondDrill; - public static boolean ExpensiveSolar; + // Power + public static int ThermalGenertaorOutput; + public static int CentrifugeInputTick; + // Charge + public static int AdvancedDrillCharge; + public static int LapotronPackCharge; + public static int LithiumBatpackCharge; + public static int OmniToolCharge; + public static int RockCutterCharge; + public static int GravityCharge; + public static int CentrifugeCharge; + public static int ThermalGeneratorCharge; + // Tier + public static int AdvancedDrillTier; + public static int LapotronPackTier; + public static int LithiumBatpackTier; + public static int OmniToolTier; + public static int RockCutterTier; + public static int GravityTier; + public static int CentrifugeTier; + public static int ThermalGeneratorTier; + // Crafting + public static boolean ExpensiveMacerator; + public static boolean ExpensiveDrill; + public static boolean ExpensiveDiamondDrill; + public static boolean ExpensiveSolar; + public static Configuration config; - public static Configuration config; + private ConfigTechReborn(File configFile) + { + config = new Configuration(configFile); + config.load(); - private ConfigTechReborn(File configFile) { - config = new Configuration(configFile); - config.load(); + ConfigTechReborn.Configs(); - ConfigTechReborn.Configs(); + config.save(); - config.save(); + } - } + public static ConfigTechReborn initialize(File configFile) + { - public static ConfigTechReborn initialize(File configFile) { + if (instance == null) + instance = new ConfigTechReborn(configFile); + else + throw new IllegalStateException( + "Cannot initialize TechReborn Config twice"); - if (instance == null) - instance = new ConfigTechReborn(configFile); - else - throw new IllegalStateException( - "Cannot initialize TechReborn Config twice"); + return instance; + } - return instance; - } + public static ConfigTechReborn instance() + { + if (instance == null) + { - public static ConfigTechReborn instance() { - if (instance == null) { + throw new IllegalStateException( + "Instance of TechReborn Config requested before initialization"); + } + return instance; + } - throw new IllegalStateException( - "Instance of TechReborn Config requested before initialization"); - } - return instance; - } + public static void Configs() + { + GalenaOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.galenaOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.galenaOre.tooltip")) + .getBoolean(true); + IridiumOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.iridiumOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.iridiumOre.tooltip")) + .getBoolean(true); + RubyOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.rubyOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.rubyOre.tooltip")) + .getBoolean(true); + SapphireOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.sapphireOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.sapphireOre.tooltip")) + .getBoolean(true); + BauxiteOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.bauxiteOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.bauxiteOre.tooltip")) + .getBoolean(true); + CopperOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.copperOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.copperOre.tooltip")) + .getBoolean(true); + TinOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.tinOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.tinOre.tooltip")) + .getBoolean(true); + LeadOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.leadOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.leadOre.tooltip")) + .getBoolean(true); + SilverOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.silverOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.silverOre.tooltip")) + .getBoolean(true); + PyriteOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.pyriteOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.pyriteOre.tooltip")) + .getBoolean(true); + CinnabarOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.cinnabarOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.cinnabarOre.tooltip")) + .getBoolean(true); + SphaleriteOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.sphaleriteOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.sphaleriteOre.tooltip")) + .getBoolean(true); + TungstenOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.tungstonOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.tungstonOre.tooltip")) + .getBoolean(true); + SheldoniteOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.sheldoniteOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.sheldoniteOre.tooltip")) + .getBoolean(true); + OlivineOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.olivineOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.olivineOre.tooltip")) + .getBoolean(true); + SodaliteOreTrue = config + .get(CATEGORY_WORLD, + StatCollector + .translateToLocal("config.techreborn.allow.sodaliteOre"), + true, + StatCollector + .translateToLocal("config.techreborn.allow.sodaliteOre.tooltip")) + .getBoolean(true); - public static void Configs() { - GalenaOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.galenaOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.galenaOre.tooltip")) - .getBoolean(true); - IridiumOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.iridiumOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.iridiumOre.tooltip")) - .getBoolean(true); - RubyOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.rubyOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.rubyOre.tooltip")) - .getBoolean(true); - SapphireOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.sapphireOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.sapphireOre.tooltip")) - .getBoolean(true); - BauxiteOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.bauxiteOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.bauxiteOre.tooltip")) - .getBoolean(true); - CopperOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.copperOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.copperOre.tooltip")) - .getBoolean(true); - TinOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.tinOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.tinOre.tooltip")) - .getBoolean(true); - LeadOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.leadOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.leadOre.tooltip")) - .getBoolean(true); - SilverOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.silverOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.silverOre.tooltip")) - .getBoolean(true); - PyriteOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.pyriteOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.pyriteOre.tooltip")) - .getBoolean(true); - CinnabarOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.cinnabarOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.cinnabarOre.tooltip")) - .getBoolean(true); - SphaleriteOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.sphaleriteOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.sphaleriteOre.tooltip")) - .getBoolean(true); - TungstenOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.tungstonOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.tungstonOre.tooltip")) - .getBoolean(true); - SheldoniteOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.sheldoniteOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.sheldoniteOre.tooltip")) - .getBoolean(true); - OlivineOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.olivineOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.olivineOre.tooltip")) - .getBoolean(true); - SodaliteOreTrue = config.get(CATEGORY_WORLD, - StatCollector.translateToLocal("config.techreborn.allow.sodaliteOre"), true, - StatCollector.translateToLocal("config.techreborn.allow.sodaliteOre.tooltip")) - .getBoolean(true); + // Power + ThermalGenertaorOutput = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.thermalGeneratorPower"), + 30, + StatCollector + .translateToLocal("config.techreborn.thermalGeneratorPower.tooltip")) + .getInt(); + CentrifugeInputTick = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.centrifugePowerUsage"), + 5, + StatCollector + .translateToLocal("config.techreborn.centrifugePowerUsage.tooltip")) + .getInt(); - //Power - ThermalGenertaorOutput = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.thermalGeneratorPower"), 30, - StatCollector.translateToLocal("config.techreborn.thermalGeneratorPower.tooltip")) - .getInt(); - CentrifugeInputTick = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.centrifugePowerUsage"), 5, - StatCollector.translateToLocal("config.techreborn.centrifugePowerUsage.tooltip")) - .getInt(); - - //Charge - AdvancedDrillCharge = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.advancedDrillMaxCharge"), 60000, - StatCollector.translateToLocal("config.techreborn.advancedDrillMaxCharge.tooltip")) - .getInt(); - LapotronPackCharge = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.lapotronPackMaxCharge"), 100000000, - StatCollector.translateToLocal("config.techreborn.lapotronPackMaxCharge.tooltop")) - .getInt(); - LithiumBatpackCharge = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.lithiumBatpackMaxCharge"), 4000000, - StatCollector.translateToLocal("config.techreborn.lithiumBatpackMaxCharge.tooltip")) - .getInt(); - OmniToolCharge = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.omniToolMaxCharge"), 20000, - StatCollector.translateToLocal("config.techreborn.omniToolMaxCharge.tooltip")) - .getInt(); - RockCutterCharge = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.rockCutterMaxCharge"), 10000, - StatCollector.translateToLocal("config.techreborn.rockCutterMaxCharge.tooltip")) - .getInt(); - GravityCharge = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.gravityChestplateMaxCharge"), 100000, - StatCollector.translateToLocal("config.techreborn.gravityChestplateMaxCharge.tooltip")) - .getInt(); - CentrifugeCharge = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.centrifugeMaxCharge"), 1000000, - StatCollector.translateToLocal("config.techreborn.centrifugeMaxCharge.tooltip")) - .getInt(); - ThermalGeneratorCharge = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.thermalGeneratorMaxCharge"), 1000000, - StatCollector.translateToLocal("config.techreborn.thermalGeneratorMaxCharge.tooltip")) - .getInt(); - - //Teir - AdvancedDrillTier = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.advancedDrillTier"), 2, - StatCollector.translateToLocal("config.techreborn.advancedDrillTier.tooltip")) - .getInt(); - LapotronPackTier = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.lapotronPackTier"), 2, - StatCollector.translateToLocal("config.techreborn.lapotronPackTier.tooltip")) - .getInt(); - LithiumBatpackTier = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.lithiumBatpackTier"), 3, - StatCollector.translateToLocal("config.techreborn.lithiumBatpackTier.tooltip")) - .getInt(); - OmniToolTier = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.omniToolTier"), 3, - StatCollector.translateToLocal("config.techreborn.omniToolTier.tooltip")) - .getInt(); - RockCutterTier = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.rockCutterTier"), 3, - StatCollector.translateToLocal("config.techreborn.rockCutterTier.tooltip")) - .getInt(); - GravityTier = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.gravityChestplateTier"), 3, - StatCollector.translateToLocal("config.techreborn.gravityChestplateTier.tooltip")) - .getInt(); - CentrifugeTier = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.centrifugeTier"), 1, - StatCollector.translateToLocal("config.techreborn.centrifugeTier.tooltip")) - .getInt(); - ThermalGeneratorTier = config.get(CATEGORY_POWER, - StatCollector.translateToLocal("config.techreborn.thermalGeneratorTier"), 1, - StatCollector.translateToLocal("config.techreborn.thermalGeneratorTier.tooltip")) - .getInt(); + // Charge + AdvancedDrillCharge = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.advancedDrillMaxCharge"), + 60000, + StatCollector + .translateToLocal("config.techreborn.advancedDrillMaxCharge.tooltip")) + .getInt(); + LapotronPackCharge = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.lapotronPackMaxCharge"), + 100000000, + StatCollector + .translateToLocal("config.techreborn.lapotronPackMaxCharge.tooltop")) + .getInt(); + LithiumBatpackCharge = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.lithiumBatpackMaxCharge"), + 4000000, + StatCollector + .translateToLocal("config.techreborn.lithiumBatpackMaxCharge.tooltip")) + .getInt(); + OmniToolCharge = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.omniToolMaxCharge"), + 20000, + StatCollector + .translateToLocal("config.techreborn.omniToolMaxCharge.tooltip")) + .getInt(); + RockCutterCharge = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.rockCutterMaxCharge"), + 10000, + StatCollector + .translateToLocal("config.techreborn.rockCutterMaxCharge.tooltip")) + .getInt(); + GravityCharge = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.gravityChestplateMaxCharge"), + 100000, + StatCollector + .translateToLocal("config.techreborn.gravityChestplateMaxCharge.tooltip")) + .getInt(); + CentrifugeCharge = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.centrifugeMaxCharge"), + 1000000, + StatCollector + .translateToLocal("config.techreborn.centrifugeMaxCharge.tooltip")) + .getInt(); + ThermalGeneratorCharge = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.thermalGeneratorMaxCharge"), + 1000000, + StatCollector + .translateToLocal("config.techreborn.thermalGeneratorMaxCharge.tooltip")) + .getInt(); - //Crafting - ExpensiveMacerator = config.get(CATEGORY_CRAFTING, - StatCollector.translateToLocal("config.techreborn.allowExpensiveMacerator"), true, - StatCollector.translateToLocal("config.techreborn.allowExpensiveMacerator.tooltip")) - .getBoolean(true); - ExpensiveDrill = config.get(CATEGORY_CRAFTING, - StatCollector.translateToLocal("config.techreborn.allowExpensiveDrill"), true, - StatCollector.translateToLocal("config.techreborn.allowExpensiveDrill.tooltip")) - .getBoolean(true); - ExpensiveDiamondDrill = config.get(CATEGORY_CRAFTING, - StatCollector.translateToLocal("config.techreborn.allowExpensiveDiamondDrill"), true, - StatCollector.translateToLocal("config.techreborn.allowExpensiveDiamondDrill.tooltip")) - .getBoolean(true); - ExpensiveSolar = config.get(CATEGORY_CRAFTING, - StatCollector.translateToLocal("config.techreborn.allowExpensiveSolarPanels"), true, - StatCollector.translateToLocal("config.techreborn.allowExpensiveSolarPanels.tooltip")) - .getBoolean(true); + // Teir + AdvancedDrillTier = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.advancedDrillTier"), + 2, + StatCollector + .translateToLocal("config.techreborn.advancedDrillTier.tooltip")) + .getInt(); + LapotronPackTier = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.lapotronPackTier"), + 2, + StatCollector + .translateToLocal("config.techreborn.lapotronPackTier.tooltip")) + .getInt(); + LithiumBatpackTier = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.lithiumBatpackTier"), + 3, + StatCollector + .translateToLocal("config.techreborn.lithiumBatpackTier.tooltip")) + .getInt(); + OmniToolTier = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.omniToolTier"), + 3, + StatCollector + .translateToLocal("config.techreborn.omniToolTier.tooltip")) + .getInt(); + RockCutterTier = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.rockCutterTier"), + 3, + StatCollector + .translateToLocal("config.techreborn.rockCutterTier.tooltip")) + .getInt(); + GravityTier = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.gravityChestplateTier"), + 3, + StatCollector + .translateToLocal("config.techreborn.gravityChestplateTier.tooltip")) + .getInt(); + CentrifugeTier = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.centrifugeTier"), + 1, + StatCollector + .translateToLocal("config.techreborn.centrifugeTier.tooltip")) + .getInt(); + ThermalGeneratorTier = config + .get(CATEGORY_POWER, + StatCollector + .translateToLocal("config.techreborn.thermalGeneratorTier"), + 1, + StatCollector + .translateToLocal("config.techreborn.thermalGeneratorTier.tooltip")) + .getInt(); - if (config.hasChanged()) - config.save(); - } + // Crafting + ExpensiveMacerator = config + .get(CATEGORY_CRAFTING, + StatCollector + .translateToLocal("config.techreborn.allowExpensiveMacerator"), + true, + StatCollector + .translateToLocal("config.techreborn.allowExpensiveMacerator.tooltip")) + .getBoolean(true); + ExpensiveDrill = config + .get(CATEGORY_CRAFTING, + StatCollector + .translateToLocal("config.techreborn.allowExpensiveDrill"), + true, + StatCollector + .translateToLocal("config.techreborn.allowExpensiveDrill.tooltip")) + .getBoolean(true); + ExpensiveDiamondDrill = config + .get(CATEGORY_CRAFTING, + StatCollector + .translateToLocal("config.techreborn.allowExpensiveDiamondDrill"), + true, + StatCollector + .translateToLocal("config.techreborn.allowExpensiveDiamondDrill.tooltip")) + .getBoolean(true); + ExpensiveSolar = config + .get(CATEGORY_CRAFTING, + StatCollector + .translateToLocal("config.techreborn.allowExpensiveSolarPanels"), + true, + StatCollector + .translateToLocal("config.techreborn.allowExpensiveSolarPanels.tooltip")) + .getBoolean(true); + if (config.hasChanged()) + config.save(); + } } diff --git a/src/main/java/techreborn/config/TechRebornConfigGui.java b/src/main/java/techreborn/config/TechRebornConfigGui.java index 928757000..60604dd5f 100644 --- a/src/main/java/techreborn/config/TechRebornConfigGui.java +++ b/src/main/java/techreborn/config/TechRebornConfigGui.java @@ -1,121 +1,141 @@ package techreborn.config; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; import cpw.mods.fml.client.config.DummyConfigElement; import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.GuiConfigEntries; import cpw.mods.fml.client.config.GuiConfigEntries.CategoryEntry; import cpw.mods.fml.client.config.IConfigElement; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.util.StatCollector; -import net.minecraftforge.common.config.ConfigElement; -import net.minecraftforge.common.config.Configuration; - -import java.util.ArrayList; -import java.util.List; public class TechRebornConfigGui extends GuiConfig { - public TechRebornConfigGui(GuiScreen top) { - super(top, getConfigCategories(), "TechReborn", false, false, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config - .toString())); - } + public TechRebornConfigGui(GuiScreen top) + { + super(top, getConfigCategories(), "TechReborn", false, false, GuiConfig + .getAbridgedConfigPath(ConfigTechReborn.config.toString())); + } - private static List getConfigCategories() { - List list = new ArrayList(); - list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.general"), - "tr.configgui.category.trGeneral", TRGeneral.class)); - list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.world"), - "tr.configgui.category.trWorld", TRWORLD.class)); - list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.power"), - "tr.configgui.category.trPower", TRPOWER.class)); - list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.crafting"), - "tr.configgui.category.trCrafting", TRCRAFTING.class)); + private static List getConfigCategories() + { + List list = new ArrayList(); + list.add(new DummyConfigElement.DummyCategoryElement(StatCollector + .translateToLocal("config.techreborn.category.general"), + "tr.configgui.category.trGeneral", TRGeneral.class)); + list.add(new DummyConfigElement.DummyCategoryElement(StatCollector + .translateToLocal("config.techreborn.category.world"), + "tr.configgui.category.trWorld", TRWORLD.class)); + list.add(new DummyConfigElement.DummyCategoryElement(StatCollector + .translateToLocal("config.techreborn.category.power"), + "tr.configgui.category.trPower", TRPOWER.class)); + list.add(new DummyConfigElement.DummyCategoryElement(StatCollector + .translateToLocal("config.techreborn.category.crafting"), + "tr.configgui.category.trCrafting", TRCRAFTING.class)); - return list; - } + return list; + } - public static class TRGeneral extends CategoryEntry { + public static class TRGeneral extends CategoryEntry { - public TRGeneral(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } + public TRGeneral(GuiConfig owningScreen, + GuiConfigEntries owningEntryList, IConfigElement configElement) + { + super(owningScreen, owningEntryList, configElement); + } - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config - .getCategory(Configuration.CATEGORY_GENERAL))) - .getChildElements(), this.owningScreen.modID, - Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); - } - } + @Override + protected GuiScreen buildChildScreen() + { + return new GuiConfig(this.owningScreen, + (new ConfigElement(ConfigTechReborn.config + .getCategory(Configuration.CATEGORY_GENERAL))) + .getChildElements(), this.owningScreen.modID, + Configuration.CATEGORY_GENERAL, + this.configElement.requiresWorldRestart() + || this.owningScreen.allRequireWorldRestart, + this.configElement.requiresMcRestart() + || this.owningScreen.allRequireMcRestart, + GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config + .toString())); + } + } - // World - public static class TRWORLD extends CategoryEntry { - public TRWORLD(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } + // World + public static class TRWORLD extends CategoryEntry { + public TRWORLD(GuiConfig owningScreen, + GuiConfigEntries owningEntryList, IConfigElement configElement) + { + super(owningScreen, owningEntryList, configElement); + } - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config - .getCategory(ConfigTechReborn.CATEGORY_WORLD))) - .getChildElements(), this.owningScreen.modID, - Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() - || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() - || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config - .toString())); - } - } + @Override + protected GuiScreen buildChildScreen() + { + return new GuiConfig(this.owningScreen, + (new ConfigElement(ConfigTechReborn.config + .getCategory(ConfigTechReborn.CATEGORY_WORLD))) + .getChildElements(), this.owningScreen.modID, + Configuration.CATEGORY_GENERAL, + this.configElement.requiresWorldRestart() + || this.owningScreen.allRequireWorldRestart, + this.configElement.requiresMcRestart() + || this.owningScreen.allRequireMcRestart, + GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config + .toString())); + } + } - // Power - public static class TRPOWER extends CategoryEntry { - public TRPOWER(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } + // Power + public static class TRPOWER extends CategoryEntry { + public TRPOWER(GuiConfig owningScreen, + GuiConfigEntries owningEntryList, IConfigElement configElement) + { + super(owningScreen, owningEntryList, configElement); + } - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config - .getCategory(ConfigTechReborn.CATEGORY_POWER))) - .getChildElements(), this.owningScreen.modID, - Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() - || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() - || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config - .toString())); - } - } + @Override + protected GuiScreen buildChildScreen() + { + return new GuiConfig(this.owningScreen, + (new ConfigElement(ConfigTechReborn.config + .getCategory(ConfigTechReborn.CATEGORY_POWER))) + .getChildElements(), this.owningScreen.modID, + Configuration.CATEGORY_GENERAL, + this.configElement.requiresWorldRestart() + || this.owningScreen.allRequireWorldRestart, + this.configElement.requiresMcRestart() + || this.owningScreen.allRequireMcRestart, + GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config + .toString())); + } + } - // Crafting - public static class TRCRAFTING extends CategoryEntry { - public TRCRAFTING(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { - super(owningScreen, owningEntryList, configElement); - } + // Crafting + public static class TRCRAFTING extends CategoryEntry { + public TRCRAFTING(GuiConfig owningScreen, + GuiConfigEntries owningEntryList, IConfigElement configElement) + { + super(owningScreen, owningEntryList, configElement); + } - @Override - protected GuiScreen buildChildScreen() { - return new GuiConfig(this.owningScreen, - (new ConfigElement(ConfigTechReborn.config - .getCategory(ConfigTechReborn.CATEGORY_CRAFTING))) - .getChildElements(), this.owningScreen.modID, - Configuration.CATEGORY_GENERAL, - this.configElement.requiresWorldRestart() - || this.owningScreen.allRequireWorldRestart, - this.configElement.requiresMcRestart() - || this.owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config - .toString())); - } - } + @Override + protected GuiScreen buildChildScreen() + { + return new GuiConfig(this.owningScreen, + (new ConfigElement(ConfigTechReborn.config + .getCategory(ConfigTechReborn.CATEGORY_CRAFTING))) + .getChildElements(), this.owningScreen.modID, + Configuration.CATEGORY_GENERAL, + this.configElement.requiresWorldRestart() + || this.owningScreen.allRequireWorldRestart, + this.configElement.requiresMcRestart() + || this.owningScreen.allRequireMcRestart, + GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config + .toString())); + } + } } diff --git a/src/main/java/techreborn/config/TechRebornGUIFactory.java b/src/main/java/techreborn/config/TechRebornGUIFactory.java index c6f7d3acc..d78ce6603 100644 --- a/src/main/java/techreborn/config/TechRebornGUIFactory.java +++ b/src/main/java/techreborn/config/TechRebornGUIFactory.java @@ -1,31 +1,35 @@ package techreborn.config; -import cpw.mods.fml.client.IModGuiFactory; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; - import java.util.Set; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import cpw.mods.fml.client.IModGuiFactory; + public class TechRebornGUIFactory implements IModGuiFactory { - @Override - public void initialize(Minecraft minecraftInstance) { + @Override + public void initialize(Minecraft minecraftInstance) + { - } + } - @Override - public Class mainConfigGuiClass() { - return TechRebornConfigGui.class; - } + @Override + public Class mainConfigGuiClass() + { + return TechRebornConfigGui.class; + } - @Override - public Set runtimeGuiCategories() { - return null; - } + @Override + public Set runtimeGuiCategories() + { + return null; + } - @Override - public RuntimeOptionGuiHandler getHandlerFor( - RuntimeOptionCategoryElement element) { - return null; - } + @Override + public RuntimeOptionGuiHandler getHandlerFor( + RuntimeOptionCategoryElement element) + { + return null; + } } diff --git a/src/main/java/techreborn/init/ModBlocks.java b/src/main/java/techreborn/init/ModBlocks.java index c2539c3c6..f6ce60d59 100644 --- a/src/main/java/techreborn/init/ModBlocks.java +++ b/src/main/java/techreborn/init/ModBlocks.java @@ -1,104 +1,150 @@ package techreborn.init; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import techreborn.blocks.*; +import techreborn.blocks.BlockBlastFurnace; +import techreborn.blocks.BlockCentrifuge; +import techreborn.blocks.BlockMachineCasing; +import techreborn.blocks.BlockOre; +import techreborn.blocks.BlockQuantumChest; +import techreborn.blocks.BlockQuantumTank; +import techreborn.blocks.BlockRollingMachine; +import techreborn.blocks.BlockStorage; +import techreborn.blocks.BlockThermalGenerator; import techreborn.client.TechRebornCreativeTab; import techreborn.itemblocks.ItemBlockMachineCasing; import techreborn.itemblocks.ItemBlockOre; import techreborn.itemblocks.ItemBlockQuantumChest; import techreborn.itemblocks.ItemBlockQuantumTank; import techreborn.itemblocks.ItemBlockStorage; -import techreborn.tiles.*; +import techreborn.tiles.TileBlastFurnace; +import techreborn.tiles.TileCentrifuge; +import techreborn.tiles.TileMachineCasing; +import techreborn.tiles.TileQuantumChest; +import techreborn.tiles.TileQuantumTank; +import techreborn.tiles.TileRollingMachine; +import techreborn.tiles.TileThermalGenerator; import techreborn.util.LogHelper; +import cpw.mods.fml.common.registry.GameRegistry; public class ModBlocks { - public static Block thermalGenerator; - public static Block quantumTank; - public static Block quantumChest; - public static Block centrifuge; - public static Block RollingMachine; - public static Block MachineCasing; - public static Block BlastFurnace; + public static Block thermalGenerator; + public static Block quantumTank; + public static Block quantumChest; + public static Block centrifuge; + public static Block RollingMachine; + public static Block MachineCasing; + public static Block BlastFurnace; - public static Block ore; - public static Block storage; + public static Block ore; + public static Block storage; - public static void init() { - thermalGenerator = new BlockThermalGenerator().setBlockName("techreborn.thermalGenerator").setBlockTextureName("techreborn:ThermalGenerator_other").setCreativeTab(TechRebornCreativeTab.instance); - GameRegistry.registerBlock(thermalGenerator, "techreborn.thermalGenerator"); - GameRegistry.registerTileEntity(TileThermalGenerator.class, "TileThermalGenerator"); + public static void init() + { + thermalGenerator = new BlockThermalGenerator() + .setBlockName("techreborn.thermalGenerator") + .setBlockTextureName("techreborn:ThermalGenerator_other") + .setCreativeTab(TechRebornCreativeTab.instance); + GameRegistry.registerBlock(thermalGenerator, + "techreborn.thermalGenerator"); + GameRegistry.registerTileEntity(TileThermalGenerator.class, + "TileThermalGenerator"); - quantumTank = new BlockQuantumTank().setBlockName("techreborn.quantumTank").setBlockTextureName("techreborn:quantumTank").setCreativeTab(TechRebornCreativeTab.instance); - GameRegistry.registerBlock(quantumTank, ItemBlockQuantumTank.class, "techreborn.quantumTank"); - GameRegistry.registerTileEntity(TileQuantumTank.class, "TileQuantumTank"); + quantumTank = new BlockQuantumTank() + .setBlockName("techreborn.quantumTank") + .setBlockTextureName("techreborn:quantumTank") + .setCreativeTab(TechRebornCreativeTab.instance); + GameRegistry.registerBlock(quantumTank, ItemBlockQuantumTank.class, + "techreborn.quantumTank"); + GameRegistry.registerTileEntity(TileQuantumTank.class, + "TileQuantumTank"); - quantumChest = new BlockQuantumChest().setBlockName("techreborn.quantumChest").setBlockTextureName("techreborn:quantumChest").setCreativeTab(TechRebornCreativeTab.instance); - GameRegistry.registerBlock(quantumChest, ItemBlockQuantumChest.class, "techreborn.quantumChest"); - GameRegistry.registerTileEntity(TileQuantumChest.class, "TileQuantumChest"); + quantumChest = new BlockQuantumChest() + .setBlockName("techreborn.quantumChest") + .setBlockTextureName("techreborn:quantumChest") + .setCreativeTab(TechRebornCreativeTab.instance); + GameRegistry.registerBlock(quantumChest, ItemBlockQuantumChest.class, + "techreborn.quantumChest"); + GameRegistry.registerTileEntity(TileQuantumChest.class, + "TileQuantumChest"); - centrifuge = new BlockCentrifuge().setBlockName("techreborn.centrifuge").setBlockTextureName("techreborn:centrifuge").setCreativeTab(TechRebornCreativeTab.instance); - GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge"); - GameRegistry.registerTileEntity(TileCentrifuge.class, "TileCentrifuge"); + centrifuge = new BlockCentrifuge() + .setBlockName("techreborn.centrifuge") + .setBlockTextureName("techreborn:centrifuge") + .setCreativeTab(TechRebornCreativeTab.instance); + GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge"); + GameRegistry.registerTileEntity(TileCentrifuge.class, "TileCentrifuge"); - RollingMachine = new BlockRollingMachine(Material.piston); - GameRegistry.registerBlock(RollingMachine, "rollingmachine"); - GameRegistry.registerTileEntity(TileRollingMachine.class, "TileRollingMachine"); - - BlastFurnace = new BlockBlastFurnace(Material.piston); - GameRegistry.registerBlock(BlastFurnace, "blastFurnace"); - GameRegistry.registerTileEntity(TileBlastFurnace.class, "TileBlastFurnace"); - - MachineCasing = new BlockMachineCasing(Material.piston); - GameRegistry.registerBlock(MachineCasing, ItemBlockMachineCasing.class, "machinecasing"); - GameRegistry.registerTileEntity(TileMachineCasing.class, "TileMachineCasing"); + RollingMachine = new BlockRollingMachine(Material.piston); + GameRegistry.registerBlock(RollingMachine, "rollingmachine"); + GameRegistry.registerTileEntity(TileRollingMachine.class, + "TileRollingMachine"); - ore = new BlockOre(Material.rock); - GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore"); - LogHelper.info("TechReborns Blocks Loaded"); + BlastFurnace = new BlockBlastFurnace(Material.piston); + GameRegistry.registerBlock(BlastFurnace, "blastFurnace"); + GameRegistry.registerTileEntity(TileBlastFurnace.class, + "TileBlastFurnace"); - storage = new BlockStorage(Material.rock); - GameRegistry.registerBlock(storage, ItemBlockStorage.class, "techreborn.storage"); - LogHelper.info("TechReborns Blocks Loaded"); + MachineCasing = new BlockMachineCasing(Material.piston); + GameRegistry.registerBlock(MachineCasing, ItemBlockMachineCasing.class, + "machinecasing"); + GameRegistry.registerTileEntity(TileMachineCasing.class, + "TileMachineCasing"); - registerOreDict(); - } + ore = new BlockOre(Material.rock); + GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore"); + LogHelper.info("TechReborns Blocks Loaded"); - public static void registerOreDict() { - OreDictionary.registerOre("oreGalena", new ItemStack(ore, 1, 0)); - OreDictionary.registerOre("oreIridium", new ItemStack(ore, 1, 1)); - OreDictionary.registerOre("oreRuby", new ItemStack(ore, 1, 2)); - OreDictionary.registerOre("oreSapphire", new ItemStack(ore, 1, 3)); - OreDictionary.registerOre("oreBauxite", new ItemStack(ore, 1, 4)); - OreDictionary.registerOre("orePyrite", new ItemStack(ore, 1, 5)); - OreDictionary.registerOre("oreCinnabar", new ItemStack(ore, 1, 6)); - OreDictionary.registerOre("oreSphalerite", new ItemStack(ore, 1, 7)); - OreDictionary.registerOre("oreTungston", new ItemStack(ore, 1, 8)); - OreDictionary.registerOre("oreSheldonite", new ItemStack(ore, 1, 9)); - OreDictionary.registerOre("oreOlivine", new ItemStack(ore, 1, 10)); - OreDictionary.registerOre("oreSodalite", new ItemStack(ore, 1, 11)); + storage = new BlockStorage(Material.rock); + GameRegistry.registerBlock(storage, ItemBlockStorage.class, + "techreborn.storage"); + LogHelper.info("TechReborns Blocks Loaded"); - OreDictionary.registerOre("blockSilver", new ItemStack(storage, 1, 0)); - OreDictionary.registerOre("blockAluminium", new ItemStack(storage, 1, 1)); - OreDictionary.registerOre("blockTitanium", new ItemStack(storage, 1, 2)); - OreDictionary.registerOre("blockSapphire", new ItemStack(storage, 1, 3)); - OreDictionary.registerOre("blockRuby", new ItemStack(storage, 1, 4)); - OreDictionary.registerOre("blockGreenSapphire", new ItemStack(storage, 1, 5)); - OreDictionary.registerOre("blockChrome", new ItemStack(storage, 1, 6)); - OreDictionary.registerOre("blockElectrum", new ItemStack(storage, 1, 7)); - OreDictionary.registerOre("blockTungsten", new ItemStack(storage, 1, 8)); - OreDictionary.registerOre("blockLead", new ItemStack(storage, 1, 9)); - OreDictionary.registerOre("blockZinc", new ItemStack(storage, 1, 10)); - OreDictionary.registerOre("blockBrass", new ItemStack(storage, 1, 11)); - OreDictionary.registerOre("blockSteel", new ItemStack(storage, 1, 12)); - OreDictionary.registerOre("blockPlatinum", new ItemStack(storage, 1, 13)); - OreDictionary.registerOre("blockNickel", new ItemStack(storage, 1, 14)); - OreDictionary.registerOre("blockInvar", new ItemStack(storage, 1, 15)); + registerOreDict(); + } - } + public static void registerOreDict() + { + OreDictionary.registerOre("oreGalena", new ItemStack(ore, 1, 0)); + OreDictionary.registerOre("oreIridium", new ItemStack(ore, 1, 1)); + OreDictionary.registerOre("oreRuby", new ItemStack(ore, 1, 2)); + OreDictionary.registerOre("oreSapphire", new ItemStack(ore, 1, 3)); + OreDictionary.registerOre("oreBauxite", new ItemStack(ore, 1, 4)); + OreDictionary.registerOre("orePyrite", new ItemStack(ore, 1, 5)); + OreDictionary.registerOre("oreCinnabar", new ItemStack(ore, 1, 6)); + OreDictionary.registerOre("oreSphalerite", new ItemStack(ore, 1, 7)); + OreDictionary.registerOre("oreTungston", new ItemStack(ore, 1, 8)); + OreDictionary.registerOre("oreSheldonite", new ItemStack(ore, 1, 9)); + OreDictionary.registerOre("oreOlivine", new ItemStack(ore, 1, 10)); + OreDictionary.registerOre("oreSodalite", new ItemStack(ore, 1, 11)); + + OreDictionary.registerOre("blockSilver", new ItemStack(storage, 1, 0)); + OreDictionary.registerOre("blockAluminium", + new ItemStack(storage, 1, 1)); + OreDictionary + .registerOre("blockTitanium", new ItemStack(storage, 1, 2)); + OreDictionary + .registerOre("blockSapphire", new ItemStack(storage, 1, 3)); + OreDictionary.registerOre("blockRuby", new ItemStack(storage, 1, 4)); + OreDictionary.registerOre("blockGreenSapphire", new ItemStack(storage, + 1, 5)); + OreDictionary.registerOre("blockChrome", new ItemStack(storage, 1, 6)); + OreDictionary + .registerOre("blockElectrum", new ItemStack(storage, 1, 7)); + OreDictionary + .registerOre("blockTungsten", new ItemStack(storage, 1, 8)); + OreDictionary.registerOre("blockLead", new ItemStack(storage, 1, 9)); + OreDictionary.registerOre("blockZinc", new ItemStack(storage, 1, 10)); + OreDictionary.registerOre("blockBrass", new ItemStack(storage, 1, 11)); + OreDictionary.registerOre("blockSteel", new ItemStack(storage, 1, 12)); + OreDictionary.registerOre("blockPlatinum", + new ItemStack(storage, 1, 13)); + OreDictionary.registerOre("blockNickel", new ItemStack(storage, 1, 14)); + OreDictionary.registerOre("blockInvar", new ItemStack(storage, 1, 15)); + + } } diff --git a/src/main/java/techreborn/init/ModItems.java b/src/main/java/techreborn/init/ModItems.java index b3802ee57..2f6cc16f4 100644 --- a/src/main/java/techreborn/init/ModItems.java +++ b/src/main/java/techreborn/init/ModItems.java @@ -1,6 +1,5 @@ package techreborn.init; -import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; @@ -20,147 +19,162 @@ import techreborn.items.tools.ItemOmniTool; import techreborn.items.tools.ItemRockCutter; import techreborn.items.tools.ItemTechPda; import techreborn.util.LogHelper; +import cpw.mods.fml.common.registry.GameRegistry; public class ModItems { - public static Item dusts; - public static Item smallDusts; - public static Item ingots; - public static Item gems; - public static Item parts; - public static Item cells; - public static Item rockCutter; - public static Item lithiumBatpack; - public static Item lapotronpack; - public static Item gravityChest; - public static Item omniTool; - public static Item advancedDrill; - public static Item manuel; + public static Item dusts; + public static Item smallDusts; + public static Item ingots; + public static Item gems; + public static Item parts; + public static Item cells; + public static Item rockCutter; + public static Item lithiumBatpack; + public static Item lapotronpack; + public static Item gravityChest; + public static Item omniTool; + public static Item advancedDrill; + public static Item manuel; - public static void init() { - dusts = new ItemDusts(); - GameRegistry.registerItem(dusts, "dust"); - smallDusts = new ItemDustsSmall(); - GameRegistry.registerItem(smallDusts, "smallDust"); - ingots = new ItemIngots(); - GameRegistry.registerItem(ingots, "ingot"); - gems = new ItemGems(); - GameRegistry.registerItem(gems, "gem"); - parts = new ItemParts(); - GameRegistry.registerItem(parts, "part"); - cells = new ItemCells(); - GameRegistry.registerItem(cells, "cell"); - rockCutter = new ItemRockCutter(ToolMaterial.EMERALD); - GameRegistry.registerItem(rockCutter, "rockCutter"); - lithiumBatpack = new ItemLithiumBatpack(ArmorMaterial.DIAMOND, 7, 1); - GameRegistry.registerItem(lithiumBatpack, "lithiumBatpack"); - lapotronpack = new ItemLapotronPack(ArmorMaterial.DIAMOND, 7, 1); - GameRegistry.registerItem(lapotronpack, "lapotronPack"); - omniTool = new ItemOmniTool(ToolMaterial.EMERALD); - GameRegistry.registerItem(omniTool, "omniTool"); - advancedDrill = new ItemAdvancedDrill(); - GameRegistry.registerItem(advancedDrill, "advancedDrill"); - gravityChest = new ItemGravityChest(ArmorMaterial.DIAMOND, 7, 1); - GameRegistry.registerItem(gravityChest, "gravitychestplate"); - manuel = new ItemTechPda(); - GameRegistry.registerItem(manuel, "techmanuel"); + public static void init() + { + dusts = new ItemDusts(); + GameRegistry.registerItem(dusts, "dust"); + smallDusts = new ItemDustsSmall(); + GameRegistry.registerItem(smallDusts, "smallDust"); + ingots = new ItemIngots(); + GameRegistry.registerItem(ingots, "ingot"); + gems = new ItemGems(); + GameRegistry.registerItem(gems, "gem"); + parts = new ItemParts(); + GameRegistry.registerItem(parts, "part"); + cells = new ItemCells(); + GameRegistry.registerItem(cells, "cell"); + rockCutter = new ItemRockCutter(ToolMaterial.EMERALD); + GameRegistry.registerItem(rockCutter, "rockCutter"); + lithiumBatpack = new ItemLithiumBatpack(ArmorMaterial.DIAMOND, 7, 1); + GameRegistry.registerItem(lithiumBatpack, "lithiumBatpack"); + lapotronpack = new ItemLapotronPack(ArmorMaterial.DIAMOND, 7, 1); + GameRegistry.registerItem(lapotronpack, "lapotronPack"); + omniTool = new ItemOmniTool(ToolMaterial.EMERALD); + GameRegistry.registerItem(omniTool, "omniTool"); + advancedDrill = new ItemAdvancedDrill(); + GameRegistry.registerItem(advancedDrill, "advancedDrill"); + gravityChest = new ItemGravityChest(ArmorMaterial.DIAMOND, 7, 1); + GameRegistry.registerItem(gravityChest, "gravitychestplate"); + manuel = new ItemTechPda(); + GameRegistry.registerItem(manuel, "techmanuel"); - LogHelper.info("TechReborns Items Loaded"); + LogHelper.info("TechReborns Items Loaded"); - registerOreDict(); - } + registerOreDict(); + } - public static void registerOreDict() { - //Dusts - OreDictionary.registerOre("dustAlmandine", new ItemStack(dusts, 1, 0)); - OreDictionary.registerOre("dustAluminium", new ItemStack(dusts, 1, 1)); - OreDictionary.registerOre("dustAndradite", new ItemStack(dusts, 1, 2)); - OreDictionary.registerOre("dustBasalt", new ItemStack(dusts, 1, 4)); - OreDictionary.registerOre("dustBauxite", new ItemStack(dusts, 1, 5)); - OreDictionary.registerOre("dustBrass", new ItemStack(dusts, 1, 6)); - OreDictionary.registerOre("dustBronze", new ItemStack(dusts, 1, 7)); - OreDictionary.registerOre("dustCalcite", new ItemStack(dusts, 1, 8)); - OreDictionary.registerOre("dustCharcoal", new ItemStack(dusts, 1, 9)); - OreDictionary.registerOre("dustChrome", new ItemStack(dusts, 1, 10)); - OreDictionary.registerOre("dustCinnabar", new ItemStack(dusts, 1, 11)); - OreDictionary.registerOre("dustClay", new ItemStack(dusts, 1, 12)); - OreDictionary.registerOre("dustCoal", new ItemStack(dusts, 1, 13)); - OreDictionary.registerOre("dustCopper", new ItemStack(dusts, 1, 14)); - OreDictionary.registerOre("dustDiamond", new ItemStack(dusts, 1, 16)); - OreDictionary.registerOre("dustElectrum", new ItemStack(dusts, 1, 17)); - OreDictionary.registerOre("dustEmerald", new ItemStack(dusts, 1, 18)); - OreDictionary.registerOre("dustEnderEye", new ItemStack(dusts, 1, 19)); - OreDictionary.registerOre("dustEnderPearl", new ItemStack(dusts, 1, 20)); - OreDictionary.registerOre("dustEndstone", new ItemStack(dusts, 1, 21)); - OreDictionary.registerOre("dustFlint", new ItemStack(dusts, 1, 22)); - OreDictionary.registerOre("dustGold", new ItemStack(dusts, 1, 23)); - OreDictionary.registerOre("dustGreenSapphire", new ItemStack(dusts, 1, 24)); - OreDictionary.registerOre("dustGrossular", new ItemStack(dusts, 1, 25)); - OreDictionary.registerOre("dustInvar", new ItemStack(dusts, 1, 26)); - OreDictionary.registerOre("dustIron", new ItemStack(dusts, 1, 27)); - OreDictionary.registerOre("dustLazurite", new ItemStack(dusts, 1, 28)); - OreDictionary.registerOre("dustLead", new ItemStack(dusts, 1, 29)); - OreDictionary.registerOre("dustMagnesium", new ItemStack(dusts, 1, 30)); - OreDictionary.registerOre("dustMarble", new ItemStack(dusts, 31)); - OreDictionary.registerOre("dustNetherrack", new ItemStack(dusts, 32)); - OreDictionary.registerOre("dustNickel", new ItemStack(dusts, 1, 33)); - OreDictionary.registerOre("dustObsidian", new ItemStack(dusts, 1, 34)); - OreDictionary.registerOre("dustOlivine", new ItemStack(dusts, 1, 35)); - OreDictionary.registerOre("dustPhosphor", new ItemStack(dusts, 1, 36)); - OreDictionary.registerOre("dustPlatinum", new ItemStack(dusts, 1, 37)); - OreDictionary.registerOre("dustPyrite", new ItemStack(dusts, 1, 38)); - OreDictionary.registerOre("dustPyrope", new ItemStack(dusts, 1, 39)); - OreDictionary.registerOre("dustRedGarnet", new ItemStack(dusts, 1, 40)); - OreDictionary.registerOre("dustRedrock", new ItemStack(dusts, 1, 41)); - OreDictionary.registerOre("dustRuby", new ItemStack(dusts, 1, 42)); - OreDictionary.registerOre("dustSaltpeter", new ItemStack(dusts, 1, 43)); - OreDictionary.registerOre("dustSapphire", new ItemStack(dusts, 1, 44)); - OreDictionary.registerOre("dustSilver", new ItemStack(dusts, 1, 45)); - OreDictionary.registerOre("dustSodalite", new ItemStack(dusts, 1, 46)); - OreDictionary.registerOre("dustSpessartine", new ItemStack(dusts, 1, 47)); - OreDictionary.registerOre("dustSphalerite", new ItemStack(dusts, 1, 48)); - OreDictionary.registerOre("dustSteel", new ItemStack(dusts, 1, 49)); - OreDictionary.registerOre("dustSulfur", new ItemStack(dusts, 1, 50)); - OreDictionary.registerOre("dustTin", new ItemStack(dusts, 1, 51)); - OreDictionary.registerOre("dustTitanium", new ItemStack(dusts, 1, 52)); - OreDictionary.registerOre("dustTungsten", new ItemStack(dusts, 1, 53)); - OreDictionary.registerOre("dustUranium", new ItemStack(dusts, 1, 54)); - OreDictionary.registerOre("dustUvarovite", new ItemStack(dusts, 1, 55)); - OreDictionary.registerOre("dustYellowGarnet", new ItemStack(dusts, 1, 56)); - OreDictionary.registerOre("dustZinc", new ItemStack(dusts, 1, 57)); - OreDictionary.registerOre("ingotCobalt", new ItemStack(dusts, 1, 58)); - OreDictionary.registerOre("ingotArdite", new ItemStack(ingots, 1, 59)); - OreDictionary.registerOre("ingotManyullyn", new ItemStack(ingots, 1, 60)); - OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots, 1, 61)); - OreDictionary.registerOre("ingotAlumite", new ItemStack(ingots, 1, 62)); - //Ingots - OreDictionary.registerOre("ingotIridium", new ItemStack(ingots, 1, 3)); - OreDictionary.registerOre("ingotSilver", new ItemStack(ingots, 1, 4)); - OreDictionary.registerOre("ingotAluminium", new ItemStack(ingots, 1, 5)); - OreDictionary.registerOre("ingotTitanium", new ItemStack(ingots, 1, 6)); - OreDictionary.registerOre("ingotChrome", new ItemStack(ingots, 1, 7)); - OreDictionary.registerOre("ingotElectrum", new ItemStack(ingots, 1, 8)); - OreDictionary.registerOre("ingotTungsten", new ItemStack(ingots, 1, 9)); - OreDictionary.registerOre("ingotLead", new ItemStack(ingots, 1, 10)); - OreDictionary.registerOre("ingotZinc", new ItemStack(ingots, 1, 11)); - OreDictionary.registerOre("ingotBrass", new ItemStack(ingots, 1, 12)); - OreDictionary.registerOre("ingotSteel", new ItemStack(ingots, 1, 13)); - OreDictionary.registerOre("ingotPlatinum", new ItemStack(ingots, 1, 14)); - OreDictionary.registerOre("ingotNickel", new ItemStack(ingots, 1, 15)); - OreDictionary.registerOre("ingotInvar", new ItemStack(ingots, 1, 16)); - OreDictionary.registerOre("ingotCobalt", new ItemStack(ingots, 1, 17)); - OreDictionary.registerOre("ingotArdite", new ItemStack(ingots, 1, 18)); - OreDictionary.registerOre("ingotManyullyn", new ItemStack(ingots, 1, 19)); - OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots, 1, 20)); - OreDictionary.registerOre("ingotAlumite", new ItemStack(ingots, 1, 21)); - //Gems - OreDictionary.registerOre("gemRuby", new ItemStack(gems, 1, 0)); - OreDictionary.registerOre("gemSapphire", new ItemStack(gems, 1, 1)); - OreDictionary.registerOre("gemGreenSapphire", new ItemStack(gems, 1, 2)); - OreDictionary.registerOre("gemOlivine", new ItemStack(gems, 1, 3)); - OreDictionary.registerOre("gemRedGarnet", new ItemStack(gems, 1, 4)); - OreDictionary.registerOre("gemYellowGarnet", new ItemStack(gems, 1, 5)); + public static void registerOreDict() + { + // Dusts + OreDictionary.registerOre("dustAlmandine", new ItemStack(dusts, 1, 0)); + OreDictionary.registerOre("dustAluminium", new ItemStack(dusts, 1, 1)); + OreDictionary.registerOre("dustAndradite", new ItemStack(dusts, 1, 2)); + OreDictionary.registerOre("dustBasalt", new ItemStack(dusts, 1, 4)); + OreDictionary.registerOre("dustBauxite", new ItemStack(dusts, 1, 5)); + OreDictionary.registerOre("dustBrass", new ItemStack(dusts, 1, 6)); + OreDictionary.registerOre("dustBronze", new ItemStack(dusts, 1, 7)); + OreDictionary.registerOre("dustCalcite", new ItemStack(dusts, 1, 8)); + OreDictionary.registerOre("dustCharcoal", new ItemStack(dusts, 1, 9)); + OreDictionary.registerOre("dustChrome", new ItemStack(dusts, 1, 10)); + OreDictionary.registerOre("dustCinnabar", new ItemStack(dusts, 1, 11)); + OreDictionary.registerOre("dustClay", new ItemStack(dusts, 1, 12)); + OreDictionary.registerOre("dustCoal", new ItemStack(dusts, 1, 13)); + OreDictionary.registerOre("dustCopper", new ItemStack(dusts, 1, 14)); + OreDictionary.registerOre("dustDiamond", new ItemStack(dusts, 1, 16)); + OreDictionary.registerOre("dustElectrum", new ItemStack(dusts, 1, 17)); + OreDictionary.registerOre("dustEmerald", new ItemStack(dusts, 1, 18)); + OreDictionary.registerOre("dustEnderEye", new ItemStack(dusts, 1, 19)); + OreDictionary + .registerOre("dustEnderPearl", new ItemStack(dusts, 1, 20)); + OreDictionary.registerOre("dustEndstone", new ItemStack(dusts, 1, 21)); + OreDictionary.registerOre("dustFlint", new ItemStack(dusts, 1, 22)); + OreDictionary.registerOre("dustGold", new ItemStack(dusts, 1, 23)); + OreDictionary.registerOre("dustGreenSapphire", new ItemStack(dusts, 1, + 24)); + OreDictionary.registerOre("dustGrossular", new ItemStack(dusts, 1, 25)); + OreDictionary.registerOre("dustInvar", new ItemStack(dusts, 1, 26)); + OreDictionary.registerOre("dustIron", new ItemStack(dusts, 1, 27)); + OreDictionary.registerOre("dustLazurite", new ItemStack(dusts, 1, 28)); + OreDictionary.registerOre("dustLead", new ItemStack(dusts, 1, 29)); + OreDictionary.registerOre("dustMagnesium", new ItemStack(dusts, 1, 30)); + OreDictionary.registerOre("dustMarble", new ItemStack(dusts, 31)); + OreDictionary.registerOre("dustNetherrack", new ItemStack(dusts, 32)); + OreDictionary.registerOre("dustNickel", new ItemStack(dusts, 1, 33)); + OreDictionary.registerOre("dustObsidian", new ItemStack(dusts, 1, 34)); + OreDictionary.registerOre("dustOlivine", new ItemStack(dusts, 1, 35)); + OreDictionary.registerOre("dustPhosphor", new ItemStack(dusts, 1, 36)); + OreDictionary.registerOre("dustPlatinum", new ItemStack(dusts, 1, 37)); + OreDictionary.registerOre("dustPyrite", new ItemStack(dusts, 1, 38)); + OreDictionary.registerOre("dustPyrope", new ItemStack(dusts, 1, 39)); + OreDictionary.registerOre("dustRedGarnet", new ItemStack(dusts, 1, 40)); + OreDictionary.registerOre("dustRedrock", new ItemStack(dusts, 1, 41)); + OreDictionary.registerOre("dustRuby", new ItemStack(dusts, 1, 42)); + OreDictionary.registerOre("dustSaltpeter", new ItemStack(dusts, 1, 43)); + OreDictionary.registerOre("dustSapphire", new ItemStack(dusts, 1, 44)); + OreDictionary.registerOre("dustSilver", new ItemStack(dusts, 1, 45)); + OreDictionary.registerOre("dustSodalite", new ItemStack(dusts, 1, 46)); + OreDictionary.registerOre("dustSpessartine", + new ItemStack(dusts, 1, 47)); + OreDictionary + .registerOre("dustSphalerite", new ItemStack(dusts, 1, 48)); + OreDictionary.registerOre("dustSteel", new ItemStack(dusts, 1, 49)); + OreDictionary.registerOre("dustSulfur", new ItemStack(dusts, 1, 50)); + OreDictionary.registerOre("dustTin", new ItemStack(dusts, 1, 51)); + OreDictionary.registerOre("dustTitanium", new ItemStack(dusts, 1, 52)); + OreDictionary.registerOre("dustTungsten", new ItemStack(dusts, 1, 53)); + OreDictionary.registerOre("dustUranium", new ItemStack(dusts, 1, 54)); + OreDictionary.registerOre("dustUvarovite", new ItemStack(dusts, 1, 55)); + OreDictionary.registerOre("dustYellowGarnet", new ItemStack(dusts, 1, + 56)); + OreDictionary.registerOre("dustZinc", new ItemStack(dusts, 1, 57)); + OreDictionary.registerOre("ingotCobalt", new ItemStack(dusts, 1, 58)); + OreDictionary.registerOre("ingotArdite", new ItemStack(ingots, 1, 59)); + OreDictionary.registerOre("ingotManyullyn", + new ItemStack(ingots, 1, 60)); + OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots, + 1, 61)); + OreDictionary.registerOre("ingotAlumite", new ItemStack(ingots, 1, 62)); + // Ingots + OreDictionary.registerOre("ingotIridium", new ItemStack(ingots, 1, 3)); + OreDictionary.registerOre("ingotSilver", new ItemStack(ingots, 1, 4)); + OreDictionary + .registerOre("ingotAluminium", new ItemStack(ingots, 1, 5)); + OreDictionary.registerOre("ingotTitanium", new ItemStack(ingots, 1, 6)); + OreDictionary.registerOre("ingotChrome", new ItemStack(ingots, 1, 7)); + OreDictionary.registerOre("ingotElectrum", new ItemStack(ingots, 1, 8)); + OreDictionary.registerOre("ingotTungsten", new ItemStack(ingots, 1, 9)); + OreDictionary.registerOre("ingotLead", new ItemStack(ingots, 1, 10)); + OreDictionary.registerOre("ingotZinc", new ItemStack(ingots, 1, 11)); + OreDictionary.registerOre("ingotBrass", new ItemStack(ingots, 1, 12)); + OreDictionary.registerOre("ingotSteel", new ItemStack(ingots, 1, 13)); + OreDictionary + .registerOre("ingotPlatinum", new ItemStack(ingots, 1, 14)); + OreDictionary.registerOre("ingotNickel", new ItemStack(ingots, 1, 15)); + OreDictionary.registerOre("ingotInvar", new ItemStack(ingots, 1, 16)); + OreDictionary.registerOre("ingotCobalt", new ItemStack(ingots, 1, 17)); + OreDictionary.registerOre("ingotArdite", new ItemStack(ingots, 1, 18)); + OreDictionary.registerOre("ingotManyullyn", + new ItemStack(ingots, 1, 19)); + OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots, + 1, 20)); + OreDictionary.registerOre("ingotAlumite", new ItemStack(ingots, 1, 21)); + // Gems + OreDictionary.registerOre("gemRuby", new ItemStack(gems, 1, 0)); + OreDictionary.registerOre("gemSapphire", new ItemStack(gems, 1, 1)); + OreDictionary + .registerOre("gemGreenSapphire", new ItemStack(gems, 1, 2)); + OreDictionary.registerOre("gemOlivine", new ItemStack(gems, 1, 3)); + OreDictionary.registerOre("gemRedGarnet", new ItemStack(gems, 1, 4)); + OreDictionary.registerOre("gemYellowGarnet", new ItemStack(gems, 1, 5)); - } + } } diff --git a/src/main/java/techreborn/init/ModParts.java b/src/main/java/techreborn/init/ModParts.java index 64abdde86..762a580ed 100644 --- a/src/main/java/techreborn/init/ModParts.java +++ b/src/main/java/techreborn/init/ModParts.java @@ -6,10 +6,13 @@ import techreborn.partSystem.parts.CablePart; public class ModParts { - public static void init(){ + public static void init() + { ModPartRegistry.registerPart(new CablePart()); - ModPartRegistry.addProvider("techreborn.partSystem.QLib.QModPartFactory", "qmunitylib"); - ModPartRegistry.addProvider("techreborn.partSystem.fmp.FMPFactory", "ForgeMultipart"); + ModPartRegistry.addProvider( + "techreborn.partSystem.QLib.QModPartFactory", "qmunitylib"); + ModPartRegistry.addProvider("techreborn.partSystem.fmp.FMPFactory", + "ForgeMultipart"); ModPartRegistry.addProvider(new WorldProvider()); ModPartRegistry.addAllPartsToSystems(); } diff --git a/src/main/java/techreborn/init/ModRecipes.java b/src/main/java/techreborn/init/ModRecipes.java index 803fb1ed3..c10929bf5 100644 --- a/src/main/java/techreborn/init/ModRecipes.java +++ b/src/main/java/techreborn/init/ModRecipes.java @@ -1,6 +1,5 @@ package techreborn.init; -import cpw.mods.fml.common.registry.GameRegistry; import ic2.api.item.IC2Items; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -11,233 +10,277 @@ import techreborn.config.ConfigTechReborn; import techreborn.util.CraftingHelper; import techreborn.util.LogHelper; import techreborn.util.RecipeRemover; +import cpw.mods.fml.common.registry.GameRegistry; public class ModRecipes { - public static ConfigTechReborn config; + public static ConfigTechReborn config; - public static void init() { - removeIc2Recipes(); - addShaplessRecipes(); - addShappedRecipes(); - addSmeltingRecipes(); - addMachineRecipes(); - } + public static void init() + { + removeIc2Recipes(); + addShaplessRecipes(); + addShappedRecipes(); + addSmeltingRecipes(); + addMachineRecipes(); + } - public static void removeIc2Recipes() { - if (config.ExpensiveMacerator) ; - RecipeRemover.removeAnyRecipe(IC2Items.getItem("macerator")); - if (config.ExpensiveDrill) ; - RecipeRemover.removeAnyRecipe(IC2Items.getItem("miningDrill")); - if (config.ExpensiveDiamondDrill) ; - RecipeRemover.removeAnyRecipe(IC2Items.getItem("diamondDrill")); - if (config.ExpensiveSolar) ; - RecipeRemover.removeAnyRecipe(IC2Items.getItem("solarPanel")); + public static void removeIc2Recipes() + { + if (config.ExpensiveMacerator) + ; + RecipeRemover.removeAnyRecipe(IC2Items.getItem("macerator")); + if (config.ExpensiveDrill) + ; + RecipeRemover.removeAnyRecipe(IC2Items.getItem("miningDrill")); + if (config.ExpensiveDiamondDrill) + ; + RecipeRemover.removeAnyRecipe(IC2Items.getItem("diamondDrill")); + if (config.ExpensiveSolar) + ; + RecipeRemover.removeAnyRecipe(IC2Items.getItem("solarPanel")); - LogHelper.info("IC2 Recipes Removed"); - } + LogHelper.info("IC2 Recipes Removed"); + } - public static void addShappedRecipes() { + public static void addShappedRecipes() + { - //IC2 Recipes - if (config.ExpensiveMacerator) ; - CraftingHelper.addShapedOreRecipe(IC2Items.getItem("macerator"), - new Object[]{"FDF", "DMD", "FCF", - 'F', Items.flint, - 'D', Items.diamond, - 'M', IC2Items.getItem("machine"), - 'C', IC2Items.getItem("electronicCircuit")}); - if (config.ExpensiveDrill) ; - CraftingHelper.addShapedOreRecipe(IC2Items.getItem("miningDrill"), - new Object[]{" S ", "SCS", "SBS", - 'S', "ingotSteel", - 'B', IC2Items.getItem("reBattery"), - 'C', IC2Items.getItem("electronicCircuit")}); - if (config.ExpensiveDiamondDrill) ; - CraftingHelper.addShapedOreRecipe(IC2Items.getItem("diamondDrill"), - new Object[]{" D ", "DBD", "TCT", - 'D', "gemDiamond", - 'T', "ingotTitanium", - 'B', IC2Items.getItem("miningDrill"), - 'C', IC2Items.getItem("advancedCircuit")}); - if (config.ExpensiveSolar) ; - CraftingHelper.addShapedOreRecipe(IC2Items.getItem("solarPanel"), - new Object[]{"PPP", "SZS", "CGC", - 'P', "paneGlass", - 'S', new ItemStack(ModItems.parts, 1, 1), - 'Z', IC2Items.getItem("carbonPlate"), - 'G', IC2Items.getItem("generator"), - 'C', IC2Items.getItem("electronicCircuit")}); + // IC2 Recipes + if (config.ExpensiveMacerator) + ; + CraftingHelper.addShapedOreRecipe( + IC2Items.getItem("macerator"), + new Object[] + { "FDF", "DMD", "FCF", 'F', Items.flint, 'D', Items.diamond, + 'M', IC2Items.getItem("machine"), 'C', + IC2Items.getItem("electronicCircuit") }); + if (config.ExpensiveDrill) + ; + CraftingHelper.addShapedOreRecipe( + IC2Items.getItem("miningDrill"), + new Object[] + { " S ", "SCS", "SBS", 'S', "ingotSteel", 'B', + IC2Items.getItem("reBattery"), 'C', + IC2Items.getItem("electronicCircuit") }); + if (config.ExpensiveDiamondDrill) + ; + CraftingHelper.addShapedOreRecipe( + IC2Items.getItem("diamondDrill"), + new Object[] + { " D ", "DBD", "TCT", 'D', "gemDiamond", 'T', "ingotTitanium", + 'B', IC2Items.getItem("miningDrill"), 'C', + IC2Items.getItem("advancedCircuit") }); + if (config.ExpensiveSolar) + ; + CraftingHelper.addShapedOreRecipe( + IC2Items.getItem("solarPanel"), + new Object[] + { "PPP", "SZS", "CGC", 'P', "paneGlass", 'S', + new ItemStack(ModItems.parts, 1, 1), 'Z', + IC2Items.getItem("carbonPlate"), 'G', + IC2Items.getItem("generator"), 'C', + IC2Items.getItem("electronicCircuit") }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.thermalGenerator), - new Object[]{"III", "IHI", "CGC", - 'I', "ingotInvar", - 'H', IC2Items.getItem("reinforcedGlass"), - 'C', IC2Items.getItem("electronicCircuit"), - 'G', IC2Items.getItem("geothermalGenerator")}); - //TechReborn Recipes - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 4, 6), - new Object[]{"EEE", "EAE", "EEE", - 'E', "gemEmerald", - 'A', IC2Items.getItem("electronicCircuit")}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.thermalGenerator), + new Object[] + { "III", "IHI", "CGC", 'I', "ingotInvar", 'H', + IC2Items.getItem("reinforcedGlass"), 'C', + IC2Items.getItem("electronicCircuit"), 'G', + IC2Items.getItem("geothermalGenerator") }); + // TechReborn Recipes + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModItems.parts, 4, 6), + new Object[] + { "EEE", "EAE", "EEE", 'E', "gemEmerald", 'A', + IC2Items.getItem("electronicCircuit") }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 7), - new Object[]{"AGA", "RPB", "ASA", - 'A', "ingotAluminium", - 'G', "dyeGreen", - 'R', "dyeRed", - 'P', "paneGlass", - 'B', "dyeBlue", - 'S', Items.glowstone_dust,}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 7), + new Object[] + { "AGA", "RPB", "ASA", 'A', "ingotAluminium", 'G', "dyeGreen", + 'R', "dyeRed", 'P', "paneGlass", 'B', "dyeBlue", 'S', + Items.glowstone_dust, }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 4, 8), - new Object[]{"DSD", "S S", "DSD", - 'D', "dustDiamond", - 'S', "ingotSteel"}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 4, 8), + new Object[] + { "DSD", "S S", "DSD", 'D', "dustDiamond", 'S', "ingotSteel" }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 16, 13), - new Object[]{"CSC", "SCS", "CSC", - 'S', "ingotSteel", - 'C', IC2Items.getItem("electronicCircuit")}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModItems.parts, 16, 13), + new Object[] + { "CSC", "SCS", "CSC", 'S', "ingotSteel", 'C', + IC2Items.getItem("electronicCircuit") }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 2, 14), - new Object[]{"TST", "SBS", "TST", - 'S', "ingotSteel", - 'T', "ingotTungsten", - 'B', "blockSteel"}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 2, 14), + new Object[] + { "TST", "SBS", "TST", 'S', "ingotSteel", 'T', "ingotTungsten", + 'B', "blockSteel" }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 15), - new Object[]{"AAA", "AMA", "AAA", - 'A', "ingotAluminium", - 'M', new ItemStack(ModItems.parts, 1, 13)}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 15), + new Object[] + { "AAA", "AMA", "AAA", 'A', "ingotAluminium", 'M', + new ItemStack(ModItems.parts, 1, 13) }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 16), - new Object[]{"AAA", "AMA", "AAA", - 'A', "ingotBronze", - 'M', new ItemStack(ModItems.parts, 1, 13)}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 16), + new Object[] + { "AAA", "AMA", "AAA", 'A', "ingotBronze", 'M', + new ItemStack(ModItems.parts, 1, 13) }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 17), - new Object[]{"AAA", "AMA", "AAA", - 'A', "ingotSteel", - 'M', new ItemStack(ModItems.parts, 1, 13)}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 17), + new Object[] + { "AAA", "AMA", "AAA", 'A', "ingotSteel", 'M', + new ItemStack(ModItems.parts, 1, 13) }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 18), - new Object[]{"AAA", "AMA", "AAA", - 'A', "ingotTitanium", - 'M', new ItemStack(ModItems.parts, 1, 13)}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 18), + new Object[] + { "AAA", "AMA", "AAA", 'A', "ingotTitanium", 'M', + new ItemStack(ModItems.parts, 1, 13) }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 19), - new Object[]{"AAA", "AMA", "AAA", - 'A', "ingotBrass", - 'M', new ItemStack(ModItems.parts, 1, 13)}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 19), + new Object[] + { "AAA", "AMA", "AAA", 'A', "ingotBrass", 'M', + new ItemStack(ModItems.parts, 1, 13) }); - //Storage Blocks - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 0), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotSilver",}); + // Storage Blocks + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 0), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotSilver", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 1), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotAluminium",}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 1), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotAluminium", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 2), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotTitanium",}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 2), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotTitanium", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 3), - new Object[]{"AAA", "AAA", "AAA", - 'A', "gemSapphire",}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 3), new Object[] + { "AAA", "AAA", "AAA", 'A', "gemSapphire", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 4), - new Object[]{"AAA", "AAA", "AAA", - 'A', "gemRuby",}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 4), new Object[] + { "AAA", "AAA", "AAA", 'A', "gemRuby", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 5), - new Object[]{"AAA", "AAA", "AAA", - 'A', "gemGreenSapphire",}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 5), new Object[] + { "AAA", "AAA", "AAA", 'A', "gemGreenSapphire", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 6), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotChrome",}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 6), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotChrome", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 7), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotElectrum",}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 7), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotElectrum", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 8), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotTungsten",}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 8), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotTungsten", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 9), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotLead",}); + CraftingHelper.addShapedOreRecipe( + new ItemStack(ModBlocks.storage, 1, 9), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotLead", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 10), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotZinc",}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, + 10), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotZinc", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 11), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotBrass",}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, + 11), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotBrass", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 12), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotSteel",}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, + 12), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotSteel", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 13), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotPlatinum",}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, + 13), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotPlatinum", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 14), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotNickel",}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, + 14), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotNickel", }); - CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 15), - new Object[]{"AAA", "AAA", "AAA", - 'A', "ingotInvar",}); + CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, + 15), new Object[] + { "AAA", "AAA", "AAA", 'A', "ingotInvar", }); - LogHelper.info("Shapped Recipes Added"); - } + LogHelper.info("Shapped Recipes Added"); + } - public static void addShaplessRecipes() { - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 4), "blockSilver"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 5), "blockAluminium"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 6), "blockTitanium"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.gems, 9, 1), "blockSapphire"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.gems, 9, 0), "blockRuby"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.gems, 9, 2), "blockGreenSapphire"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 7), "blockChrome"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 8), "blockElectrum"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 9), "blockTungsten"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 10), "blockLead"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 11), "blockZinc"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 12), "blockBrass"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 13), "blockSteel"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 14), "blockPlatinum"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 15), "blockNickel"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 16), "blockInvar"); - CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.rockCutter, 1, 27), Items.apple); + public static void addShaplessRecipes() + { + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 4), "blockSilver"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 5), "blockAluminium"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 6), "blockTitanium"); + CraftingHelper.addShapelessOreRecipe( + new ItemStack(ModItems.gems, 9, 1), "blockSapphire"); + CraftingHelper.addShapelessOreRecipe( + new ItemStack(ModItems.gems, 9, 0), "blockRuby"); + CraftingHelper.addShapelessOreRecipe( + new ItemStack(ModItems.gems, 9, 2), "blockGreenSapphire"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 7), "blockChrome"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 8), "blockElectrum"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 9), "blockTungsten"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 10), "blockLead"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 11), "blockZinc"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 12), "blockBrass"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 13), "blockSteel"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 14), "blockPlatinum"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 15), "blockNickel"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, + 16), "blockInvar"); + CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.rockCutter, + 1, 27), Items.apple); + LogHelper.info("Shapless Recipes Added"); + } - LogHelper.info("Shapless Recipes Added"); - } + public static void addSmeltingRecipes() + { + GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 27), + new ItemStack(Items.iron_ingot), 1F); + GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 23), + new ItemStack(Items.gold_ingot), 1F); + GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 14), + IC2Items.getItem("copperIngot"), 1F); + GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 51), + IC2Items.getItem("tinIngot"), 1F); + GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 7), + IC2Items.getItem("bronzeIngot"), 1F); + GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 29), + IC2Items.getItem("leadIngot"), 1F); + GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 45), + IC2Items.getItem("silverIngot"), 1F); - public static void addSmeltingRecipes() { - GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 27), new ItemStack(Items.iron_ingot), 1F); - GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 23), new ItemStack(Items.gold_ingot), 1F); - GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 14), IC2Items.getItem("copperIngot"), 1F); - GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 51), IC2Items.getItem("tinIngot"), 1F); - GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 7), IC2Items.getItem("bronzeIngot"), 1F); - GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 29), IC2Items.getItem("leadIngot"), 1F); - GameRegistry.addSmelting(new ItemStack(ModItems.dusts, 1, 45), IC2Items.getItem("silverIngot"), 1F); + LogHelper.info("Smelting Recipes Added"); + } - LogHelper.info("Smelting Recipes Added"); - } - - public static void addMachineRecipes() { - TechRebornAPI.registerCentrifugeRecipe(new CentrifugeRecipie(Items.apple, 4, Items.beef, Items.baked_potato, null, null, 120, 4)); - TechRebornAPI.registerCentrifugeRecipe(new CentrifugeRecipie(Items.nether_star, 1, Items.diamond, Items.emerald, Items.bed, Items.cake, 500, 8)); - TechRebornAPI.addRollingMachinceRecipe(new ItemStack(Blocks.furnace, 4), "ccc", "c c", "ccc", 'c', Blocks.cobblestone); - LogHelper.info("Machine Recipes Added"); - } + public static void addMachineRecipes() + { + TechRebornAPI.registerCentrifugeRecipe(new CentrifugeRecipie( + Items.apple, 4, Items.beef, Items.baked_potato, null, null, + 120, 4)); + TechRebornAPI.registerCentrifugeRecipe(new CentrifugeRecipie( + Items.nether_star, 1, Items.diamond, Items.emerald, Items.bed, + Items.cake, 500, 8)); + TechRebornAPI.addRollingMachinceRecipe( + new ItemStack(Blocks.furnace, 4), "ccc", "c c", "ccc", 'c', + Blocks.cobblestone); + LogHelper.info("Machine Recipes Added"); + } } diff --git a/src/main/java/techreborn/itemblocks/ItemBlockMachineCasing.java b/src/main/java/techreborn/itemblocks/ItemBlockMachineCasing.java index 9247c98db..c6b6b9161 100644 --- a/src/main/java/techreborn/itemblocks/ItemBlockMachineCasing.java +++ b/src/main/java/techreborn/itemblocks/ItemBlockMachineCasing.java @@ -3,13 +3,14 @@ package techreborn.itemblocks; import net.minecraft.block.Block; import net.minecraft.item.ItemMultiTexture; import techreborn.blocks.BlockMachineCasing; -import techreborn.blocks.BlockOre; import techreborn.init.ModBlocks; public class ItemBlockMachineCasing extends ItemMultiTexture { - public ItemBlockMachineCasing(Block block) { - super(ModBlocks.MachineCasing, ModBlocks.MachineCasing, BlockMachineCasing.types); - } + public ItemBlockMachineCasing(Block block) + { + super(ModBlocks.MachineCasing, ModBlocks.MachineCasing, + BlockMachineCasing.types); + } } diff --git a/src/main/java/techreborn/itemblocks/ItemBlockOre.java b/src/main/java/techreborn/itemblocks/ItemBlockOre.java index de46416aa..41abb93ba 100644 --- a/src/main/java/techreborn/itemblocks/ItemBlockOre.java +++ b/src/main/java/techreborn/itemblocks/ItemBlockOre.java @@ -12,20 +12,28 @@ import techreborn.achievement.IPickupAchievement; import techreborn.blocks.BlockOre; import techreborn.init.ModBlocks; -public class ItemBlockOre extends ItemMultiTexture implements IPickupAchievement, ICraftAchievement{ +public class ItemBlockOre extends ItemMultiTexture implements + IPickupAchievement, ICraftAchievement { - public ItemBlockOre(Block block) { - super(ModBlocks.ore, ModBlocks.ore, BlockOre.types); - } - - @Override - public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) { - return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) : null; + public ItemBlockOre(Block block) + { + super(ModBlocks.ore, ModBlocks.ore, BlockOre.types); } @Override - public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { - return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) : null; + public Achievement getAchievementOnCraft(ItemStack stack, + EntityPlayer player, IInventory matrix) + { + return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a) + .getAchievementOnCraft(stack, player, matrix) : null; + } + + @Override + public Achievement getAchievementOnPickup(ItemStack stack, + EntityPlayer player, EntityItem item) + { + return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a) + .getAchievementOnPickup(stack, player, item) : null; } } diff --git a/src/main/java/techreborn/itemblocks/ItemBlockQuantumChest.java b/src/main/java/techreborn/itemblocks/ItemBlockQuantumChest.java index ec420ed18..64caf8fa0 100644 --- a/src/main/java/techreborn/itemblocks/ItemBlockQuantumChest.java +++ b/src/main/java/techreborn/itemblocks/ItemBlockQuantumChest.java @@ -1,7 +1,7 @@ package techreborn.itemblocks; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; @@ -9,39 +9,53 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import techreborn.init.ModBlocks; import techreborn.tiles.TileQuantumChest; - -import java.util.List; - +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemBlockQuantumChest extends ItemBlock { - public ItemBlockQuantumChest(Block p_i45328_1_) { - super(p_i45328_1_); - } + public ItemBlockQuantumChest(Block p_i45328_1_) + { + super(p_i45328_1_); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { - if (stack != null && stack.hasTagCompound()) { - if (stack.getTagCompound().getCompoundTag("tileEntity") != null) - list.add(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("storedQuantity") + " items"); - } - } + @SuppressWarnings( + { "rawtypes", "unchecked" }) + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, + boolean par4) + { + if (stack != null && stack.hasTagCompound()) + { + if (stack.getTagCompound().getCompoundTag("tileEntity") != null) + list.add(stack.getTagCompound().getCompoundTag("tileEntity") + .getInteger("storedQuantity") + + " items"); + } + } - - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { - if (!world.setBlock(x, y, z, ModBlocks.quantumChest, metadata, 3)) { - return false; - } - if (world.getBlock(x, y, z) == ModBlocks.quantumChest) { - world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player, stack); - world.getBlock(x, y, z).onPostBlockPlaced(world, x, y, z, metadata); - } - if (stack != null && stack.hasTagCompound()) { - ((TileQuantumChest) world.getTileEntity(x, y, z)).readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); - } - return true; - } + @Override + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, + World world, int x, int y, int z, int side, float hitX, float hitY, + float hitZ, int metadata) + { + if (!world.setBlock(x, y, z, ModBlocks.quantumChest, metadata, 3)) + { + return false; + } + if (world.getBlock(x, y, z) == ModBlocks.quantumChest) + { + world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player, + stack); + world.getBlock(x, y, z).onPostBlockPlaced(world, x, y, z, metadata); + } + if (stack != null && stack.hasTagCompound()) + { + ((TileQuantumChest) world.getTileEntity(x, y, z)) + .readFromNBTWithoutCoords(stack.getTagCompound() + .getCompoundTag("tileEntity")); + } + return true; + } } diff --git a/src/main/java/techreborn/itemblocks/ItemBlockQuantumTank.java b/src/main/java/techreborn/itemblocks/ItemBlockQuantumTank.java index d75b4fae6..3db569eda 100644 --- a/src/main/java/techreborn/itemblocks/ItemBlockQuantumTank.java +++ b/src/main/java/techreborn/itemblocks/ItemBlockQuantumTank.java @@ -10,22 +10,32 @@ import techreborn.tiles.TileQuantumTank; public class ItemBlockQuantumTank extends ItemBlock { - public ItemBlockQuantumTank(Block block) { - super(block); - } + public ItemBlockQuantumTank(Block block) + { + super(block); + } - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { - if (!world.setBlock(x, y, z, ModBlocks.quantumTank, metadata, 3)) { - return false; - } - if (world.getBlock(x, y, z) == ModBlocks.quantumTank) { - world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player, stack); - world.getBlock(x, y, z).onPostBlockPlaced(world, x, y, z, metadata); - } - if (stack != null && stack.hasTagCompound()) { - ((TileQuantumTank) world.getTileEntity(x, y, z)).readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); - } - return true; - } + @Override + public boolean placeBlockAt(ItemStack stack, EntityPlayer player, + World world, int x, int y, int z, int side, float hitX, float hitY, + float hitZ, int metadata) + { + if (!world.setBlock(x, y, z, ModBlocks.quantumTank, metadata, 3)) + { + return false; + } + if (world.getBlock(x, y, z) == ModBlocks.quantumTank) + { + world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player, + stack); + world.getBlock(x, y, z).onPostBlockPlaced(world, x, y, z, metadata); + } + if (stack != null && stack.hasTagCompound()) + { + ((TileQuantumTank) world.getTileEntity(x, y, z)) + .readFromNBTWithoutCoords(stack.getTagCompound() + .getCompoundTag("tileEntity")); + } + return true; + } } diff --git a/src/main/java/techreborn/itemblocks/ItemBlockStorage.java b/src/main/java/techreborn/itemblocks/ItemBlockStorage.java index f6fa27fdb..7e335126d 100644 --- a/src/main/java/techreborn/itemblocks/ItemBlockStorage.java +++ b/src/main/java/techreborn/itemblocks/ItemBlockStorage.java @@ -7,8 +7,9 @@ import techreborn.init.ModBlocks; public class ItemBlockStorage extends ItemMultiTexture { - public ItemBlockStorage(Block block) { - super(ModBlocks.storage, ModBlocks.storage, BlockStorage.types); - } + public ItemBlockStorage(Block block) + { + super(ModBlocks.storage, ModBlocks.storage, BlockStorage.types); + } } diff --git a/src/main/java/techreborn/items/ItemCells.java b/src/main/java/techreborn/items/ItemCells.java index 6e0c5629d..4a39589cd 100644 --- a/src/main/java/techreborn/items/ItemCells.java +++ b/src/main/java/techreborn/items/ItemCells.java @@ -1,76 +1,85 @@ package techreborn.items; +import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTabMisc; -import java.util.List; - public class ItemCells extends ItemTR { - public static final String[] types = new String[] - { - "Berylium", "biomass", "calciumCarbonate", "calcium", "carbon", "chlorine", "deuterium", - "diesel", "ethanol", "glyceryl", "helium3", "helium", "heliumPlasma", "hydrogen", "ice", "lithium", - "mercury", "methane", "nitrocarbon", "nitroCoalfuel", "nitroDiesel", "nitrogen", "nitrogenDioxide", "oil", - "potassium", "seedOil", "silicon", "sodium", "sodiumPersulfate", "sodiumSulfide", "sulfur", "sulfuricAcid", - "wolframium", - }; + public static final String[] types = new String[] + { "Berylium", "biomass", "calciumCarbonate", "calcium", "carbon", + "chlorine", "deuterium", "diesel", "ethanol", "glyceryl", + "helium3", "helium", "heliumPlasma", "hydrogen", "ice", "lithium", + "mercury", "methane", "nitrocarbon", "nitroCoalfuel", + "nitroDiesel", "nitrogen", "nitrogenDioxide", "oil", "potassium", + "seedOil", "silicon", "sodium", "sodiumPersulfate", + "sodiumSulfide", "sulfur", "sulfuricAcid", "wolframium", }; - private IIcon[] textures; + private IIcon[] textures; - public ItemCells() { - setUnlocalizedName("techreborn.cell"); - setHasSubtypes(true); - setCreativeTab(TechRebornCreativeTabMisc.instance); - } + public ItemCells() + { + setUnlocalizedName("techreborn.cell"); + setHasSubtypes(true); + setCreativeTab(TechRebornCreativeTabMisc.instance); + } - @Override - // Registers Textures For All Dusts - public void registerIcons(IIconRegister iconRegister) { - textures = new IIcon[types.length]; + @Override + // Registers Textures For All Dusts + public void registerIcons(IIconRegister iconRegister) + { + textures = new IIcon[types.length]; - for (int i = 0; i < types.length; ++i) { - textures[i] = iconRegister.registerIcon("techreborn:" + "cells/" + types[i] + "Cell"); - } - } + for (int i = 0; i < types.length; ++i) + { + textures[i] = iconRegister.registerIcon("techreborn:" + "cells/" + + types[i] + "Cell"); + } + } - @Override - // Adds Texture what match's meta data - public IIcon getIconFromDamage(int meta) { - if (meta < 0 || meta >= textures.length) { - meta = 0; - } + @Override + // Adds Texture what match's meta data + public IIcon getIconFromDamage(int meta) + { + if (meta < 0 || meta >= textures.length) + { + meta = 0; + } - return textures[meta]; - } + return textures[meta]; + } - @Override - // gets Unlocalized Name depending on meta data - public String getUnlocalizedName(ItemStack itemStack) { - int meta = itemStack.getItemDamage(); - if (meta < 0 || meta >= types.length) { - meta = 0; - } + @Override + // gets Unlocalized Name depending on meta data + public String getUnlocalizedName(ItemStack itemStack) + { + int meta = itemStack.getItemDamage(); + if (meta < 0 || meta >= types.length) + { + meta = 0; + } - return super.getUnlocalizedName() + "." + types[meta]; - } + return super.getUnlocalizedName() + "." + types[meta]; + } - // Adds Dusts SubItems To Creative Tab - public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { - for (int meta = 0; meta < types.length; ++meta) { - list.add(new ItemStack(item, 1, meta)); - } - } - - @Override - public EnumRarity getRarity(ItemStack itemstack) { - return EnumRarity.uncommon; - } + // Adds Dusts SubItems To Creative Tab + public void getSubItems(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; ++meta) + { + list.add(new ItemStack(item, 1, meta)); + } + } + @Override + public EnumRarity getRarity(ItemStack itemstack) + { + return EnumRarity.uncommon; + } } diff --git a/src/main/java/techreborn/items/ItemDusts.java b/src/main/java/techreborn/items/ItemDusts.java index c57b4b175..c8763b48f 100644 --- a/src/main/java/techreborn/items/ItemDusts.java +++ b/src/main/java/techreborn/items/ItemDusts.java @@ -11,67 +11,79 @@ import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; public class ItemDusts extends ItemTR { - public static final String[] types = new String[] - { - "Almandine", "Aluminium", "Andradite", "Ashes", "Basalt", "Bauxite", "Brass", "Bronze", - "Calcite", "Charcoal", "Chrome", "Cinnabar", "Clay", "Coal", "Copper", "DarkAshes", "Diamond", - "Electrum", "Emerald", "EnderEye", "EnderPearl", "Endstone", "Flint", "Gold", "GreenSapphire", "Grossular", - "Invar", "Iron", "Lazurite", "Lead", "Magnesium", "Marble", "Netherrack", "Nickel", "Obsidian", - "Olivine", "Phosphor", "Platinum", "Pyrite", "Pyrope", "RedGarnet", "Redrock", "Ruby", "Saltpeter", "Sapphire", - "Silver", "Sodalite", "Spessartine", "Sphalerite", "Steel", "Sulfur", "Tin", "Titanium", "Tungsten", "Uranium", - "Uvarovite", "YellowGarnet", "Zinc", "Cobalt", "Ardite", "Manyullyn", "AlBrass", "Alumite" - }; + public static final String[] types = new String[] + { "Almandine", "Aluminium", "Andradite", "Ashes", "Basalt", "Bauxite", + "Brass", "Bronze", "Calcite", "Charcoal", "Chrome", "Cinnabar", + "Clay", "Coal", "Copper", "DarkAshes", "Diamond", "Electrum", + "Emerald", "EnderEye", "EnderPearl", "Endstone", "Flint", "Gold", + "GreenSapphire", "Grossular", "Invar", "Iron", "Lazurite", "Lead", + "Magnesium", "Marble", "Netherrack", "Nickel", "Obsidian", + "Olivine", "Phosphor", "Platinum", "Pyrite", "Pyrope", "RedGarnet", + "Redrock", "Ruby", "Saltpeter", "Sapphire", "Silver", "Sodalite", + "Spessartine", "Sphalerite", "Steel", "Sulfur", "Tin", "Titanium", + "Tungsten", "Uranium", "Uvarovite", "YellowGarnet", "Zinc", + "Cobalt", "Ardite", "Manyullyn", "AlBrass", "Alumite" }; - private IIcon[] textures; + private IIcon[] textures; - public ItemDusts() { - setUnlocalizedName("techreborn.dust"); - setHasSubtypes(true); - setCreativeTab(TechRebornCreativeTabMisc.instance); - } + public ItemDusts() + { + setUnlocalizedName("techreborn.dust"); + setHasSubtypes(true); + setCreativeTab(TechRebornCreativeTabMisc.instance); + } - @Override - // Registers Textures For All Dusts - public void registerIcons(IIconRegister iconRegister) { - textures = new IIcon[types.length]; + @Override + // Registers Textures For All Dusts + public void registerIcons(IIconRegister iconRegister) + { + textures = new IIcon[types.length]; - for (int i = 0; i < types.length; ++i) { - textures[i] = iconRegister.registerIcon("techreborn:" + "dust/" + types[i] + "Dust"); - } - } + for (int i = 0; i < types.length; ++i) + { + textures[i] = iconRegister.registerIcon("techreborn:" + "dust/" + + types[i] + "Dust"); + } + } - @Override - // Adds Texture what match's meta data - public IIcon getIconFromDamage(int meta) { - if (meta < 0 || meta >= textures.length) { - meta = 0; - } + @Override + // Adds Texture what match's meta data + public IIcon getIconFromDamage(int meta) + { + if (meta < 0 || meta >= textures.length) + { + meta = 0; + } - return textures[meta]; - } + return textures[meta]; + } - @Override - // gets Unlocalized Name depending on meta data - public String getUnlocalizedName(ItemStack itemStack) { - int meta = itemStack.getItemDamage(); - if (meta < 0 || meta >= types.length) { - meta = 0; - } + @Override + // gets Unlocalized Name depending on meta data + public String getUnlocalizedName(ItemStack itemStack) + { + int meta = itemStack.getItemDamage(); + if (meta < 0 || meta >= types.length) + { + meta = 0; + } - return super.getUnlocalizedName() + "." + types[meta]; - } + return super.getUnlocalizedName() + "." + types[meta]; + } - // Adds Dusts SubItems To Creative Tab - public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { - for (int meta = 0; meta < types.length; ++meta) { - list.add(new ItemStack(item, 1, meta)); - } - } - - @Override - public EnumRarity getRarity(ItemStack itemstack) { - return EnumRarity.uncommon; - } + // Adds Dusts SubItems To Creative Tab + public void getSubItems(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; ++meta) + { + list.add(new ItemStack(item, 1, meta)); + } + } + @Override + public EnumRarity getRarity(ItemStack itemstack) + { + return EnumRarity.uncommon; + } } diff --git a/src/main/java/techreborn/items/ItemDustsSmall.java b/src/main/java/techreborn/items/ItemDustsSmall.java index b62092d05..e0f20e276 100644 --- a/src/main/java/techreborn/items/ItemDustsSmall.java +++ b/src/main/java/techreborn/items/ItemDustsSmall.java @@ -11,67 +11,77 @@ import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; public class ItemDustsSmall extends ItemTR { - public static final String[] types = new String[] - { - "Almandine", "Aluminium", "Andradite", "Basalt", "Bauxite", "Brass", "Bronze", - "Calcite", "Charcoal", "Chrome", "Cinnabar", "Clay", "Coal", "Copper", "Diamond", - "Electrum", "Emerald", "EnderEye", "EnderPearl", "Endstone", "Gold", "GreenSapphire", "Grossular", - "Invar", "Iron", "Lazurite", "Lead", "Magnesium", "Marble", "Netherrack", "Nickel", "Obsidian", - "Olivine", "Platinum", "Pyrite", "Pyrope", "RedGarnet", "Ruby", "Saltpeter", "Sapphire", - "Silver", "Sodalite", "Steel", "Sulfur", "Tin", "Titanium", "Tungsten", - "Zinc", - }; + public static final String[] types = new String[] + { "Almandine", "Aluminium", "Andradite", "Basalt", "Bauxite", "Brass", + "Bronze", "Calcite", "Charcoal", "Chrome", "Cinnabar", "Clay", + "Coal", "Copper", "Diamond", "Electrum", "Emerald", "EnderEye", + "EnderPearl", "Endstone", "Gold", "GreenSapphire", "Grossular", + "Invar", "Iron", "Lazurite", "Lead", "Magnesium", "Marble", + "Netherrack", "Nickel", "Obsidian", "Olivine", "Platinum", + "Pyrite", "Pyrope", "RedGarnet", "Ruby", "Saltpeter", "Sapphire", + "Silver", "Sodalite", "Steel", "Sulfur", "Tin", "Titanium", + "Tungsten", "Zinc", }; - private IIcon[] textures; + private IIcon[] textures; - public ItemDustsSmall() { - setUnlocalizedName("techreborn.dustsmall"); - setHasSubtypes(true); - setCreativeTab(TechRebornCreativeTabMisc.instance); - } + public ItemDustsSmall() + { + setUnlocalizedName("techreborn.dustsmall"); + setHasSubtypes(true); + setCreativeTab(TechRebornCreativeTabMisc.instance); + } - @Override - // Registers Textures For All Dusts - public void registerIcons(IIconRegister iconRegister) { - textures = new IIcon[types.length]; + @Override + // Registers Textures For All Dusts + public void registerIcons(IIconRegister iconRegister) + { + textures = new IIcon[types.length]; - for (int i = 0; i < types.length; ++i) { - textures[i] = iconRegister.registerIcon("techreborn:" + "smallDust/small" + types[i] + "Dust"); - } - } + for (int i = 0; i < types.length; ++i) + { + textures[i] = iconRegister.registerIcon("techreborn:" + + "smallDust/small" + types[i] + "Dust"); + } + } - @Override - // Adds Texture what match's meta data - public IIcon getIconFromDamage(int meta) { - if (meta < 0 || meta >= textures.length) { - meta = 0; - } + @Override + // Adds Texture what match's meta data + public IIcon getIconFromDamage(int meta) + { + if (meta < 0 || meta >= textures.length) + { + meta = 0; + } - return textures[meta]; - } + return textures[meta]; + } - @Override - // gets Unlocalized Name depending on meta data - public String getUnlocalizedName(ItemStack itemStack) { - int meta = itemStack.getItemDamage(); - if (meta < 0 || meta >= types.length) { - meta = 0; - } + @Override + // gets Unlocalized Name depending on meta data + public String getUnlocalizedName(ItemStack itemStack) + { + int meta = itemStack.getItemDamage(); + if (meta < 0 || meta >= types.length) + { + meta = 0; + } - return super.getUnlocalizedName() + "." + types[meta]; - } + return super.getUnlocalizedName() + "." + types[meta]; + } - // Adds Dusts SubItems To Creative Tab - public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { - for (int meta = 0; meta < types.length; ++meta) { - list.add(new ItemStack(item, 1, meta)); - } - } - - @Override - public EnumRarity getRarity(ItemStack itemstack) { - return EnumRarity.epic; - } + // Adds Dusts SubItems To Creative Tab + public void getSubItems(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; ++meta) + { + list.add(new ItemStack(item, 1, meta)); + } + } + @Override + public EnumRarity getRarity(ItemStack itemstack) + { + return EnumRarity.epic; + } } diff --git a/src/main/java/techreborn/items/ItemGems.java b/src/main/java/techreborn/items/ItemGems.java index a3f3ac47d..509c2c69f 100644 --- a/src/main/java/techreborn/items/ItemGems.java +++ b/src/main/java/techreborn/items/ItemGems.java @@ -11,60 +11,70 @@ import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; public class ItemGems extends Item { - public static final String[] types = new String[] - { - "Ruby", "Sapphire", "GreenSapphire", "Olivine", "RedGarnet", "YellowGarnet" - }; + public static final String[] types = new String[] + { "Ruby", "Sapphire", "GreenSapphire", "Olivine", "RedGarnet", + "YellowGarnet" }; - private IIcon[] textures; + private IIcon[] textures; - public ItemGems() { - setCreativeTab(TechRebornCreativeTabMisc.instance); - setUnlocalizedName("techreborn.gem"); - setHasSubtypes(true); - } + public ItemGems() + { + setCreativeTab(TechRebornCreativeTabMisc.instance); + setUnlocalizedName("techreborn.gem"); + setHasSubtypes(true); + } - @Override - // Registers Textures For All Dusts - public void registerIcons(IIconRegister iconRegister) { - textures = new IIcon[types.length]; + @Override + // Registers Textures For All Dusts + public void registerIcons(IIconRegister iconRegister) + { + textures = new IIcon[types.length]; - for (int i = 0; i < types.length; ++i) { - textures[i] = iconRegister.registerIcon("techreborn:" + "gem/" + types[i]); - } - } + for (int i = 0; i < types.length; ++i) + { + textures[i] = iconRegister.registerIcon("techreborn:" + "gem/" + + types[i]); + } + } - @Override - // Adds Texture what match's meta data - public IIcon getIconFromDamage(int meta) { - if (meta < 0 || meta >= textures.length) { - meta = 0; - } + @Override + // Adds Texture what match's meta data + public IIcon getIconFromDamage(int meta) + { + if (meta < 0 || meta >= textures.length) + { + meta = 0; + } - return textures[meta]; - } + return textures[meta]; + } - @Override - // gets Unlocalized Name depending on meta data - public String getUnlocalizedName(ItemStack itemStack) { - int meta = itemStack.getItemDamage(); - if (meta < 0 || meta >= types.length) { - meta = 0; - } + @Override + // gets Unlocalized Name depending on meta data + public String getUnlocalizedName(ItemStack itemStack) + { + int meta = itemStack.getItemDamage(); + if (meta < 0 || meta >= types.length) + { + meta = 0; + } - return super.getUnlocalizedName() + "." + types[meta]; - } + return super.getUnlocalizedName() + "." + types[meta]; + } - // Adds Dusts SubItems To Creative Tab - public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { - for (int meta = 0; meta < types.length; ++meta) { - list.add(new ItemStack(item, 1, meta)); - } - } + // Adds Dusts SubItems To Creative Tab + public void getSubItems(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; ++meta) + { + list.add(new ItemStack(item, 1, meta)); + } + } - @Override - public EnumRarity getRarity(ItemStack itemstack) { - return EnumRarity.uncommon; - } + @Override + public EnumRarity getRarity(ItemStack itemstack) + { + return EnumRarity.uncommon; + } } diff --git a/src/main/java/techreborn/items/ItemIngots.java b/src/main/java/techreborn/items/ItemIngots.java index 35369c0e2..38b390720 100644 --- a/src/main/java/techreborn/items/ItemIngots.java +++ b/src/main/java/techreborn/items/ItemIngots.java @@ -11,62 +11,72 @@ import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; public class ItemIngots extends Item { - public static final String[] types = new String[] - { - "IridiumAlloy", "HotTungstenSteel", "TungstenSteel", "Iridium", "Silver", "Aluminium", "Titanium", "Chrome", - "Electrum", "Tungsten", "Lead", "Zinc", "Brass", "Steel", "Platinum", "Nickel", "Invar", - "Cobalt", "Ardite", "Manyullyn", "AlBrass", "Alumite" - }; + public static final String[] types = new String[] + { "IridiumAlloy", "HotTungstenSteel", "TungstenSteel", "Iridium", "Silver", + "Aluminium", "Titanium", "Chrome", "Electrum", "Tungsten", "Lead", + "Zinc", "Brass", "Steel", "Platinum", "Nickel", "Invar", "Cobalt", + "Ardite", "Manyullyn", "AlBrass", "Alumite" }; - private IIcon[] textures; + private IIcon[] textures; - public ItemIngots() { - setCreativeTab(TechRebornCreativeTabMisc.instance); - setHasSubtypes(true); - setUnlocalizedName("techreborn.ingot"); - } + public ItemIngots() + { + setCreativeTab(TechRebornCreativeTabMisc.instance); + setHasSubtypes(true); + setUnlocalizedName("techreborn.ingot"); + } - @Override - // Registers Textures For All Dusts - public void registerIcons(IIconRegister iconRegister) { - textures = new IIcon[types.length]; + @Override + // Registers Textures For All Dusts + public void registerIcons(IIconRegister iconRegister) + { + textures = new IIcon[types.length]; - for (int i = 0; i < types.length; ++i) { - textures[i] = iconRegister.registerIcon("techreborn:" + "ingot/" + types[i] + "Ingot"); - } - } + for (int i = 0; i < types.length; ++i) + { + textures[i] = iconRegister.registerIcon("techreborn:" + "ingot/" + + types[i] + "Ingot"); + } + } - @Override - // Adds Texture what match's meta data - public IIcon getIconFromDamage(int meta) { - if (meta < 0 || meta >= textures.length) { - meta = 0; - } + @Override + // Adds Texture what match's meta data + public IIcon getIconFromDamage(int meta) + { + if (meta < 0 || meta >= textures.length) + { + meta = 0; + } - return textures[meta]; - } + return textures[meta]; + } - @Override - // gets Unlocalized Name depending on meta data - public String getUnlocalizedName(ItemStack itemStack) { - int meta = itemStack.getItemDamage(); - if (meta < 0 || meta >= types.length) { - meta = 0; - } + @Override + // gets Unlocalized Name depending on meta data + public String getUnlocalizedName(ItemStack itemStack) + { + int meta = itemStack.getItemDamage(); + if (meta < 0 || meta >= types.length) + { + meta = 0; + } - return super.getUnlocalizedName() + "." + types[meta]; - } + return super.getUnlocalizedName() + "." + types[meta]; + } - // Adds Dusts SubItems To Creative Tab - public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { - for (int meta = 0; meta < types.length; ++meta) { - list.add(new ItemStack(item, 1, meta)); - } - } + // Adds Dusts SubItems To Creative Tab + public void getSubItems(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; ++meta) + { + list.add(new ItemStack(item, 1, meta)); + } + } - @Override - public EnumRarity getRarity(ItemStack itemstack) { - return EnumRarity.uncommon; - } + @Override + public EnumRarity getRarity(ItemStack itemstack) + { + return EnumRarity.uncommon; + } } diff --git a/src/main/java/techreborn/items/ItemParts.java b/src/main/java/techreborn/items/ItemParts.java index 31ee72b9f..503734dc0 100644 --- a/src/main/java/techreborn/items/ItemParts.java +++ b/src/main/java/techreborn/items/ItemParts.java @@ -11,63 +11,75 @@ import net.minecraft.util.IIcon; import techreborn.client.TechRebornCreativeTabMisc; public class ItemParts extends Item { - public static final String[] types = new String[] - { - "LazuriteChunk", "SiliconPlate", "MagnaliumPlate", "EnergeyFlowCircuit", "DataControlCircuit", "SuperConductor", - "DataStorageCircuit", "ComputerMonitor", "DiamondSawBlade", "DiamondGrinder", "KanthalHeatingCoil", - "NichromeHeatingCoil", "CupronickelHeatingCoil", "MachineParts", "WolframiamGrinder", - "AluminiumMachineHull", "BronzeMachineHull", "SteelMachineHull", "TitaniumMachineHull", "BrassMachineHull" - }; + public static final String[] types = new String[] + { "LazuriteChunk", "SiliconPlate", "MagnaliumPlate", "EnergeyFlowCircuit", + "DataControlCircuit", "SuperConductor", "DataStorageCircuit", + "ComputerMonitor", "DiamondSawBlade", "DiamondGrinder", + "KanthalHeatingCoil", "NichromeHeatingCoil", + "CupronickelHeatingCoil", "MachineParts", "WolframiamGrinder", + "AluminiumMachineHull", "BronzeMachineHull", "SteelMachineHull", + "TitaniumMachineHull", "BrassMachineHull" }; - private IIcon[] textures; + private IIcon[] textures; - public ItemParts() { - setCreativeTab(TechRebornCreativeTabMisc.instance); - setHasSubtypes(true); - setUnlocalizedName("techreborn.part"); - } + public ItemParts() + { + setCreativeTab(TechRebornCreativeTabMisc.instance); + setHasSubtypes(true); + setUnlocalizedName("techreborn.part"); + } - @Override - // Registers Textures For All Dusts - public void registerIcons(IIconRegister iconRegister) { - textures = new IIcon[types.length]; + @Override + // Registers Textures For All Dusts + public void registerIcons(IIconRegister iconRegister) + { + textures = new IIcon[types.length]; - for (int i = 0; i < types.length; ++i) { - textures[i] = iconRegister.registerIcon("techreborn:" + "part/" + types[i]); - } - } + for (int i = 0; i < types.length; ++i) + { + textures[i] = iconRegister.registerIcon("techreborn:" + "part/" + + types[i]); + } + } - @Override - // Adds Texture what match's meta data - public IIcon getIconFromDamage(int meta) { - if (meta < 0 || meta >= textures.length) { - meta = 0; - } + @Override + // Adds Texture what match's meta data + public IIcon getIconFromDamage(int meta) + { + if (meta < 0 || meta >= textures.length) + { + meta = 0; + } - return textures[meta]; - } + return textures[meta]; + } - @Override - // gets Unlocalized Name depending on meta data - public String getUnlocalizedName(ItemStack itemStack) { - int meta = itemStack.getItemDamage(); - if (meta < 0 || meta >= types.length) { - meta = 0; - } + @Override + // gets Unlocalized Name depending on meta data + public String getUnlocalizedName(ItemStack itemStack) + { + int meta = itemStack.getItemDamage(); + if (meta < 0 || meta >= types.length) + { + meta = 0; + } - return super.getUnlocalizedName() + "." + types[meta]; - } + return super.getUnlocalizedName() + "." + types[meta]; + } - // Adds Dusts SubItems To Creative Tab - public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { - for (int meta = 0; meta < types.length; ++meta) { - list.add(new ItemStack(item, 1, meta)); - } - } + // Adds Dusts SubItems To Creative Tab + public void getSubItems(Item item, CreativeTabs creativeTabs, List list) + { + for (int meta = 0; meta < types.length; ++meta) + { + list.add(new ItemStack(item, 1, meta)); + } + } - @Override - public EnumRarity getRarity(ItemStack itemstack) { - return EnumRarity.rare; - } + @Override + public EnumRarity getRarity(ItemStack itemstack) + { + return EnumRarity.rare; + } } diff --git a/src/main/java/techreborn/items/ItemTR.java b/src/main/java/techreborn/items/ItemTR.java index 935bd39db..a4f6dd4ea 100644 --- a/src/main/java/techreborn/items/ItemTR.java +++ b/src/main/java/techreborn/items/ItemTR.java @@ -7,14 +7,17 @@ import techreborn.lib.ModInfo; public class ItemTR extends Item { - public ItemTR() { - setNoRepair(); - setCreativeTab(TechRebornCreativeTab.instance); - } + public ItemTR() + { + setNoRepair(); + setCreativeTab(TechRebornCreativeTab.instance); + } - @Override - public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon(ModInfo.MOD_ID + ":" + getUnlocalizedName().toLowerCase().substring(5)); - } + @Override + public void registerIcons(IIconRegister iconRegister) + { + itemIcon = iconRegister.registerIcon(ModInfo.MOD_ID + ":" + + getUnlocalizedName().toLowerCase().substring(5)); + } } diff --git a/src/main/java/techreborn/items/armor/ItemGravityChest.java b/src/main/java/techreborn/items/armor/ItemGravityChest.java index 101277527..9f0d1f759 100644 --- a/src/main/java/techreborn/items/armor/ItemGravityChest.java +++ b/src/main/java/techreborn/items/armor/ItemGravityChest.java @@ -1,9 +1,10 @@ package techreborn.items.armor; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; + +import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -17,137 +18,179 @@ import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; import techreborn.client.TechRebornCreativeTab; import techreborn.config.ConfigTechReborn; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; -import java.util.List; +public class ItemGravityChest extends ItemArmor implements IElectricItem, + ISpecialArmor { -public class ItemGravityChest extends ItemArmor implements IElectricItem, ISpecialArmor { + public static int maxCharge = ConfigTechReborn.GravityCharge; + public int tier = 3; + public int cost = 100; + public double transferLimit = 1000; + public int energyPerDamage = 100; - public static int maxCharge = ConfigTechReborn.GravityCharge; - public int tier = 3; - public int cost = 100; - public double transferLimit = 1000; - public int energyPerDamage = 100; + public ItemGravityChest(ArmorMaterial material, int par3, int par4) + { + super(material, par3, par4); + setCreativeTab(TechRebornCreativeTab.instance); + setUnlocalizedName("techreborn.gravitychestplate"); + setMaxStackSize(1); + setMaxDamage(120); + // isDamageable(); + } - public ItemGravityChest(ArmorMaterial material, int par3, int par4) { - super(material, par3, par4); - setCreativeTab(TechRebornCreativeTab.instance); - setUnlocalizedName("techreborn.gravitychestplate"); - setMaxStackSize(1); - setMaxDamage(120); -// isDamageable(); - } + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("techreborn:" + + "items/gravitychestplate"); + } - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon("techreborn:" + "items/gravitychestplate"); - } + @Override + @SideOnly(Side.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, int slot, + String type) + { + return "techreborn:" + "textures/models/gravitychestplate.png"; + } - @Override - @SideOnly(Side.CLIENT) - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - return "techreborn:" + "textures/models/gravitychestplate.png"; - } + @SuppressWarnings( + { "rawtypes", "unchecked" }) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, + List itemList) + { + ItemStack itemStack = new ItemStack(this, 1); + if (getChargedItem(itemStack) == this) + { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, + false); + itemList.add(charged); + } + if (getEmptyItem(itemStack) == this) + { + itemList.add(new ItemStack(this, 1, getMaxDamage())); + } + } - @SuppressWarnings({"rawtypes", "unchecked"}) - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { - ItemStack charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); - itemList.add(charged); - } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); - } - } + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) + { + if (world.isRemote) + ; + if (ElectricItem.manager.canUse(stack, cost)) + { + player.capabilities.allowFlying = true; - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { - if (world.isRemote) ; - if (ElectricItem.manager.canUse(stack, cost)) { - player.capabilities.allowFlying = true; + if (player.fallDistance > 0.0F) + player.fallDistance = 0; - if (player.fallDistance > 0.0F) - player.fallDistance = 0; + if (player.capabilities.allowFlying == true & !player.onGround) + ElectricItem.manager.discharge(stack, cost, tier, false, true, + false); - if (player.capabilities.allowFlying == true & !player.onGround) - ElectricItem.manager.discharge(stack, cost, tier, false, true, false); + if (!ElectricItem.manager.canUse(stack, cost)) + player.capabilities.allowFlying = false; + } - if (!ElectricItem.manager.canUse(stack, cost)) - player.capabilities.allowFlying = false; - } + if (player.fallDistance > 0.0F) + player.fallDistance = 0; + } - if (player.fallDistance > 0.0F) player.fallDistance = 0; - } + @Override + public boolean canProvideEnergy(ItemStack itemStack) + { + return true; + } - @Override - public boolean canProvideEnergy(ItemStack itemStack) { - return true; - } + @Override + public Item getChargedItem(ItemStack itemStack) + { + return this; + } - @Override - public Item getChargedItem(ItemStack itemStack) { - return this; - } + @Override + public Item getEmptyItem(ItemStack itemStack) + { + return this; + } - @Override - public Item getEmptyItem(ItemStack itemStack) { - return this; - } + @Override + public double getMaxCharge(ItemStack itemStack) + { + return maxCharge; + } - @Override - public double getMaxCharge(ItemStack itemStack) { - return maxCharge; - } + @Override + public int getTier(ItemStack itemStack) + { + return tier; + } - @Override - public int getTier(ItemStack itemStack) { - return tier; - } + @Override + public double getTransferLimit(ItemStack itemStack) + { + return transferLimit; + } - @Override - public double getTransferLimit(ItemStack itemStack) { - return transferLimit; - } + public int getEnergyPerDamage() + { + return energyPerDamage; + } - public int getEnergyPerDamage() { - return energyPerDamage; - } + @Override + public ArmorProperties getProperties(EntityLivingBase player, + ItemStack armor, DamageSource source, double damage, int slot) + { + if (source.isUnblockable()) + { + return new net.minecraftforge.common.ISpecialArmor.ArmorProperties( + 0, 0.0D, 3); + } else + { + double absorptionRatio = getBaseAbsorptionRatio() + * getDamageAbsorptionRatio(); + int energyPerDamage = getEnergyPerDamage(); + double damageLimit = energyPerDamage <= 0 ? 0 + : (25 * ElectricItem.manager.getCharge(armor)) + / energyPerDamage; + return new net.minecraftforge.common.ISpecialArmor.ArmorProperties( + 3, absorptionRatio, (int) damageLimit); + } + } - @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { - if (source.isUnblockable()) { - return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3); - } else { - double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio(); - int energyPerDamage = getEnergyPerDamage(); - double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage; - return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit); - } - } + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) + { + if (ElectricItem.manager.getCharge(armor) >= getEnergyPerDamage()) + { + return (int) Math.round(20D * getBaseAbsorptionRatio() + * getDamageAbsorptionRatio()); + } else + { + return 0; + } + } - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - if (ElectricItem.manager.getCharge(armor) >= getEnergyPerDamage()) { - return (int) Math.round(20D * getBaseAbsorptionRatio() * getDamageAbsorptionRatio()); - } else { - return 0; - } - } + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, + DamageSource source, int damage, int slot) + { + ElectricItem.manager.discharge(stack, damage * getEnergyPerDamage(), + 0x7fffffff, true, false, false); + } - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - ElectricItem.manager.discharge(stack, damage * getEnergyPerDamage(), 0x7fffffff, true, false, false); - } + public double getDamageAbsorptionRatio() + { + return 1.1000000000000001D; + } - public double getDamageAbsorptionRatio() { - return 1.1000000000000001D; - } - - private double getBaseAbsorptionRatio() { - return 0.14999999999999999D; - } + private double getBaseAbsorptionRatio() + { + return 0.14999999999999999D; + } } diff --git a/src/main/java/techreborn/items/armor/ItemLapotronPack.java b/src/main/java/techreborn/items/armor/ItemLapotronPack.java index 702b2b488..5ecce3e9b 100644 --- a/src/main/java/techreborn/items/armor/ItemLapotronPack.java +++ b/src/main/java/techreborn/items/armor/ItemLapotronPack.java @@ -1,9 +1,10 @@ package techreborn.items.armor; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; + +import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -12,76 +13,93 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import techreborn.client.TechRebornCreativeTab; import techreborn.config.ConfigTechReborn; - -import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemLapotronPack extends ItemArmor implements IElectricItem { - public static final int maxCharge = ConfigTechReborn.LapotronPackCharge; - public static final int tier = ConfigTechReborn.LapotronPackTier; - public double transferLimit = 100000; + public static final int maxCharge = ConfigTechReborn.LapotronPackCharge; + public static final int tier = ConfigTechReborn.LapotronPackTier; + public double transferLimit = 100000; - public ItemLapotronPack(ArmorMaterial armormaterial, int par2, int par3) { - super(armormaterial, par2, par3); - setCreativeTab(TechRebornCreativeTab.instance); - setUnlocalizedName("techreborn.lapotronpack"); - setMaxStackSize(1); - } + public ItemLapotronPack(ArmorMaterial armormaterial, int par2, int par3) + { + super(armormaterial, par2, par3); + setCreativeTab(TechRebornCreativeTab.instance); + setUnlocalizedName("techreborn.lapotronpack"); + setMaxStackSize(1); + } - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/lapotronicEnergyOrb"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("techreborn:" + + "tool/lapotronicEnergyOrb"); + } - @Override - @SideOnly(Side.CLIENT) - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - return "techreborn:" + "textures/models/lapotronpack.png"; - } + @Override + @SideOnly(Side.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, int slot, + String type) + { + return "techreborn:" + "textures/models/lapotronpack.png"; + } - @SuppressWarnings({"rawtypes", "unchecked"}) - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { - ItemStack charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); - itemList.add(charged); - } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); - } - } + @SuppressWarnings( + { "rawtypes", "unchecked" }) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, + List itemList) + { + ItemStack itemStack = new ItemStack(this, 1); + if (getChargedItem(itemStack) == this) + { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, + false); + itemList.add(charged); + } + if (getEmptyItem(itemStack) == this) + { + itemList.add(new ItemStack(this, 1, getMaxDamage())); + } + } - @Override - public boolean canProvideEnergy(ItemStack itemStack) { - return true; - } + @Override + public boolean canProvideEnergy(ItemStack itemStack) + { + return true; + } - @Override - public Item getChargedItem(ItemStack itemStack) { - return this; - } + @Override + public Item getChargedItem(ItemStack itemStack) + { + return this; + } - @Override - public Item getEmptyItem(ItemStack itemStack) { - return this; - } + @Override + public Item getEmptyItem(ItemStack itemStack) + { + return this; + } - @Override - public double getMaxCharge(ItemStack itemStack) { - return maxCharge; - } + @Override + public double getMaxCharge(ItemStack itemStack) + { + return maxCharge; + } - @Override - public int getTier(ItemStack itemStack) { - return tier; - } + @Override + public int getTier(ItemStack itemStack) + { + return tier; + } - @Override - public double getTransferLimit(ItemStack itemStack) { - return transferLimit; - } + @Override + public double getTransferLimit(ItemStack itemStack) + { + return transferLimit; + } } diff --git a/src/main/java/techreborn/items/armor/ItemLithiumBatpack.java b/src/main/java/techreborn/items/armor/ItemLithiumBatpack.java index fd560cfc3..76e5e471d 100644 --- a/src/main/java/techreborn/items/armor/ItemLithiumBatpack.java +++ b/src/main/java/techreborn/items/armor/ItemLithiumBatpack.java @@ -1,9 +1,10 @@ package techreborn.items.armor; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; + +import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -12,76 +13,93 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import techreborn.client.TechRebornCreativeTab; import techreborn.config.ConfigTechReborn; - -import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemLithiumBatpack extends ItemArmor implements IElectricItem { - public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge; - public static final int tier = ConfigTechReborn.LithiumBatpackTier; - public double transferLimit = 10000; + public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge; + public static final int tier = ConfigTechReborn.LithiumBatpackTier; + public double transferLimit = 10000; - public ItemLithiumBatpack(ArmorMaterial armorMaterial, int par3, int par4) { - super(armorMaterial, par3, par4); - setMaxStackSize(1); - setUnlocalizedName("techreborn.lithiumbatpack"); - setCreativeTab(TechRebornCreativeTab.instance); - } + public ItemLithiumBatpack(ArmorMaterial armorMaterial, int par3, int par4) + { + super(armorMaterial, par3, par4); + setMaxStackSize(1); + setUnlocalizedName("techreborn.lithiumbatpack"); + setCreativeTab(TechRebornCreativeTab.instance); + } - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/lithiumBatpack"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("techreborn:" + + "tool/lithiumBatpack"); + } - @Override - @SideOnly(Side.CLIENT) - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { - return "techreborn:" + "textures/models/lithiumbatpack.png"; - } + @Override + @SideOnly(Side.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, int slot, + String type) + { + return "techreborn:" + "textures/models/lithiumbatpack.png"; + } - @SuppressWarnings({"rawtypes", "unchecked"}) - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { - ItemStack charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); - itemList.add(charged); - } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); - } - } + @SuppressWarnings( + { "rawtypes", "unchecked" }) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, + List itemList) + { + ItemStack itemStack = new ItemStack(this, 1); + if (getChargedItem(itemStack) == this) + { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, + false); + itemList.add(charged); + } + if (getEmptyItem(itemStack) == this) + { + itemList.add(new ItemStack(this, 1, getMaxDamage())); + } + } - @Override - public boolean canProvideEnergy(ItemStack itemStack) { - return true; - } + @Override + public boolean canProvideEnergy(ItemStack itemStack) + { + return true; + } - @Override - public Item getChargedItem(ItemStack itemStack) { - return this; - } + @Override + public Item getChargedItem(ItemStack itemStack) + { + return this; + } - @Override - public Item getEmptyItem(ItemStack itemStack) { - return this; - } + @Override + public Item getEmptyItem(ItemStack itemStack) + { + return this; + } - @Override - public double getMaxCharge(ItemStack itemStack) { - return maxCharge; - } + @Override + public double getMaxCharge(ItemStack itemStack) + { + return maxCharge; + } - @Override - public int getTier(ItemStack itemStack) { - return tier; - } + @Override + public int getTier(ItemStack itemStack) + { + return tier; + } - @Override - public double getTransferLimit(ItemStack itemStack) { - return transferLimit; - } + @Override + public double getTransferLimit(ItemStack itemStack) + { + return transferLimit; + } } diff --git a/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java b/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java index 6d65bca86..1198143ac 100644 --- a/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java +++ b/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java @@ -1,9 +1,10 @@ package techreborn.items.tools; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; + +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -17,111 +18,142 @@ import net.minecraft.world.World; import techreborn.client.TechRebornCreativeTab; import techreborn.config.ConfigTechReborn; import techreborn.util.TorchHelper; - -import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemAdvancedDrill extends ItemPickaxe implements IElectricItem { - public static final int maxCharge = ConfigTechReborn.AdvancedDrillCharge; - public int cost = 250; - public static final int tier = ConfigTechReborn.AdvancedDrillTier; - public double transferLimit = 100; + public static final int maxCharge = ConfigTechReborn.AdvancedDrillCharge; + public int cost = 250; + public static final int tier = ConfigTechReborn.AdvancedDrillTier; + public double transferLimit = 100; - public ItemAdvancedDrill() { - super(ToolMaterial.EMERALD); - efficiencyOnProperMaterial = 20F; - setCreativeTab(TechRebornCreativeTab.instance); - setMaxStackSize(1); - setMaxDamage(240); - setUnlocalizedName("techreborn.advancedDrill"); - } + public ItemAdvancedDrill() + { + super(ToolMaterial.EMERALD); + efficiencyOnProperMaterial = 20F; + setCreativeTab(TechRebornCreativeTab.instance); + setMaxStackSize(1); + setMaxDamage(240); + setUnlocalizedName("techreborn.advancedDrill"); + } - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/advancedDrill"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("techreborn:" + + "tool/advancedDrill"); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { - ItemStack charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); - itemList.add(charged); - } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); - } - } + @SuppressWarnings( + { "rawtypes", "unchecked" }) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, + List itemList) + { + ItemStack itemStack = new ItemStack(this, 1); + if (getChargedItem(itemStack) == this) + { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, + false); + itemList.add(charged); + } + if (getEmptyItem(itemStack) == this) + { + itemList.add(new ItemStack(this, 1, getMaxDamage())); + } + } - @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int par4, int par5, int par6, EntityLivingBase entityLiving) { - ElectricItem.manager.use(stack, cost, entityLiving); - return true; - } + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, + int par4, int par5, int par6, EntityLivingBase entityLiving) + { + ElectricItem.manager.use(stack, cost, entityLiving); + return true; + } - @Override - public boolean canHarvestBlock(Block block, ItemStack stack) { - return Items.diamond_pickaxe.canHarvestBlock(block, stack) || Items.diamond_shovel.canHarvestBlock(block, stack); - } + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) + { + return Items.diamond_pickaxe.canHarvestBlock(block, stack) + || Items.diamond_shovel.canHarvestBlock(block, stack); + } - @Override - public float getDigSpeed(ItemStack stack, Block block, int meta) { - if (!ElectricItem.manager.canUse(stack, cost)) { - return 4.0F; - } + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) + { + if (!ElectricItem.manager.canUse(stack, cost)) + { + return 4.0F; + } - if (Items.wooden_pickaxe.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_shovel.getDigSpeed(stack, block, meta) > 1.0F) { - return efficiencyOnProperMaterial; - } else { - return super.getDigSpeed(stack, block, meta); - } - } + if (Items.wooden_pickaxe.getDigSpeed(stack, block, meta) > 1.0F + || Items.wooden_shovel.getDigSpeed(stack, block, meta) > 1.0F) + { + return efficiencyOnProperMaterial; + } else + { + return super.getDigSpeed(stack, block, meta); + } + } - @Override - public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) { - return true; - } + @Override + public boolean hitEntity(ItemStack itemstack, + EntityLivingBase entityliving, EntityLivingBase entityliving1) + { + return true; + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { - return TorchHelper.placeTorch(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset); - } + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, + int x, int y, int z, int side, float xOffset, float yOffset, + float zOffset) + { + return TorchHelper.placeTorch(stack, player, world, x, y, z, side, + xOffset, yOffset, zOffset); + } - @Override - public boolean isRepairable() { - return false; - } + @Override + public boolean isRepairable() + { + return false; + } - @Override - public boolean canProvideEnergy(ItemStack itemStack) { - return false; - } + @Override + public boolean canProvideEnergy(ItemStack itemStack) + { + return false; + } - @Override - public double getMaxCharge(ItemStack itemStack) { - return maxCharge; - } + @Override + public double getMaxCharge(ItemStack itemStack) + { + return maxCharge; + } - @Override - public int getTier(ItemStack itemStack) { - return tier; - } + @Override + public int getTier(ItemStack itemStack) + { + return tier; + } - @Override - public double getTransferLimit(ItemStack itemStack) { - return transferLimit; - } + @Override + public double getTransferLimit(ItemStack itemStack) + { + return transferLimit; + } - @Override - public Item getChargedItem(ItemStack itemStack) { - return this; - } + @Override + public Item getChargedItem(ItemStack itemStack) + { + return this; + } - @Override - public Item getEmptyItem(ItemStack itemStack) { - return this; - } + @Override + public Item getEmptyItem(ItemStack itemStack) + { + return this; + } } diff --git a/src/main/java/techreborn/items/tools/ItemOmniTool.java b/src/main/java/techreborn/items/tools/ItemOmniTool.java index b0bf2a962..30ea3baca 100644 --- a/src/main/java/techreborn/items/tools/ItemOmniTool.java +++ b/src/main/java/techreborn/items/tools/ItemOmniTool.java @@ -1,9 +1,10 @@ package techreborn.items.tools; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; + +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -18,115 +19,155 @@ import net.minecraft.world.World; import techreborn.client.TechRebornCreativeTab; import techreborn.config.ConfigTechReborn; import techreborn.util.TorchHelper; - -import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemOmniTool extends ItemPickaxe implements IElectricItem { - public static final int maxCharge = ConfigTechReborn.OmniToolCharge; - public static final int tier = ConfigTechReborn.OmniToolTier; - public int cost = 100; - public int hitCost = 125; + public static final int maxCharge = ConfigTechReborn.OmniToolCharge; + public static final int tier = ConfigTechReborn.OmniToolTier; + public int cost = 100; + public int hitCost = 125; - public ItemOmniTool(ToolMaterial toolMaterial) { - super(toolMaterial); - efficiencyOnProperMaterial = 13F; - setCreativeTab(TechRebornCreativeTab.instance); - setMaxStackSize(1); - setMaxDamage(200); - setUnlocalizedName("techreborn.omniTool"); - } + public ItemOmniTool(ToolMaterial toolMaterial) + { + super(toolMaterial); + efficiencyOnProperMaterial = 13F; + setCreativeTab(TechRebornCreativeTab.instance); + setMaxStackSize(1); + setMaxDamage(200); + setUnlocalizedName("techreborn.omniTool"); + } - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/omnitool"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("techreborn:" + + "tool/omnitool"); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { - ItemStack charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); - itemList.add(charged); - } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); - } - } + @SuppressWarnings( + { "rawtypes", "unchecked" }) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, + List itemList) + { + ItemStack itemStack = new ItemStack(this, 1); + if (getChargedItem(itemStack) == this) + { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, + false); + itemList.add(charged); + } + if (getEmptyItem(itemStack) == this) + { + itemList.add(new ItemStack(this, 1, getMaxDamage())); + } + } - @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int par4, int par5, int par6, EntityLivingBase entityLiving) { - ElectricItem.manager.use(stack, cost, entityLiving); - return true; - } + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, + int par4, int par5, int par6, EntityLivingBase entityLiving) + { + ElectricItem.manager.use(stack, cost, entityLiving); + return true; + } - @Override - public boolean canHarvestBlock(Block block, ItemStack stack) { - return Items.diamond_axe.canHarvestBlock(block, stack) || Items.diamond_sword.canHarvestBlock(block, stack) || Items.diamond_pickaxe.canHarvestBlock(block, stack) || Items.diamond_shovel.canHarvestBlock(block, stack) || Items.shears.canHarvestBlock(block, stack); - } + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) + { + return Items.diamond_axe.canHarvestBlock(block, stack) + || Items.diamond_sword.canHarvestBlock(block, stack) + || Items.diamond_pickaxe.canHarvestBlock(block, stack) + || Items.diamond_shovel.canHarvestBlock(block, stack) + || Items.shears.canHarvestBlock(block, stack); + } - @Override - public float getDigSpeed(ItemStack stack, Block block, int meta) { - if (!ElectricItem.manager.canUse(stack, cost)) { - return 5.0F; - } + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) + { + if (!ElectricItem.manager.canUse(stack, cost)) + { + return 5.0F; + } - if (Items.wooden_axe.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_sword.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_pickaxe.getDigSpeed(stack, block, meta) > 1.0F || Items.wooden_shovel.getDigSpeed(stack, block, meta) > 1.0F || Items.shears.getDigSpeed(stack, block, meta) > 1.0F) { - return efficiencyOnProperMaterial; - } else { - return super.getDigSpeed(stack, block, meta); - } - } + if (Items.wooden_axe.getDigSpeed(stack, block, meta) > 1.0F + || Items.wooden_sword.getDigSpeed(stack, block, meta) > 1.0F + || Items.wooden_pickaxe.getDigSpeed(stack, block, meta) > 1.0F + || Items.wooden_shovel.getDigSpeed(stack, block, meta) > 1.0F + || Items.shears.getDigSpeed(stack, block, meta) > 1.0F) + { + return efficiencyOnProperMaterial; + } else + { + return super.getDigSpeed(stack, block, meta); + } + } - @Override - public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker) { - if (ElectricItem.manager.use(itemstack, hitCost, attacker)) { - entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 8F); - } - return false; - } + @Override + public boolean hitEntity(ItemStack itemstack, + EntityLivingBase entityliving, EntityLivingBase attacker) + { + if (ElectricItem.manager.use(itemstack, hitCost, attacker)) + { + entityliving + .attackEntityFrom(DamageSource + .causePlayerDamage((EntityPlayer) attacker), 8F); + } + return false; + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { - return TorchHelper.placeTorch(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset); - } + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, + int x, int y, int z, int side, float xOffset, float yOffset, + float zOffset) + { + return TorchHelper.placeTorch(stack, player, world, x, y, z, side, + xOffset, yOffset, zOffset); + } - @Override - public boolean isRepairable() { - return false; - } + @Override + public boolean isRepairable() + { + return false; + } - @Override - public Item getChargedItem(ItemStack itemStack) { - return this; - } + @Override + public Item getChargedItem(ItemStack itemStack) + { + return this; + } - @Override - public Item getEmptyItem(ItemStack itemStack) { - return this; - } + @Override + public Item getEmptyItem(ItemStack itemStack) + { + return this; + } - @Override - public boolean canProvideEnergy(ItemStack itemStack) { - return false; - } + @Override + public boolean canProvideEnergy(ItemStack itemStack) + { + return false; + } - @Override - public double getMaxCharge(ItemStack itemStack) { - return maxCharge; - } + @Override + public double getMaxCharge(ItemStack itemStack) + { + return maxCharge; + } - @Override - public int getTier(ItemStack itemStack) { - return 2; - } + @Override + public int getTier(ItemStack itemStack) + { + return 2; + } - @Override - public double getTransferLimit(ItemStack itemStack) { - return 200; - } + @Override + public double getTransferLimit(ItemStack itemStack) + { + return 200; + } } diff --git a/src/main/java/techreborn/items/tools/ItemRockCutter.java b/src/main/java/techreborn/items/tools/ItemRockCutter.java index a2c9a28ea..4e46ce2b2 100644 --- a/src/main/java/techreborn/items/tools/ItemRockCutter.java +++ b/src/main/java/techreborn/items/tools/ItemRockCutter.java @@ -1,9 +1,10 @@ package techreborn.items.tools; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; + +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -16,87 +17,105 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import techreborn.client.TechRebornCreativeTab; import techreborn.config.ConfigTechReborn; - -import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemRockCutter extends ItemPickaxe implements IElectricItem { - public static final int maxCharge = ConfigTechReborn.RockCutterCharge; - public int cost = 500; - public static final int tier = ConfigTechReborn.RockCutterTier; + public static final int maxCharge = ConfigTechReborn.RockCutterCharge; + public int cost = 500; + public static final int tier = ConfigTechReborn.RockCutterTier; - public ItemRockCutter(ToolMaterial toolMaterial) { - super(toolMaterial); - setUnlocalizedName("techreborn.rockcutter"); - setCreativeTab(TechRebornCreativeTab.instance); - setMaxStackSize(1); - setMaxDamage(27); - efficiencyOnProperMaterial = 16F; - } + public ItemRockCutter(ToolMaterial toolMaterial) + { + super(toolMaterial); + setUnlocalizedName("techreborn.rockcutter"); + setCreativeTab(TechRebornCreativeTab.instance); + setMaxStackSize(1); + setMaxDamage(27); + efficiencyOnProperMaterial = 16F; + } - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/rockcutter"); - } + @SideOnly(Side.CLIENT) + @Override + public void registerIcons(IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon("techreborn:" + + "tool/rockcutter"); + } - @SuppressWarnings({"rawtypes", "unchecked"}) - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { - ItemStack charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); - itemList.add(charged); - } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); - } - } + @SuppressWarnings( + { "rawtypes", "unchecked" }) + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, + List itemList) + { + ItemStack itemStack = new ItemStack(this, 1); + if (getChargedItem(itemStack) == this) + { + ItemStack charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, + false); + itemList.add(charged); + } + if (getEmptyItem(itemStack) == this) + { + itemList.add(new ItemStack(this, 1, getMaxDamage())); + } + } - @Override - public boolean canHarvestBlock(Block block, ItemStack stack) { - return Items.diamond_pickaxe.canHarvestBlock(block, stack); - } + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) + { + return Items.diamond_pickaxe.canHarvestBlock(block, stack); + } - @Override - public boolean isRepairable() { - return false; - } + @Override + public boolean isRepairable() + { + return false; + } - public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { - par1ItemStack.addEnchantment(Enchantment.silkTouch, 1); - } + public void onCreated(ItemStack par1ItemStack, World par2World, + EntityPlayer par3EntityPlayer) + { + par1ItemStack.addEnchantment(Enchantment.silkTouch, 1); + } + @Override + public boolean canProvideEnergy(ItemStack itemStack) + { + return false; + } - @Override - public boolean canProvideEnergy(ItemStack itemStack) { - return false; - } + @Override + public Item getChargedItem(ItemStack itemStack) + { + return this; + } - @Override - public Item getChargedItem(ItemStack itemStack) { - return this; - } + @Override + public Item getEmptyItem(ItemStack itemStack) + { + return this; + } - @Override - public Item getEmptyItem(ItemStack itemStack) { - return this; - } + @Override + public double getMaxCharge(ItemStack itemStack) + { + return maxCharge; + } - @Override - public double getMaxCharge(ItemStack itemStack) { - return maxCharge; - } + @Override + public int getTier(ItemStack itemStack) + { + return tier; + } - @Override - public int getTier(ItemStack itemStack) { - return tier; - } - - @Override - public double getTransferLimit(ItemStack itemStack) { - return 300; - } + @Override + public double getTransferLimit(ItemStack itemStack) + { + return 300; + } } diff --git a/src/main/java/techreborn/items/tools/ItemTechPda.java b/src/main/java/techreborn/items/tools/ItemTechPda.java index 1bd70aa6a..b5be3a601 100644 --- a/src/main/java/techreborn/items/tools/ItemTechPda.java +++ b/src/main/java/techreborn/items/tools/ItemTechPda.java @@ -9,25 +9,27 @@ import techreborn.Core; import techreborn.client.GuiHandler; import techreborn.client.TechRebornCreativeTab; -public class ItemTechPda extends Item{ - +public class ItemTechPda extends Item { + public ItemTechPda() { setCreativeTab(TechRebornCreativeTab.instance); setUnlocalizedName("techreborn.pda"); setMaxStackSize(1); } - - @Override - public void registerIcons(IIconRegister iconRegister) - { - itemIcon = iconRegister.registerIcon("techreborn:" + "tool/pda"); - } - - @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) + + @Override + public void registerIcons(IIconRegister iconRegister) { - player.openGui(Core.INSTANCE, GuiHandler.pdaID, world, (int)player.posX, (int)player.posY, (int)player.posY); + itemIcon = iconRegister.registerIcon("techreborn:" + "tool/pda"); + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, + EntityPlayer player) + { + player.openGui(Core.INSTANCE, GuiHandler.pdaID, world, + (int) player.posX, (int) player.posY, (int) player.posY); return itemStack; } diff --git a/src/main/java/techreborn/lib/Functions.java b/src/main/java/techreborn/lib/Functions.java index a025d3576..533c64409 100644 --- a/src/main/java/techreborn/lib/Functions.java +++ b/src/main/java/techreborn/lib/Functions.java @@ -3,43 +3,47 @@ package techreborn.lib; import net.minecraftforge.common.util.ForgeDirection; public class Functions { - public static int getIntDirFromDirection(ForgeDirection dir) { - switch (dir) { - case DOWN: - return 0; - case EAST: - return 5; - case NORTH: - return 2; - case SOUTH: - return 3; - case UNKNOWN: - return 0; - case UP: - return 1; - case WEST: - return 4; - default: - return 0; - } - } + public static int getIntDirFromDirection(ForgeDirection dir) + { + switch (dir) + { + case DOWN: + return 0; + case EAST: + return 5; + case NORTH: + return 2; + case SOUTH: + return 3; + case UNKNOWN: + return 0; + case UP: + return 1; + case WEST: + return 4; + default: + return 0; + } + } - public static ForgeDirection getDirectionFromInt(int dir) { - int metaDataToSet = 0; - switch (dir) { - case 0: - metaDataToSet = 2; - break; - case 1: - metaDataToSet = 4; - break; - case 2: - metaDataToSet = 3; - break; - case 3: - metaDataToSet = 5; - break; - } - return ForgeDirection.getOrientation(metaDataToSet); - } + public static ForgeDirection getDirectionFromInt(int dir) + { + int metaDataToSet = 0; + switch (dir) + { + case 0: + metaDataToSet = 2; + break; + case 1: + metaDataToSet = 4; + break; + case 2: + metaDataToSet = 3; + break; + case 3: + metaDataToSet = 5; + break; + } + return ForgeDirection.getOrientation(metaDataToSet); + } } diff --git a/src/main/java/techreborn/lib/Location.java b/src/main/java/techreborn/lib/Location.java index a8b9401cc..9910c103d 100644 --- a/src/main/java/techreborn/lib/Location.java +++ b/src/main/java/techreborn/lib/Location.java @@ -8,264 +8,290 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class Location { - public int x; - public int y; - public int z; - public int depth; + public int x; + public int y; + public int z; + public int depth; - public Location(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } + public Location(int x, int y, int z) + { + this.x = x; + this.y = y; + this.z = z; + } - public Location(int x, int y, int z, int depth) { - this.x = x; - this.y = y; - this.z = z; - this.depth = depth; - } + public Location(int x, int y, int z, int depth) + { + this.x = x; + this.y = y; + this.z = z; + this.depth = depth; + } + public Location(int xCoord, int yCoord, int zCoord, ForgeDirection dir) + { + this.x = xCoord + dir.offsetX; + this.y = yCoord + dir.offsetY; + this.z = zCoord + dir.offsetZ; + } - public Location(int xCoord, int yCoord, int zCoord, ForgeDirection dir) { - this.x = xCoord + dir.offsetX; - this.y = yCoord + dir.offsetY; - this.z = zCoord + dir.offsetZ; - } + public Location(int[] coords) + { + if (coords.length >= 2) + { + this.x = coords[0]; + this.y = coords[1]; + this.z = coords[2]; + } + } - public Location(int[] coords) { - if (coords.length >= 2) { - this.x = coords[0]; - this.y = coords[1]; - this.z = coords[2]; - } - } + public Location(ChunkPosition pos) + { + if (pos != null) + { + this.x = pos.chunkPosX; + this.y = pos.chunkPosY; + this.z = pos.chunkPosZ; + } + } - public Location(ChunkPosition pos) { - if (pos != null) { - this.x = pos.chunkPosX; - this.y = pos.chunkPosY; - this.z = pos.chunkPosZ; - } - } + public Location(MovingObjectPosition blockLookedAt) + { + if (blockLookedAt != null) + { + this.x = blockLookedAt.blockX; + this.y = blockLookedAt.blockY; + this.z = blockLookedAt.blockZ; + } + } - public Location(MovingObjectPosition blockLookedAt) { - if (blockLookedAt != null) { - this.x = blockLookedAt.blockX; - this.y = blockLookedAt.blockY; - this.z = blockLookedAt.blockZ; - } - } + public Location(TileEntity par1) + { + this.x = par1.xCoord; + this.y = par1.yCoord; + this.z = par1.zCoord; + } - public Location(TileEntity par1) - { - this.x = par1.xCoord; - this.y = par1.yCoord; - this.z = par1.zCoord; - } + public boolean equals(Location toTest) + { + if (this.x == toTest.x && this.y == toTest.y && this.z == toTest.z) + { + return true; + } + return false; + } - public boolean equals(Location toTest) { - if (this.x == toTest.x && this.y == toTest.y && this.z == toTest.z) { - return true; - } - return false; - } + public void setLocation(int x, int y, int z) + { + this.x = x; + this.y = y; + this.z = z; + } - public void setLocation(int x, int y, int z) { - this.x = x; - this.y = y; - this.z = z; - } + public int getX() + { + return this.x; + } - public int getX() { - return this.x; - } + public void setX(int newX) + { + this.x = newX; + } - public void setX(int newX) { - this.x = newX; - } + public int getY() + { + return this.y; + } - public int getY() { - return this.y; - } + public void setY(int newY) + { + this.y = newY; + } - public void setY(int newY) { - this.y = newY; - } + public int getZ() + { + return this.z; + } - public int getZ() { - return this.z; - } + public void setZ(int newZ) + { + this.z = newZ; + } - public void setZ(int newZ) { - this.z = newZ; - } + public int[] getLocation() + { + int[] ret = new int[3]; + ret[0] = this.x; + ret[1] = this.y; + ret[2] = this.z; + return ret; + } - public int[] getLocation() { - int[] ret = new int[3]; - ret[0] = this.x; - ret[1] = this.y; - ret[2] = this.z; - return ret; - } + public void setLocation(int[] coords) + { + this.x = coords[0]; + this.y = coords[1]; + this.z = coords[2]; + } - public void setLocation(int[] coords) { - this.x = coords[0]; - this.y = coords[1]; - this.z = coords[2]; - } + public int getDifference(Location otherLoc) + { + return (int) Math.sqrt(Math.pow(this.x - otherLoc.x, 2) + + Math.pow(this.y - otherLoc.y, 2) + + Math.pow(this.z - otherLoc.z, 2)); + } - public int getDifference(Location otherLoc) { - return (int) Math.sqrt(Math.pow(this.x - otherLoc.x, 2) + Math.pow(this.y - otherLoc.y, 2) + Math.pow(this.z - otherLoc.z, 2)); - } + public String printLocation() + { + return "X: " + this.x + " Y: " + this.y + " Z: " + this.z; + } - public String printLocation() { - return "X: " + this.x + " Y: " + this.y + " Z: " + this.z; - } + public String printCoords() + { + return this.x + ", " + this.y + ", " + this.z; + } - public String printCoords() { - return this.x + ", " + this.y + ", " + this.z; - } + public boolean compare(int x, int y, int z) + { + return (this.x == x && this.y == y && this.z == z); + } - public boolean compare(int x, int y, int z) { - return (this.x == x && this.y == y && this.z == z); - } + public Location getLocation(ForgeDirection dir) + { + return new Location(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); + } - public Location getLocation(ForgeDirection dir) { - return new Location(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); - } + public Location modifyPositionFromSide(ForgeDirection side, int amount) + { + switch (side.ordinal()) + { + case 0: + this.y -= amount; + break; + case 1: + this.y += amount; + break; + case 2: + this.z -= amount; + break; + case 3: + this.z += amount; + break; + case 4: + this.x -= amount; + break; + case 5: + this.x += amount; + break; + } + return this; + } - public Location modifyPositionFromSide(ForgeDirection side, int amount) - { - switch (side.ordinal()) - { - case 0: - this.y -= amount; - break; - case 1: - this.y += amount; - break; - case 2: - this.z -= amount; - break; - case 3: - this.z += amount; - break; - case 4: - this.x -= amount; - break; - case 5: - this.x += amount; - break; - } - return this; - } + public Location modifyPositionFromSide(ForgeDirection side) + { + return this.modifyPositionFromSide(side, 1); + } - public Location modifyPositionFromSide(ForgeDirection side) - { - return this.modifyPositionFromSide(side, 1); - } + /** + * This will load the chunk. + */ + public TileEntity getTileEntity(IBlockAccess world) + { + return world.getTileEntity(this.x, this.y, this.z); + } - /** - * This will load the chunk. - */ - public TileEntity getTileEntity(IBlockAccess world) - { - return world.getTileEntity(this.x, this.y, this.z); - } + public final Location clone() + { + return new Location(this.x, this.y, this.z); + } - public final Location clone() - { - return new Location(this.x, this.y, this.z); - } + /** + * No chunk load: returns null if chunk to side is unloaded + */ + public TileEntity getTileEntityOnSide(World world, ForgeDirection side) + { + int x = this.x; + int y = this.y; + int z = this.z; + switch (side.ordinal()) + { + case 0: + y--; + break; + case 1: + y++; + break; + case 2: + z--; + break; + case 3: + z++; + break; + case 4: + x--; + break; + case 5: + x++; + break; + default: + return null; + } + if (world.blockExists(x, y, z)) + { + return world.getTileEntity(x, y, z); + } else + { + return null; + } + } - /** - * No chunk load: returns null if chunk to side is unloaded - */ - public TileEntity getTileEntityOnSide(World world, ForgeDirection side) - { - int x = this.x; - int y = this.y; - int z = this.z; - switch (side.ordinal()) - { - case 0: - y--; - break; - case 1: - y++; - break; - case 2: - z--; - break; - case 3: - z++; - break; - case 4: - x--; - break; - case 5: - x++; - break; - default: - return null; - } - if (world.blockExists(x, y, z)) - { - return world.getTileEntity(x, y, z); - } - else - { - return null; - } - } + /** + * No chunk load: returns null if chunk to side is unloaded + */ + public TileEntity getTileEntityOnSide(World world, int side) + { + int x = this.x; + int y = this.y; + int z = this.z; + switch (side) + { + case 0: + y--; + break; + case 1: + y++; + break; + case 2: + z--; + break; + case 3: + z++; + break; + case 4: + x--; + break; + case 5: + x++; + break; + default: + return null; + } + if (world.blockExists(x, y, z)) + { + return world.getTileEntity(x, y, z); + } else + { + return null; + } + } - /** - * No chunk load: returns null if chunk to side is unloaded - */ - public TileEntity getTileEntityOnSide(World world, int side) - { - int x = this.x; - int y = this.y; - int z = this.z; - switch (side) - { - case 0: - y--; - break; - case 1: - y++; - break; - case 2: - z--; - break; - case 3: - z++; - break; - case 4: - x--; - break; - case 5: - x++; - break; - default: - return null; - } - if (world.blockExists(x, y, z)) - { - return world.getTileEntity(x, y, z); - } - else - { - return null; - } - } + public int getDepth() + { + return depth; + } - public int getDepth() { - return depth; - } - - public int compareTo(Location o) { - return ((Integer)depth).compareTo(o.depth); - } + public int compareTo(Location o) + { + return ((Integer) depth).compareTo(o.depth); + } } diff --git a/src/main/java/techreborn/lib/ModInfo.java b/src/main/java/techreborn/lib/ModInfo.java index 2a707650d..469e517ed 100644 --- a/src/main/java/techreborn/lib/ModInfo.java +++ b/src/main/java/techreborn/lib/ModInfo.java @@ -1,11 +1,11 @@ package techreborn.lib; public class ModInfo { - public static final String MOD_NAME = "TechReborn"; - public static final String MOD_ID = "techreborn"; - public static final String MOD_VERSION = "@MODVERSION@"; - public static final String MOD_DEPENDENCUIES = "required-after:IC2@:"; - public static final String SERVER_PROXY_CLASS = "techreborn.proxies.CommonProxy"; - public static final String CLIENT_PROXY_CLASS = "techreborn.proxies.ClientProxy"; - public static final String GUI_FACTORY_CLASS = "techreborn.config.TechRebornGUIFactory"; + public static final String MOD_NAME = "TechReborn"; + public static final String MOD_ID = "techreborn"; + public static final String MOD_VERSION = "@MODVERSION@"; + public static final String MOD_DEPENDENCUIES = "required-after:IC2@:"; + public static final String SERVER_PROXY_CLASS = "techreborn.proxies.CommonProxy"; + public static final String CLIENT_PROXY_CLASS = "techreborn.proxies.ClientProxy"; + public static final String GUI_FACTORY_CLASS = "techreborn.config.TechRebornGUIFactory"; } diff --git a/src/main/java/techreborn/lib/vecmath/Vecs3d.java b/src/main/java/techreborn/lib/vecmath/Vecs3d.java index 9805c50b3..df908e5ea 100644 --- a/src/main/java/techreborn/lib/vecmath/Vecs3d.java +++ b/src/main/java/techreborn/lib/vecmath/Vecs3d.java @@ -1,8 +1,7 @@ package techreborn.lib.vecmath; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import java.util.StringTokenizer; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; @@ -12,420 +11,496 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; - -import java.util.StringTokenizer; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class Vecs3d { - protected double x, y, z; - protected World w = null; + protected double x, y, z; + protected World w = null; - public Vecs3d(double x, double y, double z) { + public Vecs3d(double x, double y, double z) + { - this.x = x; - this.y = y; - this.z = z; - } + this.x = x; + this.y = y; + this.z = z; + } - public Vecs3d(double x, double y, double z, World w) { + public Vecs3d(double x, double y, double z, World w) + { - this(x, y, z); - this.w = w; - } + this(x, y, z); + this.w = w; + } - public Vecs3d(TileEntity te) { + public Vecs3d(TileEntity te) + { - this(te.xCoord, te.yCoord, te.zCoord, te.getWorldObj()); - } + this(te.xCoord, te.yCoord, te.zCoord, te.getWorldObj()); + } - public Vecs3d(Vec3 vec) { + public Vecs3d(Vec3 vec) + { - this(vec.xCoord, vec.yCoord, vec.zCoord); - } + this(vec.xCoord, vec.yCoord, vec.zCoord); + } - public Vecs3d(Vec3 vec, World w) { + public Vecs3d(Vec3 vec, World w) + { - this(vec.xCoord, vec.yCoord, vec.zCoord); - this.w = w; - } + this(vec.xCoord, vec.yCoord, vec.zCoord); + this.w = w; + } - public boolean hasWorld() { + public boolean hasWorld() + { - return w != null; - } + return w != null; + } - public Vecs3d add(double x, double y, double z) { + public Vecs3d add(double x, double y, double z) + { - this.x += x; - this.y += y; - this.z += z; - return this; - } + this.x += x; + this.y += y; + this.z += z; + return this; + } - public Vecs3d add(ForgeDirection dir) { + public Vecs3d add(ForgeDirection dir) + { - return add(dir.offsetX, dir.offsetY, dir.offsetZ); - } + return add(dir.offsetX, dir.offsetY, dir.offsetZ); + } - public Vecs3d add(Vecs3d vec) { + public Vecs3d add(Vecs3d vec) + { - return add(vec.x, vec.y, vec.z); - } + return add(vec.x, vec.y, vec.z); + } - public Vecs3d sub(double x, double y, double z) { + public Vecs3d sub(double x, double y, double z) + { - this.x -= x; - this.y -= y; - this.z -= z; - return this; - } + this.x -= x; + this.y -= y; + this.z -= z; + return this; + } - public Vecs3d sub(ForgeDirection dir) { + public Vecs3d sub(ForgeDirection dir) + { - return sub(dir.offsetX, dir.offsetY, dir.offsetZ); - } + return sub(dir.offsetX, dir.offsetY, dir.offsetZ); + } - public Vecs3d sub(Vecs3d vec) { + public Vecs3d sub(Vecs3d vec) + { - return sub(vec.x, vec.y, vec.z); - } + return sub(vec.x, vec.y, vec.z); + } - public Vecs3d mul(double x, double y, double z) { + public Vecs3d mul(double x, double y, double z) + { - this.x *= x; - this.y *= y; - this.z *= z; - return this; - } + this.x *= x; + this.y *= y; + this.z *= z; + return this; + } - public Vecs3d mul(double multiplier) { + public Vecs3d mul(double multiplier) + { - return mul(multiplier, multiplier, multiplier); - } + return mul(multiplier, multiplier, multiplier); + } - public Vecs3d mul(ForgeDirection direction) { + public Vecs3d mul(ForgeDirection direction) + { - return mul(direction.offsetX, direction.offsetY, direction.offsetZ); - } + return mul(direction.offsetX, direction.offsetY, direction.offsetZ); + } - public Vecs3d multiply(Vecs3d v) { + public Vecs3d multiply(Vecs3d v) + { - return mul(v.getX(), v.getY(), v.getZ()); - } + return mul(v.getX(), v.getY(), v.getZ()); + } - public Vecs3d div(double x, double y, double z) { + public Vecs3d div(double x, double y, double z) + { - this.x /= x; - this.y /= y; - this.z /= z; - return this; - } + this.x /= x; + this.y /= y; + this.z /= z; + return this; + } - public Vecs3d div(double multiplier) { + public Vecs3d div(double multiplier) + { - return div(multiplier, multiplier, multiplier); - } + return div(multiplier, multiplier, multiplier); + } - public Vecs3d div(ForgeDirection direction) { + public Vecs3d div(ForgeDirection direction) + { - return div(direction.offsetX, direction.offsetY, direction.offsetZ); - } + return div(direction.offsetX, direction.offsetY, direction.offsetZ); + } - public double length() { + public double length() + { - return Math.sqrt(x * x + y * y + z * z); - } + return Math.sqrt(x * x + y * y + z * z); + } - public Vecs3d normalize() { + public Vecs3d normalize() + { - Vecs3d v = clone(); + Vecs3d v = clone(); - double len = length(); + double len = length(); - if (len == 0) - return v; + if (len == 0) + return v; - v.x /= len; - v.y /= len; - v.z /= len; + v.x /= len; + v.y /= len; + v.z /= len; - return v; - } + return v; + } - public Vecs3d abs() { + public Vecs3d abs() + { - return new Vecs3d(Math.abs(x), Math.abs(y), Math.abs(z)); - } + return new Vecs3d(Math.abs(x), Math.abs(y), Math.abs(z)); + } - public double dot(Vecs3d v) { + public double dot(Vecs3d v) + { - return x * v.getX() + y * v.getY() + z * v.getZ(); - } + return x * v.getX() + y * v.getY() + z * v.getZ(); + } - public Vecs3d cross(Vecs3d v) { + public Vecs3d cross(Vecs3d v) + { - return new Vecs3d(y * v.getZ() - z * v.getY(), x * v.getZ() - z * v.getX(), x * v.getY() - y * v.getX()); - } + return new Vecs3d(y * v.getZ() - z * v.getY(), x * v.getZ() - z + * v.getX(), x * v.getY() - y * v.getX()); + } - public Vecs3d getRelative(double x, double y, double z) { + public Vecs3d getRelative(double x, double y, double z) + { - return clone().add(x, y, z); - } + return clone().add(x, y, z); + } - public Vecs3d getRelative(ForgeDirection dir) { + public Vecs3d getRelative(ForgeDirection dir) + { - return getRelative(dir.offsetX, dir.offsetY, dir.offsetZ); - } + return getRelative(dir.offsetX, dir.offsetY, dir.offsetZ); + } - public ForgeDirection getDirectionTo(Vecs3d vec) { + public ForgeDirection getDirectionTo(Vecs3d vec) + { - for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) - if (getBlockX() + d.offsetX == vec.getBlockX() && getBlockY() + d.offsetY == vec.getBlockY() - && getBlockZ() + d.offsetZ == vec.getBlockZ()) - return d; - return null; - } + for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) + if (getBlockX() + d.offsetX == vec.getBlockX() + && getBlockY() + d.offsetY == vec.getBlockY() + && getBlockZ() + d.offsetZ == vec.getBlockZ()) + return d; + return null; + } - public boolean isZero() { + public boolean isZero() + { - return x == 0 && y == 0 && z == 0; - } + return x == 0 && y == 0 && z == 0; + } - @Override - public Vecs3d clone() { + @Override + public Vecs3d clone() + { - return new Vecs3d(x, y, z, w); - } + return new Vecs3d(x, y, z, w); + } - public boolean hasTileEntity() { + public boolean hasTileEntity() + { - if (hasWorld()) { - return w.getTileEntity((int) x, (int) y, (int) z) != null; - } - return false; - } + if (hasWorld()) + { + return w.getTileEntity((int) x, (int) y, (int) z) != null; + } + return false; + } - public TileEntity getTileEntity() { + public TileEntity getTileEntity() + { - if (hasTileEntity()) { - return w.getTileEntity((int) x, (int) y, (int) z); - } - return null; - } + if (hasTileEntity()) + { + return w.getTileEntity((int) x, (int) y, (int) z); + } + return null; + } - public boolean isBlock(Block b) { + public boolean isBlock(Block b) + { - return isBlock(b, false); - } + return isBlock(b, false); + } - public boolean isBlock(Block b, boolean checkAir) { + public boolean isBlock(Block b, boolean checkAir) + { - if (hasWorld()) { - Block bl = w.getBlock((int) x, (int) y, (int) z); + if (hasWorld()) + { + Block bl = w.getBlock((int) x, (int) y, (int) z); - if (b == null && bl == Blocks.air) - return true; - if (b == null && checkAir && bl.getMaterial() == Material.air) - return true; - if (b == null && checkAir && bl.isAir(w, (int) x, (int) y, (int) z)) - return true; + if (b == null && bl == Blocks.air) + return true; + if (b == null && checkAir && bl.getMaterial() == Material.air) + return true; + if (b == null && checkAir && bl.isAir(w, (int) x, (int) y, (int) z)) + return true; - return bl.getClass().isInstance(b); - } - return false; - } + return bl.getClass().isInstance(b); + } + return false; + } - public int getBlockMeta() { + public int getBlockMeta() + { - if (hasWorld()) { - return w.getBlockMetadata((int) x, (int) y, (int) z); - } - return -1; - } + if (hasWorld()) + { + return w.getBlockMetadata((int) x, (int) y, (int) z); + } + return -1; + } - public Block getBlock() { + public Block getBlock() + { - return getBlock(false); - } + return getBlock(false); + } - public Block getBlock(boolean airIsNull) { + public Block getBlock(boolean airIsNull) + { - if (hasWorld()) { - if (airIsNull && isBlock(null, true)) - return null; - return w.getBlock((int) x, (int) y, (int) z); + if (hasWorld()) + { + if (airIsNull && isBlock(null, true)) + return null; + return w.getBlock((int) x, (int) y, (int) z); - } - return null; - } + } + return null; + } - public World getWorld() { + public World getWorld() + { - return w; - } + return w; + } - public Vecs3d setWorld(World world) { + public Vecs3d setWorld(World world) + { - w = world; + w = world; - return this; - } + return this; + } - public double getX() { + public double getX() + { - return x; - } + return x; + } - public double getY() { + public double getY() + { - return y; - } + return y; + } - public double getZ() { + public double getZ() + { - return z; - } + return z; + } - public int getBlockX() { + public int getBlockX() + { - return (int) Math.floor(x); - } + return (int) Math.floor(x); + } - public int getBlockY() { + public int getBlockY() + { - return (int) Math.floor(y); - } + return (int) Math.floor(y); + } - public int getBlockZ() { + public int getBlockZ() + { - return (int) Math.floor(z); - } + return (int) Math.floor(z); + } - public double distanceTo(Vecs3d vec) { + public double distanceTo(Vecs3d vec) + { - return distanceTo(vec.x, vec.y, vec.z); - } + return distanceTo(vec.x, vec.y, vec.z); + } - public double distanceTo(double x, double y, double z) { + public double distanceTo(double x, double y, double z) + { - double dx = x - this.x; - double dy = y - this.y; - double dz = z - this.z; - return dx * dx + dy * dy + dz * dz; - } + double dx = x - this.x; + double dy = y - this.y; + double dz = z - this.z; + return dx * dx + dy * dy + dz * dz; + } - public void setX(double x) { + public void setX(double x) + { - this.x = x; - } + this.x = x; + } - public void setY(double y) { + public void setY(double y) + { - this.y = y; - } - - public void setZ(double z) { - - this.z = z; - } - - @Override - public boolean equals(Object obj) { - - if (obj instanceof Vecs3d) { - Vecs3d vec = (Vecs3d) obj; - return vec.w == w && vec.x == x && vec.y == y && vec.z == z; - } - return false; - } - - @Override - public int hashCode() { - - return new Double(x).hashCode() + new Double(y).hashCode() << 8 + new Double(z).hashCode() << 16; - } - - public Vec3 toVec3() { - - return Vec3.createVectorHelper(x, y, z); - } - - @Override - public String toString() { - - String s = "Vector3{"; - if (hasWorld()) - s += "w=" + w.provider.dimensionId + ";"; - s += "x=" + x + ";y=" + y + ";z=" + z + "}"; - return s; - } - - public ForgeDirection toForgeDirection() { - - if (z == 1) - return ForgeDirection.SOUTH; - if (z == -1) - return ForgeDirection.NORTH; - - if (x == 1) - return ForgeDirection.EAST; - if (x == -1) - return ForgeDirection.WEST; - - if (y == 1) - return ForgeDirection.UP; - if (y == -1) - return ForgeDirection.DOWN; - - return ForgeDirection.UNKNOWN; - } - - public static Vecs3d fromString(String s) { - - if (s.startsWith("Vector3{") && s.endsWith("}")) { - World w = null; - double x = 0, y = 0, z = 0; - String s2 = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}")); - StringTokenizer st = new StringTokenizer(s2, ";"); - while (st.hasMoreTokens()) { - String t = st.nextToken(); - - if (t.toLowerCase().startsWith("w")) { - int world = Integer.parseInt(t.split("=")[1]); - if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { - for (World wo : MinecraftServer.getServer().worldServers) { - if (wo.provider.dimensionId == world) { - w = wo; - break; - } - } - } else { - w = getClientWorld(world); - } - } - - if (t.toLowerCase().startsWith("x")) - x = Double.parseDouble(t.split("=")[1]); - if (t.toLowerCase().startsWith("y")) - y = Double.parseDouble(t.split("=")[1]); - if (t.toLowerCase().startsWith("z")) - z = Double.parseDouble(t.split("=")[1]); - } - - if (w != null) { - return new Vecs3d(x, y, z, w); - } else { - return new Vecs3d(x, y, z); - } - } - return null; - } - - @SideOnly(Side.CLIENT) - private static World getClientWorld(int world) { - - if (Minecraft.getMinecraft().theWorld.provider.dimensionId != world) - return null; - return Minecraft.getMinecraft().theWorld; - } + this.y = y; + } + + public void setZ(double z) + { + + this.z = z; + } + + @Override + public boolean equals(Object obj) + { + + if (obj instanceof Vecs3d) + { + Vecs3d vec = (Vecs3d) obj; + return vec.w == w && vec.x == x && vec.y == y && vec.z == z; + } + return false; + } + + @Override + public int hashCode() + { + + return new Double(x).hashCode() + new Double(y).hashCode() << 8 + new Double( + z).hashCode() << 16; + } + + public Vec3 toVec3() + { + + return Vec3.createVectorHelper(x, y, z); + } + + @Override + public String toString() + { + + String s = "Vector3{"; + if (hasWorld()) + s += "w=" + w.provider.dimensionId + ";"; + s += "x=" + x + ";y=" + y + ";z=" + z + "}"; + return s; + } + + public ForgeDirection toForgeDirection() + { + + if (z == 1) + return ForgeDirection.SOUTH; + if (z == -1) + return ForgeDirection.NORTH; + + if (x == 1) + return ForgeDirection.EAST; + if (x == -1) + return ForgeDirection.WEST; + + if (y == 1) + return ForgeDirection.UP; + if (y == -1) + return ForgeDirection.DOWN; + + return ForgeDirection.UNKNOWN; + } + + public static Vecs3d fromString(String s) + { + + if (s.startsWith("Vector3{") && s.endsWith("}")) + { + World w = null; + double x = 0, y = 0, z = 0; + String s2 = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}")); + StringTokenizer st = new StringTokenizer(s2, ";"); + while (st.hasMoreTokens()) + { + String t = st.nextToken(); + + if (t.toLowerCase().startsWith("w")) + { + int world = Integer.parseInt(t.split("=")[1]); + if (FMLCommonHandler.instance().getEffectiveSide() + .isServer()) + { + for (World wo : MinecraftServer.getServer().worldServers) + { + if (wo.provider.dimensionId == world) + { + w = wo; + break; + } + } + } else + { + w = getClientWorld(world); + } + } + + if (t.toLowerCase().startsWith("x")) + x = Double.parseDouble(t.split("=")[1]); + if (t.toLowerCase().startsWith("y")) + y = Double.parseDouble(t.split("=")[1]); + if (t.toLowerCase().startsWith("z")) + z = Double.parseDouble(t.split("=")[1]); + } + + if (w != null) + { + return new Vecs3d(x, y, z, w); + } else + { + return new Vecs3d(x, y, z); + } + } + return null; + } + + @SideOnly(Side.CLIENT) + private static World getClientWorld(int world) + { + + if (Minecraft.getMinecraft().theWorld.provider.dimensionId != world) + return null; + return Minecraft.getMinecraft().theWorld; + } } \ No newline at end of file diff --git a/src/main/java/techreborn/lib/vecmath/Vecs3dCube.java b/src/main/java/techreborn/lib/vecmath/Vecs3dCube.java index a6eed9e1e..16a289b51 100644 --- a/src/main/java/techreborn/lib/vecmath/Vecs3dCube.java +++ b/src/main/java/techreborn/lib/vecmath/Vecs3dCube.java @@ -1,161 +1,186 @@ package techreborn.lib.vecmath; +import java.util.List; + import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; - -import java.util.List; - public class Vecs3dCube { - private Vecs3d min, max; + private Vecs3d min, max; - public Vecs3dCube(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { + public Vecs3dCube(double minX, double minY, double minZ, double maxX, + double maxY, double maxZ) + { - this(minX, minY, minZ, maxX, maxY, maxZ, (World) null); - } + this(minX, minY, minZ, maxX, maxY, maxZ, (World) null); + } - public Vecs3dCube(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, World world) { + public Vecs3dCube(double minX, double minY, double minZ, double maxX, + double maxY, double maxZ, World world) + { - this(new Vecs3d(minX, minY, minZ, world), new Vecs3d(maxX, maxY, maxZ, world)); - } + this(new Vecs3d(minX, minY, minZ, world), new Vecs3d(maxX, maxY, maxZ, + world)); + } - public Vecs3dCube(Vecs3d a, Vecs3d b) { + public Vecs3dCube(Vecs3d a, Vecs3d b) + { - World w = a.getWorld(); - if (w == null) - w = b.getWorld(); + World w = a.getWorld(); + if (w == null) + w = b.getWorld(); - min = a; - max = b; + min = a; + max = b; - fix(); - } + fix(); + } + public Vecs3dCube(AxisAlignedBB aabb) + { - public Vecs3dCube(AxisAlignedBB aabb) { + this(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ); + } - this(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ); - } + public Vecs3d getMin() + { - public Vecs3d getMin() { + return min; + } - return min; - } + public Vecs3d getMax() + { - public Vecs3d getMax() { + return max; + } - return max; - } + public Vecs3d getCenter() + { - public Vecs3d getCenter() { + return new Vecs3d((getMinX() + getMaxX()) / 2D, + (getMinY() + getMaxY()) / 2D, (getMinZ() + getMaxZ()) / 2D, + getMin().getWorld()); + } - return new Vecs3d((getMinX() + getMaxX()) / 2D, (getMinY() + getMaxY()) / 2D, (getMinZ() + getMaxZ()) / 2D, getMin().getWorld()); - } + public double getMinX() + { - public double getMinX() { + return min.getX(); + } - return min.getX(); - } + public double getMinY() + { - public double getMinY() { + return min.getY(); + } - return min.getY(); - } + public double getMinZ() + { - public double getMinZ() { + return min.getZ(); + } - return min.getZ(); - } + public double getMaxX() + { - public double getMaxX() { + return max.getX(); + } - return max.getX(); - } + public double getMaxY() + { - public double getMaxY() { + return max.getY(); + } - return max.getY(); - } + public double getMaxZ() + { - public double getMaxZ() { + return max.getZ(); + } - return max.getZ(); - } + public AxisAlignedBB toAABB() + { - public AxisAlignedBB toAABB() { + return AxisAlignedBB.getBoundingBox(getMinX(), getMinY(), getMinZ(), + getMaxX(), getMaxY(), getMaxZ()); + } - return AxisAlignedBB.getBoundingBox(getMinX(), getMinY(), getMinZ(), getMaxX(), getMaxY(), getMaxZ()); - } + @Override + public Vecs3dCube clone() + { - @Override - public Vecs3dCube clone() { + return new Vecs3dCube(min.clone(), max.clone()); + } - return new Vecs3dCube(min.clone(), max.clone()); - } + public Vecs3dCube expand(double size) + { - public Vecs3dCube expand(double size) { + min.sub(size, size, size); + max.add(size, size, size); - min.sub(size, size, size); - max.add(size, size, size); + return this; + } - return this; - } + public Vecs3dCube fix() + { - public Vecs3dCube fix() { + Vecs3d a = min.clone(); + Vecs3d b = max.clone(); - Vecs3d a = min.clone(); - Vecs3d b = max.clone(); + double minX = Math.min(a.getX(), b.getX()); + double minY = Math.min(a.getY(), b.getY()); + double minZ = Math.min(a.getZ(), b.getZ()); - double minX = Math.min(a.getX(), b.getX()); - double minY = Math.min(a.getY(), b.getY()); - double minZ = Math.min(a.getZ(), b.getZ()); + double maxX = Math.max(a.getX(), b.getX()); + double maxY = Math.max(a.getY(), b.getY()); + double maxZ = Math.max(a.getZ(), b.getZ()); - double maxX = Math.max(a.getX(), b.getX()); - double maxY = Math.max(a.getY(), b.getY()); - double maxZ = Math.max(a.getZ(), b.getZ()); + min = new Vecs3d(minX, minY, minZ, a.w); + max = new Vecs3d(maxX, maxY, maxZ, b.w); - min = new Vecs3d(minX, minY, minZ, a.w); - max = new Vecs3d(maxX, maxY, maxZ, b.w); + return this; + } - return this; - } + public Vecs3dCube add(double x, double y, double z) + { - public Vecs3dCube add(double x, double y, double z) { + min.add(x, y, z); + max.add(x, y, z); - min.add(x, y, z); - max.add(x, y, z); + return this; + } - return this; - } + public static final Vecs3dCube merge(List cubes) + { - public static final Vecs3dCube merge(List cubes) { + double minx = Double.MAX_VALUE; + double miny = Double.MAX_VALUE; + double minz = Double.MAX_VALUE; + double maxx = Double.MIN_VALUE; + double maxy = Double.MIN_VALUE; + double maxz = Double.MIN_VALUE; - double minx = Double.MAX_VALUE; - double miny = Double.MAX_VALUE; - double minz = Double.MAX_VALUE; - double maxx = Double.MIN_VALUE; - double maxy = Double.MIN_VALUE; - double maxz = Double.MIN_VALUE; + for (Vecs3dCube c : cubes) + { + minx = Math.min(minx, c.getMinX()); + miny = Math.min(miny, c.getMinY()); + minz = Math.min(minz, c.getMinZ()); + maxx = Math.max(maxx, c.getMaxX()); + maxy = Math.max(maxy, c.getMaxY()); + maxz = Math.max(maxz, c.getMaxZ()); + } - for (Vecs3dCube c : cubes) { - minx = Math.min(minx, c.getMinX()); - miny = Math.min(miny, c.getMinY()); - minz = Math.min(minz, c.getMinZ()); - maxx = Math.max(maxx, c.getMaxX()); - maxy = Math.max(maxy, c.getMaxY()); - maxz = Math.max(maxz, c.getMaxZ()); - } + if (cubes.size() == 0) + return new Vecs3dCube(0, 0, 0, 0, 0, 0); - if (cubes.size() == 0) - return new Vecs3dCube(0, 0, 0, 0, 0, 0); + return new Vecs3dCube(minx, miny, minz, maxx, maxy, maxz); + } - return new Vecs3dCube(minx, miny, minz, maxx, maxy, maxz); - } + @Override + public int hashCode() + { - @Override - public int hashCode() { - - return min.hashCode() << 8 + max.hashCode(); - } + return min.hashCode() << 8 + max.hashCode(); + } } diff --git a/src/main/java/techreborn/multiblocks/MultiBlockCasing.java b/src/main/java/techreborn/multiblocks/MultiBlockCasing.java index 0ba0ed4bb..eeebee46b 100644 --- a/src/main/java/techreborn/multiblocks/MultiBlockCasing.java +++ b/src/main/java/techreborn/multiblocks/MultiBlockCasing.java @@ -1,136 +1,164 @@ package techreborn.multiblocks; -import erogenousbeef.coreTR.multiblock.IMultiblockPart; -import erogenousbeef.coreTR.multiblock.MultiblockControllerBase; -import erogenousbeef.coreTR.multiblock.MultiblockValidationException; -import erogenousbeef.coreTR.multiblock.rectangular.RectangularMultiblockControllerBase; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import techreborn.util.LogHelper; +import erogenousbeef.coreTR.multiblock.IMultiblockPart; +import erogenousbeef.coreTR.multiblock.MultiblockControllerBase; +import erogenousbeef.coreTR.multiblock.MultiblockValidationException; +import erogenousbeef.coreTR.multiblock.rectangular.RectangularMultiblockControllerBase; public class MultiBlockCasing extends RectangularMultiblockControllerBase { - public MultiBlockCasing(World world) { - super(world); - } + public MultiBlockCasing(World world) + { + super(world); + } - @Override - public void onAttachedPartWithMultiblockData(IMultiblockPart part, NBTTagCompound data) { + @Override + public void onAttachedPartWithMultiblockData(IMultiblockPart part, + NBTTagCompound data) + { - } + } - @Override - protected void onBlockAdded(IMultiblockPart newPart) { - } + @Override + protected void onBlockAdded(IMultiblockPart newPart) + { + } - @Override - protected void onBlockRemoved(IMultiblockPart oldPart) { + @Override + protected void onBlockRemoved(IMultiblockPart oldPart) + { - } + } - @Override - protected void onMachineAssembled() { - LogHelper.warn("New multiblock created!"); - } + @Override + protected void onMachineAssembled() + { + LogHelper.warn("New multiblock created!"); + } - @Override - protected void onMachineRestored() { + @Override + protected void onMachineRestored() + { - } + } - @Override - protected void onMachinePaused() { + @Override + protected void onMachinePaused() + { - } + } - @Override - protected void onMachineDisassembled() { + @Override + protected void onMachineDisassembled() + { - } + } - @Override - protected int getMinimumNumberOfBlocksForAssembledMachine() { - return 1; - } + @Override + protected int getMinimumNumberOfBlocksForAssembledMachine() + { + return 1; + } - @Override - protected int getMaximumXSize() { - return 3; - } + @Override + protected int getMaximumXSize() + { + return 3; + } - @Override - protected int getMaximumZSize() { - return 3; - } + @Override + protected int getMaximumZSize() + { + return 3; + } - @Override - protected int getMaximumYSize() { - return 4; - } + @Override + protected int getMaximumYSize() + { + return 4; + } - @Override - protected int getMinimumXSize() { - return 3; - } + @Override + protected int getMinimumXSize() + { + return 3; + } - @Override - protected int getMinimumYSize() { - return 4; - } + @Override + protected int getMinimumYSize() + { + return 4; + } - @Override - protected int getMinimumZSize() { - return 3; - } + @Override + protected int getMinimumZSize() + { + return 3; + } - @Override - protected void onAssimilate(MultiblockControllerBase assimilated) { + @Override + protected void onAssimilate(MultiblockControllerBase assimilated) + { - } + } - @Override - protected void onAssimilated(MultiblockControllerBase assimilator) { + @Override + protected void onAssimilated(MultiblockControllerBase assimilator) + { - } + } - @Override - protected boolean updateServer() { - return true; - } + @Override + protected boolean updateServer() + { + return true; + } - @Override - protected void updateClient() { + @Override + protected void updateClient() + { - } + } - @Override - public void writeToNBT(NBTTagCompound data) { + @Override + public void writeToNBT(NBTTagCompound data) + { - } + } - @Override - public void readFromNBT(NBTTagCompound data) { + @Override + public void readFromNBT(NBTTagCompound data) + { - } + } - @Override - public void formatDescriptionPacket(NBTTagCompound data) { + @Override + public void formatDescriptionPacket(NBTTagCompound data) + { - } + } - @Override - public void decodeDescriptionPacket(NBTTagCompound data) { + @Override + public void decodeDescriptionPacket(NBTTagCompound data) + { - } + } - - @Override - protected void isBlockGoodForInterior(World world, int x, int y, int z) throws MultiblockValidationException { - Block block = world.getBlock(x, y, z); - if(block.getUnlocalizedName().equals("tile.lava") || block.getUnlocalizedName().equals("tile.air")){ - } else { - super.isBlockGoodForInterior(world, x, y, z); - } - } + @Override + protected void isBlockGoodForInterior(World world, int x, int y, int z) + throws MultiblockValidationException + { + Block block = world.getBlock(x, y, z); + if (block.getUnlocalizedName().equals("tile.lava") + || block.getUnlocalizedName().equals("tile.air")) + { + } else + { + super.isBlockGoodForInterior(world, x, y, z); + } + } } diff --git a/src/main/java/techreborn/packets/PacketHandler.java b/src/main/java/techreborn/packets/PacketHandler.java index 759499e8d..bf4ba4cce 100644 --- a/src/main/java/techreborn/packets/PacketHandler.java +++ b/src/main/java/techreborn/packets/PacketHandler.java @@ -1,71 +1,97 @@ package techreborn.packets; -import cpw.mods.fml.common.network.FMLEmbeddedChannel; -import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; -import cpw.mods.fml.common.network.FMLOutboundHandler; -import cpw.mods.fml.relauncher.Side; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.Packet; -import net.minecraft.world.World; import java.io.IOException; import java.util.EnumMap; import java.util.logging.Logger; -public class PacketHandler extends FMLIndexedMessageToMessageCodec { - private static EnumMap channels; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.Packet; +import net.minecraft.world.World; +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.relauncher.Side; - public PacketHandler() { +public class PacketHandler extends + FMLIndexedMessageToMessageCodec { + private static EnumMap channels; - } + public PacketHandler() + { - public static EnumMap getChannels() { - return channels; - } + } - public static void setChannels(EnumMap _channels) { - channels = _channels; - } + public static EnumMap getChannels() + { + return channels; + } - public static void sendPacketToServer(SimplePacket packet) { - PacketHandler.getChannels().get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); - PacketHandler.getChannels().get(Side.CLIENT).writeOutbound(packet); - } + public static void setChannels(EnumMap _channels) + { + channels = _channels; + } - public static void sendPacketToPlayer(SimplePacket packet, EntityPlayer player) { - PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); - PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); - PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet); - } + public static void sendPacketToServer(SimplePacket packet) + { + PacketHandler.getChannels().get(Side.CLIENT) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.TOSERVER); + PacketHandler.getChannels().get(Side.CLIENT).writeOutbound(packet); + } - public static void sendPacketToAllPlayers(SimplePacket packet) { - PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); - PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet); - } + public static void sendPacketToPlayer(SimplePacket packet, + EntityPlayer player) + { + PacketHandler.getChannels().get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.PLAYER); + PacketHandler.getChannels().get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); + PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet); + } - public static void sendPacketToAllPlayers(Packet packet, World world) { - for (Object player : world.playerEntities) { - if (player instanceof EntityPlayerMP) - if (player != null) - ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(packet); - } - } + public static void sendPacketToAllPlayers(SimplePacket packet) + { + PacketHandler.getChannels().get(Side.SERVER) + .attr(FMLOutboundHandler.FML_MESSAGETARGET) + .set(FMLOutboundHandler.OutboundTarget.ALL); + PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet); + } - @Override - public void encodeInto(ChannelHandlerContext ctx, SimplePacket msg, ByteBuf target) throws Exception { - msg.writePacketData(target); - } + public static void sendPacketToAllPlayers(Packet packet, World world) + { + for (Object player : world.playerEntities) + { + if (player instanceof EntityPlayerMP) + if (player != null) + ((EntityPlayerMP) player).playerNetServerHandler + .sendPacket(packet); + } + } - @Override - public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, SimplePacket msg) { - try { - msg.readPacketData(source); - msg.execute(); - } catch (IOException e) { - Logger.getLogger("Network").warning("Something caused a Protocol Exception!"); - } - } + @Override + public void encodeInto(ChannelHandlerContext ctx, SimplePacket msg, + ByteBuf target) throws Exception + { + msg.writePacketData(target); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, + SimplePacket msg) + { + try + { + msg.readPacketData(source); + msg.execute(); + } catch (IOException e) + { + Logger.getLogger("Network").warning( + "Something caused a Protocol Exception!"); + } + } } \ No newline at end of file diff --git a/src/main/java/techreborn/packets/SimplePacket.java b/src/main/java/techreborn/packets/SimplePacket.java index 6d9ae96cb..1777e5829 100644 --- a/src/main/java/techreborn/packets/SimplePacket.java +++ b/src/main/java/techreborn/packets/SimplePacket.java @@ -1,7 +1,9 @@ package techreborn.packets; -import com.google.common.base.Charsets; import io.netty.buffer.ByteBuf; + +import java.io.IOException; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -9,110 +11,133 @@ import net.minecraftforge.common.DimensionManager; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; -import java.io.IOException; +import com.google.common.base.Charsets; public abstract class SimplePacket { - protected EntityPlayer player; - protected byte mode; + protected EntityPlayer player; + protected byte mode; - public SimplePacket(EntityPlayer _player) { - player = _player; - } + public SimplePacket(EntityPlayer _player) + { + player = _player; + } - @SuppressWarnings("unused") - public SimplePacket() { - player = null; - } + @SuppressWarnings("unused") + public SimplePacket() + { + player = null; + } - public static String readString(ByteBuf in) throws IOException { - byte[] stringBytes = new byte[in.readInt()]; - in.readBytes(stringBytes); - return new String(stringBytes, Charsets.UTF_8); - } + public static String readString(ByteBuf in) throws IOException + { + byte[] stringBytes = new byte[in.readInt()]; + in.readBytes(stringBytes); + return new String(stringBytes, Charsets.UTF_8); + } - public static void writeString(String string, ByteBuf out) throws IOException { - byte[] stringBytes; - stringBytes = string.getBytes(Charsets.UTF_8); - out.writeInt(stringBytes.length); - out.writeBytes(stringBytes); - } + public static void writeString(String string, ByteBuf out) + throws IOException + { + byte[] stringBytes; + stringBytes = string.getBytes(Charsets.UTF_8); + out.writeInt(stringBytes.length); + out.writeBytes(stringBytes); + } - public static World readWorld(ByteBuf in) throws IOException { - return DimensionManager.getWorld(in.readInt()); - } + public static World readWorld(ByteBuf in) throws IOException + { + return DimensionManager.getWorld(in.readInt()); + } - public static void writeWorld(World world, ByteBuf out) throws IOException { - out.writeInt(world.provider.dimensionId); - } + public static void writeWorld(World world, ByteBuf out) throws IOException + { + out.writeInt(world.provider.dimensionId); + } - public static EntityPlayer readPlayer(ByteBuf in) throws IOException { - if (!in.readBoolean()) - return null; - World playerWorld = readWorld(in); - return playerWorld.getPlayerEntityByName(readString(in)); - } + public static EntityPlayer readPlayer(ByteBuf in) throws IOException + { + if (!in.readBoolean()) + return null; + World playerWorld = readWorld(in); + return playerWorld.getPlayerEntityByName(readString(in)); + } - public static void writePlayer(EntityPlayer player, ByteBuf out) throws IOException { - if (player == null) { - out.writeBoolean(false); - return; - } - out.writeBoolean(true); - writeWorld(player.worldObj, out); - writeString(player.getCommandSenderName(), out); - } + public static void writePlayer(EntityPlayer player, ByteBuf out) + throws IOException + { + if (player == null) + { + out.writeBoolean(false); + return; + } + out.writeBoolean(true); + writeWorld(player.worldObj, out); + writeString(player.getCommandSenderName(), out); + } - public static TileEntity readTileEntity(ByteBuf in) throws IOException { - return readWorld(in).getTileEntity(in.readInt(), in.readInt(), in.readInt()); - } + public static TileEntity readTileEntity(ByteBuf in) throws IOException + { + return readWorld(in).getTileEntity(in.readInt(), in.readInt(), + in.readInt()); + } - public static void writeTileEntity(TileEntity tileEntity, ByteBuf out) throws IOException { - writeWorld(tileEntity.getWorldObj(), out); - out.writeInt(tileEntity.xCoord); - out.writeInt(tileEntity.yCoord); - out.writeInt(tileEntity.zCoord); - } + public static void writeTileEntity(TileEntity tileEntity, ByteBuf out) + throws IOException + { + writeWorld(tileEntity.getWorldObj(), out); + out.writeInt(tileEntity.xCoord); + out.writeInt(tileEntity.yCoord); + out.writeInt(tileEntity.zCoord); + } - public static Fluid readFluid(ByteBuf in) throws IOException { - return FluidRegistry.getFluid(readString(in)); - } + public static Fluid readFluid(ByteBuf in) throws IOException + { + return FluidRegistry.getFluid(readString(in)); + } - public static void writeFluid(Fluid fluid, ByteBuf out) throws IOException { - if (fluid == null) { - writeString("", out); - return; - } - writeString(fluid.getName(), out); - } + public static void writeFluid(Fluid fluid, ByteBuf out) throws IOException + { + if (fluid == null) + { + writeString("", out); + return; + } + writeString(fluid.getName(), out); + } - public void writePacketData(ByteBuf out) throws IOException { - out.writeByte(mode); - writePlayer(player, out); - writeData(out); - } + public void writePacketData(ByteBuf out) throws IOException + { + out.writeByte(mode); + writePlayer(player, out); + writeData(out); + } - public abstract void writeData(ByteBuf out) throws IOException; + public abstract void writeData(ByteBuf out) throws IOException; - public void readPacketData(ByteBuf in) throws IOException { - mode = in.readByte(); - player = readPlayer(in); - readData(in); - } + public void readPacketData(ByteBuf in) throws IOException + { + mode = in.readByte(); + player = readPlayer(in); + readData(in); + } - public abstract void readData(ByteBuf in) throws IOException; + public abstract void readData(ByteBuf in) throws IOException; - public abstract void execute(); + public abstract void execute(); - public void sendPacketToServer() { - PacketHandler.sendPacketToServer(this); - } + public void sendPacketToServer() + { + PacketHandler.sendPacketToServer(this); + } - public void sendPacketToPlayer(EntityPlayer player) { - PacketHandler.sendPacketToPlayer(this, player); - } + public void sendPacketToPlayer(EntityPlayer player) + { + PacketHandler.sendPacketToPlayer(this, player); + } - public void sendPacketToAllPlayers() { - PacketHandler.sendPacketToAllPlayers(this); - } + public void sendPacketToAllPlayers() + { + PacketHandler.sendPacketToAllPlayers(this); + } } diff --git a/src/main/java/techreborn/partSystem/ICustomHighlight.java b/src/main/java/techreborn/partSystem/ICustomHighlight.java index 57c409594..2c8f7230b 100644 --- a/src/main/java/techreborn/partSystem/ICustomHighlight.java +++ b/src/main/java/techreborn/partSystem/ICustomHighlight.java @@ -1,13 +1,14 @@ package techreborn.partSystem; +import java.util.ArrayList; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; -import java.util.ArrayList; - public interface ICustomHighlight { - ArrayList getBoxes(World world, int x, int y, int z, EntityPlayer player); + ArrayList getBoxes(World world, int x, int y, int z, + EntityPlayer player); } diff --git a/src/main/java/techreborn/partSystem/IModPart.java b/src/main/java/techreborn/partSystem/IModPart.java index 6649dad47..5bd08df33 100644 --- a/src/main/java/techreborn/partSystem/IModPart.java +++ b/src/main/java/techreborn/partSystem/IModPart.java @@ -4,29 +4,30 @@ package techreborn.partSystem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import java.util.List; + import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import techreborn.lib.vecmath.Vecs3d; import techreborn.lib.vecmath.Vecs3dCube; - -import java.util.List; - +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** - * This is based of https://github.com/Qmunity/QmunityLib/blob/master/src/main/java/uk/co/qmunity/lib/part/IPart.java + * This is based of + * https://github.com/Qmunity/QmunityLib/blob/master/src/main/java + * /uk/co/qmunity/lib/part/IPart.java *

* You should not be implementing this. */ public interface IModPart { /** - * Adds all of this part's collision boxes to the list. These boxes can depend on the entity that's colliding with them. + * Adds all of this part's collision boxes to the list. These boxes can + * depend on the entity that's colliding with them. */ public void addCollisionBoxesToList(List boxes, Entity entity); @@ -35,7 +36,6 @@ public interface IModPart { */ public List getSelectionBoxes(); - /** * Gets this part's occlusion boxes. */ @@ -49,10 +49,12 @@ public interface IModPart { /** * Renders this part statically. A tessellator has alredy started drawing.
- * Only called when there's a block/lighting/render update in the chunk this part is in. + * Only called when there's a block/lighting/render update in the chunk this + * part is in. */ @SideOnly(Side.CLIENT) - public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, int pass); + public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, + int pass); /** * Writes the part's data to an NBT tag, which is saved with the game data. @@ -105,7 +107,8 @@ public interface IModPart { public void tick(); /** - * Called when a block or part has been changed. Can be used for cables to check nearby blocks + * Called when a block or part has been changed. Can be used for cables to + * check nearby blocks */ public void nearByChange(); diff --git a/src/main/java/techreborn/partSystem/IPartProvider.java b/src/main/java/techreborn/partSystem/IPartProvider.java index a552229fd..22b3363bd 100644 --- a/src/main/java/techreborn/partSystem/IPartProvider.java +++ b/src/main/java/techreborn/partSystem/IPartProvider.java @@ -11,18 +11,20 @@ import net.minecraft.world.World; import techreborn.lib.Location; import techreborn.lib.vecmath.Vecs3dCube; - public interface IPartProvider { public String modID(); public void registerPart(); - public boolean checkOcclusion(World world, Location location, Vecs3dCube cube); + public boolean checkOcclusion(World world, Location location, + Vecs3dCube cube); public boolean hasPart(World world, Location location, String name); - public boolean placePart(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, ModPart modPart); + public boolean placePart(ItemStack item, EntityPlayer player, World world, + int x, int y, int z, int side, float hitX, float hitY, float hitZ, + ModPart modPart); public boolean isTileFromProvider(TileEntity tileEntity); } diff --git a/src/main/java/techreborn/partSystem/ModPart.java b/src/main/java/techreborn/partSystem/ModPart.java index 23d30e014..2b8d5ac09 100644 --- a/src/main/java/techreborn/partSystem/ModPart.java +++ b/src/main/java/techreborn/partSystem/ModPart.java @@ -4,12 +4,10 @@ package techreborn.partSystem; - import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import techreborn.lib.Location; - /** * Extend this class to make your multipart */ @@ -25,21 +23,21 @@ public abstract class ModPart extends TileEntity implements IModPart { */ public Location location; - /** * This is the world */ @Override - public World getWorld() { + public World getWorld() + { return world; } /** - * This sets the world - * Don't use this unless you know what you are doing. + * This sets the world Don't use this unless you know what you are doing. */ - public void setWorld(World world) { + public void setWorld(World world) + { this.world = world; setWorldObj(world); } @@ -48,7 +46,8 @@ public abstract class ModPart extends TileEntity implements IModPart { * Gets the x position in the world */ @Override - public int getX() { + public int getX() + { return location.getX(); } @@ -56,7 +55,8 @@ public abstract class ModPart extends TileEntity implements IModPart { * Gets the y position in the world */ @Override - public int getY() { + public int getY() + { return location.getY(); } @@ -64,37 +64,39 @@ public abstract class ModPart extends TileEntity implements IModPart { * Gets the z position in the world */ @Override - public int getZ() { + public int getZ() + { return location.getZ(); } - /** * Gets the location of the part */ - public Location getLocation() { + public Location getLocation() + { return location; } - /** * Sets the x position in the world */ - public void setLocation(Location location) { + public void setLocation(Location location) + { this.location = location; this.xCoord = location.getX(); this.yCoord = location.getY(); this.zCoord = location.getZ(); } - @Override - public World getWorldObj() { + public World getWorldObj() + { return getWorld(); } @Override - public void setWorldObj(World p_145834_1_) { + public void setWorldObj(World p_145834_1_) + { super.setWorldObj(p_145834_1_); } } diff --git a/src/main/java/techreborn/partSystem/ModPartItem.java b/src/main/java/techreborn/partSystem/ModPartItem.java index 267c3a1ff..4a61c8a1b 100644 --- a/src/main/java/techreborn/partSystem/ModPartItem.java +++ b/src/main/java/techreborn/partSystem/ModPartItem.java @@ -10,38 +10,54 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import uk.co.qmunity.lib.ref.Names; - public class ModPartItem extends Item { ModPart modPart; - public ModPartItem(ModPart part) { + public ModPartItem(ModPart part) + { modPart = part; setUnlocalizedName(Names.Unlocalized.Items.MULTIPART); } @Override - public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int face, float x_, float y_, float z_) { - if(ModPartRegistry.masterProvider != null){ - try { - if (ModPartRegistry.masterProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().newInstance())) { + public boolean onItemUse(ItemStack item, EntityPlayer player, World world, + int x, int y, int z, int face, float x_, float y_, float z_) + { + if (ModPartRegistry.masterProvider != null) + { + try + { + if (ModPartRegistry.masterProvider.placePart(item, player, + world, x, y, z, face, x_, y_, z_, modPart.getClass() + .newInstance())) + { return true; } - } catch (InstantiationException e) { + } catch (InstantiationException e) + { e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException e) + { e.printStackTrace(); } return false; - }else { - for (IPartProvider partProvider : ModPartRegistry.providers) { - try { - if (partProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().newInstance())) { + } else + { + for (IPartProvider partProvider : ModPartRegistry.providers) + { + try + { + if (partProvider.placePart(item, player, world, x, y, z, + face, x_, y_, z_, modPart.getClass().newInstance())) + { return true; } - } catch (InstantiationException e) { + } catch (InstantiationException e) + { e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException e) + { e.printStackTrace(); } } @@ -50,11 +66,13 @@ public class ModPartItem extends Item { } @Override - public String getUnlocalizedName(ItemStack stack) { + public String getUnlocalizedName(ItemStack stack) + { return modPart.getName(); } - public ModPart getModPart() { + public ModPart getModPart() + { return modPart; } } diff --git a/src/main/java/techreborn/partSystem/ModPartRegistry.java b/src/main/java/techreborn/partSystem/ModPartRegistry.java index 821c891ce..0ad946b30 100644 --- a/src/main/java/techreborn/partSystem/ModPartRegistry.java +++ b/src/main/java/techreborn/partSystem/ModPartRegistry.java @@ -4,16 +4,16 @@ package techreborn.partSystem; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.item.Item; -import techreborn.client.TechRebornCreativeTab; -import techreborn.util.LogHelper; - import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import net.minecraft.item.Item; +import techreborn.client.TechRebornCreativeTab; +import techreborn.util.LogHelper; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.registry.GameRegistry; + public class ModPartRegistry { public static ArrayList parts = new ArrayList(); @@ -24,55 +24,78 @@ public class ModPartRegistry { public static Map itemParts = new HashMap(); - public static void registerPart(ModPart iModPart) { + public static void registerPart(ModPart iModPart) + { parts.add(iModPart); } - public static void addAllPartsToSystems() { + public static void addAllPartsToSystems() + { LogHelper.info("Started to load all parts"); - for (ModPart modPart : ModPartRegistry.parts) { - Item part = new ModPartItem(modPart).setUnlocalizedName(modPart.getName()).setCreativeTab(TechRebornCreativeTab.instance).setTextureName(modPart.getItemTextureName()); + for (ModPart modPart : ModPartRegistry.parts) + { + Item part = new ModPartItem(modPart) + .setUnlocalizedName(modPart.getName()) + .setCreativeTab(TechRebornCreativeTab.instance) + .setTextureName(modPart.getItemTextureName()); GameRegistry.registerItem(part, modPart.getName()); itemParts.put(part, modPart.getName()); } - for (IPartProvider iPartProvider : providers) { + for (IPartProvider iPartProvider : providers) + { iPartProvider.registerPart(); } } - public static Item getItem(String string) { - for (Map.Entry entry : itemParts.entrySet()) { - if (entry.getValue().equals(string)) { + public static Item getItem(String string) + { + for (Map.Entry entry : itemParts.entrySet()) + { + if (entry.getValue().equals(string)) + { return entry.getKey(); } } return null; } - public static void addProvider(String className, String modid) { - if (Loader.isModLoaded(modid) || modid.equals("Minecraft")) { - try { + public static void addProvider(String className, String modid) + { + if (Loader.isModLoaded(modid) || modid.equals("Minecraft")) + { + try + { IPartProvider iPartProvider = null; - iPartProvider = (IPartProvider) Class.forName(className).newInstance(); + iPartProvider = (IPartProvider) Class.forName(className) + .newInstance(); providers.add(iPartProvider); - } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) + { e.printStackTrace(); - LogHelper.error("Failed to load " + className + " to the part system!"); - } catch (InstantiationException e) { + LogHelper.error("Failed to load " + className + + " to the part system!"); + } catch (InstantiationException e) + { e.printStackTrace(); - LogHelper.error("Failed to load " + className + " to the part system!"); - } catch (IllegalAccessException e) { + LogHelper.error("Failed to load " + className + + " to the part system!"); + } catch (IllegalAccessException e) + { e.printStackTrace(); - LogHelper.error("Failed to load " + className + " to the part system!"); + LogHelper.error("Failed to load " + className + + " to the part system!"); } } } - //Only use this one if it is a standalone Provider - public static void addProvider(IPartProvider iPartProvider) { - if (Loader.isModLoaded(iPartProvider.modID()) || iPartProvider.modID().equals("Minecraft")) { + // Only use this one if it is a standalone Provider + public static void addProvider(IPartProvider iPartProvider) + { + if (Loader.isModLoaded(iPartProvider.modID()) + || iPartProvider.modID().equals("Minecraft")) + { providers.add(iPartProvider); } } diff --git a/src/main/java/techreborn/partSystem/ModPartUtils.java b/src/main/java/techreborn/partSystem/ModPartUtils.java index 9f9957edb..55e0d00b9 100644 --- a/src/main/java/techreborn/partSystem/ModPartUtils.java +++ b/src/main/java/techreborn/partSystem/ModPartUtils.java @@ -4,73 +4,96 @@ package techreborn.partSystem; +import java.util.Map; + import net.minecraft.item.Item; import net.minecraft.world.World; import techreborn.lib.Location; import techreborn.lib.vecmath.Vecs3dCube; -import java.util.Map; - public class ModPartUtils { - - public static boolean checkOcclusion(World world, Location location, Vecs3dCube cube) { - if (world == null) { + public static boolean checkOcclusion(World world, Location location, + Vecs3dCube cube) + { + if (world == null) + { return false; } IPartProvider partProvider = getPartProvider(world, location); - if (partProvider != null) { + if (partProvider != null) + { return partProvider.checkOcclusion(world, location, cube); } return false; } - public static boolean checkOcclusion(World world, int x, int y, int z, Vecs3dCube cube) { + public static boolean checkOcclusion(World world, int x, int y, int z, + Vecs3dCube cube) + { return checkOcclusion(world, new Location(x, y, z), cube); } - public static boolean checkOcclusionInvert(World world, Location location, Vecs3dCube cube) { - if (world == null) { + public static boolean checkOcclusionInvert(World world, Location location, + Vecs3dCube cube) + { + if (world == null) + { return false; } - for (IPartProvider iPartProvider : ModPartRegistry.providers) { - if (!iPartProvider.checkOcclusion(world, location, cube)) { + for (IPartProvider iPartProvider : ModPartRegistry.providers) + { + if (!iPartProvider.checkOcclusion(world, location, cube)) + { return false; } } return false; } - public static boolean checkOcclusionInvert(World world, int x, int y, int z, Vecs3dCube cube) { + public static boolean checkOcclusionInvert(World world, int x, int y, + int z, Vecs3dCube cube) + { return checkOcclusionInvert(world, new Location(x, y, z), cube); } - public static boolean hasPart(World world, Location location, String name) { - for (IPartProvider iPartProvider : ModPartRegistry.providers) { - if (iPartProvider.hasPart(world, location, name)) { + public static boolean hasPart(World world, Location location, String name) + { + for (IPartProvider iPartProvider : ModPartRegistry.providers) + { + if (iPartProvider.hasPart(world, location, name)) + { return true; } } return false; } - - public static boolean hasPart(World world, int x, int y, int z, String name) { + public static boolean hasPart(World world, int x, int y, int z, String name) + { return hasPart(world, new Location(x, y, z), name); } - public static Item getItemForPart(String string) { - for (Map.Entry item : ModPartRegistry.itemParts.entrySet()) { - if (item.getValue().equals(string)) { + public static Item getItemForPart(String string) + { + for (Map.Entry item : ModPartRegistry.itemParts + .entrySet()) + { + if (item.getValue().equals(string)) + { return item.getKey(); } } return null; } - public static IPartProvider getPartProvider(World world, Location location) { - for (IPartProvider partProvider : ModPartRegistry.providers) { - if (partProvider.isTileFromProvider(world.getTileEntity(location.getX(), location.getY(), location.getZ()))) { + public static IPartProvider getPartProvider(World world, Location location) + { + for (IPartProvider partProvider : ModPartRegistry.providers) + { + if (partProvider.isTileFromProvider(world.getTileEntity( + location.getX(), location.getY(), location.getZ()))) + { return partProvider; } } diff --git a/src/main/java/techreborn/partSystem/QLib/ModLib2QLib.java b/src/main/java/techreborn/partSystem/QLib/ModLib2QLib.java index fd1f9fb0e..fa034718f 100644 --- a/src/main/java/techreborn/partSystem/QLib/ModLib2QLib.java +++ b/src/main/java/techreborn/partSystem/QLib/ModLib2QLib.java @@ -4,52 +4,59 @@ package techreborn.partSystem.QLib; +import java.util.ArrayList; +import java.util.List; + import techreborn.lib.vecmath.Vecs3d; import techreborn.lib.vecmath.Vecs3dCube; import uk.co.qmunity.lib.vec.Vec3d; import uk.co.qmunity.lib.vec.Vec3dCube; -import java.util.ArrayList; -import java.util.List; - /** * Created by mark on 09/12/14. */ public class ModLib2QLib { - public static Vec3d convert(Vecs3d input) { + public static Vec3d convert(Vecs3d input) + { return new Vec3d(input.getX(), input.getY(), input.getZ()); } - public static Vec3dCube convert(Vecs3dCube input) { + public static Vec3dCube convert(Vecs3dCube input) + { return new Vec3dCube(input.toAABB()); } - - public static Vecs3d convert(Vec3d input) { + public static Vecs3d convert(Vec3d input) + { return new Vecs3d(input.getX(), input.getY(), input.getZ()); } - public static Vecs3dCube convert(Vec3dCube input) { + public static Vecs3dCube convert(Vec3dCube input) + { return new Vecs3dCube(input.toAABB()); } - public static List convert(List input) { + public static List convert(List input) + { List list = new ArrayList(); - for (Vec3dCube cube : input) { + for (Vec3dCube cube : input) + { list.add(new Vecs3dCube(cube.toAABB())); } return list; } - //Its got to be called becuase of some weird thing see: https://stackoverflow.com/questions/1998544/method-has-the-same-erasure-as-another-method-in-type - public static List convert2(List input) { + // Its got to be called becuase of some weird thing see: + // https://stackoverflow.com/questions/1998544/method-has-the-same-erasure-as-another-method-in-type + public static List convert2(List input) + { List list = new ArrayList(); - for (Vecs3dCube cube : input) { + for (Vecs3dCube cube : input) + { list.add(new Vec3dCube(cube.toAABB())); } return list; } - } diff --git a/src/main/java/techreborn/partSystem/QLib/QModPart.java b/src/main/java/techreborn/partSystem/QLib/QModPart.java index f17850e0b..94c973c4b 100644 --- a/src/main/java/techreborn/partSystem/QLib/QModPart.java +++ b/src/main/java/techreborn/partSystem/QLib/QModPart.java @@ -4,14 +4,17 @@ package techreborn.partSystem.QLib; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; import techreborn.lib.Location; import techreborn.lib.vecmath.Vecs3d; import techreborn.lib.vecmath.Vecs3dCube; import techreborn.partSystem.ModPart; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import uk.co.qmunity.lib.client.render.RenderHelper; import uk.co.qmunity.lib.part.IPart; import uk.co.qmunity.lib.part.IPartCollidable; @@ -27,72 +30,86 @@ import uk.co.qmunity.lib.vec.Vec3d; import uk.co.qmunity.lib.vec.Vec3dCube; import uk.co.qmunity.lib.vec.Vec3i; -import java.util.ArrayList; -import java.util.List; - - -public class QModPart extends PartBase implements IPartCollidable, IPartSelectable, IPartRenderPlacement, IPartTicking, IPartUpdateListener { +public class QModPart extends PartBase implements IPartCollidable, + IPartSelectable, IPartRenderPlacement, IPartTicking, + IPartUpdateListener { ModPart iModPart; - public QModPart(ModPart iModPart) { + public QModPart(ModPart iModPart) + { this.iModPart = iModPart; } @Override - public void setParent(ITilePartHolder parent) { + public void setParent(ITilePartHolder parent) + { super.setParent(parent); } @Override - public String getType() { + public String getType() + { return iModPart.getName(); } @Override - public ItemStack getItem() { + public ItemStack getItem() + { return iModPart.getItem(); } @Override - public void addCollisionBoxesToList(List boxes, Entity entity) { + public void addCollisionBoxesToList(List boxes, Entity entity) + { List cubes = new ArrayList(); iModPart.addCollisionBoxesToList(cubes, entity); - for (Vecs3dCube cube : cubes) { + for (Vecs3dCube cube : cubes) + { if (cube != null) boxes.add(ModLib2QLib.convert(cube)); } } @Override - public void renderDynamic(Vec3d translation, double delta, int pass) { + public void renderDynamic(Vec3d translation, double delta, int pass) + { iModPart.renderDynamic(ModLib2QLib.convert(translation), delta); } @Override - public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) { - return iModPart.renderStatic(new Vecs3d(translation.getX(), translation.getY(), translation.getZ()),renderBlocks , pass); + public boolean renderStatic(Vec3i translation, RenderHelper renderer, + RenderBlocks renderBlocks, int pass) + { + return iModPart.renderStatic( + new Vecs3d(translation.getX(), translation.getY(), translation + .getZ()), renderBlocks, pass); } @Override - public QMovingObjectPosition rayTrace(Vec3d start, Vec3d end) { + public QMovingObjectPosition rayTrace(Vec3d start, Vec3d end) + { return RayTracer.instance().rayTraceCubes(this, start, end); } @Override - public List getSelectionBoxes() { + public List getSelectionBoxes() + { return ModLib2QLib.convert2(iModPart.getSelectionBoxes()); } @Override - public World getWorld() { + public World getWorld() + { return getParent().getWorld(); } @Override - public void update() { - if (iModPart.world == null || iModPart.location == null) { + public void update() + { + if (iModPart.world == null || iModPart.location == null) + { iModPart.setWorld(getWorld()); iModPart.setLocation(new Location(getX(), getY(), getZ())); } @@ -100,18 +117,22 @@ public class QModPart extends PartBase implements IPartCollidable, IPartSelectab } @Override - public void onPartChanged(IPart part) { + public void onPartChanged(IPart part) + { iModPart.nearByChange(); } @Override - public void onNeighborBlockChange() { + public void onNeighborBlockChange() + { iModPart.nearByChange(); } @Override - public void onNeighborTileChange() { - if (iModPart.world == null || iModPart.location == null) { + public void onNeighborTileChange() + { + if (iModPart.world == null || iModPart.location == null) + { iModPart.setWorld(getWorld()); iModPart.setLocation(new Location(getX(), getY(), getZ())); } @@ -119,21 +140,26 @@ public class QModPart extends PartBase implements IPartCollidable, IPartSelectab } @Override - public void onAdded() { - if(iModPart.location != null){ + public void onAdded() + { + if (iModPart.location != null) + { iModPart.nearByChange(); iModPart.onAdded(); } } @Override - public void onRemoved() { + public void onRemoved() + { iModPart.onRemoved(); } @Override - public void onLoaded() { - if (iModPart.world == null || iModPart.location == null) { + public void onLoaded() + { + if (iModPart.world == null || iModPart.location == null) + { iModPart.setWorld(getWorld()); iModPart.setLocation(new Location(getX(), getY(), getZ())); } @@ -141,12 +167,14 @@ public class QModPart extends PartBase implements IPartCollidable, IPartSelectab } @Override - public void onUnloaded() { + public void onUnloaded() + { } @Override - public void onConverted() { + public void onConverted() + { } } diff --git a/src/main/java/techreborn/partSystem/QLib/QModPartFactory.java b/src/main/java/techreborn/partSystem/QLib/QModPartFactory.java index 4cce84803..7a337f565 100644 --- a/src/main/java/techreborn/partSystem/QLib/QModPartFactory.java +++ b/src/main/java/techreborn/partSystem/QLib/QModPartFactory.java @@ -4,7 +4,8 @@ package techreborn.partSystem.QLib; -import techreborn.lib.Location; +import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -12,6 +13,7 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import techreborn.lib.Location; import techreborn.lib.vecmath.Vecs3dCube; import techreborn.partSystem.IPartProvider; import techreborn.partSystem.ModPart; @@ -25,19 +27,22 @@ import uk.co.qmunity.lib.tile.TileMultipart; import uk.co.qmunity.lib.vec.Vec3dCube; import uk.co.qmunity.lib.vec.Vec3i; -import java.util.List; - - public class QModPartFactory implements IPartFactory, IPartProvider { @Override - public IPart createPart(String type, boolean client) { - for (ModPart modPart : ModPartRegistry.parts) { - if (modPart.getName().equals(type)) { - try { + public IPart createPart(String type, boolean client) + { + for (ModPart modPart : ModPartRegistry.parts) + { + if (modPart.getName().equals(type)) + { + try + { return new QModPart(modPart.getClass().newInstance()); - } catch (InstantiationException e) { + } catch (InstantiationException e) + { e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException e) + { e.printStackTrace(); } } @@ -45,58 +50,83 @@ public class QModPartFactory implements IPartFactory, IPartProvider { return null; } - @Override - public boolean placePart(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int face, float x_, float y_, float z_, ModPart modPart) { - IPart part = createPart(item, player, world, - new MovingObjectPosition(x, y, z, face, Vec3.createVectorHelper(x + x_, y + y_, z + z_)), modPart); + public boolean placePart(ItemStack item, EntityPlayer player, World world, + int x, int y, int z, int face, float x_, float y_, float z_, + ModPart modPart) + { + IPart part = createPart( + item, + player, + world, + new MovingObjectPosition(x, y, z, face, Vec3 + .createVectorHelper(x + x_, y + y_, z + z_)), modPart); if (part == null) return false; ForgeDirection dir = ForgeDirection.getOrientation(face); - return MultipartCompatibility.placePartInWorld(part, world, new Vec3i(x, y, z), dir, player, item); + return MultipartCompatibility.placePartInWorld(part, world, new Vec3i( + x, y, z), dir, player, item); } @Override - public boolean isTileFromProvider(TileEntity tileEntity) { + public boolean isTileFromProvider(TileEntity tileEntity) + { return tileEntity instanceof TileMultipart; } - public String getCreatedPartType(ItemStack item, EntityPlayer player, World world, MovingObjectPosition mop, ModPart modPart) { + public String getCreatedPartType(ItemStack item, EntityPlayer player, + World world, MovingObjectPosition mop, ModPart modPart) + { return modPart.getName(); } - public IPart createPart(ItemStack item, EntityPlayer player, World world, MovingObjectPosition mop, ModPart modPart) { + public IPart createPart(ItemStack item, EntityPlayer player, World world, + MovingObjectPosition mop, ModPart modPart) + { - return PartRegistry.createPart(getCreatedPartType(item, player, world, mop, modPart), world.isRemote); + return PartRegistry.createPart( + getCreatedPartType(item, player, world, mop, modPart), + world.isRemote); } @Override - public String modID() { + public String modID() + { return QLModInfo.MODID; } @Override - public void registerPart() { + public void registerPart() + { PartRegistry.registerFactory(new QModPartFactory()); } @Override - public boolean checkOcclusion(World world, Location location, Vecs3dCube cube) { - return MultipartCompatibility.checkOcclusion(world, location.x, location.y, location.z, new Vec3dCube(cube.toAABB())); + public boolean checkOcclusion(World world, Location location, + Vecs3dCube cube) + { + return MultipartCompatibility.checkOcclusion(world, location.x, + location.y, location.z, new Vec3dCube(cube.toAABB())); } @Override - public boolean hasPart(World world, Location location, String name) { - TileEntity tileEntity = world.getTileEntity(location.getX(), location.getY(), location.getZ()); - if (tileEntity instanceof TileMultipart) { + public boolean hasPart(World world, Location location, String name) + { + TileEntity tileEntity = world.getTileEntity(location.getX(), + location.getY(), location.getZ()); + if (tileEntity instanceof TileMultipart) + { TileMultipart mp = (TileMultipart) tileEntity; boolean ret = false; List t = mp.getParts(); - for (IPart p : t) { - if (ret == false) { - if (p.getType().equals(name)) { + for (IPart p : t) + { + if (ret == false) + { + if (p.getType().equals(name)) + { ret = true; } } diff --git a/src/main/java/techreborn/partSystem/block/BlockModPart.java b/src/main/java/techreborn/partSystem/block/BlockModPart.java index b4f3fa1fd..87e378c7c 100644 --- a/src/main/java/techreborn/partSystem/block/BlockModPart.java +++ b/src/main/java/techreborn/partSystem/block/BlockModPart.java @@ -4,6 +4,9 @@ package techreborn.partSystem.block; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; @@ -21,20 +24,18 @@ import techreborn.partSystem.ICustomHighlight; import techreborn.partSystem.IModPart; import techreborn.partSystem.ModPart; -import java.util.ArrayList; -import java.util.List; - /** * Created by mark on 10/12/14. */ public class BlockModPart extends BlockContainer implements ICustomHighlight { - - public BlockModPart(Material met) { + public BlockModPart(Material met) + { super(met); } - public static TileEntityModPart get(IBlockAccess world, int x, int y, int z) { + public static TileEntityModPart get(IBlockAccess world, int x, int y, int z) + { TileEntity te = world.getTileEntity(x, y, z); if (te == null) @@ -45,13 +46,17 @@ public class BlockModPart extends BlockContainer implements ICustomHighlight { } @Override - public TileEntity createNewTileEntity(World world, int i) { + public TileEntity createNewTileEntity(World world, int i) + { return new TileEntityModPart(); } - @SuppressWarnings({"rawtypes", "unchecked"}) + @SuppressWarnings( + { "rawtypes", "unchecked" }) @Override - public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB bounds, List l, Entity entity) { + public void addCollisionBoxesToList(World world, int x, int y, int z, + AxisAlignedBB bounds, List l, Entity entity) + { TileEntityModPart te = get(world, x, y, z); if (te == null) return; @@ -63,30 +68,36 @@ public class BlockModPart extends BlockContainer implements ICustomHighlight { } @Override - public boolean isOpaqueCube() { + public boolean isOpaqueCube() + { return false; } @Override - public int getRenderType() { + public int getRenderType() + { return -1; } @Override - //TODO move to array list - public ArrayList getBoxes(World world, int x, int y, int z, EntityPlayer player) { + // TODO move to array list + public ArrayList getBoxes(World world, int x, int y, int z, + EntityPlayer player) + { TileEntityModPart te = get(world, x, y, z); if (te == null) return null; List boxes = new ArrayList(); ArrayList list = new ArrayList(); - if (!te.getParts().isEmpty()) { + if (!te.getParts().isEmpty()) + { for (ModPart modPart : te.getParts()) boxes.addAll(modPart.getSelectionBoxes()); - for (int i = 0; i < boxes.size(); i++) { + for (int i = 0; i < boxes.size(); i++) + { Vecs3dCube cube = boxes.get(i); list.add(cube.toAABB()); } @@ -95,27 +106,40 @@ public class BlockModPart extends BlockContainer implements ICustomHighlight { return list; } - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { - for (ModPart part : get(world, x, y, z).getParts()) { + public void onNeighborBlockChange(World world, int x, int y, int z, + Block block) + { + for (ModPart part : get(world, x, y, z).getParts()) + { part.nearByChange(); } } @Override - public MovingObjectPosition collisionRayTrace(World wrd, int x, int y, int z, Vec3 origin, Vec3 direction) { + public MovingObjectPosition collisionRayTrace(World wrd, int x, int y, + int z, Vec3 origin, Vec3 direction) + { ArrayList aabbs = getBoxes(wrd, x, y, z, null); MovingObjectPosition closest = null; - for (AxisAlignedBB aabb : aabbs) { - MovingObjectPosition mop = aabb.getOffsetBoundingBox(x, y, z).calculateIntercept(origin, direction); - if (mop != null) { - if (closest != null && mop.hitVec.distanceTo(origin) < closest.hitVec.distanceTo(origin)) { + for (AxisAlignedBB aabb : aabbs) + { + MovingObjectPosition mop = aabb.getOffsetBoundingBox(x, y, z) + .calculateIntercept(origin, direction); + if (mop != null) + { + if (closest != null + && mop.hitVec.distanceTo(origin) < closest.hitVec + .distanceTo(origin)) + { closest = mop; - } else { + } else + { closest = mop; } } } - if (closest != null) { + if (closest != null) + { closest.blockX = x; closest.blockY = y; closest.blockZ = z; @@ -124,27 +148,36 @@ public class BlockModPart extends BlockContainer implements ICustomHighlight { } @Override - public void onBlockAdded(World world, int x, int y, int z) { - for (ModPart part : get(world, x, y, z).getParts()) { + public void onBlockAdded(World world, int x, int y, int z) + { + for (ModPart part : get(world, x, y, z).getParts()) + { part.onAdded(); } super.onBlockAdded(world, x, y, z); } @Override - public void breakBlock(World world, int x, int y, int z, Block oldid, int oldmeta) { - for (ModPart part : get(world, x, y, z).getParts()) { + public void breakBlock(World world, int x, int y, int z, Block oldid, + int oldmeta) + { + for (ModPart part : get(world, x, y, z).getParts()) + { part.onRemoved(); } super.breakBlock(world, x, y, z, oldid, oldmeta); } @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + public ArrayList getDrops(World world, int x, int y, int z, + int metadata, int fortune) + { ArrayList l = new ArrayList(); TileEntityModPart te = get(world, x, y, z); - if (te != null) { - for (IModPart p : te.getParts()) { + if (te != null) + { + for (IModPart p : te.getParts()) + { ItemStack item = p.getItem(); if (item != null) l.add(item); diff --git a/src/main/java/techreborn/partSystem/block/RenderModPart.java b/src/main/java/techreborn/partSystem/block/RenderModPart.java index 1509049b4..a286ab057 100644 --- a/src/main/java/techreborn/partSystem/block/RenderModPart.java +++ b/src/main/java/techreborn/partSystem/block/RenderModPart.java @@ -4,22 +4,26 @@ package techreborn.partSystem.block; - import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; + import org.lwjgl.opengl.GL11; + import techreborn.lib.vecmath.Vecs3d; import techreborn.partSystem.ModPart; public class RenderModPart extends TileEntitySpecialRenderer { @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float delta) { + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, + double z, float delta) + { TileEntityModPart te = (TileEntityModPart) tileEntity; GL11.glPushMatrix(); GL11.glTranslated(x, y, z); { - for (ModPart modPart : te.getParts()) { + for (ModPart modPart : te.getParts()) + { modPart.renderDynamic(new Vecs3d(0, 0, 0), delta); } } diff --git a/src/main/java/techreborn/partSystem/block/TileEntityModPart.java b/src/main/java/techreborn/partSystem/block/TileEntityModPart.java index a03acc697..90c66fece 100644 --- a/src/main/java/techreborn/partSystem/block/TileEntityModPart.java +++ b/src/main/java/techreborn/partSystem/block/TileEntityModPart.java @@ -4,6 +4,11 @@ package techreborn.partSystem.block; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -19,89 +24,94 @@ import techreborn.partSystem.ModPart; import techreborn.partSystem.ModPartRegistry; import techreborn.partSystem.parts.NullPart; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public class TileEntityModPart extends TileEntity { private Map parts = new HashMap(); - - public void addCollisionBoxesToList(List l, AxisAlignedBB bounds, Entity entity) { + public void addCollisionBoxesToList(List l, + AxisAlignedBB bounds, Entity entity) + { if (getParts().size() == 0) addPart(new NullPart()); List boxes2 = new ArrayList(); - for (ModPart mp : getParts()) { + for (ModPart mp : getParts()) + { List boxes = new ArrayList(); mp.addCollisionBoxesToList(boxes, entity); - for (int i = 0; i < boxes.size(); i++) { + for (int i = 0; i < boxes.size(); i++) + { Vecs3dCube cube = boxes.get(i).clone(); cube.add(getX(), getY(), getZ()); boxes2.add(cube); } } - for (Vecs3dCube c : boxes2) { - //if (c.toAABB().intersectsWith(bounds)) + for (Vecs3dCube c : boxes2) + { + // if (c.toAABB().intersectsWith(bounds)) l.add(c); } } - public List getOcclusionBoxes() { + public List getOcclusionBoxes() + { List boxes = new ArrayList(); - for (ModPart mp : getParts()) { + for (ModPart mp : getParts()) + { boxes.addAll(mp.getOcclusionBoxes()); } return boxes; } - @Override - public AxisAlignedBB getRenderBoundingBox() { + public AxisAlignedBB getRenderBoundingBox() + { - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, + yCoord + 1, zCoord + 1); } - - public World getWorld() { + public World getWorld() + { return getWorldObj(); } - - public int getX() { + public int getX() + { return xCoord; } - - public int getY() { + public int getY() + { return yCoord; } - - public int getZ() { + public int getZ() + { return zCoord; } - @Override - public void updateEntity() { - if (parts.isEmpty()) { + public void updateEntity() + { + if (parts.isEmpty()) + { worldObj.setBlockToAir(xCoord, yCoord, zCoord); } - for (ModPart mp : getParts()) { - if (mp.world != null && mp.location != null) { + for (ModPart mp : getParts()) + { + if (mp.world != null && mp.location != null) + { mp.tick(); } } } - @Override - public void writeToNBT(NBTTagCompound tag) { + public void writeToNBT(NBTTagCompound tag) + { super.writeToNBT(tag); @@ -111,23 +121,29 @@ public class TileEntityModPart extends TileEntity { } @Override - public void readFromNBT(NBTTagCompound tag) { + public void readFromNBT(NBTTagCompound tag) + { super.readFromNBT(tag); NBTTagList l = tag.getTagList("parts", new NBTTagCompound().getId()); - try { + try + { readParts(l); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException e) + { e.printStackTrace(); - } catch (InstantiationException e) { + } catch (InstantiationException e) + { e.printStackTrace(); } } - private void writeParts(NBTTagList l, boolean update) { + private void writeParts(NBTTagList l, boolean update) + { - for (ModPart p : getParts()) { + for (ModPart p : getParts()) + { String id = getIdentifier(p); NBTTagCompound tag = new NBTTagCompound(); @@ -142,16 +158,22 @@ public class TileEntityModPart extends TileEntity { } } - private void readParts(NBTTagList l) throws IllegalAccessException, InstantiationException { + private void readParts(NBTTagList l) throws IllegalAccessException, + InstantiationException + { - for (int i = 0; i < l.tagCount(); i++) { + for (int i = 0; i < l.tagCount(); i++) + { NBTTagCompound tag = l.getCompoundTagAt(i); String id = tag.getString("id"); ModPart p = getPart(id); - if (p == null) { - for (ModPart modPart : ModPartRegistry.parts) { - if (modPart.getName().equals(id)) { + if (p == null) + { + for (ModPart modPart : ModPartRegistry.parts) + { + if (modPart.getName().equals(id)) + { p = modPart.getClass().newInstance(); } } @@ -165,20 +187,25 @@ public class TileEntityModPart extends TileEntity { } } - public void addPart(ModPart modPart) { - try { + public void addPart(ModPart modPart) + { + try + { ModPart newPart = modPart.getClass().newInstance(); newPart.setWorld(getWorldObj()); newPart.setLocation(new Location(xCoord, yCoord, zCoord)); parts.put(newPart.getName(), newPart); - } catch (InstantiationException e) { + } catch (InstantiationException e) + { e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException e) + { e.printStackTrace(); } } - private ModPart getPart(String id) { + private ModPart getPart(String id) + { for (String s : parts.keySet()) if (s.equals(id)) return parts.get(s); @@ -186,7 +213,8 @@ public class TileEntityModPart extends TileEntity { return null; } - private String getIdentifier(ModPart part) { + private String getIdentifier(ModPart part) + { for (String s : parts.keySet()) if (parts.get(s).equals(part)) return s; @@ -194,48 +222,56 @@ public class TileEntityModPart extends TileEntity { return null; } - @Override - public Packet getDescriptionPacket() { + public Packet getDescriptionPacket() + { NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, tag); } @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) + { readFromNBT(pkt.func_148857_g()); } - - public List getParts() { + public List getParts() + { List parts = new ArrayList(); - for (String s : this.parts.keySet()) { + for (String s : this.parts.keySet()) + { ModPart p = this.parts.get(s); parts.add(p); } return parts; } - public List getPartsByName() { + public List getPartsByName() + { List parts = new ArrayList(); - for (String s : this.parts.keySet()) { + for (String s : this.parts.keySet()) + { parts.add(s); } return parts; } - public boolean canAddPart(ModPart modpart) { + public boolean canAddPart(ModPart modpart) + { List cubes = new ArrayList(); modpart.addCollisionBoxesToList(cubes, null); for (Vecs3dCube c : cubes) - if (c != null && !getWorld().checkNoEntityCollision(c.clone().add(getX(), getY(), getZ()).toAABB())) + if (c != null + && !getWorld().checkNoEntityCollision( + c.clone().add(getX(), getY(), getZ()).toAABB())) return false; List l = getOcclusionBoxes(); for (Vecs3dCube b : modpart.getOcclusionBoxes()) for (Vecs3dCube c : l) - if (c != null && b != null && b.toAABB().intersectsWith(c.toAABB())) + if (c != null && b != null + && b.toAABB().intersectsWith(c.toAABB())) return false; return true; } diff --git a/src/main/java/techreborn/partSystem/block/WorldProvider.java b/src/main/java/techreborn/partSystem/block/WorldProvider.java index 3fc4970a1..081ba5591 100644 --- a/src/main/java/techreborn/partSystem/block/WorldProvider.java +++ b/src/main/java/techreborn/partSystem/block/WorldProvider.java @@ -4,12 +4,6 @@ package techreborn.partSystem.block; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.common.registry.GameRegistry; -import techreborn.lib.Location; -import techreborn.lib.vecmath.Vecs3dCube; -import techreborn.partSystem.IPartProvider; -import techreborn.partSystem.ModPart; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; @@ -18,6 +12,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import techreborn.lib.Location; +import techreborn.lib.vecmath.Vecs3dCube; +import techreborn.partSystem.IPartProvider; +import techreborn.partSystem.ModPart; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.registry.GameRegistry; /** * Created by mark on 10/12/14. @@ -26,36 +26,49 @@ public class WorldProvider implements IPartProvider { Block blockModPart; @Override - public String modID() { + public String modID() + { return "Minecraft"; } @Override - public void registerPart() { -//Loads all of the items + public void registerPart() + { + // Loads all of the items - blockModPart = new BlockModPart(Material.ground).setBlockName("modPartBlock"); + blockModPart = new BlockModPart(Material.ground) + .setBlockName("modPartBlock"); GameRegistry.registerBlock(blockModPart, "modPartBlock"); - //registers the tile and renderer - GameRegistry.registerTileEntity(TileEntityModPart.class, "TileEntityModPart"); + // registers the tile and renderer + GameRegistry.registerTileEntity(TileEntityModPart.class, + "TileEntityModPart"); } - public void clientRegister() { - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityModPart.class, new RenderModPart()); + public void clientRegister() + { + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityModPart.class, + new RenderModPart()); } @Override - public boolean checkOcclusion(World world, Location location, Vecs3dCube cube) { + public boolean checkOcclusion(World world, Location location, + Vecs3dCube cube) + { return true; } @Override - public boolean hasPart(World world, Location location, String name) { - TileEntity tileEntity = world.getTileEntity(location.getX(), location.getY(), location.getZ()); - if (tileEntity instanceof TileEntityModPart) { - for (ModPart part : ((TileEntityModPart) tileEntity).getParts()) { - if (part.getName().equals(name)) { + public boolean hasPart(World world, Location location, String name) + { + TileEntity tileEntity = world.getTileEntity(location.getX(), + location.getY(), location.getZ()); + if (tileEntity instanceof TileEntityModPart) + { + for (ModPart part : ((TileEntityModPart) tileEntity).getParts()) + { + if (part.getName().equals(name)) + { return true; } } @@ -64,27 +77,47 @@ public class WorldProvider implements IPartProvider { } @Override - public boolean placePart(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, ModPart modPart) { + public boolean placePart(ItemStack item, EntityPlayer player, World world, + int x, int y, int z, int side, float hitX, float hitY, float hitZ, + ModPart modPart) + { ForgeDirection forgeDirection = ForgeDirection.getOrientation(side); - if (world.getBlock(x + forgeDirection.offsetX, y + forgeDirection.offsetY, z + forgeDirection.offsetZ) == Blocks.air) { + if (world.getBlock(x + forgeDirection.offsetX, y + + forgeDirection.offsetY, z + forgeDirection.offsetZ) == Blocks.air) + { TileEntityModPart modPart1; - world.setBlock(x + forgeDirection.offsetX, y + forgeDirection.offsetY, z + forgeDirection.offsetZ, blockModPart); - modPart1 = (TileEntityModPart) world.getTileEntity(x + forgeDirection.offsetX, y + forgeDirection.offsetY, z + forgeDirection.offsetZ); - //if(modPart1.canAddPart(modPart)){ - modPart1.addPart(modPart); - return true; - //} + world.setBlock(x + forgeDirection.offsetX, y + + forgeDirection.offsetY, z + forgeDirection.offsetZ, + blockModPart); + modPart1 = (TileEntityModPart) world.getTileEntity(x + + forgeDirection.offsetX, y + forgeDirection.offsetY, z + + forgeDirection.offsetZ); + // if(modPart1.canAddPart(modPart)){ + modPart1.addPart(modPart); + return true; + // } } - //this adds a part to a block - if (world.getBlock(x, y, z) == blockModPart) { - TileEntityModPart tileEntityModPart = (TileEntityModPart) world.getTileEntity(x + forgeDirection.offsetX, y + forgeDirection.offsetY, z + forgeDirection.offsetZ); - if (!tileEntityModPart.getPartsByName().contains(modPart.getName()) && tileEntityModPart.canAddPart(modPart)) + // this adds a part to a block + if (world.getBlock(x, y, z) == blockModPart) + { + TileEntityModPart tileEntityModPart = (TileEntityModPart) world + .getTileEntity(x + forgeDirection.offsetX, y + + forgeDirection.offsetY, z + + forgeDirection.offsetZ); + if (!tileEntityModPart.getPartsByName().contains(modPart.getName()) + && tileEntityModPart.canAddPart(modPart)) tileEntityModPart.addPart(modPart); return true; } - if (world.getBlock(x + forgeDirection.offsetX, y + forgeDirection.offsetY, z + forgeDirection.offsetZ) == blockModPart) { - TileEntityModPart tileEntityModPart = (TileEntityModPart) world.getTileEntity(x + forgeDirection.offsetX, y + forgeDirection.offsetY, z + forgeDirection.offsetZ); - if (!tileEntityModPart.getPartsByName().contains(modPart.getName()) && tileEntityModPart.canAddPart(modPart)) + if (world.getBlock(x + forgeDirection.offsetX, y + + forgeDirection.offsetY, z + forgeDirection.offsetZ) == blockModPart) + { + TileEntityModPart tileEntityModPart = (TileEntityModPart) world + .getTileEntity(x + forgeDirection.offsetX, y + + forgeDirection.offsetY, z + + forgeDirection.offsetZ); + if (!tileEntityModPart.getPartsByName().contains(modPart.getName()) + && tileEntityModPart.canAddPart(modPart)) tileEntityModPart.addPart(modPart); return true; } @@ -92,7 +125,8 @@ public class WorldProvider implements IPartProvider { } @Override - public boolean isTileFromProvider(TileEntity tileEntity) { + public boolean isTileFromProvider(TileEntity tileEntity) + { return tileEntity instanceof TileEntityModPart; } } diff --git a/src/main/java/techreborn/partSystem/client/PartPlacementRenderer.java b/src/main/java/techreborn/partSystem/client/PartPlacementRenderer.java index 8ef849b70..8cc316d86 100644 --- a/src/main/java/techreborn/partSystem/client/PartPlacementRenderer.java +++ b/src/main/java/techreborn/partSystem/client/PartPlacementRenderer.java @@ -1,8 +1,5 @@ package techreborn.partSystem.client; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.Tessellator; @@ -13,14 +10,21 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.util.ForgeDirection; + import org.lwjgl.opengl.GL11; + import techreborn.lib.Location; import techreborn.lib.vecmath.Vecs3d; import techreborn.partSystem.IModPart; import techreborn.partSystem.ModPartItem; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** - * This is based of https://github.com/Qmunity/QmunityLib/blob/master/src%2Fmain%2Fjava%2Fuk%2Fco%2Fqmunity%2Flib%2Fclient%2Frender%2FRenderPartPlacement.java + * This is based of + * https://github.com/Qmunity/QmunityLib/blob/master/src%2Fmain% + * 2Fjava%2Fuk%2Fco%2Fqmunity%2Flib%2Fclient%2Frender%2FRenderPartPlacement.java *

* You should go check them out! */ @@ -31,24 +35,30 @@ public class PartPlacementRenderer { private int width = 0, height = 0; @SubscribeEvent - public void onRenderTick(RenderWorldLastEvent event) { + public void onRenderTick(RenderWorldLastEvent event) + { EntityPlayer player = Minecraft.getMinecraft().thePlayer; ItemStack item = player.getCurrentEquippedItem(); if (item == null) return; if (!(item.getItem() instanceof ModPartItem)) return; - if (Minecraft.getMinecraft().gameSettings.hideGUI && Minecraft.getMinecraft().currentScreen == null) + if (Minecraft.getMinecraft().gameSettings.hideGUI + && Minecraft.getMinecraft().currentScreen == null) return; - MovingObjectPosition mop = player.rayTrace(player.capabilities.isCreativeMode ? 5 : 4, 0); - if (mop == null || mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) + MovingObjectPosition mop = player.rayTrace( + player.capabilities.isCreativeMode ? 5 : 4, 0); + if (mop == null + || mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return; IModPart part = ((ModPartItem) item.getItem()).getModPart(); if (part == null) return; ForgeDirection faceHit = ForgeDirection.getOrientation(mop.sideHit); Location location = new Location(mop.blockX, mop.blockY, mop.blockZ); - if (fb == null || width != Minecraft.getMinecraft().displayWidth || height != Minecraft.getMinecraft().displayHeight) { + if (fb == null || width != Minecraft.getMinecraft().displayWidth + || height != Minecraft.getMinecraft().displayHeight) + { width = Minecraft.getMinecraft().displayWidth; height = Minecraft.getMinecraft().displayHeight; fb = new Framebuffer(width, height, true); @@ -61,24 +71,30 @@ public class PartPlacementRenderer { { GL11.glLoadIdentity(); fb.bindFramebuffer(true); - GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); + GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT + | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glClearColor(0, 0, 0, 0); - net.minecraft.client.renderer.RenderHelper.enableStandardItemLighting(); + net.minecraft.client.renderer.RenderHelper + .enableStandardItemLighting(); GL11.glPushMatrix(); { Vec3 playerPos = player.getPosition(event.partialTicks); - double x = location.getX() - playerPos.xCoord + faceHit.offsetX; - double y = location.getY() - playerPos.yCoord + faceHit.offsetY; - double z = location.getZ() - playerPos.zCoord + faceHit.offsetZ; + double x = location.getX() - playerPos.xCoord + + faceHit.offsetX; + double y = location.getY() - playerPos.yCoord + + faceHit.offsetY; + double z = location.getZ() - playerPos.zCoord + + faceHit.offsetZ; GL11.glRotated(player.rotationPitch, 1, 0, 0); GL11.glRotated(player.rotationYaw - 180, 0, 1, 0); GL11.glTranslated(x, y, z); part.renderDynamic(new Vecs3d(0, 0, 0), event.partialTicks); } GL11.glPopMatrix(); - net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + net.minecraft.client.renderer.RenderHelper + .disableStandardItemLighting(); fb.unbindFramebuffer(); } GL11.glPopMatrix(); @@ -86,11 +102,14 @@ public class PartPlacementRenderer { GL11.glPushMatrix(); { Minecraft mc = Minecraft.getMinecraft(); - ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + ScaledResolution scaledresolution = new ScaledResolution(mc, + mc.displayWidth, mc.displayHeight); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); - GL11.glOrtho(0, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0, 0.1, 10000D); + GL11.glOrtho(0, scaledresolution.getScaledWidth_double(), + scaledresolution.getScaledHeight_double(), 0, 0.1, + 10000D); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glTranslatef(0.0F, 0.0F, -2000.0F); @@ -98,7 +117,8 @@ public class PartPlacementRenderer { { GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, + GL11.GL_ONE_MINUS_SRC_ALPHA); Tessellator tessellator = Tessellator.instance; int w = scaledresolution.getScaledWidth(); int h = scaledresolution.getScaledHeight(); diff --git a/src/main/java/techreborn/partSystem/fmp/FMPFactory.java b/src/main/java/techreborn/partSystem/fmp/FMPFactory.java index 2662b023f..0714280a6 100644 --- a/src/main/java/techreborn/partSystem/fmp/FMPFactory.java +++ b/src/main/java/techreborn/partSystem/fmp/FMPFactory.java @@ -4,38 +4,44 @@ package techreborn.partSystem.fmp; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import techreborn.lib.Location; +import techreborn.lib.vecmath.Vecs3dCube; +import techreborn.partSystem.IPartProvider; +import techreborn.partSystem.ModPart; +import techreborn.partSystem.ModPartRegistry; import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.Cuboid6; import codechicken.multipart.MultiPartRegistry; import codechicken.multipart.NormallyOccludedPart; import codechicken.multipart.TMultiPart; import codechicken.multipart.TileMultipart; -import techreborn.lib.Location; -import techreborn.lib.vecmath.Vecs3dCube; -import techreborn.partSystem.IPartProvider; -import techreborn.partSystem.ModPart; -import techreborn.partSystem.ModPartRegistry; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import java.util.List; - /** * Created by mark on 09/12/14. */ -public class FMPFactory implements MultiPartRegistry.IPartFactory, IPartProvider { +public class FMPFactory implements MultiPartRegistry.IPartFactory, + IPartProvider { @Override - public TMultiPart createPart(String type, boolean client) { - for (ModPart modPart : ModPartRegistry.parts) { - if (modPart.getName().equals(type)) { - try { + public TMultiPart createPart(String type, boolean client) + { + for (ModPart modPart : ModPartRegistry.parts) + { + if (modPart.getName().equals(type)) + { + try + { return new FMPModPart(modPart.getClass().newInstance()); - } catch (InstantiationException e) { + } catch (InstantiationException e) + { e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (IllegalAccessException e) + { e.printStackTrace(); } } @@ -43,45 +49,65 @@ public class FMPFactory implements MultiPartRegistry.IPartFactory, IPartProvider return null; } - public boolean placePart(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, ModPart modPart) { - return new FakeFMPPlacerItem(modPart).onItemUse(item, player, world, x, y, z, side, hitX, hitY, hitZ); + public boolean placePart(ItemStack item, EntityPlayer player, World world, + int x, int y, int z, int side, float hitX, float hitY, float hitZ, + ModPart modPart) + { + return new FakeFMPPlacerItem(modPart).onItemUse(item, player, world, x, + y, z, side, hitX, hitY, hitZ); } @Override - public boolean isTileFromProvider(TileEntity tileEntity) { + public boolean isTileFromProvider(TileEntity tileEntity) + { return tileEntity instanceof TileMultipart; } @Override - public String modID() { + public String modID() + { return "ForgeMultipart"; } @Override - public void registerPart() { - for (ModPart modPart : ModPartRegistry.parts) { - MultiPartRegistry.registerParts(new FMPFactory(), new String[]{modPart.getName()}); + public void registerPart() + { + for (ModPart modPart : ModPartRegistry.parts) + { + MultiPartRegistry.registerParts(new FMPFactory(), new String[] + { modPart.getName() }); } } @Override - public boolean checkOcclusion(World world, Location location, Vecs3dCube cube) { - codechicken.multipart.TileMultipart tmp = codechicken.multipart.TileMultipart.getOrConvertTile(world, new BlockCoord(location.getX(), location.getY(), location.getZ())); + public boolean checkOcclusion(World world, Location location, + Vecs3dCube cube) + { + codechicken.multipart.TileMultipart tmp = codechicken.multipart.TileMultipart + .getOrConvertTile(world, new BlockCoord(location.getX(), + location.getY(), location.getZ())); if (tmp == null) return false; - return !tmp.occlusionTest(tmp.partList(), new NormallyOccludedPart(new Cuboid6(cube.toAABB()))); + return !tmp.occlusionTest(tmp.partList(), new NormallyOccludedPart( + new Cuboid6(cube.toAABB()))); } @Override - public boolean hasPart(World world, Location location, String name) { - TileEntity tileEntity = world.getTileEntity(location.getX(), location.getY(), location.getZ()); - if (tileEntity instanceof TileMultipart) { + public boolean hasPart(World world, Location location, String name) + { + TileEntity tileEntity = world.getTileEntity(location.getX(), + location.getY(), location.getZ()); + if (tileEntity instanceof TileMultipart) + { TileMultipart mp = (TileMultipart) tileEntity; boolean ret = false; List t = mp.jPartList(); - for (TMultiPart p : t) { - if (ret == false) { - if (p.getType().equals(name)) { + for (TMultiPart p : t) + { + if (ret == false) + { + if (p.getType().equals(name)) + { ret = true; } } diff --git a/src/main/java/techreborn/partSystem/fmp/FMPModPart.java b/src/main/java/techreborn/partSystem/fmp/FMPModPart.java index 7d6a47bfc..7095c8556 100644 --- a/src/main/java/techreborn/partSystem/fmp/FMPModPart.java +++ b/src/main/java/techreborn/partSystem/fmp/FMPModPart.java @@ -4,7 +4,17 @@ package techreborn.partSystem.fmp; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.entity.Entity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import techreborn.lib.Location; +import techreborn.lib.vecmath.Vecs3d; +import techreborn.lib.vecmath.Vecs3dCube; +import techreborn.partSystem.ModPart; import codechicken.lib.raytracer.IndexedCuboid6; import codechicken.lib.vec.Cuboid6; import codechicken.lib.vec.Vector3; @@ -15,35 +25,27 @@ import codechicken.multipart.TMultiPart; import codechicken.multipart.TSlottedPart; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.Entity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; -import techreborn.lib.Location; -import techreborn.lib.vecmath.Vecs3d; -import techreborn.lib.vecmath.Vecs3dCube; -import techreborn.partSystem.ModPart; -import java.util.ArrayList; -import java.util.List; - -public class FMPModPart extends TMultiPart implements TSlottedPart, JNormalOcclusion, ISidedHollowConnect { +public class FMPModPart extends TMultiPart implements TSlottedPart, + JNormalOcclusion, ISidedHollowConnect { ModPart iModPart; - public FMPModPart(ModPart iModPart) { + public FMPModPart(ModPart iModPart) + { this.iModPart = iModPart; } @Override - public int getHollowSize(int i) { + public int getHollowSize(int i) + { return 0; } @Override - public Iterable getOcclusionBoxes() { + public Iterable getOcclusionBoxes() + { List cubes = new ArrayList(); for (Vecs3dCube c : iModPart.getOcclusionBoxes()) cubes.add(new Cuboid6(c.toAABB())); @@ -51,45 +53,53 @@ public class FMPModPart extends TMultiPart implements TSlottedPart, JNormalOcclu } @Override - public boolean occlusionTest(TMultiPart npart) { + public boolean occlusionTest(TMultiPart npart) + { return NormalOcclusionTest.apply(this, npart); } - public void addCollisionBoxesToList(List l, AxisAlignedBB bounds, Entity entity) { + public void addCollisionBoxesToList(List l, + AxisAlignedBB bounds, Entity entity) + { List boxes = new ArrayList(); List boxes_ = new ArrayList(); iModPart.addCollisionBoxesToList(boxes_, entity); - for (Vecs3dCube c : boxes_) { + for (Vecs3dCube c : boxes_) + { Vecs3dCube cube = c.clone(); cube.add(getX(), getY(), getZ()); boxes.add(cube); } boxes_.clear(); - for (Vecs3dCube c : boxes) { + for (Vecs3dCube c : boxes) + { if (c.toAABB().intersectsWith(bounds)) l.add(c); } } @Override - public Iterable getCollisionBoxes() { + public Iterable getCollisionBoxes() + { List cubes = new ArrayList(); List boxes = new ArrayList(); iModPart.addCollisionBoxesToList(boxes, null); - for (Vecs3dCube c : boxes) { + for (Vecs3dCube c : boxes) + { if (c != null) cubes.add(new Cuboid6(c.toAABB())); } - return cubes; } @Override - public Iterable getSubParts() { + public Iterable getSubParts() + { List cubes = new ArrayList(); - if (iModPart.getSelectionBoxes() != null) { + if (iModPart.getSelectionBoxes() != null) + { for (Vecs3dCube c : iModPart.getSelectionBoxes()) if (c != null) cubes.add(new IndexedCuboid6(0, new Cuboid6(c.toAABB()))); @@ -103,45 +113,52 @@ public class FMPModPart extends TMultiPart implements TSlottedPart, JNormalOcclu @Override @SideOnly(Side.CLIENT) - public void renderDynamic(Vector3 pos, float frame, int pass) { + public void renderDynamic(Vector3 pos, float frame, int pass) + { iModPart.renderDynamic(new Vecs3d(pos.x, pos.y, pos.z), frame); } @Override - public String getType() { + public String getType() + { return iModPart.getName(); } @Override - public int getSlotMask() { + public int getSlotMask() + { return 0; } - public World getWorld() { + public World getWorld() + { return world(); } - - public int getX() { - if (iModPart.world == null || iModPart.location == null) { + public int getX() + { + if (iModPart.world == null || iModPart.location == null) + { iModPart.setWorld(world()); iModPart.setLocation(new Location(x(), y(), z())); } return x(); } - - public int getY() { - if (iModPart.world == null || iModPart.location == null) { + public int getY() + { + if (iModPart.world == null || iModPart.location == null) + { iModPart.setWorld(world()); iModPart.setLocation(new Location(x(), y(), z())); } return y(); } - - public int getZ() { - if (iModPart.world == null || iModPart.location == null) { + public int getZ() + { + if (iModPart.world == null || iModPart.location == null) + { iModPart.setWorld(world()); iModPart.setLocation(new Location(x(), y(), z())); } @@ -149,7 +166,8 @@ public class FMPModPart extends TMultiPart implements TSlottedPart, JNormalOcclu } @Override - public void onAdded() { + public void onAdded() + { iModPart.setWorld(world()); iModPart.setLocation(new Location(x(), y(), z())); iModPart.nearByChange(); @@ -157,34 +175,40 @@ public class FMPModPart extends TMultiPart implements TSlottedPart, JNormalOcclu } @Override - public void update() { - if(iModPart.location != null){ + public void update() + { + if (iModPart.location != null) + { iModPart.tick(); } } @Override - public void onNeighborChanged() { + public void onNeighborChanged() + { super.onNeighborChanged(); - if (iModPart.world == null || iModPart.location == null) { + if (iModPart.world == null || iModPart.location == null) + { iModPart.setWorld(world()); iModPart.setLocation(new Location(x(), y(), z())); } iModPart.nearByChange(); } - - public void onRemoved() { + public void onRemoved() + { iModPart.onRemoved(); super.onRemoved(); } @Override - public boolean renderStatic(Vector3 pos, int pass) { + public boolean renderStatic(Vector3 pos, int pass) + { boolean render = false; RenderBlocks renderer = RenderBlocks.getInstance(); renderer.blockAccess = getWorld(); - render = iModPart.renderStatic(new Vecs3d(pos.x, pos.y, pos.z), renderer, pass); + render = iModPart.renderStatic(new Vecs3d(pos.x, pos.y, pos.z), + renderer, pass); return render; } } diff --git a/src/main/java/techreborn/partSystem/fmp/FakeFMPPlacerItem.java b/src/main/java/techreborn/partSystem/fmp/FakeFMPPlacerItem.java index fd9a403bf..55e4b9287 100644 --- a/src/main/java/techreborn/partSystem/fmp/FakeFMPPlacerItem.java +++ b/src/main/java/techreborn/partSystem/fmp/FakeFMPPlacerItem.java @@ -4,28 +4,32 @@ package techreborn.partSystem.fmp; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import techreborn.partSystem.ModPart; import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.Vector3; import codechicken.multipart.JItemMultiPart; import codechicken.multipart.MultiPartRegistry; import codechicken.multipart.TMultiPart; -import techreborn.partSystem.ModPart; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; /** - * This item is never added into the game, it is only used to add the part to the world. + * This item is never added into the game, it is only used to add the part to + * the world. */ public class FakeFMPPlacerItem extends JItemMultiPart { ModPart modPart; - public FakeFMPPlacerItem(ModPart part) { + public FakeFMPPlacerItem(ModPart part) + { modPart = part; } @Override - public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 vhit) { + public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, + BlockCoord pos, int side, Vector3 vhit) + { TMultiPart w = MultiPartRegistry.createPart(modPart.getName(), false); return w; } diff --git a/src/main/java/techreborn/partSystem/parts/CablePart.java b/src/main/java/techreborn/partSystem/parts/CablePart.java index 7657c0041..f4681e964 100644 --- a/src/main/java/techreborn/partSystem/parts/CablePart.java +++ b/src/main/java/techreborn/partSystem/parts/CablePart.java @@ -5,6 +5,12 @@ import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergyConductor; import ic2.api.energy.tile.IEnergyTile; import ic2.core.IC2; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; @@ -19,12 +25,6 @@ import techreborn.lib.vecmath.Vecs3dCube; import techreborn.partSystem.ModPart; import techreborn.partSystem.ModPartUtils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - public class CablePart extends ModPart implements IEnergyConductor { public static Vecs3dCube[] boundingBoxes = new Vecs3dCube[14]; public static float center = 0.6F; @@ -35,39 +35,55 @@ public class CablePart extends ModPart implements IEnergyConductor { private boolean[] connections = new boolean[6]; public boolean addedToEnergyNet = false; - public static void - refreshBounding() { + public static void refreshBounding() + { float centerFirst = center - offset; double w = 0.2D / 2; - boundingBoxes[6] = new Vecs3dCube(centerFirst - w - 0.03, centerFirst - w - 0.08, centerFirst - w - 0.03, centerFirst + w + 0.08, centerFirst + w + 0.04, centerFirst + w + 0.08); + boundingBoxes[6] = new Vecs3dCube(centerFirst - w - 0.03, centerFirst + - w - 0.08, centerFirst - w - 0.03, centerFirst + w + 0.08, + centerFirst + w + 0.04, centerFirst + w + 0.08); - boundingBoxes[6] = new Vecs3dCube(centerFirst - w, centerFirst - w, centerFirst - w, centerFirst + w, centerFirst + w, centerFirst + w); + boundingBoxes[6] = new Vecs3dCube(centerFirst - w, centerFirst - w, + centerFirst - w, centerFirst + w, centerFirst + w, centerFirst + + w); int i = 0; - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - double xMin1 = (dir.offsetX < 0 ? 0.0 : (dir.offsetX == 0 ? centerFirst - w : centerFirst + w)); - double xMax1 = (dir.offsetX > 0 ? 1.0 : (dir.offsetX == 0 ? centerFirst + w : centerFirst - w)); + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { + double xMin1 = (dir.offsetX < 0 ? 0.0 + : (dir.offsetX == 0 ? centerFirst - w : centerFirst + w)); + double xMax1 = (dir.offsetX > 0 ? 1.0 + : (dir.offsetX == 0 ? centerFirst + w : centerFirst - w)); - double yMin1 = (dir.offsetY < 0 ? 0.0 : (dir.offsetY == 0 ? centerFirst - w : centerFirst + w)); - double yMax1 = (dir.offsetY > 0 ? 1.0 : (dir.offsetY == 0 ? centerFirst + w : centerFirst - w)); + double yMin1 = (dir.offsetY < 0 ? 0.0 + : (dir.offsetY == 0 ? centerFirst - w : centerFirst + w)); + double yMax1 = (dir.offsetY > 0 ? 1.0 + : (dir.offsetY == 0 ? centerFirst + w : centerFirst - w)); - double zMin1 = (dir.offsetZ < 0 ? 0.0 : (dir.offsetZ == 0 ? centerFirst - w : centerFirst + w)); - double zMax1 = (dir.offsetZ > 0 ? 1.0 : (dir.offsetZ == 0 ? centerFirst + w : centerFirst - w)); + double zMin1 = (dir.offsetZ < 0 ? 0.0 + : (dir.offsetZ == 0 ? centerFirst - w : centerFirst + w)); + double zMax1 = (dir.offsetZ > 0 ? 1.0 + : (dir.offsetZ == 0 ? centerFirst + w : centerFirst - w)); - boundingBoxes[i] = new Vecs3dCube(xMin1, yMin1, zMin1, xMax1, yMax1, zMax1); + boundingBoxes[i] = new Vecs3dCube(xMin1, yMin1, zMin1, xMax1, + yMax1, zMax1); i++; } } @Override - public void addCollisionBoxesToList(List boxes, Entity entity) { - if (world != null || location != null) { + public void addCollisionBoxesToList(List boxes, Entity entity) + { + if (world != null || location != null) + { checkConnectedSides(); - } else { + } else + { connectedSides = new HashMap(); } - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { if (connectedSides.containsKey(dir)) boxes.add(boundingBoxes[Functions.getIntDirFromDirection(dir)]); } @@ -75,72 +91,88 @@ public class CablePart extends ModPart implements IEnergyConductor { } @Override - public List getSelectionBoxes() { + public List getSelectionBoxes() + { List vec3dCubeList = new ArrayList(); checkConnectedSides(); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { if (connectedSides.containsKey(dir)) - vec3dCubeList.add(boundingBoxes[Functions.getIntDirFromDirection(dir)]); + vec3dCubeList.add(boundingBoxes[Functions + .getIntDirFromDirection(dir)]); } vec3dCubeList.add(boundingBoxes[6]); return vec3dCubeList; } @Override - public List getOcclusionBoxes() { + public List getOcclusionBoxes() + { checkConnectedSides(); List vecs3dCubesList = new ArrayList(); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { if (connectedSides.containsKey(dir)) - vecs3dCubesList.add(boundingBoxes[Functions.getIntDirFromDirection(dir)]); + vecs3dCubesList.add(boundingBoxes[Functions + .getIntDirFromDirection(dir)]); } return vecs3dCubesList; } @Override - public void renderDynamic(Vecs3d translation, double delta) { + public void renderDynamic(Vecs3d translation, double delta) + { } - @Override - public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, int pass) { + public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, + int pass) + { return false; } @Override - public void writeToNBT(NBTTagCompound tag) { + public void writeToNBT(NBTTagCompound tag) + { } @Override - public void readFromNBT(NBTTagCompound tag) { + public void readFromNBT(NBTTagCompound tag) + { } @Override - public String getName() { + public String getName() + { return "Cable"; } @Override - public String getItemTextureName() { + public String getItemTextureName() + { return "network:networkCable"; } @Override - public void tick() { - if (ticks == 0) { + public void tick() + { + if (ticks == 0) + { checkConnectedSides(); ticks += 1; - } else if (ticks == 40) { + } else if (ticks == 40) + { ticks = 0; - } else { + } else + { ticks += 1; } - - if(IC2.platform.isSimulating()) { + if (IC2.platform.isSimulating()) + { MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); this.addedToEnergyNet = true; checkConnectedSides(); @@ -149,106 +181,135 @@ public class CablePart extends ModPart implements IEnergyConductor { } @Override - public void nearByChange() { + public void nearByChange() + { checkConnectedSides(); } @Override - public void onAdded() { + public void onAdded() + { checkConnections(world, getX(), getY(), getZ()); } @Override - public void onRemoved() { - if(IC2.platform.isSimulating() && this.addedToEnergyNet) { + public void onRemoved() + { + if (IC2.platform.isSimulating() && this.addedToEnergyNet) + { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); this.addedToEnergyNet = false; } } @Override - public ItemStack getItem() { + public ItemStack getItem() + { return new ItemStack(ModPartUtils.getItemForPart(getName())); } - public boolean shouldConnectTo(TileEntity entity, ForgeDirection dir) { - if (entity == null) { + public boolean shouldConnectTo(TileEntity entity, ForgeDirection dir) + { + if (entity == null) + { return false; - } else if (entity instanceof IEnergyTile) { + } else if (entity instanceof IEnergyTile) + { return true; - } else { - return ModPartUtils.hasPart(entity.getWorldObj(), entity.xCoord, entity.yCoord, entity.zCoord, this.getName()); + } else + { + return ModPartUtils.hasPart(entity.getWorldObj(), entity.xCoord, + entity.yCoord, entity.zCoord, this.getName()); } } - public void checkConnectedSides() { + public void checkConnectedSides() + { refreshBounding(); connectedSides = new HashMap(); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) + { int d = Functions.getIntDirFromDirection(dir); - if (world == null) { + if (world == null) + { return; } - TileEntity te = world.getTileEntity(getX() + dir.offsetX, getY() + dir.offsetY, getZ() + dir.offsetZ); - if (shouldConnectTo(te, dir)) { -//TODO if (ModPartUtils.checkOcclusion(getWorld(), getX(), getY(), getZ(), boundingBoxes[d])) { - connectedSides.put(dir, te); -// } + TileEntity te = world.getTileEntity(getX() + dir.offsetX, getY() + + dir.offsetY, getZ() + dir.offsetZ); + if (shouldConnectTo(te, dir)) + { + // TODO if (ModPartUtils.checkOcclusion(getWorld(), getX(), + // getY(), getZ(), boundingBoxes[d])) { + connectedSides.put(dir, te); + // } } } checkConnections(world, getX(), getY(), getZ()); getWorld().markBlockForUpdate(getX(), getY(), getZ()); } - public void checkConnections(World world, int x, int y, int z) { - for (int i = 0; i < 6; i++) { + public void checkConnections(World world, int x, int y, int z) + { + for (int i = 0; i < 6; i++) + { ForgeDirection dir = dirs[i]; int dx = x + dir.offsetX; int dy = y + dir.offsetY; int dz = z + dir.offsetZ; - connections[i] = shouldConnectTo(world.getTileEntity(dx, dy, dz), dir); + connections[i] = shouldConnectTo(world.getTileEntity(dx, dy, dz), + dir); world.func_147479_m(dx, dy, dz); } world.func_147479_m(x, y, z); } @Override - public double getConductionLoss() { + public double getConductionLoss() + { return 0D; } @Override - public double getInsulationEnergyAbsorption() { + public double getInsulationEnergyAbsorption() + { return 256; } @Override - public double getInsulationBreakdownEnergy() { + public double getInsulationBreakdownEnergy() + { return 2048; } @Override - public double getConductorBreakdownEnergy() { + public double getConductorBreakdownEnergy() + { return 2048; } @Override - public void removeInsulation() { + public void removeInsulation() + { } @Override - public void removeConductor() { + public void removeConductor() + { } @Override - public boolean acceptsEnergyFrom(TileEntity tileEntity, ForgeDirection forgeDirection) { + public boolean acceptsEnergyFrom(TileEntity tileEntity, + ForgeDirection forgeDirection) + { return true; } @Override - public boolean emitsEnergyTo(TileEntity tileEntity, ForgeDirection forgeDirection) { + public boolean emitsEnergyTo(TileEntity tileEntity, + ForgeDirection forgeDirection) + { return true; } } \ No newline at end of file diff --git a/src/main/java/techreborn/partSystem/parts/NullPart.java b/src/main/java/techreborn/partSystem/parts/NullPart.java index 7a7377e29..31a031955 100644 --- a/src/main/java/techreborn/partSystem/parts/NullPart.java +++ b/src/main/java/techreborn/partSystem/parts/NullPart.java @@ -4,6 +4,9 @@ package techreborn.partSystem.parts; +import java.util.ArrayList; +import java.util.List; + import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; @@ -12,82 +15,94 @@ import techreborn.lib.vecmath.Vecs3d; import techreborn.lib.vecmath.Vecs3dCube; import techreborn.partSystem.ModPart; -import java.util.ArrayList; -import java.util.List; - /** * Created by mark on 11/12/14. */ public class NullPart extends ModPart { @Override - public void addCollisionBoxesToList(List boxes, Entity entity) { + public void addCollisionBoxesToList(List boxes, Entity entity) + { boxes.add(new Vecs3dCube(0, 0, 0, 1, 1, 1)); } @Override - public List getSelectionBoxes() { + public List getSelectionBoxes() + { List cubes = new ArrayList(); cubes.add(new Vecs3dCube(0, 0, 0, 1, 1, 1)); return cubes; } @Override - public List getOcclusionBoxes() { + public List getOcclusionBoxes() + { return null; } @Override - public void renderDynamic(Vecs3d translation, double delta) { + public void renderDynamic(Vecs3d translation, double delta) + { } @Override - public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, int pass) { + public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, + int pass) + { return false; } @Override - public void writeToNBT(NBTTagCompound tag) { + public void writeToNBT(NBTTagCompound tag) + { } @Override - public void readFromNBT(NBTTagCompound tag) { + public void readFromNBT(NBTTagCompound tag) + { } @Override - public ItemStack getItem() { + public ItemStack getItem() + { return null; } @Override - public String getName() { + public String getName() + { return "NullPart"; } @Override - public String getItemTextureName() { + public String getItemTextureName() + { return ""; } @Override - public void tick() { + public void tick() + { } @Override - public void nearByChange() { + public void nearByChange() + { } @Override - public void onAdded() { + public void onAdded() + { } @Override - public void onRemoved() { + public void onRemoved() + { } } diff --git a/src/main/java/techreborn/pda/GuiButtonCustomTexture.java b/src/main/java/techreborn/pda/GuiButtonCustomTexture.java index 5d0e3c010..ebafeb128 100644 --- a/src/main/java/techreborn/pda/GuiButtonCustomTexture.java +++ b/src/main/java/techreborn/pda/GuiButtonCustomTexture.java @@ -12,9 +12,9 @@ public class GuiButtonCustomTexture extends GuiButtonExt { public int textureU; public int textureV; public ResourceLocation texture; - - public GuiButtonCustomTexture(int id, int xPos, int yPos, int u, int v, int width, - int height, ResourceLocation loc) + + public GuiButtonCustomTexture(int id, int xPos, int yPos, int u, int v, + int width, int height, ResourceLocation loc) { super(id, xPos, yPos, width, height, "_"); textureU = u; @@ -22,23 +22,26 @@ public class GuiButtonCustomTexture extends GuiButtonExt { texture = loc; } - public void drawButton(Minecraft mc, int mouseX, int mouseY) - { - if (this.visible) - { - boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.getTextureManager().bindTexture(texture); - int u = textureU; - int v = textureV; + public void drawButton(Minecraft mc, int mouseX, int mouseY) + { + if (this.visible) + { + boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition + && mouseX < this.xPosition + this.width + && mouseY < this.yPosition + this.height; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.getTextureManager().bindTexture(texture); + int u = textureU; + int v = textureV; - if (flag) - { - u += width; - } + if (flag) + { + u += width; + } - this.drawTexturedModalRect(this.xPosition, this.yPosition, u, v, width, height); - } - } + this.drawTexturedModalRect(this.xPosition, this.yPosition, u, v, + width, height); + } + } } diff --git a/src/main/java/techreborn/pda/GuiPda.java b/src/main/java/techreborn/pda/GuiPda.java index 504fa5974..b71ff843c 100644 --- a/src/main/java/techreborn/pda/GuiPda.java +++ b/src/main/java/techreborn/pda/GuiPda.java @@ -1,44 +1,46 @@ package techreborn.pda; -import techreborn.init.ModBlocks; -import cpw.mods.fml.client.config.GuiButtonExt; -import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -public class GuiPda extends GuiScreen{ - - public final int guiWidth = 256; - public final int guiHeight = 180; - private int guiLeft, guiTop; - - private static final ResourceLocation pdaGuipages = new ResourceLocation("techreborn:" + "textures/gui/pda.png"); - public static final ResourceLocation buttonOre = new ResourceLocation("techreborn:" + "textures/blocks/ore/book_of_revealing"); +public class GuiPda extends GuiScreen { - public GuiPda(EntityPlayer player) {} + public final int guiWidth = 256; + public final int guiHeight = 180; + private int guiLeft, guiTop; + + private static final ResourceLocation pdaGuipages = new ResourceLocation( + "techreborn:" + "textures/gui/pda.png"); + public static final ResourceLocation buttonOre = new ResourceLocation( + "techreborn:" + "textures/blocks/ore/book_of_revealing"); + + public GuiPda(EntityPlayer player) + { + } @Override - public void initGui() + public void initGui() { super.initGui(); - this.guiLeft = this.width / 2 - this.guiWidth / 2; - this.guiTop = this.height / 2 - this.guiHeight / 2; - GuiButtonCustomTexture oresButton = new GuiButtonCustomTexture(1, guiLeft +20, guiTop +20, 0, 224, 16, 16, buttonOre); + this.guiLeft = this.width / 2 - this.guiWidth / 2; + this.guiTop = this.height / 2 - this.guiHeight / 2; + GuiButtonCustomTexture oresButton = new GuiButtonCustomTexture(1, + guiLeft + 20, guiTop + 20, 0, 224, 16, 16, buttonOre); - buttonList.add(oresButton); + buttonList.add(oresButton); } - + @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) + public void drawScreen(int mouseX, int mouseY, float partialTicks) { - - mc.getTextureManager().bindTexture(pdaGuipages); - drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.guiWidth, this.guiHeight); - mc.renderEngine.bindTexture(buttonOre); - + + mc.getTextureManager().bindTexture(pdaGuipages); + drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.guiWidth, + this.guiHeight); + mc.renderEngine.bindTexture(buttonOre); + super.drawScreen(mouseX, mouseY, partialTicks); } - } diff --git a/src/main/java/techreborn/proxies/ClientProxy.java b/src/main/java/techreborn/proxies/ClientProxy.java index 052c715a7..e5eaa7922 100644 --- a/src/main/java/techreborn/proxies/ClientProxy.java +++ b/src/main/java/techreborn/proxies/ClientProxy.java @@ -1,5 +1,5 @@ package techreborn.proxies; -public class ClientProxy extends CommonProxy{ +public class ClientProxy extends CommonProxy { } diff --git a/src/main/java/techreborn/tiles/TileBlastFurnace.java b/src/main/java/techreborn/tiles/TileBlastFurnace.java index 8973de135..29251abfc 100644 --- a/src/main/java/techreborn/tiles/TileBlastFurnace.java +++ b/src/main/java/techreborn/tiles/TileBlastFurnace.java @@ -11,39 +11,45 @@ public class TileBlastFurnace extends TileMachineBase implements IWrenchable { public int tickTime; public BasicSink energy; - public Inventory inventory = new Inventory(3, "TileBlastFurnace", 64); - + public Inventory inventory = new Inventory(3, "TileBlastFurnace", 64); @Override - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { return false; } @Override - public short getFacing() { + public short getFacing() + { return 0; } @Override - public void setFacing(short facing) { + public void setFacing(short facing) + { } @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { return true; } @Override - public float getWrenchDropRate() { + public float getWrenchDropRate() + { return 1.0F; } @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { return new ItemStack(ModBlocks.BlastFurnace, 1); } - public boolean isComplete(){ + public boolean isComplete() + { return false; } diff --git a/src/main/java/techreborn/tiles/TileCentrifuge.java b/src/main/java/techreborn/tiles/TileCentrifuge.java index daabf6788..4030cf3ae 100644 --- a/src/main/java/techreborn/tiles/TileCentrifuge.java +++ b/src/main/java/techreborn/tiles/TileCentrifuge.java @@ -18,334 +18,458 @@ import techreborn.init.ModBlocks; import techreborn.util.Inventory; import techreborn.util.ItemUtils; -public class TileCentrifuge extends TileMachineBase implements IInventory, IWrenchable, ISidedInventory { +public class TileCentrifuge extends TileMachineBase implements IInventory, + IWrenchable, ISidedInventory { - public BasicSink energy; - public Inventory inventory = new Inventory(6, "TileCentrifuge", 64); + public BasicSink energy; + public Inventory inventory = new Inventory(6, "TileCentrifuge", 64); - public boolean isRunning; - public int tickTime; - public CentrifugeRecipie currentRecipe; - public boolean hasTakenCells = false; - public boolean hasTakenItem = false; + public boolean isRunning; + public int tickTime; + public CentrifugeRecipie currentRecipe; + public boolean hasTakenCells = false; + public boolean hasTakenItem = false; - public int euTick = ConfigTechReborn.CentrifugeInputTick; + public int euTick = ConfigTechReborn.CentrifugeInputTick; - public TileCentrifuge() { - energy = new BasicSink(this, ConfigTechReborn.CentrifugeCharge, ConfigTechReborn.CentrifugeTier); - } + public TileCentrifuge() + { + energy = new BasicSink(this, ConfigTechReborn.CentrifugeCharge, + ConfigTechReborn.CentrifugeTier); + } - @Override - public void updateEntity() { - super.updateEntity(); - energy.updateEntity(); - if (!worldObj.isRemote) { - if (isRunning) { - if (ItemUtils.isItemEqual(currentRecipe.getInputItem(), getStackInSlot(0), true, true)) { - if (!hasTakenCells) { - if (getStackInSlot(1) != null && getStackInSlot(1) != null && ItemUtils.isItemEqual(getStackInSlot(1), IC2Items.getItem("cell"), false, false)) { - if (getStackInSlot(1).stackSize >= currentRecipe.getCells()) { - decrStackSize(1, currentRecipe.getCells()); - hasTakenCells = true; - } - } - } - if (hasTakenCells && hasTakenItem) { - if (tickTime == currentRecipe.getTickTime()) { - if (areAnyOutputsFull()) { - return; - } - if (areOutputsEmpty()) { - setOutput(1, currentRecipe.getOutput1()); - setOutput(2, currentRecipe.getOutput2()); - setOutput(3, currentRecipe.getOutput3()); - setOutput(4, currentRecipe.getOutput4()); - } else if (areOutputsEqual()) { - if (currentRecipe.getOutput1() != null) - increacseItemStack(1, 1); - if (currentRecipe.getOutput2() != null) - increacseItemStack(2, 1); - if (currentRecipe.getOutput3() != null) - increacseItemStack(3, 1); - if (currentRecipe.getOutput4() != null) - increacseItemStack(4, 1); - } - tickTime = 0; - isRunning = false; - hasTakenCells = false; - hasTakenItem = false; - syncWithAll(); - return; - } - if (energy.canUseEnergy(euTick)) { - if (getStackInSlot(0) != null && ItemUtils.isItemEqual(getStackInSlot(0), currentRecipe.getInputItem(), true, true)) { - if (energy.useEnergy(5)) { - tickTime++; - } - } - } - } - } - } else { - //sets a new recipe - if (getStackInSlot(0) != null && currentRecipe == null) { - for (CentrifugeRecipie recipie : TechRebornAPI.centrifugeRecipies) { - if (ItemUtils.isItemEqual(recipie.getInputItem(), getStackInSlot(0), true, true)) { - currentRecipe = new CentrifugeRecipie(recipie); - } - } - } - if (!isRunning && currentRecipe != null) { - if (areOutputsEqual() || !areAnyOutputsFull()) { - if (getStackInSlot(0) != null && currentRecipe.getInputItem().stackSize <= getStackInSlot(0).stackSize) { - if (energy.canUseEnergy(euTick)) { - decrStackSize(0, currentRecipe.getInputItem().stackSize); - hasTakenItem = true; - tickTime = 0; - isRunning = true; - } - } - } - } - } - syncWithAll(); - } - } + @Override + public void updateEntity() + { + super.updateEntity(); + energy.updateEntity(); + if (!worldObj.isRemote) + { + if (isRunning) + { + if (ItemUtils.isItemEqual(currentRecipe.getInputItem(), + getStackInSlot(0), true, true)) + { + if (!hasTakenCells) + { + if (getStackInSlot(1) != null + && getStackInSlot(1) != null + && ItemUtils.isItemEqual(getStackInSlot(1), + IC2Items.getItem("cell"), false, false)) + { + if (getStackInSlot(1).stackSize >= currentRecipe + .getCells()) + { + decrStackSize(1, currentRecipe.getCells()); + hasTakenCells = true; + } + } + } + if (hasTakenCells && hasTakenItem) + { + if (tickTime == currentRecipe.getTickTime()) + { + if (areAnyOutputsFull()) + { + return; + } + if (areOutputsEmpty()) + { + setOutput(1, currentRecipe.getOutput1()); + setOutput(2, currentRecipe.getOutput2()); + setOutput(3, currentRecipe.getOutput3()); + setOutput(4, currentRecipe.getOutput4()); + } else if (areOutputsEqual()) + { + if (currentRecipe.getOutput1() != null) + increacseItemStack(1, 1); + if (currentRecipe.getOutput2() != null) + increacseItemStack(2, 1); + if (currentRecipe.getOutput3() != null) + increacseItemStack(3, 1); + if (currentRecipe.getOutput4() != null) + increacseItemStack(4, 1); + } + tickTime = 0; + isRunning = false; + hasTakenCells = false; + hasTakenItem = false; + syncWithAll(); + return; + } + if (energy.canUseEnergy(euTick)) + { + if (getStackInSlot(0) != null + && ItemUtils.isItemEqual(getStackInSlot(0), + currentRecipe.getInputItem(), true, + true)) + { + if (energy.useEnergy(5)) + { + tickTime++; + } + } + } + } + } + } else + { + // sets a new recipe + if (getStackInSlot(0) != null && currentRecipe == null) + { + for (CentrifugeRecipie recipie : TechRebornAPI.centrifugeRecipies) + { + if (ItemUtils.isItemEqual(recipie.getInputItem(), + getStackInSlot(0), true, true)) + { + currentRecipe = new CentrifugeRecipie(recipie); + } + } + } + if (!isRunning && currentRecipe != null) + { + if (areOutputsEqual() || !areAnyOutputsFull()) + { + if (getStackInSlot(0) != null + && currentRecipe.getInputItem().stackSize <= getStackInSlot(0).stackSize) + { + if (energy.canUseEnergy(euTick)) + { + decrStackSize(0, + currentRecipe.getInputItem().stackSize); + hasTakenItem = true; + tickTime = 0; + isRunning = true; + } + } + } + } + } + syncWithAll(); + } + } - public boolean areOutputsEqual() { - if (currentRecipe == null) { - return false; - } - boolean boo = false; - if (currentRecipe.getOutput1() != null && ItemUtils.isItemEqual(getOutputItemStack(1), currentRecipe.getOutput1(), false, true)) { - boo = true; - } - if (currentRecipe.getOutput2() != null && ItemUtils.isItemEqual(getOutputItemStack(2), currentRecipe.getOutput2(), false, true)) { - boo = true; - } - if (currentRecipe.getOutput3() != null && ItemUtils.isItemEqual(getOutputItemStack(3), currentRecipe.getOutput3(), false, true)) { - boo = true; - } - if (currentRecipe.getOutput4() != null && ItemUtils.isItemEqual(getOutputItemStack(4), currentRecipe.getOutput4(), false, true)) { - boo = true; - } - return boo; - } + public boolean areOutputsEqual() + { + if (currentRecipe == null) + { + return false; + } + boolean boo = false; + if (currentRecipe.getOutput1() != null + && ItemUtils.isItemEqual(getOutputItemStack(1), + currentRecipe.getOutput1(), false, true)) + { + boo = true; + } + if (currentRecipe.getOutput2() != null + && ItemUtils.isItemEqual(getOutputItemStack(2), + currentRecipe.getOutput2(), false, true)) + { + boo = true; + } + if (currentRecipe.getOutput3() != null + && ItemUtils.isItemEqual(getOutputItemStack(3), + currentRecipe.getOutput3(), false, true)) + { + boo = true; + } + if (currentRecipe.getOutput4() != null + && ItemUtils.isItemEqual(getOutputItemStack(4), + currentRecipe.getOutput4(), false, true)) + { + boo = true; + } + return boo; + } - public boolean areOutputsEmpty() { - return getOutputItemStack(1) == null && getOutputItemStack(2) == null && getOutputItemStack(3) == null && getOutputItemStack(4) == null; - } + public boolean areOutputsEmpty() + { + return getOutputItemStack(1) == null && getOutputItemStack(2) == null + && getOutputItemStack(3) == null + && getOutputItemStack(4) == null; + } - public boolean areAnyOutputsFull() { - if (currentRecipe.getOutput1() != null && getOutputItemStack(1) != null && getOutputItemStack(1).stackSize + currentRecipe.getOutput1().stackSize > currentRecipe.getOutput1().getMaxStackSize()) { - return true; - } - if (currentRecipe.getOutput2() != null && getOutputItemStack(2) != null && getOutputItemStack(2).stackSize + currentRecipe.getOutput2().stackSize > currentRecipe.getOutput1().getMaxStackSize()) { - return true; - } - if (currentRecipe.getOutput3() != null && getOutputItemStack(3) != null && getOutputItemStack(3).stackSize + currentRecipe.getOutput3().stackSize > currentRecipe.getOutput1().getMaxStackSize()) { - return true; - } - if (currentRecipe.getOutput4() != null && getOutputItemStack(4) != null && getOutputItemStack(4).stackSize + currentRecipe.getOutput4().stackSize > currentRecipe.getOutput1().getMaxStackSize()) { - return true; - } - return false; - } + public boolean areAnyOutputsFull() + { + if (currentRecipe.getOutput1() != null + && getOutputItemStack(1) != null + && getOutputItemStack(1).stackSize + + currentRecipe.getOutput1().stackSize > currentRecipe + .getOutput1().getMaxStackSize()) + { + return true; + } + if (currentRecipe.getOutput2() != null + && getOutputItemStack(2) != null + && getOutputItemStack(2).stackSize + + currentRecipe.getOutput2().stackSize > currentRecipe + .getOutput1().getMaxStackSize()) + { + return true; + } + if (currentRecipe.getOutput3() != null + && getOutputItemStack(3) != null + && getOutputItemStack(3).stackSize + + currentRecipe.getOutput3().stackSize > currentRecipe + .getOutput1().getMaxStackSize()) + { + return true; + } + if (currentRecipe.getOutput4() != null + && getOutputItemStack(4) != null + && getOutputItemStack(4).stackSize + + currentRecipe.getOutput4().stackSize > currentRecipe + .getOutput1().getMaxStackSize()) + { + return true; + } + return false; + } - public ItemStack getOutputItemStack(int slot) { - return getStackInSlot(slot + 1); - } + public ItemStack getOutputItemStack(int slot) + { + return getStackInSlot(slot + 1); + } - public void increacseItemStack(int slot, int amount) { - if (getOutputItemStack(slot) == null) { - return; - } - decrStackSize(slot + 1, -amount); - } + public void increacseItemStack(int slot, int amount) + { + if (getOutputItemStack(slot) == null) + { + return; + } + decrStackSize(slot + 1, -amount); + } - public void setOutput(int slot, ItemStack stack) { - if (stack == null) { - return; - } - setInventorySlotContents(slot + 1, stack); - } + public void setOutput(int slot, ItemStack stack) + { + if (stack == null) + { + return; + } + setInventorySlotContents(slot + 1, stack); + } - @Override - public void readFromNBT(NBTTagCompound tagCompound) { - super.readFromNBT(tagCompound); - inventory.readFromNBT(tagCompound); - String recipeName = tagCompound.getString("recipe"); - for (CentrifugeRecipie recipie : TechRebornAPI.centrifugeRecipies) { - if (recipie.getInputItem().getUnlocalizedName().equals(recipeName)) { - currentRecipe = new CentrifugeRecipie(recipie); - } - } - isRunning = tagCompound.getBoolean("isRunning"); - tickTime = tagCompound.getInteger("tickTime"); - hasTakenCells = tagCompound.getBoolean("hasTakenCells"); - hasTakenItem = tagCompound.getBoolean("hasTakenItem"); - } + @Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + inventory.readFromNBT(tagCompound); + String recipeName = tagCompound.getString("recipe"); + for (CentrifugeRecipie recipie : TechRebornAPI.centrifugeRecipies) + { + if (recipie.getInputItem().getUnlocalizedName().equals(recipeName)) + { + currentRecipe = new CentrifugeRecipie(recipie); + } + } + isRunning = tagCompound.getBoolean("isRunning"); + tickTime = tagCompound.getInteger("tickTime"); + hasTakenCells = tagCompound.getBoolean("hasTakenCells"); + hasTakenItem = tagCompound.getBoolean("hasTakenItem"); + } - @Override - public void writeToNBT(NBTTagCompound tagCompound) { - super.writeToNBT(tagCompound); - inventory.writeToNBT(tagCompound); - writeUpdateToNBT(tagCompound); - } + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + inventory.writeToNBT(tagCompound); + writeUpdateToNBT(tagCompound); + } - public void writeUpdateToNBT(NBTTagCompound tagCompound) { - if (currentRecipe != null) { - tagCompound.setString("recipe", currentRecipe.getInputItem().getUnlocalizedName()); - } else { - tagCompound.setString("recipe", "none"); - } - tagCompound.setBoolean("isRunning", isRunning); - tagCompound.setInteger("tickTime", tickTime); - tagCompound.setBoolean("hasTakenCells", hasTakenCells); - tagCompound.setBoolean("hasTakenItem", hasTakenItem); - } + public void writeUpdateToNBT(NBTTagCompound tagCompound) + { + if (currentRecipe != null) + { + tagCompound.setString("recipe", currentRecipe.getInputItem() + .getUnlocalizedName()); + } else + { + tagCompound.setString("recipe", "none"); + } + tagCompound.setBoolean("isRunning", isRunning); + tagCompound.setInteger("tickTime", tickTime); + tagCompound.setBoolean("hasTakenCells", hasTakenCells); + tagCompound.setBoolean("hasTakenItem", hasTakenItem); + } - @Override - public int getSizeInventory() { - return inventory.getSizeInventory(); - } + @Override + public int getSizeInventory() + { + return inventory.getSizeInventory(); + } - @Override - public ItemStack getStackInSlot(int p_70301_1_) { - return inventory.getStackInSlot(p_70301_1_); - } + @Override + public ItemStack getStackInSlot(int p_70301_1_) + { + return inventory.getStackInSlot(p_70301_1_); + } - @Override - public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { - return inventory.decrStackSize(p_70298_1_, p_70298_2_); - } + @Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) + { + return inventory.decrStackSize(p_70298_1_, p_70298_2_); + } - @Override - public ItemStack getStackInSlotOnClosing(int p_70304_1_) { - return inventory.getStackInSlotOnClosing(p_70304_1_); - } + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) + { + return inventory.getStackInSlotOnClosing(p_70304_1_); + } - @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - inventory.setInventorySlotContents(p_70299_1_, p_70299_2_); - } + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) + { + inventory.setInventorySlotContents(p_70299_1_, p_70299_2_); + } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); - } + @Override + public String getInventoryName() + { + return inventory.getInventoryName(); + } - @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); - } + @Override + public boolean hasCustomInventoryName() + { + return inventory.hasCustomInventoryName(); + } - @Override - public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); - } + @Override + public int getInventoryStackLimit() + { + return inventory.getInventoryStackLimit(); + } - @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - return inventory.isUseableByPlayer(p_70300_1_); - } + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) + { + return inventory.isUseableByPlayer(p_70300_1_); + } - @Override - public void openInventory() { - inventory.openInventory(); - } + @Override + public void openInventory() + { + inventory.openInventory(); + } - @Override - public void closeInventory() { - inventory.closeInventory(); - } + @Override + public void closeInventory() + { + inventory.closeInventory(); + } - @Override - public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_); - } + @Override + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) + { + return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_); + } - @Override - public void invalidate() { - energy.invalidate(); - } + @Override + public void invalidate() + { + energy.invalidate(); + } - @Override - public void onChunkUnload() { - energy.onChunkUnload(); - } + @Override + public void onChunkUnload() + { + energy.onChunkUnload(); + } - public Packet getDescriptionPacket() { - NBTTagCompound nbtTag = new NBTTagCompound(); - writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); - } + public Packet getDescriptionPacket() + { + NBTTagCompound nbtTag = new NBTTagCompound(); + writeToNBT(nbtTag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, + this.zCoord, 1, nbtTag); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - readFromNBT(packet.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) + { + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, + yCoord, zCoord); + readFromNBT(packet.func_148857_g()); + } - @Override - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { - return false; - } + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return false; + } - @Override - public short getFacing() { - return 0; - } + @Override + public short getFacing() + { + return 0; + } - @Override - public void setFacing(short facing) { - } + @Override + public void setFacing(short facing) + { + } - @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) { - return true; - } + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + return true; + } - @Override - public float getWrenchDropRate() { - return 1.0F; - } + @Override + public float getWrenchDropRate() + { + return 1.0F; + } - @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { - return new ItemStack(ModBlocks.centrifuge, 1); - } + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return new ItemStack(ModBlocks.centrifuge, 1); + } - @Override - public int[] getAccessibleSlotsFromSide(int side) { - //Top - if (side == 1) { - return new int[]{0}; - } - //Bottom - if (side == 0) { - return new int[]{1}; - } - //Not bottom or top - return new int[]{2, 3, 4, 5}; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) + { + // Top + if (side == 1) + { + return new int[] + { 0 }; + } + // Bottom + if (side == 0) + { + return new int[] + { 1 }; + } + // Not bottom or top + return new int[] + { 2, 3, 4, 5 }; + } - @Override - public boolean canInsertItem(int slot, ItemStack stack, int side) { - //Bottom - if (side == 0) { - return ItemUtils.isItemEqual(stack, IC2Items.getItem("cell"), false, false); - } - //Not bottom or top - if (side >= 2) { - return false; - } - return true; - } + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side) + { + // Bottom + if (side == 0) + { + return ItemUtils.isItemEqual(stack, IC2Items.getItem("cell"), + false, false); + } + // Not bottom or top + if (side >= 2) + { + return false; + } + return true; + } - @Override - public boolean canExtractItem(int slot, ItemStack stack, int side) { - //Only output slots and sides - return slot >= 2 && side >= 2; - } + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side) + { + // Only output slots and sides + return slot >= 2 && side >= 2; + } } diff --git a/src/main/java/techreborn/tiles/TileMachineBase.java b/src/main/java/techreborn/tiles/TileMachineBase.java index 567d921c3..a8e233c62 100644 --- a/src/main/java/techreborn/tiles/TileMachineBase.java +++ b/src/main/java/techreborn/tiles/TileMachineBase.java @@ -7,43 +7,51 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import techreborn.init.ModBlocks; import techreborn.packets.PacketHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class TileMachineBase extends TileEntity { - private int facing; + private int facing; - @Override - public void updateEntity() { - super.updateEntity(); - //TODO make this happen less - //syncWithAll(); - } + @Override + public void updateEntity() + { + super.updateEntity(); + // TODO make this happen less + // syncWithAll(); + } - @SideOnly(Side.CLIENT) - public void addWailaInfo(List info) { + @SideOnly(Side.CLIENT) + public void addWailaInfo(List info) + { - } + } - public void syncWithAll() { - if (!worldObj.isRemote) { - PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(), worldObj); - } - } + public void syncWithAll() + { + if (!worldObj.isRemote) + { + PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(), + worldObj); + } + } - public Packet getDescriptionPacket() { - NBTTagCompound nbtTag = new NBTTagCompound(); - writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); - } + public Packet getDescriptionPacket() + { + NBTTagCompound nbtTag = new NBTTagCompound(); + writeToNBT(nbtTag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, + this.zCoord, 1, nbtTag); + } + + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) + { + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, + yCoord, zCoord); + readFromNBT(packet.func_148857_g()); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - readFromNBT(packet.func_148857_g()); - } - } diff --git a/src/main/java/techreborn/tiles/TileMachineCasing.java b/src/main/java/techreborn/tiles/TileMachineCasing.java index e55286bf2..31db96635 100644 --- a/src/main/java/techreborn/tiles/TileMachineCasing.java +++ b/src/main/java/techreborn/tiles/TileMachineCasing.java @@ -1,64 +1,75 @@ package techreborn.tiles; +import techreborn.multiblocks.MultiBlockCasing; import erogenousbeef.coreTR.multiblock.MultiblockControllerBase; import erogenousbeef.coreTR.multiblock.MultiblockValidationException; import erogenousbeef.coreTR.multiblock.rectangular.RectangularMultiblockTileEntityBase; -import techreborn.multiblocks.MultiBlockCasing; public class TileMachineCasing extends RectangularMultiblockTileEntityBase { - @Override - public boolean canUpdate() { - //No need to update this. - return false; - } + @Override + public boolean canUpdate() + { + // No need to update this. + return false; + } - @Override - public void onMachineActivated() { + @Override + public void onMachineActivated() + { - } + } - @Override - public void onMachineDeactivated() { + @Override + public void onMachineDeactivated() + { - } + } - @Override - public MultiblockControllerBase createNewMultiblock() { - return new MultiBlockCasing(worldObj); - } + @Override + public MultiblockControllerBase createNewMultiblock() + { + return new MultiBlockCasing(worldObj); + } - @Override - public Class getMultiblockControllerType() { - return MultiBlockCasing.class; - } + @Override + public Class getMultiblockControllerType() + { + return MultiBlockCasing.class; + } - @Override - public void isGoodForFrame() throws MultiblockValidationException { + @Override + public void isGoodForFrame() throws MultiblockValidationException + { - } + } - @Override - public void isGoodForSides() throws MultiblockValidationException { + @Override + public void isGoodForSides() throws MultiblockValidationException + { - } + } - @Override - public void isGoodForTop() throws MultiblockValidationException { + @Override + public void isGoodForTop() throws MultiblockValidationException + { - } + } - @Override - public void isGoodForBottom() throws MultiblockValidationException { + @Override + public void isGoodForBottom() throws MultiblockValidationException + { - } + } - @Override - public void isGoodForInterior() throws MultiblockValidationException { + @Override + public void isGoodForInterior() throws MultiblockValidationException + { - } + } - public MultiBlockCasing getMultiblockController() { - return (MultiBlockCasing) super.getMultiblockController(); - } + public MultiBlockCasing getMultiblockController() + { + return (MultiBlockCasing) super.getMultiblockController(); + } } diff --git a/src/main/java/techreborn/tiles/TileQuantumChest.java b/src/main/java/techreborn/tiles/TileQuantumChest.java index 9abdb2197..396cf0954 100644 --- a/src/main/java/techreborn/tiles/TileQuantumChest.java +++ b/src/main/java/techreborn/tiles/TileQuantumChest.java @@ -1,6 +1,9 @@ package techreborn.tiles; import ic2.api.tile.IWrenchable; + +import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -12,220 +15,268 @@ import techreborn.init.ModBlocks; import techreborn.util.Inventory; import techreborn.util.ItemUtils; -import java.util.List; +public class TileQuantumChest extends TileMachineBase implements IInventory, + IWrenchable { + // Slot 0 = Input + // Slot 1 = Output + // Slot 2 = Fake Item + public Inventory inventory = new Inventory(3, "TileQuantumChest", + Integer.MAX_VALUE); -public class TileQuantumChest extends TileMachineBase implements IInventory, IWrenchable { + public ItemStack storedItem; - //Slot 0 = Input - //Slot 1 = Output - //Slot 2 = Fake Item - public Inventory inventory = new Inventory(3, "TileQuantumChest", Integer.MAX_VALUE); + @Override + public void updateEntity() + { + if (storedItem != null) + { + ItemStack fakeStack = storedItem.copy(); + fakeStack.stackSize = 1; + setInventorySlotContents(2, fakeStack); + } else + { + setInventorySlotContents(2, null); + } - public ItemStack storedItem; + if (getStackInSlot(0) != null) + { + if (storedItem == null) + { + storedItem = getStackInSlot(0); + setInventorySlotContents(0, null); + } else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), + true, true)) + { + if (storedItem.stackSize <= Integer.MAX_VALUE + - getStackInSlot(0).stackSize) + { + storedItem.stackSize += getStackInSlot(0).stackSize; + decrStackSize(0, getStackInSlot(0).stackSize); + } + } + } + if (storedItem != null && getStackInSlot(1) == null) + { + ItemStack itemStack = storedItem.copy(); + itemStack.stackSize = itemStack.getMaxStackSize(); + setInventorySlotContents(1, itemStack); + storedItem.stackSize -= itemStack.getMaxStackSize(); + } else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, + true)) + { + int wanted = getStackInSlot(1).getMaxStackSize() + - getStackInSlot(1).stackSize; + if (storedItem.stackSize >= wanted) + { + decrStackSize(1, -wanted); + storedItem.stackSize -= wanted; + } else + { + decrStackSize(1, -storedItem.stackSize); + storedItem = null; + } + } + syncWithAll(); + } - @Override - public void updateEntity() { - if (storedItem != null) { - ItemStack fakeStack = storedItem.copy(); - fakeStack.stackSize = 1; - setInventorySlotContents(2, fakeStack); - } else { - setInventorySlotContents(2, null); - } + public Packet getDescriptionPacket() + { + NBTTagCompound nbtTag = new NBTTagCompound(); + writeToNBT(nbtTag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, + this.zCoord, 1, nbtTag); + } - if (getStackInSlot(0) != null) { - if (storedItem == null) { - storedItem = getStackInSlot(0); - setInventorySlotContents(0, null); - } else if (ItemUtils.isItemEqual(storedItem, getStackInSlot(0), true, true)) { - if (storedItem.stackSize <= Integer.MAX_VALUE - getStackInSlot(0).stackSize) { - storedItem.stackSize += getStackInSlot(0).stackSize; - decrStackSize(0, getStackInSlot(0).stackSize); - } - } - } + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) + { + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, + yCoord, zCoord); + readFromNBT(packet.func_148857_g()); + } - if (storedItem != null && getStackInSlot(1) == null) { - ItemStack itemStack = storedItem.copy(); - itemStack.stackSize = itemStack.getMaxStackSize(); - setInventorySlotContents(1, itemStack); - storedItem.stackSize -= itemStack.getMaxStackSize(); - } else if (ItemUtils.isItemEqual(getStackInSlot(1), storedItem, true, true)) { - int wanted = getStackInSlot(1).getMaxStackSize() - getStackInSlot(1).stackSize; - if (storedItem.stackSize >= wanted) { - decrStackSize(1, -wanted); - storedItem.stackSize -= wanted; - } else { - decrStackSize(1, -storedItem.stackSize); - storedItem = null; - } - } - syncWithAll(); - } + @Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + readFromNBTWithoutCoords(tagCompound); + } + public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) + { + inventory.readFromNBT(tagCompound); - public Packet getDescriptionPacket() { - NBTTagCompound nbtTag = new NBTTagCompound(); - writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); - } + storedItem = null; - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - readFromNBT(packet.func_148857_g()); - } + if (tagCompound.hasKey("storedStack")) + { + storedItem = ItemStack + .loadItemStackFromNBT((NBTTagCompound) tagCompound + .getTag("storedStack")); + } - @Override - public void readFromNBT(NBTTagCompound tagCompound) { - super.readFromNBT(tagCompound); - readFromNBTWithoutCoords(tagCompound); - } + if (storedItem != null) + { + storedItem.stackSize = tagCompound.getInteger("storedQuantity"); + } + } - public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) { - inventory.readFromNBT(tagCompound); + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + writeToNBTWithoutCoords(tagCompound); + } - storedItem = null; + public void writeToNBTWithoutCoords(NBTTagCompound tagCompound) + { + inventory.writeToNBT(tagCompound); + if (storedItem != null) + { + tagCompound.setTag("storedStack", + storedItem.writeToNBT(new NBTTagCompound())); + tagCompound.setInteger("storedQuantity", storedItem.stackSize); + } else + tagCompound.setInteger("storedQuantity", 0); + } - if (tagCompound.hasKey("storedStack")) { - storedItem = ItemStack. - loadItemStackFromNBT((NBTTagCompound) tagCompound.getTag("storedStack")); - } + @Override + public int getSizeInventory() + { + return inventory.getSizeInventory(); + } - if (storedItem != null) { - storedItem.stackSize = tagCompound.getInteger("storedQuantity"); - } - } + @Override + public ItemStack getStackInSlot(int slot) + { + return inventory.getStackInSlot(slot); + } - @Override - public void writeToNBT(NBTTagCompound tagCompound) { - super.writeToNBT(tagCompound); - writeToNBTWithoutCoords(tagCompound); - } + @Override + public ItemStack decrStackSize(int slotId, int count) + { + return inventory.decrStackSize(slotId, count); + } - public void writeToNBTWithoutCoords(NBTTagCompound tagCompound) { - inventory.writeToNBT(tagCompound); - if (storedItem != null) { - tagCompound.setTag("storedStack", storedItem.writeToNBT(new NBTTagCompound())); - tagCompound.setInteger("storedQuantity", storedItem.stackSize); - } else - tagCompound.setInteger("storedQuantity", 0); - } + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + return inventory.getStackInSlotOnClosing(slot); + } - @Override - public int getSizeInventory() { - return inventory.getSizeInventory(); - } + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + inventory.setInventorySlotContents(slot, stack); + } - @Override - public ItemStack getStackInSlot(int slot) { - return inventory.getStackInSlot(slot); - } + @Override + public String getInventoryName() + { + return inventory.getInventoryName(); + } - @Override - public ItemStack decrStackSize(int slotId, int count) { - return inventory.decrStackSize(slotId, count); - } + @Override + public boolean hasCustomInventoryName() + { + return inventory.hasCustomInventoryName(); + } - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); - } + @Override + public int getInventoryStackLimit() + { + return inventory.getInventoryStackLimit(); + } - @Override - public void setInventorySlotContents(int slot, ItemStack stack) { - inventory.setInventorySlotContents(slot, stack); - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) + { + return inventory.isUseableByPlayer(player); + } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); - } + @Override + public void openInventory() + { + inventory.openInventory(); + } - @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); - } + @Override + public void closeInventory() + { + inventory.closeInventory(); + } - @Override - public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); - } + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) + { + return inventory.isItemValidForSlot(slot, stack); + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return inventory.isUseableByPlayer(player); - } + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return false; + } - @Override - public void openInventory() { - inventory.openInventory(); - } + @Override + public short getFacing() + { + return 0; + } - @Override - public void closeInventory() { - inventory.closeInventory(); - } + @Override + public void setFacing(short facing) + { + } - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack) { - return inventory.isItemValidForSlot(slot, stack); - } + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + return true; + } - @Override - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { - return false; - } + @Override + public float getWrenchDropRate() + { + return 1F; + } - @Override - public short getFacing() { - return 0; - } + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return getDropWithNBT(); + } - @Override - public void setFacing(short facing) { - } + public ItemStack getDropWithNBT() + { + NBTTagCompound tileEntity = new NBTTagCompound(); + ItemStack dropStack = new ItemStack(ModBlocks.quantumChest, 1); + writeToNBTWithoutCoords(tileEntity); + dropStack.setTagCompound(new NBTTagCompound()); + dropStack.stackTagCompound.setTag("tileEntity", tileEntity); + return dropStack; + } - @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) { - return true; - } + @Override + public void addWailaInfo(List info) + { + super.addWailaInfo(info); + int size = 0; + String name = "of nothing"; + if (storedItem != null) + { + name = storedItem.getDisplayName(); + size += storedItem.stackSize; + } + if (getStackInSlot(1) != null) + { + name = getStackInSlot(1).getDisplayName(); + size += getStackInSlot(1).stackSize; + } + info.add(size + " " + name); - @Override - public float getWrenchDropRate() { - return 1F; - } - - @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { - return getDropWithNBT(); - } - - public ItemStack getDropWithNBT() { - NBTTagCompound tileEntity = new NBTTagCompound(); - ItemStack dropStack = new ItemStack(ModBlocks.quantumChest, 1); - writeToNBTWithoutCoords(tileEntity); - dropStack.setTagCompound(new NBTTagCompound()); - dropStack.stackTagCompound.setTag("tileEntity", tileEntity); - return dropStack; - } - - @Override - public void addWailaInfo(List info) { - super.addWailaInfo(info); - int size = 0; - String name = "of nothing"; - if (storedItem != null) { - name = storedItem.getDisplayName(); - size += storedItem.stackSize; - } - if (getStackInSlot(1) != null) { - name = getStackInSlot(1).getDisplayName(); - size += getStackInSlot(1).stackSize; - } - info.add(size + " " + name); - - } + } } diff --git a/src/main/java/techreborn/tiles/TileQuantumTank.java b/src/main/java/techreborn/tiles/TileQuantumTank.java index 2010210a8..a918c8a76 100644 --- a/src/main/java/techreborn/tiles/TileQuantumTank.java +++ b/src/main/java/techreborn/tiles/TileQuantumTank.java @@ -1,6 +1,9 @@ package techreborn.tiles; import ic2.api.tile.IWrenchable; + +import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -18,197 +21,238 @@ import techreborn.util.FluidUtils; import techreborn.util.Inventory; import techreborn.util.Tank; -import java.util.List; +public class TileQuantumTank extends TileMachineBase implements IFluidHandler, + IInventory, IWrenchable { -public class TileQuantumTank extends TileMachineBase implements IFluidHandler, IInventory, IWrenchable { + public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this); + public Inventory inventory = new Inventory(3, "TileQuantumTank", 64); - public Tank tank = new Tank("TileQuantumTank", Integer.MAX_VALUE, this); - public Inventory inventory = new Inventory(3, "TileQuantumTank", 64); + @Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + readFromNBTWithoutCoords(tagCompound); + } - @Override - public void readFromNBT(NBTTagCompound tagCompound) { - super.readFromNBT(tagCompound); - readFromNBTWithoutCoords(tagCompound); - } + public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) + { + tank.readFromNBT(tagCompound); + inventory.readFromNBT(tagCompound); + } - public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) { - tank.readFromNBT(tagCompound); - inventory.readFromNBT(tagCompound); - } + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + writeToNBTWithoutCoords(tagCompound); + } - @Override - public void writeToNBT(NBTTagCompound tagCompound) { - super.writeToNBT(tagCompound); - writeToNBTWithoutCoords(tagCompound); - } + public void writeToNBTWithoutCoords(NBTTagCompound tagCompound) + { + tank.writeToNBT(tagCompound); + inventory.writeToNBT(tagCompound); + } - public void writeToNBTWithoutCoords(NBTTagCompound tagCompound) { - tank.writeToNBT(tagCompound); - inventory.writeToNBT(tagCompound); - } + public Packet getDescriptionPacket() + { + NBTTagCompound nbtTag = new NBTTagCompound(); + writeToNBT(nbtTag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, + this.zCoord, 1, nbtTag); + } + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) + { + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, + yCoord, zCoord); + readFromNBT(packet.func_148857_g()); + } - public Packet getDescriptionPacket() { - NBTTagCompound nbtTag = new NBTTagCompound(); - writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); - } + @Override + public void updateEntity() + { + super.updateEntity(); + FluidUtils.drainContainers(this, inventory, 0, 1); + FluidUtils.fillContainers(this, inventory, 0, 1, tank.getFluidType()); + if (tank.getFluidType() != null && getStackInSlot(2) == null) + { + inventory.setInventorySlotContents(2, new ItemStack(tank + .getFluidType().getBlock())); + } else if (tank.getFluidType() == null && getStackInSlot(2) != null) + { + setInventorySlotContents(2, null); + } + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - readFromNBT(packet.func_148857_g()); - } + // IFluidHandler + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + { + return tank.fill(resource, doFill); + } - @Override - public void updateEntity() { - super.updateEntity(); - FluidUtils.drainContainers(this, inventory, 0, 1); - FluidUtils.fillContainers(this, inventory, 0, 1, tank.getFluidType()); - if (tank.getFluidType() != null && getStackInSlot(2) == null) { - inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock())); - } else if (tank.getFluidType() == null && getStackInSlot(2) != null) { - setInventorySlotContents(2, null); - } - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, + boolean doDrain) + { + return tank.drain(resource.amount, doDrain); + } - //IFluidHandler - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - return tank.fill(resource, doFill); - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + { + return tank.drain(maxDrain, doDrain); + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - return tank.drain(resource.amount, doDrain); - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) + { + return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return tank.drain(maxDrain, doDrain); - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) + { + return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) { - return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) + { + return getTankInfo(from); + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) { - return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; - } + // IInventory + @Override + public int getSizeInventory() + { + return inventory.getSizeInventory(); + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) { - return getTankInfo(from); - } + @Override + public ItemStack getStackInSlot(int slot) + { + return inventory.getStackInSlot(slot); + } - //IInventory - @Override - public int getSizeInventory() { - return inventory.getSizeInventory(); - } + @Override + public ItemStack decrStackSize(int slotId, int count) + { + return inventory.decrStackSize(slotId, count); + } - @Override - public ItemStack getStackInSlot(int slot) { - return inventory.getStackInSlot(slot); - } + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + return inventory.getStackInSlotOnClosing(slot); + } - @Override - public ItemStack decrStackSize(int slotId, int count) { - return inventory.decrStackSize(slotId, count); - } + @Override + public void setInventorySlotContents(int slot, ItemStack stack) + { + inventory.setInventorySlotContents(slot, stack); + } - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - return inventory.getStackInSlotOnClosing(slot); - } + @Override + public String getInventoryName() + { + return inventory.getInventoryName(); + } - @Override - public void setInventorySlotContents(int slot, ItemStack stack) { - inventory.setInventorySlotContents(slot, stack); - } + @Override + public boolean hasCustomInventoryName() + { + return inventory.hasCustomInventoryName(); + } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); - } + @Override + public int getInventoryStackLimit() + { + return inventory.getInventoryStackLimit(); + } - @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); - } + @Override + public boolean isUseableByPlayer(EntityPlayer player) + { + return inventory.isUseableByPlayer(player); + } - @Override - public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); - } + @Override + public void openInventory() + { + inventory.openInventory(); + } - @Override - public boolean isUseableByPlayer(EntityPlayer player) { - return inventory.isUseableByPlayer(player); - } + @Override + public void closeInventory() + { + inventory.closeInventory(); + } - @Override - public void openInventory() { - inventory.openInventory(); - } + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack) + { + return inventory.isItemValidForSlot(slot, stack); + } - @Override - public void closeInventory() { - inventory.closeInventory(); - } + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return false; + } - @Override - public boolean isItemValidForSlot(int slot, ItemStack stack) { - return inventory.isItemValidForSlot(slot, stack); - } + @Override + public short getFacing() + { + return 0; + } - @Override - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { - return false; - } + @Override + public void setFacing(short facing) + { + } - @Override - public short getFacing() { - return 0; - } + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + return true; + } - @Override - public void setFacing(short facing) { - } + @Override + public float getWrenchDropRate() + { + return 1F; + } - @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) { - return true; - } + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return getDropWithNBT(); + } - @Override - public float getWrenchDropRate() { - return 1F; - } + public ItemStack getDropWithNBT() + { + NBTTagCompound tileEntity = new NBTTagCompound(); + ItemStack dropStack = new ItemStack(ModBlocks.quantumTank, 1); + writeToNBTWithoutCoords(tileEntity); + dropStack.setTagCompound(new NBTTagCompound()); + dropStack.stackTagCompound.setTag("tileEntity", tileEntity); + return dropStack; + } - @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { - return getDropWithNBT(); - } - - public ItemStack getDropWithNBT() { - NBTTagCompound tileEntity = new NBTTagCompound(); - ItemStack dropStack = new ItemStack(ModBlocks.quantumTank, 1); - writeToNBTWithoutCoords(tileEntity); - dropStack.setTagCompound(new NBTTagCompound()); - dropStack.stackTagCompound.setTag("tileEntity", tileEntity); - return dropStack; - } - - @Override - public void addWailaInfo(List info) { - super.addWailaInfo(info); - if (tank.getFluid() != null) { - info.add(tank.getFluidAmount() + " of " + tank.getFluidType().getName()); - } else { - info.add("Empty"); - } - } + @Override + public void addWailaInfo(List info) + { + super.addWailaInfo(info); + if (tank.getFluid() != null) + { + info.add(tank.getFluidAmount() + " of " + + tank.getFluidType().getName()); + } else + { + info.add("Empty"); + } + } } diff --git a/src/main/java/techreborn/tiles/TileRollingMachine.java b/src/main/java/techreborn/tiles/TileRollingMachine.java index c10c0c705..b2b7f3e11 100644 --- a/src/main/java/techreborn/tiles/TileRollingMachine.java +++ b/src/main/java/techreborn/tiles/TileRollingMachine.java @@ -15,136 +15,174 @@ import techreborn.util.ItemUtils; //TODO add tick and power bars. public class TileRollingMachine extends TileMachineBase implements IWrenchable { - public BasicSink energy; - public Inventory inventory = new Inventory(2, "TileRollingMachine", 64); - public final InventoryCrafting craftMatrix = new InventoryCrafting(new RollingTileContainer(), 3, 3); + public BasicSink energy; + public Inventory inventory = new Inventory(2, "TileRollingMachine", 64); + public final InventoryCrafting craftMatrix = new InventoryCrafting( + new RollingTileContainer(), 3, 3); - public boolean isRunning; - public int tickTime; - public int runTime = 250; - public ItemStack currentRecipe; + public boolean isRunning; + public int tickTime; + public int runTime = 250; + public ItemStack currentRecipe; - public int euTick = 5; + public int euTick = 5; - private static class RollingTileContainer extends Container { + private static class RollingTileContainer extends Container { - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - return true; - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return true; + } - } + } - public TileRollingMachine() { - energy = new BasicSink(this, 100000, 1); - } + public TileRollingMachine() + { + energy = new BasicSink(this, 100000, 1); + } - @Override - public void updateEntity() { - super.updateEntity(); - energy.updateEntity(); - if(!worldObj.isRemote){ - currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj); - if(currentRecipe != null && canMake()){ - if(tickTime >= runTime){ - currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj); - if (currentRecipe != null) { - boolean hasCrafted = false; - if(inventory.getStackInSlot(0) == null){ - inventory.setInventorySlotContents(0, currentRecipe); - tickTime = 0; - hasCrafted = true; - } else { - if(inventory.getStackInSlot(0).stackSize + currentRecipe.stackSize <= currentRecipe.getMaxStackSize()){ - ItemStack stack = inventory.getStackInSlot(0); - stack.stackSize = stack.stackSize + currentRecipe.stackSize; - inventory.setInventorySlotContents(0, stack); - tickTime = 0; - hasCrafted = true; - } - } - if(hasCrafted){ - for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { - craftMatrix.decrStackSize(i, 1); - } - currentRecipe = null; - } - } - } - } - if(currentRecipe != null) { - if(energy.canUseEnergy(euTick) && tickTime < runTime){ - tickTime ++; - } - } - if(currentRecipe == null){ - tickTime = 0; - } - } else { - currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj); - if(currentRecipe != null){ - inventory.setInventorySlotContents(1, currentRecipe); - } else { - inventory.setInventorySlotContents(1, null); - } - } - } + @Override + public void updateEntity() + { + super.updateEntity(); + energy.updateEntity(); + if (!worldObj.isRemote) + { + currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe( + craftMatrix, worldObj); + if (currentRecipe != null && canMake()) + { + if (tickTime >= runTime) + { + currentRecipe = RollingMachineRecipe.instance + .findMatchingRecipe(craftMatrix, worldObj); + if (currentRecipe != null) + { + boolean hasCrafted = false; + if (inventory.getStackInSlot(0) == null) + { + inventory + .setInventorySlotContents(0, currentRecipe); + tickTime = 0; + hasCrafted = true; + } else + { + if (inventory.getStackInSlot(0).stackSize + + currentRecipe.stackSize <= currentRecipe + .getMaxStackSize()) + { + ItemStack stack = inventory.getStackInSlot(0); + stack.stackSize = stack.stackSize + + currentRecipe.stackSize; + inventory.setInventorySlotContents(0, stack); + tickTime = 0; + hasCrafted = true; + } + } + if (hasCrafted) + { + for (int i = 0; i < craftMatrix.getSizeInventory(); i++) + { + craftMatrix.decrStackSize(i, 1); + } + currentRecipe = null; + } + } + } + } + if (currentRecipe != null) + { + if (energy.canUseEnergy(euTick) && tickTime < runTime) + { + tickTime++; + } + } + if (currentRecipe == null) + { + tickTime = 0; + } + } else + { + currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe( + craftMatrix, worldObj); + if (currentRecipe != null) + { + inventory.setInventorySlotContents(1, currentRecipe); + } else + { + inventory.setInventorySlotContents(1, null); + } + } + } - public boolean canMake() { - if (RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, worldObj) == null){ - return false; - } - return true; - } + public boolean canMake() + { + if (RollingMachineRecipe.instance.findMatchingRecipe(craftMatrix, + worldObj) == null) + { + return false; + } + return true; + } - @Override - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { - return false; - } + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return false; + } - @Override - public short getFacing() { - return 0; - } + @Override + public short getFacing() + { + return 0; + } - @Override - public void setFacing(short facing) { - } + @Override + public void setFacing(short facing) + { + } - @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) { - return true; - } + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + return true; + } - @Override - public float getWrenchDropRate() { - return 1.0F; - } + @Override + public float getWrenchDropRate() + { + return 1.0F; + } - @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { - return new ItemStack(ModBlocks.RollingMachine, 1); - } + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return new ItemStack(ModBlocks.RollingMachine, 1); + } - @Override - public void readFromNBT(NBTTagCompound tagCompound) { - super.readFromNBT(tagCompound); - inventory.readFromNBT(tagCompound); - ItemUtils.readInvFromNBT(craftMatrix, "Crafting", tagCompound); - isRunning = tagCompound.getBoolean("isRunning"); - tickTime = tagCompound.getInteger("tickTime"); - } + @Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + inventory.readFromNBT(tagCompound); + ItemUtils.readInvFromNBT(craftMatrix, "Crafting", tagCompound); + isRunning = tagCompound.getBoolean("isRunning"); + tickTime = tagCompound.getInteger("tickTime"); + } - @Override - public void writeToNBT(NBTTagCompound tagCompound) { - super.writeToNBT(tagCompound); - inventory.writeToNBT(tagCompound); - ItemUtils.writeInvToNBT(craftMatrix, "Crafting", tagCompound); - writeUpdateToNBT(tagCompound); - } + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + inventory.writeToNBT(tagCompound); + ItemUtils.writeInvToNBT(craftMatrix, "Crafting", tagCompound); + writeUpdateToNBT(tagCompound); + } - public void writeUpdateToNBT(NBTTagCompound tagCompound) { - tagCompound.setBoolean("isRunning", isRunning); - tagCompound.setInteger("tickTime", tickTime); - } + public void writeUpdateToNBT(NBTTagCompound tagCompound) + { + tagCompound.setBoolean("isRunning", isRunning); + tagCompound.setInteger("tickTime", tickTime); + } } diff --git a/src/main/java/techreborn/tiles/TileThermalGenerator.java b/src/main/java/techreborn/tiles/TileThermalGenerator.java index 812af82d6..baefdfaa7 100644 --- a/src/main/java/techreborn/tiles/TileThermalGenerator.java +++ b/src/main/java/techreborn/tiles/TileThermalGenerator.java @@ -11,201 +11,253 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; import techreborn.util.FluidUtils; import techreborn.util.Inventory; import techreborn.util.Tank; -public class TileThermalGenerator extends TileEntity implements IWrenchable, IFluidHandler, IInventory { +public class TileThermalGenerator extends TileEntity implements IWrenchable, + IFluidHandler, IInventory { - public Tank tank = new Tank("TileThermalGenerator", FluidContainerRegistry.BUCKET_VOLUME * 10, this); - public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64); - public BasicSource energySource; - public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput; + public Tank tank = new Tank("TileThermalGenerator", + FluidContainerRegistry.BUCKET_VOLUME * 10, this); + public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64); + public BasicSource energySource; + public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput; - public TileThermalGenerator() { - this.energySource = new BasicSource(this, ConfigTechReborn.ThermalGeneratorCharge, ConfigTechReborn.ThermalGeneratorTier); - } + public TileThermalGenerator() + { + this.energySource = new BasicSource(this, + ConfigTechReborn.ThermalGeneratorCharge, + ConfigTechReborn.ThermalGeneratorTier); + } - @Override - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { - return false; - } + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) + { + return false; + } - @Override - public short getFacing() { - return 0; - } + @Override + public short getFacing() + { + return 0; + } - @Override - public void setFacing(short facing) { - } + @Override + public void setFacing(short facing) + { + } - @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) { - return true; - } + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) + { + return true; + } - @Override - public float getWrenchDropRate() { - return 1.0F; - } + @Override + public float getWrenchDropRate() + { + return 1.0F; + } - @Override - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { - return new ItemStack(ModBlocks.thermalGenerator, 1); - } + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) + { + return new ItemStack(ModBlocks.thermalGenerator, 1); + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - return tank.fill(resource, doFill); - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) + { + return tank.fill(resource, doFill); + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - return tank.drain(resource.amount, doDrain); - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, + boolean doDrain) + { + return tank.drain(resource.amount, doDrain); + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return tank.drain(maxDrain, doDrain); - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) + { + return tank.drain(maxDrain, doDrain); + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) { - if (fluid != null) { - if (FluidRegistry.getFluidName(fluid.getID()).contentEquals("lava")) { - return true; - } - } - return false; - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) + { + if (fluid != null) + { + if (FluidRegistry.getFluidName(fluid.getID()).contentEquals("lava")) + { + return true; + } + } + return false; + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) { - return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) + { + return tank.getFluid() == null || tank.getFluid().getFluid() == fluid; + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) { - return getTankInfo(from); - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) + { + return getTankInfo(from); + } - @Override - public void readFromNBT(NBTTagCompound tagCompound) { - super.readFromNBT(tagCompound); - tank.readFromNBT(tagCompound); - inventory.readFromNBT(tagCompound); - energySource.readFromNBT(tagCompound); - } + @Override + public void readFromNBT(NBTTagCompound tagCompound) + { + super.readFromNBT(tagCompound); + tank.readFromNBT(tagCompound); + inventory.readFromNBT(tagCompound); + energySource.readFromNBT(tagCompound); + } - @Override - public void writeToNBT(NBTTagCompound tagCompound) { - super.writeToNBT(tagCompound); - tank.writeToNBT(tagCompound); - inventory.writeToNBT(tagCompound); - energySource.writeToNBT(tagCompound); - } + @Override + public void writeToNBT(NBTTagCompound tagCompound) + { + super.writeToNBT(tagCompound); + tank.writeToNBT(tagCompound); + inventory.writeToNBT(tagCompound); + energySource.writeToNBT(tagCompound); + } - public Packet getDescriptionPacket() { - NBTTagCompound nbtTag = new NBTTagCompound(); - writeToNBT(nbtTag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); - } + public Packet getDescriptionPacket() + { + NBTTagCompound nbtTag = new NBTTagCompound(); + writeToNBT(nbtTag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, + this.zCoord, 1, nbtTag); + } - @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { - worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); - readFromNBT(packet.func_148857_g()); - } + @Override + public void onDataPacket(NetworkManager net, + S35PacketUpdateTileEntity packet) + { + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, + yCoord, zCoord); + readFromNBT(packet.func_148857_g()); + } - @Override - public void updateEntity() { - super.updateEntity(); - FluidUtils.drainContainers(this, inventory, 0, 1); - energySource.updateEntity(); - if (tank.getFluidAmount() > 0 && energySource.getCapacity() - energySource.getEnergyStored() >= euTick) { - tank.drain(1, true); - energySource.addEnergy(euTick); - } - if (tank.getFluidType() != null && getStackInSlot(2) == null) { - inventory.setInventorySlotContents(2, new ItemStack(tank.getFluidType().getBlock())); - } else if (tank.getFluidType() == null && getStackInSlot(2) != null) { - setInventorySlotContents(2, null); - } - } + @Override + public void updateEntity() + { + super.updateEntity(); + FluidUtils.drainContainers(this, inventory, 0, 1); + energySource.updateEntity(); + if (tank.getFluidAmount() > 0 + && energySource.getCapacity() - energySource.getEnergyStored() >= euTick) + { + tank.drain(1, true); + energySource.addEnergy(euTick); + } + if (tank.getFluidType() != null && getStackInSlot(2) == null) + { + inventory.setInventorySlotContents(2, new ItemStack(tank + .getFluidType().getBlock())); + } else if (tank.getFluidType() == null && getStackInSlot(2) != null) + { + setInventorySlotContents(2, null); + } + } - @Override - public int getSizeInventory() { - return inventory.getSizeInventory(); - } + @Override + public int getSizeInventory() + { + return inventory.getSizeInventory(); + } - @Override - public ItemStack getStackInSlot(int p_70301_1_) { - return inventory.getStackInSlot(p_70301_1_); - } + @Override + public ItemStack getStackInSlot(int p_70301_1_) + { + return inventory.getStackInSlot(p_70301_1_); + } - @Override - public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { - return inventory.decrStackSize(p_70298_1_, p_70298_2_); - } + @Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) + { + return inventory.decrStackSize(p_70298_1_, p_70298_2_); + } - @Override - public ItemStack getStackInSlotOnClosing(int p_70304_1_) { - return inventory.getStackInSlotOnClosing(p_70304_1_); - } + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) + { + return inventory.getStackInSlotOnClosing(p_70304_1_); + } - @Override - public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { - inventory.setInventorySlotContents(p_70299_1_, p_70299_2_); - } + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) + { + inventory.setInventorySlotContents(p_70299_1_, p_70299_2_); + } - @Override - public String getInventoryName() { - return inventory.getInventoryName(); - } + @Override + public String getInventoryName() + { + return inventory.getInventoryName(); + } - @Override - public boolean hasCustomInventoryName() { - return inventory.hasCustomInventoryName(); - } + @Override + public boolean hasCustomInventoryName() + { + return inventory.hasCustomInventoryName(); + } - @Override - public int getInventoryStackLimit() { - return inventory.getInventoryStackLimit(); - } + @Override + public int getInventoryStackLimit() + { + return inventory.getInventoryStackLimit(); + } - @Override - public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { - return inventory.isUseableByPlayer(p_70300_1_); - } + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) + { + return inventory.isUseableByPlayer(p_70300_1_); + } - @Override - public void openInventory() { - inventory.openInventory(); - } + @Override + public void openInventory() + { + inventory.openInventory(); + } - @Override - public void closeInventory() { - inventory.closeInventory(); - } + @Override + public void closeInventory() + { + inventory.closeInventory(); + } - @Override - public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_); - } + @Override + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) + { + return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_); + } - @Override - public void onChunkUnload() { - energySource.onChunkUnload(); - } + @Override + public void onChunkUnload() + { + energySource.onChunkUnload(); + } - @Override - public void invalidate() { - energySource.invalidate(); - super.invalidate(); - } + @Override + public void invalidate() + { + energySource.invalidate(); + super.invalidate(); + } } diff --git a/src/main/java/techreborn/util/CraftingHelper.java b/src/main/java/techreborn/util/CraftingHelper.java index 35a20a9ff..be701c51d 100644 --- a/src/main/java/techreborn/util/CraftingHelper.java +++ b/src/main/java/techreborn/util/CraftingHelper.java @@ -7,12 +7,18 @@ import net.minecraftforge.oredict.ShapelessOreRecipe; public class CraftingHelper { - public static void addShapedOreRecipe(ItemStack outputItemStack, Object... objectInputs) { - CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(outputItemStack, objectInputs)); - } + public static void addShapedOreRecipe(ItemStack outputItemStack, + Object... objectInputs) + { + CraftingManager.getInstance().getRecipeList() + .add(new ShapedOreRecipe(outputItemStack, objectInputs)); + } - public static void addShapelessOreRecipe(ItemStack outputItemStack, Object... objectInputs) { - CraftingManager.getInstance().getRecipeList().add(new ShapelessOreRecipe(outputItemStack, objectInputs)); - } + public static void addShapelessOreRecipe(ItemStack outputItemStack, + Object... objectInputs) + { + CraftingManager.getInstance().getRecipeList() + .add(new ShapelessOreRecipe(outputItemStack, objectInputs)); + } } diff --git a/src/main/java/techreborn/util/FluidUtils.java b/src/main/java/techreborn/util/FluidUtils.java index 599e0bda4..64c009a96 100644 --- a/src/main/java/techreborn/util/FluidUtils.java +++ b/src/main/java/techreborn/util/FluidUtils.java @@ -10,57 +10,80 @@ import net.minecraftforge.fluids.IFluidHandler; public class FluidUtils { - public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) { - ItemStack input = inv.getStackInSlot(inputSlot); - ItemStack output = inv.getStackInSlot(outputSlot); + public static boolean drainContainers(IFluidHandler fluidHandler, + IInventory inv, int inputSlot, int outputSlot) + { + ItemStack input = inv.getStackInSlot(inputSlot); + ItemStack output = inv.getStackInSlot(outputSlot); - if (input != null) { - FluidStack fluidInContainer = getFluidStackInContainer(input); - ItemStack emptyItem = input.getItem().getContainerItem(input); - if (fluidInContainer != null && (emptyItem == null || output == null || (output.stackSize < output.getMaxStackSize() && ItemUtils.isItemEqual(output, emptyItem, true, true)))) { - int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false); - if (used >= fluidInContainer.amount) { - fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true); - if (emptyItem != null) - if (output == null) - inv.setInventorySlotContents(outputSlot, emptyItem); - else - output.stackSize++; - inv.decrStackSize(inputSlot, 1); - return true; - } - } - } - return false; - } + if (input != null) + { + FluidStack fluidInContainer = getFluidStackInContainer(input); + ItemStack emptyItem = input.getItem().getContainerItem(input); + if (fluidInContainer != null + && (emptyItem == null || output == null || (output.stackSize < output + .getMaxStackSize() && ItemUtils.isItemEqual(output, + emptyItem, true, true)))) + { + int used = fluidHandler.fill(ForgeDirection.UNKNOWN, + fluidInContainer, false); + if (used >= fluidInContainer.amount) + { + fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, + true); + if (emptyItem != null) + if (output == null) + inv.setInventorySlotContents(outputSlot, emptyItem); + else + output.stackSize++; + inv.decrStackSize(inputSlot, 1); + return true; + } + } + } + return false; + } - public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) { - ItemStack input = inv.getStackInSlot(inputSlot); - ItemStack output = inv.getStackInSlot(outputSlot); - ItemStack filled = getFilledContainer(fluidToFill, input); - if (filled != null && (output == null || (output.stackSize < output.getMaxStackSize() && ItemUtils.isItemEqual(filled, output, true, true)))) { - FluidStack fluidInContainer = getFluidStackInContainer(filled); - FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, false); - if (drain != null && drain.amount == fluidInContainer.amount) { - fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true); - if (output == null) - inv.setInventorySlotContents(outputSlot, filled); - else - output.stackSize++; - inv.decrStackSize(inputSlot, 1); - return true; - } - } - return false; - } + public static boolean fillContainers(IFluidHandler fluidHandler, + IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) + { + ItemStack input = inv.getStackInSlot(inputSlot); + ItemStack output = inv.getStackInSlot(outputSlot); + ItemStack filled = getFilledContainer(fluidToFill, input); + if (filled != null + && (output == null || (output.stackSize < output + .getMaxStackSize() && ItemUtils.isItemEqual(filled, + output, true, true)))) + { + FluidStack fluidInContainer = getFluidStackInContainer(filled); + FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, + fluidInContainer, false); + if (drain != null && drain.amount == fluidInContainer.amount) + { + fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, + true); + if (output == null) + inv.setInventorySlotContents(outputSlot, filled); + else + output.stackSize++; + inv.decrStackSize(inputSlot, 1); + return true; + } + } + return false; + } - public static FluidStack getFluidStackInContainer(ItemStack stack) { - return FluidContainerRegistry.getFluidForFilledItem(stack); - } + public static FluidStack getFluidStackInContainer(ItemStack stack) + { + return FluidContainerRegistry.getFluidForFilledItem(stack); + } - public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) { - if (fluid == null || empty == null) return null; - return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, Integer.MAX_VALUE), empty); - } + public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) + { + if (fluid == null || empty == null) + return null; + return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, + Integer.MAX_VALUE), empty); + } } diff --git a/src/main/java/techreborn/util/Inventory.java b/src/main/java/techreborn/util/Inventory.java index c898613a8..685d5cb58 100644 --- a/src/main/java/techreborn/util/Inventory.java +++ b/src/main/java/techreborn/util/Inventory.java @@ -1,6 +1,5 @@ package techreborn.util; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -11,148 +10,181 @@ import net.minecraftforge.common.util.Constants; public class Inventory implements IInventory { - private final ItemStack[] contents; - private final String name; - private final int stackLimit; - private TileEntity tile = new TileEntity(); + private final ItemStack[] contents; + private final String name; + private final int stackLimit; + private TileEntity tile = new TileEntity(); - public Inventory(int size, String invName, int invStackLimit) { - contents = new ItemStack[size]; - name = invName; - stackLimit = invStackLimit; - } + public Inventory(int size, String invName, int invStackLimit) + { + contents = new ItemStack[size]; + name = invName; + stackLimit = invStackLimit; + } - @Override - public int getSizeInventory() { - return contents.length; - } + @Override + public int getSizeInventory() + { + return contents.length; + } - @Override - public ItemStack getStackInSlot(int slotId) { - return contents[slotId]; - } + @Override + public ItemStack getStackInSlot(int slotId) + { + return contents[slotId]; + } - @Override - public ItemStack decrStackSize(int slotId, int count) { - if (slotId < contents.length && contents[slotId] != null) { - if (contents[slotId].stackSize > count) { - ItemStack result = contents[slotId].splitStack(count); - markDirty(); - return result; - } - ItemStack stack = contents[slotId]; - setInventorySlotContents(slotId, null); - return stack; - } - return null; - } + @Override + public ItemStack decrStackSize(int slotId, int count) + { + if (slotId < contents.length && contents[slotId] != null) + { + if (contents[slotId].stackSize > count) + { + ItemStack result = contents[slotId].splitStack(count); + markDirty(); + return result; + } + ItemStack stack = contents[slotId]; + setInventorySlotContents(slotId, null); + return stack; + } + return null; + } - @Override - public void setInventorySlotContents(int slotId, ItemStack itemstack) { - if (slotId >= contents.length) { - return; - } - contents[slotId] = itemstack; + @Override + public void setInventorySlotContents(int slotId, ItemStack itemstack) + { + if (slotId >= contents.length) + { + return; + } + contents[slotId] = itemstack; - if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { - itemstack.stackSize = this.getInventoryStackLimit(); - } - markDirty(); - } + if (itemstack != null + && itemstack.stackSize > this.getInventoryStackLimit()) + { + itemstack.stackSize = this.getInventoryStackLimit(); + } + markDirty(); + } - @Override - public String getInventoryName() { - return name; - } + @Override + public String getInventoryName() + { + return name; + } - @Override - public int getInventoryStackLimit() { - return stackLimit; - } + @Override + public int getInventoryStackLimit() + { + return stackLimit; + } - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return true; - } + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) + { + return true; + } - @Override - public void openInventory() { - } + @Override + public void openInventory() + { + } - @Override - public void closeInventory() { - } + @Override + public void closeInventory() + { + } + public void readFromNBT(NBTTagCompound data) + { + readFromNBT(data, "Items"); + } - public void readFromNBT(NBTTagCompound data) { - readFromNBT(data, "Items"); - } + public void readFromNBT(NBTTagCompound data, String tag) + { + NBTTagList nbttaglist = data + .getTagList(tag, Constants.NBT.TAG_COMPOUND); - public void readFromNBT(NBTTagCompound data, String tag) { - NBTTagList nbttaglist = data.getTagList(tag, Constants.NBT.TAG_COMPOUND); + for (int j = 0; j < nbttaglist.tagCount(); ++j) + { + NBTTagCompound slot = nbttaglist.getCompoundTagAt(j); + int index; + if (slot.hasKey("index")) + { + index = slot.getInteger("index"); + } else + { + index = slot.getByte("Slot"); + } + if (index >= 0 && index < contents.length) + { + setInventorySlotContents(index, + ItemStack.loadItemStackFromNBT(slot)); + } + } + } - for (int j = 0; j < nbttaglist.tagCount(); ++j) { - NBTTagCompound slot = nbttaglist.getCompoundTagAt(j); - int index; - if (slot.hasKey("index")) { - index = slot.getInteger("index"); - } else { - index = slot.getByte("Slot"); - } - if (index >= 0 && index < contents.length) { - setInventorySlotContents(index, ItemStack.loadItemStackFromNBT(slot)); - } - } - } + public void writeToNBT(NBTTagCompound data) + { + writeToNBT(data, "Items"); + } - public void writeToNBT(NBTTagCompound data) { - writeToNBT(data, "Items"); - } + public void writeToNBT(NBTTagCompound data, String tag) + { + NBTTagList slots = new NBTTagList(); + for (byte index = 0; index < contents.length; ++index) + { + if (contents[index] != null && contents[index].stackSize > 0) + { + NBTTagCompound slot = new NBTTagCompound(); + slots.appendTag(slot); + slot.setByte("Slot", index); + contents[index].writeToNBT(slot); + } + } + data.setTag(tag, slots); + } - public void writeToNBT(NBTTagCompound data, String tag) { - NBTTagList slots = new NBTTagList(); - for (byte index = 0; index < contents.length; ++index) { - if (contents[index] != null && contents[index].stackSize > 0) { - NBTTagCompound slot = new NBTTagCompound(); - slots.appendTag(slot); - slot.setByte("Slot", index); - contents[index].writeToNBT(slot); - } - } - data.setTag(tag, slots); - } + public void setTile(TileEntity tileEntity) + { + tile = tileEntity; + } - public void setTile(TileEntity tileEntity) { - tile = tileEntity; - } + @Override + public ItemStack getStackInSlotOnClosing(int slotId) + { + if (this.contents[slotId] == null) + { + return null; + } - @Override - public ItemStack getStackInSlotOnClosing(int slotId) { - if (this.contents[slotId] == null) { - return null; - } + ItemStack stackToTake = this.contents[slotId]; + setInventorySlotContents(slotId, null); + return stackToTake; + } - ItemStack stackToTake = this.contents[slotId]; - setInventorySlotContents(slotId, null); - return stackToTake; - } + public ItemStack[] getStacks() + { + return contents; + } - public ItemStack[] getStacks() { - return contents; - } + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) + { + return true; + } - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; - } + @Override + public boolean hasCustomInventoryName() + { + return false; + } - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void markDirty() { - tile.markDirty(); - } + @Override + public void markDirty() + { + tile.markDirty(); + } } diff --git a/src/main/java/techreborn/util/ItemUtils.java b/src/main/java/techreborn/util/ItemUtils.java index cefea15ec..476ed1b1d 100644 --- a/src/main/java/techreborn/util/ItemUtils.java +++ b/src/main/java/techreborn/util/ItemUtils.java @@ -10,65 +10,80 @@ import net.minecraftforge.oredict.OreDictionary; * Created by mark on 12/04/15. */ public class ItemUtils { - public static boolean isItemEqual(final ItemStack a, final ItemStack b, final boolean matchDamage, final boolean matchNBT) { - if (a == null || b == null) - return false; - if (a.getItem() != b.getItem()) - return false; - if (matchNBT && !ItemStack.areItemStackTagsEqual(a, b)) - return false; - if (matchDamage && a.getHasSubtypes()) { - if (isWildcard(a) || isWildcard(b)) - return true; - if (a.getItemDamage() != b.getItemDamage()) - return false; - } - return true; - } + public static boolean isItemEqual(final ItemStack a, final ItemStack b, + final boolean matchDamage, final boolean matchNBT) + { + if (a == null || b == null) + return false; + if (a.getItem() != b.getItem()) + return false; + if (matchNBT && !ItemStack.areItemStackTagsEqual(a, b)) + return false; + if (matchDamage && a.getHasSubtypes()) + { + if (isWildcard(a) || isWildcard(b)) + return true; + if (a.getItemDamage() != b.getItemDamage()) + return false; + } + return true; + } - public static boolean isWildcard(ItemStack stack) { - return isWildcard(stack.getItemDamage()); - } + public static boolean isWildcard(ItemStack stack) + { + return isWildcard(stack.getItemDamage()); + } - public static boolean isWildcard(int damage) { - return damage == -1 || damage == OreDictionary.WILDCARD_VALUE; - } + public static boolean isWildcard(int damage) + { + return damage == -1 || damage == OreDictionary.WILDCARD_VALUE; + } - public static void writeInvToNBT(IInventory inv, String tag, NBTTagCompound data) { - NBTTagList list = new NBTTagList(); - for (byte slot = 0; slot < inv.getSizeInventory(); slot++) { - ItemStack stack = inv.getStackInSlot(slot); - if (stack != null) { - NBTTagCompound itemTag = new NBTTagCompound(); - itemTag.setByte("Slot", slot); - writeItemToNBT(stack, itemTag); - list.appendTag(itemTag); - } - } - data.setTag(tag, list); - } + public static void writeInvToNBT(IInventory inv, String tag, + NBTTagCompound data) + { + NBTTagList list = new NBTTagList(); + for (byte slot = 0; slot < inv.getSizeInventory(); slot++) + { + ItemStack stack = inv.getStackInSlot(slot); + if (stack != null) + { + NBTTagCompound itemTag = new NBTTagCompound(); + itemTag.setByte("Slot", slot); + writeItemToNBT(stack, itemTag); + list.appendTag(itemTag); + } + } + data.setTag(tag, list); + } - public static void readInvFromNBT(IInventory inv, String tag, NBTTagCompound data) { - NBTTagList list = data.getTagList(tag, 10); - for (byte entry = 0; entry < list.tagCount(); entry++) { - NBTTagCompound itemTag = list.getCompoundTagAt(entry); - int slot = itemTag.getByte("Slot"); - if (slot >= 0 && slot < inv.getSizeInventory()) { - ItemStack stack = readItemFromNBT(itemTag); - inv.setInventorySlotContents(slot, stack); - } - } - } + public static void readInvFromNBT(IInventory inv, String tag, + NBTTagCompound data) + { + NBTTagList list = data.getTagList(tag, 10); + for (byte entry = 0; entry < list.tagCount(); entry++) + { + NBTTagCompound itemTag = list.getCompoundTagAt(entry); + int slot = itemTag.getByte("Slot"); + if (slot >= 0 && slot < inv.getSizeInventory()) + { + ItemStack stack = readItemFromNBT(itemTag); + inv.setInventorySlotContents(slot, stack); + } + } + } - public static void writeItemToNBT(ItemStack stack, NBTTagCompound data) { - if (stack == null || stack.stackSize <= 0) - return; - if (stack.stackSize > 127) - stack.stackSize = 127; - stack.writeToNBT(data); - } + public static void writeItemToNBT(ItemStack stack, NBTTagCompound data) + { + if (stack == null || stack.stackSize <= 0) + return; + if (stack.stackSize > 127) + stack.stackSize = 127; + stack.writeToNBT(data); + } - public static ItemStack readItemFromNBT(NBTTagCompound data) { - return ItemStack.loadItemStackFromNBT(data); - } + public static ItemStack readItemFromNBT(NBTTagCompound data) + { + return ItemStack.loadItemStackFromNBT(data); + } } diff --git a/src/main/java/techreborn/util/LogHelper.java b/src/main/java/techreborn/util/LogHelper.java index 81fec58e9..815d9cf28 100644 --- a/src/main/java/techreborn/util/LogHelper.java +++ b/src/main/java/techreborn/util/LogHelper.java @@ -1,45 +1,55 @@ package techreborn.util; -import cpw.mods.fml.common.FMLLog; import org.apache.logging.log4j.Level; + import techreborn.lib.ModInfo; +import cpw.mods.fml.common.FMLLog; public class LogHelper { - public static void log(Level logLevel, Object object) { - FMLLog.log(ModInfo.MOD_NAME, logLevel, String.valueOf(object)); - } + public static void log(Level logLevel, Object object) + { + FMLLog.log(ModInfo.MOD_NAME, logLevel, String.valueOf(object)); + } - public static void all(Object object) { - log(Level.ALL, object); - } + public static void all(Object object) + { + log(Level.ALL, object); + } - public static void debug(Object object) { - log(Level.DEBUG, object); - } + public static void debug(Object object) + { + log(Level.DEBUG, object); + } - public static void error(Object object) { - log(Level.ERROR, object); - } + public static void error(Object object) + { + log(Level.ERROR, object); + } - public static void fatal(Object object) { - log(Level.FATAL, object); - } + public static void fatal(Object object) + { + log(Level.FATAL, object); + } - public static void info(Object object) { - log(Level.INFO, object); - } + public static void info(Object object) + { + log(Level.INFO, object); + } - public static void off(Object object) { - log(Level.OFF, object); - } + public static void off(Object object) + { + log(Level.OFF, object); + } - public static void trace(Object object) { - log(Level.TRACE, object); - } + public static void trace(Object object) + { + log(Level.TRACE, object); + } - public static void warn(Object object) { - log(Level.WARN, object); - } + public static void warn(Object object) + { + log(Level.WARN, object); + } } diff --git a/src/main/java/techreborn/util/RecipeRemover.java b/src/main/java/techreborn/util/RecipeRemover.java index 527344d8e..5ede061ba 100644 --- a/src/main/java/techreborn/util/RecipeRemover.java +++ b/src/main/java/techreborn/util/RecipeRemover.java @@ -1,41 +1,49 @@ package techreborn.util; +import java.util.List; + import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.ShapedRecipes; -import java.util.List; - public class RecipeRemover { - public static void removeShapedRecipes(List removelist) { - for (ItemStack stack : removelist) - removeShapedRecipe(stack); - } + public static void removeShapedRecipes(List removelist) + { + for (ItemStack stack : removelist) + removeShapedRecipe(stack); + } - public static void removeAnyRecipe(ItemStack resultItem) { - List recipes = CraftingManager.getInstance().getRecipeList(); - for (int i = 0; i < recipes.size(); i++) { - IRecipe tmpRecipe = recipes.get(i); - ItemStack recipeResult = tmpRecipe.getRecipeOutput(); - if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) { - recipes.remove(i--); - } - } - } + public static void removeAnyRecipe(ItemStack resultItem) + { + List recipes = CraftingManager.getInstance().getRecipeList(); + for (int i = 0; i < recipes.size(); i++) + { + IRecipe tmpRecipe = recipes.get(i); + ItemStack recipeResult = tmpRecipe.getRecipeOutput(); + if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) + { + recipes.remove(i--); + } + } + } - public static void removeShapedRecipe(ItemStack resultItem) { - List recipes = CraftingManager.getInstance().getRecipeList(); - for (int i = 0; i < recipes.size(); i++) { - IRecipe tmpRecipe = recipes.get(i); - if (tmpRecipe instanceof ShapedRecipes) { - ShapedRecipes recipe = (ShapedRecipes) tmpRecipe; - ItemStack recipeResult = recipe.getRecipeOutput(); + public static void removeShapedRecipe(ItemStack resultItem) + { + List recipes = CraftingManager.getInstance().getRecipeList(); + for (int i = 0; i < recipes.size(); i++) + { + IRecipe tmpRecipe = recipes.get(i); + if (tmpRecipe instanceof ShapedRecipes) + { + ShapedRecipes recipe = (ShapedRecipes) tmpRecipe; + ItemStack recipeResult = recipe.getRecipeOutput(); - if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) { - recipes.remove(i++); - } - } - } - } + if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) + { + recipes.remove(i++); + } + } + } + } } diff --git a/src/main/java/techreborn/util/Tank.java b/src/main/java/techreborn/util/Tank.java index 876e4f7f7..2c45ecf7e 100644 --- a/src/main/java/techreborn/util/Tank.java +++ b/src/main/java/techreborn/util/Tank.java @@ -1,6 +1,5 @@ package techreborn.util; - import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; @@ -8,46 +7,51 @@ import net.minecraftforge.fluids.FluidTank; public class Tank extends FluidTank { + private final String name; - private final String name; + public Tank(String name, int capacity, TileEntity tile) + { + super(capacity); + this.name = name; + this.tile = tile; + } - public Tank(String name, int capacity, TileEntity tile) { - super(capacity); - this.name = name; - this.tile = tile; - } + public boolean isEmpty() + { + return getFluid() == null || getFluid().amount <= 0; + } - public boolean isEmpty() { - return getFluid() == null || getFluid().amount <= 0; - } + public boolean isFull() + { + return getFluid() != null && getFluid().amount >= getCapacity(); + } - public boolean isFull() { - return getFluid() != null && getFluid().amount >= getCapacity(); - } + public Fluid getFluidType() + { + return getFluid() != null ? getFluid().getFluid() : null; + } - public Fluid getFluidType() { - return getFluid() != null ? getFluid().getFluid() : null; - } + @Override + public final NBTTagCompound writeToNBT(NBTTagCompound nbt) + { + NBTTagCompound tankData = new NBTTagCompound(); + super.writeToNBT(tankData); + nbt.setTag(name, tankData); + return nbt; + } - @Override - public final NBTTagCompound writeToNBT(NBTTagCompound nbt) { - NBTTagCompound tankData = new NBTTagCompound(); - super.writeToNBT(tankData); - nbt.setTag(name, tankData); - return nbt; - } - - @Override - public final FluidTank readFromNBT(NBTTagCompound nbt) { - if (nbt.hasKey(name)) { - // allow to read empty tanks - setFluid(null); - - NBTTagCompound tankData = nbt.getCompoundTag(name); - super.readFromNBT(tankData); - } - return this; - } + @Override + public final FluidTank readFromNBT(NBTTagCompound nbt) + { + if (nbt.hasKey(name)) + { + // allow to read empty tanks + setFluid(null); + NBTTagCompound tankData = nbt.getCompoundTag(name); + super.readFromNBT(tankData); + } + return this; + } } diff --git a/src/main/java/techreborn/util/TorchHelper.java b/src/main/java/techreborn/util/TorchHelper.java index 60dd4e2a6..0b23365e1 100644 --- a/src/main/java/techreborn/util/TorchHelper.java +++ b/src/main/java/techreborn/util/TorchHelper.java @@ -9,24 +9,36 @@ import net.minecraftforge.event.ForgeEventFactory; public class TorchHelper { - public static boolean placeTorch(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { - for (int i = 0; i < player.inventory.mainInventory.length; i++) { - ItemStack torchStack = player.inventory.mainInventory[i]; - if (torchStack == null || !torchStack.getUnlocalizedName().toLowerCase().contains("torch")) continue; - Item item = torchStack.getItem(); - if (!(item instanceof ItemBlock)) continue; - int oldMeta = torchStack.getItemDamage(); - int oldSize = torchStack.stackSize; - boolean result = torchStack.tryPlaceItemIntoWorld(player, world, x, y, z, side, xOffset, yOffset, zOffset); - if (player.capabilities.isCreativeMode) { - torchStack.setItemDamage(oldMeta); - torchStack.stackSize = oldSize; - } else if (torchStack.stackSize <= 0) { - ForgeEventFactory.onPlayerDestroyItem(player, torchStack); - player.inventory.mainInventory[i] = null; - } - if (result) return true; - } - return false; - } + public static boolean placeTorch(ItemStack stack, EntityPlayer player, + World world, int x, int y, int z, int side, float xOffset, + float yOffset, float zOffset) + { + for (int i = 0; i < player.inventory.mainInventory.length; i++) + { + ItemStack torchStack = player.inventory.mainInventory[i]; + if (torchStack == null + || !torchStack.getUnlocalizedName().toLowerCase() + .contains("torch")) + continue; + Item item = torchStack.getItem(); + if (!(item instanceof ItemBlock)) + continue; + int oldMeta = torchStack.getItemDamage(); + int oldSize = torchStack.stackSize; + boolean result = torchStack.tryPlaceItemIntoWorld(player, world, x, + y, z, side, xOffset, yOffset, zOffset); + if (player.capabilities.isCreativeMode) + { + torchStack.setItemDamage(oldMeta); + torchStack.stackSize = oldSize; + } else if (torchStack.stackSize <= 0) + { + ForgeEventFactory.onPlayerDestroyItem(player, torchStack); + player.inventory.mainInventory[i] = null; + } + if (result) + return true; + } + return false; + } } diff --git a/src/main/java/techreborn/world/TROreGen.java b/src/main/java/techreborn/world/TROreGen.java index 3d8a0ad0f..587e64eeb 100644 --- a/src/main/java/techreborn/world/TROreGen.java +++ b/src/main/java/techreborn/world/TROreGen.java @@ -1,6 +1,7 @@ package techreborn.world; -import cpw.mods.fml.common.IWorldGenerator; +import java.util.Random; + import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; @@ -8,202 +9,247 @@ import net.minecraft.world.gen.feature.WorldGenMinable; import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; import techreborn.util.LogHelper; - -import java.util.Random; +import cpw.mods.fml.common.IWorldGenerator; public class TROreGen implements IWorldGenerator { - public static ConfigTechReborn config; + public static ConfigTechReborn config; - WorldGenMinable oreGalena; - WorldGenMinable oreIridium; - WorldGenMinable oreRuby; - WorldGenMinable oreSapphire; - WorldGenMinable oreBauxite; - WorldGenMinable orePyrite; - WorldGenMinable oreCinnabar; - WorldGenMinable oreSphalerite; - WorldGenMinable oreTungston; - WorldGenMinable oreSheldonite; - WorldGenMinable oreOlivine; - WorldGenMinable oreSodalite; - WorldGenMinable oreCopper; - WorldGenMinable oreTin; - WorldGenMinable oreLead; - WorldGenMinable oreSilver; + WorldGenMinable oreGalena; + WorldGenMinable oreIridium; + WorldGenMinable oreRuby; + WorldGenMinable oreSapphire; + WorldGenMinable oreBauxite; + WorldGenMinable orePyrite; + WorldGenMinable oreCinnabar; + WorldGenMinable oreSphalerite; + WorldGenMinable oreTungston; + WorldGenMinable oreSheldonite; + WorldGenMinable oreOlivine; + WorldGenMinable oreSodalite; + WorldGenMinable oreCopper; + WorldGenMinable oreTin; + WorldGenMinable oreLead; + WorldGenMinable oreSilver; - public TROreGen() { - //World - oreGalena = new WorldGenMinable(ModBlocks.ore, 0, 8, Blocks.stone); - oreIridium = new WorldGenMinable(ModBlocks.ore, 1, 2, Blocks.stone); - oreRuby = new WorldGenMinable(ModBlocks.ore, 2, 8, Blocks.stone); - oreSapphire = new WorldGenMinable(ModBlocks.ore, 3, 8, Blocks.stone); - oreBauxite = new WorldGenMinable(ModBlocks.ore, 4, 8, Blocks.stone); - oreCopper = new WorldGenMinable(ModBlocks.ore, 12, 8, Blocks.stone); - oreTin = new WorldGenMinable(ModBlocks.ore, 13, 8, Blocks.stone); - oreLead = new WorldGenMinable(ModBlocks.ore, 14, 8, Blocks.stone); - oreSilver = new WorldGenMinable(ModBlocks.ore, 15, 8, Blocks.stone); + public TROreGen() + { + // World + oreGalena = new WorldGenMinable(ModBlocks.ore, 0, 8, Blocks.stone); + oreIridium = new WorldGenMinable(ModBlocks.ore, 1, 2, Blocks.stone); + oreRuby = new WorldGenMinable(ModBlocks.ore, 2, 8, Blocks.stone); + oreSapphire = new WorldGenMinable(ModBlocks.ore, 3, 8, Blocks.stone); + oreBauxite = new WorldGenMinable(ModBlocks.ore, 4, 8, Blocks.stone); + oreCopper = new WorldGenMinable(ModBlocks.ore, 12, 8, Blocks.stone); + oreTin = new WorldGenMinable(ModBlocks.ore, 13, 8, Blocks.stone); + oreLead = new WorldGenMinable(ModBlocks.ore, 14, 8, Blocks.stone); + oreSilver = new WorldGenMinable(ModBlocks.ore, 15, 8, Blocks.stone); - //Nether - orePyrite = new WorldGenMinable(ModBlocks.ore, 5, 8, Blocks.netherrack); - oreCinnabar = new WorldGenMinable(ModBlocks.ore, 6, 8, Blocks.netherrack); - oreSphalerite = new WorldGenMinable(ModBlocks.ore, 7, 8, Blocks.netherrack); - //End - oreTungston = new WorldGenMinable(ModBlocks.ore, 8, 8, Blocks.end_stone); - oreSheldonite = new WorldGenMinable(ModBlocks.ore, 9, 8, Blocks.end_stone); - oreOlivine = new WorldGenMinable(ModBlocks.ore, 10, 8, Blocks.end_stone); - oreSodalite = new WorldGenMinable(ModBlocks.ore, 11, 8, Blocks.end_stone); - LogHelper.info("WorldGen Loaded"); - } + // Nether + orePyrite = new WorldGenMinable(ModBlocks.ore, 5, 8, Blocks.netherrack); + oreCinnabar = new WorldGenMinable(ModBlocks.ore, 6, 8, + Blocks.netherrack); + oreSphalerite = new WorldGenMinable(ModBlocks.ore, 7, 8, + Blocks.netherrack); + // End + oreTungston = new WorldGenMinable(ModBlocks.ore, 8, 8, Blocks.end_stone); + oreSheldonite = new WorldGenMinable(ModBlocks.ore, 9, 8, + Blocks.end_stone); + oreOlivine = new WorldGenMinable(ModBlocks.ore, 10, 8, Blocks.end_stone); + oreSodalite = new WorldGenMinable(ModBlocks.ore, 11, 8, + Blocks.end_stone); + LogHelper.info("WorldGen Loaded"); + } - @Override - public void generate(Random random, int xChunk, int zChunk, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { - if (world.provider.isSurfaceWorld()) { - generateUndergroundOres(random, xChunk * 16, zChunk * 16, world); - } else if (world.provider.isHellWorld) { - generateHellOres(random, xChunk * 16, zChunk * 16, world); - } else { - generateEndOres(random, xChunk * 16, zChunk * 16, world); - } + @Override + public void generate(Random random, int xChunk, int zChunk, World world, + IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + { + if (world.provider.isSurfaceWorld()) + { + generateUndergroundOres(random, xChunk * 16, zChunk * 16, world); + } else if (world.provider.isHellWorld) + { + generateHellOres(random, xChunk * 16, zChunk * 16, world); + } else + { + generateEndOres(random, xChunk * 16, zChunk * 16, world); + } - } + } - void generateUndergroundOres(Random random, int xChunk, int zChunk, World world) { - int xPos, yPos, zPos; - if (config.GalenaOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreGalena.generate(world, random, xPos, yPos, zPos); - } - } - if (config.IridiumOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreIridium.generate(world, random, xPos, yPos, zPos); - } - } - if (config.RubyOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreRuby.generate(world, random, xPos, yPos, zPos); - } - } - if (config.SapphireOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreSapphire.generate(world, random, xPos, yPos, zPos); - } - } - if (config.BauxiteOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreBauxite.generate(world, random, xPos, yPos, zPos); - } - } - if (config.CopperOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreCopper.generate(world, random, xPos, yPos, zPos); - } - } - if (config.TinOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreTin.generate(world, random, xPos, yPos, zPos); - } - } - if (config.LeadOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreLead.generate(world, random, xPos, yPos, zPos); - } - } - if (config.SilverOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreSilver.generate(world, random, xPos, yPos, zPos); - } - } - } + void generateUndergroundOres(Random random, int xChunk, int zChunk, + World world) + { + int xPos, yPos, zPos; + if (config.GalenaOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreGalena.generate(world, random, xPos, yPos, zPos); + } + } + if (config.IridiumOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreIridium.generate(world, random, xPos, yPos, zPos); + } + } + if (config.RubyOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreRuby.generate(world, random, xPos, yPos, zPos); + } + } + if (config.SapphireOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreSapphire.generate(world, random, xPos, yPos, zPos); + } + } + if (config.BauxiteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreBauxite.generate(world, random, xPos, yPos, zPos); + } + } + if (config.CopperOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreCopper.generate(world, random, xPos, yPos, zPos); + } + } + if (config.TinOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreTin.generate(world, random, xPos, yPos, zPos); + } + } + if (config.LeadOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreLead.generate(world, random, xPos, yPos, zPos); + } + } + if (config.SilverOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreSilver.generate(world, random, xPos, yPos, zPos); + } + } + } - void generateHellOres(Random random, int xChunk, int zChunk, World world) { - int xPos, yPos, zPos; - if (config.PyriteOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - orePyrite.generate(world, random, xPos, yPos, zPos); - } - } - if (config.CinnabarOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreCinnabar.generate(world, random, xPos, yPos, zPos); - } - } - if (config.SphaleriteOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreSphalerite.generate(world, random, xPos, yPos, zPos); - } - } - } + void generateHellOres(Random random, int xChunk, int zChunk, World world) + { + int xPos, yPos, zPos; + if (config.PyriteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + orePyrite.generate(world, random, xPos, yPos, zPos); + } + } + if (config.CinnabarOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreCinnabar.generate(world, random, xPos, yPos, zPos); + } + } + if (config.SphaleriteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreSphalerite.generate(world, random, xPos, yPos, zPos); + } + } + } - void generateEndOres(Random random, int xChunk, int zChunk, World world) { - int xPos, yPos, zPos; - if (config.TungstenOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreTungston.generate(world, random, xPos, yPos, zPos); - } - } - if (config.SheldoniteOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreSheldonite.generate(world, random, xPos, yPos, zPos); - } - } - if (config.OlivineOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreOlivine.generate(world, random, xPos, yPos, zPos); - } - } - if (config.SodaliteOreTrue) { - for (int i = 0; i <= 16; i++) { - xPos = xChunk + random.nextInt(16); - yPos = 60 + random.nextInt(60 - 20); - zPos = zChunk + random.nextInt(16); - oreSodalite.generate(world, random, xPos, yPos, zPos); - } - } - } + void generateEndOres(Random random, int xChunk, int zChunk, World world) + { + int xPos, yPos, zPos; + if (config.TungstenOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreTungston.generate(world, random, xPos, yPos, zPos); + } + } + if (config.SheldoniteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreSheldonite.generate(world, random, xPos, yPos, zPos); + } + } + if (config.OlivineOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreOlivine.generate(world, random, xPos, yPos, zPos); + } + } + if (config.SodaliteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreSodalite.generate(world, random, xPos, yPos, zPos); + } + } + } }