Fixed setVelocity null point exception

This commit is contained in:
Calclavia 2014-01-28 15:45:23 +08:00
parent 84f2a90c02
commit a0ec8a83c0
3 changed files with 9 additions and 7 deletions

View file

@ -93,7 +93,7 @@ public class PartGearShaft extends PartMechanical
{
IMechanical instance = (IMechanical) ((IMechanical) checkTile).getInstance(checkDir.getOpposite());
// Only connet to shafts outside of this block space.
// Only connect to shafts outside of this block space.
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this) && instance instanceof PartGearShaft)
{
connections[checkDir.ordinal()] = instance;

View file

@ -62,8 +62,8 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
if (!world().isRemote)
{
System.out.println(this + ":" + getNetwork());
for(Object obj : connections)
System.out.println(obj);
for (Object obj : connections)
System.out.println(obj);
}
return false;
@ -263,7 +263,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
@Override
public void setAngularVelocity(float velocity)
{
if (!world().isRemote)
if (world() != null && !world().isRemote)
this.angularVelocity = velocity;
}
@ -276,7 +276,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
@Override
public void setTorque(long torque)
{
if (!world().isRemote)
if (world() != null && !world().isRemote)
this.torque = torque;
}

View file

@ -1,5 +1,6 @@
package resonantinduction.mechanical.network;
import resonantinduction.mechanical.gear.PartGearShaft;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.vector.Vector3;
@ -46,7 +47,7 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
protected float getLoad()
{
return 0.9f;
return 0.95f;
}
@Override
@ -69,7 +70,8 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
{
IMechanical mech = ((IMechanical) tile).getInstance(dir.getOpposite());
if (mech != null && canConnect(dir, this) && mech.canConnect(dir.getOpposite(), this))
// Don't connect with shafts
if (mech != null && !(mech instanceof PartGearShaft) && canConnect(dir, this) && mech.canConnect(dir.getOpposite(), this))
{
connections[dir.ordinal()] = mech;
getNetwork().merge(mech.getNetwork());