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

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

View file

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

View file

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

View file

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

View file

@ -7,8 +7,9 @@ import net.minecraft.world.World;
import erogenousbeef.coreTR.common.BeefCoreLog;
/**
* This is a very static singleton registry class which directs incoming events to sub-objects, which
* actually manage each individual world's multiblocks.
* This is a very static singleton registry class which directs incoming events
* to sub-objects, which actually manage each individual world's multiblocks.
*
* @author Erogenous Beef
*/
public class MultiblockRegistry {
@ -17,10 +18,14 @@ public class MultiblockRegistry {
/**
* Called before Tile Entities are ticked in the world. Do bookkeeping here.
* @param world The world being ticked
*
* @param world
* The world being ticked
*/
public static void tickStart(World world) {
if(registries.containsKey(world)) {
public static void tickStart(World world)
{
if (registries.containsKey(world))
{
MultiblockWorldRegistry registry = registries.get(world);
registry.processMultiblockChanges();
registry.tickStart();
@ -29,87 +34,127 @@ public class MultiblockRegistry {
/**
* Called when the world has finished loading a chunk.
* @param world The world which has finished loading a chunk
* @param chunkX The X coordinate of the chunk
* @param chunkZ The Z coordinate of the chunk
*
* @param world
* The world which has finished loading a chunk
* @param chunkX
* The X coordinate of the chunk
* @param chunkZ
* The Z coordinate of the chunk
*/
public static void onChunkLoaded(World world, int chunkX, int chunkZ) {
if(registries.containsKey(world)) {
public static void onChunkLoaded(World world, int chunkX, int chunkZ)
{
if (registries.containsKey(world))
{
registries.get(world).onChunkLoaded(chunkX, chunkZ);
}
}
/**
* Register a new part in the system. The part has been created either through user action or via a chunk loading.
* @param world The world into which this part is loading.
* @param part The part being loaded.
* Register a new part in the system. The part has been created either
* through user action or via a chunk loading.
*
* @param world
* The world into which this part is loading.
* @param part
* The part being loaded.
*/
public static void onPartAdded(World world, IMultiblockPart part) {
public static void onPartAdded(World world, IMultiblockPart part)
{
MultiblockWorldRegistry registry = getOrCreateRegistry(world);
registry.onPartAdded(part);
}
/**
* Call to remove a part from world lists.
* @param world The world from which a multiblock part is being removed.
* @param part The part being removed.
*
* @param world
* The world from which a multiblock part is being removed.
* @param part
* The part being removed.
*/
public static void onPartRemovedFromWorld(World world, IMultiblockPart part) {
if(registries.containsKey(world)) {
public static void onPartRemovedFromWorld(World world, IMultiblockPart part)
{
if (registries.containsKey(world))
{
registries.get(world).onPartRemovedFromWorld(part);
}
}
/**
* Called whenever a world is unloaded. Unload the relevant registry, if we have one.
* @param world The world being unloaded.
* Called whenever a world is unloaded. Unload the relevant registry, if we
* have one.
*
* @param world
* The world being unloaded.
*/
public static void onWorldUnloaded(World world) {
if(registries.containsKey(world)) {
public static void onWorldUnloaded(World world)
{
if (registries.containsKey(world))
{
registries.get(world).onWorldUnloaded();
registries.remove(world);
}
}
/**
* Call to mark a controller as dirty. Dirty means that parts have
* been added or removed this tick.
* @param world The world containing the multiblock
* @param controller The dirty controller
* Call to mark a controller as dirty. Dirty means that parts have been
* added or removed this tick.
*
* @param world
* The world containing the multiblock
* @param controller
* The dirty controller
*/
public static void addDirtyController(World world,
MultiblockControllerBase controller) {
if(registries.containsKey(world)) {
MultiblockControllerBase controller)
{
if (registries.containsKey(world))
{
registries.get(world).addDirtyController(controller);
}
else {
throw new IllegalArgumentException("Adding a dirty controller to a world that has no registered controllers!");
} else
{
throw new IllegalArgumentException(
"Adding a dirty controller to a world that has no registered controllers!");
}
}
/**
* Call to mark a controller as dead. It should only be marked as dead
* when it has no connected parts. It will be removed after the next world tick.
* @param world The world formerly containing the multiblock
* @param controller The dead controller
* 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)) {
public static void addDeadController(World world,
MultiblockControllerBase controller)
{
if (registries.containsKey(world))
{
registries.get(world).addDeadController(controller);
}
else {
BeefCoreLog.warning("Controller %d in world %s marked as dead, but that world is not tracked! Controller is being ignored.", controller.hashCode(), world);
} else
{
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.
* @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)) {
public static Set<MultiblockControllerBase> getControllersFromWorld(
World world)
{
if (registries.containsKey(world))
{
return registries.get(world).getControllers();
}
return null;
@ -117,12 +162,15 @@ public class MultiblockRegistry {
// / *** PRIVATE HELPERS *** ///
private static MultiblockWorldRegistry getOrCreateRegistry(World world) {
if(registries.containsKey(world)) {
private static MultiblockWorldRegistry getOrCreateRegistry(World world)
{
if (registries.containsKey(world))
{
return registries.get(world);
}
else {
MultiblockWorldRegistry newRegistry = new MultiblockWorldRegistry(world);
} else
{
MultiblockWorldRegistry newRegistry = new MultiblockWorldRegistry(
world);
registries.put(world, newRegistry);
return newRegistry;
}

View file

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

View file

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

View file

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

View file

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

View file

@ -1,19 +1,13 @@
package erogenousbeef.coreTR.multiblock.rectangular;
public enum PartPosition {
Unknown,
Interior,
FrameCorner,
Frame,
TopFace,
BottomFace,
NorthFace,
SouthFace,
EastFace,
WestFace;
public enum PartPosition
{
Unknown, Interior, FrameCorner, Frame, TopFace, BottomFace, NorthFace, SouthFace, EastFace, WestFace;
public boolean isFace(PartPosition position) {
switch(position) {
public boolean isFace(PartPosition position)
{
switch (position)
{
case TopFace:
case BottomFace:
case NorthFace:

View file

@ -9,15 +9,19 @@ import erogenousbeef.coreTR.multiblock.MultiblockValidationException;
public abstract class RectangularMultiblockControllerBase extends
MultiblockControllerBase {
protected RectangularMultiblockControllerBase(World world) {
protected RectangularMultiblockControllerBase(World world)
{
super(world);
}
/**
* @return True if the machine is "whole" and should be assembled. False otherwise.
* @return True if the machine is "whole" and should be assembled. False
* otherwise.
*/
protected void isMachineWhole() throws MultiblockValidationException {
if(connectedParts.size() < getMinimumNumberOfBlocksForAssembledMachine()) {
protected void isMachineWhole() throws MultiblockValidationException
{
if (connectedParts.size() < getMinimumNumberOfBlocksForAssembledMachine())
{
throw new MultiblockValidationException("Machine is too small.");
}
@ -36,89 +40,161 @@ public abstract class RectangularMultiblockControllerBase extends
int minY = getMinimumYSize();
int minZ = getMinimumZSize();
if(maxX > 0 && deltaX > maxX) { throw new MultiblockValidationException(String.format("Machine is too large, it may be at most %d blocks in the X dimension", maxX)); }
if(maxY > 0 && deltaY > maxY) { throw new MultiblockValidationException(String.format("Machine is too large, it may be at most %d blocks in the Y dimension", maxY)); }
if(maxZ > 0 && deltaZ > maxZ) { throw new MultiblockValidationException(String.format("Machine is too large, it may be at most %d blocks in the Z dimension", maxZ)); }
if(deltaX < minX) { throw new MultiblockValidationException(String.format("Machine is too small, it must be at least %d blocks in the X dimension", minX)); }
if(deltaY < minY) { throw new MultiblockValidationException(String.format("Machine is too small, it must be at least %d blocks in the Y dimension", minY)); }
if(deltaZ < minZ) { throw new MultiblockValidationException(String.format("Machine is too small, it must be at least %d blocks in the Z dimension", minZ)); }
if (maxX > 0 && deltaX > maxX)
{
throw new MultiblockValidationException(
String.format(
"Machine is too large, it may be at most %d blocks in the X dimension",
maxX));
}
if (maxY > 0 && deltaY > maxY)
{
throw new MultiblockValidationException(
String.format(
"Machine is too large, it may be at most %d blocks in the Y dimension",
maxY));
}
if (maxZ > 0 && deltaZ > maxZ)
{
throw new MultiblockValidationException(
String.format(
"Machine is too large, it may be at most %d blocks in the Z dimension",
maxZ));
}
if (deltaX < minX)
{
throw new MultiblockValidationException(
String.format(
"Machine is too small, it must be at least %d blocks in the X dimension",
minX));
}
if (deltaY < minY)
{
throw new MultiblockValidationException(
String.format(
"Machine is too small, it must be at least %d blocks in the Y dimension",
minY));
}
if (deltaZ < minZ)
{
throw new MultiblockValidationException(
String.format(
"Machine is too small, it must be at least %d blocks in the Z dimension",
minZ));
}
// Now we run a simple check on each block within that volume.
// Any block deviating = NO DEAL SIR
TileEntity te;
RectangularMultiblockTileEntityBase part;
Class<? extends RectangularMultiblockControllerBase> myClass = this.getClass();
Class<? extends RectangularMultiblockControllerBase> myClass = this
.getClass();
for(int x = minimumCoord.x; x <= maximumCoord.x; x++) {
for(int y = minimumCoord.y; y <= maximumCoord.y; y++) {
for(int z = minimumCoord.z; z <= maximumCoord.z; z++) {
for (int x = minimumCoord.x; x <= maximumCoord.x; x++)
{
for (int y = minimumCoord.y; y <= maximumCoord.y; y++)
{
for (int z = minimumCoord.z; z <= maximumCoord.z; z++)
{
// Okay, figure out what sort of block this should be.
te = this.worldObj.getTileEntity(x, y, z);
if(te instanceof RectangularMultiblockTileEntityBase) {
if (te instanceof RectangularMultiblockTileEntityBase)
{
part = (RectangularMultiblockTileEntityBase) te;
// Ensure this part should actually be allowed within a cube of this controller's type
// Ensure this part should actually be allowed within a
// cube of this controller's type
if (!myClass.equals(part.getMultiblockControllerType()))
{
throw new MultiblockValidationException(String.format("Part @ %d, %d, %d is incompatible with machines of type %s", x, y, z, myClass.getSimpleName()));
throw new MultiblockValidationException(
String.format(
"Part @ %d, %d, %d is incompatible with machines of type %s",
x, y, z, myClass.getSimpleName()));
}
}
else {
// This is permitted so that we can incorporate certain non-multiblock parts inside interiors
} else
{
// This is permitted so that we can incorporate certain
// non-multiblock parts inside interiors
part = null;
}
// Validate block type against both part-level and material-level validators.
// Validate block type against both part-level and
// material-level validators.
int extremes = 0;
if(x == minimumCoord.x) { extremes++; }
if(y == minimumCoord.y) { extremes++; }
if(z == minimumCoord.z) { extremes++; }
if(x == maximumCoord.x) { extremes++; }
if(y == maximumCoord.y) { extremes++; }
if(z == maximumCoord.z) { extremes++; }
if(extremes >= 2) {
if(part != null) {
part.isGoodForFrame();
if (x == minimumCoord.x)
{
extremes++;
}
else {
if (y == minimumCoord.y)
{
extremes++;
}
if (z == minimumCoord.z)
{
extremes++;
}
if (x == maximumCoord.x)
{
extremes++;
}
if (y == maximumCoord.y)
{
extremes++;
}
if (z == maximumCoord.z)
{
extremes++;
}
if (extremes >= 2)
{
if (part != null)
{
part.isGoodForFrame();
} else
{
isBlockGoodForFrame(this.worldObj, x, y, z);
}
}
else if(extremes == 1) {
if(y == maximumCoord.y) {
if(part != null) {
} else if (extremes == 1)
{
if (y == maximumCoord.y)
{
if (part != null)
{
part.isGoodForTop();
}
else {
} else
{
isBlockGoodForTop(this.worldObj, x, y, z);
}
}
else if(y == minimumCoord.y) {
if(part != null) {
} else if (y == minimumCoord.y)
{
if (part != null)
{
part.isGoodForBottom();
}
else {
} else
{
isBlockGoodForBottom(this.worldObj, x, y, z);
}
}
else {
} else
{
// Side
if(part != null) {
if (part != null)
{
part.isGoodForSides();
}
else {
} else
{
isBlockGoodForSides(this.worldObj, x, y, z);
}
}
}
else {
if(part != null) {
} else
{
if (part != null)
{
part.isGoodForInterior();
}
else {
} else
{
isBlockGoodForInterior(this.worldObj, x, y, z);
}
}

View file

@ -12,7 +12,8 @@ public abstract class RectangularMultiblockTileEntityBase extends
PartPosition position;
ForgeDirection outwards;
public RectangularMultiblockTileEntityBase() {
public RectangularMultiblockTileEntityBase()
{
super();
position = PartPosition.Unknown;
@ -20,24 +21,28 @@ public abstract class RectangularMultiblockTileEntityBase extends
}
// Positional Data
public ForgeDirection getOutwardsDir() {
public ForgeDirection getOutwardsDir()
{
return outwards;
}
public PartPosition getPartPosition() {
public PartPosition getPartPosition()
{
return position;
}
// Handlers from MultiblockTileEntityBase
@Override
public void onAttached(MultiblockControllerBase newController) {
public void onAttached(MultiblockControllerBase newController)
{
super.onAttached(newController);
recalculateOutwardsDirection(newController.getMinimumCoord(), newController.getMaximumCoord());
recalculateOutwardsDirection(newController.getMinimumCoord(),
newController.getMaximumCoord());
}
@Override
public void onMachineAssembled(MultiblockControllerBase controller) {
public void onMachineAssembled(MultiblockControllerBase controller)
{
CoordTriplet maxCoord = controller.getMaximumCoord();
CoordTriplet minCoord = controller.getMinimumCoord();
@ -46,47 +51,67 @@ public abstract class RectangularMultiblockTileEntityBase extends
}
@Override
public void onMachineBroken() {
public void onMachineBroken()
{
position = PartPosition.Unknown;
outwards = ForgeDirection.UNKNOWN;
}
// Positional helpers
public void recalculateOutwardsDirection(CoordTriplet minCoord, CoordTriplet maxCoord) {
public void recalculateOutwardsDirection(CoordTriplet minCoord,
CoordTriplet maxCoord)
{
outwards = ForgeDirection.UNKNOWN;
position = PartPosition.Unknown;
int facesMatching = 0;
if(maxCoord.x == this.xCoord || minCoord.x == this.xCoord) { facesMatching++; }
if(maxCoord.y == this.yCoord || minCoord.y == this.yCoord) { facesMatching++; }
if(maxCoord.z == this.zCoord || minCoord.z == this.zCoord) { facesMatching++; }
if (maxCoord.x == this.xCoord || minCoord.x == this.xCoord)
{
facesMatching++;
}
if (maxCoord.y == this.yCoord || minCoord.y == this.yCoord)
{
facesMatching++;
}
if (maxCoord.z == this.zCoord || minCoord.z == this.zCoord)
{
facesMatching++;
}
if(facesMatching <= 0) { position = PartPosition.Interior; }
else if(facesMatching >= 3) { position = PartPosition.FrameCorner; }
else if(facesMatching == 2) { position = PartPosition.Frame; }
else {
if (facesMatching <= 0)
{
position = PartPosition.Interior;
} else if (facesMatching >= 3)
{
position = PartPosition.FrameCorner;
} else if (facesMatching == 2)
{
position = PartPosition.Frame;
} else
{
// 1 face matches
if(maxCoord.x == this.xCoord) {
if (maxCoord.x == this.xCoord)
{
position = PartPosition.EastFace;
outwards = ForgeDirection.EAST;
}
else if(minCoord.x == this.xCoord) {
} else if (minCoord.x == this.xCoord)
{
position = PartPosition.WestFace;
outwards = ForgeDirection.WEST;
}
else if(maxCoord.z == this.zCoord) {
} else if (maxCoord.z == this.zCoord)
{
position = PartPosition.SouthFace;
outwards = ForgeDirection.SOUTH;
}
else if(minCoord.z == this.zCoord) {
} else if (minCoord.z == this.zCoord)
{
position = PartPosition.NorthFace;
outwards = ForgeDirection.NORTH;
}
else if(maxCoord.y == this.yCoord) {
} else if (maxCoord.y == this.yCoord)
{
position = PartPosition.TopFace;
outwards = ForgeDirection.UP;
}
else {
} else
{
position = PartPosition.BottomFace;
outwards = ForgeDirection.DOWN;
}
@ -102,5 +127,6 @@ public abstract class RectangularMultiblockTileEntityBase extends
public abstract void isGoodForBottom() throws MultiblockValidationException;
public abstract void isGoodForInterior() throws MultiblockValidationException;
public abstract void isGoodForInterior()
throws MultiblockValidationException;
}

View file

@ -1,15 +1,7 @@
package techreborn;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import erogenousbeef.coreTR.multiblock.MultiblockEventHandler;
import erogenousbeef.coreTR.multiblock.MultiblockServerTickHandler;
import java.io.File;
import net.minecraftforge.common.MinecraftForge;
import techreborn.achievement.TRAchievements;
import techreborn.client.GuiHandler;
@ -25,8 +17,16 @@ import techreborn.packets.PacketHandler;
import techreborn.proxies.CommonProxy;
import techreborn.util.LogHelper;
import techreborn.world.TROreGen;
import java.io.File;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import erogenousbeef.coreTR.multiblock.MultiblockEventHandler;
import erogenousbeef.coreTR.multiblock.MultiblockServerTickHandler;
@Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCUIES, guiFactory = ModInfo.GUI_FACTORY_CLASS)
public class Core {
@ -39,7 +39,8 @@ public class Core {
public static Core INSTANCE;
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent event) {
public void preinit(FMLPreInitializationEvent event)
{
INSTANCE = this;
String path = event.getSuggestedConfigurationFile().getAbsolutePath()
.replace(ModInfo.MOD_ID, "TechReborn");
@ -49,7 +50,8 @@ public class Core {
}
@Mod.EventHandler
public void init(FMLInitializationEvent event) {
public void init(FMLInitializationEvent event)
{
// Register ModBlocks
ModBlocks.init();
// Register ModItems
@ -65,18 +67,22 @@ public class Core {
// Register Gui Handler
NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler());
// packets
PacketHandler.setChannels(NetworkRegistry.INSTANCE.newChannel(ModInfo.MOD_ID + "_packets", new PacketHandler()));
PacketHandler.setChannels(NetworkRegistry.INSTANCE.newChannel(
ModInfo.MOD_ID + "_packets", new PacketHandler()));
// Achievements
TRAchievements.init();
// Multiblock events
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
FMLCommonHandler.instance().bus().register(new MultiblockServerTickHandler());
FMLCommonHandler.instance().bus()
.register(new MultiblockServerTickHandler());
LogHelper.info("Initialization Compleate");
}
@Mod.EventHandler
public void postinit(FMLPostInitializationEvent event)
{
// Has to be done here as buildcraft registers there recipes late
RecipeManager.init();
}

View file

@ -12,19 +12,23 @@ public class AchievementMod extends Achievement{
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);
registerStat();
}
public AchievementMod(String name, int x, int y, Item icon, Achievement parent)
public AchievementMod(String name, int x, int y, Item icon,
Achievement parent)
{
this(name, x, y, new ItemStack(icon), parent);
}
public AchievementMod(String name, int x, int y, Block icon, Achievement parent)
public AchievementMod(String name, int x, int y, Block icon,
Achievement parent)
{
this(name, x, y, new ItemStack(icon), parent);
}

View file

@ -9,19 +9,27 @@ import cpw.mods.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
public class AchievementTriggerer {
@SubscribeEvent
public void onItemPickedUp(ItemPickupEvent event) {
public void onItemPickedUp(ItemPickupEvent event)
{
ItemStack stack = event.pickedUp.getEntityItem();
if(stack != null && stack.getItem() instanceof IPickupAchievement) {
Achievement achievement = ((IPickupAchievement) stack.getItem()).getAchievementOnPickup(stack, event.player, event.pickedUp);
if (stack != null && stack.getItem() instanceof IPickupAchievement)
{
Achievement achievement = ((IPickupAchievement) stack.getItem())
.getAchievementOnPickup(stack, event.player, event.pickedUp);
if (achievement != null)
event.player.addStat(achievement, 1);
}
}
@SubscribeEvent
public void onItemCrafted(ItemCraftedEvent event) {
if(event.crafting != null && event.crafting.getItem() instanceof ICraftAchievement) {
Achievement achievement = ((ICraftAchievement) event.crafting.getItem()).getAchievementOnCraft(event.crafting, event.player, event.craftMatrix);
public void onItemCrafted(ItemCraftedEvent event)
{
if (event.crafting != null
&& event.crafting.getItem() instanceof ICraftAchievement)
{
Achievement achievement = ((ICraftAchievement) event.crafting
.getItem()).getAchievementOnCraft(event.crafting,
event.player, event.craftMatrix);
if (achievement != null)
event.player.addStat(achievement, 1);
}

View file

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

View file

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

View file

@ -1,11 +1,11 @@
package techreborn.achievement;
import cpw.mods.fml.common.FMLCommonHandler;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraftforge.common.AchievementPage;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo;
import cpw.mods.fml.common.FMLCommonHandler;
public class TRAchievements {
@ -18,12 +18,18 @@ public class TRAchievements {
public static void init()
{
ore_PickUp = new AchievementMod("ore_PickUp", 0, 0, new ItemStack(ModBlocks.ore, 1, 0), null);
centrifuge_Craft = new AchievementMod("centrifuge_Craft", 1, 1, ModBlocks.centrifuge, ore_PickUp);
thermalgen_Craft = new AchievementMod("thermalgen_Craft", 2, 1, ModBlocks.thermalGenerator, ore_PickUp);
ore_PickUp = new AchievementMod("ore_PickUp", 0, 0, new ItemStack(
ModBlocks.ore, 1, 0), null);
centrifuge_Craft = new AchievementMod("centrifuge_Craft", 1, 1,
ModBlocks.centrifuge, ore_PickUp);
thermalgen_Craft = new AchievementMod("thermalgen_Craft", 2, 1,
ModBlocks.thermalGenerator, ore_PickUp);
pageIndex = AchievementPage.getAchievementPages().size();
techrebornPage = new AchievementPage(ModInfo.MOD_NAME, AchievementMod.achievements.toArray(new Achievement[AchievementMod.achievements.size()]));
techrebornPage = new AchievementPage(ModInfo.MOD_NAME,
AchievementMod.achievements
.toArray(new Achievement[AchievementMod.achievements
.size()]));
AchievementPage.registerAchievementPage(techrebornPage);
FMLCommonHandler.instance().bus().register(new AchievementTriggerer());

View file

@ -9,7 +9,10 @@ public class CentrifugeRecipie {
int tickTime;
int cells;
public CentrifugeRecipie(ItemStack inputItem, ItemStack output1, ItemStack output2, ItemStack output3, ItemStack output4, int tickTime, int cells) {
public CentrifugeRecipie(ItemStack inputItem, ItemStack output1,
ItemStack output2, ItemStack output3, ItemStack output4,
int tickTime, int cells)
{
this.inputItem = inputItem;
this.output1 = output1;
this.output2 = output2;
@ -19,7 +22,9 @@ public class CentrifugeRecipie {
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,
Item output2, Item output3, Item output4, int tickTime, int cells)
{
this.inputItem = new ItemStack(inputItem, inputAmount);
if (output1 != null)
this.output1 = new ItemStack(output1);
@ -33,7 +38,8 @@ public class CentrifugeRecipie {
this.cells = cells;
}
public CentrifugeRecipie(CentrifugeRecipie centrifugeRecipie) {
public CentrifugeRecipie(CentrifugeRecipie centrifugeRecipie)
{
this.inputItem = centrifugeRecipie.getInputItem();
this.output1 = centrifugeRecipie.getOutput1();
this.output2 = centrifugeRecipie.getOutput2();
@ -43,33 +49,38 @@ public class CentrifugeRecipie {
this.cells = centrifugeRecipie.getCells();
}
public ItemStack getInputItem() {
public ItemStack getInputItem()
{
return inputItem;
}
public ItemStack getOutput1() {
public ItemStack getOutput1()
{
return output1;
}
public ItemStack getOutput2() {
public ItemStack getOutput2()
{
return output2;
}
public ItemStack getOutput3() {
public ItemStack getOutput3()
{
return output3;
}
public ItemStack getOutput4() {
public ItemStack getOutput4()
{
return output4;
}
public int getTickTime() {
public int getTickTime()
{
return tickTime;
}
public int getCells() {
public int getCells()
{
return cells;
}
}

View file

@ -1,5 +1,9 @@
package techreborn.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
@ -9,31 +13,32 @@ import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class RollingMachineRecipe {
private final List<IRecipe> recipes = new ArrayList<IRecipe>();
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;
int j = 0;
int k = 0;
if(components[i] instanceof String[]) {
if (components[i] instanceof String[])
{
String as[] = (String[]) components[i++];
for(int l = 0; l < as.length; l++) {
for (int l = 0; l < as.length; l++)
{
String s2 = as[l];
k++;
j = s2.length();
s = (new StringBuilder()).append(s).append(s2).toString();
}
} else {
while(components[i] instanceof String) {
} else
{
while (components[i] instanceof String)
{
String s1 = (String) components[i++];
k++;
j = s1.length();
@ -41,25 +46,33 @@ public class RollingMachineRecipe {
}
}
HashMap hashmap = new HashMap();
for(; i < components.length; i += 2) {
for (; i < components.length; i += 2)
{
Character character = (Character) components[i];
ItemStack itemstack1 = null;
if(components[i + 1] instanceof Item) {
if (components[i + 1] instanceof Item)
{
itemstack1 = new ItemStack((Item) components[i + 1]);
} else if(components[i + 1] instanceof Block) {
} else if (components[i + 1] instanceof Block)
{
itemstack1 = new ItemStack((Block) components[i + 1], 1, -1);
} else if(components[i + 1] instanceof ItemStack) {
} else if (components[i + 1] instanceof ItemStack)
{
itemstack1 = (ItemStack) components[i + 1];
}
hashmap.put(character, itemstack1);
}
ItemStack recipeArray[] = new ItemStack[j * k];
for(int i1 = 0; i1 < j * k; i1++) {
for (int i1 = 0; i1 < j * k; i1++)
{
char c = s.charAt(i1);
if(hashmap.containsKey(Character.valueOf(c))) {
recipeArray[i1] = ((ItemStack)hashmap.get(Character.valueOf(c))).copy();
} else {
if (hashmap.containsKey(Character.valueOf(c)))
{
recipeArray[i1] = ((ItemStack) hashmap
.get(Character.valueOf(c))).copy();
} else
{
recipeArray[i1] = null;
}
}
@ -67,21 +80,27 @@ public class RollingMachineRecipe {
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++) {
for (int j = 0; j < components.length; j++)
{
Object obj = components[j];
if(obj instanceof ItemStack) {
if (obj instanceof ItemStack)
{
ingredients.add(((ItemStack) obj).copy());
continue;
}
if(obj instanceof Item) {
if (obj instanceof Item)
{
ingredients.add(new ItemStack((Item) obj));
continue;
}
if(obj instanceof Block) {
if (obj instanceof Block)
{
ingredients.add(new ItemStack((Block) obj));
} else {
} else
{
throw new RuntimeException("Invalid shapeless recipe!");
}
}
@ -89,11 +108,13 @@ public class RollingMachineRecipe {
recipes.add(new ShapelessRecipes(output, ingredients));
}
public ItemStack findMatchingRecipe(InventoryCrafting inv, World world) {
for(int k = 0; k < recipes.size(); k++) {
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)) {
if (irecipe.matches(inv, world))
{
return irecipe.getCraftingResult(inv);
}
}
@ -101,12 +122,9 @@ public class RollingMachineRecipe {
return null;
}
public List<IRecipe> getRecipeList() {
public List<IRecipe> getRecipeList()
{
return recipes;
}
}

View file

@ -1,23 +1,32 @@
package techreborn.api;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import techreborn.util.ItemUtils;
import java.util.ArrayList;
public final class TechRebornAPI {
public static ArrayList<CentrifugeRecipie> centrifugeRecipies = new ArrayList<CentrifugeRecipie>();
public static ArrayList<RollingMachineRecipe> rollingmachineRecipes = new ArrayList<RollingMachineRecipe>();
public static void registerCentrifugeRecipe(CentrifugeRecipie recipie) {
public static void registerCentrifugeRecipe(CentrifugeRecipie recipie)
{
boolean shouldAdd = true;
for (CentrifugeRecipie centrifugeRecipie : centrifugeRecipies) {
if (ItemUtils.isItemEqual(centrifugeRecipie.getInputItem(), recipie.getInputItem(), false, true)) {
try {
throw new RegisteredItemRecipe("Item " + recipie.getInputItem().getUnlocalizedName() + " is already being used in a recipe for the Centrifuge");
} catch (RegisteredItemRecipe registeredItemRecipe) {
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;
}
@ -27,19 +36,23 @@ public final class TechRebornAPI {
centrifugeRecipies.add(recipie);
}
public static void addRollingMachinceRecipe(ItemStack output, Object... components) {
public static void addRollingMachinceRecipe(ItemStack output,
Object... components)
{
RollingMachineRecipe.instance.addRecipe(output, components);
}
public void addShapelessRollingMachinceRecipe(ItemStack output, Object... components) {
public void addShapelessRollingMachinceRecipe(ItemStack output,
Object... components)
{
RollingMachineRecipe.instance.addShapelessRecipe(output, components);
}
}
class RegisteredItemRecipe extends Exception {
public RegisteredItemRecipe(String message) {
public RegisteredItemRecipe(String 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;

View file

@ -1,7 +1,5 @@
package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -19,6 +17,8 @@ import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileMachineCasing;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBlastFurnace extends BlockContainer {
@ -40,51 +40,69 @@ public class BlockBlastFurnace extends BlockContainer{
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
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) {
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);
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) {
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.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) {
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));
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
}
public void onBlockAdded(World world, int x, int y, int z) {
public void onBlockAdded(World world, int x, int y, int z)
{
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
}
private void setDefaultDirection(World world, int x, int y, int z) {
private void setDefaultDirection(World world, int x, int y, int z)
{
if(!world.isRemote) {
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);
@ -92,16 +110,20 @@ public class BlockBlastFurnace extends BlockContainer{
byte b = 3;
if(block1.func_149730_j() && !block2.func_149730_j()) {
if (block1.func_149730_j() && !block2.func_149730_j())
{
b = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j()) {
if (block2.func_149730_j() && !block1.func_149730_j())
{
b = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j()) {
if (block3.func_149730_j() && !block4.func_149730_j())
{
b = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j()) {
if (block4.func_149730_j() && !block3.func_149730_j())
{
b = 4;
}
@ -111,20 +133,27 @@ public class BlockBlastFurnace extends BlockContainer{
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
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;
int l = MathHelper
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
if(l == 0) {
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(l == 1) {
if (l == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(l == 2) {
if (l == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(l == 3) {
if (l == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}

View file

@ -1,7 +1,5 @@
package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -16,6 +14,8 @@ import net.minecraft.world.World;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.tiles.TileCentrifuge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCentrifuge extends BlockContainer {
@ -28,49 +28,63 @@ public class BlockCentrifuge extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockCentrifuge() {
public BlockCentrifuge()
{
super(Material.piston);
setHardness(2F);
}
@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 TileCentrifuge();
}
@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,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.centrifugeID, world, x, y, z);
player.openGui(Core.INSTANCE, GuiHandler.centrifugeID, world, x, y,
z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) {
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.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) {
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));
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
}
public void onBlockAdded(World world, int x, int y, int z) {
public void onBlockAdded(World world, int x, int y, int z)
{
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
}
private void setDefaultDirection(World world, int x, int y, int z) {
private void setDefaultDirection(World world, int x, int y, int z)
{
if(!world.isRemote) {
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);
@ -78,16 +92,20 @@ public class BlockCentrifuge extends BlockContainer {
byte b = 3;
if(block1.func_149730_j() && !block2.func_149730_j()) {
if (block1.func_149730_j() && !block2.func_149730_j())
{
b = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j()) {
if (block2.func_149730_j() && !block1.func_149730_j())
{
b = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j()) {
if (block3.func_149730_j() && !block4.func_149730_j())
{
b = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j()) {
if (block4.func_149730_j() && !block3.func_149730_j())
{
b = 4;
}
@ -97,20 +115,27 @@ public class BlockCentrifuge extends BlockContainer {
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
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;
int l = MathHelper
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
if(l == 0) {
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(l == 1) {
if (l == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(l == 2) {
if (l == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(l == 3) {
if (l == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}

View file

@ -1,8 +1,8 @@
package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import erogenousbeef.coreTR.multiblock.BlockMultiblockBase;
import java.util.List;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@ -15,13 +15,14 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileMachineCasing;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import erogenousbeef.coreTR.multiblock.BlockMultiblockBase;
public class BlockMachineCasing extends BlockMultiblockBase {
public static final String[] types = new String[] {"Standard", "Reinforced", "Advanced"};
public static final String[] types = new String[]
{ "Standard", "Reinforced", "Advanced" };
private IIcon[] textures;
public BlockMachineCasing(Material material)
@ -33,49 +34,60 @@ public class BlockMachineCasing extends BlockMultiblockBase {
}
@Override
public Item getItemDropped(int meta, Random random, int fortune) {
public Item getItemDropped(int meta, Random random, int fortune)
{
return Item.getItemFromBlock(this);
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
for (int meta = 0; meta < types.length; meta++) {
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list)
{
for (int meta = 0; meta < types.length; meta++)
{
list.add(new ItemStack(item, 1, meta));
}
}
@Override
public int damageDropped(int metaData) {
public int damageDropped(int metaData)
{
// TODO RubyOre Returns Rubys
return metaData;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
public void registerBlockIcons(IIconRegister iconRegister)
{
this.textures = new IIcon[types.length];
for (int i = 0; i < types.length; i++) {
textures[i] = iconRegister.registerIcon("techreborn:" + "machine/casing" + types[i]);
for (int i = 0; i < types.length; i++)
{
textures[i] = iconRegister.registerIcon("techreborn:"
+ "machine/casing" + types[i]);
}
}
@Override
@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);
if (ForgeDirection.getOrientation(side) == ForgeDirection.UP
|| ForgeDirection.getOrientation(side) == ForgeDirection.DOWN) {
|| ForgeDirection.getOrientation(side) == ForgeDirection.DOWN)
{
return textures[metaData];
} else {
} else
{
return textures[metaData];
}
}
@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 TileMachineCasing();
}
}

View file

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

View file

@ -1,7 +1,5 @@
package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@ -12,7 +10,8 @@ import net.minecraft.world.World;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.tiles.TileQuantumChest;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuantumChest extends BlockContainer {
@ -21,37 +20,46 @@ public class BlockQuantumChest extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon other;
public BlockQuantumChest() {
public BlockQuantumChest()
{
super(Material.piston);
setHardness(2f);
}
@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();
}
@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,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.quantumChestID, world, x, y, z);
player.openGui(Core.INSTANCE, GuiHandler.quantumChestID, world, x,
y, z);
return true;
}
@Override
@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");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int currentSide, int meta) {
public IIcon getIcon(int currentSide, int meta)
{
// TODO chest rotation
if (currentSide == 1) {
if (currentSide == 1)
{
return top;
} else {
} else
{
return other;
}
}

View file

@ -1,7 +1,5 @@
package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@ -12,6 +10,8 @@ import net.minecraft.world.World;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.tiles.TileQuantumTank;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockQuantumTank extends BlockContainer {
@ -20,36 +20,45 @@ public class BlockQuantumTank extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon other;
public BlockQuantumTank() {
public BlockQuantumTank()
{
super(Material.piston);
setHardness(2f);
}
@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();
}
@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,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.quantumTankID, world, x, y, z);
player.openGui(Core.INSTANCE, GuiHandler.quantumTankID, world, x,
y, z);
return true;
}
@Override
@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");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int currentSide, int meta) {
if (currentSide == 1) {
public IIcon getIcon(int currentSide, int meta)
{
if (currentSide == 1)
{
return top;
} else {
} else
{
return other;
}
}

View file

@ -1,7 +1,5 @@
package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -17,6 +15,8 @@ import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileRollingMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockRollingMachine extends BlockContainer {
@ -29,7 +29,8 @@ public class BlockRollingMachine extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockRollingMachine(Material material) {
public BlockRollingMachine(Material material)
{
super(material.piston);
setCreativeTab(TechRebornCreativeTab.instance);
setBlockName("techreborn.rollingmachine");
@ -37,43 +38,55 @@ public class BlockRollingMachine extends BlockContainer {
}
@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();
}
@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,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.rollingMachineID, world, x, y, z);
player.openGui(Core.INSTANCE, GuiHandler.rollingMachineID, world,
x, y, z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) {
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.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 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));
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
}
public void onBlockAdded(World world, int x, int y, int z) {
public void onBlockAdded(World world, int x, int y, int z)
{
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
}
private void setDefaultDirection(World world, int x, int y, int z) {
private void setDefaultDirection(World world, int x, int y, int z)
{
if(!world.isRemote) {
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);
@ -81,16 +94,20 @@ public class BlockRollingMachine extends BlockContainer {
byte b = 3;
if(block1.func_149730_j() && !block2.func_149730_j()) {
if (block1.func_149730_j() && !block2.func_149730_j())
{
b = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j()) {
if (block2.func_149730_j() && !block1.func_149730_j())
{
b = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j()) {
if (block3.func_149730_j() && !block4.func_149730_j())
{
b = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j()) {
if (block4.func_149730_j() && !block3.func_149730_j())
{
b = 4;
}
@ -100,20 +117,27 @@ public class BlockRollingMachine extends BlockContainer {
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
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;
int l = MathHelper
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
if(l == 0) {
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(l == 1) {
if (l == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(l == 2) {
if (l == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(l == 3) {
if (l == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}

View file

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

View file

@ -1,7 +1,7 @@
package techreborn.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -18,9 +18,8 @@ import net.minecraft.world.World;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.tiles.TileThermalGenerator;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockThermalGenerator extends BlockContainer {
@ -33,37 +32,46 @@ public class BlockThermalGenerator extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockThermalGenerator() {
public BlockThermalGenerator()
{
super(Material.piston);
setHardness(2f);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) {
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.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 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));
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
}
public void onBlockAdded(World world, int x, int y, int z) {
public void onBlockAdded(World world, int x, int y, int z)
{
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
}
private void setDefaultDirection(World world, int x, int y, int z) {
private void setDefaultDirection(World world, int x, int y, int z)
{
if(!world.isRemote) {
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);
@ -71,16 +79,20 @@ public class BlockThermalGenerator extends BlockContainer {
byte b = 3;
if(block1.func_149730_j() && !block2.func_149730_j()) {
if (block1.func_149730_j() && !block2.func_149730_j())
{
b = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j()) {
if (block2.func_149730_j() && !block1.func_149730_j())
{
b = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j()) {
if (block3.func_149730_j() && !block4.func_149730_j())
{
b = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j()) {
if (block4.func_149730_j() && !block3.func_149730_j())
{
b = 4;
}
@ -90,40 +102,52 @@ public class BlockThermalGenerator extends BlockContainer {
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
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;
int l = MathHelper
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
if(l == 0) {
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(l == 1) {
if (l == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(l == 2) {
if (l == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(l == 3) {
if (l == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
@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 TileThermalGenerator();
}
@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,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.thermalGeneratorID, world, x, y, z);
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_) {
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,13 +1,27 @@
package techreborn.client;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import techreborn.client.container.*;
import techreborn.client.gui.*;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.client.container.ContainerQuantumChest;
import techreborn.client.container.ContainerQuantumTank;
import techreborn.client.container.ContainerRollingMachine;
import techreborn.client.container.ContainerThermalGenerator;
import techreborn.client.gui.GuiBlastFurnace;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.client.gui.GuiQuantumChest;
import techreborn.client.gui.GuiQuantumTank;
import techreborn.client.gui.GuiRollingMachine;
import techreborn.client.gui.GuiThermalGenerator;
import techreborn.pda.GuiPda;
import techreborn.tiles.*;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
import techreborn.tiles.TileQuantumChest;
import techreborn.tiles.TileQuantumTank;
import techreborn.tiles.TileRollingMachine;
import techreborn.tiles.TileThermalGenerator;
import cpw.mods.fml.common.network.IGuiHandler;
public class GuiHandler implements IGuiHandler {
@ -19,22 +33,36 @@ public class GuiHandler implements IGuiHandler {
public static final int blastFurnaceID = 5;
public static final int pdaID = 6;
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == thermalGeneratorID) {
return new ContainerThermalGenerator((TileThermalGenerator) world.getTileEntity(x, y, z), player);
} else if (ID == quantumTankID) {
return new ContainerQuantumTank((TileQuantumTank) world.getTileEntity(x, y, z), player);
} else if (ID == quantumChestID) {
return new ContainerQuantumChest((TileQuantumChest) world.getTileEntity(x, y, z), player);
} else if (ID == centrifugeID) {
return new ContainerCentrifuge((TileCentrifuge) world.getTileEntity(x, y, z), player);
} else if (ID == rollingMachineID) {
return new ContainerRollingMachine((TileRollingMachine) world.getTileEntity(x, y, z), player);
} else if (ID == blastFurnaceID) {
return new ContainerBlastFurnace((TileBlastFurnace) world.getTileEntity(x, y, z), player);
} else if (ID == pdaID) {
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;
}
@ -42,20 +70,35 @@ public class GuiHandler implements IGuiHandler {
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == thermalGeneratorID) {
return new GuiThermalGenerator(player, (TileThermalGenerator) world.getTileEntity(x, y, z));
} else if (ID == quantumTankID) {
return new GuiQuantumTank(player, (TileQuantumTank) world.getTileEntity(x, y, z));
} else if (ID == quantumChestID) {
return new GuiQuantumChest(player, (TileQuantumChest) world.getTileEntity(x, y, z));
} else if (ID == centrifugeID) {
return new GuiCentrifuge(player, (TileCentrifuge) world.getTileEntity(x, y, z));
} else if (ID == rollingMachineID) {
return new GuiRollingMachine(player, (TileRollingMachine) world.getTileEntity(x, y, z));
} else if (ID == blastFurnaceID) {
return new GuiBlastFurnace(player, (TileBlastFurnace) world.getTileEntity(x, y, z));
} else if (ID == pdaID) {
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z)
{
if (ID == thermalGeneratorID)
{
return new GuiThermalGenerator(player,
(TileThermalGenerator) world.getTileEntity(x, y, z));
} else if (ID == quantumTankID)
{
return new GuiQuantumTank(player,
(TileQuantumTank) world.getTileEntity(x, y, z));
} else if (ID == quantumChestID)
{
return new GuiQuantumChest(player,
(TileQuantumChest) world.getTileEntity(x, y, z));
} else if (ID == centrifugeID)
{
return new GuiCentrifuge(player,
(TileCentrifuge) world.getTileEntity(x, y, z));
} else if (ID == rollingMachineID)
{
return new GuiRollingMachine(player,
(TileRollingMachine) world.getTileEntity(x, y, z));
} else if (ID == blastFurnaceID)
{
return new GuiBlastFurnace(player,
(TileBlastFurnace) world.getTileEntity(x, y, z));
} else if (ID == pdaID)
{
return new GuiPda(player);
}
return null;

View file

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

View file

@ -6,15 +6,18 @@ import net.minecraft.item.ItemStack;
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);
}
public boolean isItemValid(ItemStack par1ItemStack) {
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
public int getSlotStackLimit() {
public int getSlotStackLimit()
{
return 64;
}
}

View file

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

View file

@ -1,11 +1,9 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import techreborn.client.SlotOutput;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
public class ContainerBlastFurnace extends TechRebornContainer {
@ -21,7 +19,9 @@ public class ContainerBlastFurnace extends TechRebornContainer {
public int tickTime;
public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace, EntityPlayer player) {
public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace,
EntityPlayer player)
{
tile = tileblastfurnace;
this.player = player;
@ -29,19 +29,24 @@ public class ContainerBlastFurnace extends TechRebornContainer {
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 0, 56, 25));
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 1, 56, 43));
// outputs
this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2, 116, 35));
this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2,
116, 35));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}

View file

@ -14,7 +14,9 @@ public class ContainerCentrifuge extends TechRebornContainer {
public int tickTime;
public ContainerCentrifuge(TileCentrifuge tileCentrifuge, EntityPlayer player) {
public ContainerCentrifuge(TileCentrifuge tileCentrifuge,
EntityPlayer player)
{
tile = tileCentrifuge;
this.player = player;
@ -23,31 +25,42 @@ public class ContainerCentrifuge extends TechRebornContainer {
// cells
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 1, 50, 5));
// outputs
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80, 5));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3, 110, 35));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 4, 80, 65));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 5, 50, 35));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80,
5));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3,
110, 35));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 4, 80,
65));
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 5, 50,
35));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
@Override
public void addCraftingToCrafters(ICrafting crafting) {
public void addCraftingToCrafters(ICrafting crafting)
{
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, tile.tickTime);
}
@ -55,11 +68,14 @@ public class ContainerCentrifuge extends TechRebornContainer {
/**
* 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) {
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting) this.crafters.get(i);
if (this.tickTime != this.tile.tickTime) {
if (this.tickTime != this.tile.tickTime)
{
icrafting.sendProgressBarUpdate(this, 0, this.tile.tickTime);
}
}

View file

@ -10,30 +10,40 @@ public class ContainerQuantumChest extends TechRebornContainer {
public TileQuantumChest tileQuantumChest;
public EntityPlayer player;
public ContainerQuantumChest(TileQuantumChest tileQuantumChest, EntityPlayer player) {
public ContainerQuantumChest(TileQuantumChest tileQuantumChest,
EntityPlayer player)
{
super();
this.tileQuantumChest = tileQuantumChest;
this.player = player;
this.addSlotToContainer(new Slot(tileQuantumChest.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1, 80, 53));
this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59, 42, false, false, Integer.MAX_VALUE));
this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1,
80, 53));
this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59,
42, false, false, Integer.MAX_VALUE));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
public boolean canInteractWith(EntityPlayer player)
{
return true;
}

View file

@ -10,30 +10,40 @@ public class ContainerQuantumTank extends TechRebornContainer {
public TileQuantumTank tileQuantumTank;
public EntityPlayer player;
public ContainerQuantumTank(TileQuantumTank tileQuantumTank, EntityPlayer player) {
public ContainerQuantumTank(TileQuantumTank tileQuantumTank,
EntityPlayer player)
{
super();
this.tileQuantumTank = tileQuantumTank;
this.player = player;
this.addSlotToContainer(new Slot(tileQuantumTank.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1, 80, 53));
this.addSlotToContainer(new SlotFake(tileQuantumTank.inventory, 2, 59, 42, false, false, 1));
this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1,
80, 53));
this.addSlotToContainer(new SlotFake(tileQuantumTank.inventory, 2, 59,
42, false, false, 1));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
}

View file

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

View file

@ -10,30 +10,41 @@ public class ContainerThermalGenerator extends TechRebornContainer {
public TileThermalGenerator tileThermalGenerator;
public EntityPlayer player;
public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator, EntityPlayer player) {
public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator,
EntityPlayer player)
{
super();
this.tileThermalGenerator = tileThermalGenerator;
this.player = player;
this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80, 17));
this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory, 1, 80, 53));
this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2, 59, 42, false, false, 1));
this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80,
17));
this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory,
1, 80, 53));
this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2,
59, 42, false, false, 1));
int i;
for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
+ 9, 8 + j * 18, 84 + i * 18));
}
}
for (i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
for (i = 0; i < 9; ++i)
{
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
142));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
public boolean canInteractWith(EntityPlayer player)
{
return true;
}
}

View file

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

View file

@ -5,17 +5,18 @@ import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import techreborn.client.container.ContainerBlastFurnace;
import techreborn.client.container.ContainerCentrifuge;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
public class GuiBlastFurnace extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/industrial_blast_furnace.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/industrial_blast_furnace.png");
TileBlastFurnace blastfurnace;
public GuiBlastFurnace(EntityPlayer player, TileBlastFurnace tileblastfurnace) {
public GuiBlastFurnace(EntityPlayer player,
TileBlastFurnace tileblastfurnace)
{
super(new ContainerBlastFurnace(tileblastfurnace, player));
this.xSize = 176;
this.ySize = 167;
@ -23,15 +24,21 @@ public class GuiBlastFurnace extends GuiContainer {
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Blastfurnace", 60, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
}
}

View file

@ -9,11 +9,13 @@ import techreborn.tiles.TileCentrifuge;
public class GuiCentrifuge extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/centrifuge.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/centrifuge.png");
TileCentrifuge centrifuge;
public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge) {
public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge)
{
super(new ContainerCentrifuge(tileCentrifuge, player));
this.xSize = 176;
this.ySize = 167;
@ -21,16 +23,23 @@ public class GuiCentrifuge extends GuiContainer {
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Centrifuge", 110, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(centrifuge.tickTime + " " + centrifuge.isRunning, 110, this.ySize - 96 + 2, 4210752);
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;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
@ -10,11 +9,13 @@ import techreborn.tiles.TileQuantumChest;
public class GuiQuantumChest extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/ThermalGenerator.png");
TileQuantumChest tile;
public GuiQuantumChest(EntityPlayer player, TileQuantumChest tile) {
public GuiQuantumChest(EntityPlayer player, TileQuantumChest tile)
{
super(new ContainerQuantumChest(tile, player));
this.xSize = 176;
this.ySize = 167;
@ -22,19 +23,25 @@ public class GuiQuantumChest extends GuiContainer {
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Quantum Chest", 8, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(
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);
this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10,
30, 16448255);
}
}

View file

@ -9,11 +9,13 @@ import techreborn.tiles.TileQuantumTank;
public class GuiQuantumTank extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/ThermalGenerator.png");
TileQuantumTank tile;
public GuiQuantumTank(EntityPlayer player, TileQuantumTank tile) {
public GuiQuantumTank(EntityPlayer player, TileQuantumTank tile)
{
super(new ContainerQuantumTank(tile, player));
this.xSize = 176;
this.ySize = 167;
@ -21,18 +23,24 @@ public class GuiQuantumTank extends GuiContainer {
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Quantum Tank", 8, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(
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);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10,
30, 16448255);
}
}

View file

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

View file

@ -9,11 +9,13 @@ import techreborn.tiles.TileThermalGenerator;
public class GuiThermalGenerator extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/ThermalGenerator.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/ThermalGenerator.png");
TileThermalGenerator tile;
public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile) {
public GuiThermalGenerator(EntityPlayer player, TileThermalGenerator tile)
{
super(new ContainerThermalGenerator(tile, player));
this.xSize = 176;
this.ySize = 167;
@ -21,17 +23,24 @@ public class GuiThermalGenerator extends GuiContainer {
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Thermal Generator", 8, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(
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);
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10,
30, 16448255);
}
}

View file

@ -1,8 +1,8 @@
package techreborn.compat;
import techreborn.compat.waila.CompatModuleWaila;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import techreborn.compat.waila.CompatModuleWaila;
public class CompatManager {

View file

@ -1,22 +1,25 @@
package techreborn.compat.nei;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
import ic2.api.item.IC2Items;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import techreborn.api.CentrifugeRecipie;
import techreborn.api.TechRebornAPI;
import techreborn.client.gui.GuiCentrifuge;
import techreborn.config.ConfigTechReborn;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.TemplateRecipeHandler;
public class CentrifugeRecipeHandler extends TemplateRecipeHandler {
@ -27,130 +30,176 @@ public class CentrifugeRecipeHandler extends TemplateRecipeHandler {
public Point focus;
public CentrifugeRecipie centrifugeRecipie;
public CachedCentrifugeRecipe(CentrifugeRecipie recipie) {
public CachedCentrifugeRecipe(CentrifugeRecipie recipie)
{
this.centrifugeRecipie = recipie;
int offset = 4;
PositionedStack pStack = new PositionedStack(recipie.getInputItem(), 80 - offset, 35 - offset);
PositionedStack pStack = new PositionedStack(
recipie.getInputItem(), 80 - offset, 35 - offset);
pStack.setMaxSize(1);
this.input.add(pStack);
if (recipie.getOutput1() != null) {
this.outputs.add(new PositionedStack(recipie.getOutput1(), 80 - offset, 5 - offset));
if (recipie.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.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.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));
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));
this.outputs.add(new PositionedStack(cellStack, 50 - offset,
5 - offset));
}
@Override
public List<PositionedStack> getIngredients() {
public List<PositionedStack> getIngredients()
{
return this.getCycledIngredients(cycleticks / 20, this.input);
}
@Override
public List<PositionedStack> getOtherStacks() {
public List<PositionedStack> getOtherStacks()
{
return this.outputs;
}
@Override
public PositionedStack getResult() {
public PositionedStack getResult()
{
return null;
}
}
@Override
public String getRecipeName() {
public String getRecipeName()
{
return "Centrifuge";
}
@Override
public String getGuiTexture() {
public String getGuiTexture()
{
return "techreborn:textures/gui/centrifuge.png";
}
@Override
public Class<? extends GuiContainer> getGuiClass() {
public Class<? extends GuiContainer> getGuiClass()
{
return GuiCentrifuge.class;
}
@Override
public void drawBackground(int recipeIndex) {
public void drawBackground(int recipeIndex)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GuiDraw.changeTexture(getGuiTexture());
GuiDraw.drawTexturedModalRect(0, 0, 4, 4, 166, 78);
GuiDraw.drawTooltipBox(10, 80, 145, 50);
GuiDraw.drawString("Info:", 14, 84, -1);
CachedRecipe recipe = arecipes.get(recipeIndex);
if (recipe instanceof CachedCentrifugeRecipe) {
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);
GuiDraw.drawString(
"EU needed: "
+ (ConfigTechReborn.CentrifugeInputTick * centrifugeRecipie.centrifugeRecipie
.getTickTime()), 14, 94, -1);
GuiDraw.drawString("Ticks to smelt: "
+ centrifugeRecipie.centrifugeRecipie.getTickTime(), 14,
104, -1);
GuiDraw.drawString("Time to smelt: "
+ centrifugeRecipie.centrifugeRecipie.getTickTime() / 20
+ " seconds", 14, 114, -1);
}
}
@Override
public int recipiesPerPage() {
public int recipiesPerPage()
{
return 1;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(75, 22, 15, 13), "tr.centrifuge", new Object[0]));
public void loadTransferRects()
{
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
new Rectangle(75, 22, 15, 13), "tr.centrifuge", new Object[0]));
}
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("tr.centrifuge")) {
for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) {
public void loadCraftingRecipes(String outputId, Object... results)
{
if (outputId.equals("tr.centrifuge"))
{
for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies)
{
addCached(centrifugeRecipie);
}
} else {
} else
{
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies) {
if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getOutput1(), result)) {
public void loadCraftingRecipes(ItemStack result)
{
for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies)
{
if (NEIServerUtils.areStacksSameTypeCrafting(
centrifugeRecipie.getOutput1(), result))
{
addCached(centrifugeRecipie);
}
if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getOutput2(), result)) {
if (NEIServerUtils.areStacksSameTypeCrafting(
centrifugeRecipie.getOutput2(), result))
{
addCached(centrifugeRecipie);
}
if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getOutput3(), result)) {
if (NEIServerUtils.areStacksSameTypeCrafting(
centrifugeRecipie.getOutput3(), result))
{
addCached(centrifugeRecipie);
}
if (NEIServerUtils.areStacksSameTypeCrafting(centrifugeRecipie.getOutput4(), result)) {
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)) {
public void loadUsageRecipes(ItemStack ingredient)
{
for (CentrifugeRecipie centrifugeRecipie : TechRebornAPI.centrifugeRecipies)
{
if (NEIServerUtils.areStacksSameTypeCrafting(
centrifugeRecipie.getInputItem(), ingredient))
{
addCached(centrifugeRecipie);
}
}
}
private void addCached(CentrifugeRecipie recipie) {
private void addCached(CentrifugeRecipie recipie)
{
this.arecipes.add(new CachedCentrifugeRecipe(recipie));
}

View file

@ -1,23 +1,26 @@
package techreborn.compat.nei;
import techreborn.lib.ModInfo;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
import techreborn.lib.ModInfo;
public class NEIConfig implements IConfigureNEI {
@Override
public String getName() {
public String getName()
{
return ModInfo.MOD_ID;
}
@Override
public String getVersion() {
public String getVersion()
{
return ModInfo.MOD_VERSION;
}
@Override
public void loadConfig() {
public void loadConfig()
{
CentrifugeRecipeHandler centrifugeRecipeHandler = new CentrifugeRecipeHandler();
ShapedRollingMachineHandler shapedRollingMachineHandler = new ShapedRollingMachineHandler();
ShapelessRollingMachineHandler shapelessRollingMachineHandler = new 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
package techreborn.compat.nei;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.recipe.ShapedRecipeHandler;
import java.awt.Rectangle;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
@ -10,36 +11,45 @@ import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraftforge.oredict.ShapedOreRecipe;
import techreborn.api.RollingMachineRecipe;
import techreborn.client.gui.GuiRollingMachine;
import java.awt.*;
import java.util.List;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.recipe.ShapedRecipeHandler;
public class ShapedRollingMachineHandler extends ShapedRecipeHandler {
@Override
public Class<? extends GuiContainer> getGuiClass() {
public Class<? extends GuiContainer> getGuiClass()
{
return GuiRollingMachine.class;
}
@Override
public void loadTransferRects() {
this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "rollingcrafting", new Object[0]));
public void loadTransferRects()
{
this.transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24,
18), "rollingcrafting", new Object[0]));
}
@Override
public String getRecipeName() {
public String getRecipeName()
{
return "rollingcrafting";
}
@Override
public String getOverlayIdentifier() {
public String getOverlayIdentifier()
{
return "rollingcrafting";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("rollingcrafting") && getClass() == ShapedRollingMachineHandler.class) {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance.getRecipeList()) {
public void loadCraftingRecipes(String outputId, Object... results)
{
if (outputId.equals("rollingcrafting")
&& getClass() == ShapedRollingMachineHandler.class)
{
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance
.getRecipeList())
{
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
@ -52,15 +62,21 @@ public class ShapedRollingMachineHandler extends ShapedRecipeHandler {
recipe.computeVisuals();
arecipes.add(recipe);
}
} else {
} else
{
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance.getRecipeList()) {
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
public void loadCraftingRecipes(ItemStack result)
{
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance
.getRecipeList())
{
if (NEIServerUtils.areStacksSameTypeCrafting(
irecipe.getRecipeOutput(), result))
{
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
@ -77,19 +93,25 @@ public class ShapedRollingMachineHandler extends ShapedRecipeHandler {
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance.getRecipeList()) {
public void loadUsageRecipes(ItemStack ingredient)
{
for (IRecipe irecipe : (List<IRecipe>) RollingMachineRecipe.instance
.getRecipeList())
{
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem()))
if (recipe == null
|| !recipe.contains(recipe.ingredients,
ingredient.getItem()))
continue;
recipe.computeVisuals();
if (recipe.contains(recipe.ingredients, ingredient)) {
if (recipe.contains(recipe.ingredients, ingredient))
{
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
package techreborn.compat.nei;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.recipe.ShapelessRecipeHandler;
import java.awt.Rectangle;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
@ -10,36 +11,45 @@ import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import techreborn.api.RollingMachineRecipe;
import techreborn.client.gui.GuiRollingMachine;
import java.awt.*;
import java.util.List;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.recipe.ShapelessRecipeHandler;
public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler {
@Override
public Class<? extends GuiContainer> getGuiClass() {
public Class<? extends GuiContainer> getGuiClass()
{
return GuiRollingMachine.class;
}
public String getRecipeName() {
public String getRecipeName()
{
return "Shapeless Rolling Machine";
}
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "rollingcraftingnoshape"));
public void loadTransferRects()
{
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18),
"rollingcraftingnoshape"));
}
@Override
public String getOverlayIdentifier() {
public String getOverlayIdentifier()
{
return "rollingcraftingnoshape";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("rollingcraftingnoshape") && getClass() == ShapelessRollingMachineHandler.class) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList();
for (IRecipe irecipe : allrecipes) {
public void loadCraftingRecipes(String outputId, Object... results)
{
if (outputId.equals("rollingcraftingnoshape")
&& getClass() == ShapelessRollingMachineHandler.class)
{
List<IRecipe> allrecipes = RollingMachineRecipe.instance
.getRecipeList();
for (IRecipe irecipe : allrecipes)
{
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
@ -51,16 +61,22 @@ public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler {
arecipes.add(recipe);
}
} else {
} else
{
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList();
for (IRecipe irecipe : allrecipes) {
if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
public void loadCraftingRecipes(ItemStack result)
{
List<IRecipe> allrecipes = RollingMachineRecipe.instance
.getRecipeList();
for (IRecipe irecipe : allrecipes)
{
if (NEIServerUtils.areStacksSameTypeCrafting(
irecipe.getRecipeOutput(), result))
{
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
@ -76,9 +92,12 @@ public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler {
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList();
for (IRecipe irecipe : allrecipes) {
public void loadUsageRecipes(ItemStack ingredient)
{
List<IRecipe> allrecipes = RollingMachineRecipe.instance
.getRecipeList();
for (IRecipe irecipe : allrecipes)
{
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
@ -88,17 +107,20 @@ public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler {
if (recipe == null)
continue;
if (recipe.contains(recipe.ingredients, ingredient)) {
if (recipe.contains(recipe.ingredients, ingredient))
{
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) {
private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe)
{
if (recipe.recipeItems == null)
return null;
return new CachedShapelessRecipe(recipe.recipeItems, recipe.getRecipeOutput());
return new CachedShapelessRecipe(recipe.recipeItems,
recipe.getRecipeOutput());
}
}

View file

@ -1,8 +1,6 @@
package techreborn.compat.recipes;
import techreborn.compat.waila.CompatModuleWaila;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
public class RecipeManager {

View file

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

View file

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

View file

@ -1,5 +1,8 @@
package techreborn.compat.waila;
import java.util.ArrayList;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
@ -10,15 +13,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import techreborn.tiles.TileMachineBase;
import java.util.ArrayList;
import java.util.List;
public class WailaProviderMachines implements IWailaDataProvider {
private List<String> info = new ArrayList<String>();
@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();
@ -30,25 +32,33 @@ public class WailaProviderMachines implements IWailaDataProvider {
}
@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;
}
@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;
}
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
public ItemStack getWailaStack(IWailaDataAccessor accessor,
IWailaConfigHandler config)
{
return null;
}
@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;
}

View file

@ -1,10 +1,10 @@
package techreborn.config;
import java.io.File;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.config.Configuration;
import java.io.File;
public class ConfigTechReborn {
private static ConfigTechReborn instance = null;
public static String CATEGORY_WORLD = "world";
@ -57,10 +57,10 @@ public class ConfigTechReborn {
public static boolean ExpensiveDiamondDrill;
public static boolean ExpensiveSolar;
public static Configuration config;
private ConfigTechReborn(File configFile) {
private ConfigTechReborn(File configFile)
{
config = new Configuration(configFile);
config.load();
@ -70,7 +70,8 @@ public class ConfigTechReborn {
}
public static ConfigTechReborn initialize(File configFile) {
public static ConfigTechReborn initialize(File configFile)
{
if (instance == null)
instance = new ConfigTechReborn(configFile);
@ -81,8 +82,10 @@ public class ConfigTechReborn {
return instance;
}
public static ConfigTechReborn instance() {
if (instance == null) {
public static ConfigTechReborn instance()
{
if (instance == null)
{
throw new IllegalStateException(
"Instance of TechReborn Config requested before initialization");
@ -90,171 +93,323 @@ public class ConfigTechReborn {
return instance;
}
public static void Configs() {
GalenaOreTrue = config.get(CATEGORY_WORLD,
StatCollector.translateToLocal("config.techreborn.allow.galenaOre"), true,
StatCollector.translateToLocal("config.techreborn.allow.galenaOre.tooltip"))
public static void Configs()
{
GalenaOreTrue = config
.get(CATEGORY_WORLD,
StatCollector
.translateToLocal("config.techreborn.allow.galenaOre"),
true,
StatCollector
.translateToLocal("config.techreborn.allow.galenaOre.tooltip"))
.getBoolean(true);
IridiumOreTrue = config.get(CATEGORY_WORLD,
StatCollector.translateToLocal("config.techreborn.allow.iridiumOre"), true,
StatCollector.translateToLocal("config.techreborn.allow.iridiumOre.tooltip"))
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"))
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"))
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"))
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"))
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"))
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"))
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"))
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"))
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"))
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"))
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"))
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"))
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"))
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"))
SodaliteOreTrue = config
.get(CATEGORY_WORLD,
StatCollector
.translateToLocal("config.techreborn.allow.sodaliteOre"),
true,
StatCollector
.translateToLocal("config.techreborn.allow.sodaliteOre.tooltip"))
.getBoolean(true);
// Power
ThermalGenertaorOutput = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.thermalGeneratorPower"), 30,
StatCollector.translateToLocal("config.techreborn.thermalGeneratorPower.tooltip"))
ThermalGenertaorOutput = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.thermalGeneratorPower"),
30,
StatCollector
.translateToLocal("config.techreborn.thermalGeneratorPower.tooltip"))
.getInt();
CentrifugeInputTick = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.centrifugePowerUsage"), 5,
StatCollector.translateToLocal("config.techreborn.centrifugePowerUsage.tooltip"))
CentrifugeInputTick = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.centrifugePowerUsage"),
5,
StatCollector
.translateToLocal("config.techreborn.centrifugePowerUsage.tooltip"))
.getInt();
// Charge
AdvancedDrillCharge = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.advancedDrillMaxCharge"), 60000,
StatCollector.translateToLocal("config.techreborn.advancedDrillMaxCharge.tooltip"))
AdvancedDrillCharge = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.advancedDrillMaxCharge"),
60000,
StatCollector
.translateToLocal("config.techreborn.advancedDrillMaxCharge.tooltip"))
.getInt();
LapotronPackCharge = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.lapotronPackMaxCharge"), 100000000,
StatCollector.translateToLocal("config.techreborn.lapotronPackMaxCharge.tooltop"))
LapotronPackCharge = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.lapotronPackMaxCharge"),
100000000,
StatCollector
.translateToLocal("config.techreborn.lapotronPackMaxCharge.tooltop"))
.getInt();
LithiumBatpackCharge = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.lithiumBatpackMaxCharge"), 4000000,
StatCollector.translateToLocal("config.techreborn.lithiumBatpackMaxCharge.tooltip"))
LithiumBatpackCharge = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.lithiumBatpackMaxCharge"),
4000000,
StatCollector
.translateToLocal("config.techreborn.lithiumBatpackMaxCharge.tooltip"))
.getInt();
OmniToolCharge = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.omniToolMaxCharge"), 20000,
StatCollector.translateToLocal("config.techreborn.omniToolMaxCharge.tooltip"))
OmniToolCharge = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.omniToolMaxCharge"),
20000,
StatCollector
.translateToLocal("config.techreborn.omniToolMaxCharge.tooltip"))
.getInt();
RockCutterCharge = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.rockCutterMaxCharge"), 10000,
StatCollector.translateToLocal("config.techreborn.rockCutterMaxCharge.tooltip"))
RockCutterCharge = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.rockCutterMaxCharge"),
10000,
StatCollector
.translateToLocal("config.techreborn.rockCutterMaxCharge.tooltip"))
.getInt();
GravityCharge = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.gravityChestplateMaxCharge"), 100000,
StatCollector.translateToLocal("config.techreborn.gravityChestplateMaxCharge.tooltip"))
GravityCharge = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.gravityChestplateMaxCharge"),
100000,
StatCollector
.translateToLocal("config.techreborn.gravityChestplateMaxCharge.tooltip"))
.getInt();
CentrifugeCharge = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.centrifugeMaxCharge"), 1000000,
StatCollector.translateToLocal("config.techreborn.centrifugeMaxCharge.tooltip"))
CentrifugeCharge = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.centrifugeMaxCharge"),
1000000,
StatCollector
.translateToLocal("config.techreborn.centrifugeMaxCharge.tooltip"))
.getInt();
ThermalGeneratorCharge = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.thermalGeneratorMaxCharge"), 1000000,
StatCollector.translateToLocal("config.techreborn.thermalGeneratorMaxCharge.tooltip"))
ThermalGeneratorCharge = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.thermalGeneratorMaxCharge"),
1000000,
StatCollector
.translateToLocal("config.techreborn.thermalGeneratorMaxCharge.tooltip"))
.getInt();
// Teir
AdvancedDrillTier = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.advancedDrillTier"), 2,
StatCollector.translateToLocal("config.techreborn.advancedDrillTier.tooltip"))
AdvancedDrillTier = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.advancedDrillTier"),
2,
StatCollector
.translateToLocal("config.techreborn.advancedDrillTier.tooltip"))
.getInt();
LapotronPackTier = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.lapotronPackTier"), 2,
StatCollector.translateToLocal("config.techreborn.lapotronPackTier.tooltip"))
LapotronPackTier = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.lapotronPackTier"),
2,
StatCollector
.translateToLocal("config.techreborn.lapotronPackTier.tooltip"))
.getInt();
LithiumBatpackTier = config.get(CATEGORY_POWER,
StatCollector.translateToLocal("config.techreborn.lithiumBatpackTier"), 3,
StatCollector.translateToLocal("config.techreborn.lithiumBatpackTier.tooltip"))
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"))
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"))
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"))
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"))
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"))
ThermalGeneratorTier = config
.get(CATEGORY_POWER,
StatCollector
.translateToLocal("config.techreborn.thermalGeneratorTier"),
1,
StatCollector
.translateToLocal("config.techreborn.thermalGeneratorTier.tooltip"))
.getInt();
// Crafting
ExpensiveMacerator = config.get(CATEGORY_CRAFTING,
StatCollector.translateToLocal("config.techreborn.allowExpensiveMacerator"), true,
StatCollector.translateToLocal("config.techreborn.allowExpensiveMacerator.tooltip"))
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"))
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"))
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"))
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,34 +1,39 @@
package techreborn.config;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.client.config.DummyConfigElement;
import cpw.mods.fml.client.config.GuiConfig;
import cpw.mods.fml.client.config.GuiConfigEntries;
import cpw.mods.fml.client.config.GuiConfigEntries.CategoryEntry;
import cpw.mods.fml.client.config.IConfigElement;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.common.config.Configuration;
import java.util.ArrayList;
import java.util.List;
public class TechRebornConfigGui extends GuiConfig {
public TechRebornConfigGui(GuiScreen top) {
super(top, getConfigCategories(), "TechReborn", false, false,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config
.toString()));
public TechRebornConfigGui(GuiScreen top)
{
super(top, getConfigCategories(), "TechReborn", false, false, GuiConfig
.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
}
private static List<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.add(new DummyConfigElement.DummyCategoryElement(StatCollector
.translateToLocal("config.techreborn.category.general"),
"tr.configgui.category.trGeneral", TRGeneral.class));
list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.world"),
list.add(new DummyConfigElement.DummyCategoryElement(StatCollector
.translateToLocal("config.techreborn.category.world"),
"tr.configgui.category.trWorld", TRWORLD.class));
list.add(new DummyConfigElement.DummyCategoryElement(StatCollector.translateToLocal("config.techreborn.category.power"),
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"),
list.add(new DummyConfigElement.DummyCategoryElement(StatCollector
.translateToLocal("config.techreborn.category.crafting"),
"tr.configgui.category.trCrafting", TRCRAFTING.class));
return list;
@ -36,31 +41,40 @@ public class TechRebornConfigGui extends GuiConfig {
public static class TRGeneral extends CategoryEntry {
public TRGeneral(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
public TRGeneral(GuiConfig owningScreen,
GuiConfigEntries owningEntryList, IConfigElement configElement)
{
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
protected GuiScreen buildChildScreen()
{
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config
.getCategory(Configuration.CATEGORY_GENERAL)))
.getChildElements(), this.owningScreen.modID,
Configuration.CATEGORY_GENERAL,
this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config.toString()));
this.configElement.requiresWorldRestart()
|| this.owningScreen.allRequireWorldRestart,
this.configElement.requiresMcRestart()
|| this.owningScreen.allRequireMcRestart,
GuiConfig.getAbridgedConfigPath(ConfigTechReborn.config
.toString()));
}
}
// World
public static class TRWORLD extends CategoryEntry {
public TRWORLD(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
public TRWORLD(GuiConfig owningScreen,
GuiConfigEntries owningEntryList, IConfigElement configElement)
{
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
protected GuiScreen buildChildScreen()
{
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config
.getCategory(ConfigTechReborn.CATEGORY_WORLD)))
@ -77,12 +91,15 @@ public class TechRebornConfigGui extends GuiConfig {
// Power
public static class TRPOWER extends CategoryEntry {
public TRPOWER(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
public TRPOWER(GuiConfig owningScreen,
GuiConfigEntries owningEntryList, IConfigElement configElement)
{
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
protected GuiScreen buildChildScreen()
{
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config
.getCategory(ConfigTechReborn.CATEGORY_POWER)))
@ -99,12 +116,15 @@ public class TechRebornConfigGui extends GuiConfig {
// Crafting
public static class TRCRAFTING extends CategoryEntry {
public TRCRAFTING(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement configElement) {
public TRCRAFTING(GuiConfig owningScreen,
GuiConfigEntries owningEntryList, IConfigElement configElement)
{
super(owningScreen, owningEntryList, configElement);
}
@Override
protected GuiScreen buildChildScreen() {
protected GuiScreen buildChildScreen()
{
return new GuiConfig(this.owningScreen,
(new ConfigElement(ConfigTechReborn.config
.getCategory(ConfigTechReborn.CATEGORY_CRAFTING)))

View file

@ -1,30 +1,34 @@
package techreborn.config;
import cpw.mods.fml.client.IModGuiFactory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import cpw.mods.fml.client.IModGuiFactory;
public class TechRebornGUIFactory implements IModGuiFactory {
@Override
public void initialize(Minecraft minecraftInstance) {
public void initialize(Minecraft minecraftInstance)
{
}
@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
public Class<? extends GuiScreen> mainConfigGuiClass()
{
return TechRebornConfigGui.class;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
{
return null;
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(
RuntimeOptionCategoryElement element) {
RuntimeOptionCategoryElement element)
{
return null;
}

View file

@ -1,19 +1,33 @@
package techreborn.init;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import techreborn.blocks.*;
import techreborn.blocks.BlockBlastFurnace;
import techreborn.blocks.BlockCentrifuge;
import techreborn.blocks.BlockMachineCasing;
import techreborn.blocks.BlockOre;
import techreborn.blocks.BlockQuantumChest;
import techreborn.blocks.BlockQuantumTank;
import techreborn.blocks.BlockRollingMachine;
import techreborn.blocks.BlockStorage;
import techreborn.blocks.BlockThermalGenerator;
import techreborn.client.TechRebornCreativeTab;
import techreborn.itemblocks.ItemBlockMachineCasing;
import techreborn.itemblocks.ItemBlockOre;
import techreborn.itemblocks.ItemBlockQuantumChest;
import techreborn.itemblocks.ItemBlockQuantumTank;
import techreborn.itemblocks.ItemBlockStorage;
import techreborn.tiles.*;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
import techreborn.tiles.TileMachineCasing;
import techreborn.tiles.TileQuantumChest;
import techreborn.tiles.TileQuantumTank;
import techreborn.tiles.TileRollingMachine;
import techreborn.tiles.TileThermalGenerator;
import techreborn.util.LogHelper;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModBlocks {
@ -28,47 +42,72 @@ public class ModBlocks {
public static Block ore;
public static Block storage;
public static void init() {
thermalGenerator = new BlockThermalGenerator().setBlockName("techreborn.thermalGenerator").setBlockTextureName("techreborn:ThermalGenerator_other").setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(thermalGenerator, "techreborn.thermalGenerator");
GameRegistry.registerTileEntity(TileThermalGenerator.class, "TileThermalGenerator");
public static void init()
{
thermalGenerator = new BlockThermalGenerator()
.setBlockName("techreborn.thermalGenerator")
.setBlockTextureName("techreborn:ThermalGenerator_other")
.setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(thermalGenerator,
"techreborn.thermalGenerator");
GameRegistry.registerTileEntity(TileThermalGenerator.class,
"TileThermalGenerator");
quantumTank = new BlockQuantumTank().setBlockName("techreborn.quantumTank").setBlockTextureName("techreborn:quantumTank").setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(quantumTank, ItemBlockQuantumTank.class, "techreborn.quantumTank");
GameRegistry.registerTileEntity(TileQuantumTank.class, "TileQuantumTank");
quantumTank = new BlockQuantumTank()
.setBlockName("techreborn.quantumTank")
.setBlockTextureName("techreborn:quantumTank")
.setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(quantumTank, ItemBlockQuantumTank.class,
"techreborn.quantumTank");
GameRegistry.registerTileEntity(TileQuantumTank.class,
"TileQuantumTank");
quantumChest = new BlockQuantumChest().setBlockName("techreborn.quantumChest").setBlockTextureName("techreborn:quantumChest").setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(quantumChest, ItemBlockQuantumChest.class, "techreborn.quantumChest");
GameRegistry.registerTileEntity(TileQuantumChest.class, "TileQuantumChest");
quantumChest = new BlockQuantumChest()
.setBlockName("techreborn.quantumChest")
.setBlockTextureName("techreborn:quantumChest")
.setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(quantumChest, ItemBlockQuantumChest.class,
"techreborn.quantumChest");
GameRegistry.registerTileEntity(TileQuantumChest.class,
"TileQuantumChest");
centrifuge = new BlockCentrifuge().setBlockName("techreborn.centrifuge").setBlockTextureName("techreborn:centrifuge").setCreativeTab(TechRebornCreativeTab.instance);
centrifuge = new BlockCentrifuge()
.setBlockName("techreborn.centrifuge")
.setBlockTextureName("techreborn:centrifuge")
.setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge");
GameRegistry.registerTileEntity(TileCentrifuge.class, "TileCentrifuge");
RollingMachine = new BlockRollingMachine(Material.piston);
GameRegistry.registerBlock(RollingMachine, "rollingmachine");
GameRegistry.registerTileEntity(TileRollingMachine.class, "TileRollingMachine");
GameRegistry.registerTileEntity(TileRollingMachine.class,
"TileRollingMachine");
BlastFurnace = new BlockBlastFurnace(Material.piston);
GameRegistry.registerBlock(BlastFurnace, "blastFurnace");
GameRegistry.registerTileEntity(TileBlastFurnace.class, "TileBlastFurnace");
GameRegistry.registerTileEntity(TileBlastFurnace.class,
"TileBlastFurnace");
MachineCasing = new BlockMachineCasing(Material.piston);
GameRegistry.registerBlock(MachineCasing, ItemBlockMachineCasing.class, "machinecasing");
GameRegistry.registerTileEntity(TileMachineCasing.class, "TileMachineCasing");
GameRegistry.registerBlock(MachineCasing, ItemBlockMachineCasing.class,
"machinecasing");
GameRegistry.registerTileEntity(TileMachineCasing.class,
"TileMachineCasing");
ore = new BlockOre(Material.rock);
GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore");
LogHelper.info("TechReborns Blocks Loaded");
storage = new BlockStorage(Material.rock);
GameRegistry.registerBlock(storage, ItemBlockStorage.class, "techreborn.storage");
GameRegistry.registerBlock(storage, ItemBlockStorage.class,
"techreborn.storage");
LogHelper.info("TechReborns Blocks Loaded");
registerOreDict();
}
public static void registerOreDict() {
public static void registerOreDict()
{
OreDictionary.registerOre("oreGalena", new ItemStack(ore, 1, 0));
OreDictionary.registerOre("oreIridium", new ItemStack(ore, 1, 1));
OreDictionary.registerOre("oreRuby", new ItemStack(ore, 1, 2));
@ -83,19 +122,26 @@ public class ModBlocks {
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("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("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("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("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;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
@ -20,6 +19,7 @@ import techreborn.items.tools.ItemOmniTool;
import techreborn.items.tools.ItemRockCutter;
import techreborn.items.tools.ItemTechPda;
import techreborn.util.LogHelper;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModItems {
@ -37,7 +37,8 @@ public class ModItems {
public static Item advancedDrill;
public static Item manuel;
public static void init() {
public static void init()
{
dusts = new ItemDusts();
GameRegistry.registerItem(dusts, "dust");
smallDusts = new ItemDustsSmall();
@ -70,7 +71,8 @@ public class ModItems {
registerOreDict();
}
public static void registerOreDict() {
public static void registerOreDict()
{
// Dusts
OreDictionary.registerOre("dustAlmandine", new ItemStack(dusts, 1, 0));
OreDictionary.registerOre("dustAluminium", new ItemStack(dusts, 1, 1));
@ -90,11 +92,13 @@ public class ModItems {
OreDictionary.registerOre("dustElectrum", new ItemStack(dusts, 1, 17));
OreDictionary.registerOre("dustEmerald", new ItemStack(dusts, 1, 18));
OreDictionary.registerOre("dustEnderEye", new ItemStack(dusts, 1, 19));
OreDictionary.registerOre("dustEnderPearl", new ItemStack(dusts, 1, 20));
OreDictionary
.registerOre("dustEnderPearl", new ItemStack(dusts, 1, 20));
OreDictionary.registerOre("dustEndstone", new ItemStack(dusts, 1, 21));
OreDictionary.registerOre("dustFlint", new ItemStack(dusts, 1, 22));
OreDictionary.registerOre("dustGold", new ItemStack(dusts, 1, 23));
OreDictionary.registerOre("dustGreenSapphire", new ItemStack(dusts, 1, 24));
OreDictionary.registerOre("dustGreenSapphire", new ItemStack(dusts, 1,
24));
OreDictionary.registerOre("dustGrossular", new ItemStack(dusts, 1, 25));
OreDictionary.registerOre("dustInvar", new ItemStack(dusts, 1, 26));
OreDictionary.registerOre("dustIron", new ItemStack(dusts, 1, 27));
@ -117,8 +121,10 @@ public class ModItems {
OreDictionary.registerOre("dustSapphire", new ItemStack(dusts, 1, 44));
OreDictionary.registerOre("dustSilver", new ItemStack(dusts, 1, 45));
OreDictionary.registerOre("dustSodalite", new ItemStack(dusts, 1, 46));
OreDictionary.registerOre("dustSpessartine", new ItemStack(dusts, 1, 47));
OreDictionary.registerOre("dustSphalerite", new ItemStack(dusts, 1, 48));
OreDictionary.registerOre("dustSpessartine",
new ItemStack(dusts, 1, 47));
OreDictionary
.registerOre("dustSphalerite", new ItemStack(dusts, 1, 48));
OreDictionary.registerOre("dustSteel", new ItemStack(dusts, 1, 49));
OreDictionary.registerOre("dustSulfur", new ItemStack(dusts, 1, 50));
OreDictionary.registerOre("dustTin", new ItemStack(dusts, 1, 51));
@ -126,17 +132,21 @@ public class ModItems {
OreDictionary.registerOre("dustTungsten", new ItemStack(dusts, 1, 53));
OreDictionary.registerOre("dustUranium", new ItemStack(dusts, 1, 54));
OreDictionary.registerOre("dustUvarovite", new ItemStack(dusts, 1, 55));
OreDictionary.registerOre("dustYellowGarnet", new ItemStack(dusts, 1, 56));
OreDictionary.registerOre("dustYellowGarnet", new ItemStack(dusts, 1,
56));
OreDictionary.registerOre("dustZinc", new ItemStack(dusts, 1, 57));
OreDictionary.registerOre("ingotCobalt", new ItemStack(dusts, 1, 58));
OreDictionary.registerOre("ingotArdite", new ItemStack(ingots, 1, 59));
OreDictionary.registerOre("ingotManyullyn", new ItemStack(ingots, 1, 60));
OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots, 1, 61));
OreDictionary.registerOre("ingotManyullyn",
new ItemStack(ingots, 1, 60));
OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots,
1, 61));
OreDictionary.registerOre("ingotAlumite", new ItemStack(ingots, 1, 62));
// Ingots
OreDictionary.registerOre("ingotIridium", new ItemStack(ingots, 1, 3));
OreDictionary.registerOre("ingotSilver", new ItemStack(ingots, 1, 4));
OreDictionary.registerOre("ingotAluminium", new ItemStack(ingots, 1, 5));
OreDictionary
.registerOre("ingotAluminium", new ItemStack(ingots, 1, 5));
OreDictionary.registerOre("ingotTitanium", new ItemStack(ingots, 1, 6));
OreDictionary.registerOre("ingotChrome", new ItemStack(ingots, 1, 7));
OreDictionary.registerOre("ingotElectrum", new ItemStack(ingots, 1, 8));
@ -145,18 +155,22 @@ public class ModItems {
OreDictionary.registerOre("ingotZinc", new ItemStack(ingots, 1, 11));
OreDictionary.registerOre("ingotBrass", new ItemStack(ingots, 1, 12));
OreDictionary.registerOre("ingotSteel", new ItemStack(ingots, 1, 13));
OreDictionary.registerOre("ingotPlatinum", new ItemStack(ingots, 1, 14));
OreDictionary
.registerOre("ingotPlatinum", new ItemStack(ingots, 1, 14));
OreDictionary.registerOre("ingotNickel", new ItemStack(ingots, 1, 15));
OreDictionary.registerOre("ingotInvar", new ItemStack(ingots, 1, 16));
OreDictionary.registerOre("ingotCobalt", new ItemStack(ingots, 1, 17));
OreDictionary.registerOre("ingotArdite", new ItemStack(ingots, 1, 18));
OreDictionary.registerOre("ingotManyullyn", new ItemStack(ingots, 1, 19));
OreDictionary.registerOre("ingotAluminumBrass", new ItemStack(ingots, 1, 20));
OreDictionary.registerOre("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("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 static void init(){
public static void init()
{
ModPartRegistry.registerPart(new CablePart());
ModPartRegistry.addProvider("techreborn.partSystem.QLib.QModPartFactory", "qmunitylib");
ModPartRegistry.addProvider("techreborn.partSystem.fmp.FMPFactory", "ForgeMultipart");
ModPartRegistry.addProvider(
"techreborn.partSystem.QLib.QModPartFactory", "qmunitylib");
ModPartRegistry.addProvider("techreborn.partSystem.fmp.FMPFactory",
"ForgeMultipart");
ModPartRegistry.addProvider(new WorldProvider());
ModPartRegistry.addAllPartsToSystems();
}

View file

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

View file

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

View file

@ -12,20 +12,28 @@ import techreborn.achievement.IPickupAchievement;
import techreborn.blocks.BlockOre;
import techreborn.init.ModBlocks;
public class ItemBlockOre extends ItemMultiTexture implements IPickupAchievement, ICraftAchievement{
public class ItemBlockOre extends ItemMultiTexture implements
IPickupAchievement, ICraftAchievement {
public ItemBlockOre(Block block) {
public ItemBlockOre(Block block)
{
super(ModBlocks.ore, ModBlocks.ore, BlockOre.types);
}
@Override
public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) {
return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) : null;
public Achievement getAchievementOnCraft(ItemStack stack,
EntityPlayer player, IInventory matrix)
{
return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a)
.getAchievementOnCraft(stack, player, matrix) : null;
}
@Override
public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) {
return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) : null;
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;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
@ -9,38 +9,52 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import techreborn.init.ModBlocks;
import techreborn.tiles.TileQuantumChest;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockQuantumChest extends ItemBlock {
public ItemBlockQuantumChest(Block p_i45328_1_) {
public ItemBlockQuantumChest(Block p_i45328_1_)
{
super(p_i45328_1_);
}
@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings(
{ "rawtypes", "unchecked" })
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
if (stack != null && stack.hasTagCompound()) {
public void addInformation(ItemStack stack, EntityPlayer player, List list,
boolean par4)
{
if (stack != null && stack.hasTagCompound())
{
if (stack.getTagCompound().getCompoundTag("tileEntity") != null)
list.add(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("storedQuantity") + " items");
list.add(stack.getTagCompound().getCompoundTag("tileEntity")
.getInteger("storedQuantity")
+ " items");
}
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
if (!world.setBlock(x, y, z, ModBlocks.quantumChest, metadata, 3)) {
public boolean placeBlockAt(ItemStack stack, EntityPlayer player,
World world, int x, int y, int z, int side, float hitX, float hitY,
float hitZ, int metadata)
{
if (!world.setBlock(x, y, z, ModBlocks.quantumChest, metadata, 3))
{
return false;
}
if (world.getBlock(x, y, z) == ModBlocks.quantumChest) {
world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player, stack);
if (world.getBlock(x, y, z) == ModBlocks.quantumChest)
{
world.getBlock(x, y, z).onBlockPlacedBy(world, x, y, z, player,
stack);
world.getBlock(x, y, z).onPostBlockPlaced(world, x, y, z, metadata);
}
if (stack != null && stack.hasTagCompound()) {
((TileQuantumChest) world.getTileEntity(x, y, z)).readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
if (stack != null && stack.hasTagCompound())
{
((TileQuantumChest) world.getTileEntity(x, y, z))
.readFromNBTWithoutCoords(stack.getTagCompound()
.getCompoundTag("tileEntity"));
}
return true;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -12,13 +12,13 @@ import techreborn.client.TechRebornCreativeTabMisc;
public class ItemGems extends Item {
public static final String[] types = new String[]
{
"Ruby", "Sapphire", "GreenSapphire", "Olivine", "RedGarnet", "YellowGarnet"
};
{ "Ruby", "Sapphire", "GreenSapphire", "Olivine", "RedGarnet",
"YellowGarnet" };
private IIcon[] textures;
public ItemGems() {
public ItemGems()
{
setCreativeTab(TechRebornCreativeTabMisc.instance);
setUnlocalizedName("techreborn.gem");
setHasSubtypes(true);
@ -26,18 +26,23 @@ public class ItemGems extends Item {
@Override
// Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister) {
public void registerIcons(IIconRegister iconRegister)
{
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i) {
textures[i] = iconRegister.registerIcon("techreborn:" + "gem/" + types[i]);
for (int i = 0; i < types.length; ++i)
{
textures[i] = iconRegister.registerIcon("techreborn:" + "gem/"
+ types[i]);
}
}
@Override
// Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta) {
if (meta < 0 || meta >= textures.length) {
public IIcon getIconFromDamage(int meta)
{
if (meta < 0 || meta >= textures.length)
{
meta = 0;
}
@ -46,9 +51,11 @@ public class ItemGems extends Item {
@Override
// 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) {
if (meta < 0 || meta >= types.length)
{
meta = 0;
}
@ -56,14 +63,17 @@ public class ItemGems extends Item {
}
// Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
for (int meta = 0; meta < types.length; ++meta) {
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
{
for (int meta = 0; meta < types.length; ++meta)
{
list.add(new ItemStack(item, 1, meta));
}
}
@Override
public EnumRarity getRarity(ItemStack itemstack) {
public EnumRarity getRarity(ItemStack itemstack)
{
return EnumRarity.uncommon;
}

View file

@ -12,15 +12,15 @@ import techreborn.client.TechRebornCreativeTabMisc;
public class ItemIngots extends Item {
public static final String[] types = new String[]
{
"IridiumAlloy", "HotTungstenSteel", "TungstenSteel", "Iridium", "Silver", "Aluminium", "Titanium", "Chrome",
"Electrum", "Tungsten", "Lead", "Zinc", "Brass", "Steel", "Platinum", "Nickel", "Invar",
"Cobalt", "Ardite", "Manyullyn", "AlBrass", "Alumite"
};
{ "IridiumAlloy", "HotTungstenSteel", "TungstenSteel", "Iridium", "Silver",
"Aluminium", "Titanium", "Chrome", "Electrum", "Tungsten", "Lead",
"Zinc", "Brass", "Steel", "Platinum", "Nickel", "Invar", "Cobalt",
"Ardite", "Manyullyn", "AlBrass", "Alumite" };
private IIcon[] textures;
public ItemIngots() {
public ItemIngots()
{
setCreativeTab(TechRebornCreativeTabMisc.instance);
setHasSubtypes(true);
setUnlocalizedName("techreborn.ingot");
@ -28,18 +28,23 @@ public class ItemIngots extends Item {
@Override
// Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister) {
public void registerIcons(IIconRegister iconRegister)
{
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i) {
textures[i] = iconRegister.registerIcon("techreborn:" + "ingot/" + types[i] + "Ingot");
for (int i = 0; i < types.length; ++i)
{
textures[i] = iconRegister.registerIcon("techreborn:" + "ingot/"
+ types[i] + "Ingot");
}
}
@Override
// Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta) {
if (meta < 0 || meta >= textures.length) {
public IIcon getIconFromDamage(int meta)
{
if (meta < 0 || meta >= textures.length)
{
meta = 0;
}
@ -48,9 +53,11 @@ public class ItemIngots extends Item {
@Override
// 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) {
if (meta < 0 || meta >= types.length)
{
meta = 0;
}
@ -58,14 +65,17 @@ public class ItemIngots extends Item {
}
// Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
for (int meta = 0; meta < types.length; ++meta) {
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
{
for (int meta = 0; meta < types.length; ++meta)
{
list.add(new ItemStack(item, 1, meta));
}
}
@Override
public EnumRarity getRarity(ItemStack itemstack) {
public EnumRarity getRarity(ItemStack itemstack)
{
return EnumRarity.uncommon;
}

View file

@ -12,16 +12,18 @@ import techreborn.client.TechRebornCreativeTabMisc;
public class ItemParts extends Item {
public static final String[] types = new String[]
{
"LazuriteChunk", "SiliconPlate", "MagnaliumPlate", "EnergeyFlowCircuit", "DataControlCircuit", "SuperConductor",
"DataStorageCircuit", "ComputerMonitor", "DiamondSawBlade", "DiamondGrinder", "KanthalHeatingCoil",
"NichromeHeatingCoil", "CupronickelHeatingCoil", "MachineParts", "WolframiamGrinder",
"AluminiumMachineHull", "BronzeMachineHull", "SteelMachineHull", "TitaniumMachineHull", "BrassMachineHull"
};
{ "LazuriteChunk", "SiliconPlate", "MagnaliumPlate", "EnergeyFlowCircuit",
"DataControlCircuit", "SuperConductor", "DataStorageCircuit",
"ComputerMonitor", "DiamondSawBlade", "DiamondGrinder",
"KanthalHeatingCoil", "NichromeHeatingCoil",
"CupronickelHeatingCoil", "MachineParts", "WolframiamGrinder",
"AluminiumMachineHull", "BronzeMachineHull", "SteelMachineHull",
"TitaniumMachineHull", "BrassMachineHull" };
private IIcon[] textures;
public ItemParts() {
public ItemParts()
{
setCreativeTab(TechRebornCreativeTabMisc.instance);
setHasSubtypes(true);
setUnlocalizedName("techreborn.part");
@ -29,18 +31,23 @@ public class ItemParts extends Item {
@Override
// Registers Textures For All Dusts
public void registerIcons(IIconRegister iconRegister) {
public void registerIcons(IIconRegister iconRegister)
{
textures = new IIcon[types.length];
for (int i = 0; i < types.length; ++i) {
textures[i] = iconRegister.registerIcon("techreborn:" + "part/" + types[i]);
for (int i = 0; i < types.length; ++i)
{
textures[i] = iconRegister.registerIcon("techreborn:" + "part/"
+ types[i]);
}
}
@Override
// Adds Texture what match's meta data
public IIcon getIconFromDamage(int meta) {
if (meta < 0 || meta >= textures.length) {
public IIcon getIconFromDamage(int meta)
{
if (meta < 0 || meta >= textures.length)
{
meta = 0;
}
@ -49,9 +56,11 @@ public class ItemParts extends Item {
@Override
// 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) {
if (meta < 0 || meta >= types.length)
{
meta = 0;
}
@ -59,14 +68,17 @@ public class ItemParts extends Item {
}
// Adds Dusts SubItems To Creative Tab
public void getSubItems(Item item, CreativeTabs creativeTabs, List list) {
for (int meta = 0; meta < types.length; ++meta) {
public void getSubItems(Item item, CreativeTabs creativeTabs, List list)
{
for (int meta = 0; meta < types.length; ++meta)
{
list.add(new ItemStack(item, 1, meta));
}
}
@Override
public EnumRarity getRarity(ItemStack itemstack) {
public EnumRarity getRarity(ItemStack itemstack)
{
return EnumRarity.rare;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -25,9 +25,11 @@ public class ItemTechPda extends Item{
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
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);
player.openGui(Core.INSTANCE, GuiHandler.pdaID, world,
(int) player.posX, (int) player.posY, (int) player.posY);
return itemStack;
}

View file

@ -3,8 +3,10 @@ package techreborn.lib;
import net.minecraftforge.common.util.ForgeDirection;
public class Functions {
public static int getIntDirFromDirection(ForgeDirection dir) {
switch (dir) {
public static int getIntDirFromDirection(ForgeDirection dir)
{
switch (dir)
{
case DOWN:
return 0;
case EAST:
@ -24,9 +26,11 @@ public class Functions {
}
}
public static ForgeDirection getDirectionFromInt(int dir) {
public static ForgeDirection getDirectionFromInt(int dir)
{
int metaDataToSet = 0;
switch (dir) {
switch (dir)
{
case 0:
metaDataToSet = 2;
break;

View file

@ -13,44 +13,52 @@ public class Location {
public int z;
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.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.z = z;
this.depth = depth;
}
public Location(int xCoord, int yCoord, int zCoord, ForgeDirection dir) {
public Location(int xCoord, int yCoord, int zCoord, ForgeDirection dir)
{
this.x = xCoord + dir.offsetX;
this.y = yCoord + dir.offsetY;
this.z = zCoord + dir.offsetZ;
}
public Location(int[] coords) {
if (coords.length >= 2) {
public Location(int[] coords)
{
if (coords.length >= 2)
{
this.x = coords[0];
this.y = coords[1];
this.z = coords[2];
}
}
public Location(ChunkPosition pos) {
if (pos != null) {
public Location(ChunkPosition pos)
{
if (pos != null)
{
this.x = pos.chunkPosX;
this.y = pos.chunkPosY;
this.z = pos.chunkPosZ;
}
}
public Location(MovingObjectPosition blockLookedAt) {
if (blockLookedAt != null) {
public Location(MovingObjectPosition blockLookedAt)
{
if (blockLookedAt != null)
{
this.x = blockLookedAt.blockX;
this.y = blockLookedAt.blockY;
this.z = blockLookedAt.blockZ;
@ -64,44 +72,54 @@ public class Location {
this.z = par1.zCoord;
}
public boolean equals(Location toTest) {
if (this.x == toTest.x && this.y == toTest.y && this.z == toTest.z) {
public boolean equals(Location toTest)
{
if (this.x == toTest.x && this.y == toTest.y && this.z == toTest.z)
{
return true;
}
return false;
}
public void setLocation(int x, int y, int z) {
public void setLocation(int x, int y, int z)
{
this.x = x;
this.y = y;
this.z = z;
}
public int getX() {
public int getX()
{
return this.x;
}
public void setX(int newX) {
public void setX(int newX)
{
this.x = newX;
}
public int getY() {
public int getY()
{
return this.y;
}
public void setY(int newY) {
public void setY(int newY)
{
this.y = newY;
}
public int getZ() {
public int getZ()
{
return this.z;
}
public void setZ(int newZ) {
public void setZ(int newZ)
{
this.z = newZ;
}
public int[] getLocation() {
public int[] getLocation()
{
int[] ret = new int[3];
ret[0] = this.x;
ret[1] = this.y;
@ -109,29 +127,37 @@ public class Location {
return ret;
}
public void setLocation(int[] coords) {
public void setLocation(int[] coords)
{
this.x = coords[0];
this.y = coords[1];
this.z = coords[2];
}
public int getDifference(Location otherLoc) {
return (int) Math.sqrt(Math.pow(this.x - otherLoc.x, 2) + Math.pow(this.y - otherLoc.y, 2) + Math.pow(this.z - otherLoc.z, 2));
public int getDifference(Location otherLoc)
{
return (int) Math.sqrt(Math.pow(this.x - otherLoc.x, 2)
+ Math.pow(this.y - otherLoc.y, 2)
+ Math.pow(this.z - otherLoc.z, 2));
}
public String printLocation() {
public String printLocation()
{
return "X: " + this.x + " Y: " + this.y + " Z: " + this.z;
}
public String printCoords() {
public String printCoords()
{
return this.x + ", " + this.y + ", " + this.z;
}
public boolean compare(int x, int y, int z) {
public boolean compare(int x, int y, int z)
{
return (this.x == x && this.y == y && this.z == z);
}
public Location getLocation(ForgeDirection dir) {
public Location getLocation(ForgeDirection dir)
{
return new Location(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
}
@ -213,8 +239,7 @@ public class Location {
if (world.blockExists(x, y, z))
{
return world.getTileEntity(x, y, z);
}
else
} else
{
return null;
}
@ -254,18 +279,19 @@ public class Location {
if (world.blockExists(x, y, z))
{
return world.getTileEntity(x, y, z);
}
else
} else
{
return null;
}
}
public int getDepth() {
public int getDepth()
{
return depth;
}
public int compareTo(Location o) {
public int compareTo(Location o)
{
return ((Integer) depth).compareTo(o.depth);
}
}

View file

@ -1,8 +1,7 @@
package techreborn.lib.vecmath;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.StringTokenizer;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
@ -12,48 +11,56 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.StringTokenizer;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Vecs3d {
protected double x, y, z;
protected World w = null;
public Vecs3d(double x, double y, double z) {
public Vecs3d(double x, double y, double z)
{
this.x = x;
this.y = y;
this.z = z;
}
public Vecs3d(double x, double y, double z, World w) {
public Vecs3d(double x, double y, double z, World w)
{
this(x, y, z);
this.w = w;
}
public Vecs3d(TileEntity te) {
public Vecs3d(TileEntity te)
{
this(te.xCoord, te.yCoord, te.zCoord, te.getWorldObj());
}
public Vecs3d(Vec3 vec) {
public Vecs3d(Vec3 vec)
{
this(vec.xCoord, vec.yCoord, vec.zCoord);
}
public Vecs3d(Vec3 vec, World w) {
public Vecs3d(Vec3 vec, World w)
{
this(vec.xCoord, vec.yCoord, vec.zCoord);
this.w = w;
}
public boolean hasWorld() {
public boolean hasWorld()
{
return w != null;
}
public Vecs3d add(double x, double y, double z) {
public Vecs3d add(double x, double y, double z)
{
this.x += x;
this.y += y;
@ -61,17 +68,20 @@ public class Vecs3d {
return this;
}
public Vecs3d add(ForgeDirection dir) {
public Vecs3d add(ForgeDirection dir)
{
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);
}
public Vecs3d sub(double x, double y, double z) {
public Vecs3d sub(double x, double y, double z)
{
this.x -= x;
this.y -= y;
@ -79,17 +89,20 @@ public class Vecs3d {
return this;
}
public Vecs3d sub(ForgeDirection dir) {
public Vecs3d sub(ForgeDirection dir)
{
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);
}
public Vecs3d mul(double x, double y, double z) {
public Vecs3d mul(double x, double y, double z)
{
this.x *= x;
this.y *= y;
@ -97,22 +110,26 @@ public class Vecs3d {
return this;
}
public Vecs3d mul(double multiplier) {
public Vecs3d mul(double multiplier)
{
return mul(multiplier, multiplier, multiplier);
}
public Vecs3d mul(ForgeDirection direction) {
public Vecs3d mul(ForgeDirection direction)
{
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());
}
public Vecs3d div(double x, double y, double z) {
public Vecs3d div(double x, double y, double z)
{
this.x /= x;
this.y /= y;
@ -120,22 +137,26 @@ public class Vecs3d {
return this;
}
public Vecs3d div(double multiplier) {
public Vecs3d div(double multiplier)
{
return div(multiplier, multiplier, multiplier);
}
public Vecs3d div(ForgeDirection direction) {
public Vecs3d div(ForgeDirection direction)
{
return div(direction.offsetX, direction.offsetY, direction.offsetZ);
}
public double length() {
public double length()
{
return Math.sqrt(x * x + y * y + z * z);
}
public Vecs3d normalize() {
public Vecs3d normalize()
{
Vecs3d v = clone();
@ -151,75 +172,92 @@ public class Vecs3d {
return v;
}
public Vecs3d abs() {
public Vecs3d abs()
{
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();
}
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);
}
public Vecs3d getRelative(ForgeDirection dir) {
public Vecs3d getRelative(ForgeDirection dir)
{
return getRelative(dir.offsetX, dir.offsetY, dir.offsetZ);
}
public ForgeDirection getDirectionTo(Vecs3d vec) {
public ForgeDirection getDirectionTo(Vecs3d vec)
{
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
if (getBlockX() + d.offsetX == vec.getBlockX() && getBlockY() + d.offsetY == vec.getBlockY()
if (getBlockX() + d.offsetX == vec.getBlockX()
&& getBlockY() + d.offsetY == vec.getBlockY()
&& getBlockZ() + d.offsetZ == vec.getBlockZ())
return d;
return null;
}
public boolean isZero() {
public boolean isZero()
{
return x == 0 && y == 0 && z == 0;
}
@Override
public Vecs3d clone() {
public Vecs3d clone()
{
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 false;
}
public TileEntity getTileEntity() {
public TileEntity getTileEntity()
{
if (hasTileEntity()) {
if (hasTileEntity())
{
return w.getTileEntity((int) x, (int) y, (int) z);
}
return null;
}
public boolean isBlock(Block b) {
public boolean isBlock(Block b)
{
return isBlock(b, false);
}
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);
if (b == null && bl == Blocks.air)
@ -234,22 +272,27 @@ public class Vecs3d {
return false;
}
public int getBlockMeta() {
public int getBlockMeta()
{
if (hasWorld()) {
if (hasWorld())
{
return w.getBlockMetadata((int) x, (int) y, (int) z);
}
return -1;
}
public Block getBlock() {
public Block getBlock()
{
return getBlock(false);
}
public Block getBlock(boolean airIsNull) {
public Block getBlock(boolean airIsNull)
{
if (hasWorld()) {
if (hasWorld())
{
if (airIsNull && isBlock(null, true))
return null;
return w.getBlock((int) x, (int) y, (int) z);
@ -258,54 +301,64 @@ public class Vecs3d {
return null;
}
public World getWorld() {
public World getWorld()
{
return w;
}
public Vecs3d setWorld(World world) {
public Vecs3d setWorld(World world)
{
w = world;
return this;
}
public double getX() {
public double getX()
{
return x;
}
public double getY() {
public double getY()
{
return y;
}
public double getZ() {
public double getZ()
{
return z;
}
public int getBlockX() {
public int getBlockX()
{
return (int) Math.floor(x);
}
public int getBlockY() {
public int getBlockY()
{
return (int) Math.floor(y);
}
public int getBlockZ() {
public int getBlockZ()
{
return (int) Math.floor(z);
}
public double distanceTo(Vecs3d vec) {
public double distanceTo(Vecs3d vec)
{
return distanceTo(vec.x, vec.y, vec.z);
}
public double distanceTo(double x, double y, double z) {
public double distanceTo(double x, double y, double z)
{
double dx = x - this.x;
double dy = y - this.y;
@ -313,25 +366,30 @@ public class Vecs3d {
return dx * dx + dy * dy + dz * dz;
}
public void setX(double x) {
public void setX(double x)
{
this.x = x;
}
public void setY(double y) {
public void setY(double y)
{
this.y = y;
}
public void setZ(double z) {
public void setZ(double z)
{
this.z = z;
}
@Override
public boolean equals(Object obj) {
public boolean equals(Object obj)
{
if (obj instanceof Vecs3d) {
if (obj instanceof Vecs3d)
{
Vecs3d vec = (Vecs3d) obj;
return vec.w == w && vec.x == x && vec.y == y && vec.z == z;
}
@ -339,18 +397,22 @@ public class Vecs3d {
}
@Override
public int hashCode() {
public int hashCode()
{
return new Double(x).hashCode() + new Double(y).hashCode() << 8 + new Double(z).hashCode() << 16;
return new Double(x).hashCode() + new Double(y).hashCode() << 8 + new Double(
z).hashCode() << 16;
}
public Vec3 toVec3() {
public Vec3 toVec3()
{
return Vec3.createVectorHelper(x, y, z);
}
@Override
public String toString() {
public String toString()
{
String s = "Vector3{";
if (hasWorld())
@ -359,7 +421,8 @@ public class Vecs3d {
return s;
}
public ForgeDirection toForgeDirection() {
public ForgeDirection toForgeDirection()
{
if (z == 1)
return ForgeDirection.SOUTH;
@ -379,26 +442,35 @@ public class Vecs3d {
return ForgeDirection.UNKNOWN;
}
public static Vecs3d fromString(String s) {
public static Vecs3d fromString(String s)
{
if (s.startsWith("Vector3{") && s.endsWith("}")) {
if (s.startsWith("Vector3{") && s.endsWith("}"))
{
World w = null;
double x = 0, y = 0, z = 0;
String s2 = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}"));
StringTokenizer st = new StringTokenizer(s2, ";");
while (st.hasMoreTokens()) {
while (st.hasMoreTokens())
{
String t = st.nextToken();
if (t.toLowerCase().startsWith("w")) {
if (t.toLowerCase().startsWith("w"))
{
int world = Integer.parseInt(t.split("=")[1]);
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
for (World wo : MinecraftServer.getServer().worldServers) {
if (wo.provider.dimensionId == world) {
if (FMLCommonHandler.instance().getEffectiveSide()
.isServer())
{
for (World wo : MinecraftServer.getServer().worldServers)
{
if (wo.provider.dimensionId == world)
{
w = wo;
break;
}
}
} else {
} else
{
w = getClientWorld(world);
}
}
@ -411,9 +483,11 @@ public class Vecs3d {
z = Double.parseDouble(t.split("=")[1]);
}
if (w != null) {
if (w != null)
{
return new Vecs3d(x, y, z, w);
} else {
} else
{
return new Vecs3d(x, y, z);
}
}
@ -421,7 +495,8 @@ public class Vecs3d {
}
@SideOnly(Side.CLIENT)
private static World getClientWorld(int world) {
private static World getClientWorld(int world)
{
if (Minecraft.getMinecraft().theWorld.provider.dimensionId != world)
return null;

View file

@ -1,26 +1,31 @@
package techreborn.lib.vecmath;
import java.util.List;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import java.util.List;
public class Vecs3dCube {
private Vecs3d min, max;
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);
}
public Vecs3dCube(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, World world) {
public Vecs3dCube(double minX, double minY, double minZ, double maxX,
double maxY, double maxZ, World world)
{
this(new Vecs3d(minX, minY, minZ, world), new Vecs3d(maxX, maxY, maxZ, world));
this(new Vecs3d(minX, minY, minZ, world), new Vecs3d(maxX, maxY, maxZ,
world));
}
public Vecs3dCube(Vecs3d a, Vecs3d b) {
public Vecs3dCube(Vecs3d a, Vecs3d b)
{
World w = a.getWorld();
if (w == null)
@ -32,69 +37,84 @@ public class Vecs3dCube {
fix();
}
public Vecs3dCube(AxisAlignedBB aabb) {
public Vecs3dCube(AxisAlignedBB aabb)
{
this(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ);
}
public Vecs3d getMin() {
public Vecs3d getMin()
{
return min;
}
public Vecs3d getMax() {
public Vecs3d getMax()
{
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();
}
public double getMinY() {
public double getMinY()
{
return min.getY();
}
public double getMinZ() {
public double getMinZ()
{
return min.getZ();
}
public double getMaxX() {
public double getMaxX()
{
return max.getX();
}
public double getMaxY() {
public double getMaxY()
{
return max.getY();
}
public double getMaxZ() {
public double getMaxZ()
{
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() {
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);
@ -102,7 +122,8 @@ public class Vecs3dCube {
return this;
}
public Vecs3dCube fix() {
public Vecs3dCube fix()
{
Vecs3d a = min.clone();
Vecs3d b = max.clone();
@ -121,7 +142,8 @@ public class Vecs3dCube {
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);
@ -129,7 +151,8 @@ public class Vecs3dCube {
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;
@ -138,7 +161,8 @@ public class Vecs3dCube {
double maxy = Double.MIN_VALUE;
double maxz = Double.MIN_VALUE;
for (Vecs3dCube c : cubes) {
for (Vecs3dCube c : cubes)
{
minx = Math.min(minx, c.getMinX());
miny = Math.min(miny, c.getMinY());
minz = Math.min(minz, c.getMinZ());
@ -154,7 +178,8 @@ public class Vecs3dCube {
}
@Override
public int hashCode() {
public int hashCode()
{
return min.hashCode() << 8 + max.hashCode();
}

View file

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

View file

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

View file

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

View file

@ -1,13 +1,14 @@
package techreborn.partSystem;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import java.util.ArrayList;
public interface ICustomHighlight {
ArrayList<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;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import techreborn.lib.vecmath.Vecs3d;
import techreborn.lib.vecmath.Vecs3dCube;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* This is based of https://github.com/Qmunity/QmunityLib/blob/master/src/main/java/uk/co/qmunity/lib/part/IPart.java
* This is based of
* https://github.com/Qmunity/QmunityLib/blob/master/src/main/java
* /uk/co/qmunity/lib/part/IPart.java
* <p/>
* You should not be implementing this.
*/
public interface IModPart {
/**
* Adds all of this part's collision boxes to the list. These boxes can depend on the entity that's colliding with them.
* Adds all of this part's collision boxes to the list. These boxes can
* depend on the entity that's colliding with them.
*/
public void addCollisionBoxesToList(List<Vecs3dCube> boxes, Entity entity);
@ -35,7 +36,6 @@ public interface IModPart {
*/
public List<Vecs3dCube> getSelectionBoxes();
/**
* Gets this part's occlusion boxes.
*/
@ -49,10 +49,12 @@ public interface IModPart {
/**
* 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)
public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks, int pass);
public boolean renderStatic(Vecs3d translation, RenderBlocks renderBlocks,
int pass);
/**
* Writes the part's data to an NBT tag, which is saved with the game data.
@ -105,7 +107,8 @@ public interface IModPart {
public void tick();
/**
* Called when a block or part has been changed. Can be used for cables to check nearby blocks
* Called when a block or part has been changed. Can be used for cables to
* check nearby blocks
*/
public void nearByChange();

View file

@ -11,18 +11,20 @@ import net.minecraft.world.World;
import techreborn.lib.Location;
import techreborn.lib.vecmath.Vecs3dCube;
public interface IPartProvider {
public String modID();
public void registerPart();
public boolean checkOcclusion(World world, Location location, Vecs3dCube cube);
public boolean checkOcclusion(World world, Location location,
Vecs3dCube cube);
public boolean hasPart(World world, Location location, String name);
public boolean placePart(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, ModPart modPart);
public boolean placePart(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int side, float hitX, float hitY, float hitZ,
ModPart modPart);
public boolean isTileFromProvider(TileEntity tileEntity);
}

View file

@ -4,12 +4,10 @@
package techreborn.partSystem;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import techreborn.lib.Location;
/**
* Extend this class to make your multipart
*/
@ -25,21 +23,21 @@ public abstract class ModPart extends TileEntity implements IModPart {
*/
public Location location;
/**
* This is the world
*/
@Override
public World getWorld() {
public World getWorld()
{
return world;
}
/**
* This sets the world
* Don't use this unless you know what you are doing.
* This sets the world Don't use this unless you know what you are doing.
*/
public void setWorld(World world) {
public void setWorld(World world)
{
this.world = world;
setWorldObj(world);
}
@ -48,7 +46,8 @@ public abstract class ModPart extends TileEntity implements IModPart {
* Gets the x position in the world
*/
@Override
public int getX() {
public int getX()
{
return location.getX();
}
@ -56,7 +55,8 @@ public abstract class ModPart extends TileEntity implements IModPart {
* Gets the y position in the world
*/
@Override
public int getY() {
public int getY()
{
return location.getY();
}
@ -64,37 +64,39 @@ public abstract class ModPart extends TileEntity implements IModPart {
* Gets the z position in the world
*/
@Override
public int getZ() {
public int getZ()
{
return location.getZ();
}
/**
* Gets the location of the part
*/
public Location getLocation() {
public Location getLocation()
{
return location;
}
/**
* Sets the x position in the world
*/
public void setLocation(Location location) {
public void setLocation(Location location)
{
this.location = location;
this.xCoord = location.getX();
this.yCoord = location.getY();
this.zCoord = location.getZ();
}
@Override
public World getWorldObj() {
public World getWorldObj()
{
return getWorld();
}
@Override
public void setWorldObj(World p_145834_1_) {
public void setWorldObj(World p_145834_1_)
{
super.setWorldObj(p_145834_1_);
}
}

View file

@ -10,38 +10,54 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import uk.co.qmunity.lib.ref.Names;
public class ModPartItem extends Item {
ModPart modPart;
public ModPartItem(ModPart part) {
public ModPartItem(ModPart part)
{
modPart = part;
setUnlocalizedName(Names.Unlocalized.Items.MULTIPART);
}
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int face, float x_, float y_, float z_) {
if(ModPartRegistry.masterProvider != null){
try {
if (ModPartRegistry.masterProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().newInstance())) {
public boolean onItemUse(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int face, float x_, float y_, float z_)
{
if (ModPartRegistry.masterProvider != null)
{
try
{
if (ModPartRegistry.masterProvider.placePart(item, player,
world, x, y, z, face, x_, y_, z_, modPart.getClass()
.newInstance()))
{
return true;
}
} catch (InstantiationException e) {
} catch (InstantiationException e)
{
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (IllegalAccessException e)
{
e.printStackTrace();
}
return false;
}else {
for (IPartProvider partProvider : ModPartRegistry.providers) {
try {
if (partProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().newInstance())) {
} else
{
for (IPartProvider partProvider : ModPartRegistry.providers)
{
try
{
if (partProvider.placePart(item, player, world, x, y, z,
face, x_, y_, z_, modPart.getClass().newInstance()))
{
return true;
}
} catch (InstantiationException e) {
} catch (InstantiationException e)
{
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (IllegalAccessException e)
{
e.printStackTrace();
}
}
@ -50,11 +66,13 @@ public class ModPartItem extends Item {
}
@Override
public String getUnlocalizedName(ItemStack stack) {
public String getUnlocalizedName(ItemStack stack)
{
return modPart.getName();
}
public ModPart getModPart() {
public ModPart getModPart()
{
return modPart;
}
}

View file

@ -4,16 +4,16 @@
package techreborn.partSystem;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.item.Item;
import techreborn.client.TechRebornCreativeTab;
import techreborn.util.LogHelper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.item.Item;
import techreborn.client.TechRebornCreativeTab;
import techreborn.util.LogHelper;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModPartRegistry {
public static ArrayList<ModPart> parts = new ArrayList<ModPart>();
@ -24,55 +24,78 @@ public class ModPartRegistry {
public static Map<Item, String> itemParts = new HashMap<Item, String>();
public static void registerPart(ModPart iModPart) {
public static void registerPart(ModPart iModPart)
{
parts.add(iModPart);
}
public static void addAllPartsToSystems() {
public static void addAllPartsToSystems()
{
LogHelper.info("Started to load all parts");
for (ModPart modPart : ModPartRegistry.parts) {
Item part = new ModPartItem(modPart).setUnlocalizedName(modPart.getName()).setCreativeTab(TechRebornCreativeTab.instance).setTextureName(modPart.getItemTextureName());
for (ModPart modPart : ModPartRegistry.parts)
{
Item part = new ModPartItem(modPart)
.setUnlocalizedName(modPart.getName())
.setCreativeTab(TechRebornCreativeTab.instance)
.setTextureName(modPart.getItemTextureName());
GameRegistry.registerItem(part, modPart.getName());
itemParts.put(part, modPart.getName());
}
for (IPartProvider iPartProvider : providers) {
for (IPartProvider iPartProvider : providers)
{
iPartProvider.registerPart();
}
}
public static Item getItem(String string) {
for (Map.Entry<Item, String> entry : itemParts.entrySet()) {
if (entry.getValue().equals(string)) {
public static Item getItem(String string)
{
for (Map.Entry<Item, String> entry : itemParts.entrySet())
{
if (entry.getValue().equals(string))
{
return entry.getKey();
}
}
return null;
}
public static void addProvider(String className, String modid) {
if (Loader.isModLoaded(modid) || modid.equals("Minecraft")) {
try {
public static void addProvider(String className, String modid)
{
if (Loader.isModLoaded(modid) || modid.equals("Minecraft"))
{
try
{
IPartProvider iPartProvider = null;
iPartProvider = (IPartProvider) Class.forName(className).newInstance();
iPartProvider = (IPartProvider) Class.forName(className)
.newInstance();
providers.add(iPartProvider);
} catch (ClassNotFoundException e) {
} catch (ClassNotFoundException e)
{
e.printStackTrace();
LogHelper.error("Failed to load " + className + " to the part system!");
} catch (InstantiationException e) {
LogHelper.error("Failed to load " + className
+ " to the part system!");
} catch (InstantiationException e)
{
e.printStackTrace();
LogHelper.error("Failed to load " + className + " to the part system!");
} catch (IllegalAccessException e) {
LogHelper.error("Failed to load " + className
+ " to the part system!");
} catch (IllegalAccessException e)
{
e.printStackTrace();
LogHelper.error("Failed to load " + className + " to the part system!");
LogHelper.error("Failed to load " + className
+ " to the part system!");
}
}
}
// Only use this one if it is a standalone Provider
public static void addProvider(IPartProvider iPartProvider) {
if (Loader.isModLoaded(iPartProvider.modID()) || iPartProvider.modID().equals("Minecraft")) {
public static void addProvider(IPartProvider iPartProvider)
{
if (Loader.isModLoaded(iPartProvider.modID())
|| iPartProvider.modID().equals("Minecraft"))
{
providers.add(iPartProvider);
}
}

View file

@ -4,73 +4,96 @@
package techreborn.partSystem;
import java.util.Map;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import techreborn.lib.Location;
import techreborn.lib.vecmath.Vecs3dCube;
import java.util.Map;
public class ModPartUtils {
public static boolean checkOcclusion(World world, Location location, Vecs3dCube cube) {
if (world == null) {
public static boolean checkOcclusion(World world, Location location,
Vecs3dCube cube)
{
if (world == null)
{
return false;
}
IPartProvider partProvider = getPartProvider(world, location);
if (partProvider != null) {
if (partProvider != null)
{
return partProvider.checkOcclusion(world, location, cube);
}
return false;
}
public static boolean checkOcclusion(World world, int x, int y, int z, Vecs3dCube cube) {
public static boolean checkOcclusion(World world, int x, int y, int z,
Vecs3dCube cube)
{
return checkOcclusion(world, new Location(x, y, z), cube);
}
public static boolean checkOcclusionInvert(World world, Location location, Vecs3dCube cube) {
if (world == null) {
public static boolean checkOcclusionInvert(World world, Location location,
Vecs3dCube cube)
{
if (world == null)
{
return false;
}
for (IPartProvider iPartProvider : ModPartRegistry.providers) {
if (!iPartProvider.checkOcclusion(world, location, cube)) {
for (IPartProvider iPartProvider : ModPartRegistry.providers)
{
if (!iPartProvider.checkOcclusion(world, location, cube))
{
return false;
}
}
return false;
}
public static boolean checkOcclusionInvert(World world, int x, int y, int z, Vecs3dCube cube) {
public static boolean checkOcclusionInvert(World world, int x, int y,
int z, Vecs3dCube cube)
{
return checkOcclusionInvert(world, new Location(x, y, z), cube);
}
public static boolean hasPart(World world, Location location, String name) {
for (IPartProvider iPartProvider : ModPartRegistry.providers) {
if (iPartProvider.hasPart(world, location, name)) {
public static boolean hasPart(World world, Location location, String name)
{
for (IPartProvider iPartProvider : ModPartRegistry.providers)
{
if (iPartProvider.hasPart(world, location, name))
{
return true;
}
}
return false;
}
public static boolean hasPart(World world, int x, int y, int z, String name) {
public static boolean hasPart(World world, int x, int y, int z, String name)
{
return hasPart(world, new Location(x, y, z), name);
}
public static Item getItemForPart(String string) {
for (Map.Entry<Item, String> item : ModPartRegistry.itemParts.entrySet()) {
if (item.getValue().equals(string)) {
public static Item getItemForPart(String string)
{
for (Map.Entry<Item, String> item : ModPartRegistry.itemParts
.entrySet())
{
if (item.getValue().equals(string))
{
return item.getKey();
}
}
return null;
}
public static IPartProvider getPartProvider(World world, Location location) {
for (IPartProvider partProvider : ModPartRegistry.providers) {
if (partProvider.isTileFromProvider(world.getTileEntity(location.getX(), location.getY(), location.getZ()))) {
public static IPartProvider getPartProvider(World world, Location location)
{
for (IPartProvider partProvider : ModPartRegistry.providers)
{
if (partProvider.isTileFromProvider(world.getTileEntity(
location.getX(), location.getY(), location.getZ())))
{
return partProvider;
}
}

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