This commit is contained in:
Gig 2015-04-24 14:20:09 +01:00
parent 6e0ec1d861
commit 4ac26ac086
137 changed files with 10339 additions and 7322 deletions

View file

@ -5,41 +5,41 @@ import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
public class BeefCoreLog { public class BeefCoreLog {
private static final String CHANNEL = "BeefCore"; private static final String CHANNEL = "BeefCore";
public static void log(Level level, String format, Object... data) public static void log(Level level, String format, Object... data)
{ {
FMLLog.log(level, format, data); FMLLog.log(level, format, data);
} }
public static void fatal(String format, Object... data) public static void fatal(String format, Object... data)
{ {
log(Level.FATAL, format, data); log(Level.FATAL, format, data);
} }
public static void error(String format, Object... data) public static void error(String format, Object... data)
{ {
log(Level.ERROR, format, data); log(Level.ERROR, format, data);
} }
public static void warning(String format, Object... data) public static void warning(String format, Object... data)
{ {
log(Level.WARN, format, data); log(Level.WARN, format, data);
} }
public static void info(String format, Object... data) public static void info(String format, Object... data)
{ {
log(Level.INFO, format, data); log(Level.INFO, format, data);
} }
public static void debug(String format, Object... data) public static void debug(String format, Object... data)
{ {
log(Level.DEBUG, format, data); log(Level.DEBUG, format, data);
} }
public static void trace(String format, Object... data) public static void trace(String format, Object... data)
{ {
log(Level.TRACE, format, data); log(Level.TRACE, format, data);
} }
} }

View file

@ -9,41 +9,60 @@ import net.minecraftforge.common.util.ForgeDirection;
public class CoordTriplet implements Comparable { public class CoordTriplet implements Comparable {
public int x, y, z; 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.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
} }
public int getChunkX() { return x >> 4; } public int getChunkX()
public int getChunkZ() { return z >> 4; } {
public long getChunkXZHash() { return ChunkCoordIntPair.chunkXZ2Int(x >> 4, z >> 4); } return x >> 4;
}
public int getChunkZ()
{
return z >> 4;
}
public long getChunkXZHash()
{
return ChunkCoordIntPair.chunkXZ2Int(x >> 4, z >> 4);
}
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other)
if(other == null) {
{ return false; } if (other == null)
else if(other instanceof CoordTriplet) { {
CoordTriplet otherTriplet = (CoordTriplet)other; return false;
return this.x == otherTriplet.x && this.y == otherTriplet.y && this.z == otherTriplet.z; } else if (other instanceof CoordTriplet)
} {
else { CoordTriplet otherTriplet = (CoordTriplet) other;
return this.x == otherTriplet.x && this.y == otherTriplet.y
&& this.z == otherTriplet.z;
} else
{
return false; return false;
} }
} }
public void translate(ForgeDirection dir) { public void translate(ForgeDirection dir)
{
this.x += dir.offsetX; this.x += dir.offsetX;
this.y += dir.offsetY; this.y += dir.offsetY;
this.z += dir.offsetZ; 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; return this.x == x && this.y == y && this.z == z;
} }
// Suggested implementation from NetBeans 7.1 // Suggested implementation from NetBeans 7.1
public int hashCode() { public int hashCode()
{
int hash = 7; int hash = 7;
hash = 71 * hash + this.x; hash = 71 * hash + this.x;
hash = 71 * hash + this.y; hash = 71 * hash + this.y;
@ -51,78 +70,144 @@ public class CoordTriplet implements Comparable {
return hash; return hash;
} }
public CoordTriplet copy() { public CoordTriplet copy()
{
return new CoordTriplet(x, y, z); return new CoordTriplet(x, y, z);
} }
public void copy(CoordTriplet other) { public void copy(CoordTriplet other)
{
this.x = other.x; this.x = other.x;
this.y = other.y; this.y = other.y;
this.z = other.z; this.z = other.z;
} }
public CoordTriplet[] getNeighbors() { public CoordTriplet[] getNeighbors()
return new CoordTriplet[]{ {
new CoordTriplet(x + 1, y, z), return new CoordTriplet[]
new CoordTriplet(x - 1, y, z), { 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 - 1, z),
new CoordTriplet(x, y - 1, z), new CoordTriplet(x, y, z + 1), new CoordTriplet(x, y, z - 1) };
new CoordTriplet(x, y, z + 1),
new CoordTriplet(x, y, z - 1)
};
} }
///// IComparable // /// IComparable
@Override @Override
public int compareTo(Object o) { public int compareTo(Object o)
if(o instanceof CoordTriplet) { {
CoordTriplet other = (CoordTriplet)o; if (o instanceof CoordTriplet)
if(this.x < other.x) { return -1; } {
else if(this.x > other.x) { return 1; } CoordTriplet other = (CoordTriplet) o;
else if(this.y < other.y) { return -1; } if (this.x < other.x)
else if(this.y > other.y) { return 1; } {
else if(this.z < other.z) { return -1; } return -1;
else if(this.z > other.z) { return 1; } } else if (this.x > other.x)
else { return 0; } {
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; return 0;
} }
///// Really confusing code that should be cleaned up // /// Really confusing code that should be cleaned up
public ForgeDirection getDirectionFromSourceCoords(int x, int y, int z) { public ForgeDirection getDirectionFromSourceCoords(int x, int y, int z)
if(this.x < x) { return ForgeDirection.WEST; } {
else if(this.x > x) { return ForgeDirection.EAST; } if (this.x < x)
else if(this.y < y) { return ForgeDirection.DOWN; } {
else if(this.y > y) { return ForgeDirection.UP; } return ForgeDirection.WEST;
else if(this.z < z) { return ForgeDirection.SOUTH; } } else if (this.x > x)
else if(this.z > z) { return ForgeDirection.NORTH; } {
else { return ForgeDirection.UNKNOWN; } 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) { public ForgeDirection getOppositeDirectionFromSourceCoords(int x, int y,
if(this.x < x) { return ForgeDirection.EAST; } int z)
else if(this.x > x) { return ForgeDirection.WEST; } {
else if(this.y < y) { return ForgeDirection.UP; } if (this.x < x)
else if(this.y > y) { return ForgeDirection.DOWN; } {
else if(this.z < z) { return ForgeDirection.NORTH; } return ForgeDirection.EAST;
else if(this.z > z) { return ForgeDirection.SOUTH; } } else if (this.x > x)
else { return ForgeDirection.UNKNOWN; } {
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 @Override
public String toString() { public String toString()
{
return String.format("(%d, %d, %d)", this.x, this.y, this.z); return String.format("(%d, %d, %d)", this.x, this.y, this.z);
} }
public int compareTo(int xCoord, int yCoord, int zCoord) { public int compareTo(int xCoord, int yCoord, int zCoord)
if(this.x < xCoord) { return -1; } {
else if(this.x > xCoord) { return 1; } if (this.x < xCoord)
else if(this.y < yCoord) { return -1; } {
else if(this.y > yCoord) { return 1; } return -1;
else if(this.z < zCoord) { return -1; } } else if (this.x > xCoord)
else if(this.z > zCoord) { return 1; } {
else { return 0; } 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;
}
} }
} }

View file

@ -9,7 +9,8 @@ import net.minecraft.block.material.Material;
*/ */
public abstract class BlockMultiblockBase extends BlockContainer { public abstract class BlockMultiblockBase extends BlockContainer {
protected BlockMultiblockBase(Material material) { protected BlockMultiblockBase(Material material)
{
super(material); super(material);
} }
} }

View file

@ -7,106 +7,132 @@ import net.minecraft.tileentity.TileEntity;
import erogenousbeef.coreTR.common.CoordTriplet; import erogenousbeef.coreTR.common.CoordTriplet;
/** /**
* Basic interface for a multiblock machine part. This is defined as an abstract class * Basic interface for a multiblock machine part. This is defined as an abstract
* as we need the basic functionality of a TileEntity as well. * class as we need the basic functionality of a TileEntity as well. Preferably,
* Preferably, you should derive from MultiblockTileEntityBase, * you should derive from MultiblockTileEntityBase, which does all the hard work
* which does all the hard work for you. * for you.
* *
* {@link erogenousbeef.coreTR.multiblock.MultiblockTileEntityBase} * {@link erogenousbeef.coreTR.multiblock.MultiblockTileEntityBase}
*/ */
public abstract class IMultiblockPart extends TileEntity { public abstract class IMultiblockPart extends TileEntity {
public static final int INVALID_DISTANCE = Integer.MAX_VALUE; 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(); 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(); public abstract MultiblockControllerBase getMultiblockController();
/** /**
* Returns the location of this tile entity in the world, in CoordTriplet form. * Returns the location of this tile entity in the world, in CoordTriplet
* @return A CoordTriplet with its x,y,z members set to the location of this tile entity in the world. * 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(); public abstract CoordTriplet getWorldLocation();
// Multiblock connection-logic callbacks // Multiblock connection-logic callbacks
/** /**
* Called after this block has been attached to a new multiblock controller. * 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); public abstract void onAttached(MultiblockControllerBase newController);
/** /**
* Called after this block has been detached from a multiblock controller. * 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 * Called when this block is being orphaned. Use this to copy game-data
* should persist despite a machine being broken. * values that should persist despite a machine being broken. This should
* This should NOT mark the part as disconnected. onDetached will be called immediately afterwards. * NOT mark the part as disconnected. onDetached will be called immediately
* afterwards.
*
* @see #onDetached(MultiblockControllerBase) * @see #onDetached(MultiblockControllerBase)
* @param oldController The controller which is orphaning this block. * @param oldController
* @param oldControllerSize The number of connected blocks in the controller prior to shedding orphans. * The controller which is orphaning this block.
* @param newControllerSize The number of connected blocks in the controller after shedding orphans. * @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. // Multiblock fuse/split helper methods. Here there be dragons.
/** /**
* Factory method. Creates a new multiblock controller and returns it. * Factory method. Creates a new multiblock controller and returns it. Does
* Does not attach this tile entity to it. * not attach this tile entity to it. Override this in your game code!
* Override this in your game code! *
* @return A new Multiblock Controller, derived from MultiblockControllerBase. * @return A new Multiblock Controller, derived from
* MultiblockControllerBase.
*/ */
public abstract MultiblockControllerBase createNewMultiblock(); public abstract MultiblockControllerBase createNewMultiblock();
/** /**
* Retrieve the type of multiblock controller which governs this part. * Retrieve the type of multiblock controller which governs this part. Used
* Used to ensure that incompatible multiblocks are not merged. * to ensure that incompatible multiblocks are not merged.
* @return The class/type of the multiblock controller which governs this type of part. *
* @return The class/type of the multiblock controller which governs this
* type of part.
*/ */
public abstract Class<? extends MultiblockControllerBase> getMultiblockControllerType(); public abstract Class<? extends MultiblockControllerBase> getMultiblockControllerType();
/** /**
* Called when this block is moved from its current controller into a new controller. * Called when this block is moved from its current controller into a new
* A special case of attach/detach, done here for efficiency to avoid triggering * controller. A special case of attach/detach, done here for efficiency to
* lots of recalculation logic. * avoid triggering lots of recalculation logic.
* @param newController The new controller into which this tile entity is being merged. *
* @param newController
* The new controller into which this tile entity is being
* merged.
*/ */
public abstract void onAssimilated(MultiblockControllerBase newController); public abstract void onAssimilated(MultiblockControllerBase newController);
// Multiblock connection data access. // Multiblock connection data access.
// You generally shouldn't toy with these! // You generally shouldn't toy with these!
// They're for use by Multiblock Controllers. // They're for use by Multiblock Controllers.
/** /**
* Set that this block has been visited by your validation algorithms. * Set that this block has been visited by your validation algorithms.
*/ */
public abstract void setVisited(); public abstract void setVisited();
/** /**
* Set that this block has not been visited by your validation algorithms; * Set that this block has not been visited by your validation algorithms;
*/ */
public abstract void setUnvisited(); 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(); public abstract boolean isVisited();
/** /**
* Called when this block becomes the designated block for saving data and * Called when this block becomes the designated block for saving data and
* transmitting data across the wire. * transmitting data across the wire.
*/ */
public abstract void becomeMultiblockSaveDelegate(); public abstract void becomeMultiblockSaveDelegate();
/** /**
* Called when this block is no longer the designated block for saving data * Called when this block is no longer the designated block for saving data
* and transmitting data across the wire. * 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? * 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. * Returns an array containing references to neighboring IMultiblockPart
* Primarily a utility method. Only works after tileentity construction, so it cannot be used in * tile entities. Primarily a utility method. Only works after tileentity
* construction, so it cannot be used in
* MultiblockControllerBase::attachBlock. * MultiblockControllerBase::attachBlock.
* *
* This method is chunk-safe on the server; it will not query for parts in chunks that are unloaded. * This method is chunk-safe on the server; it will not query for parts in
* Note that no method is chunk-safe on the client, because ChunkProviderClient is stupid. * chunks that are unloaded. Note that no method is chunk-safe on the
* @return An array of references to neighboring IMultiblockPart tile entities. * client, because ChunkProviderClient is stupid.
*
* @return An array of references to neighboring IMultiblockPart tile
* entities.
*/ */
public abstract IMultiblockPart[] getNeighboringParts(); public abstract IMultiblockPart[] getNeighboringParts();
// Multiblock business-logic callbacks - implement these! // Multiblock business-logic callbacks - implement these!
/** /**
* Called when a machine is fully assembled from the disassembled state, meaning * Called when a machine is fully assembled from the disassembled state,
* it was broken by a player/entity action, not by chunk unloads. * 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 * Note that, for non-square machines, the min/max coordinates may not
* of the machine! They form an outer bounding box for the whole machine itself. * actually be part of the machine! They form an outer bounding box for the
* @param multiblockControllerBase The controller to which this part is being assembled. * 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 * Called when the machine is broken for game reasons, e.g. a player removed
* or an explosion occurred. * a block or an explosion occurred.
*/ */
public abstract void onMachineBroken(); public abstract void onMachineBroken();
/** /**
* Called when the user activates the machine. This is not called by default, but is included * Called when the user activates the machine. This is not called by
* as most machines have this game-logical concept. * default, but is included as most machines have this game-logical concept.
*/ */
public abstract void onMachineActivated(); public abstract void onMachineActivated();
/** /**
* Called when the user deactivates the machine. This is not called by default, but is included * Called when the user deactivates the machine. This is not called by
* as most machines have this game-logical concept. * default, but is included as most machines have this game-logical concept.
*/ */
public abstract void onMachineDeactivated(); public abstract void onMachineDeactivated();
// Block events // Block events
/** /**
* Called when this part should check its neighbors. * Called when this part should check its neighbors. This method MUST NOT
* This method MUST NOT cause additional chunks to load. * cause additional chunks to load. ALWAYS check to see if a chunk is loaded
* ALWAYS check to see if a chunk is loaded before querying for its tile entity * before querying for its tile entity This part should inform the
* This part should inform the controller that it is attaching at this time. * 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. *
* @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<MultiblockControllerBase> attachToNeighbors(); public abstract Set<MultiblockControllerBase> attachToNeighbors();
/** /**
* Assert that this part is detached. If not, log a warning and set the part's controller to null. * Assert that this part is detached. If not, log a warning and set the
* Do NOT fire the full disconnection logic. * part's controller to null. Do NOT fire the full disconnection logic.
*/ */
public abstract void assertDetached(); 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. * @return True if a part has multiblock game-data saved inside it.
*/ */
public abstract boolean hasMultiblockSaveData(); 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(); public abstract NBTTagCompound getMultiblockSaveData();
/** /**
* Called after a block is added and the controller has incorporated the part's saved * Called after a block is added and the controller has incorporated the
* multiblock game-data into itself. Generally, you should clear the saved data here. * part's saved multiblock game-data into itself. Generally, you should
* clear the saved data here.
*/ */
public abstract void onMultiblockDataAssimilated(); public abstract void onMultiblockDataAssimilated();
} }

View file

@ -6,10 +6,12 @@ import cpw.mods.fml.common.gameevent.TickEvent;
public class MultiblockClientTickHandler { public class MultiblockClientTickHandler {
@SubscribeEvent @SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) { public void onClientTick(TickEvent.ClientTickEvent event)
if(event.phase == TickEvent.Phase.START) { {
MultiblockRegistry.tickStart(Minecraft.getMinecraft().theWorld); if (event.phase == TickEvent.Phase.START)
} {
} MultiblockRegistry.tickStart(Minecraft.getMinecraft().theWorld);
}
}
} }

View file

@ -8,22 +8,25 @@ import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
/** /**
* In your mod, subscribe this on both the client and server sides side to handle chunk * In your mod, subscribe this on both the client and server sides side to
* load events for your multiblock machines. * handle chunk load events for your multiblock machines. Chunks can load
* Chunks can load asynchronously in environments like MCPC+, so we cannot * asynchronously in environments like MCPC+, so we cannot process any blocks
* process any blocks that are in chunks which are still loading. * that are in chunks which are still loading.
*/ */
public class MultiblockEventHandler { public class MultiblockEventHandler {
@SubscribeEvent(priority = EventPriority.NORMAL) @SubscribeEvent(priority = EventPriority.NORMAL)
public void onChunkLoad(ChunkEvent.Load loadEvent) { public void onChunkLoad(ChunkEvent.Load loadEvent)
{
Chunk chunk = loadEvent.getChunk(); Chunk chunk = loadEvent.getChunk();
World world = loadEvent.world; World world = loadEvent.world;
MultiblockRegistry.onChunkLoaded(world, chunk.xPosition, chunk.zPosition); MultiblockRegistry.onChunkLoaded(world, chunk.xPosition,
chunk.zPosition);
} }
// Cleanup, for nice memory usageness // Cleanup, for nice memory usageness
@SubscribeEvent(priority = EventPriority.NORMAL) @SubscribeEvent(priority = EventPriority.NORMAL)
public void onWorldUnload(WorldEvent.Unload unloadWorldEvent) { public void onWorldUnload(WorldEvent.Unload unloadWorldEvent)
{
MultiblockRegistry.onWorldUnloaded(unloadWorldEvent.world); MultiblockRegistry.onWorldUnloaded(unloadWorldEvent.world);
} }
} }

View file

@ -7,122 +7,170 @@ import net.minecraft.world.World;
import erogenousbeef.coreTR.common.BeefCoreLog; import erogenousbeef.coreTR.common.BeefCoreLog;
/** /**
* This is a very static singleton registry class which directs incoming events to sub-objects, which * This is a very static singleton registry class which directs incoming events
* actually manage each individual world's multiblocks. * to sub-objects, which actually manage each individual world's multiblocks.
*
* @author Erogenous Beef * @author Erogenous Beef
*/ */
public class MultiblockRegistry { public class MultiblockRegistry {
// World > WorldRegistry map // World > WorldRegistry map
private static HashMap<World, MultiblockWorldRegistry> registries = new HashMap<World, MultiblockWorldRegistry>(); private static HashMap<World, MultiblockWorldRegistry> registries = new HashMap<World, MultiblockWorldRegistry>();
/** /**
* Called before Tile Entities are ticked in the world. Do bookkeeping here. * 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) { public static void tickStart(World world)
if(registries.containsKey(world)) { {
if (registries.containsKey(world))
{
MultiblockWorldRegistry registry = registries.get(world); MultiblockWorldRegistry registry = registries.get(world);
registry.processMultiblockChanges(); registry.processMultiblockChanges();
registry.tickStart(); registry.tickStart();
} }
} }
/** /**
* Called when the world has finished loading a chunk. * 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 world
* @param chunkZ The Z coordinate of the chunk * 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) { public static void onChunkLoaded(World world, int chunkX, int chunkZ)
if(registries.containsKey(world)) { {
if (registries.containsKey(world))
{
registries.get(world).onChunkLoaded(chunkX, chunkZ); 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. * Register a new part in the system. The part has been created either
* @param world The world into which this part is loading. * through user action or via a chunk loading.
* @param part The part being loaded. *
* @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); MultiblockWorldRegistry registry = getOrCreateRegistry(world);
registry.onPartAdded(part); registry.onPartAdded(part);
} }
/** /**
* Call to remove a part from world lists. * 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) { public static void onPartRemovedFromWorld(World world, IMultiblockPart part)
if(registries.containsKey(world)) { {
if (registries.containsKey(world))
{
registries.get(world).onPartRemovedFromWorld(part); registries.get(world).onPartRemovedFromWorld(part);
} }
} }
/** /**
* Called whenever a world is unloaded. Unload the relevant registry, if we have one. * Called whenever a world is unloaded. Unload the relevant registry, if we
* @param world The world being unloaded. * have one.
*
* @param world
* The world being unloaded.
*/ */
public static void onWorldUnloaded(World world) { public static void onWorldUnloaded(World world)
if(registries.containsKey(world)) { {
if (registries.containsKey(world))
{
registries.get(world).onWorldUnloaded(); registries.get(world).onWorldUnloaded();
registries.remove(world); registries.remove(world);
} }
} }
/** /**
* Call to mark a controller as dirty. Dirty means that parts have * Call to mark a controller as dirty. Dirty means that parts have been
* been added or removed this tick. * added or removed this tick.
* @param world The world containing the multiblock *
* @param controller The dirty controller * @param world
* The world containing the multiblock
* @param controller
* The dirty controller
*/ */
public static void addDirtyController(World world, public static void addDirtyController(World world,
MultiblockControllerBase controller) { MultiblockControllerBase controller)
if(registries.containsKey(world)) { {
if (registries.containsKey(world))
{
registries.get(world).addDirtyController(controller); registries.get(world).addDirtyController(controller);
} } else
else { {
throw new IllegalArgumentException("Adding a dirty controller to a world that has no registered controllers!"); 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);
} }
} }
/** /**
* @param world The world whose controllers you wish to retrieve. * Call to mark a controller as dead. It should only be marked as dead when
* @return An unmodifiable set of controllers active in the given world, or null if there are none. * 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<MultiblockControllerBase> getControllersFromWorld(World world) { public static void addDeadController(World world,
if(registries.containsKey(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<MultiblockControllerBase> getControllersFromWorld(
World world)
{
if (registries.containsKey(world))
{
return registries.get(world).getControllers(); return registries.get(world).getControllers();
} }
return null; return null;
} }
/// *** PRIVATE HELPERS *** /// // / *** PRIVATE HELPERS *** ///
private static MultiblockWorldRegistry getOrCreateRegistry(World world) { private static MultiblockWorldRegistry getOrCreateRegistry(World world)
if(registries.containsKey(world)) { {
if (registries.containsKey(world))
{
return registries.get(world); return registries.get(world);
} } else
else { {
MultiblockWorldRegistry newRegistry = new MultiblockWorldRegistry(world); MultiblockWorldRegistry newRegistry = new MultiblockWorldRegistry(
world);
registries.put(world, newRegistry); registries.put(world, newRegistry);
return newRegistry; return newRegistry;
} }

View file

@ -4,20 +4,21 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent;
/** /**
* This is a generic multiblock tick handler. If you are using this code on your own, * This is a generic multiblock tick handler. If you are using this code on your
* you will need to register this with the Forge TickRegistry on both the * own, you will need to register this with the Forge TickRegistry on both the
* client AND server sides. * client AND server sides. Note that different types of ticks run on different
* Note that different types of ticks run on different parts of the system. * parts of the system. CLIENT ticks only run on the client, at the start/end of
* CLIENT ticks only run on the client, at the start/end of each game loop. * each game loop. SERVER and WORLD ticks only run on the server. WORLDLOAD
* SERVER and WORLD ticks only run on the server. * ticks run only on the server, and only when worlds are loaded.
* WORLDLOAD ticks run only on the server, and only when worlds are loaded.
*/ */
public class MultiblockServerTickHandler { public class MultiblockServerTickHandler {
@SubscribeEvent @SubscribeEvent
public void onWorldTick(TickEvent.WorldTickEvent event) { public void onWorldTick(TickEvent.WorldTickEvent event)
if(event.phase == TickEvent.Phase.START) { {
MultiblockRegistry.tickStart(event.world); if (event.phase == TickEvent.Phase.START)
} {
} MultiblockRegistry.tickStart(event.world);
}
}
} }

View file

@ -15,18 +15,20 @@ import erogenousbeef.coreTR.common.BeefCoreLog;
import erogenousbeef.coreTR.common.CoordTriplet; import erogenousbeef.coreTR.common.CoordTriplet;
/** /**
* Base logic class for Multiblock-connected tile entities. Most multiblock machines * Base logic class for Multiblock-connected tile entities. Most multiblock
* should derive from this and implement their game logic in certain abstract methods. * machines should derive from this and implement their game logic in certain
* abstract methods.
*/ */
public abstract class MultiblockTileEntityBase extends IMultiblockPart { public abstract class MultiblockTileEntityBase extends IMultiblockPart {
private MultiblockControllerBase controller; private MultiblockControllerBase controller;
private boolean visited; private boolean visited;
private boolean saveMultiblockData; private boolean saveMultiblockData;
private NBTTagCompound cachedMultiblockData; private NBTTagCompound cachedMultiblockData;
private boolean paused; private boolean paused;
public MultiblockTileEntityBase() { public MultiblockTileEntityBase()
{
super(); super();
controller = null; controller = null;
visited = false; visited = false;
@ -35,36 +37,45 @@ public abstract class MultiblockTileEntityBase extends IMultiblockPart {
cachedMultiblockData = null; cachedMultiblockData = null;
} }
///// Multiblock Connection Base Logic // /// Multiblock Connection Base Logic
@Override @Override
public Set<MultiblockControllerBase> attachToNeighbors() { public Set<MultiblockControllerBase> attachToNeighbors()
{
Set<MultiblockControllerBase> controllers = null; Set<MultiblockControllerBase> controllers = null;
MultiblockControllerBase bestController = null; MultiblockControllerBase bestController = null;
// Look for a compatible controller in our neighboring parts. // Look for a compatible controller in our neighboring parts.
IMultiblockPart[] partsToCheck = getNeighboringParts(); IMultiblockPart[] partsToCheck = getNeighboringParts();
for(IMultiblockPart neighborPart : partsToCheck) { for (IMultiblockPart neighborPart : partsToCheck)
if(neighborPart.isConnected()) { {
MultiblockControllerBase candidate = neighborPart.getMultiblockController(); if (neighborPart.isConnected())
if(!candidate.getClass().equals(this.getMultiblockControllerType())) { {
MultiblockControllerBase candidate = neighborPart
.getMultiblockController();
if (!candidate.getClass().equals(
this.getMultiblockControllerType()))
{
// Skip multiblocks with incompatible types // Skip multiblocks with incompatible types
continue; continue;
} }
if(controllers == null) { if (controllers == null)
{
controllers = new HashSet<MultiblockControllerBase>(); controllers = new HashSet<MultiblockControllerBase>();
bestController = candidate; bestController = candidate;
} } else if (!controllers.contains(candidate)
else if(!controllers.contains(candidate) && candidate.shouldConsume(bestController)) { && candidate.shouldConsume(bestController))
{
bestController = candidate; bestController = candidate;
} }
controllers.add(candidate); controllers.add(candidate);
} }
} }
// If we've located a valid neighboring controller, attach to it. // 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. // attachBlock will call onAttached, which will set the controller.
this.controller = bestController; this.controller = bestController;
bestController.attachBlock(this); bestController.attachBlock(this);
@ -74,152 +85,193 @@ public abstract class MultiblockTileEntityBase extends IMultiblockPart {
} }
@Override @Override
public void assertDetached() { 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); 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; this.controller = null;
} }
} }
///// Overrides from base TileEntity methods // /// Overrides from base TileEntity methods
@Override @Override
public void readFromNBT(NBTTagCompound data) { public void readFromNBT(NBTTagCompound data)
{
super.readFromNBT(data); super.readFromNBT(data);
// We can't directly initialize a multiblock controller yet, so we cache the data here until // We can't directly initialize a multiblock controller yet, so we cache
// we receive a validate() call, which creates the controller and hands off the cached data. // the data here until
if(data.hasKey("multiblockData")) { // we receive a validate() call, which creates the controller and hands
// off the cached data.
if (data.hasKey("multiblockData"))
{
this.cachedMultiblockData = data.getCompoundTag("multiblockData"); this.cachedMultiblockData = data.getCompoundTag("multiblockData");
} }
} }
@Override @Override
public void writeToNBT(NBTTagCompound data) { public void writeToNBT(NBTTagCompound data)
{
super.writeToNBT(data); super.writeToNBT(data);
if(isMultiblockSaveDelegate() && isConnected()) { if (isMultiblockSaveDelegate() && isConnected())
{
NBTTagCompound multiblockData = new NBTTagCompound(); NBTTagCompound multiblockData = new NBTTagCompound();
this.controller.writeToNBT(multiblockData); this.controller.writeToNBT(multiblockData);
data.setTag("multiblockData", multiblockData); data.setTag("multiblockData", multiblockData);
} }
} }
/** /**
* Generally, TileEntities that are part of a multiblock should not subscribe to updates * Generally, TileEntities that are part of a multiblock should not
* from the main game loop. Instead, you should have lists of TileEntities which need to * subscribe to updates from the main game loop. Instead, you should have
* be notified during an update() in your Controller and perform callbacks from there. * 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() * @see net.minecraft.tileentity.TileEntity#canUpdate()
*/ */
@Override @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 * Called when a block is removed by game actions, such as a player breaking
* or the block being changed into another block. * the block or the block being changed into another block.
*
* @see net.minecraft.tileentity.TileEntity#invalidate() * @see net.minecraft.tileentity.TileEntity#invalidate()
*/ */
@Override @Override
public void invalidate() { public void invalidate()
{
super.invalidate(); super.invalidate();
detachSelf(false); detachSelf(false);
} }
/** /**
* Called from Minecraft's tile entity loop, after all tile entities have been ticked, * Called from Minecraft's tile entity loop, after all tile entities have
* as the chunk in which this tile entity is contained is unloading. * been ticked, as the chunk in which this tile entity is contained is
* Happens before the Forge TickEnd event. * unloading. Happens before the Forge TickEnd event.
*
* @see net.minecraft.tileentity.TileEntity#onChunkUnload() * @see net.minecraft.tileentity.TileEntity#onChunkUnload()
*/ */
@Override @Override
public void onChunkUnload() { public void onChunkUnload()
{
super.onChunkUnload(); super.onChunkUnload();
detachSelf(true); detachSelf(true);
} }
/** /**
* This is called when a block is being marked as valid by the chunk, but has not yet fully * This is called when a block is being marked as valid by the chunk, but
* been placed into the world's TileEntity cache. this.worldObj, xCoord, yCoord and zCoord have * has not yet fully been placed into the world's TileEntity cache.
* been initialized, but any attempts to read data about the world can cause infinite loops - * this.worldObj, xCoord, yCoord and zCoord have been initialized, but any
* if you call getTileEntity on this TileEntity's coordinate from within validate(), you will * attempts to read data about the world can cause infinite loops - if you
* blow your call stack. * call getTileEntity on this TileEntity's coordinate from within
* validate(), you will blow your call stack.
* *
* TL;DR: Here there be dragons. * TL;DR: Here there be dragons.
*
* @see net.minecraft.tileentity.TileEntity#validate() * @see net.minecraft.tileentity.TileEntity#validate()
*/ */
@Override @Override
public void validate() { public void validate()
{
super.validate(); super.validate();
MultiblockRegistry.onPartAdded(this.worldObj, this); MultiblockRegistry.onPartAdded(this.worldObj, this);
} }
// Network Communication // Network Communication
@Override @Override
public Packet getDescriptionPacket() { public Packet getDescriptionPacket()
{
NBTTagCompound packetData = new NBTTagCompound(); NBTTagCompound packetData = new NBTTagCompound();
encodeDescriptionPacket(packetData); encodeDescriptionPacket(packetData);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0, packetData); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 0,
packetData);
} }
@Override @Override
public void onDataPacket(NetworkManager network, S35PacketUpdateTileEntity packet) { public void onDataPacket(NetworkManager network,
S35PacketUpdateTileEntity packet)
{
decodeDescriptionPacket(packet.func_148857_g()); 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 * Override this to easily modify the description packet's data without
* to worry about sending the packet itself. * having to worry about sending the packet itself. Decode this data in
* Decode this data in decodeDescriptionPacket. * decodeDescriptionPacket.
* @param packetData An NBT compound tag into which you should write your custom description data. *
* @param packetData
* An NBT compound tag into which you should write your custom
* description data.
* @see erogenousbeef.coreTR.multiblock.MultiblockTileEntityBase#decodeDescriptionPacket(NBTTagCompound) * @see erogenousbeef.coreTR.multiblock.MultiblockTileEntityBase#decodeDescriptionPacket(NBTTagCompound)
*/ */
protected void encodeDescriptionPacket(NBTTagCompound packetData) { protected void encodeDescriptionPacket(NBTTagCompound packetData)
if(this.isMultiblockSaveDelegate() && isConnected()) { {
if (this.isMultiblockSaveDelegate() && isConnected())
{
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
getMultiblockController().formatDescriptionPacket(tag); getMultiblockController().formatDescriptionPacket(tag);
packetData.setTag("multiblockData", tag); packetData.setTag("multiblockData", tag);
} }
} }
/** /**
* Override this to easily read in data from a TileEntity's description packet. * Override this to easily read in data from a TileEntity's description
* Encoded in encodeDescriptionPacket. * packet. Encoded in encodeDescriptionPacket.
* @param packetData The NBT data from the tile entity's description packet. *
* @param packetData
* The NBT data from the tile entity's description packet.
* @see erogenousbeef.coreTR.multiblock.MultiblockTileEntityBase#encodeDescriptionPacket(NBTTagCompound) * @see erogenousbeef.coreTR.multiblock.MultiblockTileEntityBase#encodeDescriptionPacket(NBTTagCompound)
*/ */
protected void decodeDescriptionPacket(NBTTagCompound packetData) { protected void decodeDescriptionPacket(NBTTagCompound packetData)
if(packetData.hasKey("multiblockData")) { {
if (packetData.hasKey("multiblockData"))
{
NBTTagCompound tag = packetData.getCompoundTag("multiblockData"); NBTTagCompound tag = packetData.getCompoundTag("multiblockData");
if(isConnected()) { if (isConnected())
{
getMultiblockController().decodeDescriptionPacket(tag); getMultiblockController().decodeDescriptionPacket(tag);
} } else
else { {
// This part hasn't been added to a machine yet, so cache the data. // This part hasn't been added to a machine yet, so cache the
// data.
this.cachedMultiblockData = tag; this.cachedMultiblockData = tag;
} }
} }
} }
@Override @Override
public boolean hasMultiblockSaveData() { public boolean hasMultiblockSaveData()
{
return this.cachedMultiblockData != null; return this.cachedMultiblockData != null;
} }
@Override @Override
public NBTTagCompound getMultiblockSaveData() { public NBTTagCompound getMultiblockSaveData()
{
return this.cachedMultiblockData; return this.cachedMultiblockData;
} }
@Override @Override
public void onMultiblockDataAssimilated() { public void onMultiblockDataAssimilated()
{
this.cachedMultiblockData = null; this.cachedMultiblockData = null;
} }
///// Game logic callbacks (IMultiblockPart) // /// Game logic callbacks (IMultiblockPart)
@Override @Override
public abstract void onMachineAssembled(MultiblockControllerBase multiblockControllerBase); public abstract void onMachineAssembled(
MultiblockControllerBase multiblockControllerBase);
@Override @Override
public abstract void onMachineBroken(); public abstract void onMachineBroken();
@ -230,120 +282,148 @@ public abstract class MultiblockTileEntityBase extends IMultiblockPart {
@Override @Override
public abstract void onMachineDeactivated(); public abstract void onMachineDeactivated();
///// Miscellaneous multiblock-assembly callbacks and support methods (IMultiblockPart) // /// Miscellaneous multiblock-assembly callbacks and support methods
// (IMultiblockPart)
@Override @Override
public boolean isConnected() { public boolean isConnected()
{
return (controller != null); return (controller != null);
} }
@Override @Override
public MultiblockControllerBase getMultiblockController() { public MultiblockControllerBase getMultiblockController()
{
return controller; return controller;
} }
@Override @Override
public CoordTriplet getWorldLocation() { public CoordTriplet getWorldLocation()
{
return new CoordTriplet(this.xCoord, this.yCoord, this.zCoord); return new CoordTriplet(this.xCoord, this.yCoord, this.zCoord);
} }
@Override @Override
public void becomeMultiblockSaveDelegate() { public void becomeMultiblockSaveDelegate()
{
this.saveMultiblockData = true; this.saveMultiblockData = true;
} }
@Override @Override
public void forfeitMultiblockSaveDelegate() { public void forfeitMultiblockSaveDelegate()
{
this.saveMultiblockData = false; this.saveMultiblockData = false;
} }
@Override
public boolean isMultiblockSaveDelegate() { return this.saveMultiblockData; }
@Override @Override
public void setUnvisited() { public boolean isMultiblockSaveDelegate()
{
return this.saveMultiblockData;
}
@Override
public void setUnvisited()
{
this.visited = false; this.visited = false;
} }
@Override @Override
public void setVisited() { public void setVisited()
{
this.visited = true; this.visited = true;
} }
@Override @Override
public boolean isVisited() { public boolean isVisited()
{
return this.visited; return this.visited;
} }
@Override @Override
public void onAssimilated(MultiblockControllerBase newController) { public void onAssimilated(MultiblockControllerBase newController)
assert(this.controller != newController); {
assert (this.controller != newController);
this.controller = newController; this.controller = newController;
} }
@Override @Override
public void onAttached(MultiblockControllerBase newController) { public void onAttached(MultiblockControllerBase newController)
{
this.controller = newController; this.controller = newController;
} }
@Override @Override
public void onDetached(MultiblockControllerBase oldController) { public void onDetached(MultiblockControllerBase oldController)
{
this.controller = null; this.controller = null;
} }
@Override @Override
public abstract MultiblockControllerBase createNewMultiblock(); public abstract MultiblockControllerBase createNewMultiblock();
@Override @Override
public IMultiblockPart[] getNeighboringParts() { public IMultiblockPart[] getNeighboringParts()
CoordTriplet[] neighbors = new CoordTriplet[] { {
new CoordTriplet(this.xCoord-1, this.yCoord, this.zCoord), CoordTriplet[] neighbors = new CoordTriplet[]
new CoordTriplet(this.xCoord, this.yCoord-1, this.zCoord), { new CoordTriplet(this.xCoord - 1, this.yCoord, this.zCoord),
new CoordTriplet(this.xCoord, this.yCoord, this.zCoord-1), 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, this.yCoord, this.zCoord + 1),
new CoordTriplet(this.xCoord+1, this.yCoord, this.zCoord) new CoordTriplet(this.xCoord, this.yCoord + 1, this.zCoord),
}; new CoordTriplet(this.xCoord + 1, this.yCoord, this.zCoord) };
TileEntity te; TileEntity te;
List<IMultiblockPart> neighborParts = new ArrayList<IMultiblockPart>(); List<IMultiblockPart> neighborParts = new ArrayList<IMultiblockPart>();
IChunkProvider chunkProvider = worldObj.getChunkProvider(); IChunkProvider chunkProvider = worldObj.getChunkProvider();
for(CoordTriplet neighbor : neighbors) { for (CoordTriplet neighbor : neighbors)
if(!chunkProvider.chunkExists(neighbor.getChunkX(), neighbor.getChunkZ())) { {
if (!chunkProvider.chunkExists(neighbor.getChunkX(),
neighbor.getChunkZ()))
{
// Chunk not loaded, skip it. // Chunk not loaded, skip it.
continue; continue;
} }
te = this.worldObj.getTileEntity(neighbor.x, neighbor.y, neighbor.z); te = this.worldObj
if(te instanceof IMultiblockPart) { .getTileEntity(neighbor.x, neighbor.y, neighbor.z);
neighborParts.add((IMultiblockPart)te); if (te instanceof IMultiblockPart)
{
neighborParts.add((IMultiblockPart) te);
} }
} }
IMultiblockPart[] tmp = new IMultiblockPart[neighborParts.size()]; IMultiblockPart[] tmp = new IMultiblockPart[neighborParts.size()];
return neighborParts.toArray(tmp); return neighborParts.toArray(tmp);
} }
@Override @Override
public void onOrphaned(MultiblockControllerBase controller, int oldSize, int newSize) { public void onOrphaned(MultiblockControllerBase controller, int oldSize,
int newSize)
{
this.markDirty(); this.markDirty();
worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this);
} }
//// Helper functions for notifying neighboring blocks // // Helper functions for notifying neighboring blocks
protected void notifyNeighborsOfBlockChange() { protected void notifyNeighborsOfBlockChange()
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); {
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord,
getBlockType());
} }
protected void notifyNeighborsOfTileChange() { protected void notifyNeighborsOfTileChange()
{
worldObj.func_147453_f(xCoord, yCoord, zCoord, getBlockType()); 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) { protected void detachSelf(boolean chunkUnloading)
if(this.controller != null) { {
if (this.controller != null)
{
// Clean part out of controller // Clean part out of controller
this.controller.detachBlock(this, chunkUnloading); this.controller.detachBlock(this, chunkUnloading);

View file

@ -1,13 +1,15 @@
package erogenousbeef.coreTR.multiblock; package erogenousbeef.coreTR.multiblock;
/** /**
* An exception thrown when trying to validate a multiblock. Requires a string describing why the multiblock * An exception thrown when trying to validate a multiblock. Requires a string
* could not assemble. * describing why the multiblock could not assemble.
*
* @author Erogenous Beef * @author Erogenous Beef
*/ */
public class MultiblockValidationException extends Exception { public class MultiblockValidationException extends Exception {
public MultiblockValidationException(String reason) { public MultiblockValidationException(String reason)
{
super(reason); super(reason);
} }
} }

View file

@ -15,45 +15,51 @@ import erogenousbeef.coreTR.common.BeefCoreLog;
import erogenousbeef.coreTR.common.CoordTriplet; import erogenousbeef.coreTR.common.CoordTriplet;
/** /**
* This class manages all the multiblock controllers that exist in a given world, * This class manages all the multiblock controllers that exist in a given
* either client- or server-side. * world, either client- or server-side. You must create different registries
* You must create different registries for server and client worlds. * for server and client worlds.
* *
* @author Erogenous Beef * @author Erogenous Beef
*/ */
public class MultiblockWorldRegistry { public class MultiblockWorldRegistry {
private World worldObj; private World worldObj;
private Set<MultiblockControllerBase> controllers; // Active controllers
private Set<MultiblockControllerBase> dirtyControllers; // Controllers whose parts lists have changed
private Set<MultiblockControllerBase> deadControllers; // Controllers which are empty
// A list of orphan parts - parts which currently have no master, but should seek one this tick private Set<MultiblockControllerBase> controllers; // Active controllers
private Set<MultiblockControllerBase> dirtyControllers; // Controllers whose
// parts lists have
// changed
private Set<MultiblockControllerBase> 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 // Indexed by the hashed chunk coordinate
// This can be added-to asynchronously via chunk loads! // This can be added-to asynchronously via chunk loads!
private Set<IMultiblockPart> orphanedParts; private Set<IMultiblockPart> orphanedParts;
// A list of parts which have been detached during internal operations // A list of parts which have been detached during internal operations
private Set<IMultiblockPart> detachedParts; private Set<IMultiblockPart> detachedParts;
// A list of parts whose chunks have not yet finished loading // A list of parts whose chunks have not yet finished loading
// They will be added to the orphan list when they are finished loading. // They will be added to the orphan list when they are finished loading.
// Indexed by the hashed chunk coordinate // Indexed by the hashed chunk coordinate
// This can be added-to asynchronously via chunk loads! // This can be added-to asynchronously via chunk loads!
private HashMap<Long, Set<IMultiblockPart>> partsAwaitingChunkLoad; private HashMap<Long, Set<IMultiblockPart>> 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 partsAwaitingChunkLoadMutex;
private Object orphanedPartsMutex; private Object orphanedPartsMutex;
public MultiblockWorldRegistry(World world) { public MultiblockWorldRegistry(World world)
{
worldObj = world; worldObj = world;
controllers = new HashSet<MultiblockControllerBase>(); controllers = new HashSet<MultiblockControllerBase>();
deadControllers = new HashSet<MultiblockControllerBase>(); deadControllers = new HashSet<MultiblockControllerBase>();
dirtyControllers = new HashSet<MultiblockControllerBase>(); dirtyControllers = new HashSet<MultiblockControllerBase>();
detachedParts = new HashSet<IMultiblockPart>(); detachedParts = new HashSet<IMultiblockPart>();
orphanedParts = new HashSet<IMultiblockPart>(); orphanedParts = new HashSet<IMultiblockPart>();
@ -61,20 +67,27 @@ public class MultiblockWorldRegistry {
partsAwaitingChunkLoadMutex = new Object(); partsAwaitingChunkLoadMutex = new Object();
orphanedPartsMutex = new Object(); orphanedPartsMutex = new Object();
} }
/** /**
* Called before Tile Entities are ticked in the world. Run game logic. * Called before Tile Entities are ticked in the world. Run game logic.
*/ */
public void tickStart() { public void tickStart()
if(controllers.size() > 0) { {
for(MultiblockControllerBase controller : controllers) { if (controllers.size() > 0)
if(controller.worldObj == worldObj && controller.worldObj.isRemote == worldObj.isRemote) { {
if(controller.isEmpty()) { for (MultiblockControllerBase controller : controllers)
// This happens on the server when the user breaks the last block. It's fine. {
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. // Mark 'er dead and move on.
deadControllers.add(controller); deadControllers.add(controller);
} } else
else { {
// Run the game logic for this world // Run the game logic for this world
controller.updateMultiblockEntity(); controller.updateMultiblockEntity();
} }
@ -82,87 +95,119 @@ public class MultiblockWorldRegistry {
} }
} }
} }
/** /**
* Called prior to processing multiblock controllers. Do bookkeeping. * Called prior to processing multiblock controllers. Do bookkeeping.
*/ */
public void processMultiblockChanges() { public void processMultiblockChanges()
{
IChunkProvider chunkProvider = worldObj.getChunkProvider(); IChunkProvider chunkProvider = worldObj.getChunkProvider();
CoordTriplet coord; 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<Set<MultiblockControllerBase>> mergePools = null; List<Set<MultiblockControllerBase>> mergePools = null;
if(orphanedParts.size() > 0) { if (orphanedParts.size() > 0)
{
Set<IMultiblockPart> orphansToProcess = null; Set<IMultiblockPart> orphansToProcess = null;
// Keep the synchronized block small. We can't iterate over orphanedParts directly // Keep the synchronized block small. We can't iterate over
// because the client does not know which chunks are actually loaded, so attachToNeighbors() // 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. // 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. // It's possible to polyfill this, but the polyfill is too slow for
synchronized(orphanedPartsMutex) { // comfort.
if(orphanedParts.size() > 0) { synchronized (orphanedPartsMutex)
{
if (orphanedParts.size() > 0)
{
orphansToProcess = orphanedParts; orphansToProcess = orphanedParts;
orphanedParts = new HashSet<IMultiblockPart>(); orphanedParts = new HashSet<IMultiblockPart>();
} }
} }
if(orphansToProcess != null && orphansToProcess.size() > 0) { if (orphansToProcess != null && orphansToProcess.size() > 0)
{
Set<MultiblockControllerBase> compatibleControllers; Set<MultiblockControllerBase> compatibleControllers;
// Process orphaned blocks // Process orphaned blocks
// These are blocks that exist in a valid chunk and require a controller // These are blocks that exist in a valid chunk and require a
for(IMultiblockPart orphan : orphansToProcess) { // controller
for (IMultiblockPart orphan : orphansToProcess)
{
coord = orphan.getWorldLocation(); coord = orphan.getWorldLocation();
if(!chunkProvider.chunkExists(coord.getChunkX(), coord.getChunkZ())) { if (!chunkProvider.chunkExists(coord.getChunkX(),
coord.getChunkZ()))
{
continue; continue;
} }
// This can occur on slow machines. // 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. // This block has been replaced by another.
continue; continue;
} }
// THIS IS THE ONLY PLACE WHERE PARTS ATTACH TO MACHINES // THIS IS THE ONLY PLACE WHERE PARTS ATTACH TO MACHINES
// Try to attach to a neighbor's master controller // Try to attach to a neighbor's master controller
compatibleControllers = orphan.attachToNeighbors(); compatibleControllers = orphan.attachToNeighbors();
if(compatibleControllers == null) { if (compatibleControllers == null)
{
// FOREVER ALONE! Create and register a new controller. // FOREVER ALONE! Create and register a new controller.
// THIS IS THE ONLY PLACE WHERE NEW CONTROLLERS ARE CREATED. // THIS IS THE ONLY PLACE WHERE NEW CONTROLLERS ARE
MultiblockControllerBase newController = orphan.createNewMultiblock(); // CREATED.
MultiblockControllerBase newController = orphan
.createNewMultiblock();
newController.attachBlock(orphan); newController.attachBlock(orphan);
this.controllers.add(newController); this.controllers.add(newController);
} } else if (compatibleControllers.size() > 1)
else if(compatibleControllers.size() > 1) { {
if(mergePools == null) { mergePools = new ArrayList<Set<MultiblockControllerBase>>(); } if (mergePools == null)
{
mergePools = new ArrayList<Set<MultiblockControllerBase>>();
}
// THIS IS THE ONLY PLACE WHERE MERGES ARE DETECTED // 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) // Locate the appropriate merge pool(s)
boolean hasAddedToPool = false; boolean hasAddedToPool = false;
List<Set<MultiblockControllerBase>> candidatePools = new ArrayList<Set<MultiblockControllerBase>>(); List<Set<MultiblockControllerBase>> candidatePools = new ArrayList<Set<MultiblockControllerBase>>();
for(Set<MultiblockControllerBase> candidatePool : mergePools) { for (Set<MultiblockControllerBase> candidatePool : mergePools)
if(!Collections.disjoint(candidatePool, compatibleControllers)) { {
// They share at least one element, so that means they will all touch after the merge if (!Collections.disjoint(candidatePool,
compatibleControllers))
{
// They share at least one element, so that
// means they will all touch after the merge
candidatePools.add(candidatePool); candidatePools.add(candidatePool);
} }
} }
if(candidatePools.size() <= 0) { if (candidatePools.size() <= 0)
{
// No pools nearby, create a new merge pool // No pools nearby, create a new merge pool
mergePools.add(compatibleControllers); mergePools.add(compatibleControllers);
} } else if (candidatePools.size() == 1)
else if(candidatePools.size() == 1) { {
// Only one pool nearby, simply add to that one // Only one pool nearby, simply add to that one
candidatePools.get(0).addAll(compatibleControllers); candidatePools.get(0).addAll(compatibleControllers);
} } else
else { {
// Multiple pools- merge into one, then add the compatible controllers // Multiple pools- merge into one, then add the
Set<MultiblockControllerBase> masterPool = candidatePools.get(0); // compatible controllers
Set<MultiblockControllerBase> masterPool = candidatePools
.get(0);
Set<MultiblockControllerBase> consumedPool; Set<MultiblockControllerBase> consumedPool;
for(int i = 1; i < candidatePools.size(); i++) { for (int i = 1; i < candidatePools.size(); i++)
{
consumedPool = candidatePools.get(i); consumedPool = candidatePools.get(i);
masterPool.addAll(consumedPool); masterPool.addAll(consumedPool);
mergePools.remove(consumedPool); mergePools.remove(consumedPool);
@ -174,28 +219,42 @@ public class MultiblockWorldRegistry {
} }
} }
if(mergePools != null && mergePools.size() > 0) { if (mergePools != null && mergePools.size() > 0)
// Process merges - any machines that have been marked for merge should be merged {
// Process merges - any machines that have been marked for merge
// should be merged
// into the "master" machine. // 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. // should voltron the fuck up.
for(Set<MultiblockControllerBase> mergePool : mergePools) { for (Set<MultiblockControllerBase> mergePool : mergePools)
// Search for the new master machine, which will take over all the blocks contained in the other machines {
// Search for the new master machine, which will take over all
// the blocks contained in the other machines
MultiblockControllerBase newMaster = null; MultiblockControllerBase newMaster = null;
for(MultiblockControllerBase controller : mergePool) { for (MultiblockControllerBase controller : mergePool)
if(newMaster == null || controller.shouldConsume(newMaster)) { {
if (newMaster == null
|| controller.shouldConsume(newMaster))
{
newMaster = controller; newMaster = controller;
} }
} }
if(newMaster == null) { if (newMaster == null)
BeefCoreLog.fatal("Multiblock system checked a merge pool of size %d, found no master candidates. This should never happen.", mergePool.size()); {
} BeefCoreLog
else { .fatal("Multiblock system checked a merge pool of size %d, found no master candidates. This should never happen.",
// Merge all the other machines into the master machine, then unregister them mergePool.size());
} else
{
// Merge all the other machines into the master machine,
// then unregister them
addDirtyController(newMaster); addDirtyController(newMaster);
for(MultiblockControllerBase controller : mergePool) { for (MultiblockControllerBase controller : mergePool)
if(controller != newMaster) { {
if (controller != newMaster)
{
newMaster.assimilate(controller); newMaster.assimilate(controller);
addDeadController(controller); addDeadController(controller);
addDirtyController(newMaster); addDirtyController(newMaster);
@ -206,109 +265,142 @@ public class MultiblockWorldRegistry {
} }
// Process splits and assembly // 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. // physically connected to their master.
if(dirtyControllers.size() > 0) { if (dirtyControllers.size() > 0)
{
Set<IMultiblockPart> newlyDetachedParts = null; Set<IMultiblockPart> newlyDetachedParts = null;
for(MultiblockControllerBase controller : dirtyControllers) { for (MultiblockControllerBase controller : dirtyControllers)
{
// Tell the machine to check if any parts are disconnected. // Tell the machine to check if any parts are disconnected.
// It should return a set of parts which are no longer connected. // It should return a set of parts which are no longer
// POSTCONDITION: The controller must have informed those parts that // connected.
// POSTCONDITION: The controller must have informed those parts
// that
// they are no longer connected to this machine. // they are no longer connected to this machine.
newlyDetachedParts = controller.checkForDisconnections(); newlyDetachedParts = controller.checkForDisconnections();
if(!controller.isEmpty()) { if (!controller.isEmpty())
{
controller.recalculateMinMaxCoords(); controller.recalculateMinMaxCoords();
controller.checkIfMachineIsWhole(); controller.checkIfMachineIsWhole();
} } else
else { {
addDeadController(controller); addDeadController(controller);
} }
if(newlyDetachedParts != null && newlyDetachedParts.size() > 0) { if (newlyDetachedParts != null && newlyDetachedParts.size() > 0)
// Controller has shed some parts - add them to the detached list for delayed processing {
// Controller has shed some parts - add them to the detached
// list for delayed processing
detachedParts.addAll(newlyDetachedParts); detachedParts.addAll(newlyDetachedParts);
} }
} }
dirtyControllers.clear(); dirtyControllers.clear();
} }
// Unregister dead controllers // Unregister dead controllers
if(deadControllers.size() > 0) { if (deadControllers.size() > 0)
for(MultiblockControllerBase controller : deadControllers) { {
// Go through any controllers which have marked themselves as potentially dead. for (MultiblockControllerBase controller : deadControllers)
{
// Go through any controllers which have marked themselves as
// potentially dead.
// Validate that they are empty/dead, then unregister them. // Validate that they are empty/dead, then unregister them.
if(!controller.isEmpty()) { if (!controller.isEmpty())
BeefCoreLog.fatal("Found a non-empty controller. Forcing it to shed its blocks and die. This should never happen!"); {
BeefCoreLog
.fatal("Found a non-empty controller. Forcing it to shed its blocks and die. This should never happen!");
detachedParts.addAll(controller.detachAllBlocks()); detachedParts.addAll(controller.detachAllBlocks());
} }
// THIS IS THE ONLY PLACE WHERE CONTROLLERS ARE UNREGISTERED. // THIS IS THE ONLY PLACE WHERE CONTROLLERS ARE UNREGISTERED.
this.controllers.remove(controller); this.controllers.remove(controller);
} }
deadControllers.clear(); deadControllers.clear();
} }
// Process detached blocks // Process detached blocks
// Any blocks which have been detached this tick should be moved to the orphaned // Any blocks which have been detached this tick should be moved to the
// list, and will be checked next tick to see if their chunk is still loaded. // orphaned
for(IMultiblockPart part : detachedParts) { // 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 // Ensure parts know they're detached
part.assertDetached(); part.assertDetached();
} }
addAllOrphanedPartsThreadsafe(detachedParts); addAllOrphanedPartsThreadsafe(detachedParts);
detachedParts.clear(); detachedParts.clear();
} }
/** /**
* Called when a multiblock part is added to the world, either via chunk-load or user action. * Called when a multiblock part is added to the world, either via
* If its chunk is loaded, it will be processed during the next tick. * chunk-load or user action. If its chunk is loaded, it will be processed
* If the chunk is not loaded, it will be added to a list of objects waiting for a chunkload. * during the next tick. If the chunk is not loaded, it will be added to a
* @param part The part which is being added to this world. * 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(); 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 // Part goes into the waiting-for-chunk-load list
Set<IMultiblockPart> partSet; Set<IMultiblockPart> partSet;
long chunkHash = worldLocation.getChunkXZHash(); long chunkHash = worldLocation.getChunkXZHash();
synchronized(partsAwaitingChunkLoadMutex) { synchronized (partsAwaitingChunkLoadMutex)
if(!partsAwaitingChunkLoad.containsKey(chunkHash)) { {
if (!partsAwaitingChunkLoad.containsKey(chunkHash))
{
partSet = new HashSet<IMultiblockPart>(); partSet = new HashSet<IMultiblockPart>();
partsAwaitingChunkLoad.put(chunkHash, partSet); partsAwaitingChunkLoad.put(chunkHash, partSet);
} } else
else { {
partSet = partsAwaitingChunkLoad.get(chunkHash); partSet = partsAwaitingChunkLoad.get(chunkHash);
} }
partSet.add(part); partSet.add(part);
} }
} } else
else { {
// Part goes into the orphan queue, to be checked this tick // Part goes into the orphan queue, to be checked this tick
addOrphanedPartThreadsafe(part); addOrphanedPartThreadsafe(part);
} }
} }
/** /**
* Called when a part is removed from the world, via user action or via chunk unloads. * Called when a part is removed from the world, via user action or via
* This part is removed from any lists in which it may be, and its machine is marked for recalculation. * chunk unloads. This part is removed from any lists in which it may be,
* @param part The part which is being removed. * 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(); CoordTriplet coord = part.getWorldLocation();
if(coord != null) { if (coord != null)
{
long hash = coord.getChunkXZHash(); long hash = coord.getChunkXZHash();
if(partsAwaitingChunkLoad.containsKey(hash)) { if (partsAwaitingChunkLoad.containsKey(hash))
synchronized(partsAwaitingChunkLoadMutex) { {
if(partsAwaitingChunkLoad.containsKey(hash)) { synchronized (partsAwaitingChunkLoadMutex)
{
if (partsAwaitingChunkLoad.containsKey(hash))
{
partsAwaitingChunkLoad.get(hash).remove(part); partsAwaitingChunkLoad.get(hash).remove(part);
if(partsAwaitingChunkLoad.get(hash).size() <= 0) { if (partsAwaitingChunkLoad.get(hash).size() <= 0)
{
partsAwaitingChunkLoad.remove(hash); partsAwaitingChunkLoad.remove(hash);
} }
} }
@ -317,51 +409,65 @@ public class MultiblockWorldRegistry {
} }
detachedParts.remove(part); detachedParts.remove(part);
if(orphanedParts.contains(part)) { if (orphanedParts.contains(part))
synchronized(orphanedPartsMutex) { {
synchronized (orphanedPartsMutex)
{
orphanedParts.remove(part); orphanedParts.remove(part);
} }
} }
part.assertDetached(); part.assertDetached();
} }
/** /**
* Called when the world which this World Registry represents is fully unloaded from the system. * Called when the world which this World Registry represents is fully
* Does some housekeeping just to be nice. * unloaded from the system. Does some housekeeping just to be nice.
*/ */
public void onWorldUnloaded() { public void onWorldUnloaded()
{
controllers.clear(); controllers.clear();
deadControllers.clear(); deadControllers.clear();
dirtyControllers.clear(); dirtyControllers.clear();
detachedParts.clear(); detachedParts.clear();
synchronized(partsAwaitingChunkLoadMutex) { synchronized (partsAwaitingChunkLoadMutex)
{
partsAwaitingChunkLoad.clear(); partsAwaitingChunkLoad.clear();
} }
synchronized(orphanedPartsMutex) { synchronized (orphanedPartsMutex)
{
orphanedParts.clear(); orphanedParts.clear();
} }
worldObj = null; worldObj = null;
} }
/** /**
* Called when a chunk has finished loading. Adds all of the parts which are awaiting * Called when a chunk has finished loading. Adds all of the parts which are
* load to the list of parts which are orphans and therefore will be added to machines * awaiting load to the list of parts which are orphans and therefore will
* after the next world tick. * be added to machines after the next world tick.
* *
* @param chunkX Chunk X coordinate (world coordate >> 4) of the chunk that was loaded * @param chunkX
* @param chunkZ Chunk Z coordinate (world coordate >> 4) of the chunk that was loaded * 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); long chunkHash = ChunkCoordIntPair.chunkXZ2Int(chunkX, chunkZ);
if(partsAwaitingChunkLoad.containsKey(chunkHash)) { if (partsAwaitingChunkLoad.containsKey(chunkHash))
synchronized(partsAwaitingChunkLoadMutex) { {
if(partsAwaitingChunkLoad.containsKey(chunkHash)) { synchronized (partsAwaitingChunkLoadMutex)
addAllOrphanedPartsThreadsafe(partsAwaitingChunkLoad.get(chunkHash)); {
if (partsAwaitingChunkLoad.containsKey(chunkHash))
{
addAllOrphanedPartsThreadsafe(partsAwaitingChunkLoad
.get(chunkHash));
partsAwaitingChunkLoad.remove(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. * Registers a controller as dead. It will be cleaned up at the end of the
* Note that a controller must shed all of its blocks before being marked as dead, or the system * next world tick. Note that a controller must shed all of its blocks
* will complain at you. * 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); this.deadControllers.add(deadController);
} }
/** /**
* Registers a controller as dirty - its list of attached blocks has changed, and it * Registers a controller as dirty - its list of attached blocks has
* must be re-checked for assembly and, possibly, for orphans. * 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); this.dirtyControllers.add(dirtyController);
} }
/** /**
* Use this only if you know what you're doing. You should rarely need to iterate * Use this only if you know what you're doing. You should rarely need to
* over all controllers in a world! * 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<MultiblockControllerBase> getControllers() { public Set<MultiblockControllerBase> getControllers()
{
return Collections.unmodifiableSet(controllers); return Collections.unmodifiableSet(controllers);
} }
/* *** PRIVATE HELPERS *** */ /* *** PRIVATE HELPERS *** */
private void addOrphanedPartThreadsafe(IMultiblockPart part) { private void addOrphanedPartThreadsafe(IMultiblockPart part)
synchronized(orphanedPartsMutex) { {
synchronized (orphanedPartsMutex)
{
orphanedParts.add(part); orphanedParts.add(part);
} }
} }
private void addAllOrphanedPartsThreadsafe(Collection<? extends IMultiblockPart> parts) { private void addAllOrphanedPartsThreadsafe(
synchronized(orphanedPartsMutex) { Collection<? extends IMultiblockPart> parts)
{
synchronized (orphanedPartsMutex)
{
orphanedParts.addAll(parts); orphanedParts.addAll(parts);
} }
} }
private String clientOrServer() { return worldObj.isRemote ? "CLIENT" : "SERVER"; } private String clientOrServer()
{
return worldObj.isRemote ? "CLIENT" : "SERVER";
}
} }

View file

@ -1,28 +1,22 @@
package erogenousbeef.coreTR.multiblock.rectangular; package erogenousbeef.coreTR.multiblock.rectangular;
public enum PartPosition { public enum PartPosition
Unknown, {
Interior, Unknown, Interior, FrameCorner, Frame, TopFace, BottomFace, NorthFace, SouthFace, EastFace, WestFace;
FrameCorner,
Frame, public boolean isFace(PartPosition position)
TopFace, {
BottomFace, switch (position)
NorthFace, {
SouthFace, case TopFace:
EastFace, case BottomFace:
WestFace; case NorthFace:
case SouthFace:
public boolean isFace(PartPosition position) { case EastFace:
switch(position) { case WestFace:
case TopFace: return true;
case BottomFace: default:
case NorthFace: return false;
case SouthFace:
case EastFace:
case WestFace:
return true;
default:
return false;
} }
} }
} }

View file

@ -9,122 +9,198 @@ import erogenousbeef.coreTR.multiblock.MultiblockValidationException;
public abstract class RectangularMultiblockControllerBase extends public abstract class RectangularMultiblockControllerBase extends
MultiblockControllerBase { MultiblockControllerBase {
protected RectangularMultiblockControllerBase(World world) { protected RectangularMultiblockControllerBase(World world)
{
super(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 { protected void isMachineWhole() throws MultiblockValidationException
if(connectedParts.size() < getMinimumNumberOfBlocksForAssembledMachine()) { {
if (connectedParts.size() < getMinimumNumberOfBlocksForAssembledMachine())
{
throw new MultiblockValidationException("Machine is too small."); throw new MultiblockValidationException("Machine is too small.");
} }
CoordTriplet maximumCoord = getMaximumCoord(); CoordTriplet maximumCoord = getMaximumCoord();
CoordTriplet minimumCoord = getMinimumCoord(); CoordTriplet minimumCoord = getMinimumCoord();
// Quickly check for exceeded dimensions // Quickly check for exceeded dimensions
int deltaX = maximumCoord.x - minimumCoord.x + 1; int deltaX = maximumCoord.x - minimumCoord.x + 1;
int deltaY = maximumCoord.y - minimumCoord.y + 1; int deltaY = maximumCoord.y - minimumCoord.y + 1;
int deltaZ = maximumCoord.z - minimumCoord.z + 1; int deltaZ = maximumCoord.z - minimumCoord.z + 1;
int maxX = getMaximumXSize(); int maxX = getMaximumXSize();
int maxY = getMaximumYSize(); int maxY = getMaximumYSize();
int maxZ = getMaximumZSize(); int maxZ = getMaximumZSize();
int minX = getMinimumXSize(); int minX = getMinimumXSize();
int minY = getMinimumYSize(); int minY = getMinimumYSize();
int minZ = getMinimumZSize(); 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 (maxX > 0 && deltaX > 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)); } throw new MultiblockValidationException(
if(deltaX < minX) { throw new MultiblockValidationException(String.format("Machine is too small, it must be at least %d blocks in the X dimension", minX)); } String.format(
if(deltaY < minY) { throw new MultiblockValidationException(String.format("Machine is too small, it must be at least %d blocks in the Y dimension", minY)); } "Machine is too large, it may be at most %d blocks in the X dimension",
if(deltaZ < minZ) { throw new MultiblockValidationException(String.format("Machine is too small, it must be at least %d blocks in the Z dimension", minZ)); } 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. // Now we run a simple check on each block within that volume.
// Any block deviating = NO DEAL SIR // Any block deviating = NO DEAL SIR
TileEntity te; TileEntity te;
RectangularMultiblockTileEntityBase part; RectangularMultiblockTileEntityBase part;
Class<? extends RectangularMultiblockControllerBase> myClass = this.getClass(); Class<? extends RectangularMultiblockControllerBase> myClass = this
.getClass();
for(int x = minimumCoord.x; x <= maximumCoord.x; x++) { 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 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. // Okay, figure out what sort of block this should be.
te = this.worldObj.getTileEntity(x, y, z); te = this.worldObj.getTileEntity(x, y, z);
if(te instanceof RectangularMultiblockTileEntityBase) { if (te instanceof RectangularMultiblockTileEntityBase)
part = (RectangularMultiblockTileEntityBase)te; {
part = (RectangularMultiblockTileEntityBase) te;
// Ensure this part should actually be allowed within a cube of this controller's type
if(!myClass.equals(part.getMultiblockControllerType())) // 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
else { {
// This is permitted so that we can incorporate certain non-multiblock parts inside interiors // This is permitted so that we can incorporate certain
// non-multiblock parts inside interiors
part = null; 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; int extremes = 0;
if(x == minimumCoord.x) { extremes++; } if (x == minimumCoord.x)
if(y == minimumCoord.y) { extremes++; } {
if(z == minimumCoord.z) { extremes++; } extremes++;
}
if(x == maximumCoord.x) { extremes++; } if (y == minimumCoord.y)
if(y == maximumCoord.y) { extremes++; } {
if(z == maximumCoord.z) { extremes++; } extremes++;
}
if(extremes >= 2) { if (z == minimumCoord.z)
if(part != null) { {
extremes++;
}
if (x == maximumCoord.x)
{
extremes++;
}
if (y == maximumCoord.y)
{
extremes++;
}
if (z == maximumCoord.z)
{
extremes++;
}
if (extremes >= 2)
{
if (part != null)
{
part.isGoodForFrame(); part.isGoodForFrame();
} } else
else { {
isBlockGoodForFrame(this.worldObj, x, y, z); isBlockGoodForFrame(this.worldObj, x, y, z);
} }
} } else if (extremes == 1)
else if(extremes == 1) { {
if(y == maximumCoord.y) { if (y == maximumCoord.y)
if(part != null) { {
if (part != null)
{
part.isGoodForTop(); part.isGoodForTop();
} } else
else { {
isBlockGoodForTop(this.worldObj, x, y, z); isBlockGoodForTop(this.worldObj, x, y, z);
} }
} } else if (y == minimumCoord.y)
else if(y == minimumCoord.y) { {
if(part != null) { if (part != null)
{
part.isGoodForBottom(); part.isGoodForBottom();
} } else
else { {
isBlockGoodForBottom(this.worldObj, x, y, z); isBlockGoodForBottom(this.worldObj, x, y, z);
} }
} } else
else { {
// Side // Side
if(part != null) { if (part != null)
{
part.isGoodForSides(); part.isGoodForSides();
} } else
else { {
isBlockGoodForSides(this.worldObj, x, y, z); isBlockGoodForSides(this.worldObj, x, y, z);
} }
} }
} } else
else { {
if(part != null) { if (part != null)
{
part.isGoodForInterior(); part.isGoodForInterior();
} } else
else { {
isBlockGoodForInterior(this.worldObj, x, y, z); isBlockGoodForInterior(this.worldObj, x, y, z);
} }
} }
} }
} }
} }
} }
} }

View file

@ -11,89 +11,114 @@ public abstract class RectangularMultiblockTileEntityBase extends
PartPosition position; PartPosition position;
ForgeDirection outwards; ForgeDirection outwards;
public RectangularMultiblockTileEntityBase() { public RectangularMultiblockTileEntityBase()
{
super(); super();
position = PartPosition.Unknown; position = PartPosition.Unknown;
outwards = ForgeDirection.UNKNOWN; outwards = ForgeDirection.UNKNOWN;
} }
// Positional Data // Positional Data
public ForgeDirection getOutwardsDir() { public ForgeDirection getOutwardsDir()
{
return outwards; return outwards;
} }
public PartPosition getPartPosition() { public PartPosition getPartPosition()
{
return position; return position;
} }
// Handlers from MultiblockTileEntityBase // Handlers from MultiblockTileEntityBase
@Override @Override
public void onAttached(MultiblockControllerBase newController) { public void onAttached(MultiblockControllerBase newController)
{
super.onAttached(newController); super.onAttached(newController);
recalculateOutwardsDirection(newController.getMinimumCoord(), newController.getMaximumCoord()); recalculateOutwardsDirection(newController.getMinimumCoord(),
newController.getMaximumCoord());
} }
@Override @Override
public void onMachineAssembled(MultiblockControllerBase controller) { public void onMachineAssembled(MultiblockControllerBase controller)
{
CoordTriplet maxCoord = controller.getMaximumCoord(); CoordTriplet maxCoord = controller.getMaximumCoord();
CoordTriplet minCoord = controller.getMinimumCoord(); CoordTriplet minCoord = controller.getMinimumCoord();
// Discover where I am on the reactor // Discover where I am on the reactor
recalculateOutwardsDirection(minCoord, maxCoord); recalculateOutwardsDirection(minCoord, maxCoord);
} }
@Override @Override
public void onMachineBroken() { public void onMachineBroken()
{
position = PartPosition.Unknown; position = PartPosition.Unknown;
outwards = ForgeDirection.UNKNOWN; outwards = ForgeDirection.UNKNOWN;
} }
// Positional helpers // Positional helpers
public void recalculateOutwardsDirection(CoordTriplet minCoord, CoordTriplet maxCoord) { public void recalculateOutwardsDirection(CoordTriplet minCoord,
CoordTriplet maxCoord)
{
outwards = ForgeDirection.UNKNOWN; outwards = ForgeDirection.UNKNOWN;
position = PartPosition.Unknown; position = PartPosition.Unknown;
int facesMatching = 0; int facesMatching = 0;
if(maxCoord.x == this.xCoord || minCoord.x == this.xCoord) { facesMatching++; } if (maxCoord.x == this.xCoord || minCoord.x == this.xCoord)
if(maxCoord.y == this.yCoord || minCoord.y == this.yCoord) { facesMatching++; } {
if(maxCoord.z == this.zCoord || minCoord.z == this.zCoord) { facesMatching++; } facesMatching++;
}
if(facesMatching <= 0) { position = PartPosition.Interior; } if (maxCoord.y == this.yCoord || minCoord.y == this.yCoord)
else if(facesMatching >= 3) { position = PartPosition.FrameCorner; } {
else if(facesMatching == 2) { position = PartPosition.Frame; } facesMatching++;
else { }
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 // 1 face matches
if(maxCoord.x == this.xCoord) { if (maxCoord.x == this.xCoord)
{
position = PartPosition.EastFace; position = PartPosition.EastFace;
outwards = ForgeDirection.EAST; outwards = ForgeDirection.EAST;
} } else if (minCoord.x == this.xCoord)
else if(minCoord.x == this.xCoord) { {
position = PartPosition.WestFace; position = PartPosition.WestFace;
outwards = ForgeDirection.WEST; outwards = ForgeDirection.WEST;
} } else if (maxCoord.z == this.zCoord)
else if(maxCoord.z == this.zCoord) { {
position = PartPosition.SouthFace; position = PartPosition.SouthFace;
outwards = ForgeDirection.SOUTH; outwards = ForgeDirection.SOUTH;
} } else if (minCoord.z == this.zCoord)
else if(minCoord.z == this.zCoord) { {
position = PartPosition.NorthFace; position = PartPosition.NorthFace;
outwards = ForgeDirection.NORTH; outwards = ForgeDirection.NORTH;
} } else if (maxCoord.y == this.yCoord)
else if(maxCoord.y == this.yCoord) { {
position = PartPosition.TopFace; position = PartPosition.TopFace;
outwards = ForgeDirection.UP; outwards = ForgeDirection.UP;
} } else
else { {
position = PartPosition.BottomFace; position = PartPosition.BottomFace;
outwards = ForgeDirection.DOWN; outwards = ForgeDirection.DOWN;
} }
} }
} }
///// Validation Helpers (IMultiblockPart) // /// Validation Helpers (IMultiblockPart)
public abstract void isGoodForFrame() throws MultiblockValidationException; public abstract void isGoodForFrame() throws MultiblockValidationException;
public abstract void isGoodForSides() 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 isGoodForBottom() throws MultiblockValidationException;
public abstract void isGoodForInterior() throws MultiblockValidationException; public abstract void isGoodForInterior()
throws MultiblockValidationException;
} }

View file

@ -1,15 +1,7 @@
package techreborn; package techreborn;
import cpw.mods.fml.common.FMLCommonHandler; import java.io.File;
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 net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import techreborn.achievement.TRAchievements; import techreborn.achievement.TRAchievements;
import techreborn.client.GuiHandler; import techreborn.client.GuiHandler;
@ -25,59 +17,73 @@ import techreborn.packets.PacketHandler;
import techreborn.proxies.CommonProxy; import techreborn.proxies.CommonProxy;
import techreborn.util.LogHelper; import techreborn.util.LogHelper;
import techreborn.world.TROreGen; import techreborn.world.TROreGen;
import cpw.mods.fml.common.FMLCommonHandler;
import java.io.File; 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) @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 class Core {
public static ConfigTechReborn config; public static ConfigTechReborn config;
@SidedProxy(clientSide = ModInfo.CLIENT_PROXY_CLASS, serverSide = ModInfo.SERVER_PROXY_CLASS) @SidedProxy(clientSide = ModInfo.CLIENT_PROXY_CLASS, serverSide = ModInfo.SERVER_PROXY_CLASS)
public static CommonProxy proxy; public static CommonProxy proxy;
@Mod.Instance @Mod.Instance
public static Core INSTANCE; public static Core INSTANCE;
@Mod.EventHandler @Mod.EventHandler
public void preinit(FMLPreInitializationEvent event) { public void preinit(FMLPreInitializationEvent event)
INSTANCE = this; {
String path = event.getSuggestedConfigurationFile().getAbsolutePath() INSTANCE = this;
.replace(ModInfo.MOD_ID, "TechReborn"); String path = event.getSuggestedConfigurationFile().getAbsolutePath()
.replace(ModInfo.MOD_ID, "TechReborn");
config = ConfigTechReborn.initialize(new File(path)); config = ConfigTechReborn.initialize(new File(path));
LogHelper.info("PreInitialization Compleate"); LogHelper.info("PreInitialization Compleate");
} }
@Mod.EventHandler @Mod.EventHandler
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event)
//Register ModBlocks {
ModBlocks.init(); // Register ModBlocks
//Register ModItems ModBlocks.init();
ModItems.init(); // Register ModItems
//Register Multiparts ModItems.init();
// Register Multiparts
ModParts.init(); ModParts.init();
// Recipes // Recipes
ModRecipes.init(); ModRecipes.init();
//Compat // Compat
CompatManager.init(event); CompatManager.init(event);
// WorldGen // WorldGen
GameRegistry.registerWorldGenerator(new TROreGen(), 0); GameRegistry.registerWorldGenerator(new TROreGen(), 0);
//Register Gui Handler // Register Gui Handler
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler()); NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
//packets // packets
PacketHandler.setChannels(NetworkRegistry.INSTANCE.newChannel(ModInfo.MOD_ID + "_packets", new PacketHandler())); PacketHandler.setChannels(NetworkRegistry.INSTANCE.newChannel(
//Achievements ModInfo.MOD_ID + "_packets", new PacketHandler()));
TRAchievements.init(); // Achievements
//Multiblock events TRAchievements.init();
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler()); // Multiblock events
FMLCommonHandler.instance().bus().register(new MultiblockServerTickHandler()); MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
LogHelper.info("Initialization Compleate"); FMLCommonHandler.instance().bus()
} .register(new MultiblockServerTickHandler());
@Mod.EventHandler LogHelper.info("Initialization Compleate");
public void postinit(FMLPostInitializationEvent event) }
{
RecipeManager.init(); @Mod.EventHandler
} public void postinit(FMLPostInitializationEvent event)
{
// Has to be done here as buildcraft registers there recipes late
RecipeManager.init();
}
} }

View file

@ -8,23 +8,27 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement; import net.minecraft.stats.Achievement;
public class AchievementMod extends Achievement{ public class AchievementMod extends Achievement {
public static List<Achievement> achievements = new ArrayList(); public static List<Achievement> 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); achievements.add(this);
registerStat(); 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); 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); this(name, x, y, new ItemStack(icon), parent);
} }

View file

@ -7,22 +7,30 @@ import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
public class AchievementTriggerer { public class AchievementTriggerer {
@SubscribeEvent @SubscribeEvent
public void onItemPickedUp(ItemPickupEvent event) { public void onItemPickedUp(ItemPickupEvent event)
{
ItemStack stack = event.pickedUp.getEntityItem(); ItemStack stack = event.pickedUp.getEntityItem();
if(stack != null && stack.getItem() instanceof IPickupAchievement) { if (stack != null && stack.getItem() instanceof IPickupAchievement)
Achievement achievement = ((IPickupAchievement) stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp); {
if(achievement != null) Achievement achievement = ((IPickupAchievement) stack.getItem())
.getAchievementOnPickup(stack, event.player, event.pickedUp);
if (achievement != null)
event.player.addStat(achievement, 1); event.player.addStat(achievement, 1);
} }
} }
@SubscribeEvent @SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event) { 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 (event.crafting != null
if(achievement != 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); event.player.addStat(achievement, 1);
} }
} }

View file

@ -6,7 +6,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement; import net.minecraft.stats.Achievement;
public interface ICraftAchievement { public interface ICraftAchievement {
public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix); public Achievement getAchievementOnCraft(ItemStack stack,
EntityPlayer player, IInventory matrix);
} }

View file

@ -6,7 +6,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement; import net.minecraft.stats.Achievement;
public interface IPickupAchievement { public interface IPickupAchievement {
public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item); public Achievement getAchievementOnPickup(ItemStack stack,
EntityPlayer player, EntityItem item);
} }

View file

@ -1,33 +1,39 @@
package techreborn.achievement; 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.item.ItemStack;
import net.minecraft.stats.Achievement; import net.minecraft.stats.Achievement;
import net.minecraftforge.common.AchievementPage; import net.minecraftforge.common.AchievementPage;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import cpw.mods.fml.common.FMLCommonHandler;
public class TRAchievements { public class TRAchievements {
public static AchievementPage techrebornPage; public static AchievementPage techrebornPage;
public static int pageIndex; public static int pageIndex;
public static Achievement ore_PickUp; public static Achievement ore_PickUp;
public static Achievement thermalgen_Craft; public static Achievement thermalgen_Craft;
public static Achievement centrifuge_Craft; public static Achievement centrifuge_Craft;
public static void init() public static void init()
{ {
ore_PickUp = new AchievementMod("ore_PickUp", 0, 0, new ItemStack(ModBlocks.ore, 1, 0), null); ore_PickUp = new AchievementMod("ore_PickUp", 0, 0, new ItemStack(
centrifuge_Craft = new AchievementMod("centrifuge_Craft", 1, 1, ModBlocks.centrifuge, ore_PickUp); ModBlocks.ore, 1, 0), null);
thermalgen_Craft = new AchievementMod("thermalgen_Craft", 2, 1, ModBlocks.thermalGenerator, ore_PickUp); 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(); 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); AchievementPage.registerAchievementPage(techrebornPage);
FMLCommonHandler.instance().bus().register(new AchievementTriggerer()); FMLCommonHandler.instance().bus().register(new AchievementTriggerer());
} }
} }

View file

@ -4,72 +4,83 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class CentrifugeRecipie { public class CentrifugeRecipie {
ItemStack inputItem; ItemStack inputItem;
ItemStack output1, output2, output3, output4; ItemStack output1, output2, output3, output4;
int tickTime; int tickTime;
int cells; int cells;
public CentrifugeRecipie(ItemStack inputItem, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int cells) { public CentrifugeRecipie(ItemStack inputItem, ItemStack output1,
this.inputItem = inputItem; ItemStack output2, ItemStack output3, ItemStack output4,
this.output1 = output1; int tickTime, int cells)
this.output2 = output2; {
this.output3 = output3; this.inputItem = inputItem;
this.output4 = output4; this.output1 = output1;
this.tickTime = tickTime; this.output2 = output2;
this.cells = cells; 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) { public CentrifugeRecipie(Item inputItem, int inputAmount, Item output1,
this.inputItem = new ItemStack(inputItem, inputAmount); Item output2, Item output3, Item output4, int tickTime, int cells)
if (output1 != null) {
this.output1 = new ItemStack(output1); this.inputItem = new ItemStack(inputItem, inputAmount);
if (output2 != null) if (output1 != null)
this.output2 = new ItemStack(output2); this.output1 = new ItemStack(output1);
if (output3 != null) if (output2 != null)
this.output3 = new ItemStack(output3); this.output2 = new ItemStack(output2);
if (output4 != null) if (output3 != null)
this.output4 = new ItemStack(output4); this.output3 = new ItemStack(output3);
this.tickTime = tickTime; if (output4 != null)
this.cells = cells; this.output4 = new ItemStack(output4);
} this.tickTime = tickTime;
this.cells = cells;
}
public CentrifugeRecipie(CentrifugeRecipie centrifugeRecipie) { public CentrifugeRecipie(CentrifugeRecipie centrifugeRecipie)
this.inputItem = centrifugeRecipie.getInputItem(); {
this.output1 = centrifugeRecipie.getOutput1(); this.inputItem = centrifugeRecipie.getInputItem();
this.output2 = centrifugeRecipie.getOutput2(); this.output1 = centrifugeRecipie.getOutput1();
this.output3 = centrifugeRecipie.getOutput3(); this.output2 = centrifugeRecipie.getOutput2();
this.output4 = centrifugeRecipie.getOutput4(); this.output3 = centrifugeRecipie.getOutput3();
this.tickTime = centrifugeRecipie.getTickTime(); this.output4 = centrifugeRecipie.getOutput4();
this.cells = centrifugeRecipie.getCells(); this.tickTime = centrifugeRecipie.getTickTime();
} this.cells = centrifugeRecipie.getCells();
}
public ItemStack getInputItem() { public ItemStack getInputItem()
return inputItem; {
} return inputItem;
}
public ItemStack getOutput1() { public ItemStack getOutput1()
return output1; {
} return output1;
}
public ItemStack getOutput2() { public ItemStack getOutput2()
return output2; {
} return output2;
}
public ItemStack getOutput3() { public ItemStack getOutput3()
return output3; {
} return output3;
}
public ItemStack getOutput4() { public ItemStack getOutput4()
return output4; {
} return output4;
}
public int getTickTime() { public int getTickTime()
return tickTime; {
} return tickTime;
}
public int getCells() { public int getCells()
return cells; {
} return cells;
}
} }

View file

@ -1,5 +1,9 @@
package techreborn.api; package techreborn.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -9,104 +13,118 @@ import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class RollingMachineRecipe { public class RollingMachineRecipe {
private final List<IRecipe> recipes = new ArrayList<IRecipe>(); private final List<IRecipe> recipes = new ArrayList<IRecipe>();
public static final RollingMachineRecipe instance = new RollingMachineRecipe(); public static final RollingMachineRecipe instance = new RollingMachineRecipe();
public void addRecipe(ItemStack output, Object... components) { public void addRecipe(ItemStack output, Object... components)
String s = ""; {
int i = 0; String s = "";
int j = 0; int i = 0;
int k = 0; int j = 0;
if(components[i] instanceof String[]) { int k = 0;
String as[] = (String[])components[i++]; if (components[i] instanceof String[])
for(int l = 0; l < as.length; l++) { {
String s2 = as[l]; String as[] = (String[]) components[i++];
k++; for (int l = 0; l < as.length; l++)
j = s2.length(); {
s = (new StringBuilder()).append(s).append(s2).toString(); String s2 = as[l];
} k++;
} else { j = s2.length();
while(components[i] instanceof String) { s = (new StringBuilder()).append(s).append(s2).toString();
String s1 = (String)components[i++]; }
k++; } else
j = s1.length(); {
s = (new StringBuilder()).append(s).append(s1).toString(); while (components[i] instanceof String)
} {
} String s1 = (String) components[i++];
HashMap hashmap = new HashMap(); k++;
for(; i < components.length; i += 2) { j = s1.length();
Character character = (Character)components[i]; s = (new StringBuilder()).append(s).append(s1).toString();
ItemStack itemstack1 = null; }
if(components[i + 1] instanceof Item) { }
itemstack1 = new ItemStack((Item)components[i + 1]); HashMap hashmap = new HashMap();
} else if(components[i + 1] instanceof Block) { for (; i < components.length; i += 2)
itemstack1 = new ItemStack((Block)components[i + 1], 1, -1); {
} else if(components[i + 1] instanceof ItemStack) { Character character = (Character) components[i];
itemstack1 = (ItemStack)components[i + 1]; ItemStack itemstack1 = null;
} if (components[i + 1] instanceof Item)
hashmap.put(character, itemstack1); {
} 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]; ItemStack recipeArray[] = new ItemStack[j * k];
for(int i1 = 0; i1 < j * k; i1++) { for (int i1 = 0; i1 < j * k; i1++)
char c = s.charAt(i1); {
if(hashmap.containsKey(Character.valueOf(c))) { char c = s.charAt(i1);
recipeArray[i1] = ((ItemStack)hashmap.get(Character.valueOf(c))).copy(); if (hashmap.containsKey(Character.valueOf(c)))
} else { {
recipeArray[i1] = null; 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) { public void addShapelessRecipe(ItemStack output, Object... components)
List<ItemStack> ingredients = new ArrayList<ItemStack>(); {
for(int j = 0; j < components.length; j++) { List<ItemStack> ingredients = new ArrayList<ItemStack>();
Object obj = components[j]; for (int j = 0; j < components.length; j++)
if(obj instanceof ItemStack) { {
ingredients.add(((ItemStack)obj).copy()); Object obj = components[j];
continue; if (obj instanceof ItemStack)
} {
if(obj instanceof Item) { ingredients.add(((ItemStack) obj).copy());
ingredients.add(new ItemStack((Item)obj)); continue;
continue; }
} if (obj instanceof Item)
if(obj instanceof Block) { {
ingredients.add(new ItemStack((Block)obj)); ingredients.add(new ItemStack((Item) obj));
} else { continue;
throw new RuntimeException("Invalid shapeless recipe!"); }
} 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) { return null;
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<IRecipe> getRecipeList() {
return recipes;
}
public List<IRecipe> getRecipeList()
{
return recipes;
}
} }

View file

@ -1,45 +1,58 @@
package techreborn.api; package techreborn.api;
import java.util.ArrayList;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import techreborn.util.ItemUtils; import techreborn.util.ItemUtils;
import java.util.ArrayList;
public final class TechRebornAPI { public final class TechRebornAPI {
public static ArrayList<CentrifugeRecipie> centrifugeRecipies = new ArrayList<CentrifugeRecipie>(); public static ArrayList<CentrifugeRecipie> centrifugeRecipies = new ArrayList<CentrifugeRecipie>();
public static ArrayList<RollingMachineRecipe> rollingmachineRecipes = new ArrayList<RollingMachineRecipe>(); public static ArrayList<RollingMachineRecipe> rollingmachineRecipes = new ArrayList<RollingMachineRecipe>();
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) { public static void addRollingMachinceRecipe(ItemStack output,
boolean shouldAdd = true; Object... components)
for (CentrifugeRecipie centrifugeRecipie : centrifugeRecipies) { {
if (ItemUtils.isItemEqual(centrifugeRecipie.getInputItem(), recipie.getInputItem(), false, true)) { RollingMachineRecipe.instance.addRecipe(output, components);
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) { public void addShapelessRollingMachinceRecipe(ItemStack output,
RollingMachineRecipe.instance.addRecipe(output, components); Object... components)
} {
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
public void addShapelessRollingMachinceRecipe(ItemStack output, Object... components) { }
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
}
} }
class RegisteredItemRecipe extends Exception { class RegisteredItemRecipe extends Exception {
public RegisteredItemRecipe(String message) { public RegisteredItemRecipe(String message)
super(message); {
} super(message);
}
} }

View file

@ -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; import cpw.mods.fml.common.API;

View file

@ -1,7 +1,5 @@
package techreborn.blocks; package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -19,115 +17,146 @@ import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileBlastFurnace; import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileMachineCasing; 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) @SideOnly(Side.CLIENT)
private IIcon iconFront; private IIcon iconFront;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconTop; private IIcon iconTop;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconBottom; private IIcon iconBottom;
public BlockBlastFurnace(Material material) public BlockBlastFurnace(Material material)
{ {
super(material); super(material);
setCreativeTab(TechRebornCreativeTab.instance); setCreativeTab(TechRebornCreativeTab.instance);
setBlockName("techreborn.blastfurnace"); setBlockName("techreborn.blastfurnace");
setHardness(2F); 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); @SideOnly(Side.CLIENT)
this.setDefaultDirection(world, x, y, z); public IIcon getIcon(int side, int metadata)
{
} return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
private void setDefaultDirection(World world, int x, int y, int z) { : (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()) { super.onBlockAdded(world, x, y, z);
b = 3; this.setDefaultDirection(world, x, y, z);
}
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)
{
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { 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) { if (block1.func_149730_j() && !block2.func_149730_j())
world.setBlockMetadataWithNotify(x, y, z, 2, 2); {
} b = 3;
if(l == 1) { }
world.setBlockMetadataWithNotify(x, y, z, 5, 2); if (block2.func_149730_j() && !block1.func_149730_j())
} {
if(l == 2) { b = 2;
world.setBlockMetadataWithNotify(x, y, z, 3, 2); }
} if (block3.func_149730_j() && !block4.func_149730_j())
if(l == 3) { {
world.setBlockMetadataWithNotify(x, y, z, 4, 2); 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);
}
}
} }

View file

@ -1,7 +1,5 @@
package techreborn.blocks; package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -16,104 +14,131 @@ import net.minecraft.world.World;
import techreborn.Core; import techreborn.Core;
import techreborn.client.GuiHandler; import techreborn.client.GuiHandler;
import techreborn.tiles.TileCentrifuge; import techreborn.tiles.TileCentrifuge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCentrifuge extends BlockContainer { public class BlockCentrifuge extends BlockContainer {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconFront; private IIcon iconFront;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconTop; private IIcon iconTop;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconBottom; private IIcon iconBottom;
public BlockCentrifuge() {
super(Material.piston);
setHardness(2F);
}
@Override public BlockCentrifuge()
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { {
return new TileCentrifuge(); super(Material.piston);
} setHardness(2F);
}
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
if (!player.isSneaking()) {
player.openGui(Core.INSTANCE, GuiHandler.centrifugeID, world, x, y, z); return new TileCentrifuge();
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) {
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); return metadata == 0 && side == 3 ? this.iconFront
this.setDefaultDirection(world, x, y, z); : 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) { public void onBlockAdded(World world, int x, int y, int z)
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; 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);
} byte b = 3;
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 (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, b, 2);
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);
}
}
} }

View file

@ -1,8 +1,8 @@
package techreborn.blocks; package techreborn.blocks;
import cpw.mods.fml.relauncher.Side; import java.util.List;
import cpw.mods.fml.relauncher.SideOnly; import java.util.Random;
import erogenousbeef.coreTR.multiblock.BlockMultiblockBase;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@ -15,67 +15,79 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileMachineCasing; import techreborn.tiles.TileMachineCasing;
import cpw.mods.fml.relauncher.Side;
import java.util.List; import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random; import erogenousbeef.coreTR.multiblock.BlockMultiblockBase;
public class BlockMachineCasing extends 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); super(material);
setCreativeTab(TechRebornCreativeTab.instance); setCreativeTab(TechRebornCreativeTab.instance);
setBlockName("techreborn.machineCasing"); setBlockName("techreborn.machineCasing");
setHardness(2F); setHardness(2F);
} }
@Override
public Item getItemDropped(int meta, Random random, int fortune) {
return Item.getItemFromBlock(this);
}
@Override @Override
@SideOnly(Side.CLIENT) public Item getItemDropped(int meta, Random random, int fortune)
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { {
for (int meta = 0; meta < types.length; meta++) { return Item.getItemFromBlock(this);
list.add(new ItemStack(item, 1, meta)); }
}
}
@Override @Override
public int damageDropped(int metaData) { @SideOnly(Side.CLIENT)
//TODO RubyOre Returns Rubys public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list)
return metaData; {
} for (int meta = 0; meta < types.length; meta++)
{
list.add(new ItemStack(item, 1, meta));
}
}
@Override @Override
@SideOnly(Side.CLIENT) public int damageDropped(int metaData)
public void registerBlockIcons(IIconRegister iconRegister) { {
this.textures = new IIcon[types.length]; // TODO RubyOre Returns Rubys
return metaData;
}
for (int i = 0; i < types.length; i++) { @Override
textures[i] = iconRegister.registerIcon("techreborn:" + "machine/casing" + types[i]); @SideOnly(Side.CLIENT)
} public void registerBlockIcons(IIconRegister iconRegister)
} {
this.textures = new IIcon[types.length];
@Override for (int i = 0; i < types.length; i++)
@SideOnly(Side.CLIENT) {
public IIcon getIcon(int side, int metaData) { textures[i] = iconRegister.registerIcon("techreborn:"
metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); + "machine/casing" + types[i]);
}
}
if (ForgeDirection.getOrientation(side) == ForgeDirection.UP @Override
|| ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) { @SideOnly(Side.CLIENT)
return textures[metaData]; public IIcon getIcon(int side, int metaData)
} else { {
return textures[metaData]; metaData = MathHelper.clamp_int(metaData, 0, types.length - 1);
}
}
@Override if (ForgeDirection.getOrientation(side) == ForgeDirection.UP
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN)
return new TileMachineCasing(); {
} return textures[metaData];
} else
{
return textures[metaData];
}
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
{
return new TileMachineCasing();
}
} }

View file

@ -18,61 +18,71 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockOre extends Block { public class BlockOre extends Block {
public static final String[] types = new String[] public static final String[] types = new String[]
{ { "Galena", "Iridium", "Ruby", "Sapphire", "Bauxite", "Pyrite", "Cinnabar",
"Galena", "Iridium", "Ruby", "Sapphire", "Bauxite", "Pyrite", "Cinnabar", "Sphalerite", "Sphalerite", "Tungston", "Sheldonite", "Olivine", "Sodalite",
"Tungston", "Sheldonite", "Olivine", "Sodalite", "Copper", "Tin", "Lead", "Silver" "Copper", "Tin", "Lead", "Silver" };
};
private IIcon[] textures; private IIcon[] textures;
public BlockOre(Material material) { public BlockOre(Material material)
super(material); {
setBlockName("techreborn.ore"); super(material);
setCreativeTab(TechRebornCreativeTabMisc.instance); setBlockName("techreborn.ore");
setHardness(1f); setCreativeTab(TechRebornCreativeTabMisc.instance);
} setHardness(1f);
}
@Override @Override
public Item getItemDropped(int meta, Random random, int fortune) { public Item getItemDropped(int meta, Random random, int fortune)
return Item.getItemFromBlock(this); {
} return Item.getItemFromBlock(this);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list)
for (int meta = 0; meta < types.length; meta++) { {
list.add(new ItemStack(item, 1, meta)); for (int meta = 0; meta < types.length; meta++)
} {
} list.add(new ItemStack(item, 1, meta));
}
}
@Override @Override
public int damageDropped(int metaData) { public int damageDropped(int metaData)
//TODO RubyOre Returns Rubys {
return metaData; // TODO RubyOre Returns Rubys
} return metaData;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) { public void registerBlockIcons(IIconRegister iconRegister)
this.textures = new IIcon[types.length]; {
this.textures = new IIcon[types.length];
for (int i = 0; i < types.length; i++) { for (int i = 0; i < types.length; i++)
textures[i] = iconRegister.registerIcon("techreborn:" + "ore/ore" + types[i]); {
} textures[i] = iconRegister.registerIcon("techreborn:" + "ore/ore"
} + types[i]);
}
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metaData) { public IIcon getIcon(int side, int metaData)
metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); {
metaData = MathHelper.clamp_int(metaData, 0, types.length - 1);
if (ForgeDirection.getOrientation(side) == ForgeDirection.UP if (ForgeDirection.getOrientation(side) == ForgeDirection.UP
|| ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) { || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN)
return textures[metaData]; {
} else { return textures[metaData];
return textures[metaData]; } else
} {
} return textures[metaData];
}
}
} }

View file

@ -1,7 +1,5 @@
package techreborn.blocks; package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@ -12,47 +10,57 @@ import net.minecraft.world.World;
import techreborn.Core; import techreborn.Core;
import techreborn.client.GuiHandler; import techreborn.client.GuiHandler;
import techreborn.tiles.TileQuantumChest; import techreborn.tiles.TileQuantumChest;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuantumChest extends BlockContainer { public class BlockQuantumChest extends BlockContainer {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon top; private IIcon top;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon other; private IIcon other;
public BlockQuantumChest() { public BlockQuantumChest()
super(Material.piston); {
setHardness(2f); super(Material.piston);
} setHardness(2f);
}
@Override @Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
return new TileQuantumChest(); {
} return new TileQuantumChest();
}
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, int x, int y, int z,
if (!player.isSneaking()) EntityPlayer player, int side, float hitX, float hitY, float hitZ)
player.openGui(Core.INSTANCE, GuiHandler.quantumChestID, world, x, y, z); {
return true; if (!player.isSneaking())
} player.openGui(Core.INSTANCE, GuiHandler.quantumChestID, world, x,
y, z);
return true;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) { public void registerBlockIcons(IIconRegister icon)
top = icon.registerIcon("techreborn:machine/quantum_top"); {
other = icon.registerIcon("techreborn:machine/quantum_chest"); top = icon.registerIcon("techreborn:machine/quantum_top");
} other = icon.registerIcon("techreborn:machine/quantum_chest");
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int currentSide, int meta) { public IIcon getIcon(int currentSide, int meta)
//TODO chest rotation {
if (currentSide == 1) { // TODO chest rotation
return top; if (currentSide == 1)
} else { {
return other; return top;
} } else
} {
return other;
}
}
} }

