Fixed some imports for Mechanical Debug
This commit is contained in:
parent
5d92c562b5
commit
fb06356ca2
7 changed files with 376 additions and 380 deletions
|
@ -1,244 +1,233 @@
|
|||
package resonantinduction.core.debug;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.LayoutManager;
|
||||
import java.awt.Panel;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.transform.vector.IVectorWorld;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
/**
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
/** @author Darkguardsman */
|
||||
@SuppressWarnings("serial")
|
||||
public class FrameDebug extends Frame implements IVectorWorld
|
||||
{
|
||||
protected long tick = 0;
|
||||
/**
|
||||
* Linked tile
|
||||
*/
|
||||
TileEntity tile = null;
|
||||
boolean debugNode = false;
|
||||
/** Linked tile */
|
||||
TileEntity tile = null;
|
||||
|
||||
public FrameDebug(TileEntity tile)
|
||||
{
|
||||
this();
|
||||
this.tile = tile;
|
||||
}
|
||||
boolean debugNode = false;
|
||||
protected long tick = 0;
|
||||
|
||||
protected FrameDebug()
|
||||
{
|
||||
buildGUI();
|
||||
}
|
||||
public FrameDebug(TileEntity tile)
|
||||
{
|
||||
this();
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to build the base of the GUI
|
||||
*/
|
||||
protected void buildGUI()
|
||||
{
|
||||
Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
|
||||
UpdatePanel topPanel = new UpdatePanel();
|
||||
UpdatePanel botPanel = new UpdatePanel();
|
||||
UpdatePanel rightPanel = new UpdatePanel();
|
||||
protected FrameDebug()
|
||||
{
|
||||
buildGUI();
|
||||
}
|
||||
|
||||
topPanel.setBorder(loweredetched);
|
||||
botPanel.setBorder(loweredetched);
|
||||
rightPanel.setBorder(loweredetched);
|
||||
/** Called to build the base of the GUI */
|
||||
protected void buildGUI()
|
||||
{
|
||||
Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
|
||||
UpdatePanel topPanel = new UpdatePanel();
|
||||
UpdatePanel botPanel = new UpdatePanel();
|
||||
UpdatePanel rightPanel = new UpdatePanel();
|
||||
|
||||
buildTop(topPanel);
|
||||
buildBottom(botPanel);
|
||||
buildCenter(rightPanel);
|
||||
topPanel.setBorder(loweredetched);
|
||||
botPanel.setBorder(loweredetched);
|
||||
rightPanel.setBorder(loweredetched);
|
||||
|
||||
this.add(topPanel, BorderLayout.NORTH);
|
||||
this.add(botPanel, BorderLayout.SOUTH);
|
||||
this.add(rightPanel, BorderLayout.CENTER);
|
||||
buildTop(topPanel);
|
||||
buildBottom(botPanel);
|
||||
buildCenter(rightPanel);
|
||||
|
||||
//exit icon handler
|
||||
addWindowListener(new WindowAdapter()
|
||||
{
|
||||
public void windowClosing(WindowEvent e)
|
||||
{
|
||||
Frame f = (Frame) e.getSource();
|
||||
f.setVisible(false);
|
||||
f.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
this.add(topPanel, BorderLayout.NORTH);
|
||||
this.add(botPanel, BorderLayout.SOUTH);
|
||||
this.add(rightPanel, BorderLayout.CENTER);
|
||||
|
||||
/**
|
||||
* Top are of the Frame
|
||||
*/
|
||||
public void buildTop(UpdatePanel panel)
|
||||
{
|
||||
panel.setLayout(new GridLayout(1, 2, 0, 0));
|
||||
UpdatedLabel tickLabel = new UpdatedLabel("Tile: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + tile;
|
||||
}
|
||||
};
|
||||
panel.add(tickLabel);
|
||||
}
|
||||
//exit icon handler
|
||||
addWindowListener(new WindowAdapter()
|
||||
{
|
||||
public void windowClosing(WindowEvent e)
|
||||
{
|
||||
Frame f = (Frame) e.getSource();
|
||||
f.setVisible(false);
|
||||
f.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bottom are of the Frame
|
||||
*/
|
||||
public void buildBottom(UpdatePanel panel)
|
||||
{
|
||||
panel.setLayout(new GridLayout(1, 4, 0, 0));
|
||||
UpdatedLabel tickLabel = new UpdatedLabel("Tick: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + tick;
|
||||
}
|
||||
};
|
||||
panel.add(tickLabel);
|
||||
/** Top are of the Frame */
|
||||
public void buildTop(UpdatePanel panel)
|
||||
{
|
||||
panel.setLayout(new GridLayout(1, 2, 0, 0));
|
||||
UpdatedLabel tickLabel = new UpdatedLabel("Tile: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + tile;
|
||||
}
|
||||
};
|
||||
panel.add(tickLabel);
|
||||
}
|
||||
|
||||
UpdatedLabel xLabel = new UpdatedLabel("X: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + x();
|
||||
}
|
||||
};
|
||||
panel.add(xLabel);
|
||||
/** Bottom are of the Frame */
|
||||
public void buildBottom(UpdatePanel panel)
|
||||
{
|
||||
panel.setLayout(new GridLayout(1, 4, 0, 0));
|
||||
UpdatedLabel tickLabel = new UpdatedLabel("Tick: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + tick;
|
||||
}
|
||||
};
|
||||
panel.add(tickLabel);
|
||||
|
||||
UpdatedLabel yLabel = new UpdatedLabel("Y: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + y();
|
||||
}
|
||||
};
|
||||
panel.add(yLabel);
|
||||
UpdatedLabel xLabel = new UpdatedLabel("X: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + x();
|
||||
}
|
||||
};
|
||||
panel.add(xLabel);
|
||||
|
||||
UpdatedLabel zLabel = new UpdatedLabel("Z: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + z();
|
||||
}
|
||||
};
|
||||
panel.add(zLabel);
|
||||
}
|
||||
UpdatedLabel yLabel = new UpdatedLabel("Y: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + y();
|
||||
}
|
||||
};
|
||||
panel.add(yLabel);
|
||||
|
||||
/**
|
||||
* Left are of the Frame
|
||||
*/
|
||||
public void buildCenter(UpdatePanel panel)
|
||||
{
|
||||
panel.setLayout(new GridLayout(1, 4, 0, 0));
|
||||
UpdatedLabel tickLabel = new UpdatedLabel("Valid: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + (tile != null ? tile.isInvalid() : "null");
|
||||
}
|
||||
};
|
||||
panel.add(tickLabel);
|
||||
UpdatedLabel block_label = new UpdatedLabel("BLOCK: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + (tile != null ? tile.getBlockType() : "null");
|
||||
}
|
||||
};
|
||||
panel.add(block_label);
|
||||
UpdatedLabel zLabel = new UpdatedLabel("Z: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + z();
|
||||
}
|
||||
};
|
||||
panel.add(zLabel);
|
||||
}
|
||||
|
||||
UpdatedLabel meta_label = new UpdatedLabel("META: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + (tile != null && tile.getBlockType() != null ? tile.getBlockType() : "-");
|
||||
}
|
||||
};
|
||||
panel.add(meta_label);
|
||||
/** Left are of the Frame */
|
||||
public void buildCenter(UpdatePanel panel)
|
||||
{
|
||||
panel.setLayout(new GridLayout(1, 4, 0, 0));
|
||||
UpdatedLabel tickLabel = new UpdatedLabel("Valid: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + (tile != null ? tile.isInvalid() : "null");
|
||||
}
|
||||
};
|
||||
panel.add(tickLabel);
|
||||
UpdatedLabel block_label = new UpdatedLabel("BLOCK: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + (tile != null ? tile.getBlockType() : "null");
|
||||
}
|
||||
};
|
||||
panel.add(block_label);
|
||||
|
||||
UpdatedLabel id_label = new UpdatedLabel("ID: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + (tile != null && tile.getBlockType() != null ? tile.getBlockType() : "-");
|
||||
}
|
||||
};
|
||||
panel.add(id_label);
|
||||
UpdatedLabel meta_label = new UpdatedLabel("META: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + (tile != null && tile.getBlockType() != null ? tile.getBlockType().blockID : "-");
|
||||
}
|
||||
};
|
||||
panel.add(meta_label);
|
||||
|
||||
}
|
||||
UpdatedLabel id_label = new UpdatedLabel("ID: ")
|
||||
{
|
||||
@Override
|
||||
public String buildLabel()
|
||||
{
|
||||
return super.buildLabel() + (tile != null && tile.getBlockType() != null ? tile.getBlockType().blockID : "-");
|
||||
}
|
||||
};
|
||||
panel.add(id_label);
|
||||
|
||||
/**
|
||||
* Called each tick by the host of this GUI
|
||||
*/
|
||||
public void update()
|
||||
{
|
||||
tick++;
|
||||
if (tick >= Long.MAX_VALUE)
|
||||
{
|
||||
tick = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (Component component : getComponents())
|
||||
{
|
||||
if (component instanceof IUpdate)
|
||||
{
|
||||
((IUpdate) component).update();
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Called each tick by the host of this GUI */
|
||||
public void update()
|
||||
{
|
||||
tick++;
|
||||
if (tick >= Long.MAX_VALUE)
|
||||
{
|
||||
tick = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the frame
|
||||
*/
|
||||
public void showDebugFrame()
|
||||
{
|
||||
setTitle("Resonant Engine Debug Window");
|
||||
setBounds(200, 200, 450, 600);
|
||||
setVisible(true);
|
||||
}
|
||||
for (Component component : getComponents())
|
||||
{
|
||||
if (component instanceof IUpdate)
|
||||
{
|
||||
((IUpdate) component).update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the frame and tells it to die off
|
||||
*/
|
||||
public void closeDebugFrame()
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
/** Shows the frame */
|
||||
public void showDebugFrame()
|
||||
{
|
||||
setTitle("Resonant Engine Debug Window");
|
||||
setBounds(200, 200, 450, 600);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double z()
|
||||
{
|
||||
return tile != null ? tile.zCoord : 0;
|
||||
}
|
||||
/** Hides the frame and tells it to die off */
|
||||
public void closeDebugFrame()
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double x()
|
||||
{
|
||||
return tile != null ? tile.xCoord : 0;
|
||||
}
|
||||
@Override
|
||||
public double z()
|
||||
{
|
||||
return tile != null ? tile.zCoord : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double y()
|
||||
{
|
||||
return tile != null ? tile.yCoord : 0;
|
||||
}
|
||||
@Override
|
||||
public double x()
|
||||
{
|
||||
return tile != null ? tile.xCoord : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World world()
|
||||
{
|
||||
return tile != null ? tile.getWorldObj() : null;
|
||||
}
|
||||
@Override
|
||||
public double y()
|
||||
{
|
||||
return tile != null ? tile.yCoord : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World world()
|
||||
{
|
||||
return tile != null ? tile.getWorldObj() : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,117 +1,109 @@
|
|||
package resonantinduction.core.debug;
|
||||
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import universalelectricity.api.core.grid.INode;
|
||||
import universalelectricity.api.core.grid.INodeProvider;
|
||||
|
||||
/**
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
/** @author Darkguardsman */
|
||||
@SuppressWarnings("serial")
|
||||
public class FrameNodeDebug extends FrameDebug
|
||||
{
|
||||
protected INodeProvider nodeProvider = null;
|
||||
/**
|
||||
* Linked node
|
||||
*/
|
||||
protected INode node = null;
|
||||
protected Class<? extends INode> nodeClazz = null;
|
||||
protected INodeProvider nodeProvider = null;
|
||||
/** Linked node */
|
||||
protected INode node = null;
|
||||
protected Class<? extends INode> nodeClazz = null;
|
||||
|
||||
/**
|
||||
* Are we debugging a node
|
||||
*/
|
||||
/** Are we debugging a node */
|
||||
|
||||
public FrameNodeDebug(TileEntity tile, Class<? extends INode> nodeClazz)
|
||||
{
|
||||
super(tile);
|
||||
this.nodeClazz = nodeClazz;
|
||||
}
|
||||
public FrameNodeDebug(TileEntity tile, Class<? extends INode> nodeClazz)
|
||||
{
|
||||
super(tile);
|
||||
this.nodeClazz = nodeClazz;
|
||||
}
|
||||
|
||||
public FrameNodeDebug(INodeProvider node, Class<? extends INode> nodeClazz)
|
||||
{
|
||||
super();
|
||||
this.nodeProvider = node;
|
||||
this.nodeClazz = nodeClazz;
|
||||
}
|
||||
public FrameNodeDebug(INodeProvider node, Class<? extends INode> nodeClazz)
|
||||
{
|
||||
super();
|
||||
this.nodeProvider = node;
|
||||
this.nodeClazz = nodeClazz;
|
||||
}
|
||||
|
||||
public FrameNodeDebug(INode node)
|
||||
{
|
||||
super();
|
||||
this.node = node;
|
||||
}
|
||||
public FrameNodeDebug(INode node)
|
||||
{
|
||||
super();
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the node used for debug
|
||||
*/
|
||||
public INode getNode()
|
||||
{
|
||||
if (tile instanceof INodeProvider && nodeClazz != null)
|
||||
{
|
||||
return ((INodeProvider) tile).getNode(nodeClazz, ForgeDirection.UNKNOWN);
|
||||
}
|
||||
else if (nodeProvider != null && nodeClazz != null)
|
||||
{
|
||||
return nodeProvider.getNode(nodeClazz, ForgeDirection.UNKNOWN);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
/** Gets the node used for debug */
|
||||
public INode getNode()
|
||||
{
|
||||
if (tile instanceof INodeProvider && nodeClazz != null)
|
||||
{
|
||||
return ((INodeProvider) tile).getNode(nodeClazz, ForgeDirection.UNKNOWN);
|
||||
}
|
||||
else if (nodeProvider != null && nodeClazz != null)
|
||||
{
|
||||
return nodeProvider.getNode(nodeClazz, ForgeDirection.UNKNOWN);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double z()
|
||||
{
|
||||
if (nodeProvider instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity) nodeProvider).zCoord;
|
||||
}
|
||||
else if (nodeProvider instanceof TMultiPart)
|
||||
{
|
||||
return ((TMultiPart) nodeProvider).z();
|
||||
}
|
||||
return super.z();
|
||||
}
|
||||
@Override
|
||||
public double z()
|
||||
{
|
||||
if (nodeProvider instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity) nodeProvider).zCoord;
|
||||
}
|
||||
else if (nodeProvider instanceof TMultiPart)
|
||||
{
|
||||
return ((TMultiPart) nodeProvider).z();
|
||||
}
|
||||
return super.z();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double x()
|
||||
{
|
||||
if (nodeProvider instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity) nodeProvider).xCoord;
|
||||
}
|
||||
else if (nodeProvider instanceof TMultiPart)
|
||||
{
|
||||
return ((TMultiPart) nodeProvider).x();
|
||||
}
|
||||
return super.x();
|
||||
}
|
||||
@Override
|
||||
public double x()
|
||||
{
|
||||
if (nodeProvider instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity) nodeProvider).xCoord;
|
||||
}
|
||||
else if (nodeProvider instanceof TMultiPart)
|
||||
{
|
||||
return ((TMultiPart) nodeProvider).x();
|
||||
}
|
||||
return super.x();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double y()
|
||||
{
|
||||
if (nodeProvider instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity) nodeProvider).yCoord;
|
||||
}
|
||||
else if (nodeProvider instanceof TMultiPart)
|
||||
{
|
||||
return ((TMultiPart) nodeProvider).y();
|
||||
}
|
||||
return super.y();
|
||||
}
|
||||
@Override
|
||||
public double y()
|
||||
{
|
||||
if (nodeProvider instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity) nodeProvider).yCoord;
|
||||
}
|
||||
else if (nodeProvider instanceof TMultiPart)
|
||||
{
|
||||
return ((TMultiPart) nodeProvider).y();
|
||||
}
|
||||
return super.y();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World world()
|
||||
{
|
||||
if (nodeProvider instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity) nodeProvider).getWorldObj();
|
||||
}
|
||||
else if (nodeProvider instanceof TMultiPart)
|
||||
{
|
||||
return ((TMultiPart) nodeProvider).world();
|
||||
}
|
||||
return super.world();
|
||||
}
|
||||
@Override
|
||||
public World world()
|
||||
{
|
||||
if (nodeProvider instanceof TileEntity)
|
||||
{
|
||||
return ((TileEntity) nodeProvider).getWorldObj();
|
||||
}
|
||||
else if (nodeProvider instanceof TMultiPart)
|
||||
{
|
||||
return ((TMultiPart) nodeProvider).world();
|
||||
}
|
||||
return super.world();
|
||||
}
|
||||
}
|
||||
|
|
9
src/main/scala/resonantinduction/core/debug/IDebug.java
Normal file
9
src/main/scala/resonantinduction/core/debug/IDebug.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package resonantinduction.core.debug;
|
||||
|
||||
/** Used to pass info to the debug GUI
|
||||
*
|
||||
* @author Darkguardsman */
|
||||
public interface IDebug
|
||||
{
|
||||
|
||||
}
|
|
@ -1,11 +1,9 @@
|
|||
package resonantinduction.core.debug;
|
||||
|
||||
/**
|
||||
* Used by objects can update each tick
|
||||
*
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
/** Used by objects can update each tick
|
||||
*
|
||||
* @author Darkguardsman */
|
||||
public interface IUpdate
|
||||
{
|
||||
public void update();
|
||||
public void update();
|
||||
}
|
||||
|
|
|
@ -1,32 +1,33 @@
|
|||
package resonantinduction.core.debug;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Panel;
|
||||
|
||||
/**
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/** @author Darkguardsman */
|
||||
@SuppressWarnings("serial")
|
||||
public class UpdatePanel extends JPanel implements IUpdate
|
||||
{
|
||||
public UpdatePanel()
|
||||
{
|
||||
}
|
||||
public UpdatePanel()
|
||||
{
|
||||
}
|
||||
|
||||
public UpdatePanel(BorderLayout borderLayout)
|
||||
{
|
||||
super(borderLayout);
|
||||
}
|
||||
public UpdatePanel(BorderLayout borderLayout)
|
||||
{
|
||||
super(borderLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
for (Component component : getComponents())
|
||||
{
|
||||
if (component instanceof IUpdate)
|
||||
{
|
||||
((IUpdate) component).update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
for (Component component : getComponents())
|
||||
{
|
||||
if (component instanceof IUpdate)
|
||||
{
|
||||
((IUpdate) component).update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,30 @@
|
|||
package resonantinduction.core.debug;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Label;
|
||||
|
||||
/**
|
||||
* Simple label with an update method
|
||||
*
|
||||
* @author Darkguardsman
|
||||
*/
|
||||
/** Simple label with an update method
|
||||
*
|
||||
* @author Darkguardsman */
|
||||
@SuppressWarnings("serial")
|
||||
public class UpdatedLabel extends Label implements IUpdate
|
||||
{
|
||||
String start_string = "I Am a Label";
|
||||
String start_string = "I Am a Label";
|
||||
|
||||
public UpdatedLabel(String start)
|
||||
{
|
||||
super(start);
|
||||
this.start_string = start;
|
||||
}
|
||||
public UpdatedLabel(String start)
|
||||
{
|
||||
super(start);
|
||||
this.start_string = start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
this.setText(buildLabel());
|
||||
}
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
this.setText(buildLabel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Recreates then returns the label's string value
|
||||
*/
|
||||
public String buildLabel()
|
||||
{
|
||||
return start_string;
|
||||
}
|
||||
/** Recreates then returns the label's string value */
|
||||
public String buildLabel()
|
||||
{
|
||||
return start_string;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,18 +13,21 @@ import universalelectricity.core.transform.vector.{Vector3, VectorWorld}
|
|||
|
||||
import scala.util.control.Breaks._
|
||||
|
||||
|
||||
abstract class PartConductor extends TMultiPart with TraitPart {
|
||||
override def doesTick: Boolean = {
|
||||
abstract class PartConductor extends TMultiPart with TraitPart
|
||||
{
|
||||
override def doesTick: Boolean =
|
||||
{
|
||||
return false
|
||||
}
|
||||
|
||||
def getConnections: Array[AnyRef] = {
|
||||
def getConnections: Array[AnyRef] =
|
||||
{
|
||||
return this.connections
|
||||
}
|
||||
|
||||
/** EXTERNAL USE Can this wire be connected by another block? */
|
||||
def canConnect(direction: ForgeDirection, source: AnyRef): Boolean = {
|
||||
def canConnect(direction: ForgeDirection, source: AnyRef): Boolean =
|
||||
{
|
||||
val connectPos: Vector3 = new Vector3(tile).add(direction)
|
||||
val connectTile: TileEntity = connectPos.getTileEntity(world)
|
||||
return Compatibility.isHandler(connectTile)
|
||||
|
@ -33,21 +36,23 @@ abstract class PartConductor extends TMultiPart with TraitPart {
|
|||
def canConnectTo(obj: AnyRef): Boolean
|
||||
|
||||
/** Recalculates all the network connections */
|
||||
protected def recalculateConnections {
|
||||
protected def recalculateConnections
|
||||
{
|
||||
this.connections = new Array[AnyRef](6)
|
||||
for(i <- 0 until 6)
|
||||
for (i <- 0 until 6)
|
||||
{
|
||||
val side: ForgeDirection = ForgeDirection.getOrientation(i)
|
||||
val tileEntity: TileEntity = new VectorWorld(world, x, y, z).getTileEntity
|
||||
if (this.canConnect(side, tileEntity))
|
||||
{
|
||||
val side: ForgeDirection = ForgeDirection.getOrientation(i)
|
||||
val tileEntity: TileEntity = new VectorWorld(world, x, y, z).getTileEntity
|
||||
if (this.canConnect(side, tileEntity))
|
||||
{
|
||||
connections(i) = tileEntity
|
||||
}
|
||||
connections(i) = tileEntity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** IC2 Functions */
|
||||
override def onWorldJoin {
|
||||
override def onWorldJoin
|
||||
{
|
||||
if (!world.isRemote && tile.isInstanceOf[IEnergyTile])
|
||||
{
|
||||
var foundAnotherPart: Boolean = false
|
||||
|
@ -73,18 +78,21 @@ abstract class PartConductor extends TMultiPart with TraitPart {
|
|||
if (!world.isRemote)
|
||||
{
|
||||
//this.getNetwork.split(this)
|
||||
if (tile.isInstanceOf[IEnergyTile]) {
|
||||
if (tile.isInstanceOf[IEnergyTile])
|
||||
{
|
||||
var foundAnotherPart: Boolean = false
|
||||
for(i <- 0 until tile.partList.size)
|
||||
for (i <- 0 until tile.partList.size)
|
||||
{
|
||||
val part: TMultiPart = tile.partMap(i)
|
||||
if (part.isInstanceOf[IEnergyTile] && part != this) {
|
||||
if (part.isInstanceOf[IEnergyTile] && part != this)
|
||||
{
|
||||
foundAnotherPart = true
|
||||
break //todo: break is not supported
|
||||
}
|
||||
|
||||
}
|
||||
if (!foundAnotherPart) {
|
||||
if (!foundAnotherPart)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(tile.asInstanceOf[IEnergyTile]))
|
||||
}
|
||||
}
|
||||
|
@ -92,15 +100,18 @@ abstract class PartConductor extends TMultiPart with TraitPart {
|
|||
super.preRemove
|
||||
}
|
||||
|
||||
override def save(nbt: NBTTagCompound) {
|
||||
override def save(nbt: NBTTagCompound)
|
||||
{
|
||||
super.save(nbt)
|
||||
}
|
||||
|
||||
override def load(nbt: NBTTagCompound) {
|
||||
override def load(nbt: NBTTagCompound)
|
||||
{
|
||||
super.load(nbt)
|
||||
}
|
||||
|
||||
override def toString: String = {
|
||||
override def toString: String =
|
||||
{
|
||||
return "[PartConductor]" + x + "x " + y + "y " + z + "z "
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue