Moved some things to RE, and converted a few classes

This commit is contained in:
Robert S 2014-09-25 18:26:42 -04:00
parent aff1d3c789
commit 58715f9f07
15 changed files with 90 additions and 587 deletions

View file

@ -1,50 +0,0 @@
package resonantinduction.core;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import java.util.HashMap;
public class Timer<K>
{
private final HashMap<K, Integer> clientTimer = new HashMap<K, Integer>();
private final HashMap<K, Integer> serverTimer = new HashMap<K, Integer>();
public void put(K key, int defaultTime)
{
getTimeMap().put(key, defaultTime);
}
public boolean containsKey(K key)
{
return getTimeMap().containsKey(key);
}
public void remove(K key)
{
getTimeMap().remove(key);
}
public int decrease(K key)
{
return decrease(key, 1);
}
public int decrease(K key, int amount)
{
int timeLeft = getTimeMap().get(key) - amount;
getTimeMap().put(key, timeLeft);
return timeLeft;
}
public HashMap<K, Integer> getTimeMap()
{
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
{
return serverTimer;
}
return clientTimer;
}
}

View file

@ -1,233 +0,0 @@
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;
/** @author Darkguardsman */
@SuppressWarnings("serial")
public class FrameDebug extends Frame implements IVectorWorld
{
/** Linked tile */
TileEntity tile = null;
boolean debugNode = false;
protected long tick = 0;
public FrameDebug(TileEntity tile)
{
this();
this.tile = tile;
}
protected FrameDebug()
{
buildGUI();
}
/** 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();
topPanel.setBorder(loweredetched);
botPanel.setBorder(loweredetched);
rightPanel.setBorder(loweredetched);
buildTop(topPanel);
buildBottom(botPanel);
buildCenter(rightPanel);
this.add(topPanel, BorderLayout.NORTH);
this.add(botPanel, BorderLayout.SOUTH);
this.add(rightPanel, BorderLayout.CENTER);
//exit icon handler
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
Frame f = (Frame) e.getSource();
f.setVisible(false);
f.dispose();
}
});
}
/** 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);
}
/** 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 xLabel = new UpdatedLabel("X: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + x();
}
};
panel.add(xLabel);
UpdatedLabel yLabel = new UpdatedLabel("Y: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + y();
}
};
panel.add(yLabel);
UpdatedLabel zLabel = new UpdatedLabel("Z: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + z();
}
};
panel.add(zLabel);
}
/** 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 meta_label = new UpdatedLabel("META: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + (tile != null && tile.getBlockType() != null ? tile.getBlockMetadata() : "-");
}
};
panel.add(meta_label);
UpdatedLabel id_label = new UpdatedLabel("BLOCK: ")
{
@Override
public String buildLabel()
{
return super.buildLabel() + (tile != null && tile.getBlockType() != null ? tile.getBlockType() : "-");
}
};
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();
}
}
}
/** Shows the frame */
public void showDebugFrame()
{
setTitle("Resonant Engine Debug Window");
setBounds(200, 200, 450, 600);
setVisible(true);
}
/** Hides the frame and tells it to die off */
public void closeDebugFrame()
{
dispose();
}
@Override
public double z()
{
return tile != null ? tile.zCoord : 0;
}
@Override
public double x()
{
return tile != null ? tile.xCoord : 0;
}
@Override
public double y()
{
return tile != null ? tile.yCoord : 0;
}
@Override
public World world()
{
return tile != null ? tile.getWorldObj() : null;
}
}

View file

@ -1,109 +0,0 @@
package resonantinduction.core.debug;
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 */
@SuppressWarnings("serial")
public class FrameNodeDebug extends FrameDebug
{
protected INodeProvider nodeProvider = null;
/** Linked node */
protected INode node = null;
protected Class<? extends INode> nodeClazz = null;
/** Are we debugging a node */
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(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;
}
@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 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();
}
}

View file

@ -1,9 +0,0 @@
package resonantinduction.core.debug;
/** Used to pass info to the debug GUI
*
* @author Darkguardsman */
public interface IDebug
{
}

View file

@ -1,9 +0,0 @@
package resonantinduction.core.debug;
/** Used by objects can update each tick
*
* @author Darkguardsman */
public interface IUpdate
{
public void update();
}

View file

@ -1,33 +0,0 @@
package resonantinduction.core.debug;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Panel;
import javax.swing.JPanel;
/** @author Darkguardsman */
@SuppressWarnings("serial")
public class UpdatePanel extends JPanel implements IUpdate
{
public UpdatePanel()
{
}
public UpdatePanel(BorderLayout borderLayout)
{
super(borderLayout);
}
@Override
public void update()
{
for (Component component : getComponents())
{
if (component instanceof IUpdate)
{
((IUpdate) component).update();
}
}
}
}

View file

@ -1,30 +0,0 @@
package resonantinduction.core.debug;
import java.awt.Label;
/** Simple label with an update method
*
* @author Darkguardsman */
@SuppressWarnings("serial")
public class UpdatedLabel extends Label implements IUpdate
{
String start_string = "I Am a Label";
public UpdatedLabel(String start)
{
super(start);
this.start_string = start;
}
@Override
public void update()
{
this.setText(buildLabel());
}
/** Recreates then returns the label's string value */
public String buildLabel()
{
return start_string;
}
}

View file

@ -1,32 +0,0 @@
package resonantinduction.core.handler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.event.TextureStitchEvent;
import resonant.lib.render.RenderUtility;
import resonantinduction.core.Reference;
/**
* @author Calclavia
*/
public class TextureHookHandler
{
@Mod.EventHandler
@SideOnly(Side.CLIENT)
public void preTextureHook(TextureStitchEvent.Pre event)
{
if (event.map.getTextureType() == 0)
{
RenderUtility.registerIcon(Reference.prefix() + "glyph_0", event.map);
RenderUtility.registerIcon(Reference.prefix() + "glyph_1", event.map);
RenderUtility.registerIcon(Reference.prefix() + "glyph_2", event.map);
RenderUtility.registerIcon(Reference.prefix() + "glyph_3", event.map);
RenderUtility.registerIcon(Reference.prefix() + "mixture_flow", event.map);
RenderUtility.registerIcon(Reference.prefix() + "molten_flow", event.map);
RenderUtility.registerIcon(Reference.prefix() + "multimeter_screen", event.map);
RenderUtility.registerIcon(Reference.prefix() + "tankEdge", event.map);
}
}
}

View file

@ -0,0 +1,31 @@
package resonantinduction.core.handler
import cpw.mods.fml.common.Mod
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
import net.minecraftforge.client.event.TextureStitchEvent
import resonant.lib.render.RenderUtility
import resonantinduction.core.Reference
/** Event handler for texture events
* @author Calclavia
*/
class TextureHookHandler
{
@Mod.EventHandler
@SideOnly(Side.CLIENT)
def preTextureHook(event: TextureStitchEvent.Pre)
{
if (event.map.getTextureType == 0)
{
RenderUtility.registerIcon(Reference.prefix + "glyph_0", event.map)
RenderUtility.registerIcon(Reference.prefix + "glyph_1", event.map)
RenderUtility.registerIcon(Reference.prefix + "glyph_2", event.map)
RenderUtility.registerIcon(Reference.prefix + "glyph_3", event.map)
RenderUtility.registerIcon(Reference.prefix + "mixture_flow", event.map)
RenderUtility.registerIcon(Reference.prefix + "molten_flow", event.map)
RenderUtility.registerIcon(Reference.prefix + "multimeter_screen", event.map)
RenderUtility.registerIcon(Reference.prefix + "tankEdge", event.map)
}
}
}

View file

@ -1,21 +0,0 @@
package resonantinduction.core.interfaces;
import net.minecraft.command.ICommandSender;
/**
* Used by machines that can be control by chat commands. Mainly for dev debug of the machine.
*
* @author robert
*/
public interface ICmdMachine
{
/**
* Pre-check too see if this machine can even process the command
*/
public boolean canTakeCommand(ICommandSender sender, String[] args);
/**
* Processing of the command
*/
public void processCommand(ICommandSender sender, String[] args);
}

View file

@ -1,56 +0,0 @@
package resonantinduction.core.interfaces;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.api.core.grid.INode;
import universalelectricity.core.transform.vector.IVectorWorld;
/**
* Applied to any node that will act as a mechanical object
*
* @author Darkguardsman
*/
public interface IMechanicalNode extends INode, IVectorWorld
{
/**
* Gets the radius of the gear in meters. Used to calculate torque and gear ratio for connections.
* Is not applied to direct face to face connections
*
* @param side - side of the machine
* @return radius in meters of the rotation peace
*/
public double getRadius(ForgeDirection side, IMechanicalNode with);
/**
* The Rotational speed of the object
*
* @param side - side of the machine
* @return speed in meters per second
*/
public double getAngularSpeed(ForgeDirection side);
/**
* Force applied from this side
*
* @param side - side of the machine
* @return force
*/
public double getForce(ForgeDirection side);
/**
* Does the direction flip on this side for rotation
*
* @param side - side of the machine
* @return boolean, true = flipped, false = not
*/
public boolean inverseRotation(ForgeDirection side);
/**
* Applies rotational force and velocity to this node increasing its current rotation value
*
* @param source - should not be null
* @param torque - force at an angle
* @param angularVelocity - speed of rotation
*/
public void apply(Object source, double torque, double angularVelocity);
}

View file

@ -0,0 +1,54 @@
package resonantinduction.core.interfaces
import net.minecraftforge.common.util.ForgeDirection
import universalelectricity.api.core.grid.INode
import universalelectricity.core.transform.vector.IVectorWorld
/**
* Applied to any node that will act as a mechanical object
*
* @author Darkguardsman
*/
abstract trait IMechanicalNode extends INode with IVectorWorld {
/**
* Gets the radius of the gear in meters. Used to calculate torque and gear ratio for connections.
* Is not applied to direct face to face connections
*
* @param side - side of the machine
* @return radius in meters of the rotation peace
*/
def getRadius(side: ForgeDirection, `with`: IMechanicalNode): Double = 0.5
/**
* The Rotational speed of the object
*
* @param side - side of the machine
* @return speed in meters per second
*/
def getAngularSpeed(side: ForgeDirection): Double
/**
* Force applied from this side
*
* @param side - side of the machine
* @return force
*/
def getForce(side: ForgeDirection): Double
/**
* Does the direction flip on this side for rotation
*
* @param side - side of the machine
* @return boolean, true = flipped, false = not
*/
def inverseRotation(side: ForgeDirection): Boolean = false
/**
* Applies rotational force and velocity to this node increasing its current rotation value
*
* @param source - should not be null
* @param torque - force at an angle
* @param angularVelocity - speed of rotation
*/
def apply(source: AnyRef, torque: Double, angularVelocity: Double)
}

View file

@ -12,9 +12,9 @@ import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import net.minecraftforge.common.util.ForgeDirection;
import resonantinduction.core.debug.FrameNodeDebug;
import resonantinduction.core.debug.UpdatePanel;
import resonantinduction.core.debug.UpdatedLabel;
import resonant.lib.debug.FrameNodeDebug;
import resonant.lib.debug.UpdatePanel;
import resonant.lib.debug.UpdatedLabel;
import universalelectricity.api.core.grid.INode;
import universalelectricity.api.core.grid.INodeProvider;

View file

@ -14,7 +14,7 @@ import resonant.api.recipe.RecipeResource;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonant.content.factory.resources.RecipeType;
import resonantinduction.core.Timer;
import resonant.lib.utility.Timer;
import universalelectricity.core.transform.region.Cuboid;
import universalelectricity.core.transform.vector.Vector3;

View file

@ -18,7 +18,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidBlock;
import resonant.api.recipe.MachineRecipes;
import resonantinduction.core.Reference;
import resonantinduction.core.Timer;
import resonant.lib.utility.Timer;
import resonant.content.factory.resources.block.BlockFluidMixture;
import universalelectricity.api.core.grid.INode;
import universalelectricity.core.transform.rotation.Quaternion;