Removed GearShaftNode from PartGearShaft allowing it to more easily be worked on
This commit is contained in:
parent
ccffd62055
commit
9e45080d24
2 changed files with 117 additions and 97 deletions
|
@ -0,0 +1,116 @@
|
|||
package resonantinduction.mechanical.energy.gear;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import calclavia.api.resonantinduction.IMechanicalNode;
|
||||
import calclavia.lib.grid.INodeProvider;
|
||||
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
||||
|
||||
public class GearShaftNode extends MechanicalNode
|
||||
{
|
||||
|
||||
public GearShaftNode(PartGearShaft parent)
|
||||
{
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTorqueLoad()
|
||||
{
|
||||
// Decelerate the gear based on tier.
|
||||
switch (shaft().tier)
|
||||
{
|
||||
default:
|
||||
return 0.03;
|
||||
case 1:
|
||||
return 0.02;
|
||||
case 2:
|
||||
return 0.01;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAngularVelocityLoad()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRecache()
|
||||
{
|
||||
connections.clear();
|
||||
|
||||
/** Check for internal connections, the FRONT and BACK. */
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection checkDir = ForgeDirection.getOrientation(i);
|
||||
|
||||
if (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite())
|
||||
{
|
||||
MechanicalNode instance = ((INodeProvider) shaft().tile()).getNode(MechanicalNode.class, checkDir);
|
||||
|
||||
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this))
|
||||
{
|
||||
connections.put(instance, checkDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Look for connections outside this block space, the relative FRONT and BACK */
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection checkDir = ForgeDirection.getOrientation(i);
|
||||
|
||||
if (!connections.containsValue(checkDir) && (checkDir == shaft().placementSide || checkDir == shaft().placementSide.getOpposite()))
|
||||
{
|
||||
TileEntity checkTile = new universalelectricity.api.vector.Vector3(shaft().tile()).translate(checkDir).getTileEntity(world());
|
||||
|
||||
if (checkTile instanceof INodeProvider)
|
||||
{
|
||||
MechanicalNode instance = ((INodeProvider) checkTile).getNode(MechanicalNode.class, checkDir.getOpposite());
|
||||
|
||||
// Only connect to shafts outside of this block space.
|
||||
if (instance != null && instance != this && instance.parent instanceof PartGearShaft && instance.canConnect(checkDir.getOpposite(), this))
|
||||
{
|
||||
connections.put(instance, checkDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection from, Object source)
|
||||
{
|
||||
if (source instanceof MechanicalNode)
|
||||
{
|
||||
if (((MechanicalNode) source).parent instanceof PartGear)
|
||||
{
|
||||
PartGear gear = (PartGear) ((MechanicalNode) source).parent;
|
||||
|
||||
if (!(Math.abs(gear.placementSide.offsetX) == Math.abs(shaft().placementSide.offsetX) && Math.abs(gear.placementSide.offsetY) == Math.abs(shaft().placementSide.offsetY) && Math.abs(gear.placementSide.offsetZ) == Math.abs(shaft().placementSide.offsetZ)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return from == shaft().placementSide || from == shaft().placementSide.getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
|
||||
{
|
||||
if (shaft().placementSide.offsetY != 0 || shaft().placementSide.offsetZ != 0)
|
||||
{
|
||||
return dir == shaft().placementSide.getOpposite();
|
||||
}
|
||||
|
||||
return dir == shaft().placementSide;
|
||||
}
|
||||
|
||||
public PartGearShaft shaft()
|
||||
{
|
||||
return (PartGearShaft) this.parent;
|
||||
}
|
||||
}
|
|
@ -43,103 +43,7 @@ public class PartGearShaft extends PartMechanical
|
|||
{
|
||||
super();
|
||||
|
||||
node = new MechanicalNode(this)
|
||||
{
|
||||
@Override
|
||||
public double getTorqueLoad()
|
||||
{
|
||||
// Decelerate the gear based on tier.
|
||||
switch (tier)
|
||||
{
|
||||
default:
|
||||
return 0.03;
|
||||
case 1:
|
||||
return 0.02;
|
||||
case 2:
|
||||
return 0.01;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAngularVelocityLoad()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRecache()
|
||||
{
|
||||
connections.clear();
|
||||
|
||||
/** Check for internal connections, the FRONT and BACK. */
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection checkDir = ForgeDirection.getOrientation(i);
|
||||
|
||||
if (checkDir == placementSide || checkDir == placementSide.getOpposite())
|
||||
{
|
||||
MechanicalNode instance = ((INodeProvider) tile()).getNode(MechanicalNode.class, checkDir);
|
||||
|
||||
if (instance != null && instance != this && instance.canConnect(checkDir.getOpposite(), this))
|
||||
{
|
||||
connections.put(instance, checkDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Look for connections outside this block space, the relative FRONT and BACK */
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection checkDir = ForgeDirection.getOrientation(i);
|
||||
|
||||
if (!connections.containsValue(checkDir) && (checkDir == placementSide || checkDir == placementSide.getOpposite()))
|
||||
{
|
||||
TileEntity checkTile = new universalelectricity.api.vector.Vector3(tile()).translate(checkDir).getTileEntity(world());
|
||||
|
||||
if (checkTile instanceof INodeProvider)
|
||||
{
|
||||
MechanicalNode instance = ((INodeProvider) checkTile).getNode(MechanicalNode.class, checkDir.getOpposite());
|
||||
|
||||
// Only connect to shafts outside of this block space.
|
||||
if (instance != null && instance != this && instance.parent instanceof PartGearShaft && instance.canConnect(checkDir.getOpposite(), this))
|
||||
{
|
||||
connections.put(instance, checkDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection from, Object source)
|
||||
{
|
||||
if (source instanceof MechanicalNode)
|
||||
{
|
||||
if (((MechanicalNode) source).parent instanceof PartGear)
|
||||
{
|
||||
PartGear gear = (PartGear) ((MechanicalNode) source).parent;
|
||||
|
||||
if (!(Math.abs(gear.placementSide.offsetX) == Math.abs(placementSide.offsetX) && Math.abs(gear.placementSide.offsetY) == Math.abs(placementSide.offsetY) && Math.abs(gear.placementSide.offsetZ) == Math.abs(placementSide.offsetZ)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return from == placementSide || from == placementSide.getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inverseRotation(ForgeDirection dir, IMechanicalNode with)
|
||||
{
|
||||
if (placementSide.offsetY != 0 || placementSide.offsetZ != 0)
|
||||
{
|
||||
return dir == placementSide.getOpposite();
|
||||
}
|
||||
|
||||
return dir == placementSide;
|
||||
}
|
||||
};
|
||||
node = new GearShaftNode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue