Added toString to several tiles allowing better debug

This commit is contained in:
Robert S 2014-04-27 15:20:48 -04:00
parent 67d7114f1b
commit 990f83d5ce
9 changed files with 2027 additions and 2023 deletions

View file

@ -17,16 +17,12 @@ import calclavia.lib.network.IPacketSender;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
/** /** A modular battery box that allows shared connections with boxes next to it.
* A modular battery box that allows shared connections with boxes next to it.
* *
* @author Calclavia * @author Calclavia */
*/
public class TileBattery extends TileEnergyDistribution implements IVoltageInput, IVoltageOutput, IPacketSender, IPacketReceiver, IEnergyInterface, IEnergyContainer public class TileBattery extends TileEnergyDistribution implements IVoltageInput, IVoltageOutput, IPacketSender, IPacketReceiver, IEnergyInterface, IEnergyContainer
{ {
/** /** Tiers: 0, 1, 2 */
* Tiers: 0, 1, 2
*/
public static final int MAX_TIER = 2; public static final int MAX_TIER = 2;
/** The transfer rate **/ /** The transfer rate **/
@ -40,10 +36,8 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
this.saveIOMap = true; this.saveIOMap = true;
} }
/** /** @param tier - 0, 1, 2
* @param tier - 0, 1, 2 * @return */
* @return
*/
public static long getEnergyForTier(int tier) public static long getEnergyForTier(int tier)
{ {
return Math.round(Math.pow(500000000, (tier / (MAX_TIER + 0.7f)) + 1) / (500000000)) * (500000000); return Math.round(Math.pow(500000000, (tier / (MAX_TIER + 0.7f)) + 1) / (500000000)) * (500000000);
@ -114,4 +108,10 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
super.setIO(dir, type); super.setIO(dir, type);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
} }
@Override
public String toString()
{
return "[TileBattery]" + x() + "x " + y() + "y " + z() + "z ";
}
} }

View file

@ -140,4 +140,10 @@ public class PartCharger extends PartInventoryPanel implements IEnergyInterface
{ {
return slot < this.getSizeInventory() && stack != null && CompatibilityModule.isHandler(stack.getItem()); return slot < this.getSizeInventory() && stack != null && CompatibilityModule.isHandler(stack.getItem());
} }
@Override
public String toString()
{
return "[PartCharger]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
}
} }

View file

@ -39,18 +39,19 @@ import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
/** /** Block that detects power.
* Block that detects power.
* *
* @author Calclavia * @author Calclavia */
*
*/
public class PartMultimeter extends PartFace implements IConnector<MultimeterNetwork>, IRedstonePart, IPacketReceiver public class PartMultimeter extends PartFace implements IConnector<MultimeterNetwork>, IRedstonePart, IPacketReceiver
{ {
public enum DetectMode public enum DetectMode
{ {
NONE("none"), LESS_THAN("lessThan"), LESS_THAN_EQUAL("lessThanOrEqual"), EQUAL("equal"), NONE("none"),
GREATER_THAN_EQUAL("greaterThanOrEqual"), GREATER_THAN("greaterThan"); LESS_THAN("lessThan"),
LESS_THAN_EQUAL("lessThanOrEqual"),
EQUAL("equal"),
GREATER_THAN_EQUAL("greaterThanOrEqual"),
GREATER_THAN("greaterThan");
public String display; public String display;
@ -62,9 +63,7 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>(); public Set<EntityPlayer> playersUsing = new HashSet<EntityPlayer>();
/** /** Detection */
* Detection
*/
public double redstoneTriggerLimit; public double redstoneTriggerLimit;
public byte detectType = 0; public byte detectType = 0;
public byte graphType = 0; public byte graphType = 0;
@ -134,9 +133,7 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
refresh(); refresh();
} }
/** /** Gets the multimeter on the same plane. */
* Gets the multimeter on the same plane.
*/
public PartMultimeter getMultimeter(int x, int y, int z) public PartMultimeter getMultimeter(int x, int y, int z)
{ {
TileEntity tileEntity = world().getBlockTileEntity(x, y, z); TileEntity tileEntity = world().getBlockTileEntity(x, y, z);
@ -237,9 +234,7 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
ForgeDirection receivingSide = getDirection().getOpposite(); ForgeDirection receivingSide = getDirection().getOpposite();
TileEntity tileEntity = getDetectedTile(); TileEntity tileEntity = getDetectedTile();
/** /** Update Energy Graph */
* Update Energy Graph
*/
if (tileEntity instanceof IConductor) if (tileEntity instanceof IConductor)
{ {
IConnector<IEnergyNetwork> instance = ((IConductor) tileEntity).getInstance(receivingSide); IConnector<IEnergyNetwork> instance = ((IConductor) tileEntity).getInstance(receivingSide);
@ -312,9 +307,7 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
getNetwork().energyGraph.queue(CompatibilityModule.getEnergy(tileEntity, receivingSide)); getNetwork().energyGraph.queue(CompatibilityModule.getEnergy(tileEntity, receivingSide));
/** /** Update Energy Capacity Graph */
* Update Energy Capacity Graph
*/
getNetwork().energyCapacityGraph.queue(CompatibilityModule.getMaxEnergy(tileEntity, receivingSide)); getNetwork().energyCapacityGraph.queue(CompatibilityModule.getMaxEnergy(tileEntity, receivingSide));
} }
@ -584,4 +577,10 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
return Cuboid6.full; return Cuboid6.full;
} }
@Override
public String toString()
{
return "[PartMultimeter]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
}
} }

View file

@ -343,4 +343,10 @@ public abstract class PartAdvancedWire extends PartConductor
return false; return false;
} }
@Override
public String toString()
{
return "[PartAdvancedWire]" + x() + "x " + y() + "y " + z() + "z ";
}
} }

View file

@ -26,9 +26,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
protected Object[] connections = new Object[6]; protected Object[] connections = new Object[6];
/** /** Universal Electricity conductor functions. */
* Universal Electricity conductor functions.
*/
@Override @Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive) public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{ {
@ -70,9 +68,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
return this.connections; return this.connections;
} }
/** /** EXTERNAL USE Can this wire be connected by another block? */
* EXTERNAL USE Can this wire be connected by another block?
*/
@Override @Override
public boolean canConnect(ForgeDirection direction, Object source) public boolean canConnect(ForgeDirection direction, Object source)
{ {
@ -89,15 +85,11 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
public abstract boolean canConnectTo(Object obj); public abstract boolean canConnectTo(Object obj);
/** /** Recalculates all the network connections */
* Recalculates all the network connections
*/
protected void recalculateConnections() protected void recalculateConnections()
{ {
this.connections = new Object[6]; this.connections = new Object[6];
/** /** Calculate all external connections with this conductor. */
* Calculate all external connections with this conductor.
*/
for (byte i = 0; i < 6; i++) for (byte i = 0; i < 6; i++)
{ {
ForgeDirection side = ForgeDirection.getOrientation(i); ForgeDirection side = ForgeDirection.getOrientation(i);
@ -110,9 +102,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
} }
} }
/** /** IC2 Functions */
* IC2 Functions
*/
@Override @Override
public void onWorldJoin() public void onWorldJoin()
{ {
@ -191,4 +181,10 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
super.load(nbt); super.load(nbt);
getNetwork().setBufferFor(this, nbt.getLong("savedBuffer")); getNetwork().setBufferFor(this, nbt.getLong("savedBuffer"));
} }
@Override
public String toString()
{
return "[PartConductor]" + x() + "x " + y() + "y " + z() + "z ";
}
} }

View file

@ -41,13 +41,11 @@ import codechicken.multipart.TileMultipart;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
/** /** This is the base class for all wire types. It can be used for any sub type, as it contains the
* This is the base class for all wire types. It can be used for any sub type, as it contains the
* base calculations necessary to create a working wire. This calculates all possible connections to * base calculations necessary to create a working wire. This calculates all possible connections to
* sides, around corners, and inside corners, while checking for microblock obstructions. * sides, around corners, and inside corners, while checking for microblock obstructions.
* *
* @author Modified by Calclavia, MrTJP * @author Modified by Calclavia, MrTJP */
*/
public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormalOcclusion public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormalOcclusion
{ {
public static Cuboid6[][] selectionBounds = new Cuboid6[3][6]; public static Cuboid6[][] selectionBounds = new Cuboid6[3][6];
@ -70,8 +68,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
public byte side; public byte side;
/** /** A map of the corners.
* A map of the corners.
* *
* *
* Currently split into 4 nybbles (from lowest) 0 = Corner connections (this wire should connect * Currently split into 4 nybbles (from lowest) 0 = Corner connections (this wire should connect
@ -80,8 +77,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
* 3 = Internal open connections (this wire is not blocked by a cover/edge part and *could* * 3 = Internal open connections (this wire is not blocked by a cover/edge part and *could*
* connect through side) bit 16 = connection to the centerpart 5 = Render corner connections. * connect through side) bit 16 = connection to the centerpart 5 = Render corner connections.
* Like corner connections but set to low if the other wire part is smaller than this (they * Like corner connections but set to low if the other wire part is smaller than this (they
* render to us not us to them) * render to us not us to them) */
*/
public int connMap; public int connMap;
public PartFlatWire() public PartFlatWire()
@ -427,9 +423,7 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
return true; return true;
} }
/** /** Check for a micro-energy block */
* Check for a micro-energy block
*/
if (canConnectTo(tp)) if (canConnectTo(tp))
{ {
connections[absSide] = tp; connections[absSide] = tp;
@ -502,11 +496,9 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
tile().remPart(this); tile().remPart(this);
} }
/** /** Recalculates connections to blocks outside this space
* Recalculates connections to blocks outside this space
* *
* @return true if a new connection was added or one was removed * @return true if a new connection was added or one was removed */
*/
protected boolean updateExternalConnections() protected boolean updateExternalConnections()
{ {
int newConn = 0; int newConn = 0;
@ -558,11 +550,9 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
return false; return false;
} }
/** /** Recalculates connections to other parts within this space
* Recalculates connections to other parts within this space
* *
* @return true if a new connection was added or one was removed * @return true if a new connection was added or one was removed */
*/
protected boolean updateInternalConnections() protected boolean updateInternalConnections()
{ {
int newConn = 0; int newConn = 0;
@ -587,11 +577,9 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
return false; return false;
} }
/** /** Recalculates connections that can be made to other parts outside of this space
* Recalculates connections that can be made to other parts outside of this space
* *
* @return true if external connections should be recalculated * @return true if external connections should be recalculated */
*/
protected boolean updateOpenConnections() protected boolean updateOpenConnections()
{ {
int newConn = 0; int newConn = 0;
@ -620,10 +608,8 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
return true; return true;
} }
/** /** Return a corner connection state. 0 = No connection 1 = Physical connection 2 = Render
* Return a corner connection state. 0 = No connection 1 = Physical connection 2 = Render * connection */
* connection
*/
public int connectCorner(int r) public int connectCorner(int r)
{ {
int absDir = Rotation.rotateSide(side, r); int absDir = Rotation.rotateSide(side, r);
@ -955,12 +941,10 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
RenderFlatWire.renderBreakingOverlay(renderBlocks.overrideBlockTexture, this); RenderFlatWire.renderBreakingOverlay(renderBlocks.overrideBlockTexture, this);
} }
/** /** Utility method to aid in initializing this or subclasses, usually when you need to change the
* Utility method to aid in initializing this or subclasses, usually when you need to change the
* wire to another type * wire to another type
* *
* @param otherCable the wire to copy from * @param otherCable the wire to copy from */
*/
public void copyFrom(PartFlatWire otherCable) public void copyFrom(PartFlatWire otherCable)
{ {
this.isInsulated = otherCable.isInsulated; this.isInsulated = otherCable.isInsulated;
@ -972,4 +956,10 @@ public class PartFlatWire extends PartAdvancedWire implements TFacePart, JNormal
this.setNetwork(otherCable.getNetwork()); this.setNetwork(otherCable.getNetwork());
this.getNetwork().setBufferFor(this, otherCable.getNetwork().getBufferOf(otherCable)); this.getNetwork().setBufferFor(this, otherCable.getNetwork().getBufferOf(otherCable));
} }
@Override
public String toString()
{
return "[PartFlatWire]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
}
} }

View file

@ -8,12 +8,10 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import calclavia.lib.prefab.damage.ElectricalDamage;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
@ -29,6 +27,7 @@ import universalelectricity.api.electricity.IElectricalNetwork;
import universalelectricity.api.energy.EnergyNetworkLoader; import universalelectricity.api.energy.EnergyNetworkLoader;
import universalelectricity.api.energy.IConductor; import universalelectricity.api.energy.IConductor;
import universalelectricity.api.energy.IEnergyNetwork; import universalelectricity.api.energy.IEnergyNetwork;
import calclavia.lib.prefab.damage.ElectricalDamage;
import codechicken.lib.lighting.LazyLightMatrix; import codechicken.lib.lighting.LazyLightMatrix;
import codechicken.lib.render.CCRenderState; import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.IconTransformation; import codechicken.lib.render.IconTransformation;
@ -357,4 +356,10 @@ public class PartFramedWire extends PartFramedConnection<EnumWireMaterial, ICond
ElectricalDamage.handleElectrocution(entity, this, (IElectricalNetwork) this.getNetwork()); ElectricalDamage.handleElectrocution(entity, this, (IElectricalNetwork) this.getNetwork());
} }
@Override
public String toString()
{
return "[PartFramedWire]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
}
} }

View file

@ -550,4 +550,10 @@ public class PartGear extends PartMechanical implements IMultiBlockStructure<Par
{ {
return Cuboid6.full.copy().expand(multiBlockRadius); return Cuboid6.full.copy().expand(multiBlockRadius);
} }
@Override
public String toString()
{
return "[PartGear]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
}
} }

View file

@ -60,9 +60,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
protected N network; protected N network;
/** /** Bitmask connections */
* Bitmask connections
*/
public byte currentWireConnections = 0x00; public byte currentWireConnections = 0x00;
public byte currentAcceptorConnections = 0x00; public byte currentAcceptorConnections = 0x00;
@ -108,9 +106,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
return subParts; return subParts;
} }
/** /** Rendering and block bounds. */
* Rendering and block bounds.
*/
@Override @Override
public Iterable<Cuboid6> getCollisionBoxes() public Iterable<Cuboid6> getCollisionBoxes()
{ {
@ -189,9 +185,7 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
} }
} }
/** /** CONNECTION LOGIC CODE */
* CONNECTION LOGIC CODE
*/
protected abstract boolean canConnectTo(TileEntity tile, ForgeDirection to); protected abstract boolean canConnectTo(TileEntity tile, ForgeDirection to);
protected abstract C getConnector(TileEntity tile); protected abstract C getConnector(TileEntity tile);
@ -208,13 +202,11 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
return notPrevented; return notPrevented;
} }
/** /** Override if there are ways of preventing a connection
* Override if there are ways of preventing a connection
* *
* @param tile The TileEntity on the given side * @param tile The TileEntity on the given side
* @param side The side we're checking * @param side The side we're checking
* @return Whether we're preventing connections on given side or to given tileEntity * @return Whether we're preventing connections on given side or to given tileEntity */
*/
public boolean isConnectionPrevented(TileEntity tile, ForgeDirection side) public boolean isConnectionPrevented(TileEntity tile, ForgeDirection side)
{ {
return (!this.canConnectTo(tile, side)) || (isBlockedOnSide(side)); return (!this.canConnectTo(tile, side)) || (isBlockedOnSide(side));
@ -297,10 +289,8 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
tile().markRender(); tile().markRender();
} }
/** /** Should include connections that are in the current connection maps even if those connections
* Should include connections that are in the current connection maps even if those connections * aren't allowed any more. This is so that networks split correctly. */
* aren't allowed any more. This is so that networks split correctly.
*/
@Override @Override
public TileEntity[] getConnections() public TileEntity[] getConnections()
{ {
@ -430,4 +420,10 @@ public abstract class PartFramedConnection<M extends Enum, C extends IConnector<
return this; return this;
} }
@Override
public String toString()
{
return "[PartFramedConnection]" + x() + "x " + y() + "y " + z() + "z " + getSlotMask() + "s ";
}
} }