Gears now update client side showing animation, Fixed a NPE when breaking gears
This commit is contained in:
parent
4fbbdd101b
commit
9f4c9edf7d
2 changed files with 42 additions and 17 deletions
|
@ -13,6 +13,7 @@ import resonant.api.grid.INode;
|
||||||
import resonant.api.grid.INodeProvider;
|
import resonant.api.grid.INodeProvider;
|
||||||
import resonant.lib.utility.nbt.ISaveObj;
|
import resonant.lib.utility.nbt.ISaveObj;
|
||||||
import resonantinduction.core.interfaces.IMechanicalNode;
|
import resonantinduction.core.interfaces.IMechanicalNode;
|
||||||
|
import universalelectricity.api.vector.IVectorWorld;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import codechicken.multipart.TMultiPart;
|
import codechicken.multipart.TMultiPart;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ import codechicken.multipart.TMultiPart;
|
||||||
* can be added by extending the gui.
|
* can be added by extending the gui.
|
||||||
*
|
*
|
||||||
* @author Calclavia, Darkguardsman */
|
* @author Calclavia, Darkguardsman */
|
||||||
public class MechanicalNode implements IMechanicalNode, ISaveObj
|
public class MechanicalNode implements IMechanicalNode, ISaveObj, IVectorWorld
|
||||||
{
|
{
|
||||||
/** Is debug enabled for the node */
|
/** Is debug enabled for the node */
|
||||||
public boolean doDebug = false;
|
public boolean doDebug = false;
|
||||||
|
@ -261,15 +262,7 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
return load;
|
return load;
|
||||||
}
|
}
|
||||||
|
|
||||||
public World world()
|
|
||||||
{
|
|
||||||
return getParent() instanceof TMultiPart ? ((TMultiPart) getParent()).world() : getParent() instanceof TileEntity ? ((TileEntity) getParent()).getWorldObj() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector3 position()
|
|
||||||
{
|
|
||||||
return getParent() instanceof TMultiPart ? new Vector3(((TMultiPart) getParent()).x(), ((TMultiPart) getParent()).y(), ((TMultiPart) getParent()).z()) : getParent() instanceof TileEntity ? new Vector3((TileEntity) getParent()) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Checks to see if a connection is allowed from side and from a source */
|
/** Checks to see if a connection is allowed from side and from a source */
|
||||||
public boolean canConnect(ForgeDirection from, Object source)
|
public boolean canConnect(ForgeDirection from, Object source)
|
||||||
|
@ -319,6 +312,7 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
{
|
{
|
||||||
for (Entry<MechanicalNode, ForgeDirection> entry : getConnections().entrySet())
|
for (Entry<MechanicalNode, ForgeDirection> entry : getConnections().entrySet())
|
||||||
{
|
{
|
||||||
|
entry.getKey().getConnections().remove(this);
|
||||||
entry.getKey().recache();
|
entry.getKey().recache();
|
||||||
}
|
}
|
||||||
getConnections().clear();
|
getConnections().clear();
|
||||||
|
@ -371,4 +365,33 @@ public class MechanicalNode implements IMechanicalNode, ISaveObj
|
||||||
{
|
{
|
||||||
return connections;
|
return connections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public World world()
|
||||||
|
{
|
||||||
|
return getParent() instanceof TMultiPart ? ((TMultiPart) getParent()).world() : getParent() instanceof TileEntity ? ((TileEntity) getParent()).getWorldObj() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 position()
|
||||||
|
{
|
||||||
|
return new Vector3(x(), y(), z());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double z()
|
||||||
|
{
|
||||||
|
return this.getParent() instanceof TMultiPart && ((TMultiPart)this.getParent()).tile() != null ? ((TMultiPart)this.getParent()).z() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double x()
|
||||||
|
{
|
||||||
|
return this.getParent() instanceof TMultiPart && ((TMultiPart)this.getParent()).tile() != null ? ((TMultiPart)this.getParent()).x() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double y()
|
||||||
|
{
|
||||||
|
return this.getParent() instanceof TMultiPart && ((TMultiPart)this.getParent()).tile() != null ? ((TMultiPart)this.getParent()).y() : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ import codechicken.multipart.TFacePart;
|
||||||
* @author Calclavia */
|
* @author Calclavia */
|
||||||
public abstract class PartMechanical extends JCuboidPart implements JNormalOcclusion, TFacePart, INodeProvider
|
public abstract class PartMechanical extends JCuboidPart implements JNormalOcclusion, TFacePart, INodeProvider
|
||||||
{
|
{
|
||||||
|
/** Node that handles mechanical action of the machine */
|
||||||
public MechanicalNode node;
|
public MechanicalNode node;
|
||||||
protected double prevAngularVelocity;
|
protected double prevAngularVelocity;
|
||||||
|
|
||||||
/** Packets */
|
|
||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
|
/** Packets */
|
||||||
boolean markPacketUpdate = false;
|
boolean markPacketUpdate = false;
|
||||||
/** Simple debug external GUI */
|
/** Simple debug external GUI */
|
||||||
GearDebugFrame frame = null;
|
GearDebugFrame frame = null;
|
||||||
|
@ -53,15 +53,17 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
|
||||||
{
|
{
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Make sure to update on both sides
|
||||||
|
this.node.update(0.05f);
|
||||||
|
|
||||||
if (!world().isRemote)
|
if (!world().isRemote)
|
||||||
{
|
{
|
||||||
checkClientUpdate();
|
checkClientUpdate();
|
||||||
this.node.update(0.05f);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//System.out.println("Client->[" + this + "]Angle: " + node.renderAngle);
|
System.out.println("Client->[" + this + "]Angle: " + node.renderAngle);
|
||||||
}
|
}
|
||||||
if (frame != null)
|
if (frame != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue