Loads of javadocs, cleaned up Gas API code, removed old induction interfaces, made configurable machines notify neighbor when configuration changes, added functionality for GasStack-based ChemicaIInputs.

This commit is contained in:
Aidan C. Brady 2013-12-23 17:06:22 -05:00
parent 824a3e0306
commit 6df7544540
36 changed files with 610 additions and 111 deletions

View file

@ -1,51 +1,96 @@
package mekanism.api;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
/**
* An input of gasses for the Chemical Infuser.
* @author aidancbrady
*
*/
public class ChemicalInput
{
public Gas leftGas;
public Gas rightGas;
/** The left gas of this chemical input */
public GasStack leftGas;
public ChemicalInput(Gas left, Gas right)
/** The right gas of this chemical input */
public GasStack rightGas;
/**
* Creates a chemical input with two defined gasses of the Chemical Infuser.
* @param left - left gas
* @param right - right gas
*/
public ChemicalInput(GasStack left, GasStack right)
{
leftGas = left;
rightGas = right;
}
/**
* If this is a valid
* @return
*/
public boolean isValid()
{
return leftGas != null && rightGas != null;
}
@Override
public boolean equals(Object obj)
/**
* Whether or not the defined input contains the same gasses and at least the required amount of the defined gasses as this input.
* @param input - input to check
* @return if the input meets this input's requirements
*/
public boolean meetsInput(ChemicalInput input)
{
if(!(obj instanceof ChemicalInput))
return meets(input) || meets(input.swap());
}
/**
* Swaps the right gas and left gas of this input.
* @return a swapped ChemicalInput
*/
private ChemicalInput swap()
{
return new ChemicalInput(rightGas, leftGas);
}
/**
* Draws the needed amount of gas from each tank.
* @param leftTank - left tank to draw from
* @param rightTank - right tank to draw from
*/
public void draw(GasTank leftTank, GasTank rightTank)
{
if(meets(new ChemicalInput(leftTank.getGas(), rightTank.getGas())))
{
leftTank.draw(leftGas.amount, true);
rightTank.draw(rightGas.amount, true);
}
else if(meets(new ChemicalInput(rightTank.getGas(), leftTank.getGas())))
{
leftTank.draw(rightGas.amount, true);
rightTank.draw(leftGas.amount, true);
}
}
/**
* Actual implementation of meetsInput(), performs the checks.
* @param input - input to check
* @return if the input meets this input's requirements
*/
private boolean meets(ChemicalInput input)
{
if(input == null || !input.isValid())
{
return false;
}
ChemicalInput compare = (ChemicalInput)obj;
if(leftGas == compare.leftGas && rightGas == compare.rightGas)
if(input.leftGas.getGas() != leftGas.getGas() || input.rightGas.getGas() != rightGas.getGas())
{
return true;
}
else if(leftGas == compare.rightGas && rightGas == compare.leftGas)
{
return true;
return false;
}
return false;
}
@Override
public int hashCode()
{
int code = 1;
code = 31 * code + leftGas.getID();
code = 31 * code + rightGas.getID();
return code;
return input.leftGas.amount >= leftGas.amount && input.rightGas.amount >= rightGas.amount;
}
}

View file

