Added TileMechanical

This commit is contained in:
Calclavia 2014-01-19 13:11:36 +08:00
parent 12fe602ced
commit 503e7a5d17
4 changed files with 63 additions and 5836 deletions

View file

@ -18,10 +18,10 @@ import resonantinduction.mechanical.network.IMechanical;
import resonantinduction.mechanical.network.IMechanicalConnector; import resonantinduction.mechanical.network.IMechanicalConnector;
import resonantinduction.mechanical.network.IMechanicalNetwork; import resonantinduction.mechanical.network.IMechanicalNetwork;
import resonantinduction.mechanical.network.MechanicalNetwork; import resonantinduction.mechanical.network.MechanicalNetwork;
import resonantinduction.mechanical.network.TileMechanical;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.network.IPacketReceiverWithID; import calclavia.lib.network.IPacketReceiverWithID;
import calclavia.lib.prefab.tile.IRotatable; import calclavia.lib.prefab.tile.IRotatable;
import calclavia.lib.prefab.tile.TileAdvanced;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
@ -32,7 +32,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
* *
* @author DarkGuardsman * @author DarkGuardsman
*/ */
public class TileConveyorBelt extends TileAdvanced implements IMechanicalConnector, IBelt, IRotatable, IPacketReceiverWithID public class TileConveyorBelt extends TileMechanical implements IMechanicalConnector, IBelt, IRotatable, IPacketReceiverWithID
{ {
public enum SlantType public enum SlantType
{ {
@ -49,11 +49,6 @@ public class TileConveyorBelt extends TileAdvanced implements IMechanicalConnect
/** Acceleration of entities on the belt */ /** Acceleration of entities on the belt */
public static final float ACCELERATION = 0.01f; public static final float ACCELERATION = 0.01f;
private IMechanicalNetwork network;
/** The mechanical connections this connector has made */
protected Object[] connections = new Object[6];
/** Frame count for texture animation from 0 - maxFrame */ /** Frame count for texture animation from 0 - maxFrame */
private int animationFrame = 0; private int animationFrame = 0;
@ -298,41 +293,6 @@ public class TileConveyorBelt extends TileAdvanced implements IMechanicalConnect
return Math.max(this.getNetwork().getAngularVelocity(), this.getNetwork().getPrevAngularVelocity()); return Math.max(this.getNetwork().getAngularVelocity(), this.getNetwork().getPrevAngularVelocity());
} }
@Override
public long onReceiveEnergy(ForgeDirection from, long torque, float angularVelocity, boolean doReceive)
{
return this.getNetwork().onReceiveEnergy(torque, angularVelocity);
}
@Override
public Object[] getConnections()
{
return connections;
}
@Override
public IMechanicalNetwork getNetwork()
{
if (this.network == null)
{
this.network = new MechanicalNetwork();
this.network.addConnector(this);
}
return this.network;
}
@Override
public void setNetwork(IMechanicalNetwork network)
{
this.network = network;
}
@Override
public boolean sendNetworkPacket(long torque, float angularVelocity)
{
return false;
}
@Override @Override
public float getResistance() public float getResistance()
{ {

View file

@ -0,0 +1,59 @@
package resonantinduction.mechanical.network;
import net.minecraftforge.common.ForgeDirection;
import calclavia.lib.prefab.tile.TileAdvanced;
public class TileMechanical extends TileAdvanced implements IMechanicalConnector
{
/** The mechanical connections this connector has made */
protected Object[] connections = new Object[6];
private IMechanicalNetwork network;
@Override
public long onReceiveEnergy(ForgeDirection from, long torque, float angularVelocity, boolean doReceive)
{
return this.getNetwork().onReceiveEnergy(torque, angularVelocity);
}
@Override
public boolean canConnect(ForgeDirection direction)
{
return false;
}
@Override
public Object[] getConnections()
{
return connections;
}
@Override
public IMechanicalNetwork getNetwork()
{
if (this.network == null)
{
this.network = new MechanicalNetwork();
this.network.addConnector(this);
}
return this.network;
}
@Override
public void setNetwork(IMechanicalNetwork network)
{
this.network = network;
}
@Override
public boolean sendNetworkPacket(long torque, float angularVelocity)
{
return false;
}
@Override
public float getResistance()
{
return 0;
}
}

View file

@ -9,9 +9,9 @@ import resonantinduction.api.recipe.MachineRecipes.RecipeType;
import resonantinduction.api.recipe.RecipeUtils.ItemStackResource; import resonantinduction.api.recipe.RecipeUtils.ItemStackResource;
import resonantinduction.api.recipe.RecipeUtils.Resource; import resonantinduction.api.recipe.RecipeUtils.Resource;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.mechanical.network.TileMechanical;
import universalelectricity.api.energy.EnergyStorageHandler; import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.tile.TileElectrical;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -19,7 +19,7 @@ import cpw.mods.fml.relauncher.Side;
* @author Calclavia * @author Calclavia
* *
*/ */
public class TileGrinderWheel extends TileElectrical public class TileGrinderWheel extends TileMechanical
{ {
public static final long POWER = 500000; public static final long POWER = 500000;
public static final int DEFAULT_TIME = 20 * 20; public static final int DEFAULT_TIME = 20 * 20;
@ -29,16 +29,10 @@ public class TileGrinderWheel extends TileElectrical
public EntityItem grindingItem = null; public EntityItem grindingItem = null;
public TileGrinderWheel()
{
this.energy = new EnergyStorageHandler(POWER * 2);
}
@Override @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
// TODO: Add energy support.
doWork(); doWork();
} }
@ -102,8 +96,6 @@ public class TileGrinderWheel extends TileElectrical
{ {
this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.PREFIX + "grinder", 0.5f, 1); this.worldObj.playSoundEffect(this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5, Reference.PREFIX + "grinder", 0.5f, 1);
} }
this.energy.extractEnergy(POWER / 20, true);
} }
} }

File diff suppressed because it is too large Load diff