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

View file

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

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

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

View file

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

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

View file

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

View file

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

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,45 +15,51 @@ import erogenousbeef.coreTR.common.BeefCoreLog;
import erogenousbeef.coreTR.common.CoordTriplet;
/**
* This class manages all the multiblock controllers that exist in a given world,
* either client- or server-side.
* You must create different registries for server and client worlds.
* This class manages all the multiblock controllers that exist in a given
* world, either client- or server-side. You must create different registries
* for server and client worlds.
*
* @author Erogenous Beef
*/
public class MultiblockWorldRegistry {
private World worldObj;
private Set<MultiblockControllerBase> controllers; // Active controllers
private Set<MultiblockControllerBase> dirtyControllers; // Controllers whose parts lists have changed
private Set<MultiblockControllerBase> deadControllers; // Controllers which are empty
// A list of orphan parts - parts which currently have no master, but should seek one this tick
private Set<MultiblockControllerBase> controllers; // Active controllers
private Set<MultiblockControllerBase> dirtyControllers; // Controllers whose
// parts lists have
// changed
private Set<MultiblockControllerBase> deadControllers; // Controllers which
// are empty
// A list of orphan parts - parts which currently have no master, but should
// seek one this tick
// Indexed by the hashed chunk coordinate
// This can be added-to asynchronously via chunk loads!
private Set<IMultiblockPart> orphanedParts;
// A list of parts which have been detached during internal operations
private Set<IMultiblockPart> detachedParts;
// A list of parts whose chunks have not yet finished loading
// They will be added to the orphan list when they are finished loading.
// Indexed by the hashed chunk coordinate
// This can be added-to asynchronously via chunk loads!
private HashMap<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>();
deadControllers = new HashSet<MultiblockControllerBase>();
dirtyControllers = new HashSet<MultiblockControllerBase>();
detachedParts = new HashSet<IMultiblockPart>();
orphanedParts = new HashSet<IMultiblockPart>();
@ -61,20 +67,27 @@ public class MultiblockWorldRegistry {
partsAwaitingChunkLoadMutex = new Object();
orphanedPartsMutex = new Object();
}
/**
* Called before Tile Entities are ticked in the world. Run game logic.
*/
public void tickStart() {
if(controllers.size() > 0) {
for(MultiblockControllerBase controller : controllers) {
if(controller.worldObj == worldObj && controller.worldObj.isRemote == worldObj.isRemote) {
if(controller.isEmpty()) {
// This happens on the server when the user breaks the last block. It's fine.
public void tickStart()
{
if (controllers.size() > 0)
{
for (MultiblockControllerBase controller : controllers)
{
if (controller.worldObj == worldObj
&& controller.worldObj.isRemote == worldObj.isRemote)
{
if (controller.isEmpty())
{
// This happens on the server when the user breaks the
// last block. It's fine.
// Mark 'er dead and move on.
deadControllers.add(controller);
}
else {
} else
{
// Run the game logic for this world
controller.updateMultiblockEntity();
}
@ -82,87 +95,119 @@ public class MultiblockWorldRegistry {
}
}
}
/**
* Called prior to processing multiblock controllers. Do bookkeeping.
*/
public void processMultiblockChanges() {
public void processMultiblockChanges()
{
IChunkProvider chunkProvider = worldObj.getChunkProvider();
CoordTriplet coord;
// Merge pools - sets of adjacent machines which should be merged later on in processing
// Merge pools - sets of adjacent machines which should be merged later
// on in processing
List<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;
}
// 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,109 +265,142 @@ public class MultiblockWorldRegistry {
}
// Process splits and assembly
// Any controllers which have had parts removed must be checked to see if some parts are no longer
// Any controllers which have had parts removed must be checked to see
// if some parts are no longer
// physically connected to their master.
if(dirtyControllers.size() > 0) {
if (dirtyControllers.size() > 0)
{
Set<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);
}
}
dirtyControllers.clear();
}
// Unregister dead controllers
if(deadControllers.size() > 0) {
for(MultiblockControllerBase controller : deadControllers) {
// Go through any controllers which have marked themselves as potentially dead.
if (deadControllers.size() > 0)
{
for (MultiblockControllerBase controller : deadControllers)
{
// Go through any controllers which have marked themselves as
// potentially dead.
// Validate that they are empty/dead, then unregister them.
if(!controller.isEmpty()) {
BeefCoreLog.fatal("Found a non-empty controller. Forcing it to shed its blocks and die. This should never happen!");
if (!controller.isEmpty())
{
BeefCoreLog
.fatal("Found a non-empty controller. Forcing it to shed its blocks and die. This should never happen!");
detachedParts.addAll(controller.detachAllBlocks());
}
// THIS IS THE ONLY PLACE WHERE CONTROLLERS ARE UNREGISTERED.
this.controllers.remove(controller);
}
deadControllers.clear();
}
// Process detached blocks
// Any blocks which have been detached this tick should be moved to the orphaned
// list, and will be checked next tick to see if their chunk is still loaded.
for(IMultiblockPart part : detachedParts) {
// Any blocks which have been detached this tick should be moved to the
// orphaned
// list, and will be checked next tick to see if their chunk is still
// loaded.
for (IMultiblockPart part : detachedParts)
{
// Ensure parts know they're detached
part.assertDetached();
}
addAllOrphanedPartsThreadsafe(detachedParts);
detachedParts.clear();
}
/**
* Called when a multiblock part is added to the world, either via chunk-load or user action.
* If its chunk is loaded, it will be processed during the next tick.
* If the chunk is not loaded, it will be added to a list of objects waiting for a chunkload.
* @param part The part which is being added to this world.
* Called when a multiblock part is added to the world, either via
* chunk-load or user action. If its chunk is loaded, it will be processed
* during the next tick. If the chunk is not loaded, it will be added to a
* list of objects waiting for a chunkload.
*
* @param part
* The part which is being added to this world.
*/
public void onPartAdded(IMultiblockPart part) {
public void onPartAdded(IMultiblockPart part)
{
CoordTriplet worldLocation = part.getWorldLocation();
if(!worldObj.getChunkProvider().chunkExists(worldLocation.getChunkX(), worldLocation.getChunkZ())) {
if (!worldObj.getChunkProvider().chunkExists(worldLocation.getChunkX(),
worldLocation.getChunkZ()))
{
// Part goes into the waiting-for-chunk-load list
Set<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,51 +409,65 @@ public class MultiblockWorldRegistry {
}
detachedParts.remove(part);
if(orphanedParts.contains(part)) {
synchronized(orphanedPartsMutex) {
if (orphanedParts.contains(part))
{
synchronized (orphanedPartsMutex)
{
orphanedParts.remove(part);
}
}
part.assertDetached();
}
/**
* Called when the world which this World Registry represents is fully unloaded from the system.
* Does some housekeeping just to be nice.
* Called when the world which this World Registry represents is fully
* unloaded from the system. Does some housekeeping just to be nice.
*/
public void onWorldUnloaded() {
public void onWorldUnloaded()
{
controllers.clear();
deadControllers.clear();
dirtyControllers.clear();
detachedParts.clear();
synchronized(partsAwaitingChunkLoadMutex) {
synchronized (partsAwaitingChunkLoadMutex)
{
partsAwaitingChunkLoad.clear();
}
synchronized(orphanedPartsMutex) {
synchronized (orphanedPartsMutex)
{
orphanedParts.clear();
}
worldObj = null;
}
/**
* Called when a chunk has finished loading. Adds all of the parts which are awaiting
* load to the list of parts which are orphans and therefore will be added to machines
* after the next world tick.
* Called when a chunk has finished loading. Adds all of the parts which are
* awaiting load to the list of parts which are orphans and therefore will
* be added to machines after the next world tick.
*
* @param chunkX Chunk X coordinate (world coordate >> 4) of the chunk that was loaded
* @param chunkZ Chunk Z coordinate (world coordate >> 4) of the chunk that was loaded
* @param chunkX
* Chunk X coordinate (world coordate >> 4) of the chunk that was
* loaded
* @param chunkZ
* Chunk Z coordinate (world coordate >> 4) of the chunk that was
* loaded
*/
public void onChunkLoaded(int chunkX, int chunkZ) {
public void onChunkLoaded(int chunkX, int chunkZ)
{
long chunkHash = ChunkCoordIntPair.chunkXZ2Int(chunkX, chunkZ);
if(partsAwaitingChunkLoad.containsKey(chunkHash)) {
synchronized(partsAwaitingChunkLoadMutex) {
if(partsAwaitingChunkLoad.containsKey(chunkHash)) {
addAllOrphanedPartsThreadsafe(partsAwaitingChunkLoad.get(chunkHash));
if (partsAwaitingChunkLoad.containsKey(chunkHash))
{
synchronized (partsAwaitingChunkLoadMutex)
{
if (partsAwaitingChunkLoad.containsKey(chunkHash))
{
addAllOrphanedPartsThreadsafe(partsAwaitingChunkLoad
.get(chunkHash));
partsAwaitingChunkLoad.remove(chunkHash);
}
}
@ -369,49 +475,64 @@ public class MultiblockWorldRegistry {
}
/**
* Registers a controller as dead. It will be cleaned up at the end of the next world tick.
* Note that a controller must shed all of its blocks before being marked as dead, or the system
* will complain at you.
* Registers a controller as dead. It will be cleaned up at the end of the
* next world tick. Note that a controller must shed all of its blocks
* before being marked as dead, or the system will complain at you.
*
* @param deadController The controller which is dead.
* @param deadController
* The controller which is dead.
*/
public void addDeadController(MultiblockControllerBase deadController) {
public void addDeadController(MultiblockControllerBase deadController)
{
this.deadControllers.add(deadController);
}
/**
* Registers a controller as dirty - its list of attached blocks has changed, and it
* must be re-checked for assembly and, possibly, for orphans.
* Registers a controller as dirty - its list of attached blocks has
* changed, and it must be re-checked for assembly and, possibly, for
* orphans.
*
* @param dirtyController The dirty controller.
* @param dirtyController
* The dirty controller.
*/
public void addDirtyController(MultiblockControllerBase dirtyController) {
public void addDirtyController(MultiblockControllerBase dirtyController)
{
this.dirtyControllers.add(dirtyController);
}
/**
* Use this only if you know what you're doing. You should rarely need to iterate
* over all controllers in a world!
* Use this only if you know what you're doing. You should rarely need to
* iterate over all controllers in a world!
*
* @return An (unmodifiable) set of controllers which are active in this world.
* @return An (unmodifiable) set of controllers which are active in this
* world.
*/
public Set<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,28 +1,22 @@
package erogenousbeef.coreTR.multiblock.rectangular;
public enum PartPosition {
Unknown,
Interior,
FrameCorner,
Frame,
TopFace,
BottomFace,
NorthFace,
SouthFace,
EastFace,
WestFace;
public boolean isFace(PartPosition position) {
switch(position) {
case TopFace:
case BottomFace:
case NorthFace:
case SouthFace:
case EastFace:
case WestFace:
return true;
default:
return false;
public enum PartPosition
{
Unknown, Interior, FrameCorner, Frame, TopFace, BottomFace, NorthFace, SouthFace, EastFace, WestFace;
public boolean isFace(PartPosition position)
{
switch (position)
{
case TopFace:
case BottomFace:
case NorthFace:
case SouthFace:
case EastFace:
case WestFace:
return true;
default:
return false;
}
}
}

View file

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

View file

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

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

View file

@ -8,23 +8,27 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
public class AchievementMod extends Achievement{
public class AchievementMod extends Achievement {
public static List<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

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

View file

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

View file

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

View file

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

View file

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

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

View file

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

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,115 +17,146 @@ import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileMachineCasing;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBlastFurnace extends BlockContainer {
public class BlockBlastFurnace extends BlockContainer{
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockBlastFurnace(Material material)
public BlockBlastFurnace(Material material)
{
super(material);
setCreativeTab(TechRebornCreativeTab.instance);
setBlockName("techreborn.blastfurnace");
setHardness(2F);
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileBlastFurnace();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (!player.isSneaking())
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){
if(world.getTileEntity(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ) instanceof TileMachineCasing){
TileMachineCasing casing = (TileMachineCasing) world.getTileEntity(x + direction.offsetX, y + direction.offsetY, z + direction.offsetZ);
if(casing.getMultiblockController() != null && casing.getMultiblockController().isAssembled()){
player.openGui(Core.INSTANCE, GuiHandler.blastFurnaceID, world, x, y, z);
}
}
}
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
this.iconFront = icon.registerIcon("techreborn:machine/industrial_blast_furnace_front_off");
this.iconTop = icon.registerIcon("techreborn:machine/machine_side");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_side");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop: (side == metadata ? this.iconFront : this.blockIcon));
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_)
{
return new TileBlastFurnace();
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
if (world.getTileEntity(x + direction.offsetX, y
+ direction.offsetY, z + direction.offsetZ) instanceof TileMachineCasing)
{
TileMachineCasing casing = (TileMachineCasing) world
.getTileEntity(x + direction.offsetX, y
+ direction.offsetY, z + direction.offsetZ);
if (casing.getMultiblockController() != null
&& casing.getMultiblockController().isAssembled())
{
player.openGui(Core.INSTANCE,
GuiHandler.blastFurnaceID, world, x, y, z);
}
}
}
return true;
}
public void onBlockAdded(World world, int x, int y, int z) {
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon)
{
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
this.iconFront = icon
.registerIcon("techreborn:machine/industrial_blast_furnace_front_off");
this.iconTop = icon.registerIcon("techreborn:machine/machine_side");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_side");
}
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
}
private void setDefaultDirection(World world, int x, int y, int z) {
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
if(!world.isRemote) {
Block block1 = world.getBlock(x, y, z - 1);
Block block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
}
byte b = 3;
public void onBlockAdded(World world, int x, int y, int z)
{
if(block1.func_149730_j() && !block2.func_149730_j()) {
b = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j()) {
b = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j()) {
b = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j()) {
b = 4;
}
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
world.setBlockMetadataWithNotify(x, y, z, b, 2);
}
}
private void setDefaultDirection(World world, int x, int y, int z)
{
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
if (!world.isRemote)
{
Block block1 = world.getBlock(x, y, z - 1);
Block block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
byte b = 3;
if(l == 0) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(l == 1) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(l == 2) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(l == 3) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
if (block1.func_149730_j() && !block2.func_149730_j())
{
b = 3;
}
if (block2.func_149730_j() && !block1.func_149730_j())
{
b = 2;
}
if (block3.func_149730_j() && !block4.func_149730_j())
{
b = 5;
}
if (block4.func_149730_j() && !block3.func_149730_j())
{
b = 4;
}
}
world.setBlockMetadataWithNotify(x, y, z, b, 2);
}
}
public void onBlockPlacedBy(World world, int x, int y, int z,
EntityLivingBase player, ItemStack itemstack)
{
int l = MathHelper
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if (l == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if (l == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if (l == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
}

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,104 +14,131 @@ import net.minecraft.world.World;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.tiles.TileCentrifuge;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCentrifuge extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockCentrifuge() {
super(Material.piston);
setHardness(2F);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileCentrifuge();
}
public BlockCentrifuge()
{
super(Material.piston);
setHardness(2F);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.centrifugeID, world, x, y, z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
this.iconFront = icon.registerIcon("techreborn:machine/industrial_blast_furnace_front_off");
this.iconTop = icon.registerIcon("techreborn:machine/industrial_grinder_top_on");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_side");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
{
return new TileCentrifuge();
}
return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop: (side == metadata ? this.iconFront : this.blockIcon));
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.centrifugeID, world, x, y,
z);
return true;
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon)
{
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
this.iconFront = icon
.registerIcon("techreborn:machine/industrial_blast_furnace_front_off");
this.iconTop = icon
.registerIcon("techreborn:machine/industrial_grinder_top_on");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_side");
}
public void onBlockAdded(World world, int x, int y, int z) {
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
}
private void setDefaultDirection(World world, int x, int y, int z) {
}
if(!world.isRemote) {
Block block1 = world.getBlock(x, y, z - 1);
Block block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
public void onBlockAdded(World world, int x, int y, int z)
{
byte b = 3;
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
if(block1.func_149730_j() && !block2.func_149730_j()) {
b = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j()) {
b = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j()) {
b = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j()) {
b = 4;
}
}
world.setBlockMetadataWithNotify(x, y, z, b, 2);
private void setDefaultDirection(World world, int x, int y, int z)
{
}
if (!world.isRemote)
{
Block block1 = world.getBlock(x, y, z - 1);
Block block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
byte b = 3;
int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
if (block1.func_149730_j() && !block2.func_149730_j())
{
b = 3;
}
if (block2.func_149730_j() && !block1.func_149730_j())
{
b = 2;
}
if (block3.func_149730_j() && !block4.func_149730_j())
{
b = 5;
}
if (block4.func_149730_j() && !block3.func_149730_j())
{
b = 4;
}
if(l == 0) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(l == 1) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(l == 2) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(l == 3) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
world.setBlockMetadataWithNotify(x, y, z, b, 2);
}
}
}
public void onBlockPlacedBy(World world, int x, int y, int z,
EntityLivingBase player, ItemStack itemstack)
{
int l = MathHelper
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if (l == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if (l == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if (l == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
}

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

View file

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

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

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

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,106 +15,132 @@ import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.TileRollingMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockRollingMachine extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockRollingMachine(Material material) {
super(material.piston);
setCreativeTab(TechRebornCreativeTab.instance);
setBlockName("techreborn.rollingmachine");
setHardness(2f);
}
public BlockRollingMachine(Material material)
{
super(material.piston);
setCreativeTab(TechRebornCreativeTab.instance);
setBlockName("techreborn.rollingmachine");
setHardness(2f);
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileRollingMachine();
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
{
return new TileRollingMachine();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.rollingMachineID, world, x, y, z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
this.iconFront = icon.registerIcon("techreborn:machine/machine_side");
this.iconTop = icon.registerIcon("techreborn:machine/rollingmachine_top");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_side");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.rollingMachineID, world,
x, y, z);
return true;
}
return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop: (side == metadata ? this.iconFront : this.blockIcon));
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon)
{
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
this.iconFront = icon.registerIcon("techreborn:machine/machine_side");
this.iconTop = icon
.registerIcon("techreborn:machine/rollingmachine_top");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_side");
}
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
public void onBlockAdded(World world, int x, int y, int z) {
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
}
}
private void setDefaultDirection(World world, int x, int y, int z) {
public void onBlockAdded(World world, int x, int y, int z)
{
if(!world.isRemote) {
Block block1 = world.getBlock(x, y, z - 1);
Block block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
byte b = 3;
}
if(block1.func_149730_j() && !block2.func_149730_j()) {
b = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j()) {
b = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j()) {
b = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j()) {
b = 4;
}
private void setDefaultDirection(World world, int x, int y, int z)
{
world.setBlockMetadataWithNotify(x, y, z, b, 2);
if (!world.isRemote)
{
Block block1 = world.getBlock(x, y, z - 1);
Block block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
}
byte b = 3;
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
if (block1.func_149730_j() && !block2.func_149730_j())
{
b = 3;
}
if (block2.func_149730_j() && !block1.func_149730_j())
{
b = 2;
}
if (block3.func_149730_j() && !block4.func_149730_j())
{
b = 5;
}
if (block4.func_149730_j() && !block3.func_149730_j())
{
b = 4;
}
int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, b, 2);
if(l == 0) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(l == 1) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(l == 2) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(l == 3) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
}
}
public void onBlockPlacedBy(World world, int x, int y, int z,
EntityLivingBase player, ItemStack itemstack)
{
int l = MathHelper
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if (l == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if (l == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if (l == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
}

View file

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

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,113 +18,137 @@ import net.minecraft.world.World;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.tiles.TileThermalGenerator;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockThermalGenerator extends BlockContainer {
@SideOnly(Side.CLIENT)
private IIcon iconFront;
@SideOnly(Side.CLIENT)
private IIcon iconTop;
@SideOnly(Side.CLIENT)
private IIcon iconBottom;
public BlockThermalGenerator() {
super(Material.piston);
setHardness(2f);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon) {
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
this.iconFront = icon.registerIcon("techreborn:machine/machine_side");
this.iconTop = icon.registerIcon("techreborn:machine/ThermalGenerator_top");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_side");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata) {
public BlockThermalGenerator()
{
super(Material.piston);
setHardness(2f);
}
return metadata == 0 && side == 3 ? this.iconFront : side == 1 ? this.iconTop : (side == 0 ? this.iconTop: (side == metadata ? this.iconFront : this.blockIcon));
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister icon)
{
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
this.iconFront = icon.registerIcon("techreborn:machine/machine_side");
this.iconTop = icon
.registerIcon("techreborn:machine/ThermalGenerator_top");
this.iconBottom = icon.registerIcon("techreborn:machine/machine_side");
}
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata)
{
public void onBlockAdded(World world, int x, int y, int z) {
return metadata == 0 && side == 3 ? this.iconFront
: side == 1 ? this.iconTop : (side == 0 ? this.iconTop
: (side == metadata ? this.iconFront : this.blockIcon));
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
}
}
private void setDefaultDirection(World world, int x, int y, int z) {
public void onBlockAdded(World world, int x, int y, int z)
{
if(!world.isRemote) {
Block block1 = world.getBlock(x, y, z - 1);
Block block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
super.onBlockAdded(world, x, y, z);
this.setDefaultDirection(world, x, y, z);
byte b = 3;
}
if(block1.func_149730_j() && !block2.func_149730_j()) {
b = 3;
}
if(block2.func_149730_j() && !block1.func_149730_j()) {
b = 2;
}
if(block3.func_149730_j() && !block4.func_149730_j()) {
b = 5;
}
if(block4.func_149730_j() && !block3.func_149730_j()) {
b = 4;
}
private void setDefaultDirection(World world, int x, int y, int z)
{
world.setBlockMetadataWithNotify(x, y, z, b, 2);
if (!world.isRemote)
{
Block block1 = world.getBlock(x, y, z - 1);
Block block2 = world.getBlock(x, y, z + 1);
Block block3 = world.getBlock(x - 1, y, z);
Block block4 = world.getBlock(x + 1, y, z);
}
byte b = 3;
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
if (block1.func_149730_j() && !block2.func_149730_j())
{
b = 3;
}
if (block2.func_149730_j() && !block1.func_149730_j())
{
b = 2;
}
if (block3.func_149730_j() && !block4.func_149730_j())
{
b = 5;
}
if (block4.func_149730_j() && !block3.func_149730_j())
{
b = 4;
}
int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, b, 2);
if(l == 0) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if(l == 1) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if(l == 2) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if(l == 3) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
}
}
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileThermalGenerator();
}
public void onBlockPlacedBy(World world, int x, int y, int z,
EntityLivingBase player, ItemStack itemstack)
{
int l = MathHelper
.floor_double((double) (player.rotationYaw * 4.0F / 360F) + 0.5D) & 3;
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.thermalGeneratorID, world, x, y, z);
return true;
}
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if (l == 1)
{
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if (l == 2)
{
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if (l == 3)
{
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
//TODO change when added crafting
return Item.getItemFromBlock(Blocks.furnace);
}
}
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
{
return new TileThermalGenerator();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z,
EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.thermalGeneratorID, world,
x, y, z);
return true;
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_,
int p_149650_3_)
{
// TODO change when added crafting
return Item.getItemFromBlock(Blocks.furnace);
}
}

View file

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

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 boolean mCanInsertItem;
public boolean mCanStackItem;
public int mMaxStacksize = 127;
public SlotFake(IInventory par1iInventory, int par2, int par3, int par4,
boolean aCanInsertItem, boolean aCanStackItem, int aMaxStacksize)
{
super(par1iInventory, par2, par3, par4);
this.mCanInsertItem = aCanInsertItem;
this.mCanStackItem = aCanStackItem;
this.mMaxStacksize = aMaxStacksize;
}
public SlotFake(IInventory par1iInventory, int par2, int par3, int par4, boolean aCanInsertItem, boolean aCanStackItem, int aMaxStacksize) {
super(par1iInventory, par2, par3, par4);
this.mCanInsertItem = aCanInsertItem;
this.mCanStackItem = aCanStackItem;
this.mMaxStacksize = aMaxStacksize;
}
public boolean isItemValid(ItemStack par1ItemStack)
{
return this.mCanInsertItem;
}
public boolean isItemValid(ItemStack par1ItemStack) {
return this.mCanInsertItem;
}
public int getSlotStackLimit()
{
return this.mMaxStacksize;
}
public int getSlotStackLimit() {
return this.mMaxStacksize;
}
public boolean getHasStack()
{
return false;
}
public boolean getHasStack() {
return false;
}
public ItemStack decrStackSize(int par1) {
return !this.mCanStackItem ? null : super.decrStackSize(par1);
}
public ItemStack decrStackSize(int par1)
{
return !this.mCanStackItem ? null : super.decrStackSize(par1);
}
}

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) {
super(par1iInventory, par2, par3, par4);
}
public SlotInput(IInventory par1iInventory, int par2, int par3, int par4)
{
super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
}
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
public int getSlotStackLimit() {
return 64;
}
public int getSlotStackLimit()
{
return 64;
}
}

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) {
super(par1iInventory, par2, par3, par4);
}
public SlotOutput(IInventory par1iInventory, int par2, int par3, int par4)
{
super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
}
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
public int getSlotStackLimit() {
return 64;
}
public int getSlotStackLimit()
{
return 64;
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,28 +9,37 @@ import techreborn.tiles.TileCentrifuge;
public class GuiCentrifuge extends GuiContainer {
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/centrifuge.png");
private static final ResourceLocation texture = new ResourceLocation(
"techreborn", "textures/gui/centrifuge.png");
TileCentrifuge centrifuge;
TileCentrifuge centrifuge;
public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge) {
super(new ContainerCentrifuge(tileCentrifuge, player));
this.xSize = 176;
this.ySize = 167;
centrifuge = tileCentrifuge;
}
public GuiCentrifuge(EntityPlayer player, TileCentrifuge tileCentrifuge)
{
super(new ContainerCentrifuge(tileCentrifuge, player));
this.xSize = 176;
this.ySize = 167;
centrifuge = tileCentrifuge;
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_,
int p_146976_2_, int p_146976_3_)
{
this.mc.getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
this.fontRendererObj.drawString("Centrifuge", 110, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(centrifuge.tickTime + " " + centrifuge.isRunning, 110, this.ySize - 96 + 2, 4210752);
}
protected void drawGuiContainerForegroundLayer(int p_146979_1_,
int p_146979_2_)
{
this.fontRendererObj.drawString("Centrifuge", 110, 6, 4210752);
this.fontRendererObj.drawString(
I18n.format("container.inventory", new Object[0]), 8,
this.ySize - 96 + 2, 4210752);
this.fontRendererObj.drawString(centrifuge.tickTime + " "
+ centrifuge.isRunning, 110, this.ySize - 96 + 2, 4210752);
}
}

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

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,95 +11,116 @@ import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import techreborn.api.RollingMachineRecipe;
import techreborn.client.gui.GuiRollingMachine;
import java.awt.*;
import java.util.List;
import codechicken.nei.NEIServerUtils;
import codechicken.nei.recipe.ShapelessRecipeHandler;
public class ShapelessRollingMachineHandler extends ShapelessRecipeHandler {
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiRollingMachine.class;
}
@Override
public Class<? extends GuiContainer> getGuiClass()
{
return GuiRollingMachine.class;
}
public String getRecipeName() {
return "Shapeless Rolling Machine";
}
public String getRecipeName()
{
return "Shapeless Rolling Machine";
}
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18), "rollingcraftingnoshape"));
}
@Override
public void loadTransferRects()
{
transferRects.add(new RecipeTransferRect(new Rectangle(84, 23, 24, 18),
"rollingcraftingnoshape"));
}
@Override
public String getOverlayIdentifier() {
return "rollingcraftingnoshape";
}
@Override
public String getOverlayIdentifier()
{
return "rollingcraftingnoshape";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("rollingcraftingnoshape") && getClass() == ShapelessRollingMachineHandler.class) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if (outputId.equals("rollingcraftingnoshape")
&& getClass() == ShapelessRollingMachineHandler.class)
{
List<IRecipe> allrecipes = RollingMachineRecipe.instance
.getRecipeList();
for (IRecipe irecipe : allrecipes)
{
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
if (recipe == null)
continue;
arecipes.add(recipe);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
arecipes.add(recipe);
}
} else
{
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result) {
List<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);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
@Override
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);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
if (recipe == null)
continue;
arecipes.add(recipe);
}
}
}
arecipes.add(recipe);
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
List<IRecipe> allrecipes = RollingMachineRecipe.instance.getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
@Override
public void loadUsageRecipes(ItemStack ingredient)
{
List<IRecipe> allrecipes = RollingMachineRecipe.instance
.getRecipeList();
for (IRecipe irecipe : allrecipes)
{
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
if (recipe == null)
continue;
if (recipe.contains(recipe.ingredients, ingredient)) {
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
if (recipe.contains(recipe.ingredients, ingredient))
{
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe) {
if(recipe.recipeItems == null)
return null;
private CachedShapelessRecipe shapelessRecipe(ShapelessRecipes recipe)
{
if (recipe.recipeItems == null)
return null;
return new CachedShapelessRecipe(recipe.recipeItems, recipe.getRecipeOutput());
}
return new CachedShapelessRecipe(recipe.recipeItems,
recipe.getRecipeOutput());
}
}

View file

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

View file

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

View file

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

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

View file

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

View file

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

View file

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

View file

@ -1,104 +1,150 @@
package techreborn.init;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import techreborn.blocks.*;
import techreborn.blocks.BlockBlastFurnace;
import techreborn.blocks.BlockCentrifuge;
import techreborn.blocks.BlockMachineCasing;
import techreborn.blocks.BlockOre;
import techreborn.blocks.BlockQuantumChest;
import techreborn.blocks.BlockQuantumTank;
import techreborn.blocks.BlockRollingMachine;
import techreborn.blocks.BlockStorage;
import techreborn.blocks.BlockThermalGenerator;
import techreborn.client.TechRebornCreativeTab;
import techreborn.itemblocks.ItemBlockMachineCasing;
import techreborn.itemblocks.ItemBlockOre;
import techreborn.itemblocks.ItemBlockQuantumChest;
import techreborn.itemblocks.ItemBlockQuantumTank;
import techreborn.itemblocks.ItemBlockStorage;
import techreborn.tiles.*;
import techreborn.tiles.TileBlastFurnace;
import techreborn.tiles.TileCentrifuge;
import techreborn.tiles.TileMachineCasing;
import techreborn.tiles.TileQuantumChest;
import techreborn.tiles.TileQuantumTank;
import techreborn.tiles.TileRollingMachine;
import techreborn.tiles.TileThermalGenerator;
import techreborn.util.LogHelper;
import cpw.mods.fml.common.registry.GameRegistry;
public class ModBlocks {
public static Block thermalGenerator;
public static Block quantumTank;
public static Block quantumChest;
public static Block centrifuge;
public static Block RollingMachine;
public static Block MachineCasing;
public static Block BlastFurnace;
public static Block thermalGenerator;
public static Block quantumTank;
public static Block quantumChest;
public static Block centrifuge;
public static Block RollingMachine;
public static Block MachineCasing;
public static Block BlastFurnace;
public static Block ore;
public static Block storage;
public static Block ore;
public static Block storage;
public static void init() {
thermalGenerator = new BlockThermalGenerator().setBlockName("techreborn.thermalGenerator").setBlockTextureName("techreborn:ThermalGenerator_other").setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(thermalGenerator, "techreborn.thermalGenerator");
GameRegistry.registerTileEntity(TileThermalGenerator.class, "TileThermalGenerator");
public static void init()
{
thermalGenerator = new BlockThermalGenerator()
.setBlockName("techreborn.thermalGenerator")
.setBlockTextureName("techreborn:ThermalGenerator_other")
.setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(thermalGenerator,
"techreborn.thermalGenerator");
GameRegistry.registerTileEntity(TileThermalGenerator.class,
"TileThermalGenerator");
quantumTank = new BlockQuantumTank().setBlockName("techreborn.quantumTank").setBlockTextureName("techreborn:quantumTank").setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(quantumTank, ItemBlockQuantumTank.class, "techreborn.quantumTank");
GameRegistry.registerTileEntity(TileQuantumTank.class, "TileQuantumTank");
quantumTank = new BlockQuantumTank()
.setBlockName("techreborn.quantumTank")
.setBlockTextureName("techreborn:quantumTank")
.setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(quantumTank, ItemBlockQuantumTank.class,
"techreborn.quantumTank");
GameRegistry.registerTileEntity(TileQuantumTank.class,
"TileQuantumTank");
quantumChest = new BlockQuantumChest().setBlockName("techreborn.quantumChest").setBlockTextureName("techreborn:quantumChest").setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(quantumChest, ItemBlockQuantumChest.class, "techreborn.quantumChest");
GameRegistry.registerTileEntity(TileQuantumChest.class, "TileQuantumChest");
quantumChest = new BlockQuantumChest()
.setBlockName("techreborn.quantumChest")
.setBlockTextureName("techreborn:quantumChest")
.setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(quantumChest, ItemBlockQuantumChest.class,
"techreborn.quantumChest");
GameRegistry.registerTileEntity(TileQuantumChest.class,
"TileQuantumChest");
centrifuge = new BlockCentrifuge().setBlockName("techreborn.centrifuge").setBlockTextureName("techreborn:centrifuge").setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge");
GameRegistry.registerTileEntity(TileCentrifuge.class, "TileCentrifuge");
centrifuge = new BlockCentrifuge()
.setBlockName("techreborn.centrifuge")
.setBlockTextureName("techreborn:centrifuge")
.setCreativeTab(TechRebornCreativeTab.instance);
GameRegistry.registerBlock(centrifuge, "techreborn.centrifuge");
GameRegistry.registerTileEntity(TileCentrifuge.class, "TileCentrifuge");
RollingMachine = new BlockRollingMachine(Material.piston);
GameRegistry.registerBlock(RollingMachine, "rollingmachine");
GameRegistry.registerTileEntity(TileRollingMachine.class, "TileRollingMachine");
BlastFurnace = new BlockBlastFurnace(Material.piston);
GameRegistry.registerBlock(BlastFurnace, "blastFurnace");
GameRegistry.registerTileEntity(TileBlastFurnace.class, "TileBlastFurnace");
MachineCasing = new BlockMachineCasing(Material.piston);
GameRegistry.registerBlock(MachineCasing, ItemBlockMachineCasing.class, "machinecasing");
GameRegistry.registerTileEntity(TileMachineCasing.class, "TileMachineCasing");
RollingMachine = new BlockRollingMachine(Material.piston);
GameRegistry.registerBlock(RollingMachine, "rollingmachine");
GameRegistry.registerTileEntity(TileRollingMachine.class,
"TileRollingMachine");
ore = new BlockOre(Material.rock);
GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore");
LogHelper.info("TechReborns Blocks Loaded");
BlastFurnace = new BlockBlastFurnace(Material.piston);
GameRegistry.registerBlock(BlastFurnace, "blastFurnace");
GameRegistry.registerTileEntity(TileBlastFurnace.class,
"TileBlastFurnace");
storage = new BlockStorage(Material.rock);
GameRegistry.registerBlock(storage, ItemBlockStorage.class, "techreborn.storage");
LogHelper.info("TechReborns Blocks Loaded");
MachineCasing = new BlockMachineCasing(Material.piston);
GameRegistry.registerBlock(MachineCasing, ItemBlockMachineCasing.class,
"machinecasing");
GameRegistry.registerTileEntity(TileMachineCasing.class,
"TileMachineCasing");
registerOreDict();
}
ore = new BlockOre(Material.rock);
GameRegistry.registerBlock(ore, ItemBlockOre.class, "techreborn.ore");
LogHelper.info("TechReborns Blocks Loaded");
public static void registerOreDict() {
OreDictionary.registerOre("oreGalena", new ItemStack(ore, 1, 0));
OreDictionary.registerOre("oreIridium", new ItemStack(ore, 1, 1));
OreDictionary.registerOre("oreRuby", new ItemStack(ore, 1, 2));
OreDictionary.registerOre("oreSapphire", new ItemStack(ore, 1, 3));
OreDictionary.registerOre("oreBauxite", new ItemStack(ore, 1, 4));
OreDictionary.registerOre("orePyrite", new ItemStack(ore, 1, 5));
OreDictionary.registerOre("oreCinnabar", new ItemStack(ore, 1, 6));
OreDictionary.registerOre("oreSphalerite", new ItemStack(ore, 1, 7));
OreDictionary.registerOre("oreTungston", new ItemStack(ore, 1, 8));
OreDictionary.registerOre("oreSheldonite", new ItemStack(ore, 1, 9));
OreDictionary.registerOre("oreOlivine", new ItemStack(ore, 1, 10));
OreDictionary.registerOre("oreSodalite", new ItemStack(ore, 1, 11));
storage = new BlockStorage(Material.rock);
GameRegistry.registerBlock(storage, ItemBlockStorage.class,
"techreborn.storage");
LogHelper.info("TechReborns Blocks Loaded");
OreDictionary.registerOre("blockSilver", new ItemStack(storage, 1, 0));
OreDictionary.registerOre("blockAluminium", new ItemStack(storage, 1, 1));
OreDictionary.registerOre("blockTitanium", new ItemStack(storage, 1, 2));
OreDictionary.registerOre("blockSapphire", new ItemStack(storage, 1, 3));
OreDictionary.registerOre("blockRuby", new ItemStack(storage, 1, 4));
OreDictionary.registerOre("blockGreenSapphire", new ItemStack(storage, 1, 5));
OreDictionary.registerOre("blockChrome", new ItemStack(storage, 1, 6));
OreDictionary.registerOre("blockElectrum", new ItemStack(storage, 1, 7));
OreDictionary.registerOre("blockTungsten", new ItemStack(storage, 1, 8));
OreDictionary.registerOre("blockLead", new ItemStack(storage, 1, 9));
OreDictionary.registerOre("blockZinc", new ItemStack(storage, 1, 10));
OreDictionary.registerOre("blockBrass", new ItemStack(storage, 1, 11));
OreDictionary.registerOre("blockSteel", new ItemStack(storage, 1, 12));
OreDictionary.registerOre("blockPlatinum", new ItemStack(storage, 1, 13));
OreDictionary.registerOre("blockNickel", new ItemStack(storage, 1, 14));
OreDictionary.registerOre("blockInvar", new ItemStack(storage, 1, 15));
registerOreDict();
}
}
public static void registerOreDict()
{
OreDictionary.registerOre("oreGalena", new ItemStack(ore, 1, 0));
OreDictionary.registerOre("oreIridium", new ItemStack(ore, 1, 1));
OreDictionary.registerOre("oreRuby", new ItemStack(ore, 1, 2));
OreDictionary.registerOre("oreSapphire", new ItemStack(ore, 1, 3));
OreDictionary.registerOre("oreBauxite", new ItemStack(ore, 1, 4));
OreDictionary.registerOre("orePyrite", new ItemStack(ore, 1, 5));
OreDictionary.registerOre("oreCinnabar", new ItemStack(ore, 1, 6));
OreDictionary.registerOre("oreSphalerite", new ItemStack(ore, 1, 7));
OreDictionary.registerOre("oreTungston", new ItemStack(ore, 1, 8));
OreDictionary.registerOre("oreSheldonite", new ItemStack(ore, 1, 9));
OreDictionary.registerOre("oreOlivine", new ItemStack(ore, 1, 10));
OreDictionary.registerOre("oreSodalite", new ItemStack(ore, 1, 11));
OreDictionary.registerOre("blockSilver", new ItemStack(storage, 1, 0));
OreDictionary.registerOre("blockAluminium",
new ItemStack(storage, 1, 1));
OreDictionary
.registerOre("blockTitanium", new ItemStack(storage, 1, 2));
OreDictionary
.registerOre("blockSapphire", new ItemStack(storage, 1, 3));
OreDictionary.registerOre("blockRuby", new ItemStack(storage, 1, 4));
OreDictionary.registerOre("blockGreenSapphire", new ItemStack(storage,
1, 5));
OreDictionary.registerOre("blockChrome", new ItemStack(storage, 1, 6));
OreDictionary
.registerOre("blockElectrum", new ItemStack(storage, 1, 7));
OreDictionary
.registerOre("blockTungsten", new ItemStack(storage, 1, 8));
OreDictionary.registerOre("blockLead", new ItemStack(storage, 1, 9));
OreDictionary.registerOre("blockZinc", new ItemStack(storage, 1, 10));
OreDictionary.registerOre("blockBrass", new ItemStack(storage, 1, 11));
OreDictionary.registerOre("blockSteel", new ItemStack(storage, 1, 12));
OreDictionary.registerOre("blockPlatinum",
new ItemStack(storage, 1, 13));
OreDictionary.registerOre("blockNickel", new ItemStack(storage, 1, 14));
OreDictionary.registerOre("blockInvar", new ItemStack(storage, 1, 15));
}
}

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

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

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) {
super(ModBlocks.ore, ModBlocks.ore, BlockOre.types);
}
@Override
public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) {
return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a).getAchievementOnCraft(stack, player, matrix) : null;
public ItemBlockOre(Block block)
{
super(ModBlocks.ore, ModBlocks.ore, BlockOre.types);
}
@Override
public Achievement getAchievementOnPickup(ItemStack stack, EntityPlayer player, EntityItem item) {
return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a).getAchievementOnPickup(stack, player, item) : null;
public Achievement getAchievementOnCraft(ItemStack stack,
EntityPlayer player, IInventory matrix)
{
return field_150939_a instanceof ICraftAchievement ? ((ICraftAchievement) field_150939_a)
.getAchievementOnCraft(stack, player, matrix) : null;
}
@Override
public Achievement getAchievementOnPickup(ItemStack stack,
EntityPlayer player, EntityItem item)
{
return field_150939_a instanceof IPickupAchievement ? ((IPickupAchievement) field_150939_a)
.getAchievementOnPickup(stack, player, item) : null;
}
}

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

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

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

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

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

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

View file

@ -9,25 +9,27 @@ import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
public class ItemTechPda extends Item{
public class ItemTechPda extends Item {
public ItemTechPda()
{
setCreativeTab(TechRebornCreativeTab.instance);
setUnlocalizedName("techreborn.pda");
setMaxStackSize(1);
}
@Override
public void registerIcons(IIconRegister iconRegister)
{
itemIcon = iconRegister.registerIcon("techreborn:" + "tool/pda");
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
@Override
public void registerIcons(IIconRegister iconRegister)
{
player.openGui(Core.INSTANCE, GuiHandler.pdaID, world, (int)player.posX, (int)player.posY, (int)player.posY);
itemIcon = iconRegister.registerIcon("techreborn:" + "tool/pda");
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world,
EntityPlayer player)
{
player.openGui(Core.INSTANCE, GuiHandler.pdaID, world,
(int) player.posX, (int) player.posY, (int) player.posY);
return itemStack;
}

View file

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

View file

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

View file

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

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

View file

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

View file

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

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

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

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);
}

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