@ -2,6 +2,7 @@ package mekanism.api;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
@ -12,6 +13,12 @@ import net.minecraftforge.common.ForgeDirection;
import com.google.common.io.ByteArrayDataInput;
/**
* Coord4D - an integer-based way to keep track of and perform operations on blocks in a Minecraft-based environment. This also takes
* in account the dimension the coordinate is in.
* @author aidancbrady
*
*/
public class Coord4D
{
public int xCoord;
@ -20,6 +27,12 @@ public class Coord4D
public int dimensionId;
/**
* Creates a Coord4D WITHOUT a dimensionId. Don't use unless absolutely necessary.
* @param x - x coordinate
* @param y - y coordinate
* @param z - z coordinate
*/
public Coord4D(int x, int y, int z)
{
xCoord = x;
@ -29,6 +42,13 @@ public class Coord4D
dimensionId = 0;
}
/**
* Creates a Coord4D from the defined x, y, z, and dimension values.
* @param x - x coordinate
* @param y - y coordinate
* @param z - z coordinate
* @param dimension - dimension ID
*/
public Coord4D(int x, int y, int z, int dimension)
{
xCoord = x;
@ -38,19 +58,34 @@ public class Coord4D
dimensionId = dimension;
}
/**
* Gets the metadata of the block representing this Coord4D.
* @param world - world this Coord4D is in
* @return the metadata of this Coord4D's block
*/
public int getMetadata(IBlockAccess world)
{
return world.getBlockMetadata(xCoord, yCoord, zCoord);
}
/**
* Gets the block ID of the block representing this Coord4D.
* @param world - world this Coord4D is in
* @return the block ID of this Coord4D's block
*/
public int getBlockId(IBlockAccess world)
{
return world.getBlockId(xCoord, yCoord, zCoord);
}
/**
* Gets the TileEntity of the block representing this Coord4D.
* @param world - world this Coord4D is in
* @return the TileEntity of this Coord4D's block
*/
public TileEntity getTileEntity(IBlockAccess world)
{
if(!(world instanceof World && ((World)world).blockExists(xCoord, yCoord, zCoord)))
if(!(world instanceof World && exists((World)world)))
{
return null;
}
@ -58,6 +93,26 @@ public class Coord4D
return world.getBlockTileEntity(xCoord, yCoord, zCoord);
}
/**
* Gets the Block value of the block representing this Coord4D.
* @param world - world this Coord4D is in
* @return the Block value of this Coord4D's block
*/
public Block getBlock(IBlockAccess world)
{
if(!(world instanceof World && exists((World)world)))
{
return null;
}
return Block.blocksList[getBlockId(world)];
}
/**
* Writes this Coord4D's data to an NBTTagCompound.
* @param nbtTags - tag compound to write to
* @return the tag compound with this Coord4D's data
*/
public NBTTagCompound write(NBTTagCompound nbtTags)
{
nbtTags.setInteger("x", xCoord);
@ -68,13 +123,25 @@ public class Coord4D
return nbtTags;
}
/**
* Writes this Coord4D's data to an ArrayList for packet transfer.
* @param data - the ArrayList to add the data to
*/
public void write(ArrayList data)
{
data.add(xCoord);
data.add(yCoord);
data.add(zCoord);
data.add(dimensionId);
}
/**
* Translates this Coord4D by the defined x, y, and z values.
* @param x - x value to translate
* @param y - y value to translate
* @param z - z value to translate
* @return translated Coord4D
*/
public Coord4D translate(int x, int y, int z)
{
xCoord += x;
@ -84,31 +151,62 @@ public class Coord4D
return this;
}
/**
* Creates and returns a new Coord4D translated to the defined offsets of the side.
* @param side - side to translate this Coord4D to
* @return translated Coord4D
*/
public Coord4D getFromSide(ForgeDirection side)
{
return new Coord4D(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ, dimensionId);
}
/**
* Returns a new Coord4D from a defined TileEntity's xCoord, yCoord and zCoord values.
* @param tileEntity - TileEntity at the location that will represent this Coord4D
* @return the Coord4D object from the TileEntity
*/
public static Coord4D get(TileEntity tileEntity)
{
return new Coord4D(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity.worldObj.provider.dimensionId);
}
/**
* Returns a new Coord4D from a tag compound.
* @param nbtTags - tag compound to read from
* @return the Coord4D from the tag compound
*/
public static Coord4D read(NBTTagCompound nbtTags)
{
return new Coord4D(nbtTags.getInteger("x"), nbtTags.getInteger("y"), nbtTags.getInteger("z"), nbtTags.getInteger("dimensionId"));
}
/**
* Returns a new Coord4D from a ByteArrayDataInput.
* @param dataStream - data input to read from
* @return the Coord4D from the data input
*/
public static Coord4D read(ByteArrayDataInput dataStream)
{
return new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
return new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
}
/**
* Creates and returns a new Coord4D with values representing the difference between the defined Coord4D
* @param other - the Coord4D to subtract from this
* @return a Coord4D representing the distance between the defined Coord4D
*/
public Coord4D difference(Coord4D other)
{
return new Coord4D(xCoord-other.xCoord, yCoord-other.yCoord, zCoord-other.zCoord);
return new Coord4D(xCoord-other.xCoord, yCoord-other.yCoord, zCoord-other.zCoord, dimensionId);
}
/**
* A method used to find the ForgeDirection represented by the distance of the defined Coord4D. Most likely won't have many
* applicable uses.
* @param other - Coord4D to find the side difference of
* @return ForgeDirection representing the side the defined relative Coord4D is on to this
*/
public ForgeDirection sideDifference(Coord4D other)
{
Coord4D diff = difference(other);
@ -124,6 +222,11 @@ public class Coord4D
return ForgeDirection.UNKNOWN;
}
/**
* Gets the distance to a defined Coord4D.
* @param obj - the Coord4D to find the distance to
* @return the distance to the defined Coord4D
*/
public int distanceTo(Coord4D obj)
{
int subX = xCoord - obj.xCoord;
@ -132,21 +235,42 @@ public class Coord4D
return (int)MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ);
}
/**
* Whether or not the defined side of this Coord4D is visible.
* @param side - side to check
* @param world - world this Coord4D is in
* @return
*/
public boolean sideVisible(ForgeDirection side, IBlockAccess world)
{
return world.getBlockId(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ) == 0;
return world.isAirBlock(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ);
}
/**
* Steps this Coord4D in the defined side's offset without creating a new value.
* @param side - side to step towards
* @return this Coord4D
*/
public Coord4D step(ForgeDirection side)
{
return translate(side.offsetX, side.offsetY, side.offsetZ);
}
/**
* Whether or not the chunk this Coord4D is in exists and is loaded.
* @param world - world this Coord4D is in
* @return the chunk of this Coord4D
*/
public boolean exists(World world)
{
return world.getChunkProvider().chunkExists(xCoord >> 4, zCoord >> 4);
}
/**
* Gets the chunk this Coord4D is in.
* @param world - world this Coord4D is in
* @return the chunk of this Coord4D
*/
public Chunk getChunk(World world)
{
return world.getChunkFromBlockCoords(xCoord >> 4, zCoord >> 4);

View file

@ -46,21 +46,38 @@ public enum EnumColor
mcMeta = meta;
}
/**
* Gets the localized name of this color by translating the unlocalized name.
* @return localized name
*/
public String getLocalizedName()
{
return StatCollector.translateToLocal("color." + unlocalizedName);
}
/**
* Gets the name of this color with it's color prefix code.
* @return the color's name and color prefix
*/
public String getName()
{
return code + getLocalizedName();
}
/**
* Gets the 0-1 of this color's RGB value by dividing by 255 (used for OpenGL coloring).
* @param index - R:0, G:1, B:2
* @return the color value
*/
public float getColor(int index)
{
return (float)rgbCode[index]/255F;
}
/**
* Gets the value of this color mapped to MC in-game item colors present in dyes and wool.
* @return mc meta value
*/
public int getMetaValue()
{
return mcMeta;

View file

@ -30,6 +30,10 @@ public final class ItemRetriever
*
* ItemStack refinedObsidian = ItemRetriever.getItem("RefinedObsidian");
*
* Note that for items or blocks that have specific metadata you will need to create
* a new ItemStack with that specified value, as this will only return an ItemStack
* with the meta value '0.'
*
* Make sure you run this in or after FMLPostInitializationEvent runs, because most
* items are registered when FMLInitializationEvent runs. However, some items ARE
* registered later in order to hook into other mods. In a rare circumstance you may

View file

@ -4,6 +4,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
/**
* Pos3D - a way of performing operations on objects in a three dimensional environment.
* @author aidancbrady
*
*/
public class Pos3D
{
public double xPos;
@ -22,26 +27,51 @@ public class Pos3D
zPos = z;
}
/**
* Creates a Pos3D with an entity's posX, posY, and posZ values.
* @param entity - entity to create the Pos3D from
*/
public Pos3D(Entity entity)
{
this(entity.posX, entity.posY, entity.posZ);
}
/**
* Creates a Pos3D with a TileEntity's xCoord, yCoord and zCoord values.
* @param tileEntity - TileEntity to create the Pos3D from
*/
public Pos3D(TileEntity tileEntity)
{
this(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
}
/**
* Creates and returns a Pos3D with values representing the difference between this and the Pos3D in the parameters.
* @param pos - Pos3D to subtract
* @return difference of the two Pos3Ds
*/
public Pos3D diff(Pos3D pos)
{
return new Pos3D(xPos-pos.xPos, yPos-pos.yPos, zPos-pos.zPos);
}
/**
* Creates a new Pos3D from the motion of an entity.
* @param entity
* @return
*/
public static Pos3D fromMotion(Entity entity)
{
return new Pos3D(entity.motionX, entity.motionY, entity.motionZ);
}
/**
* Translates this Pos3D by the defined values.
* @param x - amount to translate on the x axis
* @param y - amount to translate on the y axis
* @param z - amount to translate on the z axis
* @return the translated Pos3D
*/
public Pos3D translate(double x, double y, double z)
{
xPos += x;
@ -51,11 +81,21 @@ public class Pos3D
return this;
}
/**
* Performs the same operation as translate(x, y, z), but with a Pos3D value instead.
* @param pos - Pos3D value to translate by
* @return translated Pos3D
*/
public Pos3D translate(Pos3D pos)
{
return translate(pos.xPos, pos.yPos, pos.zPos);
}
/**
* Returns the distance between this and the defined Pos3D.
* @param pos - the Pos3D to find the distance to
* @return the distance between this and the defined Pos3D
*/
public double distance(Pos3D pos)
{
double subX = xPos - pos.xPos;
@ -64,6 +104,11 @@ public class Pos3D
return MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ);
}
/**
* Rotates this Pos3D by the defined yaw value.
* @param yaw - yaw to rotate by
* @return rotated Pos3D
*/
public Pos3D rotateYaw(double yaw)
{
double yawRadians = Math.toRadians(yaw);
@ -80,6 +125,13 @@ public class Pos3D
return this;
}
/**
* Scales this Pos3D by the defined x, y, an z values.
* @param x - x value to scale by
* @param y - y value to scale by
* @param z - z value to scale by
* @return scaled Pos3D
*/
public Pos3D scale(double x, double y, double z)
{
xPos *= x;
@ -89,6 +141,11 @@ public class Pos3D
return this;
}
/**
* Performs the same operation as scale(x, y, z), but with a value representing all three dimensions.
* @param scale - value to scale by
* @return scaled Pos3D
*/
public Pos3D scale(double scale)
{
return scale(scale, scale, scale);

View file

@ -6,6 +6,11 @@ import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
/**
* Gas - a class used to set specific properties of gasses when used or seen in-game.
* @author aidancbrady
*
*/
public class Gas
{
private String name;
@ -16,26 +21,47 @@ public class Gas
private Icon icon;
/**
* Creates a new Gas object with a defined name or key value.
* @param s - name or key to associate this Gas with
*/
public Gas(String s)
{
unlocalizedName = name = s;
}
/**
* Gets the name (key) of this Gas. This is NOT a translated or localized display name.
* @return this Gas's name or key
*/
public String getName()
{
return name;
}
/**
* Gets the unlocalized name of this Gas.
* @return this Gas's unlocalized name
*/
public String getUnlocalizedName()
{
return "gas." + unlocalizedName;
}
/**
* Translates this Gas's unlocalized name and returns it as localized.
* @return this Gas's localized name
*/
public String getLocalizedName()
{
return StatCollector.translateToLocal(getUnlocalizedName());
}
/**
* Sets the unlocalized name of this Gas.
* @param s - unlocalized name to set
* @return this Gas object
*/
public Gas setUnlocalizedName(String s)
{
unlocalizedName = s;
@ -43,11 +69,20 @@ public class Gas
return this;
}
/**
* Gets the Icon associated with this Gas.
* @return associated Icon
*/
public Icon getIcon()
{
return icon;
}
/**
* Sets this gas's icon.
* @param i - Icon to associate with this Gas
* @return this Gas object
*/
public Gas setIcon(Icon i)
{
icon = i;
@ -60,11 +95,20 @@ public class Gas
return this;
}
/**
* Gets the ID associated with this gas.
* @return the associated gas ID
*/
public int getID()
{
return GasRegistry.getGasID(this);
}
/**
* Writes this Gas to a defined tag compound.
* @param nbtTags - tag compound to write this Gas to
* @return the tag compound this gas was written to
*/
public NBTTagCompound write(NBTTagCompound nbtTags)
{
nbtTags.setString("gasName", getName());
@ -72,6 +116,11 @@ public class Gas
return nbtTags;
}
/**
* Returns the Gas stored in the defined tag compound.
* @param nbtTags - tag compound to get the Gas from
* @return Gas stored in the tag compound
*/
public static Gas readFromNBT(NBTTagCompound nbtTags)
{
if(nbtTags == null || nbtTags.hasNoTags())
@ -82,16 +131,28 @@ public class Gas
return GasRegistry.getGas(nbtTags.getString("gasName"));
}
/**
* Whether or not this Gas has an associated fluid.
* @return if this gas has a fluid
*/
public boolean hasFluid()
{
return fluid != null;
}
/**
* Gets the fluid associated with this Gas.
* @return fluid associated with this gas
*/
public Fluid getFluid()
{
return fluid;
}
/**
* Registers a new fluid out of this Gas.
* @return this Gas object
*/
public Gas registerFluid()
{
if(fluid == null)

View file

@ -22,6 +22,12 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import cpw.mods.fml.common.FMLCommonHandler;
/**
* A DynamicNetwork extension created specifically for the transfer of Gasses. By default this is server-only, but if ticked on
* the client side and if it's posted events are handled properly, it has the capability to visually display gasses network-wide.
* @author aidancbrady
*
*/
public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
{
public int transferDelay = 0;

View file

@ -9,6 +9,11 @@ public class GasRegistry
{
private static ArrayList<Gas> registeredGasses = new ArrayList<Gas>();
/**
* Register a new gas into GasRegistry.
* @param gas - Gas to register
* @return the gas that has been registered, pulled right out of GasRegistry
*/
public static Gas register(Gas gas)
{
if(gas == null)
@ -21,6 +26,11 @@ public class GasRegistry
return getGas(gas.getName());
}
/**
* Gets the gas associated with the defined ID.
* @param id - ID to check
* @return gas associated with defined ID
*/
public static Gas getGas(int id)
{
if(id == -1)
@ -31,6 +41,11 @@ public class GasRegistry
return registeredGasses.get(id);
}
/**
* Gets the gas associated with the defined fluid.
* @param f - fluid to check
* @return the gas associated with the fluid
*/
public static Gas getGas(Fluid f)
{
for(Gas gas : getRegisteredGasses())
@ -44,16 +59,30 @@ public class GasRegistry
return null;
}
/**
* Whether or not GasRegistry contains a gas with the specified name
* @param name - name to check
* @return if GasRegistry contains a gas with the defined name
*/
public static boolean containsGas(String name)
{
return getGas(name) != null;
}
/**
* Gets the list of all gasses registered in GasRegistry.
* @return a cloned list of all registered gasses
*/
public static List<Gas> getRegisteredGasses()
{
return (List<Gas>)registeredGasses.clone();
}
/**
* Gets the gas associated with the specified name.
* @param name - name of the gas to get
* @return gas associated with the name
*/
public static Gas getGas(String name)
{
for(Gas gas : registeredGasses)
@ -67,6 +96,11 @@ public class GasRegistry
return null;
}
/**
* Gets the gas ID of a specified gas.
* @param gas - gas to get the ID from
* @return gas ID
*/
public static int getGasID(Gas gas)
{
if(gas == null || !containsGas(gas.getName()))

View file

@ -2,17 +2,33 @@ package mekanism.api.gas;
import net.minecraft.nbt.NBTTagCompound;
/**
* GasStack - a specified amount of a defined Gas with certain properties.
* @author aidancbrady
*
*/
public class GasStack
{
private Gas type;
public int amount;
/**
* Creates a new GasStack with a defined gas ID and quantity.
* @param id - gas ID to associate this GasStack to, will perform a GasRegistry lookup in the constructor
* @param quantity - amount of gas to be referenced in this GasStack
*/
public GasStack(int id, int quantity)
{
type = GasRegistry.getGas(id);
amount = quantity;
}
/**
* Creates a new GasStack with a defined Gas type and quantity.
* @param gas - gas type of the stack
* @param quantity - amount of gas to be referenced in this GasStack
*/
public GasStack(Gas gas, int quantity)
{
type = gas;
@ -21,11 +37,20 @@ public class GasStack
private GasStack() {}
/**
* Gets the Gas type of this GasStack.
* @return this GasStack's Gas type
*/
public Gas getGas()
{
return type;
}
/**
* Writes this GasStack to a defined tag compound.
* @param nbtTags - tag compound to write to
* @return tag compound with this GasStack's data
*/
public NBTTagCompound write(NBTTagCompound nbtTags)
{
type.write(nbtTags);
@ -34,12 +59,21 @@ public class GasStack
return nbtTags;
}
/**
* Reads this GasStack's data from a defined tag compound.
* @param nbtTags - tag compound to read from
*/
public void read(NBTTagCompound nbtTags)
{
type = Gas.readFromNBT(nbtTags);
amount = nbtTags.getInteger("amount");
}
/**
* Returns the GasStack stored in the defined tag compound, or null if it doesn't exist.
* @param nbtTags - tag compound to read from
* @return GasStack stored in the tag compound
*/
public static GasStack readFromNBT(NBTTagCompound nbtTags)
{
if(nbtTags == null || nbtTags.hasNoTags())
@ -58,6 +92,10 @@ public class GasStack
return stack;
}
/**
* Returns a copied form of this GasStack.
* @return copied GasStack
*/
public GasStack copy()
{
return new GasStack(type, amount);

View file

@ -2,24 +2,48 @@ package mekanism.api.gas;
import net.minecraft.nbt.NBTTagCompound;
/**
* An optional way of managing and/or storing gasses. Would be very useful in TileEntity and Entity gas storage.
* @author aidancbrady
*
*/
public class GasTank
{
public GasStack stored;
public int maxGas;
private int maxGas;
private GasTank() {}
/**
* Creates a tank with a defined capacity.
* @param max - the maximum amount of gas this GasTank can hold
*/
public GasTank(int max)
{
maxGas = max;
}
/**
* Sets this tank's GasStack value to a new value. Will cap the amount to this GasTank's capacity.
* @param stack - value to set this tank's GasStack value to
*/
public void setGas(GasStack stack)
{
stored = stack;
if(stored != null)
{
stored.amount = Math.min(getMaxGas(), stored.amount);
}
}
/**
* Draws a specified amount of gas out of this tank.
* @param amount - amount to draw
* @param doDraw - if the gas should actually be removed from this tank
* @return gas taken from this GasTank as a GasStack value
*/
public GasStack draw(int amount, boolean doDraw)
{
if(stored == null || amount <= 0)
@ -47,14 +71,20 @@ public class GasTank
return null;
}
/**
* Adds a specified amount of gas to this tank.
* @param amount - the GasStack for this tank to receive
* @param doReceive - if the gas should actually be added to this tank
* @return the amount of gas accepted by this tank
*/
public int receive(GasStack amount, boolean doReceive)
{
if(amount == null || (stored != null && stored.amount == maxGas))
if(amount == null || (stored != null && stored.amount == getMaxGas()))
{
return 0;
}
int toFill = Math.min(maxGas-getStored(), amount.amount);
int toFill = Math.min(getMaxGas()-getStored(), amount.amount);
if(doReceive)
{
@ -63,13 +93,18 @@ public class GasTank
stored = amount;
}
else {
stored.amount = Math.min(maxGas, getStored()+amount.amount);
stored.amount = Math.min(getMaxGas(), getStored()+amount.amount);
}
}
return toFill;
}
/**
* If this GasTank can receive the specified type of gas. Will return false if this tank does not need anymore gas.
* @param gas - gas to check
* @return if this GasTank can accept the defined gas
*/
public boolean canReceive(Gas gas)
{
if(getNeeded() == 0 || stored != null && (gas != null && gas != stored.getGas()))
@ -80,6 +115,11 @@ public class GasTank
return true;
}
/**
* If this GasTank can be drawn of the specified type of gas. Will return false if this tank does not contain any gas.
* @param gas - gas to check
* @return if this GasTank can be drawn of the defined gas
*/
public boolean canDraw(Gas gas)
{
if(stored == null || (gas != null && gas != stored.getGas()))
@ -90,26 +130,47 @@ public class GasTank
return true;
}
/**
* Gets the amount of gas needed by this GasTank.
* @return
*/
public int getNeeded()
{
return getMaxGas()-getStored();
}
/**
* Gets the maximum amount of gas this tank can hold.
* @return - max gas
*/
public int getMaxGas()
{
return maxGas;
}
/**
* Gets the GasStack held by this GasTank.
* @return - GasStakc held by this tank
*/
public GasStack getGas()
{
return stored;
}
/**
* Gets the amount of gas stored by this GasTank.
* @return amount of gas stored
*/
public int getStored()
{
return stored != null ? stored.amount : 0;
}
/**
* Writes this tank to a defined tag compound.
* @param nbtTags - tag compound to write to
* @return tag compound with this tank's data
*/
public NBTTagCompound write(NBTTagCompound nbtTags)
{
if(stored != null)
@ -122,6 +183,10 @@ public class GasTank
return nbtTags;
}
/**
* Reads this tank's data from a defined tag compound.
* @param nbtTags - tag compound to read from
*/
public void read(NBTTagCompound nbtTags)
{
if(nbtTags.hasKey("stored"))
@ -132,6 +197,11 @@ public class GasTank
maxGas = nbtTags.getInteger("maxGas");
}
/**
* Returns the tank stored in the defined tag compound, or null if it doesn't exist.
* @param nbtTags - tag compound to read from
* @return tank stored in the tag compound
*/
public static GasTank readFromNBT(NBTTagCompound nbtTags)
{
if(nbtTags == null || nbtTags.hasNoTags())

View file

@ -80,6 +80,12 @@ public final class GasTransmission
return connections;
}
/**
* Whether or not a TileEntity can connect to a specified tile on a specified side.
* @param tileEntity - TileEntity to attempt connection to
* @param side - side to attempt connection on
* @return if this tile and side are connectable
*/
public static boolean canConnect(TileEntity tileEntity, ForgeDirection side)
{
if(tileEntity instanceof ITubeConnection && (!(tileEntity instanceof IGasTransmitter) || TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, tileEntity)))
@ -113,6 +119,13 @@ public final class GasTransmission
return 0;
}
/**
* Removes a specified amount of gas from an IGasItem.
* @param itemStack - ItemStack of the IGasItem
* @param type - type of gas to remove from the IGasItem, null if it doesn't matter
* @param amount - amount of gas to remove from the ItemStack
* @return the GasStack removed by the IGasItem
*/
public static GasStack removeGas(ItemStack itemStack, Gas type, int amount)
{
if(itemStack != null && itemStack.getItem() instanceof IGasItem)
@ -130,6 +143,12 @@ public final class GasTransmission
return null;
}
/**
* Adds a specified amount of gas to an IGasItem.
* @param itemStack - ItemStack of the IGasItem
* @param stack - stack to add to the IGasItem
* @return amount of gas accepted by the IGasItem
*/
public static int addGas(ItemStack itemStack, GasStack stack)
{
if(itemStack != null && itemStack.getItem() instanceof IGasItem && ((IGasItem)itemStack.getItem()).canReceiveGas(itemStack, stack.getGas()))

View file

@ -3,7 +3,7 @@ package mekanism.api.gas;
import net.minecraftforge.common.ForgeDirection;
/**
* Implement this if your tile entity accepts gas from a foreign, external source.
* Implement this if your tile entity accepts gas from an external source.
* @author AidanBrady
*
*/

View file

@ -1,23 +0,0 @@
/**
*
*/
package mekanism.api.induction;
import net.minecraft.tileentity.TileEntity;
/**
* @author Calclavia
*
*/
public interface ITesla
{
/**
* @param transferEnergy - The energy amount in kilojoules.
* @param doTransfer - Actually transfer
* @return Energy actually transfered.
*/
public double transfer(double transferEnergy, boolean doTransfer);
public boolean canReceive(TileEntity transferTile);
}

View file

@ -189,7 +189,7 @@ public class RenderPartTransmitter implements IIconRegister
int yPos = MathHelper.floor_double(pos.blockY);
int zPos = MathHelper.floor_double(pos.blockZ);
Coord4D obj = new Coord4D(xPos, yPos, zPos);
Coord4D obj = new Coord4D(xPos, yPos, zPos, transporter.world().provider.dimensionId);
if(obj.equals(Coord4D.get(transporter.tile())))
{

View file

@ -57,7 +57,7 @@ public class RenderTickHandler implements ITickHandler
int y = MathHelper.floor_double(pos.blockY);
int z = MathHelper.floor_double(pos.blockZ);
Coord4D obj = new Coord4D(x, y, z);
Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId);
if(Mekanism.debug && mc.currentScreen == null && !mc.gameSettings.showDebugInfo)
{

View file

@ -56,7 +56,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
int yPos = MathHelper.floor_double(pos.blockY);
int zPos = MathHelper.floor_double(pos.blockZ);
Coord4D obj = new Coord4D(xPos, yPos, zPos);
Coord4D obj = new Coord4D(xPos, yPos, zPos, tileEntity.worldObj.provider.dimensionId);
if(xPos == tileEntity.xCoord && yPos == tileEntity.yCoord && zPos == tileEntity.zCoord)
{

View file

@ -145,7 +145,7 @@ public class RenderLogisticalTransporter extends TileEntitySpecialRenderer
int yPos = MathHelper.floor_double(pos.blockY);
int zPos = MathHelper.floor_double(pos.blockZ);
Coord4D obj = new Coord4D(xPos, yPos, zPos);
Coord4D obj = new Coord4D(xPos, yPos, zPos, tileEntity.worldObj.provider.dimensionId);
if(obj.equals(Coord4D.get(tileEntity)))
{

View file

@ -212,7 +212,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
toSend = Math.min(toSend, ((IEnergySink)acceptor).demandedEnergyUnits()*Mekanism.FROM_IC2);
sent += (toSend - (((IEnergySink)acceptor).injectEnergyUnits(side.getOpposite(), toSend*Mekanism.TO_IC2)*Mekanism.FROM_IC2));
}
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildcraft())
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildCraft())
{
PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(side.getOpposite());
@ -288,7 +288,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
}
}
}
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildcraft())
else if(acceptor instanceof IPowerReceptor && MekanismUtils.useBuildCraft())
{
IPowerReceptor handler = (IPowerReceptor)acceptor;

View file

@ -193,6 +193,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
data.writeInt(latched.xCoord);
data.writeInt(latched.yCoord);
data.writeInt(latched.zCoord);
data.writeInt(latched.dimensionId);
}
else {
data.writeBoolean(false);
@ -208,7 +209,7 @@ public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData
if(data.readBoolean())
{
latched = new Coord4D(data.readInt(), data.readInt(), data.readInt());
latched = Coord4D.read(data);
}
else {
latched = null;

View file

@ -617,7 +617,7 @@ public class Mekanism
RecipeHandler.addChemicalFormulatorRecipe(new ItemStack(Item.gunpowder), new GasStack(GasRegistry.getGas("sulfuricGas"), 100));
//Chemical Infuser Recipes
RecipeHandler.addChemicalInfuserRecipe(new ChemicalInput(GasRegistry.getGas("hydrogen"), GasRegistry.getGas("sulfuricGas")), new GasStack(GasRegistry.getGas("sulfuricAcid"), 1));
RecipeHandler.addChemicalInfuserRecipe(new ChemicalInput(new GasStack(GasRegistry.getGas("hydrogen"), 1), new GasStack(GasRegistry.getGas("sulfuricGas"), 1)), new GasStack(GasRegistry.getGas("sulfuricAcid"), 1));
//Infuse objects
InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10));

View file

@ -5,6 +5,7 @@ import java.util.Map;
import mekanism.api.ChemicalInput;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.infuse.InfusionInput;
import mekanism.api.infuse.InfusionOutput;
import mekanism.common.util.StackUtils;
@ -139,11 +140,13 @@ public final class RecipeHandler
/**
* Gets the GasStack of the ChemicalInput in the parameters.
* @param input - input ChemicalInput
* @return GasStack
* @return output GasStack
*/
public static GasStack getChemicalInfuserOutput(ChemicalInput input)
public static GasStack getChemicalInfuserOutput(GasTank leftTank, GasTank rightTank, boolean doRemove)
{
if(input != null && input.isValid())
ChemicalInput input = new ChemicalInput(leftTank.getGas(), rightTank.getGas());
if(input.isValid())
{
HashMap<ChemicalInput, GasStack> recipes = Recipe.CHEMICAL_INFUSER.get();
@ -151,8 +154,13 @@ public final class RecipeHandler
{
ChemicalInput key = (ChemicalInput)entry.getKey();
if(key.equals(input))
if(key.meetsInput(input))
{
if(doRemove)
{
key.draw(leftTank, rightTank);
}
return entry.getValue().copy();
}
}
@ -165,7 +173,7 @@ public final class RecipeHandler
* Gets the InfusionOutput of the ItemStack in the parameters.
* @param itemstack - input ItemStack
* @param stackDecrease - whether or not to decrease the input slot's stack size
* @return GasStack
* @return output GasStack
*/
public static GasStack getChemicalFormulatorOutput(ItemStack itemstack, boolean stackDecrease)
{

View file

@ -82,7 +82,7 @@ public class ItemBalloon extends ItemMekanism
{
if(player.isSneaking())
{
Coord4D obj = new Coord4D(x, y, z);
Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId);
if(Block.blocksList[obj.getBlockId(world)].isBlockReplaceable(world, x, y, z))
{

View file

@ -46,7 +46,7 @@ public class ThreadMinerSearch extends Thread
continue;
}
if(new Coord4D(x, y, z).getTileEntity(tileEntity.worldObj) instanceof IBoundingBlock)
if(new Coord4D(x, y, z, tileEntity.worldObj.provider.dimensionId).getTileEntity(tileEntity.worldObj) instanceof IBoundingBlock)
{
continue;
}
@ -67,7 +67,7 @@ public class ThreadMinerSearch extends Thread
{
if(filter.canFilter(stack))
{
tileEntity.oresToMine.add(new Coord4D(x, y, z));
tileEntity.oresToMine.add(new Coord4D(x, y, z, tileEntity.worldObj.provider.dimensionId));
}
}
}

View file

@ -46,7 +46,7 @@ public class ItemPartTransmitter extends JItemMultiPart
if(type.getTransmission() != TransmissionType.ITEM)
{
Coord4D obj = new Coord4D(coord.x, coord.y, coord.z);
Coord4D obj = new Coord4D(coord.x, coord.y, coord.z, world.provider.dimensionId);
List<ITransmitterNetwork<?, ?>> networks = new ArrayList<ITransmitterNetwork<?, ?>>();

View file

@ -13,7 +13,7 @@ import com.google.common.io.ByteArrayDataInput;
public class PacketRedstoneControl implements IMekanismPacket
{
public Coord4D object3D;
public Coord4D coord;
public RedstoneControl value;
@Override
@ -25,7 +25,7 @@ public class PacketRedstoneControl implements IMekanismPacket
@Override
public IMekanismPacket setParams(Object... data)
{
object3D = (Coord4D)data[0];
coord = (Coord4D)data[0];
value = (RedstoneControl)data[1];
return this;
@ -34,7 +34,7 @@ public class PacketRedstoneControl implements IMekanismPacket
@Override
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
{
Coord4D obj = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
Coord4D obj = Coord4D.read(dataStream);
RedstoneControl control = RedstoneControl.values()[dataStream.readInt()];
TileEntity tileEntity = obj.getTileEntity(world);
@ -48,9 +48,10 @@ public class PacketRedstoneControl implements IMekanismPacket
@Override
public void write(DataOutputStream dataStream) throws Exception
{
dataStream.writeInt(object3D.xCoord);
dataStream.writeInt(object3D.yCoord);
dataStream.writeInt(object3D.zCoord);
dataStream.writeInt(coord.xCoord);
dataStream.writeInt(coord.yCoord);
dataStream.writeInt(coord.zCoord);
dataStream.writeInt(coord.dimensionId);
dataStream.writeInt(value.ordinal());
}

View file

@ -369,6 +369,6 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
public IAdvancedBoundingBlock getInv()
{
return (IAdvancedBoundingBlock)new Coord4D(mainX, mainY, mainZ).getTileEntity(worldObj);
return (IAdvancedBoundingBlock)new Coord4D(mainX, mainY, mainZ, worldObj.provider.dimensionId).getTileEntity(worldObj);
}
}

View file

@ -109,10 +109,8 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement
if(canOperate() && getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this))
{
setActive(true);
GasStack stack = RecipeHandler.getChemicalInfuserOutput(new ChemicalInput(leftTank.getGas().getGas(), rightTank.getGas().getGas()));
GasStack stack = RecipeHandler.getChemicalInfuserOutput(leftTank, rightTank, true);
leftTank.draw(1, true);
rightTank.draw(1, true);
centerTank.receive(stack, true);
setEnergy(getEnergy() - ENERGY_USAGE);
@ -151,7 +149,7 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement
return false;
}
GasStack out = RecipeHandler.getChemicalInfuserOutput(new ChemicalInput(leftTank.getGas().getGas(), rightTank.getGas().getGas()));
GasStack out = RecipeHandler.getChemicalInfuserOutput(leftTank, rightTank, false);
if(out == null)
{

View file

@ -398,7 +398,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
public TileEntity getPullInv()
{
return new Coord4D(xCoord, yCoord+2, zCoord).getTileEntity(worldObj);
return Coord4D.get(this).translate(0, 2, 0).getTileEntity(worldObj);
}
public TileEntity getEjectInv()
@ -957,8 +957,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
{
ForgeDirection dir = ForgeDirection.getOrientation(facing).getOpposite();
Coord4D eject = new Coord4D(xCoord+dir.offsetX, yCoord+1, zCoord+dir.offsetZ, worldObj.provider.dimensionId);
Coord4D pull = new Coord4D(xCoord, yCoord+1, zCoord);
Coord4D eject = Coord4D.get(this).translate(dir.offsetX, 1, dir.offsetZ);
Coord4D pull = Coord4D.get(this).translate(0, 1, 0);
if((location.equals(eject) && side == dir.ordinal()) || (location.equals(pull) && side == 1))
{
@ -983,8 +983,8 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
{
ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite();
Coord4D eject = new Coord4D(xCoord+side.offsetX, yCoord+1, zCoord+side.offsetZ, worldObj.provider.dimensionId);
Coord4D pull = new Coord4D(xCoord, yCoord+1, zCoord);
Coord4D eject = Coord4D.get(this).translate(side.offsetX, 1, side.offsetZ);
Coord4D pull = Coord4D.get(this).translate(0, 1, 0);
if(location.equals(eject))
{
@ -1007,7 +1007,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite();
Coord4D eject = new Coord4D(xCoord+side.offsetX, yCoord+1, zCoord+side.offsetZ, worldObj.provider.dimensionId);
Coord4D pull = new Coord4D(xCoord, yCoord+1, zCoord);
Coord4D pull = new Coord4D(xCoord, yCoord+1, zCoord, worldObj.provider.dimensionId);
if(location.equals(eject))
{

View file

@ -348,9 +348,8 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
data.add(structure.volHeight);
data.add(structure.volWidth);
data.add(structure.volLength);
data.add(structure.renderLocation.xCoord);
data.add(structure.renderLocation.yCoord);
data.add(structure.renderLocation.zCoord);
structure.renderLocation.write(data);
}
else {
data.add(false);
@ -360,9 +359,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
for(ValveData valveData : structure.valves)
{
data.add(valveData.location.xCoord);
data.add(valveData.location.yCoord);
data.add(valveData.location.zCoord);
valveData.location.write(data);
data.add(valveData.side.ordinal());
data.add(valveData.serverFluid);
@ -402,7 +399,8 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
structure.volHeight = dataStream.readInt();
structure.volWidth = dataStream.readInt();
structure.volLength = dataStream.readInt();
structure.renderLocation = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
structure.renderLocation = Coord4D.read(dataStream);
}
int size = dataStream.readInt();
@ -410,7 +408,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
for(int i = 0; i < size; i++)
{
ValveData data = new ValveData();
data.location = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
data.location = Coord4D.read(dataStream);
data.side = ForgeDirection.getOrientation(dataStream.readInt());
int viewingTicks = 0;

View file

@ -161,7 +161,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
protected void reconfigure()
{
if(MekanismUtils.useBuildcraft())
if(MekanismUtils.useBuildCraft())
{
powerHandler.configure(1, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), 0, (float)(getMaxEnergy()*Mekanism.TO_BC));
}

View file

@ -151,7 +151,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
if(take)
{
setEnergy(getEnergy() - 100);
recurringNodes.add(new Coord4D(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord));
recurringNodes.add(wrapper.clone());
fluidTank.fill(MekanismUtils.getFluid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord), true);
worldObj.setBlockToAir(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord);
}

View file

@ -178,7 +178,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
private void reconfigure()
{
if(MekanismUtils.useBuildcraft())
if(MekanismUtils.useBuildCraft())
{
float needed = (float)(getTransmitterNetwork().getEnergyNeeded()*Mekanism.TO_BC);
powerHandler.configure(1, needed, 0, needed);
@ -188,7 +188,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyNetwor
@Override
public void doWork(PowerHandler workProvider)
{
if(MekanismUtils.useBuildcraft())
if(MekanismUtils.useBuildCraft())
{
if(powerHandler.getEnergyStored() > 0)
{

View file

@ -39,7 +39,7 @@ public final class CableUtils
if(acceptor instanceof IStrictEnergyAcceptor ||
acceptor instanceof IEnergySink ||
(acceptor instanceof IPowerReceptor && !(acceptor instanceof IGridTransmitter) && MekanismUtils.useBuildcraft()) ||
(acceptor instanceof IPowerReceptor && !(acceptor instanceof IGridTransmitter) && MekanismUtils.useBuildCraft()) ||
acceptor instanceof IEnergyHandler)
{
acceptors[orientation.ordinal()] = acceptor;
@ -194,7 +194,7 @@ public final class CableUtils
return true;
}
}
else if(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IGridTransmitter) && MekanismUtils.useBuildcraft())
else if(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IGridTransmitter) && MekanismUtils.useBuildCraft())
{
if(!(tileEntity instanceof IEnergyAcceptor) || ((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(null, side.getOpposite()))
{
@ -313,7 +313,7 @@ public final class CableUtils
sent += (toSend - rejects);
}
}
else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildcraft())
else if(tileEntity instanceof IPowerReceptor && MekanismUtils.useBuildCraft())
{
PowerReceiver receiver = ((IPowerReceptor)tileEntity).getPowerReceiver(side.getOpposite());

View file

@ -572,6 +572,11 @@ public final class MekanismUtils
{
config.getConfiguration()[side] = 0;
}
TileEntity tile = (TileEntity)config;
Coord4D coord = Coord4D.get(tile).getFromSide(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, config.getOrientation())));
tile.worldObj.notifyBlockOfNeighborChange(coord.xCoord, coord.yCoord, coord.zCoord, tile.getBlockType().blockID);
}
/**
@ -592,6 +597,11 @@ public final class MekanismUtils
{
config.getConfiguration()[side] = (byte)max;
}
TileEntity tile = (TileEntity)config;
Coord4D coord = Coord4D.get(tile).getFromSide(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, config.getOrientation())));
tile.worldObj.notifyBlockOfNeighborChange(coord.xCoord, coord.yCoord, coord.zCoord, tile.getBlockType().blockID);
}
/**
@ -1071,6 +1081,12 @@ public final class MekanismUtils
return false;
}
/**
* Ray-traces what block a player is looking at.
* @param world - world the player is in
* @param player - player to raytrace
* @return raytraced value
*/
public static MovingObjectPosition rayTrace(World world, EntityPlayer player)
{
double reach = Mekanism.proxy.getReach(player);
@ -1082,6 +1098,11 @@ public final class MekanismUtils
return world.rayTraceBlocks_do_do(headVec, endVec, true, false);
}
/**
* Gets the head vector of a player for a ray trace.
* @param player - player to check
* @return head location
*/
private static Vec3 getHeadVec(EntityPlayer player)
{
Vec3 vec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ);
@ -1099,21 +1120,41 @@ public final class MekanismUtils
return vec;
}
/**
* Gets a rounded energy display of a defined amount of energy.
* @param energy - energy to display
* @return rounded energy display
*/
public static String getEnergyDisplay(double energy)
{
return EnergyDisplay.getDisplayShort(energy, ElectricUnit.JOULES);
}
/**
* Gets a rounded power display of a defined amount of energy.
* @param energy - energy to display
* @return rounded power display
*/
public static String getPowerDisplay(double energy)
{
return EnergyDisplay.getDisplayShort(energy, ElectricUnit.WATT);
}
public static boolean useBuildcraft()
/**
* Whether or not BuildCraft power should be used, taking into account both whether or not it is installed or if
* the player has configured the mod to do so.
* @return if BuildCraft power should be used
*/
public static boolean useBuildCraft()
{
return Mekanism.hooks.BuildCraftLoaded || Mekanism.forceBuildcraft;
}
/**
* Gets a clean view of a coordinate value without the dimension ID.
* @param obj - coordinate to check
* @return coordinate display
*/
public static String getCoordDisplay(Coord4D obj)
{
return "[" + obj.xCoord + ", " + obj.yCoord + ", " + obj.zCoord + "]";

View file

@ -85,7 +85,7 @@ public final class TransporterUtils
ForgeDirection forgeSide = ForgeDirection.getOrientation(side).getOpposite();
//Immature BuildCraft inv check
if(MekanismUtils.useBuildcraft() && inventory instanceof IPowerReceptor)
if(MekanismUtils.useBuildCraft() && inventory instanceof IPowerReceptor)
{
if(((IPowerReceptor)inventory).getPowerReceiver(forgeSide) != null && ((IPowerReceptor)inventory).getPowerReceiver(forgeSide).getType() == Type.MACHINE)
{
@ -216,7 +216,7 @@ public final class TransporterUtils
public static float[] getStackPosition(ILogisticalTransporter tileEntity, TransporterStack stack, float partial)
{
Coord4D offset = new Coord4D(0, 0, 0).step(ForgeDirection.getOrientation(stack.getSide(tileEntity)));
Coord4D offset = new Coord4D(0, 0, 0, tileEntity.getTile().worldObj.provider.dimensionId).step(ForgeDirection.getOrientation(stack.getSide(tileEntity)));
float progress = (((float)stack.progress + partial) / 100F) - 0.5F;
float itemFix = 0;

View file

@ -78,7 +78,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator
for(int y = yCoord+1; y < 256; y++)
{
Coord4D obj = new Coord4D(xCoord, y, zCoord);
Coord4D obj = new Coord4D(xCoord, y, zCoord, worldObj.provider.dimensionId);
Block block = Block.blocksList[obj.getBlockId(worldObj)];
if(block != null)