v5.5.1 Release

*Cleaned up code.
*Fixed BuildCraft reference.
This commit is contained in:
Aidan Brady 2013-03-29 12:10:23 -04:00
parent 51d525e350
commit 1fd0353225
14 changed files with 212 additions and 187 deletions

View file

@ -1,4 +1,4 @@
# Mekanism for Minecraft 1.4.7 #
# Mekanism for Minecraft 1.5.1 #
Source code. More information can be found on the mod's forum post.

View file

@ -2,7 +2,7 @@ package mekanism.client;
import java.util.Arrays;
import mekanism.common.MekanismUtils;
import mekanism.common.CableUtils;
import mekanism.common.TileEntityUniversalCable;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
@ -28,15 +28,15 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
boolean[] connectable = new boolean[] {false, false, false, false, false, false};
TileEntity[] connectedAcceptors = MekanismUtils.getConnectedEnergyAcceptors(tileEntity);
TileEntity[] connectedCables = MekanismUtils.getConnectedCables(tileEntity);
TileEntity[] connectedOutputters = MekanismUtils.getConnectedOutputters(tileEntity);
TileEntity[] connectedAcceptors = CableUtils.getConnectedEnergyAcceptors(tileEntity);
TileEntity[] connectedCables = CableUtils.getConnectedCables(tileEntity);
TileEntity[] connectedOutputters = CableUtils.getConnectedOutputters(tileEntity);
for(TileEntity tile : connectedAcceptors)
{
int side = Arrays.asList(connectedAcceptors).indexOf(tile);
if(MekanismUtils.canCableConnect(ForgeDirection.getOrientation(side), tileEntity))
if(CableUtils.canConnectToAcceptor(ForgeDirection.getOrientation(side), tileEntity))
{
connectable[side] = true;
}

View file

@ -79,15 +79,15 @@ public class BlockTransmitter extends Block
}
else if(world.getBlockMetadata(x, y, z) == 1)
{
TileEntity[] connectedAcceptors = MekanismUtils.getConnectedEnergyAcceptors(tileEntity);
TileEntity[] connectedCables = MekanismUtils.getConnectedCables(tileEntity);
TileEntity[] connectedOutputters = MekanismUtils.getConnectedOutputters(tileEntity);
TileEntity[] connectedAcceptors = CableUtils.getConnectedEnergyAcceptors(tileEntity);
TileEntity[] connectedCables = CableUtils.getConnectedCables(tileEntity);
TileEntity[] connectedOutputters = CableUtils.getConnectedOutputters(tileEntity);
for(TileEntity tile : connectedAcceptors)
{
int side = Arrays.asList(connectedAcceptors).indexOf(tile);
if(MekanismUtils.canCableConnect(ForgeDirection.getOrientation(side), tileEntity))
if(CableUtils.canConnectToAcceptor(ForgeDirection.getOrientation(side), tileEntity))
{
connectable[side] = true;
}

View file

@ -0,0 +1,182 @@
package mekanism.common;
import ic2.api.energy.tile.IEnergyAcceptor;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import java.util.ArrayList;
import mekanism.api.ICableOutputter;
import mekanism.api.IStrictEnergyAcceptor;
import mekanism.api.IUniversalCable;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.block.IConnectionProvider;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import buildcraft.api.power.IPowerReceptor;
public final class CableUtils
{
/**
* Gets all the connected energy acceptors, whether IC2-based or BuildCraft-based, surrounding a specific tile entity.
* @param tileEntity - center tile entity
* @return TileEntity[] of connected acceptors
*/
public static TileEntity[] getConnectedEnergyAcceptors(TileEntity tileEntity)
{
TileEntity[] acceptors = new TileEntity[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity acceptor = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(acceptor instanceof IStrictEnergyAcceptor || acceptor instanceof IEnergySink || (acceptor instanceof IPowerReceptor && !(acceptor instanceof IUniversalCable) && Mekanism.hooks.BuildCraftLoaded))
{
acceptors[orientation.ordinal()] = acceptor;
}
}
return acceptors;
}
/**
* Gets all the connected cables around a specific tile entity.
* @param tileEntity - center tile entity
* @return TileEntity[] of connected cables
*/
public static TileEntity[] getConnectedCables(TileEntity tileEntity)
{
TileEntity[] cables = new TileEntity[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity cable = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(cable instanceof IUniversalCable && ((IUniversalCable)cable).canTransferEnergy())
{
cables[orientation.ordinal()] = cable;
}
}
return cables;
}
/**
* Gets all the connected cables around a specific tile entity.
* @param tileEntity - center tile entity
* @return TileEntity[] of connected cables
*/
public static TileEntity[] getConnectedOutputters(TileEntity tileEntity)
{
TileEntity[] outputters = new TileEntity[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity outputter = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(outputter instanceof ICableOutputter && ((ICableOutputter)outputter).canOutputTo(orientation.getOpposite()))
{
outputters[orientation.ordinal()] = outputter;
}
}
return outputters;
}
/**
* Whether or not a cable can connect to a specific acceptor.
* @param side - side to check
* @param tileEntity - cable TileEntity
* @return whether or not the cable can connect to the specific side
*/
public static boolean canConnectToAcceptor(ForgeDirection side, TileEntity tile)
{
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(tile.worldObj, new Vector3(tile.xCoord, tile.yCoord, tile.zCoord), side);
if(tileEntity instanceof IStrictEnergyAcceptor && ((IStrictEnergyAcceptor)tileEntity).canReceiveEnergy(side.getOpposite()))
{
return true;
}
if(tileEntity instanceof IConnectionProvider && ((IConnectionProvider)tileEntity).canConnect(side.getOpposite()))
{
return true;
}
if(tileEntity instanceof IEnergyAcceptor && ((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(null, MekanismUtils.toIC2Direction(side).getInverse()))
{
return true;
}
if(tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite()))
{
return true;
}
if(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IUniversalCable) && Mekanism.hooks.BuildCraftLoaded)
{
if(!(tileEntity instanceof IEnergyAcceptor) || ((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(null, MekanismUtils.toIC2Direction(side).getInverse()))
{
if(!(tileEntity instanceof IEnergySource) || ((IEnergySource)tileEntity).emitsEnergyTo(null, MekanismUtils.toIC2Direction(side).getInverse()))
{
return true;
}
}
}
return false;
}
/**
* Emits a defined amount of energy to the network, distributing between IC2-based and BuildCraft-based acceptors.
* @param amount - amount to send
* @param sender - sending TileEntity
* @param facing - direction the TileEntity is facing
* @return rejected energy
*/
public static double emitEnergyToNetwork(double amount, TileEntity sender, ForgeDirection facing)
{
TileEntity pointer = VectorHelper.getTileEntityFromSide(sender.worldObj, new Vector3(sender.xCoord, sender.yCoord, sender.zCoord), facing);
if(pointer instanceof IUniversalCable)
{
return new EnergyTransferProtocol(pointer, sender, amount, new ArrayList()).calculate();
}
return amount;
}
/**
* Emits energy from all sides of a TileEntity.
* @param amount - amount to send
* @param pointer - sending TileEntity
* @return rejected energy
*/
public static double emitEnergyFromAllSides(double amount, TileEntity pointer)
{
if(pointer != null)
{
return new EnergyTransferProtocol(pointer, pointer, amount, new ArrayList()).calculate();
}
return amount;
}
/**
* Emits energy from all sides of a TileEntity, while ignoring specific acceptors.
* @param amount - amount to send
* @param pointer - sending TileEntity
* @param ignored - ignored acceptors
* @return rejected energy
*/
public static double emitEnergyFromAllSidesIgnore(double amount, TileEntity pointer, ArrayList ignored)
{
if(pointer != null)
{
return new EnergyTransferProtocol(pointer, pointer, amount, ignored).calculate();
}
return amount;
}
}

View file

@ -73,7 +73,7 @@ public class EnergyTransferProtocol
*/
public void loopThrough(TileEntity tile)
{
TileEntity[] acceptors = MekanismUtils.getConnectedEnergyAcceptors(tile);
TileEntity[] acceptors = CableUtils.getConnectedEnergyAcceptors(tile);
for(TileEntity acceptor : acceptors)
{
@ -116,7 +116,7 @@ public class EnergyTransferProtocol
iteratedCables.add(tile);
TileEntity[] tubes = MekanismUtils.getConnectedCables(tile);
TileEntity[] tubes = CableUtils.getConnectedCables(tile);
for(TileEntity tube : tubes)
{

View file

@ -39,6 +39,6 @@ public class IC2EnergyHandler
}
}
event.amount = (int)(MekanismUtils.emitEnergyFromAllSidesIgnore(event.amount*Mekanism.FROM_IC2, tileEntity, ignoredTiles)*Mekanism.TO_IC2);
event.amount = (int)(CableUtils.emitEnergyFromAllSidesIgnore(event.amount*Mekanism.FROM_IC2, tileEntity, ignoredTiles)*Mekanism.TO_IC2);
}
}

View file

@ -52,7 +52,7 @@ import cpw.mods.fml.relauncher.SideOnly;
* @author AidanBrady
*
*/
@Mod(modid = "Mekanism", name = "Mekanism", version = "5.5.0")
@Mod(modid = "Mekanism", name = "Mekanism", version = "5.5.1")
@NetworkMod(channels = {"Mekanism"}, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
public class Mekanism
{
@ -74,7 +74,7 @@ public class Mekanism
public static Configuration configuration;
/** Mekanism version number */
public static Version versionNumber = new Version(5, 5, 0);
public static Version versionNumber = new Version(5, 5, 1);
/** Map of Teleporters */
public static Map<Teleporter.Code, ArrayList<Teleporter.Coords>> teleporters = new HashMap<Teleporter.Code, ArrayList<Teleporter.Coords>>();
@ -161,10 +161,10 @@ public class Mekanism
public static boolean controlCircuitOreDict = true;
public static int obsidianTNTBlastRadius = 12;
public static int obsidianTNTDelay = 100;
public static double TO_IC2 = .1;
public static double TO_BC = .04;
public static double FROM_IC2 = 10;
public static double FROM_BC = 25;
public static double TO_IC2;
public static double TO_BC;
public static double FROM_IC2;
public static double FROM_BC;
/** Total ticks passed since thePlayer joined theWorld */
public static int ticksPassed = 0;

View file

@ -466,168 +466,6 @@ public final class MekanismUtils
world.updateAllLightTypes(x, y, z);
}
/**
* Gets all the connected energy acceptors, whether IC2-based or BuildCraft-based, surrounding a specific tile entity.
* @param tileEntity - center tile entity
* @return TileEntity[] of connected acceptors
*/
public static TileEntity[] getConnectedEnergyAcceptors(TileEntity tileEntity)
{
TileEntity[] acceptors = new TileEntity[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity acceptor = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(acceptor instanceof IStrictEnergyAcceptor || acceptor instanceof IEnergySink || (acceptor instanceof IPowerReceptor && !(acceptor instanceof IUniversalCable) && Mekanism.hooks.BuildCraftLoaded))
{
acceptors[orientation.ordinal()] = acceptor;
}
}
return acceptors;
}
/**
* Gets all the connected cables around a specific tile entity.
* @param tileEntity - center tile entity
* @return TileEntity[] of connected cables
*/
public static TileEntity[] getConnectedCables(TileEntity tileEntity)
{
TileEntity[] cables = new TileEntity[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity cable = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(cable instanceof IUniversalCable && ((IUniversalCable)cable).canTransferEnergy())
{
cables[orientation.ordinal()] = cable;
}
}
return cables;
}
/**
* Gets all the connected cables around a specific tile entity.
* @param tileEntity - center tile entity
* @return TileEntity[] of connected cables
*/
public static TileEntity[] getConnectedOutputters(TileEntity tileEntity)
{
TileEntity[] outputters = new TileEntity[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity outputter = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
if(outputter instanceof ICableOutputter && ((ICableOutputter)outputter).canOutputTo(orientation.getOpposite()))
{
outputters[orientation.ordinal()] = outputter;
}
}
return outputters;
}
/**
* Whether or not a cable can connect to a specific side.
* @param side - side to check
* @param tileEntity - cable TileEntity
* @return whether or not the cable can connect to the specific side
*/
public static boolean canCableConnect(ForgeDirection side, TileEntity tile)
{
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(tile.worldObj, new Vector3(tile.xCoord, tile.yCoord, tile.zCoord), side);
if(tileEntity instanceof IStrictEnergyAcceptor && ((IStrictEnergyAcceptor)tileEntity).canReceiveEnergy(side.getOpposite()))
{
return true;
}
if(tileEntity instanceof IConnectionProvider && ((IConnectionProvider)tileEntity).canConnect(side.getOpposite()))
{
return true;
}
if(tileEntity instanceof IEnergyAcceptor && ((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(null, toIC2Direction(side).getInverse()))
{
return true;
}
if(tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite()))
{
return true;
}
if(tileEntity instanceof IPowerReceptor && !(tileEntity instanceof IUniversalCable) && Mekanism.hooks.BuildCraftLoaded)
{
if(!(tileEntity instanceof IEnergyAcceptor) || ((IEnergyAcceptor)tileEntity).acceptsEnergyFrom(null, toIC2Direction(side).getInverse()))
{
if(!(tileEntity instanceof IEnergySource) || ((IEnergySource)tileEntity).emitsEnergyTo(null, toIC2Direction(side).getInverse()))
{
return true;
}
}
}
return false;
}
/**
* Emits a defined amount of energy to the network, distributing between IC2-based and BuildCraft-based acceptors.
* @param amount - amount to send
* @param sender - sending TileEntity
* @param facing - direction the TileEntity is facing
* @return rejected energy
*/
public static double emitEnergyToNetwork(double amount, TileEntity sender, ForgeDirection facing)
{
TileEntity pointer = VectorHelper.getTileEntityFromSide(sender.worldObj, new Vector3(sender.xCoord, sender.yCoord, sender.zCoord), facing);
if(pointer instanceof IUniversalCable)
{
return new EnergyTransferProtocol(pointer, sender, amount, new ArrayList()).calculate();
}
return amount;
}
/**
* Emits energy from all sides of a TileEntity.
* @param amount - amount to send
* @param pointer - sending TileEntity
* @return rejected energy
*/
public static double emitEnergyFromAllSides(double amount, TileEntity pointer)
{
if(pointer != null)
{
return new EnergyTransferProtocol(pointer, pointer, amount, new ArrayList()).calculate();
}
return amount;
}
/**
* Emits energy from all sides of a TileEntity, while ignoring specific acceptors.
* @param amount - amount to send
* @param pointer - sending TileEntity
* @param ignored - ignored acceptors
* @return rejected energy
*/
public static double emitEnergyFromAllSidesIgnore(double amount, TileEntity pointer, ArrayList ignored)
{
if(pointer != null)
{
return new EnergyTransferProtocol(pointer, pointer, amount, ignored).calculate();
}
return amount;
}
/**
* Converts a ForgeDirection enum value to it's corresponding value in IndustrialCraft's 'Direction.' Using values()[ordinal()] will not work in this situation,
* as IC2 uses different values from base MC direction theory.

View file

@ -69,7 +69,11 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
if(!worldObj.isRemote)
{
powerProvider.update(this);
if(powerProvider != null)
{
powerProvider.update(this);
}
ElectricityPack electricityPack = ElectricityNetworkHelper.consumeFromMultipleSides(this, getConsumingSides(), getRequest());
setJoules(getJoules()+electricityPack.getWatts());
}

View file

@ -104,7 +104,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
if(tileEntity instanceof IUniversalCable)
{
setJoules(electricityStored - (Math.min(electricityStored, tier.OUTPUT) - MekanismUtils.emitEnergyToNetwork(Math.min(electricityStored, tier.OUTPUT), this, ForgeDirection.getOrientation(facing))));
setJoules(electricityStored - (Math.min(electricityStored, tier.OUTPUT) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, tier.OUTPUT), this, ForgeDirection.getOrientation(facing))));
}
else if(tileEntity instanceof IEnergyConductor && Mekanism.hooks.IC2Loaded)
{

View file

@ -83,6 +83,6 @@ class CablePowerProvider extends PowerProvider
{
ArrayList<TileEntity> ignored = new ArrayList<TileEntity>();
ignored.add(VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), from));
MekanismUtils.emitEnergyFromAllSidesIgnore(quantity*Mekanism.FROM_BC, tileEntity, ignored);
CableUtils.emitEnergyFromAllSidesIgnore(quantity*Mekanism.FROM_BC, tileEntity, ignored);
}
}

View file

@ -22,7 +22,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "5.5.0", dependencies = "required-after:Mekanism")
@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "5.5.1", dependencies = "required-after:Mekanism")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class MekanismGenerators
{

View file

@ -20,6 +20,7 @@ import mekanism.api.ICableOutputter;
import mekanism.api.IUniversalCable;
import mekanism.client.IHasSound;
import mekanism.client.Sound;
import mekanism.common.CableUtils;
import mekanism.common.Mekanism;
import mekanism.common.MekanismUtils;
import mekanism.common.PacketHandler;
@ -98,7 +99,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
if(tileEntity instanceof IUniversalCable)
{
setJoules(electricityStored - (Math.min(electricityStored, output) - MekanismUtils.emitEnergyToNetwork(Math.min(electricityStored, output), this, ForgeDirection.getOrientation(facing))));
setJoules(electricityStored - (Math.min(electricityStored, output) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, output), this, ForgeDirection.getOrientation(facing))));
}
else if(tileEntity instanceof IEnergyConductor && Mekanism.hooks.IC2Loaded)
{

View file

@ -22,7 +22,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "MekanismTools", name = "MekanismTools", version = "5.5.0", dependencies = "required-after:Mekanism")
@Mod(modid = "MekanismTools", name = "MekanismTools", version = "5.5.1", dependencies = "required-after:Mekanism")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class MekanismTools
{