View file

@ -1,7 +1,5 @@
package techreborn.blocks; package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@ -12,45 +10,56 @@ import net.minecraft.world.World;
import techreborn.Core; import techreborn.Core;
import techreborn.client.GuiHandler; import techreborn.client.GuiHandler;
import techreborn.tiles.TileQuantumTank; import techreborn.tiles.TileQuantumTank;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuantumTank extends BlockContainer { public class BlockQuantumTank extends BlockContainer {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon top; private IIcon top;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon other; private IIcon other;
public BlockQuantumTank() { public BlockQuantumTank()
super(Material.piston); {
setHardness(2f); super(Material.piston);
} setHardness(2f);
}
@Override @Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
return new TileQuantumTank(); {
} return new TileQuantumTank();
}
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, int x, int y, int z,
if (!player.isSneaking()) EntityPlayer player, int side, float hitX, float hitY, float hitZ)
player.openGui(Core.INSTANCE, GuiHandler.quantumTankID, world, x, y, z); {
return true; if (!player.isSneaking())
} player.openGui(Core.INSTANCE, GuiHandler.quantumTankID, world, x,
y, z);
return true;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) { public void registerBlockIcons(IIconRegister icon)
top = icon.registerIcon("techreborn:machine/quantum_top"); {
other = icon.registerIcon("techreborn:machine/ThermalGenerator_other"); top = icon.registerIcon("techreborn:machine/quantum_top");
} other = icon.registerIcon("techreborn:machine/ThermalGenerator_other");
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int currentSide, int meta) { public IIcon getIcon(int currentSide, int meta)
if (currentSide == 1) { {
return top; if (currentSide == 1)
} else { {
return other; return top;
} } else
} {
return other;
}
}
} }

View file

@ -1,7 +1,5 @@
package techreborn.blocks; package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -17,106 +15,132 @@ import techreborn.Core;
import techreborn.client.GuiHandler; import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileRollingMachine; import techreborn.tiles.TileRollingMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockRollingMachine extends BlockContainer { public class BlockRollingMachine extends BlockContainer {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconFront; private IIcon iconFront;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconTop; private IIcon iconTop;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconBottom; private IIcon iconBottom;
public BlockRollingMachine(Material material) { public BlockRollingMachine(Material material)
super(material.piston); {
setCreativeTab(TechRebornCreativeTab.instance); super(material.piston);
setBlockName("techreborn.rollingmachine"); setCreativeTab(TechRebornCreativeTab.instance);
setHardness(2f); setBlockName("techreborn.rollingmachine");
} setHardness(2f);
}
@Override @Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
return new TileRollingMachine(); {
} return new TileRollingMachine();
}
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, int x, int y, int z,
if (!player.isSneaking()) EntityPlayer player, int side, float hitX, float hitY, float hitZ)
player.openGui(Core.INSTANCE, GuiHandler.rollingMachineID, world, x, y, z); {
return true; if (!player.isSneaking())
} player.openGui(Core.INSTANCE, GuiHandler.rollingMachineID, world,
x, y, z);
@Override return true;
@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) {
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);
} public void onBlockAdded(World world, int x, int y, int z)
{
private void setDefaultDirection(World world, int x, int y, int z) {
if(!world.isRemote) { super.onBlockAdded(world, x, y, z);
Block block1 = world.getBlock(x, y, z - 1); this.setDefaultDirection(world, x, y, z);
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; }
if(block1.func_149730_j() && !block2.func_149730_j()) { private void setDefaultDirection(World world, int x, int y, int z)
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); 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;
} if (block1.func_149730_j() && !block2.func_149730_j())
{
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { 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);
}
}
} }

View file

@ -18,60 +18,70 @@ import cpw.mods.fml.relauncher.SideOnly;
public class BlockStorage extends Block { public class BlockStorage extends Block {
public static final String[] types = new String[] public static final String[] types = new String[]
{ { "Silver", "Aluminium", "Titanium", "Sapphire", "Ruby", "GreenSapphire",
"Silver", "Aluminium", "Titanium", "Sapphire", "Ruby", "GreenSapphire", "Chrome", "Electrum", "Tungsten", "Chrome", "Electrum", "Tungsten", "Lead", "Zinc", "Brass", "Steel",
"Lead", "Zinc", "Brass", "Steel", "Platinum", "Nickel", "Invar", "Platinum", "Nickel", "Invar", };
};
private IIcon[] textures; private IIcon[] textures;
public BlockStorage(Material material) { public BlockStorage(Material material)
super(material); {
setBlockName("techreborn.storage"); super(material);
setCreativeTab(TechRebornCreativeTabMisc.instance); setBlockName("techreborn.storage");
setHardness(2f); setCreativeTab(TechRebornCreativeTabMisc.instance);
} setHardness(2f);
}
@Override @Override
public Item getItemDropped(int par1, Random random, int par2) { public Item getItemDropped(int par1, Random random, int par2)
return Item.getItemFromBlock(this); {
} return Item.getItemFromBlock(this);
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list)
for (int meta = 0; meta < types.length; meta++) { {
list.add(new ItemStack(item, 1, meta)); for (int meta = 0; meta < types.length; meta++)
} {
} list.add(new ItemStack(item, 1, meta));
}
}
@Override @Override
public int damageDropped(int metaData) { public int damageDropped(int metaData)
return metaData; {
} return metaData;
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) { public void registerBlockIcons(IIconRegister iconRegister)
this.textures = new IIcon[types.length]; {
this.textures = new IIcon[types.length];
for (int i = 0; i < types.length; i++) { for (int i = 0; i < types.length; i++)
textures[i] = iconRegister.registerIcon("techreborn:" + "storage/storage" + types[i]); {
} textures[i] = iconRegister.registerIcon("techreborn:"
} + "storage/storage" + types[i]);
}
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metaData) { public IIcon getIcon(int side, int metaData)
metaData = MathHelper.clamp_int(metaData, 0, types.length - 1); {
metaData = MathHelper.clamp_int(metaData, 0, types.length - 1);
if (ForgeDirection.getOrientation(side) == ForgeDirection.UP if (ForgeDirection.getOrientation(side) == ForgeDirection.UP
|| ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) { || ForgeDirection.getOrientation(side) == ForgeDirection.DOWN)
return textures[metaData]; {
} else { return textures[metaData];
return textures[metaData]; } else
} {
} return textures[metaData];
}
}
} }

View file

@ -1,7 +1,7 @@
package techreborn.blocks; package techreborn.blocks;
import cpw.mods.fml.relauncher.Side; import java.util.Random;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -18,113 +18,137 @@ import net.minecraft.world.World;
import techreborn.Core; import techreborn.Core;
import techreborn.client.GuiHandler; import techreborn.client.GuiHandler;
import techreborn.tiles.TileThermalGenerator; import techreborn.tiles.TileThermalGenerator;
import cpw.mods.fml.relauncher.Side;
import java.util.Random; import cpw.mods.fml.relauncher.SideOnly;
public class BlockThermalGenerator extends BlockContainer { public class BlockThermalGenerator extends BlockContainer {
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconFront; private IIcon iconFront;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconTop; private IIcon iconTop;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
private IIcon iconBottom; private IIcon iconBottom;
public BlockThermalGenerator() { public BlockThermalGenerator()
super(Material.piston); {
setHardness(2f); 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) {
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);
} public void onBlockAdded(World world, int x, int y, int z)
{
private void setDefaultDirection(World world, int x, int y, int z) {
if(!world.isRemote) { super.onBlockAdded(world, x, y, z);
Block block1 = world.getBlock(x, y, z - 1); this.setDefaultDirection(world, x, y, z);
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; }
if(block1.func_149730_j() && !block2.func_149730_j()) { private void setDefaultDirection(World world, int x, int y, int z)
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); 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;
} if (block1.func_149730_j() && !block2.func_149730_j())
{
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { 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 void onBlockPlacedBy(World world, int x, int y, int z,
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { EntityLivingBase player, ItemStack itemstack)
return new TileThermalGenerator(); {
}
int l = MathHelper
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
@Override if (l == 0)
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { {
if (!player.isSneaking()) world.setBlockMetadataWithNotify(x, y, z, 2, 2);
player.openGui(Core.INSTANCE, GuiHandler.thermalGeneratorID, world, x, y, z); }
return true; 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 @Override
return Item.getItemFromBlock(Blocks.furnace); 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);
}
} }

View file

@ -1,63 +1,106 @@
package techreborn.client; package techreborn.client;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.world.World;
import techreborn.client.container.*; import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.gui.*; 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.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 class GuiHandler implements IGuiHandler {
public static final int thermalGeneratorID = 0; public static final int thermalGeneratorID = 0;
public static final int quantumTankID = 1; public static final int quantumTankID = 1;
public static final int quantumChestID = 2; public static final int quantumChestID = 2;
public static final int centrifugeID = 3; public static final int centrifugeID = 3;
public static final int rollingMachineID = 4; public static final int rollingMachineID = 4;
public static final int blastFurnaceID = 5; public static final int blastFurnaceID = 5;
public static final int pdaID = 6; 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 return null;
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;
}
@Override @Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { public Object getClientGuiElement(int ID, EntityPlayer player, World world,
if (ID == thermalGeneratorID) { int x, int y, int z)
return new GuiThermalGenerator(player, (TileThermalGenerator) world.getTileEntity(x, y, z)); {
} else if (ID == quantumTankID) { if (ID == thermalGeneratorID)
return new GuiQuantumTank(player, (TileQuantumTank) world.getTileEntity(x, y, z)); {
} else if (ID == quantumChestID) { return new GuiThermalGenerator(player,
return new GuiQuantumChest(player, (TileQuantumChest) world.getTileEntity(x, y, z)); (TileThermalGenerator) world.getTileEntity(x, y, z));
} else if (ID == centrifugeID) { } else if (ID == quantumTankID)
return new GuiCentrifuge(player, (TileCentrifuge) world.getTileEntity(x, y, z)); {
} else if (ID == rollingMachineID) { return new GuiQuantumTank(player,
return new GuiRollingMachine(player, (TileRollingMachine) world.getTileEntity(x, y, z)); (TileQuantumTank) world.getTileEntity(x, y, z));
} else if (ID == blastFurnaceID) { } else if (ID == quantumChestID)
return new GuiBlastFurnace(player, (TileBlastFurnace) world.getTileEntity(x, y, z)); {
} else if (ID == pdaID) { return new GuiQuantumChest(player,
return new GuiPda(player); (TileQuantumChest) world.getTileEntity(x, y, z));
} } else if (ID == centrifugeID)
return null; {
} 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;
}
} }

View file

@ -4,34 +4,38 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class SlotFake extends Slot { public class SlotFake extends Slot {
public boolean mCanInsertItem; public boolean mCanInsertItem;
public boolean mCanStackItem; public boolean mCanStackItem;
public int mMaxStacksize = 127; 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) { public boolean isItemValid(ItemStack par1ItemStack)
super(par1iInventory, par2, par3, par4); {
this.mCanInsertItem = aCanInsertItem; return this.mCanInsertItem;
this.mCanStackItem = aCanStackItem; }
this.mMaxStacksize = aMaxStacksize;
}
public boolean isItemValid(ItemStack par1ItemStack) { public int getSlotStackLimit()
return this.mCanInsertItem; {
} return this.mMaxStacksize;
}
public int getSlotStackLimit() { public boolean getHasStack()
return this.mMaxStacksize; {
} return false;
}
public boolean getHasStack() { public ItemStack decrStackSize(int par1)
return false; {
} return !this.mCanStackItem ? null : super.decrStackSize(par1);
}
public ItemStack decrStackSize(int par1) {
return !this.mCanStackItem ? null : super.decrStackSize(par1);
}
} }

View file

@ -6,15 +6,18 @@ import net.minecraft.item.ItemStack;
public class SlotInput extends Slot { public class SlotInput extends Slot {
public SlotInput(IInventory par1iInventory, int par2, int par3, int par4) { public SlotInput(IInventory par1iInventory, int par2, int par3, int par4)
super(par1iInventory, par2, par3, par4); {
} super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack par1ItemStack) { public boolean isItemValid(ItemStack par1ItemStack)
return false; {
} return false;
}
public int getSlotStackLimit() { public int getSlotStackLimit()
return 64; {
} return 64;
}
} }

View file

@ -6,15 +6,18 @@ import net.minecraft.item.ItemStack;
public class SlotOutput extends Slot { public class SlotOutput extends Slot {
public SlotOutput(IInventory par1iInventory, int par2, int par3, int par4) { public SlotOutput(IInventory par1iInventory, int par2, int par3, int par4)
super(par1iInventory, par2, par3, par4); {
} super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack par1ItemStack) { public boolean isItemValid(ItemStack par1ItemStack)
return false; {
} return false;
}
public int getSlotStackLimit() { public int getSlotStackLimit()
return 64; {
} return 64;
}
} }

View file

@ -6,14 +6,16 @@ import techreborn.init.ModBlocks;
public class TechRebornCreativeTab extends CreativeTabs { public class TechRebornCreativeTab extends CreativeTabs {
public static TechRebornCreativeTab instance = new TechRebornCreativeTab(); public static TechRebornCreativeTab instance = new TechRebornCreativeTab();
public TechRebornCreativeTab() { public TechRebornCreativeTab()
super("techreborn"); {
} super("techreborn");
}
@Override @Override
public Item getTabIconItem() { public Item getTabIconItem()
return Item.getItemFromBlock(ModBlocks.thermalGenerator); {
} return Item.getItemFromBlock(ModBlocks.thermalGenerator);
}
} }

View file

@ -4,19 +4,19 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import techreborn.init.ModItems; import techreborn.init.ModItems;
public class TechRebornCreativeTabMisc extends CreativeTabs{ public class TechRebornCreativeTabMisc extends CreativeTabs {
public static TechRebornCreativeTabMisc instance = new TechRebornCreativeTabMisc();
public TechRebornCreativeTabMisc() public static TechRebornCreativeTabMisc instance = new TechRebornCreativeTabMisc();
{
super("techreborn");
}
@Override public TechRebornCreativeTabMisc()
public Item getTabIconItem() {
{ super("techreborn");
return ModItems.cells; }
}
@Override
public Item getTabIconItem()
{
return ModItems.cells;
}
} }

View file

@ -1,48 +1,53 @@
package techreborn.client.container; package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import techreborn.client.SlotOutput; import techreborn.client.SlotOutput;
import techreborn.tiles.TileBlastFurnace; import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
public class ContainerBlastFurnace extends TechRebornContainer { public class ContainerBlastFurnace extends TechRebornContainer {
EntityPlayer player; EntityPlayer player;
TileBlastFurnace tile;
TileBlastFurnace tile;
@Override @Override
public boolean canInteractWith(EntityPlayer player) public boolean canInteractWith(EntityPlayer player)
{ {
return true; return true;
} }
public int tickTime; public int tickTime;
public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace, EntityPlayer player) { public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace,
tile = tileblastfurnace; EntityPlayer player)
this.player = player; {
tile = tileblastfurnace;
this.player = player;
//input // input
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 0, 56, 25)); this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 0, 56, 25));
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 1, 56, 43)); this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 1, 56, 43));
//outputs // outputs
this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2, 116, 35)); 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 (i = 0; i < 9; ++i)
for (int j = 0; j < 9; ++j) { {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); 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));
}
}
} }

View file

@ -8,61 +8,77 @@ import techreborn.tiles.TileCentrifuge;
public class ContainerCentrifuge extends TechRebornContainer { 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) { public ContainerCentrifuge(TileCentrifuge tileCentrifuge,
tile = tileCentrifuge; EntityPlayer player)
this.player = player; {
tile = tileCentrifuge;
this.player = player;
//input // input
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 0, 80, 35)); this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 0, 80, 35));
//cells // cells
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 1, 50, 5)); this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 1, 50, 5));
//outputs // outputs
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80, 5)); this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80,
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3, 110, 35)); 5));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 4, 80, 65)); this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3,
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 5, 50, 35)); 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 (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 (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) { for (i = 0; i < 9; ++i)
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); {
} this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
} 142));
}
}
@Override @Override
public boolean canInteractWith(EntityPlayer player) { public boolean canInteractWith(EntityPlayer player)
return true; {
} return true;
}
@Override @Override
public void addCraftingToCrafters(ICrafting crafting) { public void addCraftingToCrafters(ICrafting crafting)
super.addCraftingToCrafters(crafting); {
crafting.sendProgressBarUpdate(this, 0, tile.tickTime); super.addCraftingToCrafters(crafting);
} crafting.sendProgressBarUpdate(this, 0, tile.tickTime);
}
/** /**
* Looks for changes made in the container, sends them to every listener. * Looks for changes made in the container, sends them to every listener.
*/ */
public void detectAndSendChanges() { public void detectAndSendChanges()
super.detectAndSendChanges(); {
for (int i = 0; i < this.crafters.size(); ++i) { super.detectAndSendChanges();
ICrafting icrafting = (ICrafting) this.crafters.get(i); for (int i = 0; i < this.crafters.size(); ++i)
if (this.tickTime != this.tile.tickTime) { {
icrafting.sendProgressBarUpdate(this, 0, this.tile.tickTime); ICrafting icrafting = (ICrafting) this.crafters.get(i);
} if (this.tickTime != this.tile.tickTime)
} {
this.tickTime = this.tile.tickTime; icrafting.sendProgressBarUpdate(this, 0, this.tile.tickTime);
} }
}
this.tickTime = this.tile.tickTime;
}
} }

View file

@ -7,34 +7,44 @@ import techreborn.client.SlotOutput;
import techreborn.tiles.TileQuantumChest; import techreborn.tiles.TileQuantumChest;
public class ContainerQuantumChest extends TechRebornContainer { public class ContainerQuantumChest extends TechRebornContainer {
public TileQuantumChest tileQuantumChest; public TileQuantumChest tileQuantumChest;
public EntityPlayer player; public EntityPlayer player;
public ContainerQuantumChest(TileQuantumChest tileQuantumChest, EntityPlayer player) { public ContainerQuantumChest(TileQuantumChest tileQuantumChest,
super(); EntityPlayer player)
this.tileQuantumChest = tileQuantumChest; {
this.player = player; super();
this.tileQuantumChest = tileQuantumChest;
this.player = player;
this.addSlotToContainer(new Slot(tileQuantumChest.inventory, 0, 80, 17)); this.addSlotToContainer(new Slot(tileQuantumChest.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1, 80, 53)); this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1,
this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59, 42, false, false, Integer.MAX_VALUE)); 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 (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 (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) { for (i = 0; i < 9; ++i)
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); {
} this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
} 142));
}
}
@Override @Override
public boolean canInteractWith(EntityPlayer player) { public boolean canInteractWith(EntityPlayer player)
return true; {
} return true;
}
} }

View file

@ -7,33 +7,43 @@ import techreborn.client.SlotOutput;
import techreborn.tiles.TileQuantumTank; import techreborn.tiles.TileQuantumTank;
public class ContainerQuantumTank extends TechRebornContainer { public class ContainerQuantumTank extends TechRebornContainer {
public TileQuantumTank tileQuantumTank; public TileQuantumTank tileQuantumTank;
public EntityPlayer player; public EntityPlayer player;
public ContainerQuantumTank(TileQuantumTank tileQuantumTank, EntityPlayer player) { public ContainerQuantumTank(TileQuantumTank tileQuantumTank,
super(); EntityPlayer player)
this.tileQuantumTank = tileQuantumTank; {
this.player = player; super();
this.tileQuantumTank = tileQuantumTank;
this.player = player;
this.addSlotToContainer(new Slot(tileQuantumTank.inventory, 0, 80, 17)); this.addSlotToContainer(new Slot(tileQuantumTank.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1, 80, 53)); this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1,
this.addSlotToContainer(new SlotFake(tileQuantumTank.inventory, 2, 59, 42, false, false, 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 (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 (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) { for (i = 0; i < 9; ++i)
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); {
} this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
} 142));
}
}
@Override @Override
public boolean canInteractWith(EntityPlayer player) { public boolean canInteractWith(EntityPlayer player)
return true; {
} return true;
}
} }

View file

@ -11,50 +11,63 @@ import techreborn.tiles.TileRollingMachine;
public class ContainerRollingMachine extends TechRebornContainer { public class ContainerRollingMachine extends TechRebornContainer {
EntityPlayer player; EntityPlayer player;
TileRollingMachine tile; TileRollingMachine tile;
public ContainerRollingMachine(TileRollingMachine tileRollingmachine, EntityPlayer player) { public ContainerRollingMachine(TileRollingMachine tileRollingmachine,
tile = tileRollingmachine; EntityPlayer player)
this.player = 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++) { // output
for (int k1 = 0; k1 < 3; k1++) { this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 0,
this.addSlotToContainer(new Slot(tileRollingmachine.craftMatrix, k1 + l * 3, 30 + k1 * 18, 17 + l * 18)); 124, 35));
}
}
//output // fakeOutput
this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 0, 124, 35)); this.addSlotToContainer(new SlotFake(tileRollingmachine.inventory, 1,
124, 10, false, false, 1));
//fakeOutput int i;
this.addSlotToContainer(new SlotFake(tileRollingmachine.inventory, 1, 124, 10, false, false, 1));
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) { @Override
for (int j = 0; j < 9; ++j) { public boolean canInteractWith(EntityPlayer player)
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); {
} return true;
} }
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 final void onCraftMatrixChanged(IInventory inv)
{
ItemStack output = RollingMachineRecipe.instance.findMatchingRecipe(
tile.craftMatrix, tile.getWorldObj());
tile.inventory.setInventorySlotContents(1, output);
}
} }

View file

@ -7,33 +7,44 @@ import techreborn.client.SlotOutput;
import techreborn.tiles.TileThermalGenerator; import techreborn.tiles.TileThermalGenerator;
public class ContainerThermalGenerator extends TechRebornContainer { public class ContainerThermalGenerator extends TechRebornContainer {
public TileThermalGenerator tileThermalGenerator; public TileThermalGenerator tileThermalGenerator;
public EntityPlayer player; public EntityPlayer player;
public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator, EntityPlayer player) { public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator,
super(); EntityPlayer player)
this.tileThermalGenerator = tileThermalGenerator; {
this.player = player; super();
this.tileThermalGenerator = tileThermalGenerator;
this.player = player;
this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80, 17)); this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80,
this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory, 1, 80, 53)); 17));
this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2, 59, 42, false, false, 1)); 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 (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 (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) { for (i = 0; i < 9; ++i)
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); {
} this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
} 142));
}
}
@Override @Override
public boolean canInteractWith(EntityPlayer player) { public boolean canInteractWith(EntityPlayer player)
return true; {
} return true;
}
} }

View file

@ -7,88 +7,112 @@ import net.minecraft.item.ItemStack;
import techreborn.client.SlotFake; import techreborn.client.SlotFake;
import techreborn.util.ItemUtils; import techreborn.util.ItemUtils;
public abstract class TechRebornContainer extends Container { public abstract class TechRebornContainer extends Container {
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)
ItemStack originalStack = null; {
Slot slot = (Slot) inventorySlots.get(slotIndex); ItemStack originalStack = null;
int numSlots = inventorySlots.size(); Slot slot = (Slot) inventorySlots.get(slotIndex);
if (slot != null && slot.getHasStack()) { int numSlots = inventorySlots.size();
ItemStack stackInSlot = slot.getStack(); if (slot != null && slot.getHasStack())
originalStack = stackInSlot.copy(); {
if (slotIndex >= numSlots - 9 * 4 && tryShiftItem(stackInSlot, numSlots)) { ItemStack stackInSlot = slot.getStack();
// NOOP originalStack = stackInSlot.copy();
} else if (slotIndex >= numSlots - 9 * 4 && slotIndex < numSlots - 9) { if (slotIndex >= numSlots - 9 * 4
if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots)) && tryShiftItem(stackInSlot, numSlots))
return null; {
} else if (slotIndex >= numSlots - 9 && slotIndex < numSlots) { // NOOP
if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9)) } else if (slotIndex >= numSlots - 9 * 4
return null; && slotIndex < numSlots - 9)
} else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots)) {
return null; if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots))
slot.onSlotChange(stackInSlot, originalStack); return null;
if (stackInSlot.stackSize <= 0) } else if (slotIndex >= numSlots - 9 && slotIndex < numSlots)
slot.putStack(null); {
else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9))
slot.onSlotChanged(); return null;
if (stackInSlot.stackSize == originalStack.stackSize) } else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots))
return null; return null;
slot.onPickupFromSlot(player, stackInSlot); slot.onSlotChange(stackInSlot, originalStack);
} if (stackInSlot.stackSize <= 0)
return originalStack; 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) { protected boolean shiftItemStack(ItemStack stackToShift, int start, int end)
boolean changed = false; {
if (stackToShift.isStackable()) boolean changed = false;
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) { if (stackToShift.isStackable())
Slot slot = (Slot) inventorySlots.get(slotIndex); for (int slotIndex = start; stackToShift.stackSize > 0
ItemStack stackInSlot = slot.getStack(); && slotIndex < end; slotIndex++)
if (stackInSlot != null && ItemUtils.isItemEqual(stackInSlot, stackToShift, true, true)) { {
int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize; Slot slot = (Slot) inventorySlots.get(slotIndex);
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit()); ItemStack stackInSlot = slot.getStack();
if (resultingStackSize <= max) { if (stackInSlot != null
stackToShift.stackSize = 0; && ItemUtils.isItemEqual(stackInSlot, stackToShift,
stackInSlot.stackSize = resultingStackSize; true, true))
slot.onSlotChanged(); {
changed = true; int resultingStackSize = stackInSlot.stackSize
} else if (stackInSlot.stackSize < max) { + stackToShift.stackSize;
stackToShift.stackSize -= max - stackInSlot.stackSize; int max = Math.min(stackToShift.getMaxStackSize(),
stackInSlot.stackSize = max; slot.getSlotStackLimit());
slot.onSlotChanged(); if (resultingStackSize <= max)
changed = true; {
} stackToShift.stackSize = 0;
} stackInSlot.stackSize = resultingStackSize;
} slot.onSlotChanged();
if (stackToShift.stackSize > 0) changed = true;
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) { } else if (stackInSlot.stackSize < max)
Slot slot = (Slot) inventorySlots.get(slotIndex); {
ItemStack stackInSlot = slot.getStack(); stackToShift.stackSize -= max - stackInSlot.stackSize;
if (stackInSlot == null) { stackInSlot.stackSize = max;
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit()); slot.onSlotChanged();
stackInSlot = stackToShift.copy(); changed = true;
stackInSlot.stackSize = Math.min(stackToShift.stackSize, max); }
stackToShift.stackSize -= stackInSlot.stackSize; }
slot.putStack(stackInSlot); }
slot.onSlotChanged(); if (stackToShift.stackSize > 0)
changed = true; for (int slotIndex = start; stackToShift.stackSize > 0
} && slotIndex < end; slotIndex++)
} {
return changed; 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) { private boolean tryShiftItem(ItemStack stackToShift, int numSlots)
for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++) { {
Slot slot = (Slot) inventorySlots.get(machineIndex); for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++)
if (slot instanceof SlotFake) { {
continue; Slot slot = (Slot) inventorySlots.get(machineIndex);
} if (slot instanceof SlotFake)
if (!slot.isItemValid(stackToShift)) {
continue; continue;
if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1)) }
return true; if (!slot.isItemValid(stackToShift))
} continue;
return false; if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1))
} return true;
}
return false;
}
} }

View file

@ -5,33 +5,40 @@ import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import techreborn.client.container.ContainerBlastFurnace; import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.tiles.TileBlastFurnace; import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
public class GuiBlastFurnace extends GuiContainer { 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) { public GuiBlastFurnace(EntityPlayer player,
super(new ContainerBlastFurnace(tileblastfurnace, player)); TileBlastFurnace tileblastfurnace)
this.xSize = 176; {
this.ySize = 167; super(new ContainerBlastFurnace(tileblastfurnace, player));
blastfurnace = tileblastfurnace; this.xSize = 176;
} this.ySize = 167;
blastfurnace = tileblastfurnace;
}
@Override @Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
this.mc.getTextureManager().bindTexture(texture); int p_146976_2_, int p_146976_3_)
int k = (this.width - this.xSize) / 2; {
int l = (this.height - this.ySize) / 2; this.mc.getTextureManager().bindTexture(texture);
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); 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_) { protected void drawGuiContainerForegroundLayer(int p_146979_1_,
this.fontRendererObj.drawString("Blastfurnace", 60, 6, 4210752); int p_146979_2_)
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); {
} this.fontRendererObj.drawString("Blastfurnace", 60, 6, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
}
} }

View file

@ -9,28 +9,37 @@ import techreborn.tiles.TileCentrifuge;
public class GuiCentrifuge extends GuiContainer { 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) { public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge)
super(new ContainerCentrifuge(tileCentrifuge, player)); {
this.xSize = 176; super(new ContainerCentrifuge(tileCentrifuge, player));
this.ySize = 167; this.xSize = 176;
centrifuge = tileCentrifuge; this.ySize = 167;
} centrifuge = tileCentrifuge;
}
@Override @Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
this.mc.getTextureManager().bindTexture(texture); int p_146976_2_, int p_146976_3_)
int k = (this.width - this.xSize) / 2; {
int l = (this.height - this.ySize) / 2; this.mc.getTextureManager().bindTexture(texture);
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); 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_) { protected void drawGuiContainerForegroundLayer(int p_146979_1_,
this.fontRendererObj.drawString("Centrifuge", 110, 6, 4210752); int p_146979_2_)
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); 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);
}
} }

View file

@ -1,6 +1,5 @@
package techreborn.client.gui; package techreborn.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -10,31 +9,39 @@ import techreborn.tiles.TileQuantumChest;
public class GuiQuantumChest extends GuiContainer { 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) { public GuiQuantumChest(EntityPlayer player, TileQuantumChest tile)
super(new ContainerQuantumChest(tile, player)); {
this.xSize = 176; super(new ContainerQuantumChest(tile, player));
this.ySize = 167; this.xSize = 176;
this.tile = tile; this.ySize = 167;
} this.tile = tile;
}
@Override @Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
this.mc.getTextureManager().bindTexture(texture); int p_146976_2_, int p_146976_3_)
int k = (this.width - this.xSize) / 2; {
int l = (this.height - this.ySize) / 2; this.mc.getTextureManager().bindTexture(texture);
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); 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_) { protected void drawGuiContainerForegroundLayer(int p_146979_1_,
this.fontRendererObj.drawString("Quantum Chest", 8, 6, 4210752); int p_146979_2_)
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); {
this.fontRendererObj.drawString("Amount", 10, 20, 16448255); this.fontRendererObj.drawString("Quantum Chest", 8, 6, 4210752);
if (tile.storedItem != null) this.fontRendererObj.drawString(
this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10, 30, 16448255); 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);
}
} }

View file

@ -9,30 +9,38 @@ import techreborn.tiles.TileQuantumTank;
public class GuiQuantumTank extends GuiContainer { 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) { public GuiQuantumTank(EntityPlayer player, TileQuantumTank tile)
super(new ContainerQuantumTank(tile, player)); {
this.xSize = 176; super(new ContainerQuantumTank(tile, player));
this.ySize = 167; this.xSize = 176;
this.tile = tile; this.ySize = 167;
} this.tile = tile;
}
@Override @Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
this.mc.getTextureManager().bindTexture(texture); int p_146976_2_, int p_146976_3_)
int k = (this.width - this.xSize) / 2; {
int l = (this.height - this.ySize) / 2; this.mc.getTextureManager().bindTexture(texture);
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); 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_) { protected void drawGuiContainerForegroundLayer(int p_146979_1_,
this.fontRendererObj.drawString("Quantum Tank", 8, 6, 4210752); int p_146979_2_)
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("Quantum Tank", 8, 6, 4210752);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255); 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);
}
} }

View file

@ -8,22 +8,27 @@ import techreborn.tiles.TileRollingMachine;
public class GuiRollingMachine extends GuiContainer { public class GuiRollingMachine extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/rollingmachine.png"); private static final ResourceLocation texture = new ResourceLocation(
TileRollingMachine rollingMachine; "techreborn", "textures/gui/rollingmachine.png");
TileRollingMachine rollingMachine;
public GuiRollingMachine(EntityPlayer player, TileRollingMachine tileRollingmachine) { public GuiRollingMachine(EntityPlayer player,
super(new ContainerRollingMachine(tileRollingmachine, player)); TileRollingMachine tileRollingmachine)
this.xSize = 176; {
this.ySize = 167; super(new ContainerRollingMachine(tileRollingmachine, player));
rollingMachine = tileRollingmachine; this.xSize = 176;
} this.ySize = 167;
rollingMachine = tileRollingmachine;
}
@Override @Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
this.mc.getTextureManager().bindTexture(texture); int p_146976_2_, int p_146976_3_)
int k = (this.width - this.xSize) / 2; {
int l = (this.height - this.ySize) / 2; this.mc.getTextureManager().bindTexture(texture);
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); int k = (this.width - this.xSize) / 2;
} int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
} }

View file

@ -9,29 +9,38 @@ import techreborn.tiles.TileThermalGenerator;
public class GuiThermalGenerator extends GuiContainer { 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) { public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile)
super(new ContainerThermalGenerator(tile, player)); {
this.xSize = 176; super(new ContainerThermalGenerator(tile, player));
this.ySize = 167; this.xSize = 176;
this.tile = tile; this.ySize = 167;
} this.tile = tile;
}
@Override @Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
this.mc.getTextureManager().bindTexture(texture); int p_146976_2_, int p_146976_3_)
int k = (this.width - this.xSize) / 2; {
int l = (this.height - this.ySize) / 2; this.mc.getTextureManager().bindTexture(texture);
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); 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_) { protected void drawGuiContainerForegroundLayer(int p_146979_1_,
this.fontRendererObj.drawString("Thermal Generator", 8, 6, 4210752); int p_146979_2_)
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("Thermal Generator", 8, 6, 4210752);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10, 30, 16448255); 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);
}
} }

View file

@ -1,16 +1,16 @@
package techreborn.compat; package techreborn.compat;
import techreborn.compat.waila.CompatModuleWaila;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInitializationEvent;
import techreborn.compat.waila.CompatModuleWaila;
public class CompatManager { public class CompatManager {
public static void init(FMLInitializationEvent event) public static void init(FMLInitializationEvent event)
{ {
if (Loader.isModLoaded("Waila")) if (Loader.isModLoaded("Waila"))
{ {
new CompatModuleWaila().init(event); new CompatModuleWaila().init(event);
} }
} }
} }

View file

@ -1,157 +1,206 @@
package techreborn.compat.nei; 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 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.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import techreborn.api.CentrifugeRecipie; import techreborn.api.CentrifugeRecipie;
import techreborn.api.TechRebornAPI; import techreborn.api.TechRebornAPI;
import techreborn.client.gui.GuiCentrifuge; import techreborn.client.gui.GuiCentrifuge;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import codechicken.lib.gui.GuiDraw;
import java.awt.*; import codechicken.nei.NEIServerUtils;
import java.util.ArrayList; import codechicken.nei.PositionedStack;
import java.util.List; import codechicken.nei.recipe.TemplateRecipeHandler;
public class CentrifugeRecipeHandler extends TemplateRecipeHandler { public class CentrifugeRecipeHandler extends TemplateRecipeHandler {
public class CachedCentrifugeRecipe extends CachedRecipe { public class CachedCentrifugeRecipe extends CachedRecipe {
private List<PositionedStack> input = new ArrayList<PositionedStack>(); private List<PositionedStack> input = new ArrayList<PositionedStack>();
private List<PositionedStack> outputs = new ArrayList<PositionedStack>(); private List<PositionedStack> outputs = new ArrayList<PositionedStack>();
public Point focus; public Point focus;
public CentrifugeRecipie centrifugeRecipie; 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) { if (recipie.getOutput1() != null)
this.centrifugeRecipie = recipie; {
int offset = 4; this.outputs.add(new PositionedStack(recipie.getOutput1(),
PositionedStack pStack = new PositionedStack(recipie.getInputItem(), 80 - offset, 35 - offset); 80 - offset, 5 - offset));
pStack.setMaxSize(1); }
this.input.add(pStack); 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"); @Override
cellStack.stackSize = recipie.getCells(); public List<PositionedStack> getIngredients()
this.outputs.add(new PositionedStack(cellStack, 50 - offset, 5 - offset)); {
return this.getCycledIngredients(cycleticks / 20, this.input);
}
} @Override
public List<PositionedStack> getOtherStacks()
{
return this.outputs;
}
@Override @Override
public List<PositionedStack> getIngredients() { public PositionedStack getResult()
return this.getCycledIngredients(cycleticks / 20, this.input); {
} return null;
}
}
@Override @Override
public List<PositionedStack> getOtherStacks() { public String getRecipeName()
return this.outputs; {
} return "Centrifuge";
}
@Override @Override
public PositionedStack getResult() { public String getGuiTexture()
return null; {
} return "techreborn:textures/gui/centrifuge.png";
} }
@Override @Override
public String getRecipeName() { public Class<? extends GuiContainer> getGuiClass()
return "Centrifuge"; {
} return GuiCentrifuge.class;
}
@Override @Override
public String getGuiTexture() { public void drawBackground(int recipeIndex)
return "techreborn:textures/gui/centrifuge.png"; {
} 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<? extends GuiContainer> getGuiClass() {
return GuiCentrifuge.class;
}
@Override @Override
public void drawBackground(int recipeIndex) { public int recipiesPerPage()
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); {
GuiDraw.changeTexture(getGuiTexture()); return 1;
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 void loadTransferRects()
{
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(75, 22, 15, 13), "tr.centrifuge", new Object[0]));
}
@Override public void loadCraftingRecipes(String outputId, Object... results)
public int recipiesPerPage() { {
return 1; if (outputId.equals("tr.centrifuge"))
} {
for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies)
{
addCached(centrifugeRecipie);
}
} else
{
super.loadCraftingRecipes(outputId, results);
}
}
@Override @Override
public void loadTransferRects() { public void loadCraftingRecipes(ItemStack result)
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(75, 22, 15, 13), "tr.centrifuge", new Object[0])); {
} 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) { @Override
if (outputId.equals("tr.centrifuge")) { public void loadUsageRecipes(ItemStack ingredient)
for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) { {
addCached(centrifugeRecipie); for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies)
} {
} else { if (NEIServerUtils.areStacksSameTypeCrafting(
super.loadCraftingRecipes(outputId, results); centrifugeRecipie.getInputItem(), ingredient))
} {
} addCached(centrifugeRecipie);
}
}
}
@Override private void addCached(CentrifugeRecipie recipie)
public void loadCraftingRecipes(ItemStack result) { {
for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) { this.arecipes.add(new CachedCentrifugeRecipe(recipie));
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));
}
} }

View file

@ -1,35 +1,38 @@
package techreborn.compat.nei; package techreborn.compat.nei;
import techreborn.lib.ModInfo;
import codechicken.nei.api.API; import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI; import codechicken.nei.api.IConfigureNEI;
import techreborn.lib.ModInfo;
public class NEIConfig implements IConfigureNEI { public class NEIConfig implements IConfigureNEI {
@Override @Override
public String getName() { public String getName()
return ModInfo.MOD_ID; {
} return ModInfo.MOD_ID;
}
@Override @Override
public String getVersion() { public String getVersion()
return ModInfo.MOD_VERSION; {
} return ModInfo.MOD_VERSION;
}
@Override @Override
public void loadConfig() { public void loadConfig()
CentrifugeRecipeHandler centrifugeRecipeHandler = new CentrifugeRecipeHandler(); {
ShapedRollingMachineHandler shapedRollingMachineHandler = new ShapedRollingMachineHandler(); CentrifugeRecipeHandler centrifugeRecipeHandler = new CentrifugeRecipeHandler();
ShapelessRollingMachineHandler shapelessRollingMachineHandler = new ShapelessRollingMachineHandler(); ShapedRollingMachineHandler shapedRollingMachineHandler = new ShapedRollingMachineHandler();
ShapelessRollingMachineHandler shapelessRollingMachineHandler = new ShapelessRollingMachineHandler();
API.registerRecipeHandler(centrifugeRecipeHandler); API.registerRecipeHandler(centrifugeRecipeHandler);
API.registerUsageHandler(centrifugeRecipeHandler); API.registerUsageHandler(centrifugeRecipeHandler);
API.registerUsageHandler(shapedRollingMachineHandler); API.registerUsageHandler(shapedRollingMachineHandler);
API.registerRecipeHandler(shapedRollingMachineHandler); API.registerRecipeHandler(shapedRollingMachineHandler);
API.registerUsageHandler(shapelessRollingMachineHandler); API.registerUsageHandler(shapelessRollingMachineHandler);
API.registerRecipeHandler(shapelessRollingMachineHandler); API.registerRecipeHandler(shapelessRollingMachineHandler);
} }
} }

View file

@ -1,8 +1,9 @@
//Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapedRecipeHandler.java //Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapedRecipeHandler.java
package techreborn.compat.nei; package techreborn.compat.nei;
import codechicken.nei.NEIServerUtils; import java.awt.Rectangle;
import codechicken.nei.recipe.ShapedRecipeHandler; import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
@ -10,89 +11,110 @@ import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import techreborn.api.RollingMachineRecipe; import techreborn.api.RollingMachineRecipe;
import techreborn.client.gui.GuiRollingMachine; import techreborn.client.gui.GuiRollingMachine;
import codechicken.nei.NEIServerUtils;
import java.awt.*; import codechicken.nei.recipe.ShapedRecipeHandler;
import java.util.List;
public class ShapedRollingMachineHandler extends ShapedRecipeHandler { public class ShapedRollingMachineHandler extends ShapedRecipeHandler {
@Override @Override
public Class<? extends GuiContainer> getGuiClass() { public Class<? extends GuiContainer> getGuiClass()
return GuiRollingMachine.class; {
} return GuiRollingMachine.class;
}
@Override @Override
public void loadTransferRects() { public void loadTransferRects()
this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "rollingcrafting", new Object[0])); {
} this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24,
18), "rollingcrafting", new Object[0]));
}
@Override @Override
public String getRecipeName() { public String getRecipeName()
return "rollingcrafting"; {
} return "rollingcrafting";
}
@Override @Override
public String getOverlayIdentifier() { public String getOverlayIdentifier()
return "rollingcrafting"; {
} return "rollingcrafting";
}
@Override @Override
public void loadCraftingRecipes(String outputId, Object... results) { public void loadCraftingRecipes(String outputId, Object... results)
if (outputId.equals("rollingcrafting") && getClass() == ShapedRollingMachineHandler.class) { {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance.getRecipeList()) { if (outputId.equals("rollingcrafting")
CachedShapedRecipe recipe = null; && getClass() == ShapedRollingMachineHandler.class)
if (irecipe instanceof ShapedRecipes) {
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance
else if (irecipe instanceof ShapedOreRecipe) .getRecipeList())
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null) if (recipe == null)
continue; continue;
recipe.computeVisuals(); recipe.computeVisuals();
arecipes.add(recipe); arecipes.add(recipe);
} }
} else { } else
super.loadCraftingRecipes(outputId, results); {
} super.loadCraftingRecipes(outputId, results);
} }
}
@Override @Override
public void loadCraftingRecipes(ItemStack result) { public void loadCraftingRecipes(ItemStack result)
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance.getRecipeList()) { {
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) { for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance
CachedShapedRecipe recipe = null; .getRecipeList())
if (irecipe instanceof ShapedRecipes) {
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); if (NEIServerUtils.areStacksSameTypeCrafting(
else if (irecipe instanceof ShapedOreRecipe) irecipe.getRecipeOutput(), result))
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null) if (recipe == null)
continue; continue;
recipe.computeVisuals(); recipe.computeVisuals();
arecipes.add(recipe); arecipes.add(recipe);
} }
} }
} }
@Override @Override
public void loadUsageRecipes(ItemStack ingredient) { public void loadUsageRecipes(ItemStack ingredient)
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance.getRecipeList()) { {
CachedShapedRecipe recipe = null; for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance
if (irecipe instanceof ShapedRecipes) .getRecipeList())
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe); {
else if (irecipe instanceof ShapedOreRecipe) CachedShapedRecipe recipe = null;
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe); 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())) if (recipe == null
continue; || !recipe.contains(recipe.ingredients,
ingredient.getItem()))
continue;
recipe.computeVisuals(); recipe.computeVisuals();
if (recipe.contains(recipe.ingredients, ingredient)) { if (recipe.contains(recipe.ingredients, ingredient))
recipe.setIngredientPermutation(recipe.ingredients, ingredient); {
arecipes.add(recipe); recipe.setIngredientPermutation(recipe.ingredients, ingredient);
} arecipes.add(recipe);
} }
} }
}
} }

View file

@ -1,8 +1,9 @@
//Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapelessRecipeHandler.java //Copy and pasted from https://github.com/Chicken-Bones/NotEnoughItems/blob/master/src/codechicken/nei/recipe/ShapelessRecipeHandler.java
package techreborn.compat.nei; package techreborn.compat.nei;
import codechicken.nei.NEIServerUtils; import java.awt.Rectangle;
import codechicken.nei.recipe.ShapelessRecipeHandler; import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
@ -10,95 +11,116 @@ import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapelessOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe;
import techreborn.api.RollingMachineRecipe; import techreborn.api.RollingMachineRecipe;
import techreborn.client.gui.GuiRollingMachine; import techreborn.client.gui.GuiRollingMachine;
import codechicken.nei.NEIServerUtils;
import java.awt.*; import codechicken.nei.recipe.ShapelessRecipeHandler;
import java.util.List;
public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler { public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler {
@Override @Override
public Class<? extends GuiContainer> getGuiClass() { public Class<? extends GuiContainer> getGuiClass()
return GuiRollingMachine.class; {
} return GuiRollingMachine.class;
}
public String getRecipeName() { public String getRecipeName()
return "Shapeless Rolling Machine"; {
} return "Shapeless Rolling Machine";
}
@Override @Override
public void loadTransferRects() { public void loadTransferRects()
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "rollingcraftingnoshape")); {
} transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18),
"rollingcraftingnoshape"));
}
@Override @Override
public String getOverlayIdentifier() { public String getOverlayIdentifier()
return "rollingcraftingnoshape"; {
} return "rollingcraftingnoshape";
}
@Override @Override
public void loadCraftingRecipes(String outputId, Object... results) { public void loadCraftingRecipes(String outputId, Object... results)
if (outputId.equals("rollingcraftingnoshape") && getClass() == ShapelessRollingMachineHandler.class) { {
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList(); if (outputId.equals("rollingcraftingnoshape")
for (IRecipe irecipe : allrecipes) { && getClass() == ShapelessRollingMachineHandler.class)
CachedShapelessRecipe recipe = null; {
if (irecipe instanceof ShapelessRecipes) List<IRecipe> allrecipes = RollingMachineRecipe.instance
recipe = shapelessRecipe((ShapelessRecipes) irecipe); .getRecipeList();
else if (irecipe instanceof ShapelessOreRecipe) for (IRecipe irecipe : allrecipes)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null) if (recipe == null)
continue; continue;
arecipes.add(recipe); arecipes.add(recipe);
} }
} else { } else
super.loadCraftingRecipes(outputId, results); {
} super.loadCraftingRecipes(outputId, results);
} }
}
@Override @Override
public void loadCraftingRecipes(ItemStack result) { public void loadCraftingRecipes(ItemStack result)
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList(); {
for (IRecipe irecipe : allrecipes) { List<IRecipe> allrecipes = RollingMachineRecipe.instance
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) { .getRecipeList();
CachedShapelessRecipe recipe = null; for (IRecipe irecipe : allrecipes)
if (irecipe instanceof ShapelessRecipes) {
recipe = shapelessRecipe((ShapelessRecipes) irecipe); if (NEIServerUtils.areStacksSameTypeCrafting(
else if (irecipe instanceof ShapelessOreRecipe) irecipe.getRecipeOutput(), result))
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null) if (recipe == null)
continue; continue;
arecipes.add(recipe); arecipes.add(recipe);
} }
} }
} }
@Override @Override
public void loadUsageRecipes(ItemStack ingredient) { public void loadUsageRecipes(ItemStack ingredient)
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList(); {
for (IRecipe irecipe : allrecipes) { List<IRecipe> allrecipes = RollingMachineRecipe.instance
CachedShapelessRecipe recipe = null; .getRecipeList();
if (irecipe instanceof ShapelessRecipes) for (IRecipe irecipe : allrecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe); {
else if (irecipe instanceof ShapelessOreRecipe) CachedShapelessRecipe recipe = null;
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe); if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null) if (recipe == null)
continue; continue;
if (recipe.contains(recipe.ingredients, ingredient)) { if (recipe.contains(recipe.ingredients, ingredient))
recipe.setIngredientPermutation(recipe.ingredients, ingredient); {
arecipes.add(recipe); recipe.setIngredientPermutation(recipe.ingredients, ingredient);
} arecipes.add(recipe);
} }
} }
}
private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) { private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe)
if(recipe.recipeItems == null) {
return null; if (recipe.recipeItems == null)
return null;
return new CachedShapelessRecipe(recipe.recipeItems, recipe.getRecipeOutput()); return new CachedShapelessRecipe(recipe.recipeItems,
} recipe.getRecipeOutput());
}
} }

View file

@ -1,12 +1,10 @@
package techreborn.compat.recipes; package techreborn.compat.recipes;
import techreborn.compat.waila.CompatModuleWaila;
import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
public class RecipeManager { public class RecipeManager {
public static void init() public static void init()
{ {
if (Loader.isModLoaded("BuildCraft|Factory")) if (Loader.isModLoaded("BuildCraft|Factory"))
{ {

View file

@ -1,25 +1,26 @@
package techreborn.compat.recipes; package techreborn.compat.recipes;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import buildcraft.BuildCraftFactory;
import techreborn.util.RecipeRemover; import techreborn.util.RecipeRemover;
import buildcraft.BuildCraftFactory;
public class RecipesBuildcraft { public class RecipesBuildcraft {
public static void init() public static void init()
{ {
removeRecipes(); removeRecipes();
addRecipies(); addRecipies();
} }
public static void removeRecipes() public static void removeRecipes()
{ {
RecipeRemover.removeAnyRecipe(new ItemStack(BuildCraftFactory.quarryBlock)); RecipeRemover.removeAnyRecipe(new ItemStack(
BuildCraftFactory.quarryBlock));
} }
public static void addRecipies() public static void addRecipies()
{ {
} }
} }

View file

@ -1,7 +1,7 @@
package techreborn.compat.recipes; package techreborn.compat.recipes;
public class RecipesThermalExpansion { public class RecipesThermalExpansion {
//TODO remove basic machine frame recipe // TODO remove basic machine frame recipe
//TODO replace iron in recipe to steel // TODO replace iron in recipe to steel
} }

View file

@ -1,17 +1,21 @@
package techreborn.compat.waila; 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 mcp.mobius.waila.api.IWailaRegistrar;
import techreborn.tiles.TileMachineBase; import techreborn.tiles.TileMachineBase;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
public class CompatModuleWaila { public class CompatModuleWaila {
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event)
FMLInterModComms.sendMessage("Waila", "register", getClass().getName() + ".callbackRegister"); {
} FMLInterModComms.sendMessage("Waila", "register", getClass().getName()
+ ".callbackRegister");
}
public static void callbackRegister(IWailaRegistrar registrar) { public static void callbackRegister(IWailaRegistrar registrar)
registrar.registerBodyProvider(new WailaProviderMachines(), TileMachineBase.class); {
} registrar.registerBodyProvider(new WailaProviderMachines(),
TileMachineBase.class);
}
} }

View file

@ -1,5 +1,8 @@
package techreborn.compat.waila; package techreborn.compat.waila;
import java.util.ArrayList;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider; import mcp.mobius.waila.api.IWailaDataProvider;
@ -10,46 +13,53 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import techreborn.tiles.TileMachineBase; import techreborn.tiles.TileMachineBase;
import java.util.ArrayList;
import java.util.List;
public class WailaProviderMachines implements IWailaDataProvider { public class WailaProviderMachines implements IWailaDataProvider {
private List<String> info = new ArrayList<String>(); private List<String> info = new ArrayList<String>();
@Override @Override
public List<String> getWailaBody(ItemStack item, List<String> tip, IWailaDataAccessor accessor, IWailaConfigHandler config) { public List<String> getWailaBody(ItemStack item, List<String> tip,
IWailaDataAccessor accessor, IWailaConfigHandler config)
{
TileMachineBase machine = (TileMachineBase) accessor.getTileEntity(); TileMachineBase machine = (TileMachineBase) accessor.getTileEntity();
machine.addWailaInfo(info); machine.addWailaInfo(info);
tip.addAll(info); tip.addAll(info);
info.clear(); info.clear();
return tip; return tip;
} }
@Override @Override
public List<String> getWailaHead(ItemStack item, List<String> tip, IWailaDataAccessor accessor, IWailaConfigHandler config) { public List<String> getWailaHead(ItemStack item, List<String> tip,
IWailaDataAccessor accessor, IWailaConfigHandler config)
{
return tip; return tip;
} }
@Override @Override
public List<String> getWailaTail(ItemStack item, List<String> tip, IWailaDataAccessor accessor, IWailaConfigHandler config) { public List<String> getWailaTail(ItemStack item, List<String> tip,
IWailaDataAccessor accessor, IWailaConfigHandler config)
{
return tip; return tip;
} }
@Override @Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { public ItemStack getWailaStack(IWailaDataAccessor accessor,
IWailaConfigHandler config)
{
return null; return null;
} }
@Override @Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World w, int x, int y, int z) { public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te,
NBTTagCompound tag, World w, int x, int y, int z)
{
return tag; return tag;
} }
} }

View file

@ -1,260 +1,415 @@
package techreborn.config; package techreborn.config;
import java.io.File;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import java.io.File;
public class ConfigTechReborn { public class ConfigTechReborn {
private static ConfigTechReborn instance = null; private static ConfigTechReborn instance = null;
public static String CATEGORY_WORLD = "world"; public static String CATEGORY_WORLD = "world";
public static String CATEGORY_POWER = "power"; public static String CATEGORY_POWER = "power";
public static String CATEGORY_CRAFTING = "crafting"; public static String CATEGORY_CRAFTING = "crafting";
//WORLDGEN // WORLDGEN
public static boolean GalenaOreTrue; public static boolean GalenaOreTrue;
public static boolean IridiumOreTrue; public static boolean IridiumOreTrue;
public static boolean RubyOreTrue; public static boolean RubyOreTrue;
public static boolean SapphireOreTrue; public static boolean SapphireOreTrue;
public static boolean BauxiteOreTrue; public static boolean BauxiteOreTrue;
public static boolean CopperOreTrue; public static boolean CopperOreTrue;
public static boolean TinOreTrue; public static boolean TinOreTrue;
public static boolean LeadOreTrue; public static boolean LeadOreTrue;
public static boolean SilverOreTrue; public static boolean SilverOreTrue;
public static boolean PyriteOreTrue; public static boolean PyriteOreTrue;
public static boolean CinnabarOreTrue; public static boolean CinnabarOreTrue;
public static boolean SphaleriteOreTrue; public static boolean SphaleriteOreTrue;
public static boolean TungstenOreTrue; public static boolean TungstenOreTrue;
public static boolean SheldoniteOreTrue; public static boolean SheldoniteOreTrue;
public static boolean OlivineOreTrue; public static boolean OlivineOreTrue;
public static boolean SodaliteOreTrue; public static boolean SodaliteOreTrue;
//Power // Power
public static int ThermalGenertaorOutput; public static int ThermalGenertaorOutput;
public static int CentrifugeInputTick; public static int CentrifugeInputTick;
//Charge // Charge
public static int AdvancedDrillCharge; public static int AdvancedDrillCharge;
public static int LapotronPackCharge; public static int LapotronPackCharge;
public static int LithiumBatpackCharge; public static int LithiumBatpackCharge;
public static int OmniToolCharge; public static int OmniToolCharge;
public static int RockCutterCharge; public static int RockCutterCharge;
public static int GravityCharge; public static int GravityCharge;
public static int CentrifugeCharge; public static int CentrifugeCharge;
public static int ThermalGeneratorCharge; public static int ThermalGeneratorCharge;
//Tier // Tier
public static int AdvancedDrillTier; public static int AdvancedDrillTier;
public static int LapotronPackTier; public static int LapotronPackTier;
public static int LithiumBatpackTier; public static int LithiumBatpackTier;
public static int OmniToolTier; public static int OmniToolTier;
public static int RockCutterTier; public static int RockCutterTier;
public static int GravityTier; public static int GravityTier;
public static int CentrifugeTier; public static int CentrifugeTier;
public static int ThermalGeneratorTier; public static int ThermalGeneratorTier;
//Crafting // Crafting
public static boolean ExpensiveMacerator; public static boolean ExpensiveMacerator;
public static boolean ExpensiveDrill; public static boolean ExpensiveDrill;
public static boolean ExpensiveDiamondDrill; public static boolean ExpensiveDiamondDrill;
public static boolean ExpensiveSolar; 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) { ConfigTechReborn.Configs();
config = new Configuration(configFile);
config.load();
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) return instance;
instance = new ConfigTechReborn(configFile); }
else
throw new IllegalStateException(
"Cannot initialize TechReborn Config twice");
return instance; public static ConfigTechReborn instance()
} {
if (instance == null)
{
public static ConfigTechReborn instance() { throw new IllegalStateException(
if (instance == null) { "Instance of TechReborn Config requested before initialization");
}
return instance;
}
throw new IllegalStateException( public static void Configs()
"Instance of TechReborn Config requested before initialization"); {
} GalenaOreTrue = config
return instance; .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() { // Power
GalenaOreTrue = config.get(CATEGORY_WORLD, ThermalGenertaorOutput = config
StatCollector.translateToLocal("config.techreborn.allow.galenaOre"), true, .get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.allow.galenaOre.tooltip")) StatCollector
.getBoolean(true); .translateToLocal("config.techreborn.thermalGeneratorPower"),
IridiumOreTrue = config.get(CATEGORY_WORLD, 30,
StatCollector.translateToLocal("config.techreborn.allow.iridiumOre"), true, StatCollector
StatCollector.translateToLocal("config.techreborn.allow.iridiumOre.tooltip")) .translateToLocal("config.techreborn.thermalGeneratorPower.tooltip"))
.getBoolean(true); .getInt();
RubyOreTrue = config.get(CATEGORY_WORLD, CentrifugeInputTick = config
StatCollector.translateToLocal("config.techreborn.allow.rubyOre"), true, .get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.allow.rubyOre.tooltip")) StatCollector
.getBoolean(true); .translateToLocal("config.techreborn.centrifugePowerUsage"),
SapphireOreTrue = config.get(CATEGORY_WORLD, 5,
StatCollector.translateToLocal("config.techreborn.allow.sapphireOre"), true, StatCollector
StatCollector.translateToLocal("config.techreborn.allow.sapphireOre.tooltip")) .translateToLocal("config.techreborn.centrifugePowerUsage.tooltip"))
.getBoolean(true); .getInt();
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 // Charge
ThermalGenertaorOutput = config.get(CATEGORY_POWER, AdvancedDrillCharge = config
StatCollector.translateToLocal("config.techreborn.thermalGeneratorPower"), 30, .get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.thermalGeneratorPower.tooltip")) StatCollector
.getInt(); .translateToLocal("config.techreborn.advancedDrillMaxCharge"),
CentrifugeInputTick = config.get(CATEGORY_POWER, 60000,
StatCollector.translateToLocal("config.techreborn.centrifugePowerUsage"), 5, StatCollector
StatCollector.translateToLocal("config.techreborn.centrifugePowerUsage.tooltip")) .translateToLocal("config.techreborn.advancedDrillMaxCharge.tooltip"))
.getInt(); .getInt();
LapotronPackCharge = config
//Charge .get(CATEGORY_POWER,
AdvancedDrillCharge = config.get(CATEGORY_POWER, StatCollector
StatCollector.translateToLocal("config.techreborn.advancedDrillMaxCharge"), 60000, .translateToLocal("config.techreborn.lapotronPackMaxCharge"),
StatCollector.translateToLocal("config.techreborn.advancedDrillMaxCharge.tooltip")) 100000000,
.getInt(); StatCollector
LapotronPackCharge = config.get(CATEGORY_POWER, .translateToLocal("config.techreborn.lapotronPackMaxCharge.tooltop"))
StatCollector.translateToLocal("config.techreborn.lapotronPackMaxCharge"), 100000000, .getInt();
StatCollector.translateToLocal("config.techreborn.lapotronPackMaxCharge.tooltop")) LithiumBatpackCharge = config
.getInt(); .get(CATEGORY_POWER,
LithiumBatpackCharge = config.get(CATEGORY_POWER, StatCollector
StatCollector.translateToLocal("config.techreborn.lithiumBatpackMaxCharge"), 4000000, .translateToLocal("config.techreborn.lithiumBatpackMaxCharge"),
StatCollector.translateToLocal("config.techreborn.lithiumBatpackMaxCharge.tooltip")) 4000000,
.getInt(); StatCollector
OmniToolCharge = config.get(CATEGORY_POWER, .translateToLocal("config.techreborn.lithiumBatpackMaxCharge.tooltip"))
StatCollector.translateToLocal("config.techreborn.omniToolMaxCharge"), 20000, .getInt();
StatCollector.translateToLocal("config.techreborn.omniToolMaxCharge.tooltip")) OmniToolCharge = config
.getInt(); .get(CATEGORY_POWER,
RockCutterCharge = config.get(CATEGORY_POWER, StatCollector
StatCollector.translateToLocal("config.techreborn.rockCutterMaxCharge"), 10000, .translateToLocal("config.techreborn.omniToolMaxCharge"),
StatCollector.translateToLocal("config.techreborn.rockCutterMaxCharge.tooltip")) 20000,
.getInt(); StatCollector
GravityCharge = config.get(CATEGORY_POWER, .translateToLocal("config.techreborn.omniToolMaxCharge.tooltip"))
StatCollector.translateToLocal("config.techreborn.gravityChestplateMaxCharge"), 100000, .getInt();
StatCollector.translateToLocal("config.techreborn.gravityChestplateMaxCharge.tooltip")) RockCutterCharge = config
.getInt(); .get(CATEGORY_POWER,
CentrifugeCharge = config.get(CATEGORY_POWER, StatCollector
StatCollector.translateToLocal("config.techreborn.centrifugeMaxCharge"), 1000000, .translateToLocal("config.techreborn.rockCutterMaxCharge"),
StatCollector.translateToLocal("config.techreborn.centrifugeMaxCharge.tooltip")) 10000,
.getInt(); StatCollector
ThermalGeneratorCharge = config.get(CATEGORY_POWER, .translateToLocal("config.techreborn.rockCutterMaxCharge.tooltip"))
StatCollector.translateToLocal("config.techreborn.thermalGeneratorMaxCharge"), 1000000, .getInt();
StatCollector.translateToLocal("config.techreborn.thermalGeneratorMaxCharge.tooltip")) GravityCharge = config
.getInt(); .get(CATEGORY_POWER,
StatCollector
//Teir .translateToLocal("config.techreborn.gravityChestplateMaxCharge"),
AdvancedDrillTier = config.get(CATEGORY_POWER, 100000,
StatCollector.translateToLocal("config.techreborn.advancedDrillTier"), 2, StatCollector
StatCollector.translateToLocal("config.techreborn.advancedDrillTier.tooltip")) .translateToLocal("config.techreborn.gravityChestplateMaxCharge.tooltip"))
.getInt(); .getInt();
LapotronPackTier = config.get(CATEGORY_POWER, CentrifugeCharge = config
StatCollector.translateToLocal("config.techreborn.lapotronPackTier"), 2, .get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.lapotronPackTier.tooltip")) StatCollector
.getInt(); .translateToLocal("config.techreborn.centrifugeMaxCharge"),
LithiumBatpackTier = config.get(CATEGORY_POWER, 1000000,
StatCollector.translateToLocal("config.techreborn.lithiumBatpackTier"), 3, StatCollector
StatCollector.translateToLocal("config.techreborn.lithiumBatpackTier.tooltip")) .translateToLocal("config.techreborn.centrifugeMaxCharge.tooltip"))
.getInt(); .getInt();
OmniToolTier = config.get(CATEGORY_POWER, ThermalGeneratorCharge = config
StatCollector.translateToLocal("config.techreborn.omniToolTier"), 3, .get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.omniToolTier.tooltip")) StatCollector
.getInt(); .translateToLocal("config.techreborn.thermalGeneratorMaxCharge"),
RockCutterTier = config.get(CATEGORY_POWER, 1000000,
StatCollector.translateToLocal("config.techreborn.rockCutterTier"), 3, StatCollector
StatCollector.translateToLocal("config.techreborn.rockCutterTier.tooltip")) .translateToLocal("config.techreborn.thermalGeneratorMaxCharge.tooltip"))
.getInt(); .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();
//Crafting // Teir
ExpensiveMacerator = config.get(CATEGORY_CRAFTING, AdvancedDrillTier = config
StatCollector.translateToLocal("config.techreborn.allowExpensiveMacerator"), true, .get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.allowExpensiveMacerator.tooltip")) StatCollector
.getBoolean(true); .translateToLocal("config.techreborn.advancedDrillTier"),
ExpensiveDrill = config.get(CATEGORY_CRAFTING, 2,
StatCollector.translateToLocal("config.techreborn.allowExpensiveDrill"), true, StatCollector
StatCollector.translateToLocal("config.techreborn.allowExpensiveDrill.tooltip")) .translateToLocal("config.techreborn.advancedDrillTier.tooltip"))
.getBoolean(true); .getInt();
ExpensiveDiamondDrill = config.get(CATEGORY_CRAFTING, LapotronPackTier = config
StatCollector.translateToLocal("config.techreborn.allowExpensiveDiamondDrill"), true, .get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.allowExpensiveDiamondDrill.tooltip")) StatCollector
.getBoolean(true); .translateToLocal("config.techreborn.lapotronPackTier"),
ExpensiveSolar = config.get(CATEGORY_CRAFTING, 2,
StatCollector.translateToLocal("config.techreborn.allowExpensiveSolarPanels"), true, StatCollector
StatCollector.translateToLocal("config.techreborn.allowExpensiveSolarPanels.tooltip")) .translateToLocal("config.techreborn.lapotronPackTier.tooltip"))
.getBoolean(true); .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()) // Crafting
config.save(); 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();
}
} }

View file

@ -1,121 +1,141 @@
package techreborn.config; 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.DummyConfigElement;
import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.GuiConfig;
import cpw.mods.fml.client.config.GuiConfigEntries; import cpw.mods.fml.client.config.GuiConfigEntries;
import cpw.mods.fml.client.config.GuiConfigEntries.CategoryEntry; import cpw.mods.fml.client.config.GuiConfigEntries.CategoryEntry;
import cpw.mods.fml.client.config.IConfigElement; 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 class TechRebornConfigGui extends GuiConfig {
public TechRebornConfigGui(GuiScreen top) { public TechRebornConfigGui(GuiScreen top)
super(top, getConfigCategories(), "TechReborn", false, false, {
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config super(top, getConfigCategories(), "TechReborn", false, false, GuiConfig
.toString())); .getAbridgedConfigPath(ConfigTechReborn.config.toString()));
} }
private static List<IConfigElement> getConfigCategories() { private static List<IConfigElement> getConfigCategories()
List<IConfigElement> list = new ArrayList<IConfigElement>(); {
list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.general"), List<IConfigElement> list = new ArrayList<IConfigElement>();
"tr.configgui.category.trGeneral", TRGeneral.class)); list.add(new DummyConfigElement.DummyCategoryElement(StatCollector
list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.world"), .translateToLocal("config.techreborn.category.general"),
"tr.configgui.category.trWorld", TRWORLD.class)); "tr.configgui.category.trGeneral", TRGeneral.class));
list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.power"), list.add(new DummyConfigElement.DummyCategoryElement(StatCollector
"tr.configgui.category.trPower", TRPOWER.class)); .translateToLocal("config.techreborn.category.world"),
list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.crafting"), "tr.configgui.category.trWorld", TRWORLD.class));
"tr.configgui.category.trCrafting", TRCRAFTING.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) { public TRGeneral(GuiConfig owningScreen,
super(owningScreen, owningEntryList, configElement); GuiConfigEntries owningEntryList, IConfigElement configElement)
} {
super(owningScreen, owningEntryList, configElement);
}
@Override @Override
protected GuiScreen buildChildScreen() { protected GuiScreen buildChildScreen()
return new GuiConfig(this.owningScreen, {
(new ConfigElement(ConfigTechReborn.config return new GuiConfig(this.owningScreen,
.getCategory(Configuration.CATEGORY_GENERAL))) (new ConfigElement(ConfigTechReborn.config
.getChildElements(), this.owningScreen.modID, .getCategory(Configuration.CATEGORY_GENERAL)))
Configuration.CATEGORY_GENERAL, .getChildElements(), this.owningScreen.modID,
this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart, Configuration.CATEGORY_GENERAL,
this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, this.configElement.requiresWorldRestart()
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString())); || this.owningScreen.allRequireWorldRestart,
} this.configElement.requiresMcRestart()
} || this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config
.toString()));
}
}
// World // World
public static class TRWORLD extends CategoryEntry { public static class TRWORLD extends CategoryEntry {
public TRWORLD(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { public TRWORLD(GuiConfig owningScreen,
super(owningScreen, owningEntryList, configElement); GuiConfigEntries owningEntryList, IConfigElement configElement)
} {
super(owningScreen, owningEntryList, configElement);
}
@Override @Override
protected GuiScreen buildChildScreen() { protected GuiScreen buildChildScreen()
return new GuiConfig(this.owningScreen, {
(new ConfigElement(ConfigTechReborn.config return new GuiConfig(this.owningScreen,
.getCategory(ConfigTechReborn.CATEGORY_WORLD))) (new ConfigElement(ConfigTechReborn.config
.getChildElements(), this.owningScreen.modID, .getCategory(ConfigTechReborn.CATEGORY_WORLD)))
Configuration.CATEGORY_GENERAL, .getChildElements(), this.owningScreen.modID,
this.configElement.requiresWorldRestart() Configuration.CATEGORY_GENERAL,
|| this.owningScreen.allRequireWorldRestart, this.configElement.requiresWorldRestart()
this.configElement.requiresMcRestart() || this.owningScreen.allRequireWorldRestart,
|| this.owningScreen.allRequireMcRestart, this.configElement.requiresMcRestart()
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config || this.owningScreen.allRequireMcRestart,
.toString())); GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config
} .toString()));
} }
}
// Power // Power
public static class TRPOWER extends CategoryEntry { public static class TRPOWER extends CategoryEntry {
public TRPOWER(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { public TRPOWER(GuiConfig owningScreen,
super(owningScreen, owningEntryList, configElement); GuiConfigEntries owningEntryList, IConfigElement configElement)
} {
super(owningScreen, owningEntryList, configElement);
}
@Override @Override
protected GuiScreen buildChildScreen() { protected GuiScreen buildChildScreen()
return new GuiConfig(this.owningScreen, {
(new ConfigElement(ConfigTechReborn.config return new GuiConfig(this.owningScreen,
.getCategory(ConfigTechReborn.CATEGORY_POWER))) (new ConfigElement(ConfigTechReborn.config
.getChildElements(), this.owningScreen.modID, .getCategory(ConfigTechReborn.CATEGORY_POWER)))
Configuration.CATEGORY_GENERAL, .getChildElements(), this.owningScreen.modID,
this.configElement.requiresWorldRestart() Configuration.CATEGORY_GENERAL,
|| this.owningScreen.allRequireWorldRestart, this.configElement.requiresWorldRestart()
this.configElement.requiresMcRestart() || this.owningScreen.allRequireWorldRestart,
|| this.owningScreen.allRequireMcRestart, this.configElement.requiresMcRestart()
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config || this.owningScreen.allRequireMcRestart,
.toString())); GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config
} .toString()));
} }
}
// Crafting // Crafting
public static class TRCRAFTING extends CategoryEntry { public static class TRCRAFTING extends CategoryEntry {
public TRCRAFTING(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) { public TRCRAFTING(GuiConfig owningScreen,
super(owningScreen, owningEntryList, configElement); GuiConfigEntries owningEntryList, IConfigElement configElement)
} {
super(owningScreen, owningEntryList, configElement);
}
@Override @Override
protected GuiScreen buildChildScreen() { protected GuiScreen buildChildScreen()
return new GuiConfig(this.owningScreen, {
(new ConfigElement(ConfigTechReborn.config return new GuiConfig(this.owningScreen,
.getCategory(ConfigTechReborn.CATEGORY_CRAFTING))) (new ConfigElement(ConfigTechReborn.config
.getChildElements(), this.owningScreen.modID, .getCategory(ConfigTechReborn.CATEGORY_CRAFTING)))
Configuration.CATEGORY_GENERAL, .getChildElements(), this.owningScreen.modID,
this.configElement.requiresWorldRestart() Configuration.CATEGORY_GENERAL,
|| this.owningScreen.allRequireWorldRestart, this.configElement.requiresWorldRestart()
this.configElement.requiresMcRestart() || this.owningScreen.allRequireWorldRestart,
|| this.owningScreen.allRequireMcRestart, this.configElement.requiresMcRestart()
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config || this.owningScreen.allRequireMcRestart,
.toString())); GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config
} .toString()));
} }
}
} }

View file

@ -1,31 +1,35 @@
package techreborn.config; 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 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 { public class TechRebornGUIFactory implements IModGuiFactory {
@Override @Override
public void initialize(Minecraft minecraftInstance) { public void initialize(Minecraft minecraftInstance)
{
} }
@Override @Override
public Class<? extends GuiScreen> mainConfigGuiClass() { public Class<? extends GuiScreen> mainConfigGuiClass()
return TechRebornConfigGui.class; {
} return TechRebornConfigGui.class;
}
@Override @Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() { public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
return null; {
} return null;
}
@Override @Override
public RuntimeOptionGuiHandler getHandlerFor( public RuntimeOptionGuiHandler getHandlerFor(
RuntimeOptionCategoryElement element) { RuntimeOptionCategoryElement element)
return null; {
} return null;
}
} }

View file

@ -1,104 +1,150 @@
package techreborn.init; package techreborn.init;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary; 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.client.TechRebornCreativeTab;
import techreborn.itemblocks.ItemBlockMachineCasing; import techreborn.itemblocks.ItemBlockMachineCasing;
import techreborn.itemblocks.ItemBlockOre; import techreborn.itemblocks.ItemBlockOre;
import techreborn.itemblocks.ItemBlockQuantumChest; import techreborn.itemblocks.ItemBlockQuantumChest;
import techreborn.itemblocks.ItemBlockQuantumTank; import techreborn.itemblocks.ItemBlockQuantumTank;
import techreborn.itemblocks.ItemBlockStorage; 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 techreborn.util.LogHelper;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModBlocks { public class ModBlocks {
public static Block thermalGenerator; public static Block thermalGenerator;
public static Block quantumTank; public static Block quantumTank;
public static Block quantumChest; public static Block quantumChest;
public static Block centrifuge; public static Block centrifuge;
public static Block RollingMachine; public static Block RollingMachine;
public static Block MachineCasing; public static Block MachineCasing;
public static Block BlastFurnace; public static Block BlastFurnace;
public static Block ore; public static Block ore;
public static Block storage; public static Block storage;
public static void init() { public static void init()
thermalGenerator = new BlockThermalGenerator().setBlockName("techreborn.thermalGenerator").setBlockTextureName("techreborn:ThermalGenerator_other").setCreativeTab(TechRebornCreativeTab.instance); {
GameRegistry.registerBlock(thermalGenerator, "techreborn.thermalGenerator"); thermalGenerator = new BlockThermalGenerator()
GameRegistry.registerTileEntity(TileThermalGenerator.class, "TileThermalGenerator"); .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); quantumTank = new BlockQuantumTank()
GameRegistry.registerBlock(quantumTank, ItemBlockQuantumTank.class, "techreborn.quantumTank"); .setBlockName("techreborn.quantumTank")
GameRegistry.registerTileEntity(TileQuantumTank.class, "TileQuantumTank"); .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); quantumChest = new BlockQuantumChest()
GameRegistry.registerBlock(quantumChest, ItemBlockQuantumChest.class, "techreborn.quantumChest"); .setBlockName("techreborn.quantumChest")
GameRegistry.registerTileEntity(TileQuantumChest.class, "TileQuantumChest"); .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); centrifuge = new BlockCentrifuge()
GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge"); .setBlockName("techreborn.centrifuge")
GameRegistry.registerTileEntity(TileCentrifuge.class, "TileCentrifuge"); .setBlockTextureName("techreborn:centrifuge")
.setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge");
GameRegistry.registerTileEntity(TileCentrifuge.class, "TileCentrifuge");
RollingMachine = new BlockRollingMachine(Material.piston); RollingMachine = new BlockRollingMachine(Material.piston);
GameRegistry.registerBlock(RollingMachine, "rollingmachine"); GameRegistry.registerBlock(RollingMachine, "rollingmachine");
GameRegistry.registerTileEntity(TileRollingMachine.class, "TileRollingMachine"); 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");
ore = new BlockOre(Material.rock); BlastFurnace = new BlockBlastFurnace(Material.piston);
GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore"); GameRegistry.registerBlock(BlastFurnace, "blastFurnace");
LogHelper.info("TechReborns Blocks Loaded"); GameRegistry.registerTileEntity(TileBlastFurnace.class,
"TileBlastFurnace");
storage = new BlockStorage(Material.rock); MachineCasing = new BlockMachineCasing(Material.piston);
GameRegistry.registerBlock(storage, ItemBlockStorage.class, "techreborn.storage"); GameRegistry.registerBlock(MachineCasing, ItemBlockMachineCasing.class,
LogHelper.info("TechReborns Blocks Loaded"); "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() { storage = new BlockStorage(Material.rock);
OreDictionary.registerOre("oreGalena", new ItemStack(ore, 1, 0)); GameRegistry.registerBlock(storage, ItemBlockStorage.class,
OreDictionary.registerOre("oreIridium", new ItemStack(ore, 1, 1)); "techreborn.storage");
OreDictionary.registerOre("oreRuby", new ItemStack(ore, 1, 2)); LogHelper.info("TechReborns Blocks Loaded");
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)); registerOreDict();
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));
} 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));
}
} }

View file

