Some more work on mechanical network
This commit is contained in:
parent
22b4188443
commit
5c3601585d
5 changed files with 38 additions and 9 deletions
|
@ -22,7 +22,7 @@ public class TileGenerator extends TileElectrical implements IMechanical
|
|||
|
||||
public TileGenerator()
|
||||
{
|
||||
energy = new EnergyStorageHandler(10000, 100);
|
||||
energy = new EnergyStorageHandler(10000, 1000);
|
||||
this.ioMap = 728;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,9 @@ public class TileGenerator extends TileElectrical implements IMechanical
|
|||
if (mechanical instanceof IMechanical)
|
||||
{
|
||||
long extract = energy.extractEnergy();
|
||||
((IMechanical) mechanical).onReceiveEnergy(getOuputDirection().getOpposite(), (long) (extract / 0.5f), 0.5f);
|
||||
|
||||
if (extract > 0)
|
||||
((IMechanical) mechanical).onReceiveEnergy(getOuputDirection().getOpposite(), (long) (500), extract / 500f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import resonantinduction.electrical.wire.EnumWireMaterial;
|
|||
import calclavia.lib.utility.LanguageUtility;
|
||||
import codechicken.lib.vec.BlockCoord;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
import codechicken.multipart.ControlKeyModifer;
|
||||
import codechicken.multipart.MultiPartRegistry;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
|
@ -30,7 +31,7 @@ public class ItemMultimeter extends ItemMultipartBase
|
|||
@Override
|
||||
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
|
||||
{
|
||||
if (world.getBlockTileEntity(pos.x, pos.y, pos.z) instanceof TileMultipart)
|
||||
if (world.getBlockTileEntity(pos.x, pos.y, pos.z) instanceof TileMultipart && !ControlKeyModifer.isControlDown(player))
|
||||
{
|
||||
pos.offset(side ^ 1, -1);
|
||||
}
|
||||
|
|
|
@ -87,11 +87,19 @@ public class PartGear extends JCuboidPart implements JNormalOcclusion, TFacePart
|
|||
manualCrankTime--;
|
||||
}
|
||||
|
||||
if (!world().isRemote)
|
||||
{
|
||||
//TODO: Save packets.
|
||||
if (markRotationUpdate || this.getNetwork().getPrevTorque() != this.getNetwork().getTorque() || this.getNetwork().getPrevAngularVelocity() != this.getNetwork().getAngularVelocity())
|
||||
{
|
||||
this.sendRotationUpdate(this.getNetwork().getTorque(), this.getNetwork().getAngularVelocity());
|
||||
}
|
||||
}
|
||||
|
||||
if (markRotationUpdate)
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -194,7 +202,7 @@ public class PartGear extends JCuboidPart implements JNormalOcclusion, TFacePart
|
|||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item)
|
||||
{
|
||||
System.out.println(this.getNetwork().getAngularVelocity());
|
||||
System.out.println(world().isRemote + " : " + this.getNetwork().getAngularVelocity());
|
||||
if (player.isSneaking())
|
||||
{
|
||||
this.manualCrankTime = 20;
|
||||
|
@ -207,9 +215,6 @@ public class PartGear extends JCuboidPart implements JNormalOcclusion, TFacePart
|
|||
{
|
||||
getNetwork().applyEnergy(torque, angularVelocity);
|
||||
markRotationUpdate = true;
|
||||
|
||||
if (!world().isRemote)
|
||||
this.sendRotationUpdate(torque, angularVelocity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,10 @@ public interface IMechanicalNetwork extends INetwork<IMechanicalNetwork, IMechan
|
|||
*/
|
||||
public float getAngularVelocity();
|
||||
|
||||
public int getPrevTorque();
|
||||
|
||||
public float getPrevAngularVelocity();
|
||||
|
||||
/** Called to rebuild the network */
|
||||
public void reconstruct();
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@ import universalelectricity.core.net.NetworkTickHandler;
|
|||
*/
|
||||
public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalConnector, IMechanical> implements IMechanicalNetwork
|
||||
{
|
||||
public int prevTorque = 0;
|
||||
public float prevAngularVelocity = 0;
|
||||
|
||||
public int torque = 0;
|
||||
public float angularVelocity = 0;
|
||||
|
||||
|
@ -38,6 +41,9 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalCo
|
|||
@Override
|
||||
public void update()
|
||||
{
|
||||
prevTorque = torque;
|
||||
prevAngularVelocity = angularVelocity;
|
||||
|
||||
for (IMechanicalConnector connector : this.getConnectors())
|
||||
{
|
||||
connector.networkUpdate();
|
||||
|
@ -50,7 +56,6 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalCo
|
|||
node.onReceiveEnergy(dir, torque, angularVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
torque = 0;
|
||||
angularVelocity = 0;
|
||||
}
|
||||
|
@ -263,4 +268,16 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanicalCo
|
|||
newNetwork.reconstruct();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrevTorque()
|
||||
{
|
||||
return prevTorque;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPrevAngularVelocity()
|
||||
{
|
||||
return prevAngularVelocity;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue