Finished up large gears!

This commit is contained in:
Calclavia 2014-01-26 20:55:33 +08:00
parent 4fdc27cabe
commit 56ab302f0e
3 changed files with 39 additions and 16 deletions

View file

@ -69,15 +69,16 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
}
getMultiBlock().update();
super.update();
if (getMultiBlock().isPrimary())
{
super.update();
}
}
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item)
{
if (!world().isRemote)
System.out.println(getNetwork());
if (BlockAdvanced.isUsableWrench(player, player.getCurrentEquippedItem(), x(), y(), z()))
{
if (player.isSneaking())
@ -163,7 +164,6 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
{
displaceCheck = 2;
}
/** Look for gears outside this block space, the relative UP, DOWN, LEFT, RIGHT */
for (int i = 0; i < 4; i++)
{
@ -221,7 +221,12 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
@Override
public Object[] getConnections()
{
return getMultiBlock().get().connections;
if (!getMultiBlock().isPrimary())
{
return new Object[6];
}
return connections;
}
@Override
@ -305,10 +310,10 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
@Override
public void onMultiBlockChanged()
{
tile().notifyPartChange(this);
if (!world().isRemote)
{
refresh();
tile().notifyPartChange(this);
sendDescUpdate();
}
}
@ -348,6 +353,11 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
@Override
public boolean canConnect(ForgeDirection from, Object source)
{
if (!getMultiBlock().isPrimary())
{
return false;
}
if (source instanceof IMechanical)
{
/**
@ -356,6 +366,14 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
*/
if (from == placementSide.getOpposite())
{
if (source instanceof PartGear)
{
if (((PartGear) source).tile() == tile() && !getMultiBlock().isConstructed())
{
return true;
}
}
TileEntity sourceTile = getPosition().translate(from.getOpposite()).getTileEntity(world());
if (sourceTile instanceof IMechanical)
@ -376,7 +394,6 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
{
if (this != destinationPart)
{
System.out.println("WORK" + ((PartGear) destinationPart).isCenterMultiBlock());
return ((PartGear) destinationPart).isCenterMultiBlock();
}
else
@ -384,6 +401,10 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
return true;
}
}
else
{
return true;
}
}
}
}

View file

@ -71,13 +71,13 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
for (int i = 0; i < connections.length; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
Object adacent = connections[i];
Object adjacent = connections[i];
if (adacent instanceof IMechanical)
if (adjacent instanceof IMechanical)
{
IMechanical adjacentMech = ((IMechanical) adacent).getInstance(dir);
IMechanical adjacentMech = ((IMechanical) adjacent).getInstance(dir.getOpposite());
if (adjacentMech != null)
if (adjacentMech != null && adjacent != mechanical)
{
float ratio = adjacentMech.getRatio(dir) / mechanical.getRatio(dir.getOpposite());
long torque = mechanical.getTorque();

View file

@ -82,7 +82,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
markPacketUpdate = true;
}
if (!world().isRemote && markPacketUpdate && ticks % 20 == 0)
if (!world().isRemote && markPacketUpdate && ticks % 10 == 0)
{
sendRotationPacket();
markPacketUpdate = false;
@ -285,7 +285,8 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
@Override
public void setAngularVelocity(float velocity)
{
this.angularVelocity = velocity;
if (!world().isRemote)
this.angularVelocity = velocity;
}
@Override
@ -297,7 +298,8 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
@Override
public void setTorque(long torque)
{
this.torque = torque;
if (!world().isRemote)
this.torque = torque;
}
@Override