@ -1,6 +1,5 @@
package techreborn.init; package techreborn.init;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial;
@ -20,147 +19,162 @@ import techreborn.items.tools.ItemOmniTool;
import techreborn.items.tools.ItemRockCutter; import techreborn.items.tools.ItemRockCutter;
import techreborn.items.tools.ItemTechPda; import techreborn.items.tools.ItemTechPda;
import techreborn.util.LogHelper; import techreborn.util.LogHelper;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModItems { public class ModItems {
public static Item dusts; public static Item dusts;
public static Item smallDusts; public static Item smallDusts;
public static Item ingots; public static Item ingots;
public static Item gems; public static Item gems;
public static Item parts; public static Item parts;
public static Item cells; public static Item cells;
public static Item rockCutter; public static Item rockCutter;
public static Item lithiumBatpack; public static Item lithiumBatpack;
public static Item lapotronpack; public static Item lapotronpack;
public static Item gravityChest; public static Item gravityChest;
public static Item omniTool; public static Item omniTool;
public static Item advancedDrill; public static Item advancedDrill;
public static Item manuel; public static Item manuel;
public static void init() { public static void init()
dusts = new ItemDusts(); {
GameRegistry.registerItem(dusts, "dust"); dusts = new ItemDusts();
smallDusts = new ItemDustsSmall(); GameRegistry.registerItem(dusts, "dust");
GameRegistry.registerItem(smallDusts, "smallDust"); smallDusts = new ItemDustsSmall();
ingots = new ItemIngots(); GameRegistry.registerItem(smallDusts, "smallDust");
GameRegistry.registerItem(ingots, "ingot"); ingots = new ItemIngots();
gems = new ItemGems(); GameRegistry.registerItem(ingots, "ingot");
GameRegistry.registerItem(gems, "gem"); gems = new ItemGems();
parts = new ItemParts(); GameRegistry.registerItem(gems, "gem");
GameRegistry.registerItem(parts, "part"); parts = new ItemParts();
cells = new ItemCells(); GameRegistry.registerItem(parts, "part");
GameRegistry.registerItem(cells, "cell"); cells = new ItemCells();
rockCutter = new ItemRockCutter(ToolMaterial.EMERALD); GameRegistry.registerItem(cells, "cell");
GameRegistry.registerItem(rockCutter, "rockCutter"); rockCutter = new ItemRockCutter(ToolMaterial.EMERALD);
lithiumBatpack = new ItemLithiumBatpack(ArmorMaterial.DIAMOND, 7, 1); GameRegistry.registerItem(rockCutter, "rockCutter");
GameRegistry.registerItem(lithiumBatpack, "lithiumBatpack"); lithiumBatpack = new ItemLithiumBatpack(ArmorMaterial.DIAMOND, 7, 1);
lapotronpack = new ItemLapotronPack(ArmorMaterial.DIAMOND, 7, 1); GameRegistry.registerItem(lithiumBatpack, "lithiumBatpack");
GameRegistry.registerItem(lapotronpack, "lapotronPack"); lapotronpack = new ItemLapotronPack(ArmorMaterial.DIAMOND, 7, 1);
omniTool = new ItemOmniTool(ToolMaterial.EMERALD); GameRegistry.registerItem(lapotronpack, "lapotronPack");
GameRegistry.registerItem(omniTool, "omniTool"); omniTool = new ItemOmniTool(ToolMaterial.EMERALD);
advancedDrill = new ItemAdvancedDrill(); GameRegistry.registerItem(omniTool, "omniTool");
GameRegistry.registerItem(advancedDrill, "advancedDrill"); advancedDrill = new ItemAdvancedDrill();
gravityChest = new ItemGravityChest(ArmorMaterial.DIAMOND, 7, 1); GameRegistry.registerItem(advancedDrill, "advancedDrill");
GameRegistry.registerItem(gravityChest, "gravitychestplate"); gravityChest = new ItemGravityChest(ArmorMaterial.DIAMOND, 7, 1);
manuel = new ItemTechPda(); GameRegistry.registerItem(gravityChest, "gravitychestplate");
GameRegistry.registerItem(manuel, "techmanuel"); manuel = new ItemTechPda();
GameRegistry.registerItem(manuel, "techmanuel");
LogHelper.info("TechReborns Items Loaded"); LogHelper.info("TechReborns Items Loaded");
registerOreDict(); registerOreDict();
} }
public static void registerOreDict() { public static void registerOreDict()
//Dusts {
OreDictionary.registerOre("dustAlmandine", new ItemStack(dusts, 1, 0)); // Dusts
OreDictionary.registerOre("dustAluminium", new ItemStack(dusts, 1, 1)); OreDictionary.registerOre("dustAlmandine", new ItemStack(dusts, 1, 0));
OreDictionary.registerOre("dustAndradite", new ItemStack(dusts, 1, 2)); OreDictionary.registerOre("dustAluminium", new ItemStack(dusts, 1, 1));
OreDictionary.registerOre("dustBasalt", new ItemStack(dusts, 1, 4)); OreDictionary.registerOre("dustAndradite", new ItemStack(dusts, 1, 2));
OreDictionary.registerOre("dustBauxite", new ItemStack(dusts, 1, 5)); OreDictionary.registerOre("dustBasalt", new ItemStack(dusts, 1, 4));
OreDictionary.registerOre("dustBrass", new ItemStack(dusts, 1, 6)); OreDictionary.registerOre("dustBauxite", new ItemStack(dusts, 1, 5));
OreDictionary.registerOre("dustBronze", new ItemStack(dusts, 1, 7)); OreDictionary.registerOre("dustBrass", new ItemStack(dusts, 1, 6));
OreDictionary.registerOre("dustCalcite", new ItemStack(dusts, 1, 8)); OreDictionary.registerOre("dustBronze", new ItemStack(dusts, 1, 7));
OreDictionary.registerOre("dustCharcoal", new ItemStack(dusts, 1, 9)); OreDictionary.registerOre("dustCalcite", new ItemStack(dusts, 1, 8));
OreDictionary.registerOre("dustChrome", new ItemStack(dusts, 1, 10)); OreDictionary.registerOre("dustCharcoal", new ItemStack(dusts, 1, 9));
OreDictionary.registerOre("dustCinnabar", new ItemStack(dusts, 1, 11)); OreDictionary.registerOre("dustChrome", new ItemStack(dusts, 1, 10));
OreDictionary.registerOre("dustClay", new ItemStack(dusts, 1, 12)); OreDictionary.registerOre("dustCinnabar", new ItemStack(dusts, 1, 11));
OreDictionary.registerOre("dustCoal", new ItemStack(dusts, 1, 13)); OreDictionary.registerOre("dustClay", new ItemStack(dusts, 1, 12));
OreDictionary.registerOre("dustCopper", new ItemStack(dusts, 1, 14)); OreDictionary.registerOre("dustCoal", new ItemStack(dusts, 1, 13));
OreDictionary.registerOre("dustDiamond", new ItemStack(dusts, 1, 16)); OreDictionary.registerOre("dustCopper", new ItemStack(dusts, 1, 14));
OreDictionary.registerOre("dustElectrum", new ItemStack(dusts, 1, 17)); OreDictionary.registerOre("dustDiamond", new ItemStack(dusts, 1, 16));
OreDictionary.registerOre("dustEmerald", new ItemStack(dusts, 1, 18)); OreDictionary.registerOre("dustElectrum", new ItemStack(dusts, 1, 17));
OreDictionary.registerOre("dustEnderEye", new ItemStack(dusts, 1, 19)); OreDictionary.registerOre("dustEmerald", new ItemStack(dusts, 1, 18));
OreDictionary.registerOre("dustEnderPearl", new ItemStack(dusts, 1, 20)); OreDictionary.registerOre("dustEnderEye", new ItemStack(dusts, 1, 19));
OreDictionary.registerOre("dustEndstone", new ItemStack(dusts, 1, 21)); OreDictionary
OreDictionary.registerOre("dustFlint", new ItemStack(dusts, 1, 22)); .registerOre("dustEnderPearl", new ItemStack(dusts, 1, 20));
OreDictionary.registerOre("dustGold", new ItemStack(dusts, 1, 23)); OreDictionary.registerOre("dustEndstone", new ItemStack(dusts, 1, 21));
OreDictionary.registerOre("dustGreenSapphire", new ItemStack(dusts, 1, 24)); OreDictionary.registerOre("dustFlint", new ItemStack(dusts, 1, 22));
OreDictionary.registerOre("dustGrossular", new ItemStack(dusts, 1, 25)); OreDictionary.registerOre("dustGold", new ItemStack(dusts, 1, 23));
OreDictionary.registerOre("dustInvar", new ItemStack(dusts, 1, 26)); OreDictionary.registerOre("dustGreenSapphire", new ItemStack(dusts, 1,
OreDictionary.registerOre("dustIron", new ItemStack(dusts, 1, 27)); 24));
OreDictionary.registerOre("dustLazurite", new ItemStack(dusts, 1, 28)); OreDictionary.registerOre("dustGrossular", new ItemStack(dusts, 1, 25));
OreDictionary.registerOre("dustLead", new ItemStack(dusts, 1, 29)); OreDictionary.registerOre("dustInvar", new ItemStack(dusts, 1, 26));
OreDictionary.registerOre("dustMagnesium", new ItemStack(dusts, 1, 30)); OreDictionary.registerOre("dustIron", new ItemStack(dusts, 1, 27));
OreDictionary.registerOre("dustMarble", new ItemStack(dusts, 31)); OreDictionary.registerOre("dustLazurite", new ItemStack(dusts, 1, 28));
OreDictionary.registerOre("dustNetherrack", new ItemStack(dusts, 32)); OreDictionary.registerOre("dustLead", new ItemStack(dusts, 1, 29));
OreDictionary.registerOre("dustNickel", new ItemStack(dusts, 1, 33)); OreDictionary.registerOre("dustMagnesium", new ItemStack(dusts, 1, 30));
OreDictionary.registerOre("dustObsidian", new ItemStack(dusts, 1, 34)); OreDictionary.registerOre("dustMarble", new ItemStack(dusts, 31));
OreDictionary.registerOre("dustOlivine", new ItemStack(dusts, 1, 35)); OreDictionary.registerOre("dustNetherrack", new ItemStack(dusts, 32));
OreDictionary.registerOre("dustPhosphor", new ItemStack(dusts, 1, 36)); OreDictionary.registerOre("dustNickel", new ItemStack(dusts, 1, 33));
OreDictionary.registerOre("dustPlatinum", new ItemStack(dusts, 1, 37)); OreDictionary.registerOre("dustObsidian", new ItemStack(dusts, 1, 34));
OreDictionary.registerOre("dustPyrite", new ItemStack(dusts, 1, 38)); OreDictionary.registerOre("dustOlivine", new ItemStack(dusts, 1, 35));
OreDictionary.registerOre("dustPyrope", new ItemStack(dusts, 1, 39)); OreDictionary.registerOre("dustPhosphor", new ItemStack(dusts, 1, 36));
OreDictionary.registerOre("dustRedGarnet", new ItemStack(dusts, 1, 40)); OreDictionary.registerOre("dustPlatinum", new ItemStack(dusts, 1, 37));
OreDictionary.registerOre("dustRedrock", new ItemStack(dusts, 1, 41)); OreDictionary.registerOre("dustPyrite", new ItemStack(dusts, 1, 38));
OreDictionary.registerOre("dustRuby", new ItemStack(dusts, 1, 42)); OreDictionary.registerOre("dustPyrope", new ItemStack(dusts, 1, 39));
OreDictionary.registerOre("dustSaltpeter", new ItemStack(dusts, 1, 43)); OreDictionary.registerOre("dustRedGarnet", new ItemStack(dusts, 1, 40));
OreDictionary.registerOre("dustSapphire", new ItemStack(dusts, 1, 44)); OreDictionary.registerOre("dustRedrock", new ItemStack(dusts, 1, 41));
OreDictionary.registerOre("dustSilver", new ItemStack(dusts, 1, 45)); OreDictionary.registerOre("dustRuby", new ItemStack(dusts, 1, 42));
OreDictionary.registerOre("dustSodalite", new ItemStack(dusts, 1, 46)); OreDictionary.registerOre("dustSaltpeter", new ItemStack(dusts, 1, 43));
OreDictionary.registerOre("dustSpessartine", new ItemStack(dusts, 1, 47)); OreDictionary.registerOre("dustSapphire", new ItemStack(dusts, 1, 44));
OreDictionary.registerOre("dustSphalerite", new ItemStack(dusts, 1, 48)); OreDictionary.registerOre("dustSilver", new ItemStack(dusts, 1, 45));
OreDictionary.registerOre("dustSteel", new ItemStack(dusts, 1, 49)); OreDictionary.registerOre("dustSodalite", new ItemStack(dusts, 1, 46));
OreDictionary.registerOre("dustSulfur", new ItemStack(dusts, 1, 50)); OreDictionary.registerOre("dustSpessartine",
OreDictionary.registerOre("dustTin", new ItemStack(dusts, 1, 51)); new ItemStack(dusts, 1, 47));
OreDictionary.registerOre("dustTitanium", new ItemStack(dusts, 1, 52)); OreDictionary
OreDictionary.registerOre("dustTungsten", new ItemStack(dusts, 1, 53)); .registerOre("dustSphalerite", new ItemStack(dusts, 1, 48));
OreDictionary.registerOre("dustUranium", new ItemStack(dusts, 1, 54)); OreDictionary.registerOre("dustSteel", new ItemStack(dusts, 1, 49));
OreDictionary.registerOre("dustUvarovite", new ItemStack(dusts, 1, 55)); OreDictionary.registerOre("dustSulfur", new ItemStack(dusts, 1, 50));
OreDictionary.registerOre("dustYellowGarnet", new ItemStack(dusts, 1, 56)); OreDictionary.registerOre("dustTin", new ItemStack(dusts, 1, 51));
OreDictionary.registerOre("dustZinc", new ItemStack(dusts, 1, 57)); OreDictionary.registerOre("dustTitanium", new ItemStack(dusts, 1, 52));
OreDictionary.registerOre("ingotCobalt", new ItemStack(dusts, 1, 58)); OreDictionary.registerOre("dustTungsten", new ItemStack(dusts, 1, 53));
OreDictionary.registerOre("ingotArdite", new ItemStack(ingots, 1, 59)); OreDictionary.registerOre("dustUranium", new ItemStack(dusts, 1, 54));
OreDictionary.registerOre("ingotManyullyn", new ItemStack(ingots, 1, 60)); OreDictionary.registerOre("dustUvarovite", new ItemStack(dusts, 1, 55));
OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots, 1, 61)); OreDictionary.registerOre("dustYellowGarnet", new ItemStack(dusts, 1,
OreDictionary.registerOre("ingotAlumite", new ItemStack(ingots, 1, 62)); 56));
//Ingots OreDictionary.registerOre("dustZinc", new ItemStack(dusts, 1, 57));
OreDictionary.registerOre("ingotIridium", new ItemStack(ingots, 1, 3)); OreDictionary.registerOre("ingotCobalt", new ItemStack(dusts, 1, 58));
OreDictionary.registerOre("ingotSilver", new ItemStack(ingots, 1, 4)); OreDictionary.registerOre("ingotArdite", new ItemStack(ingots, 1, 59));
OreDictionary.registerOre("ingotAluminium", new ItemStack(ingots, 1, 5)); OreDictionary.registerOre("ingotManyullyn",
OreDictionary.registerOre("ingotTitanium", new ItemStack(ingots, 1, 6)); new ItemStack(ingots, 1, 60));
OreDictionary.registerOre("ingotChrome", new ItemStack(ingots, 1, 7)); OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots,
OreDictionary.registerOre("ingotElectrum", new ItemStack(ingots, 1, 8)); 1, 61));
OreDictionary.registerOre("ingotTungsten", new ItemStack(ingots, 1, 9)); OreDictionary.registerOre("ingotAlumite", new ItemStack(ingots, 1, 62));
OreDictionary.registerOre("ingotLead", new ItemStack(ingots, 1, 10)); // Ingots
OreDictionary.registerOre("ingotZinc", new ItemStack(ingots, 1, 11)); OreDictionary.registerOre("ingotIridium", new ItemStack(ingots, 1, 3));
OreDictionary.registerOre("ingotBrass", new ItemStack(ingots, 1, 12)); OreDictionary.registerOre("ingotSilver", new ItemStack(ingots, 1, 4));
OreDictionary.registerOre("ingotSteel", new ItemStack(ingots, 1, 13)); OreDictionary
OreDictionary.registerOre("ingotPlatinum", new ItemStack(ingots, 1, 14)); .registerOre("ingotAluminium", new ItemStack(ingots, 1, 5));
OreDictionary.registerOre("ingotNickel", new ItemStack(ingots, 1, 15)); OreDictionary.registerOre("ingotTitanium", new ItemStack(ingots, 1, 6));
OreDictionary.registerOre("ingotInvar", new ItemStack(ingots, 1, 16)); OreDictionary.registerOre("ingotChrome", new ItemStack(ingots, 1, 7));
OreDictionary.registerOre("ingotCobalt", new ItemStack(ingots, 1, 17)); OreDictionary.registerOre("ingotElectrum", new ItemStack(ingots, 1, 8));
OreDictionary.registerOre("ingotArdite", new ItemStack(ingots, 1, 18)); OreDictionary.registerOre("ingotTungsten", new ItemStack(ingots, 1, 9));
OreDictionary.registerOre("ingotManyullyn", new ItemStack(ingots, 1, 19)); OreDictionary.registerOre("ingotLead", new ItemStack(ingots, 1, 10));
OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots, 1, 20)); OreDictionary.registerOre("ingotZinc", new ItemStack(ingots, 1, 11));
OreDictionary.registerOre("ingotAlumite", new ItemStack(ingots, 1, 21)); OreDictionary.registerOre("ingotBrass", new ItemStack(ingots, 1, 12));
//Gems OreDictionary.registerOre("ingotSteel", new ItemStack(ingots, 1, 13));
OreDictionary.registerOre("gemRuby", new ItemStack(gems, 1, 0)); OreDictionary
OreDictionary.registerOre("gemSapphire", new ItemStack(gems, 1, 1)); .registerOre("ingotPlatinum", new ItemStack(ingots, 1, 14));
OreDictionary.registerOre("gemGreenSapphire", new ItemStack(gems, 1, 2)); OreDictionary.registerOre("ingotNickel", new ItemStack(ingots, 1, 15));
OreDictionary.registerOre("gemOlivine", new ItemStack(gems, 1, 3)); OreDictionary.registerOre("ingotInvar", new ItemStack(ingots, 1, 16));
OreDictionary.registerOre("gemRedGarnet", new ItemStack(gems, 1, 4)); OreDictionary.registerOre("ingotCobalt", new ItemStack(ingots, 1, 17));
OreDictionary.registerOre("gemYellowGarnet", new ItemStack(gems, 1, 5)); 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));
} }
} }

View file

@ -6,10 +6,13 @@ import techreborn.partSystem.parts.CablePart;
public class ModParts { public class ModParts {
public static void init(){ public static void init()
{
ModPartRegistry.registerPart(new CablePart()); ModPartRegistry.registerPart(new CablePart());
ModPartRegistry.addProvider("techreborn.partSystem.QLib.QModPartFactory", "qmunitylib"); ModPartRegistry.addProvider(
ModPartRegistry.addProvider("techreborn.partSystem.fmp.FMPFactory", "ForgeMultipart"); "techreborn.partSystem.QLib.QModPartFactory", "qmunitylib");
ModPartRegistry.addProvider("techreborn.partSystem.fmp.FMPFactory",
"ForgeMultipart");
ModPartRegistry.addProvider(new WorldProvider()); ModPartRegistry.addProvider(new WorldProvider());
ModPartRegistry.addAllPartsToSystems(); ModPartRegistry.addAllPartsToSystems();
} }

View file

@ -1,6 +1,5 @@
package techreborn.init; package techreborn.init;
import cpw.mods.fml.common.registry.GameRegistry;
import ic2.api.item.IC2Items; import ic2.api.item.IC2Items;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
@ -11,233 +10,277 @@ import techreborn.config.ConfigTechReborn;
import techreborn.util.CraftingHelper; import techreborn.util.CraftingHelper;
import techreborn.util.LogHelper; import techreborn.util.LogHelper;
import techreborn.util.RecipeRemover; import techreborn.util.RecipeRemover;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModRecipes { public class ModRecipes {
public static ConfigTechReborn config; public static ConfigTechReborn config;
public static void init() { public static void init()
removeIc2Recipes(); {
addShaplessRecipes(); removeIc2Recipes();
addShappedRecipes(); addShaplessRecipes();
addSmeltingRecipes(); addShappedRecipes();
addMachineRecipes(); addSmeltingRecipes();
} addMachineRecipes();
}
public static void removeIc2Recipes() { public static void removeIc2Recipes()
if (config.ExpensiveMacerator) ; {
RecipeRemover.removeAnyRecipe(IC2Items.getItem("macerator")); if (config.ExpensiveMacerator)
if (config.ExpensiveDrill) ; ;
RecipeRemover.removeAnyRecipe(IC2Items.getItem("miningDrill")); RecipeRemover.removeAnyRecipe(IC2Items.getItem("macerator"));
if (config.ExpensiveDiamondDrill) ; if (config.ExpensiveDrill)
RecipeRemover.removeAnyRecipe(IC2Items.getItem("diamondDrill")); ;
if (config.ExpensiveSolar) ; RecipeRemover.removeAnyRecipe(IC2Items.getItem("miningDrill"));
RecipeRemover.removeAnyRecipe(IC2Items.getItem("solarPanel")); 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 // IC2 Recipes
if (config.ExpensiveMacerator) ; if (config.ExpensiveMacerator)
CraftingHelper.addShapedOreRecipe(IC2Items.getItem("macerator"), ;
new Object[]{"FDF", "DMD", "FCF", CraftingHelper.addShapedOreRecipe(
'F', Items.flint, IC2Items.getItem("macerator"),
'D', Items.diamond, new Object[]
'M', IC2Items.getItem("machine"), { "FDF", "DMD", "FCF", 'F', Items.flint, 'D', Items.diamond,
'C', IC2Items.getItem("electronicCircuit")}); 'M', IC2Items.getItem("machine"), 'C',
if (config.ExpensiveDrill) ; IC2Items.getItem("electronicCircuit") });
CraftingHelper.addShapedOreRecipe(IC2Items.getItem("miningDrill"), if (config.ExpensiveDrill)
new Object[]{" S ", "SCS", "SBS", ;
'S', "ingotSteel", CraftingHelper.addShapedOreRecipe(
'B', IC2Items.getItem("reBattery"), IC2Items.getItem("miningDrill"),
'C', IC2Items.getItem("electronicCircuit")}); new Object[]
if (config.ExpensiveDiamondDrill) ; { " S ", "SCS", "SBS", 'S', "ingotSteel", 'B',
CraftingHelper.addShapedOreRecipe(IC2Items.getItem("diamondDrill"), IC2Items.getItem("reBattery"), 'C',
new Object[]{" D ", "DBD", "TCT", IC2Items.getItem("electronicCircuit") });
'D', "gemDiamond", if (config.ExpensiveDiamondDrill)
'T', "ingotTitanium", ;
'B', IC2Items.getItem("miningDrill"), CraftingHelper.addShapedOreRecipe(
'C', IC2Items.getItem("advancedCircuit")}); IC2Items.getItem("diamondDrill"),
if (config.ExpensiveSolar) ; new Object[]
CraftingHelper.addShapedOreRecipe(IC2Items.getItem("solarPanel"), { " D ", "DBD", "TCT", 'D', "gemDiamond", 'T', "ingotTitanium",
new Object[]{"PPP", "SZS", "CGC", 'B', IC2Items.getItem("miningDrill"), 'C',
'P', "paneGlass", IC2Items.getItem("advancedCircuit") });
'S', new ItemStack(ModItems.parts, 1, 1), if (config.ExpensiveSolar)
'Z', IC2Items.getItem("carbonPlate"), ;
'G', IC2Items.getItem("generator"), CraftingHelper.addShapedOreRecipe(
'C', IC2Items.getItem("electronicCircuit")}); 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), CraftingHelper.addShapedOreRecipe(
new Object[]{"III", "IHI", "CGC", new ItemStack(ModBlocks.thermalGenerator),
'I', "ingotInvar", new Object[]
'H', IC2Items.getItem("reinforcedGlass"), { "III", "IHI", "CGC", 'I', "ingotInvar", 'H',
'C', IC2Items.getItem("electronicCircuit"), IC2Items.getItem("reinforcedGlass"), 'C',
'G', IC2Items.getItem("geothermalGenerator")}); IC2Items.getItem("electronicCircuit"), 'G',
//TechReborn Recipes IC2Items.getItem("geothermalGenerator") });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 4, 6), // TechReborn Recipes
new Object[]{"EEE", "EAE", "EEE", CraftingHelper.addShapedOreRecipe(
'E', "gemEmerald", new ItemStack(ModItems.parts, 4, 6),
'A', IC2Items.getItem("electronicCircuit")}); new Object[]
{ "EEE", "EAE", "EEE", 'E', "gemEmerald", 'A',
IC2Items.getItem("electronicCircuit") });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 7), CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 7),
new Object[]{"AGA", "RPB", "ASA", new Object[]
'A', "ingotAluminium", { "AGA", "RPB", "ASA", 'A', "ingotAluminium", 'G', "dyeGreen",
'G', "dyeGreen", 'R', "dyeRed", 'P', "paneGlass", 'B', "dyeBlue", 'S',
'R', "dyeRed", Items.glowstone_dust, });
'P', "paneGlass",
'B', "dyeBlue",
'S', Items.glowstone_dust,});
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 4, 8), CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 4, 8),
new Object[]{"DSD", "S S", "DSD", new Object[]
'D', "dustDiamond", { "DSD", "S S", "DSD", 'D', "dustDiamond", 'S', "ingotSteel" });
'S', "ingotSteel"});
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 16, 13), CraftingHelper.addShapedOreRecipe(
new Object[]{"CSC", "SCS", "CSC", new ItemStack(ModItems.parts, 16, 13),
'S', "ingotSteel", new Object[]
'C', IC2Items.getItem("electronicCircuit")}); { "CSC", "SCS", "CSC", 'S', "ingotSteel", 'C',
IC2Items.getItem("electronicCircuit") });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 2, 14), CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 2, 14),
new Object[]{"TST", "SBS", "TST", new Object[]
'S', "ingotSteel", { "TST", "SBS", "TST", 'S', "ingotSteel", 'T', "ingotTungsten",
'T', "ingotTungsten", 'B', "blockSteel" });
'B', "blockSteel"});
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 15), CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 15),
new Object[]{"AAA", "AMA", "AAA", new Object[]
'A', "ingotAluminium", { "AAA", "AMA", "AAA", 'A', "ingotAluminium", 'M',
'M', new ItemStack(ModItems.parts, 1, 13)}); new ItemStack(ModItems.parts, 1, 13) });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 16), CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 16),
new Object[]{"AAA", "AMA", "AAA", new Object[]
'A', "ingotBronze", { "AAA", "AMA", "AAA", 'A', "ingotBronze", 'M',
'M', new ItemStack(ModItems.parts, 1, 13)}); new ItemStack(ModItems.parts, 1, 13) });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 17), CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 17),
new Object[]{"AAA", "AMA", "AAA", new Object[]
'A', "ingotSteel", { "AAA", "AMA", "AAA", 'A', "ingotSteel", 'M',
'M', new ItemStack(ModItems.parts, 1, 13)}); new ItemStack(ModItems.parts, 1, 13) });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 18), CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 18),
new Object[]{"AAA", "AMA", "AAA", new Object[]
'A', "ingotTitanium", { "AAA", "AMA", "AAA", 'A', "ingotTitanium", 'M',
'M', new ItemStack(ModItems.parts, 1, 13)}); new ItemStack(ModItems.parts, 1, 13) });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 19), CraftingHelper.addShapedOreRecipe(new ItemStack(ModItems.parts, 1, 19),
new Object[]{"AAA", "AMA", "AAA", new Object[]
'A', "ingotBrass", { "AAA", "AMA", "AAA", 'A', "ingotBrass", 'M',
'M', new ItemStack(ModItems.parts, 1, 13)}); new ItemStack(ModItems.parts, 1, 13) });
//Storage Blocks // Storage Blocks
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 0), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 0), new Object[]
'A', "ingotSilver",}); { "AAA", "AAA", "AAA", 'A', "ingotSilver", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 1), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 1), new Object[]
'A', "ingotAluminium",}); { "AAA", "AAA", "AAA", 'A', "ingotAluminium", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 2), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 2), new Object[]
'A', "ingotTitanium",}); { "AAA", "AAA", "AAA", 'A', "ingotTitanium", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 3), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 3), new Object[]
'A', "gemSapphire",}); { "AAA", "AAA", "AAA", 'A', "gemSapphire", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 4), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 4), new Object[]
'A', "gemRuby",}); { "AAA", "AAA", "AAA", 'A', "gemRuby", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 5), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 5), new Object[]
'A', "gemGreenSapphire",}); { "AAA", "AAA", "AAA", 'A', "gemGreenSapphire", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 6), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 6), new Object[]
'A', "ingotChrome",}); { "AAA", "AAA", "AAA", 'A', "ingotChrome", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 7), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 7), new Object[]
'A', "ingotElectrum",}); { "AAA", "AAA", "AAA", 'A', "ingotElectrum", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 8), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 8), new Object[]
'A', "ingotTungsten",}); { "AAA", "AAA", "AAA", 'A', "ingotTungsten", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 9), CraftingHelper.addShapedOreRecipe(
new Object[]{"AAA", "AAA", "AAA", new ItemStack(ModBlocks.storage, 1, 9), new Object[]
'A', "ingotLead",}); { "AAA", "AAA", "AAA", 'A', "ingotLead", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 10), CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1,
new Object[]{"AAA", "AAA", "AAA", 10), new Object[]
'A', "ingotZinc",}); { "AAA", "AAA", "AAA", 'A', "ingotZinc", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 11), CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1,
new Object[]{"AAA", "AAA", "AAA", 11), new Object[]
'A', "ingotBrass",}); { "AAA", "AAA", "AAA", 'A', "ingotBrass", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 12), CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1,
new Object[]{"AAA", "AAA", "AAA", 12), new Object[]
'A', "ingotSteel",}); { "AAA", "AAA", "AAA", 'A', "ingotSteel", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 13), CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1,
new Object[]{"AAA", "AAA", "AAA", 13), new Object[]
'A', "ingotPlatinum",}); { "AAA", "AAA", "AAA", 'A', "ingotPlatinum", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 14), CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1,
new Object[]{"AAA", "AAA", "AAA", 14), new Object[]
'A', "ingotNickel",}); { "AAA", "AAA", "AAA", 'A', "ingotNickel", });
CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1, 15), CraftingHelper.addShapedOreRecipe(new ItemStack(ModBlocks.storage, 1,
new Object[]{"AAA", "AAA", "AAA", 15), new Object[]
'A', "ingotInvar",}); { "AAA", "AAA", "AAA", 'A', "ingotInvar", });
LogHelper.info("Shapped Recipes Added"); LogHelper.info("Shapped Recipes Added");
} }
public static void addShaplessRecipes() { 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,
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 6), "blockTitanium"); 4), "blockSilver");
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.gems, 9, 1), "blockSapphire"); CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9,
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.gems, 9, 0), "blockRuby"); 5), "blockAluminium");
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.gems, 9, 2), "blockGreenSapphire"); CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9,
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 7), "blockChrome"); 6), "blockTitanium");
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 8), "blockElectrum"); CraftingHelper.addShapelessOreRecipe(
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 9), "blockTungsten"); new ItemStack(ModItems.gems, 9, 1), "blockSapphire");
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 10), "blockLead"); CraftingHelper.addShapelessOreRecipe(
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 11), "blockZinc"); new ItemStack(ModItems.gems, 9, 0), "blockRuby");
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 12), "blockBrass"); CraftingHelper.addShapelessOreRecipe(
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 13), "blockSteel"); new ItemStack(ModItems.gems, 9, 2), "blockGreenSapphire");
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 14), "blockPlatinum"); CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9,
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 15), "blockNickel"); 7), "blockChrome");
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9, 16), "blockInvar"); CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.ingots, 9,
CraftingHelper.addShapelessOreRecipe(new ItemStack(ModItems.rockCutter, 1, 27), Items.apple); 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() { LogHelper.info("Smelting Recipes Added");
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"); public static void addMachineRecipes()
} {
TechRebornAPI.registerCentrifugeRecipe(new CentrifugeRecipie(
public static void addMachineRecipes() { Items.apple, 4, Items.beef, Items.baked_potato, null, null,
TechRebornAPI.registerCentrifugeRecipe(new CentrifugeRecipie(Items.apple, 4, Items.beef, Items.baked_potato, null, null, 120, 4)); 120, 4));
TechRebornAPI.registerCentrifugeRecipe(new CentrifugeRecipie(Items.nether_star, 1, Items.diamond, Items.emerald, Items.bed, Items.cake, 500, 8)); TechRebornAPI.registerCentrifugeRecipe(new CentrifugeRecipie(
TechRebornAPI.addRollingMachinceRecipe(new ItemStack(Blocks.furnace, 4), "ccc", "c c", "ccc", 'c', Blocks.cobblestone); Items.nether_star, 1, Items.diamond, Items.emerald, Items.bed,
LogHelper.info("Machine Recipes Added"); Items.cake, 500, 8));
} TechRebornAPI.addRollingMachinceRecipe(
new ItemStack(Blocks.furnace, 4), "ccc", "c c", "ccc", 'c',
Blocks.cobblestone);
LogHelper.info("Machine Recipes Added");
}
} }

View file

@ -3,13 +3,14 @@ package techreborn.itemblocks;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.ItemMultiTexture; import net.minecraft.item.ItemMultiTexture;
import techreborn.blocks.BlockMachineCasing; import techreborn.blocks.BlockMachineCasing;
import techreborn.blocks.BlockOre;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
public class ItemBlockMachineCasing extends ItemMultiTexture { public class ItemBlockMachineCasing extends ItemMultiTexture {
public ItemBlockMachineCasing(Block block) { public ItemBlockMachineCasing(Block block)
super(ModBlocks.MachineCasing, ModBlocks.MachineCasing, BlockMachineCasing.types); {
} super(ModBlocks.MachineCasing, ModBlocks.MachineCasing,
BlockMachineCasing.types);
}
} }

View file

@ -12,20 +12,28 @@ import techreborn.achievement.IPickupAchievement;
import techreborn.blocks.BlockOre; import techreborn.blocks.BlockOre;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
public class ItemBlockOre extends ItemMultiTexture implements IPickupAchievement, ICraftAchievement{ public class ItemBlockOre extends ItemMultiTexture implements
IPickupAchievement, ICraftAchievement {
public ItemBlockOre(Block block) { public ItemBlockOre(Block block)
super(ModBlocks.ore, ModBlocks.ore, BlockOre.types); {
} 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;
} }
@Override @Override
public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) { public Achievement getAchievementOnCraft(ItemStack stack,
return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) : null; 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;
} }
} }

View file

@ -1,7 +1,7 @@
package techreborn.itemblocks; package techreborn.itemblocks;
import cpw.mods.fml.relauncher.Side; import java.util.List;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
@ -9,39 +9,53 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.tiles.TileQuantumChest; import techreborn.tiles.TileQuantumChest;
import cpw.mods.fml.relauncher.Side;
import java.util.List; import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockQuantumChest extends ItemBlock { public class ItemBlockQuantumChest extends ItemBlock {
public ItemBlockQuantumChest(Block p_i45328_1_) { public ItemBlockQuantumChest(Block p_i45328_1_)
super(p_i45328_1_); {
} super(p_i45328_1_);
}
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings(
@Override { "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT) @Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { @SideOnly(Side.CLIENT)
if (stack != null && stack.hasTagCompound()) { public void addInformation(ItemStack stack, EntityPlayer player, List list,
if (stack.getTagCompound().getCompoundTag("tileEntity") != null) boolean par4)
list.add(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("storedQuantity") + " items"); {
} if (stack != null && stack.hasTagCompound())
} {
if (stack.getTagCompound().getCompoundTag("tileEntity") != null)
list.add(stack.getTagCompound().getCompoundTag("tileEntity")
.getInteger("storedQuantity")
+ " items");
}
}
@Override
@Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player,
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) { World world, int x, int y, int z, int side, float hitX, float hitY,
if (!world.setBlock(x, y, z, ModBlocks.quantumChest, metadata, 3)) { float hitZ, int metadata)
return false; {
} if (!world.setBlock(x, y, z, ModBlocks.quantumChest, metadata, 3))
if (world.getBlock(x, y, z) == ModBlocks.quantumChest) { {
world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player, stack); return false;
world.getBlock(x, y, z).onPostBlockPlaced(world, x, y, z, metadata); }
} if (world.getBlock(x, y, z) == ModBlocks.quantumChest)
if (stack != null && stack.hasTagCompound()) { {
((TileQuantumChest) world.getTileEntity(x, y, z)).readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player,
} stack);
return true; 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;
}
} }

View file

@ -10,22 +10,32 @@ import techreborn.tiles.TileQuantumTank;
public class ItemBlockQuantumTank extends ItemBlock { public class ItemBlockQuantumTank extends ItemBlock {
public ItemBlockQuantumTank(Block block) { public ItemBlockQuantumTank(Block block)
super(block); {
} super(block);
}
@Override @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) { public boolean placeBlockAt(ItemStack stack, EntityPlayer player,
if (!world.setBlock(x, y, z, ModBlocks.quantumTank, metadata, 3)) { World world, int x, int y, int z, int side, float hitX, float hitY,
return false; float hitZ, int metadata)
} {
if (world.getBlock(x, y, z) == ModBlocks.quantumTank) { if (!world.setBlock(x, y, z, ModBlocks.quantumTank, metadata, 3))
world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player, stack); {
world.getBlock(x, y, z).onPostBlockPlaced(world, x, y, z, metadata); return false;
} }
if (stack != null && stack.hasTagCompound()) { if (world.getBlock(x, y, z) == ModBlocks.quantumTank)
((TileQuantumTank) world.getTileEntity(x, y, z)).readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity")); {
} world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player,
return true; 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;
}
} }

View file

@ -7,8 +7,9 @@ import techreborn.init.ModBlocks;
public class ItemBlockStorage extends ItemMultiTexture { public class ItemBlockStorage extends ItemMultiTexture {
public ItemBlockStorage(Block block) { public ItemBlockStorage(Block block)
super(ModBlocks.storage, ModBlocks.storage, BlockStorage.types); {
} super(ModBlocks.storage, ModBlocks.storage, BlockStorage.types);
}
} }

View file

@ -1,76 +1,85 @@
package techreborn.items; package techreborn.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import techreborn.client.TechRebornCreativeTab;
import techreborn.client.TechRebornCreativeTabMisc; import techreborn.client.TechRebornCreativeTabMisc;
import java.util.List;
public class ItemCells extends ItemTR { public class ItemCells extends ItemTR {
public static final String[] types = new String[] public static final String[] types = new String[]
{ { "Berylium", "biomass", "calciumCarbonate", "calcium", "carbon",
"Berylium", "biomass", "calciumCarbonate", "calcium", "carbon", "chlorine", "deuterium", "chlorine", "deuterium", "diesel", "ethanol", "glyceryl",
"diesel", "ethanol", "glyceryl", "helium3", "helium", "heliumPlasma", "hydrogen", "ice", "lithium", "helium3", "helium", "heliumPlasma", "hydrogen", "ice", "lithium",
"mercury", "methane", "nitrocarbon", "nitroCoalfuel", "nitroDiesel", "nitrogen", "nitrogenDioxide", "oil", "mercury", "methane", "nitrocarbon", "nitroCoalfuel",
"potassium", "seedOil", "silicon", "sodium", "sodiumPersulfate", "sodiumSulfide", "sulfur", "sulfuricAcid", "nitroDiesel", "nitrogen", "nitrogenDioxide", "oil", "potassium",
"wolframium", "seedOil", "silicon", "sodium", "sodiumPersulfate",
}; "sodiumSulfide", "sulfur", "sulfuricAcid", "wolframium", };
private IIcon[] textures; private IIcon[] textures;
public ItemCells() { public ItemCells()
setUnlocalizedName("techreborn.cell"); {
setHasSubtypes(true); setUnlocalizedName("techreborn.cell");
setCreativeTab(TechRebornCreativeTabMisc.instance); setHasSubtypes(true);
} setCreativeTab(TechRebornCreativeTabMisc.instance);
}
@Override @Override
// Registers Textures For All Dusts // Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
textures = new IIcon[types.length]; {
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i) { for (int i = 0; i < types.length; ++i)
textures[i] = iconRegister.registerIcon("techreborn:" + "cells/" + types[i] + "Cell"); {
} textures[i] = iconRegister.registerIcon("techreborn:" + "cells/"
} + types[i] + "Cell");
}
}
@Override @Override
// Adds Texture what match's meta data // Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta) { public IIcon getIconFromDamage(int meta)
if (meta < 0 || meta >= textures.length) { {
meta = 0; if (meta < 0 || meta >= textures.length)
} {
meta = 0;
}
return textures[meta]; return textures[meta];
} }
@Override @Override
// gets Unlocalized Name depending on meta data // gets Unlocalized Name depending on meta data
public String getUnlocalizedName(ItemStack itemStack) { public String getUnlocalizedName(ItemStack itemStack)
int meta = itemStack.getItemDamage(); {
if (meta < 0 || meta >= types.length) { int meta = itemStack.getItemDamage();
meta = 0; if (meta < 0 || meta >= types.length)
} {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta]; return super.getUnlocalizedName() + "." + types[meta];
} }
// Adds Dusts SubItems To Creative Tab // Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
for (int meta = 0; meta < types.length; ++meta) { {
list.add(new ItemStack(item, 1, meta)); 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;
}
} }

View file

@ -11,67 +11,79 @@ import net.minecraft.util.IIcon;
import techreborn.client.TechRebornCreativeTabMisc; import techreborn.client.TechRebornCreativeTabMisc;
public class ItemDusts extends ItemTR { public class ItemDusts extends ItemTR {
public static final String[] types = new String[] public static final String[] types = new String[]
{ { "Almandine", "Aluminium", "Andradite", "Ashes", "Basalt", "Bauxite",
"Almandine", "Aluminium", "Andradite", "Ashes", "Basalt", "Bauxite", "Brass", "Bronze", "Brass", "Bronze", "Calcite", "Charcoal", "Chrome", "Cinnabar",
"Calcite", "Charcoal", "Chrome", "Cinnabar", "Clay", "Coal", "Copper", "DarkAshes", "Diamond", "Clay", "Coal", "Copper", "DarkAshes", "Diamond", "Electrum",
"Electrum", "Emerald", "EnderEye", "EnderPearl", "Endstone", "Flint", "Gold", "GreenSapphire", "Grossular", "Emerald", "EnderEye", "EnderPearl", "Endstone", "Flint", "Gold",
"Invar", "Iron", "Lazurite", "Lead", "Magnesium", "Marble", "Netherrack", "Nickel", "Obsidian", "GreenSapphire", "Grossular", "Invar", "Iron", "Lazurite", "Lead",
"Olivine", "Phosphor", "Platinum", "Pyrite", "Pyrope", "RedGarnet", "Redrock", "Ruby", "Saltpeter", "Sapphire", "Magnesium", "Marble", "Netherrack", "Nickel", "Obsidian",
"Silver", "Sodalite", "Spessartine", "Sphalerite", "Steel", "Sulfur", "Tin", "Titanium", "Tungsten", "Uranium", "Olivine", "Phosphor", "Platinum", "Pyrite", "Pyrope", "RedGarnet",
"Uvarovite", "YellowGarnet", "Zinc", "Cobalt", "Ardite", "Manyullyn", "AlBrass", "Alumite" "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() { public ItemDusts()
setUnlocalizedName("techreborn.dust"); {
setHasSubtypes(true); setUnlocalizedName("techreborn.dust");
setCreativeTab(TechRebornCreativeTabMisc.instance); setHasSubtypes(true);
} setCreativeTab(TechRebornCreativeTabMisc.instance);
}
@Override @Override
// Registers Textures For All Dusts // Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
textures = new IIcon[types.length]; {
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i) { for (int i = 0; i < types.length; ++i)
textures[i] = iconRegister.registerIcon("techreborn:" + "dust/" + types[i] + "Dust"); {
} textures[i] = iconRegister.registerIcon("techreborn:" + "dust/"
} + types[i] + "Dust");
}
}
@Override @Override
// Adds Texture what match's meta data // Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta) { public IIcon getIconFromDamage(int meta)
if (meta < 0 || meta >= textures.length) { {
meta = 0; if (meta < 0 || meta >= textures.length)
} {
meta = 0;
}
return textures[meta]; return textures[meta];
} }
@Override @Override
// gets Unlocalized Name depending on meta data // gets Unlocalized Name depending on meta data
public String getUnlocalizedName(ItemStack itemStack) { public String getUnlocalizedName(ItemStack itemStack)
int meta = itemStack.getItemDamage(); {
if (meta < 0 || meta >= types.length) { int meta = itemStack.getItemDamage();
meta = 0; if (meta < 0 || meta >= types.length)
} {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta]; return super.getUnlocalizedName() + "." + types[meta];
} }
// Adds Dusts SubItems To Creative Tab // Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
for (int meta = 0; meta < types.length; ++meta) { {
list.add(new ItemStack(item, 1, meta)); 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;
}
} }

View file

@ -11,67 +11,77 @@ import net.minecraft.util.IIcon;
import techreborn.client.TechRebornCreativeTabMisc; import techreborn.client.TechRebornCreativeTabMisc;
public class ItemDustsSmall extends ItemTR { public class ItemDustsSmall extends ItemTR {
public static final String[] types = new String[] public static final String[] types = new String[]
{ { "Almandine", "Aluminium", "Andradite", "Basalt", "Bauxite", "Brass",
"Almandine", "Aluminium", "Andradite", "Basalt", "Bauxite", "Brass", "Bronze", "Bronze", "Calcite", "Charcoal", "Chrome", "Cinnabar", "Clay",
"Calcite", "Charcoal", "Chrome", "Cinnabar", "Clay", "Coal", "Copper", "Diamond", "Coal", "Copper", "Diamond", "Electrum", "Emerald", "EnderEye",
"Electrum", "Emerald", "EnderEye", "EnderPearl", "Endstone", "Gold", "GreenSapphire", "Grossular", "EnderPearl", "Endstone", "Gold", "GreenSapphire", "Grossular",
"Invar", "Iron", "Lazurite", "Lead", "Magnesium", "Marble", "Netherrack", "Nickel", "Obsidian", "Invar", "Iron", "Lazurite", "Lead", "Magnesium", "Marble",
"Olivine", "Platinum", "Pyrite", "Pyrope", "RedGarnet", "Ruby", "Saltpeter", "Sapphire", "Netherrack", "Nickel", "Obsidian", "Olivine", "Platinum",
"Silver", "Sodalite", "Steel", "Sulfur", "Tin", "Titanium", "Tungsten", "Pyrite", "Pyrope", "RedGarnet", "Ruby", "Saltpeter", "Sapphire",
"Zinc", "Silver", "Sodalite", "Steel", "Sulfur", "Tin", "Titanium",
}; "Tungsten", "Zinc", };
private IIcon[] textures; private IIcon[] textures;
public ItemDustsSmall() { public ItemDustsSmall()
setUnlocalizedName("techreborn.dustsmall"); {
setHasSubtypes(true); setUnlocalizedName("techreborn.dustsmall");
setCreativeTab(TechRebornCreativeTabMisc.instance); setHasSubtypes(true);
} setCreativeTab(TechRebornCreativeTabMisc.instance);
}
@Override @Override
// Registers Textures For All Dusts // Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
textures = new IIcon[types.length]; {
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i) { for (int i = 0; i < types.length; ++i)
textures[i] = iconRegister.registerIcon("techreborn:" + "smallDust/small" + types[i] + "Dust"); {
} textures[i] = iconRegister.registerIcon("techreborn:"
} + "smallDust/small" + types[i] + "Dust");
}
}
@Override @Override
// Adds Texture what match's meta data // Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta) { public IIcon getIconFromDamage(int meta)
if (meta < 0 || meta >= textures.length) { {
meta = 0; if (meta < 0 || meta >= textures.length)
} {
meta = 0;
}
return textures[meta]; return textures[meta];
} }
@Override @Override
// gets Unlocalized Name depending on meta data // gets Unlocalized Name depending on meta data
public String getUnlocalizedName(ItemStack itemStack) { public String getUnlocalizedName(ItemStack itemStack)
int meta = itemStack.getItemDamage(); {
if (meta < 0 || meta >= types.length) { int meta = itemStack.getItemDamage();
meta = 0; if (meta < 0 || meta >= types.length)
} {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta]; return super.getUnlocalizedName() + "." + types[meta];
} }
// Adds Dusts SubItems To Creative Tab // Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
for (int meta = 0; meta < types.length; ++meta) { {
list.add(new ItemStack(item, 1, meta)); for (int meta = 0; meta < types.length; ++meta)
} {
} list.add(new ItemStack(item, 1, meta));
}
@Override }
public EnumRarity getRarity(ItemStack itemstack) {
return EnumRarity.epic;
}
@Override
public EnumRarity getRarity(ItemStack itemstack)
{
return EnumRarity.epic;
}
} }

View file

@ -11,60 +11,70 @@ import net.minecraft.util.IIcon;
import techreborn.client.TechRebornCreativeTabMisc; import techreborn.client.TechRebornCreativeTabMisc;
public class ItemGems extends Item { public class ItemGems extends Item {
public static final String[] types = new String[] public static final String[] types = new String[]
{ { "Ruby", "Sapphire", "GreenSapphire", "Olivine", "RedGarnet",
"Ruby", "Sapphire", "GreenSapphire", "Olivine", "RedGarnet", "YellowGarnet" "YellowGarnet" };
};
private IIcon[] textures; private IIcon[] textures;
public ItemGems() { public ItemGems()
setCreativeTab(TechRebornCreativeTabMisc.instance); {
setUnlocalizedName("techreborn.gem"); setCreativeTab(TechRebornCreativeTabMisc.instance);
setHasSubtypes(true); setUnlocalizedName("techreborn.gem");
} setHasSubtypes(true);
}
@Override @Override
// Registers Textures For All Dusts // Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
textures = new IIcon[types.length]; {
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i) { for (int i = 0; i < types.length; ++i)
textures[i] = iconRegister.registerIcon("techreborn:" + "gem/" + types[i]); {
} textures[i] = iconRegister.registerIcon("techreborn:" + "gem/"
} + types[i]);
}
}
@Override @Override
// Adds Texture what match's meta data // Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta) { public IIcon getIconFromDamage(int meta)
if (meta < 0 || meta >= textures.length) { {
meta = 0; if (meta < 0 || meta >= textures.length)
} {
meta = 0;
}
return textures[meta]; return textures[meta];
} }
@Override @Override
// gets Unlocalized Name depending on meta data // gets Unlocalized Name depending on meta data
public String getUnlocalizedName(ItemStack itemStack) { public String getUnlocalizedName(ItemStack itemStack)
int meta = itemStack.getItemDamage(); {
if (meta < 0 || meta >= types.length) { int meta = itemStack.getItemDamage();
meta = 0; if (meta < 0 || meta >= types.length)
} {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta]; return super.getUnlocalizedName() + "." + types[meta];
} }
// Adds Dusts SubItems To Creative Tab // Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
for (int meta = 0; meta < types.length; ++meta) { {
list.add(new ItemStack(item, 1, meta)); for (int meta = 0; meta < types.length; ++meta)
} {
} list.add(new ItemStack(item, 1, meta));
}
}
@Override @Override
public EnumRarity getRarity(ItemStack itemstack) { public EnumRarity getRarity(ItemStack itemstack)
return EnumRarity.uncommon; {
} return EnumRarity.uncommon;
}
} }

View file

@ -11,62 +11,72 @@ import net.minecraft.util.IIcon;
import techreborn.client.TechRebornCreativeTabMisc; import techreborn.client.TechRebornCreativeTabMisc;
public class ItemIngots extends Item { public class ItemIngots extends Item {
public static final String[] types = new String[] public static final String[] types = new String[]
{ { "IridiumAlloy", "HotTungstenSteel", "TungstenSteel", "Iridium", "Silver",
"IridiumAlloy", "HotTungstenSteel", "TungstenSteel", "Iridium", "Silver", "Aluminium", "Titanium", "Chrome", "Aluminium", "Titanium", "Chrome", "Electrum", "Tungsten", "Lead",
"Electrum", "Tungsten", "Lead", "Zinc", "Brass", "Steel", "Platinum", "Nickel", "Invar", "Zinc", "Brass", "Steel", "Platinum", "Nickel", "Invar", "Cobalt",
"Cobalt", "Ardite", "Manyullyn", "AlBrass", "Alumite" "Ardite", "Manyullyn", "AlBrass", "Alumite" };
};
private IIcon[] textures; private IIcon[] textures;
public ItemIngots() { public ItemIngots()
setCreativeTab(TechRebornCreativeTabMisc.instance); {
setHasSubtypes(true); setCreativeTab(TechRebornCreativeTabMisc.instance);
setUnlocalizedName("techreborn.ingot"); setHasSubtypes(true);
} setUnlocalizedName("techreborn.ingot");
}
@Override @Override
// Registers Textures For All Dusts // Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
textures = new IIcon[types.length]; {
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i) { for (int i = 0; i < types.length; ++i)
textures[i] = iconRegister.registerIcon("techreborn:" + "ingot/" + types[i] + "Ingot"); {
} textures[i] = iconRegister.registerIcon("techreborn:" + "ingot/"
} + types[i] + "Ingot");
}
}
@Override @Override
// Adds Texture what match's meta data // Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta) { public IIcon getIconFromDamage(int meta)
if (meta < 0 || meta >= textures.length) { {
meta = 0; if (meta < 0 || meta >= textures.length)
} {
meta = 0;
}
return textures[meta]; return textures[meta];
} }
@Override @Override
// gets Unlocalized Name depending on meta data // gets Unlocalized Name depending on meta data
public String getUnlocalizedName(ItemStack itemStack) { public String getUnlocalizedName(ItemStack itemStack)
int meta = itemStack.getItemDamage(); {
if (meta < 0 || meta >= types.length) { int meta = itemStack.getItemDamage();
meta = 0; if (meta < 0 || meta >= types.length)
} {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta]; return super.getUnlocalizedName() + "." + types[meta];
} }
// Adds Dusts SubItems To Creative Tab // Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
for (int meta = 0; meta < types.length; ++meta) { {
list.add(new ItemStack(item, 1, meta)); for (int meta = 0; meta < types.length; ++meta)
} {
} list.add(new ItemStack(item, 1, meta));
}
}
@Override @Override
public EnumRarity getRarity(ItemStack itemstack) { public EnumRarity getRarity(ItemStack itemstack)
return EnumRarity.uncommon; {
} return EnumRarity.uncommon;
}
} }

View file

@ -11,63 +11,75 @@ import net.minecraft.util.IIcon;
import techreborn.client.TechRebornCreativeTabMisc; import techreborn.client.TechRebornCreativeTabMisc;
public class ItemParts extends Item { public class ItemParts extends Item {
public static final String[] types = new String[] public static final String[] types = new String[]
{ { "LazuriteChunk", "SiliconPlate", "MagnaliumPlate", "EnergeyFlowCircuit",
"LazuriteChunk", "SiliconPlate", "MagnaliumPlate", "EnergeyFlowCircuit", "DataControlCircuit", "SuperConductor", "DataControlCircuit", "SuperConductor", "DataStorageCircuit",
"DataStorageCircuit", "ComputerMonitor", "DiamondSawBlade", "DiamondGrinder", "KanthalHeatingCoil", "ComputerMonitor", "DiamondSawBlade", "DiamondGrinder",
"NichromeHeatingCoil", "CupronickelHeatingCoil", "MachineParts", "WolframiamGrinder", "KanthalHeatingCoil", "NichromeHeatingCoil",
"AluminiumMachineHull", "BronzeMachineHull", "SteelMachineHull", "TitaniumMachineHull", "BrassMachineHull" "CupronickelHeatingCoil", "MachineParts", "WolframiamGrinder",
}; "AluminiumMachineHull", "BronzeMachineHull", "SteelMachineHull",
"TitaniumMachineHull", "BrassMachineHull" };
private IIcon[] textures; private IIcon[] textures;
public ItemParts() { public ItemParts()
setCreativeTab(TechRebornCreativeTabMisc.instance); {
setHasSubtypes(true); setCreativeTab(TechRebornCreativeTabMisc.instance);
setUnlocalizedName("techreborn.part"); setHasSubtypes(true);
} setUnlocalizedName("techreborn.part");
}
@Override @Override
// Registers Textures For All Dusts // Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
textures = new IIcon[types.length]; {
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i) { for (int i = 0; i < types.length; ++i)
textures[i] = iconRegister.registerIcon("techreborn:" + "part/" + types[i]); {
} textures[i] = iconRegister.registerIcon("techreborn:" + "part/"
} + types[i]);
}
}
@Override @Override
// Adds Texture what match's meta data // Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta) { public IIcon getIconFromDamage(int meta)
if (meta < 0 || meta >= textures.length) { {
meta = 0; if (meta < 0 || meta >= textures.length)
} {
meta = 0;
}
return textures[meta]; return textures[meta];
} }
@Override @Override
// gets Unlocalized Name depending on meta data // gets Unlocalized Name depending on meta data
public String getUnlocalizedName(ItemStack itemStack) { public String getUnlocalizedName(ItemStack itemStack)
int meta = itemStack.getItemDamage(); {
if (meta < 0 || meta >= types.length) { int meta = itemStack.getItemDamage();
meta = 0; if (meta < 0 || meta >= types.length)
} {
meta = 0;
}
return super.getUnlocalizedName() + "." + types[meta]; return super.getUnlocalizedName() + "." + types[meta];
} }
// Adds Dusts SubItems To Creative Tab // Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
for (int meta = 0; meta < types.length; ++meta) { {
list.add(new ItemStack(item, 1, meta)); for (int meta = 0; meta < types.length; ++meta)
} {
} list.add(new ItemStack(item, 1, meta));
}
}
@Override @Override
public EnumRarity getRarity(ItemStack itemstack) { public EnumRarity getRarity(ItemStack itemstack)
return EnumRarity.rare; {
} return EnumRarity.rare;
}
} }

View file

@ -7,14 +7,17 @@ import techreborn.lib.ModInfo;
public class ItemTR extends Item { public class ItemTR extends Item {
public ItemTR() { public ItemTR()
setNoRepair(); {
setCreativeTab(TechRebornCreativeTab.instance); setNoRepair();
} setCreativeTab(TechRebornCreativeTab.instance);
}
@Override @Override
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
itemIcon = iconRegister.registerIcon(ModInfo.MOD_ID + ":" + getUnlocalizedName().toLowerCase().substring(5)); {
} itemIcon = iconRegister.registerIcon(ModInfo.MOD_ID + ":"
+ getUnlocalizedName().toLowerCase().substring(5));
}
} }

View file

@ -1,9 +1,10 @@
package techreborn.items.armor; 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.ElectricItem;
import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -17,137 +18,179 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ISpecialArmor; import net.minecraftforge.common.ISpecialArmor;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn; 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 ItemGravityChest(ArmorMaterial material, int par3, int par4)
public int tier = 3; {
public int cost = 100; super(material, par3, par4);
public double transferLimit = 1000; setCreativeTab(TechRebornCreativeTab.instance);
public int energyPerDamage = 100; setUnlocalizedName("techreborn.gravitychestplate");
setMaxStackSize(1);
setMaxDamage(120);
// isDamageable();
}
public ItemGravityChest(ArmorMaterial material, int par3, int par4) { @SideOnly(Side.CLIENT)
super(material, par3, par4); @Override
setCreativeTab(TechRebornCreativeTab.instance); public void registerIcons(IIconRegister iconRegister)
setUnlocalizedName("techreborn.gravitychestplate"); {
setMaxStackSize(1); this.itemIcon = iconRegister.registerIcon("techreborn:"
setMaxDamage(120); + "items/gravitychestplate");
// isDamageable(); }
}
@SideOnly(Side.CLIENT) @Override
@Override @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) { public String getArmorTexture(ItemStack stack, Entity entity, int slot,
this.itemIcon = iconRegister.registerIcon("techreborn:" + "items/gravitychestplate"); String type)
} {
return "techreborn:" + "textures/models/gravitychestplate.png";
}
@Override @SuppressWarnings(
@SideOnly(Side.CLIENT) { "rawtypes", "unchecked" })
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { @SideOnly(Side.CLIENT)
return "techreborn:" + "textures/models/gravitychestplate.png"; 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"}) @Override
@SideOnly(Side.CLIENT) public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { {
ItemStack itemStack = new ItemStack(this, 1); if (world.isRemote)
if (getChargedItem(itemStack) == this) { ;
ItemStack charged = new ItemStack(this, 1); if (ElectricItem.manager.canUse(stack, cost))
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); {
itemList.add(charged); player.capabilities.allowFlying = true;
}
if (getEmptyItem(itemStack) == this) {
itemList.add(new ItemStack(this, 1, getMaxDamage()));
}
}
@Override if (player.fallDistance > 0.0F)
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { player.fallDistance = 0;
if (world.isRemote) ;
if (ElectricItem.manager.canUse(stack, cost)) {
player.capabilities.allowFlying = true;
if (player.fallDistance > 0.0F) if (player.capabilities.allowFlying == true & !player.onGround)
player.fallDistance = 0; ElectricItem.manager.discharge(stack, cost, tier, false, true,
false);
if (player.capabilities.allowFlying == true & !player.onGround) if (!ElectricItem.manager.canUse(stack, cost))
ElectricItem.manager.discharge(stack, cost, tier, false, true, false); player.capabilities.allowFlying = false;
}
if (!ElectricItem.manager.canUse(stack, cost)) if (player.fallDistance > 0.0F)
player.capabilities.allowFlying = false; player.fallDistance = 0;
} }
if (player.fallDistance > 0.0F) player.fallDistance = 0; @Override
} public boolean canProvideEnergy(ItemStack itemStack)
{
return true;
}
@Override @Override
public boolean canProvideEnergy(ItemStack itemStack) { public Item getChargedItem(ItemStack itemStack)
return true; {
} return this;
}
@Override @Override
public Item getChargedItem(ItemStack itemStack) { public Item getEmptyItem(ItemStack itemStack)
return this; {
} return this;
}
@Override @Override
public Item getEmptyItem(ItemStack itemStack) { public double getMaxCharge(ItemStack itemStack)
return this; {
} return maxCharge;
}
@Override @Override
public double getMaxCharge(ItemStack itemStack) { public int getTier(ItemStack itemStack)
return maxCharge; {
} return tier;
}
@Override @Override
public int getTier(ItemStack itemStack) { public double getTransferLimit(ItemStack itemStack)
return tier; {
} return transferLimit;
}
@Override public int getEnergyPerDamage()
public double getTransferLimit(ItemStack itemStack) { {
return transferLimit; return energyPerDamage;
} }
public int getEnergyPerDamage() { @Override
return energyPerDamage; 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 @Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot)
if (source.isUnblockable()) { {
return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 3); if (ElectricItem.manager.getCharge(armor) >= getEnergyPerDamage())
} else { {
double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio(); return (int) Math.round(20D * getBaseAbsorptionRatio()
int energyPerDamage = getEnergyPerDamage(); * getDamageAbsorptionRatio());
double damageLimit = energyPerDamage <= 0 ? 0 : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage; } else
return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(3, absorptionRatio, (int) damageLimit); {
} return 0;
} }
}
@Override @Override
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { public void damageArmor(EntityLivingBase entity, ItemStack stack,
if (ElectricItem.manager.getCharge(armor) >= getEnergyPerDamage()) { DamageSource source, int damage, int slot)
return (int) Math.round(20D * getBaseAbsorptionRatio() * getDamageAbsorptionRatio()); {
} else { ElectricItem.manager.discharge(stack, damage * getEnergyPerDamage(),
return 0; 0x7fffffff, true, false, false);
} }
}
@Override public double getDamageAbsorptionRatio()
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { {
ElectricItem.manager.discharge(stack, damage * getEnergyPerDamage(), 0x7fffffff, true, false, false); return 1.1000000000000001D;
} }
public double getDamageAbsorptionRatio() { private double getBaseAbsorptionRatio()
return 1.1000000000000001D; {
} return 0.14999999999999999D;
}
private double getBaseAbsorptionRatio() {
return 0.14999999999999999D;
}
} }

View file

@ -1,9 +1,10 @@
package techreborn.items.armor; 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.ElectricItem;
import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -12,76 +13,93 @@ import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import cpw.mods.fml.relauncher.Side;
import java.util.List; import cpw.mods.fml.relauncher.SideOnly;
public class ItemLapotronPack extends ItemArmor implements IElectricItem { public class ItemLapotronPack extends ItemArmor implements IElectricItem {
public static final int maxCharge = ConfigTechReborn.LapotronPackCharge; public static final int maxCharge = ConfigTechReborn.LapotronPackCharge;
public static final int tier = ConfigTechReborn.LapotronPackTier; public static final int tier = ConfigTechReborn.LapotronPackTier;
public double transferLimit = 100000; public double transferLimit = 100000;
public ItemLapotronPack(ArmorMaterial armormaterial, int par2, int par3) { public ItemLapotronPack(ArmorMaterial armormaterial, int par2, int par3)
super(armormaterial, par2, par3); {
setCreativeTab(TechRebornCreativeTab.instance); super(armormaterial, par2, par3);
setUnlocalizedName("techreborn.lapotronpack"); setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(1); setUnlocalizedName("techreborn.lapotronpack");
} setMaxStackSize(1);
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/lapotronicEnergyOrb"); {
} this.itemIcon = iconRegister.registerIcon("techreborn:"
+ "tool/lapotronicEnergyOrb");
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { public String getArmorTexture(ItemStack stack, Entity entity, int slot,
return "techreborn:" + "textures/models/lapotronpack.png"; String type)
} {
return "techreborn:" + "textures/models/lapotronpack.png";
}
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings(
@SideOnly(Side.CLIENT) { "rawtypes", "unchecked" })
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { @SideOnly(Side.CLIENT)
ItemStack itemStack = new ItemStack(this, 1); public void getSubItems(Item item, CreativeTabs par2CreativeTabs,
if (getChargedItem(itemStack) == this) { List itemList)
ItemStack charged = new ItemStack(this, 1); {
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); ItemStack itemStack = new ItemStack(this, 1);
itemList.add(charged); if (getChargedItem(itemStack) == this)
} {
if (getEmptyItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1);
itemList.add(new ItemStack(this, 1, getMaxDamage())); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
} false);
} itemList.add(charged);
}
if (getEmptyItem(itemStack) == this)
{
itemList.add(new ItemStack(this, 1, getMaxDamage()));
}
}
@Override @Override
public boolean canProvideEnergy(ItemStack itemStack) { public boolean canProvideEnergy(ItemStack itemStack)
return true; {
} return true;
}
@Override @Override
public Item getChargedItem(ItemStack itemStack) { public Item getChargedItem(ItemStack itemStack)
return this; {
} return this;
}
@Override @Override
public Item getEmptyItem(ItemStack itemStack) { public Item getEmptyItem(ItemStack itemStack)
return this; {
} return this;
}
@Override @Override
public double getMaxCharge(ItemStack itemStack) { public double getMaxCharge(ItemStack itemStack)
return maxCharge; {
} return maxCharge;
}
@Override @Override
public int getTier(ItemStack itemStack) { public int getTier(ItemStack itemStack)
return tier; {
} return tier;
}
@Override @Override
public double getTransferLimit(ItemStack itemStack) { public double getTransferLimit(ItemStack itemStack)
return transferLimit; {
} return transferLimit;
}
} }

View file

@ -1,9 +1,10 @@
package techreborn.items.armor; 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.ElectricItem;
import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItem;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -12,76 +13,93 @@ import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import cpw.mods.fml.relauncher.Side;
import java.util.List; import cpw.mods.fml.relauncher.SideOnly;
public class ItemLithiumBatpack extends ItemArmor implements IElectricItem { public class ItemLithiumBatpack extends ItemArmor implements IElectricItem {
public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge; public static final int maxCharge = ConfigTechReborn.LithiumBatpackCharge;
public static final int tier = ConfigTechReborn.LithiumBatpackTier; public static final int tier = ConfigTechReborn.LithiumBatpackTier;
public double transferLimit = 10000; public double transferLimit = 10000;
public ItemLithiumBatpack(ArmorMaterial armorMaterial, int par3, int par4) { public ItemLithiumBatpack(ArmorMaterial armorMaterial, int par3, int par4)
super(armorMaterial, par3, par4); {
setMaxStackSize(1); super(armorMaterial, par3, par4);
setUnlocalizedName("techreborn.lithiumbatpack"); setMaxStackSize(1);
setCreativeTab(TechRebornCreativeTab.instance); setUnlocalizedName("techreborn.lithiumbatpack");
} setCreativeTab(TechRebornCreativeTab.instance);
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/lithiumBatpack"); {
} this.itemIcon = iconRegister.registerIcon("techreborn:"
+ "tool/lithiumBatpack");
}
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { public String getArmorTexture(ItemStack stack, Entity entity, int slot,
return "techreborn:" + "textures/models/lithiumbatpack.png"; String type)
} {
return "techreborn:" + "textures/models/lithiumbatpack.png";
}
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings(
@SideOnly(Side.CLIENT) { "rawtypes", "unchecked" })
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { @SideOnly(Side.CLIENT)
ItemStack itemStack = new ItemStack(this, 1); public void getSubItems(Item item, CreativeTabs par2CreativeTabs,
if (getChargedItem(itemStack) == this) { List itemList)
ItemStack charged = new ItemStack(this, 1); {
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); ItemStack itemStack = new ItemStack(this, 1);
itemList.add(charged); if (getChargedItem(itemStack) == this)
} {
if (getEmptyItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1);
itemList.add(new ItemStack(this, 1, getMaxDamage())); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
} false);
} itemList.add(charged);
}
if (getEmptyItem(itemStack) == this)
{
itemList.add(new ItemStack(this, 1, getMaxDamage()));
}
}
@Override @Override
public boolean canProvideEnergy(ItemStack itemStack) { public boolean canProvideEnergy(ItemStack itemStack)
return true; {
} return true;
}
@Override @Override
public Item getChargedItem(ItemStack itemStack) { public Item getChargedItem(ItemStack itemStack)
return this; {
} return this;
}
@Override @Override
public Item getEmptyItem(ItemStack itemStack) { public Item getEmptyItem(ItemStack itemStack)
return this; {
} return this;
}
@Override @Override
public double getMaxCharge(ItemStack itemStack) { public double getMaxCharge(ItemStack itemStack)
return maxCharge; {
} return maxCharge;
}
@Override @Override
public int getTier(ItemStack itemStack) { public int getTier(ItemStack itemStack)
return tier; {
} return tier;
}
@Override @Override
public double getTransferLimit(ItemStack itemStack) { public double getTransferLimit(ItemStack itemStack)
return transferLimit; {
} return transferLimit;
}
} }

View file

@ -1,9 +1,10 @@
package techreborn.items.tools; 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.ElectricItem;
import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItem;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@ -17,111 +18,142 @@ import net.minecraft.world.World;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.util.TorchHelper; import techreborn.util.TorchHelper;
import cpw.mods.fml.relauncher.Side;
import java.util.List; import cpw.mods.fml.relauncher.SideOnly;
public class ItemAdvancedDrill extends ItemPickaxe implements IElectricItem { public class ItemAdvancedDrill extends ItemPickaxe implements IElectricItem {
public static final int maxCharge = ConfigTechReborn.AdvancedDrillCharge; public static final int maxCharge = ConfigTechReborn.AdvancedDrillCharge;
public int cost = 250; public int cost = 250;
public static final int tier = ConfigTechReborn.AdvancedDrillTier; public static final int tier = ConfigTechReborn.AdvancedDrillTier;
public double transferLimit = 100; public double transferLimit = 100;
public ItemAdvancedDrill() { public ItemAdvancedDrill()
super(ToolMaterial.EMERALD); {
efficiencyOnProperMaterial = 20F; super(ToolMaterial.EMERALD);
setCreativeTab(TechRebornCreativeTab.instance); efficiencyOnProperMaterial = 20F;
setMaxStackSize(1); setCreativeTab(TechRebornCreativeTab.instance);
setMaxDamage(240); setMaxStackSize(1);
setUnlocalizedName("techreborn.advancedDrill"); setMaxDamage(240);
} setUnlocalizedName("techreborn.advancedDrill");
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/advancedDrill"); {
} this.itemIcon = iconRegister.registerIcon("techreborn:"
+ "tool/advancedDrill");
}
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings(
@SideOnly(Side.CLIENT) { "rawtypes", "unchecked" })
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { @SideOnly(Side.CLIENT)
ItemStack itemStack = new ItemStack(this, 1); public void getSubItems(Item item, CreativeTabs par2CreativeTabs,
if (getChargedItem(itemStack) == this) { List itemList)
ItemStack charged = new ItemStack(this, 1); {
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); ItemStack itemStack = new ItemStack(this, 1);
itemList.add(charged); if (getChargedItem(itemStack) == this)
} {
if (getEmptyItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1);
itemList.add(new ItemStack(this, 1, getMaxDamage())); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
} false);
} itemList.add(charged);
}
if (getEmptyItem(itemStack) == this)
{
itemList.add(new ItemStack(this, 1, getMaxDamage()));
}
}
@Override @Override
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int par4, int par5, int par6, EntityLivingBase entityLiving) { public boolean onBlockDestroyed(ItemStack stack, World world, Block block,
ElectricItem.manager.use(stack, cost, entityLiving); int par4, int par5, int par6, EntityLivingBase entityLiving)
return true; {
} ElectricItem.manager.use(stack, cost, entityLiving);
return true;
}
@Override @Override
public boolean canHarvestBlock(Block block, ItemStack stack) { public boolean canHarvestBlock(Block block, ItemStack stack)
return Items.diamond_pickaxe.canHarvestBlock(block, stack) || Items.diamond_shovel.canHarvestBlock(block, stack); {
} return Items.diamond_pickaxe.canHarvestBlock(block, stack)
|| Items.diamond_shovel.canHarvestBlock(block, stack);
}
@Override @Override
public float getDigSpeed(ItemStack stack, Block block, int meta) { public float getDigSpeed(ItemStack stack, Block block, int meta)
if (!ElectricItem.manager.canUse(stack, cost)) { {
return 4.0F; 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) { if (Items.wooden_pickaxe.getDigSpeed(stack, block, meta) > 1.0F
return efficiencyOnProperMaterial; || Items.wooden_shovel.getDigSpeed(stack, block, meta) > 1.0F)
} else { {
return super.getDigSpeed(stack, block, meta); return efficiencyOnProperMaterial;
} } else
} {
return super.getDigSpeed(stack, block, meta);
}
}
@Override @Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase entityliving1) { public boolean hitEntity(ItemStack itemstack,
return true; EntityLivingBase entityliving, EntityLivingBase entityliving1)
} {
return true;
}
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { public boolean onItemUse(ItemStack stack, EntityPlayer player, World world,
return TorchHelper.placeTorch(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset); 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 @Override
public boolean isRepairable() { public boolean isRepairable()
return false; {
} return false;
}
@Override @Override
public boolean canProvideEnergy(ItemStack itemStack) { public boolean canProvideEnergy(ItemStack itemStack)
return false; {
} return false;
}
@Override @Override
public double getMaxCharge(ItemStack itemStack) { public double getMaxCharge(ItemStack itemStack)
return maxCharge; {
} return maxCharge;
}
@Override @Override
public int getTier(ItemStack itemStack) { public int getTier(ItemStack itemStack)
return tier; {
} return tier;
}
@Override @Override
public double getTransferLimit(ItemStack itemStack) { public double getTransferLimit(ItemStack itemStack)
return transferLimit; {
} return transferLimit;
}
@Override @Override
public Item getChargedItem(ItemStack itemStack) { public Item getChargedItem(ItemStack itemStack)
return this; {
} return this;
}
@Override @Override
public Item getEmptyItem(ItemStack itemStack) { public Item getEmptyItem(ItemStack itemStack)
return this; {
} return this;
}
} }

View file

@ -1,9 +1,10 @@
package techreborn.items.tools; 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.ElectricItem;
import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItem;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@ -18,115 +19,155 @@ import net.minecraft.world.World;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.util.TorchHelper; import techreborn.util.TorchHelper;
import cpw.mods.fml.relauncher.Side;
import java.util.List; import cpw.mods.fml.relauncher.SideOnly;
public class ItemOmniTool extends ItemPickaxe implements IElectricItem { public class ItemOmniTool extends ItemPickaxe implements IElectricItem {
public static final int maxCharge = ConfigTechReborn.OmniToolCharge; public static final int maxCharge = ConfigTechReborn.OmniToolCharge;
public static final int tier = ConfigTechReborn.OmniToolTier; public static final int tier = ConfigTechReborn.OmniToolTier;
public int cost = 100; public int cost = 100;
public int hitCost = 125; public int hitCost = 125;
public ItemOmniTool(ToolMaterial toolMaterial) { public ItemOmniTool(ToolMaterial toolMaterial)
super(toolMaterial); {
efficiencyOnProperMaterial = 13F; super(toolMaterial);
setCreativeTab(TechRebornCreativeTab.instance); efficiencyOnProperMaterial = 13F;
setMaxStackSize(1); setCreativeTab(TechRebornCreativeTab.instance);
setMaxDamage(200); setMaxStackSize(1);
setUnlocalizedName("techreborn.omniTool"); setMaxDamage(200);
} setUnlocalizedName("techreborn.omniTool");
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/omnitool"); {
} this.itemIcon = iconRegister.registerIcon("techreborn:"
+ "tool/omnitool");
}
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings(
@SideOnly(Side.CLIENT) { "rawtypes", "unchecked" })
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { @SideOnly(Side.CLIENT)
ItemStack itemStack = new ItemStack(this, 1); public void getSubItems(Item item, CreativeTabs par2CreativeTabs,
if (getChargedItem(itemStack) == this) { List itemList)
ItemStack charged = new ItemStack(this, 1); {
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); ItemStack itemStack = new ItemStack(this, 1);
itemList.add(charged); if (getChargedItem(itemStack) == this)
} {
if (getEmptyItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1);
itemList.add(new ItemStack(this, 1, getMaxDamage())); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
} false);
} itemList.add(charged);
}
if (getEmptyItem(itemStack) == this)
{
itemList.add(new ItemStack(this, 1, getMaxDamage()));
}
}
@Override @Override
public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int par4, int par5, int par6, EntityLivingBase entityLiving) { public boolean onBlockDestroyed(ItemStack stack, World world, Block block,
ElectricItem.manager.use(stack, cost, entityLiving); int par4, int par5, int par6, EntityLivingBase entityLiving)
return true; {
} ElectricItem.manager.use(stack, cost, entityLiving);
return true;
}
@Override @Override
public boolean canHarvestBlock(Block block, ItemStack stack) { 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); {
} 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 @Override
public float getDigSpeed(ItemStack stack, Block block, int meta) { public float getDigSpeed(ItemStack stack, Block block, int meta)
if (!ElectricItem.manager.canUse(stack, cost)) { {
return 5.0F; 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) { if (Items.wooden_axe.getDigSpeed(stack, block, meta) > 1.0F
return efficiencyOnProperMaterial; || Items.wooden_sword.getDigSpeed(stack, block, meta) > 1.0F
} else { || Items.wooden_pickaxe.getDigSpeed(stack, block, meta) > 1.0F
return super.getDigSpeed(stack, block, meta); || 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 @Override
public boolean hitEntity(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker) { public boolean hitEntity(ItemStack itemstack,
if (ElectricItem.manager.use(itemstack, hitCost, attacker)) { EntityLivingBase entityliving, EntityLivingBase attacker)
entityliving.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), 8F); {
} if (ElectricItem.manager.use(itemstack, hitCost, attacker))
return false; {
} entityliving
.attackEntityFrom(DamageSource
.causePlayerDamage((EntityPlayer) attacker), 8F);
}
return false;
}
@Override @Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { public boolean onItemUse(ItemStack stack, EntityPlayer player, World world,
return TorchHelper.placeTorch(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset); 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 @Override
public boolean isRepairable() { public boolean isRepairable()
return false; {
} return false;
}
@Override @Override
public Item getChargedItem(ItemStack itemStack) { public Item getChargedItem(ItemStack itemStack)
return this; {
} return this;
}
@Override @Override
public Item getEmptyItem(ItemStack itemStack) { public Item getEmptyItem(ItemStack itemStack)
return this; {
} return this;
}
@Override @Override
public boolean canProvideEnergy(ItemStack itemStack) { public boolean canProvideEnergy(ItemStack itemStack)
return false; {
} return false;
}
@Override @Override
public double getMaxCharge(ItemStack itemStack) { public double getMaxCharge(ItemStack itemStack)
return maxCharge; {
} return maxCharge;
}
@Override @Override
public int getTier(ItemStack itemStack) { public int getTier(ItemStack itemStack)
return 2; {
} return 2;
}
@Override @Override
public double getTransferLimit(ItemStack itemStack) { public double getTransferLimit(ItemStack itemStack)
return 200; {
} return 200;
}
} }

View file

@ -1,9 +1,10 @@
package techreborn.items.tools; 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.ElectricItem;
import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItem;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@ -16,87 +17,105 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import cpw.mods.fml.relauncher.Side;
import java.util.List; import cpw.mods.fml.relauncher.SideOnly;
public class ItemRockCutter extends ItemPickaxe implements IElectricItem { public class ItemRockCutter extends ItemPickaxe implements IElectricItem {
public static final int maxCharge = ConfigTechReborn.RockCutterCharge; public static final int maxCharge = ConfigTechReborn.RockCutterCharge;
public int cost = 500; public int cost = 500;
public static final int tier = ConfigTechReborn.RockCutterTier; public static final int tier = ConfigTechReborn.RockCutterTier;
public ItemRockCutter(ToolMaterial toolMaterial) { public ItemRockCutter(ToolMaterial toolMaterial)
super(toolMaterial); {
setUnlocalizedName("techreborn.rockcutter"); super(toolMaterial);
setCreativeTab(TechRebornCreativeTab.instance); setUnlocalizedName("techreborn.rockcutter");
setMaxStackSize(1); setCreativeTab(TechRebornCreativeTab.instance);
setMaxDamage(27); setMaxStackSize(1);
efficiencyOnProperMaterial = 16F; setMaxDamage(27);
} efficiencyOnProperMaterial = 16F;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public void registerIcons(IIconRegister iconRegister) { public void registerIcons(IIconRegister iconRegister)
this.itemIcon = iconRegister.registerIcon("techreborn:" + "tool/rockcutter"); {
} this.itemIcon = iconRegister.registerIcon("techreborn:"
+ "tool/rockcutter");
}
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings(
@SideOnly(Side.CLIENT) { "rawtypes", "unchecked" })
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { @SideOnly(Side.CLIENT)
ItemStack itemStack = new ItemStack(this, 1); public void getSubItems(Item item, CreativeTabs par2CreativeTabs,
if (getChargedItem(itemStack) == this) { List itemList)
ItemStack charged = new ItemStack(this, 1); {
ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); ItemStack itemStack = new ItemStack(this, 1);
itemList.add(charged); if (getChargedItem(itemStack) == this)
} {
if (getEmptyItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1);
itemList.add(new ItemStack(this, 1, getMaxDamage())); ElectricItem.manager.charge(charged, 2147483647, 2147483647, true,
} false);
} itemList.add(charged);
}
if (getEmptyItem(itemStack) == this)
{
itemList.add(new ItemStack(this, 1, getMaxDamage()));
}
}
@Override @Override
public boolean canHarvestBlock(Block block, ItemStack stack) { public boolean canHarvestBlock(Block block, ItemStack stack)
return Items.diamond_pickaxe.canHarvestBlock(block, stack); {
} return Items.diamond_pickaxe.canHarvestBlock(block, stack);
}
@Override @Override
public boolean isRepairable() { public boolean isRepairable()
return false; {
} return false;
}
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { public void onCreated(ItemStack par1ItemStack, World par2World,
par1ItemStack.addEnchantment(Enchantment.silkTouch, 1); EntityPlayer par3EntityPlayer)
} {
par1ItemStack.addEnchantment(Enchantment.silkTouch, 1);
}
@Override
public boolean canProvideEnergy(ItemStack itemStack)
{
return false;
}
@Override @Override
public boolean canProvideEnergy(ItemStack itemStack) { public Item getChargedItem(ItemStack itemStack)
return false; {
} return this;
}
@Override @Override
public Item getChargedItem(ItemStack itemStack) { public Item getEmptyItem(ItemStack itemStack)
return this; {
} return this;
}
@Override @Override
public Item getEmptyItem(ItemStack itemStack) { public double getMaxCharge(ItemStack itemStack)
return this; {
} return maxCharge;
}
@Override @Override
public double getMaxCharge(ItemStack itemStack) { public int getTier(ItemStack itemStack)
return maxCharge; {
} return tier;
}
@Override @Override
public int getTier(ItemStack itemStack) { public double getTransferLimit(ItemStack itemStack)
return tier; {
} return 300;
}
@Override
public double getTransferLimit(ItemStack itemStack) {
return 300;
}
} }

View file

@ -9,25 +9,27 @@ import techreborn.Core;
import techreborn.client.GuiHandler; import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
public class ItemTechPda extends Item{ public class ItemTechPda extends Item {
public ItemTechPda() public ItemTechPda()
{ {
setCreativeTab(TechRebornCreativeTab.instance); setCreativeTab(TechRebornCreativeTab.instance);
setUnlocalizedName("techreborn.pda"); setUnlocalizedName("techreborn.pda");
setMaxStackSize(1); setMaxStackSize(1);
} }
@Override @Override
public void registerIcons(IIconRegister iconRegister) public void registerIcons(IIconRegister iconRegister)
{
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); 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; return itemStack;
} }

View file

@ -3,43 +3,47 @@ package techreborn.lib;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class Functions { public class Functions {
public static int getIntDirFromDirection(ForgeDirection dir) { public static int getIntDirFromDirection(ForgeDirection dir)
switch (dir) { {
case DOWN: switch (dir)
return 0; {
case EAST: case DOWN:
return 5; return 0;
case NORTH: case EAST:
return 2; return 5;
case SOUTH: case NORTH:
return 3; return 2;
case UNKNOWN: case SOUTH:
return 0; return 3;
case UP: case UNKNOWN:
return 1; return 0;
case WEST: case UP:
return 4; return 1;
default: case WEST:
return 0; return 4;
} default:
} return 0;
}
}
public static ForgeDirection getDirectionFromInt(int dir) { public static ForgeDirection getDirectionFromInt(int dir)
int metaDataToSet = 0; {
switch (dir) { int metaDataToSet = 0;
case 0: switch (dir)
metaDataToSet = 2; {
break; case 0:
case 1: metaDataToSet = 2;
metaDataToSet = 4; break;
break; case 1:
case 2: metaDataToSet = 4;
metaDataToSet = 3; break;
break; case 2:
case 3: metaDataToSet = 3;
metaDataToSet = 5; break;
break; case 3:
} metaDataToSet = 5;
return ForgeDirection.getOrientation(metaDataToSet); break;
} }
return ForgeDirection.getOrientation(metaDataToSet);
}
} }

View file

@ -8,264 +8,290 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class Location { public class Location {
public int x; public int x;
public int y; public int y;
public int z; public int z;
public int depth; public int depth;
public Location(int x, int y, int z) { public Location(int x, int y, int z)
this.x = x; {
this.y = y; this.x = x;
this.z = z; this.y = y;
} this.z = z;
}
public Location(int x, int y, int z, int depth) { public Location(int x, int y, int z, int depth)
this.x = x; {
this.y = y; this.x = x;
this.z = z; this.y = y;
this.depth = depth; 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) { public Location(int[] coords)
this.x = xCoord + dir.offsetX; {
this.y = yCoord + dir.offsetY; if (coords.length >= 2)
this.z = zCoord + dir.offsetZ; {
} this.x = coords[0];
this.y = coords[1];
this.z = coords[2];
}
}
public Location(int[] coords) { public Location(ChunkPosition pos)
if (coords.length >= 2) { {
this.x = coords[0]; if (pos != null)
this.y = coords[1]; {
this.z = coords[2]; this.x = pos.chunkPosX;
} this.y = pos.chunkPosY;
} this.z = pos.chunkPosZ;
}
}
public Location(ChunkPosition pos) { public Location(MovingObjectPosition blockLookedAt)
if (pos != null) { {
this.x = pos.chunkPosX; if (blockLookedAt != null)
this.y = pos.chunkPosY; {
this.z = pos.chunkPosZ; this.x = blockLookedAt.blockX;
} this.y = blockLookedAt.blockY;
} this.z = blockLookedAt.blockZ;
}
}
public Location(MovingObjectPosition blockLookedAt) { public Location(TileEntity par1)
if (blockLookedAt != null) { {
this.x = blockLookedAt.blockX; this.x = par1.xCoord;
this.y = blockLookedAt.blockY; this.y = par1.yCoord;
this.z = blockLookedAt.blockZ; this.z = par1.zCoord;
} }
}
public Location(TileEntity par1) public boolean equals(Location toTest)
{ {
this.x = par1.xCoord; if (this.x == toTest.x && this.y == toTest.y && this.z == toTest.z)
this.y = par1.yCoord; {
this.z = par1.zCoord; return true;
} }
return false;
}
public boolean equals(Location toTest) { public void setLocation(int x, int y, int z)
if (this.x == toTest.x && this.y == toTest.y && this.z == toTest.z) { {
return true; this.x = x;
} this.y = y;
return false; this.z = z;
} }
public void setLocation(int x, int y, int z) { public int getX()
this.x = x; {
this.y = y; return this.x;
this.z = z; }
}
public int getX() { public void setX(int newX)
return this.x; {
} this.x = newX;
}
public void setX(int newX) { public int getY()
this.x = newX; {
} return this.y;
}
public int getY() { public void setY(int newY)
return this.y; {
} this.y = newY;
}
public void setY(int newY) { public int getZ()
this.y = newY; {
} return this.z;
}
public int getZ() { public void setZ(int newZ)
return this.z; {
} this.z = newZ;
}
public void setZ(int newZ) { public int[] getLocation()
this.z = newZ; {
} int[] ret = new int[3];
ret[0] = this.x;
ret[1] = this.y;
ret[2] = this.z;
return ret;
}
public int[] getLocation() { public void setLocation(int[] coords)
int[] ret = new int[3]; {
ret[0] = this.x; this.x = coords[0];
ret[1] = this.y; this.y = coords[1];
ret[2] = this.z; this.z = coords[2];
return ret; }
}
public void setLocation(int[] coords) { public int getDifference(Location otherLoc)
this.x = coords[0]; {
this.y = coords[1]; return (int) Math.sqrt(Math.pow(this.x - otherLoc.x, 2)
this.z = coords[2]; + Math.pow(this.y - otherLoc.y, 2)
} + Math.pow(this.z - otherLoc.z, 2));
}
public int getDifference(Location otherLoc) { public String printLocation()
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)); {
} return "X: " + this.x + " Y: " + this.y + " Z: " + this.z;
}
public String printLocation() { public String printCoords()
return "X: " + this.x + " Y: " + this.y + " Z: " + this.z; {
} return this.x + ", " + this.y + ", " + this.z;
}
public String printCoords() { public boolean compare(int x, int y, int z)
return this.x + ", " + this.y + ", " + this.z; {
} return (this.x == x && this.y == y && this.z == z);
}
public boolean compare(int x, int y, int z) { public Location getLocation(ForgeDirection dir)
return (this.x == x && this.y == y && this.z == z); {
} return new Location(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
}
public Location getLocation(ForgeDirection dir) { public Location modifyPositionFromSide(ForgeDirection side, int amount)
return new Location(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ); {
} 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) public Location modifyPositionFromSide(ForgeDirection side)
{ {
switch (side.ordinal()) return this.modifyPositionFromSide(side, 1);
{ }
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) /**
{ * This will load the chunk.
return this.modifyPositionFromSide(side, 1); */
} public TileEntity getTileEntity(IBlockAccess world)
{
return world.getTileEntity(this.x, this.y, this.z);
}
/** public final Location clone()
* This will load the chunk. {
*/ return new Location(this.x, this.y, this.z);
public TileEntity getTileEntity(IBlockAccess world) }
{
return world.getTileEntity(this.x, this.y, this.z);
}
public final Location clone() /**
{ * No chunk load: returns null if chunk to side is unloaded
return new Location(this.x, this.y, this.z); */
} 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 * No chunk load: returns null if chunk to side is unloaded
*/ */
public TileEntity getTileEntityOnSide(World world, ForgeDirection side) public TileEntity getTileEntityOnSide(World world, int side)
{ {
int x = this.x; int x = this.x;
int y = this.y; int y = this.y;
int z = this.z; int z = this.z;
switch (side.ordinal()) switch (side)
{ {
case 0: case 0:
y--; y--;
break; break;
case 1: case 1:
y++; y++;
break; break;
case 2: case 2:
z--; z--;
break; break;
case 3: case 3:
z++; z++;
break; break;
case 4: case 4:
x--; x--;
break; break;
case 5: case 5:
x++; x++;
break; break;
default: default:
return null; return null;
} }
if (world.blockExists(x, y, z)) if (world.blockExists(x, y, z))
{ {
return world.getTileEntity(x, y, z); return world.getTileEntity(x, y, z);
} } else
else {
{ return null;
return null; }
} }
}
/** public int getDepth()
* No chunk load: returns null if chunk to side is unloaded {
*/ return depth;
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() { public int compareTo(Location o)
return depth; {
} return ((Integer) depth).compareTo(o.depth);
}
public int compareTo(Location o) {
return ((Integer)depth).compareTo(o.depth);
}
} }

View file

@ -1,11 +1,11 @@
package techreborn.lib; package techreborn.lib;
public class ModInfo { public class ModInfo {
public static final String MOD_NAME = "TechReborn"; public static final String MOD_NAME = "TechReborn";
public static final String MOD_ID = "techreborn"; public static final String MOD_ID = "techreborn";
public static final String MOD_VERSION = "@MODVERSION@"; public static final String MOD_VERSION = "@MODVERSION@";
public static final String MOD_DEPENDENCUIES = "required-after:IC2@:"; public static final String MOD_DEPENDENCUIES = "required-after:IC2@:";
public static final String SERVER_PROXY_CLASS = "techreborn.proxies.CommonProxy"; public static final String SERVER_PROXY_CLASS = "techreborn.proxies.CommonProxy";
public static final String CLIENT_PROXY_CLASS = "techreborn.proxies.ClientProxy"; public static final String CLIENT_PROXY_CLASS = "techreborn.proxies.ClientProxy";
public static final String GUI_FACTORY_CLASS = "techreborn.config.TechRebornGUIFactory"; public static final String GUI_FACTORY_CLASS = "techreborn.config.TechRebornGUIFactory";
} }

View file

@ -1,8 +1,7 @@
package techreborn.lib.vecmath; package techreborn.lib.vecmath;
import cpw.mods.fml.common.FMLCommonHandler; import java.util.StringTokenizer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -12,420 +11,496 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.FMLCommonHandler;
import java.util.StringTokenizer; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Vecs3d { public class Vecs3d {
protected double x, y, z; protected double x, y, z;
protected World w = null; protected World w = null;
public Vecs3d(double x, double y, double z) { public Vecs3d(double x, double y, double z)
{
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; 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(x, y, z);
this.w = w; 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(vec.xCoord, vec.yCoord, vec.zCoord);
this.w = w; 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.x += x;
this.y += y; this.y += y;
this.z += z; this.z += z;
return this; 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.x -= x;
this.y -= y; this.y -= y;
this.z -= z; this.z -= z;
return this; 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.x *= x;
this.y *= y; this.y *= y;
this.z *= z; this.z *= z;
return this; 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.x /= x;
this.y /= y; this.y /= y;
this.z /= z; this.z /= z;
return this; 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) if (len == 0)
return v; return v;
v.x /= len; v.x /= len;
v.y /= len; v.y /= len;
v.z /= 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) for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
if (getBlockX() + d.offsetX == vec.getBlockX() && getBlockY() + d.offsetY == vec.getBlockY() if (getBlockX() + d.offsetX == vec.getBlockX()
&& getBlockZ() + d.offsetZ == vec.getBlockZ()) && getBlockY() + d.offsetY == vec.getBlockY()
return d; && getBlockZ() + d.offsetZ == vec.getBlockZ())
return null; 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 @Override
public Vecs3d clone() { 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()) { if (hasWorld())
return w.getTileEntity((int) x, (int) y, (int) z) != null; {
} return w.getTileEntity((int) x, (int) y, (int) z) != null;
return false; }
} return false;
}
public TileEntity getTileEntity() { public TileEntity getTileEntity()
{
if (hasTileEntity()) { if (hasTileEntity())
return w.getTileEntity((int) x, (int) y, (int) z); {
} return w.getTileEntity((int) x, (int) y, (int) z);
return null; }
} 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()) { if (hasWorld())
Block bl = w.getBlock((int) x, (int) y, (int) z); {
Block bl = w.getBlock((int) x, (int) y, (int) z);
if (b == null && bl == Blocks.air) if (b == null && bl == Blocks.air)
return true; return true;
if (b == null && checkAir && bl.getMaterial() == Material.air) if (b == null && checkAir && bl.getMaterial() == Material.air)
return true; return true;
if (b == null && checkAir && bl.isAir(w, (int) x, (int) y, (int) z)) if (b == null && checkAir && bl.isAir(w, (int) x, (int) y, (int) z))
return true; return true;
return bl.getClass().isInstance(b); return bl.getClass().isInstance(b);
} }
return false; return false;
} }
public int getBlockMeta() { public int getBlockMeta()
{
if (hasWorld()) { if (hasWorld())
return w.getBlockMetadata((int) x, (int) y, (int) z); {
} return w.getBlockMetadata((int) x, (int) y, (int) z);
return -1; }
} 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 (hasWorld())
if (airIsNull && isBlock(null, true)) {
return null; if (airIsNull && isBlock(null, true))
return w.getBlock((int) x, (int) y, (int) z); 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 dx = x - this.x;
double dy = y - this.y; double dy = y - this.y;
double dz = z - this.z; double dz = z - this.z;
return dx * dx + dy * dy + dz * dz; 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; this.y = y;
} }
public void setZ(double z) { public void setZ(double z)
{
this.z = z;
} this.z = z;
}
@Override
public boolean equals(Object obj) { @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; if (obj instanceof Vecs3d)
} {
return false; Vecs3d vec = (Vecs3d) obj;
} return vec.w == w && vec.x == x && vec.y == y && vec.z == z;
}
@Override return false;
public int hashCode() { }
return new Double(x).hashCode() + new Double(y).hashCode() << 8 + new Double(z).hashCode() << 16; @Override
} public int hashCode()
{
public Vec3 toVec3() {
return new Double(x).hashCode() + new Double(y).hashCode() << 8 + new Double(
return Vec3.createVectorHelper(x, y, z); z).hashCode() << 16;
} }
@Override public Vec3 toVec3()
public String toString() { {
String s = "Vector3{"; return Vec3.createVectorHelper(x, y, z);
if (hasWorld()) }
s += "w=" + w.provider.dimensionId + ";";
s += "x=" + x + ";y=" + y + ";z=" + z + "}"; @Override
return s; public String toString()
} {
public ForgeDirection toForgeDirection() { String s = "Vector3{";
if (hasWorld())
if (z == 1) s += "w=" + w.provider.dimensionId + ";";
return ForgeDirection.SOUTH; s += "x=" + x + ";y=" + y + ";z=" + z + "}";
if (z == -1) return s;
return ForgeDirection.NORTH; }
if (x == 1) public ForgeDirection toForgeDirection()
return ForgeDirection.EAST; {
if (x == -1)
return ForgeDirection.WEST; if (z == 1)
return ForgeDirection.SOUTH;
if (y == 1) if (z == -1)
return ForgeDirection.UP; return ForgeDirection.NORTH;
if (y == -1)
return ForgeDirection.DOWN; if (x == 1)
return ForgeDirection.EAST;
return ForgeDirection.UNKNOWN; if (x == -1)
} return ForgeDirection.WEST;
public static Vecs3d fromString(String s) { if (y == 1)
return ForgeDirection.UP;
if (s.startsWith("Vector3{") && s.endsWith("}")) { if (y == -1)
World w = null; return ForgeDirection.DOWN;
double x = 0, y = 0, z = 0;
String s2 = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}")); return ForgeDirection.UNKNOWN;
StringTokenizer st = new StringTokenizer(s2, ";"); }
while (st.hasMoreTokens()) {
String t = st.nextToken(); public static Vecs3d fromString(String s)
{
if (t.toLowerCase().startsWith("w")) {
int world = Integer.parseInt(t.split("=")[1]); if (s.startsWith("Vector3{") && s.endsWith("}"))
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { {
for (World wo : MinecraftServer.getServer().worldServers) { World w = null;
if (wo.provider.dimensionId == world) { double x = 0, y = 0, z = 0;
w = wo; String s2 = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}"));
break; StringTokenizer st = new StringTokenizer(s2, ";");
} while (st.hasMoreTokens())
} {
} else { String t = st.nextToken();
w = getClientWorld(world);
} if (t.toLowerCase().startsWith("w"))
} {
int world = Integer.parseInt(t.split("=")[1]);
if (t.toLowerCase().startsWith("x")) if (FMLCommonHandler.instance().getEffectiveSide()
x = Double.parseDouble(t.split("=")[1]); .isServer())
if (t.toLowerCase().startsWith("y")) {
y = Double.parseDouble(t.split("=")[1]); for (World wo : MinecraftServer.getServer().worldServers)
if (t.toLowerCase().startsWith("z")) {
z = Double.parseDouble(t.split("=")[1]); if (wo.provider.dimensionId == world)
} {
w = wo;
if (w != null) { break;
return new Vecs3d(x, y, z, w); }
} else { }
return new Vecs3d(x, y, z); } else
} {
} w = getClientWorld(world);
return null; }
} }
@SideOnly(Side.CLIENT) if (t.toLowerCase().startsWith("x"))
private static World getClientWorld(int world) { x = Double.parseDouble(t.split("=")[1]);
if (t.toLowerCase().startsWith("y"))
if (Minecraft.getMinecraft().theWorld.provider.dimensionId != world) y = Double.parseDouble(t.split("=")[1]);
return null; if (t.toLowerCase().startsWith("z"))
return Minecraft.getMinecraft().theWorld; 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;
}
} }

View file

@ -1,161 +1,186 @@
package techreborn.lib.vecmath; package techreborn.lib.vecmath;
import java.util.List;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.List;
public class Vecs3dCube { 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(); World w = a.getWorld();
if (w == null) if (w == null)
w = b.getWorld(); w = b.getWorld();
min = a; min = a;
max = b; 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 return new Vecs3dCube(min.clone(), max.clone());
public Vecs3dCube 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); return this;
max.add(size, size, size); }
return this; public Vecs3dCube fix()
} {
public Vecs3dCube fix() { Vecs3d a = min.clone();
Vecs3d b = max.clone();
Vecs3d a = min.clone(); double minX = Math.min(a.getX(), b.getX());
Vecs3d b = max.clone(); 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 maxX = Math.max(a.getX(), b.getX());
double minY = Math.min(a.getY(), b.getY()); double maxY = Math.max(a.getY(), b.getY());
double minZ = Math.min(a.getZ(), b.getZ()); double maxZ = Math.max(a.getZ(), b.getZ());
double maxX = Math.max(a.getX(), b.getX()); min = new Vecs3d(minX, minY, minZ, a.w);
double maxY = Math.max(a.getY(), b.getY()); max = new Vecs3d(maxX, maxY, maxZ, b.w);
double maxZ = Math.max(a.getZ(), b.getZ());
min = new Vecs3d(minX, minY, minZ, a.w); return this;
max = new Vecs3d(maxX, maxY, maxZ, b.w); }
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); return this;
max.add(x, y, z); }
return this; public static final Vecs3dCube merge(List<Vecs3dCube> cubes)
} {
public static final Vecs3dCube merge(List<Vecs3dCube> 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; for (Vecs3dCube c : cubes)
double miny = Double.MAX_VALUE; {
double minz = Double.MAX_VALUE; minx = Math.min(minx, c.getMinX());
double maxx = Double.MIN_VALUE; miny = Math.min(miny, c.getMinY());
double maxy = Double.MIN_VALUE; minz = Math.min(minz, c.getMinZ());
double maxz = Double.MIN_VALUE; maxx = Math.max(maxx, c.getMaxX());
maxy = Math.max(maxy, c.getMaxY());
maxz = Math.max(maxz, c.getMaxZ());
}
for (Vecs3dCube c : cubes) { if (cubes.size() == 0)
minx = Math.min(minx, c.getMinX()); return new Vecs3dCube(0, 0, 0, 0, 0, 0);
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(minx, miny, minz, maxx, maxy, maxz);
return new Vecs3dCube(0, 0, 0, 0, 0, 0); }
return new Vecs3dCube(minx, miny, minz, maxx, maxy, maxz); @Override
} public int hashCode()
{
@Override return min.hashCode() << 8 + max.hashCode();
public int hashCode() { }
return min.hashCode() << 8 + max.hashCode();
}
} }

View file

@ -1,136 +1,164 @@
package techreborn.multiblocks; 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.block.Block;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import techreborn.util.LogHelper; 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 class MultiBlockCasing extends RectangularMultiblockControllerBase {
public MultiBlockCasing(World world) { public MultiBlockCasing(World world)
super(world); {
} super(world);
}
@Override @Override
public void onAttachedPartWithMultiblockData(IMultiblockPart part, NBTTagCompound data) { public void onAttachedPartWithMultiblockData(IMultiblockPart part,
NBTTagCompound data)
{
} }
@Override @Override
protected void onBlockAdded(IMultiblockPart newPart) { protected void onBlockAdded(IMultiblockPart newPart)
} {
}
@Override @Override
protected void onBlockRemoved(IMultiblockPart oldPart) { protected void onBlockRemoved(IMultiblockPart oldPart)
{
} }
@Override @Override
protected void onMachineAssembled() { protected void onMachineAssembled()
LogHelper.warn("New multiblock created!"); {
} LogHelper.warn("New multiblock created!");
}
@Override @Override
protected void onMachineRestored() { protected void onMachineRestored()
{
} }
@Override @Override
protected void onMachinePaused() { protected void onMachinePaused()
{
} }
@Override @Override
protected void onMachineDisassembled() { protected void onMachineDisassembled()
{
} }
@Override @Override
protected int getMinimumNumberOfBlocksForAssembledMachine() { protected int getMinimumNumberOfBlocksForAssembledMachine()
return 1; {
} return 1;
}
@Override @Override
protected int getMaximumXSize() { protected int getMaximumXSize()
return 3; {
} return 3;
}
@Override @Override
protected int getMaximumZSize() { protected int getMaximumZSize()
return 3; {
} return 3;
}
@Override @Override
protected int getMaximumYSize() { protected int getMaximumYSize()
return 4; {
} return 4;
}
@Override @Override
protected int getMinimumXSize() { protected int getMinimumXSize()
return 3; {
} return 3;
}
@Override @Override
protected int getMinimumYSize() { protected int getMinimumYSize()
return 4; {
} return 4;
}
@Override @Override
protected int getMinimumZSize() { protected int getMinimumZSize()
return 3; {
} return 3;
}
@Override @Override
protected void onAssimilate(MultiblockControllerBase assimilated) { protected void onAssimilate(MultiblockControllerBase assimilated)
{
} }
@Override @Override
protected void onAssimilated(MultiblockControllerBase assimilator) { protected void onAssimilated(MultiblockControllerBase assimilator)
{
} }
@Override @Override
protected boolean updateServer() { protected boolean updateServer()
return true; {
} return true;
}
@Override @Override
protected void updateClient() { protected void updateClient()
{
} }
@Override @Override
public void writeToNBT(NBTTagCompound data) { public void writeToNBT(NBTTagCompound data)
{
} }
@Override @Override
public void readFromNBT(NBTTagCompound data) { public void readFromNBT(NBTTagCompound data)
{
} }
@Override @Override
public void formatDescriptionPacket(NBTTagCompound data) { public void formatDescriptionPacket(NBTTagCompound data)
{
} }
@Override @Override
public void decodeDescriptionPacket(NBTTagCompound data) { public void decodeDescriptionPacket(NBTTagCompound data)
{
} }
@Override
@Override protected void isBlockGoodForInterior(World world, int x, int y, int z)
protected void isBlockGoodForInterior(World world, int x, int y, int z) throws MultiblockValidationException { throws MultiblockValidationException
Block block = world.getBlock(x, y, z); {
if(block.getUnlocalizedName().equals("tile.lava") || block.getUnlocalizedName().equals("tile.air")){ Block block = world.getBlock(x, y, z);
} else { if (block.getUnlocalizedName().equals("tile.lava")
super.isBlockGoodForInterior(world, x, y, z); || block.getUnlocalizedName().equals("tile.air"))
} {
} } else
{
super.isBlockGoodForInterior(world, x, y, z);
}
}
} }

View file

@ -1,71 +1,97 @@
package techreborn.packets; 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.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; 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.io.IOException;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.logging.Logger; import java.util.logging.Logger;
public class PacketHandler extends FMLIndexedMessageToMessageCodec<SimplePacket> { import net.minecraft.entity.player.EntityPlayer;
private static EnumMap<Side, FMLEmbeddedChannel> channels; 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<SimplePacket> {
private static EnumMap<Side, FMLEmbeddedChannel> channels;
} public PacketHandler()
{
public static EnumMap<Side, FMLEmbeddedChannel> getChannels() { }
return channels;
}
public static void setChannels(EnumMap<Side, FMLEmbeddedChannel> _channels) { public static EnumMap<Side, FMLEmbeddedChannel> getChannels()
channels = _channels; {
} return channels;
}
public static void sendPacketToServer(SimplePacket packet) { public static void setChannels(EnumMap<Side, FMLEmbeddedChannel> _channels)
PacketHandler.getChannels().get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); {
PacketHandler.getChannels().get(Side.CLIENT).writeOutbound(packet); channels = _channels;
} }
public static void sendPacketToPlayer(SimplePacket packet, EntityPlayer player) { public static void sendPacketToServer(SimplePacket packet)
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.CLIENT)
PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet); .attr(FMLOutboundHandler.FML_MESSAGETARGET)
} .set(FMLOutboundHandler.OutboundTarget.TOSERVER);
PacketHandler.getChannels().get(Side.CLIENT).writeOutbound(packet);
}
public static void sendPacketToAllPlayers(SimplePacket packet) { public static void sendPacketToPlayer(SimplePacket packet,
PacketHandler.getChannels().get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); EntityPlayer player)
PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet); {
} 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) { public static void sendPacketToAllPlayers(SimplePacket packet)
for (Object player : world.playerEntities) { {
if (player instanceof EntityPlayerMP) PacketHandler.getChannels().get(Side.SERVER)
if (player != null) .attr(FMLOutboundHandler.FML_MESSAGETARGET)
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(packet); .set(FMLOutboundHandler.OutboundTarget.ALL);
} PacketHandler.getChannels().get(Side.SERVER).writeOutbound(packet);
} }
@Override public static void sendPacketToAllPlayers(Packet packet, World world)
public void encodeInto(ChannelHandlerContext ctx, SimplePacket msg, ByteBuf target) throws Exception { {
msg.writePacketData(target); for (Object player : world.playerEntities)
} {
if (player instanceof EntityPlayerMP)
if (player != null)
((EntityPlayerMP) player).playerNetServerHandler
.sendPacket(packet);
}
}
@Override @Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, SimplePacket msg) { public void encodeInto(ChannelHandlerContext ctx, SimplePacket msg,
try { ByteBuf target) throws Exception
msg.readPacketData(source); {
msg.execute(); msg.writePacketData(target);
} catch (IOException e) { }
Logger.getLogger("Network").warning("Something caused a Protocol Exception!");
} @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!");
}
}
} }

View file

@ -1,7 +1,9 @@
package techreborn.packets; package techreborn.packets;
import com.google.common.base.Charsets;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -9,110 +11,133 @@ import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import java.io.IOException; import com.google.common.base.Charsets;
public abstract class SimplePacket { public abstract class SimplePacket {
protected EntityPlayer player; protected EntityPlayer player;
protected byte mode; protected byte mode;
public SimplePacket(EntityPlayer _player) { public SimplePacket(EntityPlayer _player)
player = _player; {
} player = _player;
}
@SuppressWarnings("unused") @SuppressWarnings("unused")
public SimplePacket() { public SimplePacket()
player = null; {
} player = null;
}
public static String readString(ByteBuf in) throws IOException { public static String readString(ByteBuf in) throws IOException
byte[] stringBytes = new byte[in.readInt()]; {
in.readBytes(stringBytes); byte[] stringBytes = new byte[in.readInt()];
return new String(stringBytes, Charsets.UTF_8); in.readBytes(stringBytes);
} return new String(stringBytes, Charsets.UTF_8);
}
public static void writeString(String string, ByteBuf out) throws IOException { public static void writeString(String string, ByteBuf out)
byte[] stringBytes; throws IOException
stringBytes = string.getBytes(Charsets.UTF_8); {
out.writeInt(stringBytes.length); byte[] stringBytes;
out.writeBytes(stringBytes); stringBytes = string.getBytes(Charsets.UTF_8);
} out.writeInt(stringBytes.length);
out.writeBytes(stringBytes);
}
public static World readWorld(ByteBuf in) throws IOException { public static World readWorld(ByteBuf in) throws IOException
return DimensionManager.getWorld(in.readInt()); {
} return DimensionManager.getWorld(in.readInt());
}
public static void writeWorld(World world, ByteBuf out) throws IOException { public static void writeWorld(World world, ByteBuf out) throws IOException
out.writeInt(world.provider.dimensionId); {
} out.writeInt(world.provider.dimensionId);
}
public static EntityPlayer readPlayer(ByteBuf in) throws IOException { public static EntityPlayer readPlayer(ByteBuf in) throws IOException
if (!in.readBoolean()) {
return null; if (!in.readBoolean())
World playerWorld = readWorld(in); return null;
return playerWorld.getPlayerEntityByName(readString(in)); World playerWorld = readWorld(in);
} return playerWorld.getPlayerEntityByName(readString(in));
}
public static void writePlayer(EntityPlayer player, ByteBuf out) throws IOException { public static void writePlayer(EntityPlayer player, ByteBuf out)
if (player == null) { throws IOException
out.writeBoolean(false); {
return; if (player == null)
} {
out.writeBoolean(true); out.writeBoolean(false);
writeWorld(player.worldObj, out); return;
writeString(player.getCommandSenderName(), out); }
} out.writeBoolean(true);
writeWorld(player.worldObj, out);
writeString(player.getCommandSenderName(), out);
}
public static TileEntity readTileEntity(ByteBuf in) throws IOException { public static TileEntity readTileEntity(ByteBuf in) throws IOException
return readWorld(in).getTileEntity(in.readInt(), in.readInt(), in.readInt()); {
} return readWorld(in).getTileEntity(in.readInt(), in.readInt(),
in.readInt());
}
public static void writeTileEntity(TileEntity tileEntity, ByteBuf out) throws IOException { public static void writeTileEntity(TileEntity tileEntity, ByteBuf out)
writeWorld(tileEntity.getWorldObj(), out); throws IOException
out.writeInt(tileEntity.xCoord); {
out.writeInt(tileEntity.yCoord); writeWorld(tileEntity.getWorldObj(), out);
out.writeInt(tileEntity.zCoord); out.writeInt(tileEntity.xCoord);
} out.writeInt(tileEntity.yCoord);
out.writeInt(tileEntity.zCoord);
}
public static Fluid readFluid(ByteBuf in) throws IOException { public static Fluid readFluid(ByteBuf in) throws IOException
return FluidRegistry.getFluid(readString(in)); {
} return FluidRegistry.getFluid(readString(in));
}
public static void writeFluid(Fluid fluid, ByteBuf out) throws IOException { public static void writeFluid(Fluid fluid, ByteBuf out) throws IOException
if (fluid == null) { {
writeString("", out); if (fluid == null)
return; {
} writeString("", out);
writeString(fluid.getName(), out); return;
} }
writeString(fluid.getName(), out);
}
public void writePacketData(ByteBuf out) throws IOException { public void writePacketData(ByteBuf out) throws IOException
out.writeByte(mode); {
writePlayer(player, out); out.writeByte(mode);
writeData(out); 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 { public void readPacketData(ByteBuf in) throws IOException
mode = in.readByte(); {
player = readPlayer(in); mode = in.readByte();
readData(in); 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() { public void sendPacketToServer()
PacketHandler.sendPacketToServer(this); {
} PacketHandler.sendPacketToServer(this);
}
public void sendPacketToPlayer(EntityPlayer player) { public void sendPacketToPlayer(EntityPlayer player)
PacketHandler.sendPacketToPlayer(this, player); {
} PacketHandler.sendPacketToPlayer(this, player);
}
public void sendPacketToAllPlayers() { public void sendPacketToAllPlayers()
PacketHandler.sendPacketToAllPlayers(this); {
} PacketHandler.sendPacketToAllPlayers(this);
}
} }

View file

@ -1,13 +1,14 @@
package techreborn.partSystem; package techreborn.partSystem;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList;
public interface ICustomHighlight { public interface ICustomHighlight {
ArrayList<AxisAlignedBB> getBoxes(World world, int x, int y, int z, EntityPlayer player); ArrayList<AxisAlignedBB> getBoxes(World world, int x, int y, int z,
EntityPlayer player);
} }

View file

@ -4,29 +4,30 @@
package techreborn.partSystem; package techreborn.partSystem;
import cpw.mods.fml.relauncher.Side; import java.util.List;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import techreborn.lib.vecmath.Vecs3d; import techreborn.lib.vecmath.Vecs3d;
import techreborn.lib.vecmath.Vecs3dCube; import techreborn.lib.vecmath.Vecs3dCube;
import cpw.mods.fml.relauncher.Side;
import java.util.List; 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
* <p/> * <p/>
* You should not be implementing this. * You should not be implementing this.
*/ */
public interface IModPart { 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<Vecs3dCube> boxes, Entity entity); public void addCollisionBoxesToList(List<Vecs3dCube> boxes, Entity entity);
@ -35,7 +36,6 @@ public interface IModPart {
*/ */
public List<Vecs3dCube> getSelectionBoxes(); public List<Vecs3dCube> getSelectionBoxes();
/** /**
* Gets this part's occlusion boxes. * Gets this part's occlusion boxes.
*/ */
@ -49,10 +49,12 @@ public interface IModPart {
/** /**
* Renders this part statically. A tessellator has alredy started drawing. <br> * Renders this part statically. A tessellator has alredy started drawing. <br>
* 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) @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. * 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(); 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(); public void nearByChange();

View file

@ -11,18 +11,20 @@ import net.minecraft.world.World;
import techreborn.lib.Location; import techreborn.lib.Location;
import techreborn.lib.vecmath.Vecs3dCube; import techreborn.lib.vecmath.Vecs3dCube;
public interface IPartProvider { public interface IPartProvider {
public String modID(); public String modID();
public void registerPart(); 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 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); public boolean isTileFromProvider(TileEntity tileEntity);
} }

Some files were not shown because too many files have changed in this diff Show more