Improved grinder direction

This commit is contained in:
Calclavia 2014-01-21 19:52:14 +08:00
parent a7f19b20a2
commit be722cc586
5 changed files with 18 additions and 49 deletions

View file

@ -35,7 +35,7 @@ public class TileGenerator extends TileElectrical implements IMechanical, IRotat
public float toggleRatio() public float toggleRatio()
{ {
return torqueRatio = (torqueRatio + 1000) % energy.getMaxExtract(); return torqueRatio = (torqueRatio + 1000) % energy.getMaxExtract() + 1000;
} }
@Override @Override
@ -85,7 +85,7 @@ public class TileGenerator extends TileElectrical implements IMechanical, IRotat
{ {
EnumSet<ForgeDirection> dirs = EnumSet.allOf(ForgeDirection.class); EnumSet<ForgeDirection> dirs = EnumSet.allOf(ForgeDirection.class);
dirs.remove(this.getDirection()); dirs.remove(this.getDirection());
dirs.remove(this.getDirection().ordinal()); dirs.remove(this.getDirection().getOpposite());
return dirs; return dirs;
} }

View file

@ -226,7 +226,7 @@ public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatabl
for (int i = 2; i < 6; i++) for (int i = 2; i < 6; i++)
{ {
ForgeDirection dir = ForgeDirection.getOrientation(i); ForgeDirection dir = ForgeDirection.getOrientation(i);
Vector3 pos = new Vector3(this).modifyPositionFromSide(dir); Vector3 pos = new Vector3(this).translate(dir);
TileEntity tile = pos.getTileEntity(this.worldObj); TileEntity tile = pos.getTileEntity(this.worldObj);
if (dir == this.getDirection() || dir == this.getDirection().getOpposite()) if (dir == this.getDirection() || dir == this.getDirection().getOpposite())
@ -265,8 +265,13 @@ public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatabl
} }
else if (tile instanceof IMechanical) else if (tile instanceof IMechanical)
{ {
// TODO: Fix split connection in network. IMechanical mechanical = (IMechanical) ((IMechanical) tile).getInstance(dir.getOpposite());
// connections[dir.ordinal()] = tile;
if (mechanical != null)
{
connections[dir.ordinal()] = mechanical;
getNetwork().merge(mechanical.getNetwork());
}
} }
} }

View file

@ -75,7 +75,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
* Calculation rotations of all generators. * Calculation rotations of all generators.
*/ */
if (!(prevGenerators.equals(generators)) && generators.size() > 0) if (!(prevGenerators.equals(generators)) && generators.size() > 0)
{System.out.println("UPDA PATH"); {
Set<IMechanical> closedSet = new LinkedHashSet<IMechanical>(); Set<IMechanical> closedSet = new LinkedHashSet<IMechanical>();
for (IMechanical generatorNode : generators) for (IMechanical generatorNode : generators)
@ -90,9 +90,10 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
} }
prevGenerators = new LinkedHashSet<>(generators); prevGenerators = new LinkedHashSet<>(generators);
generators.clear();
} }
generators.clear();
/** /**
* Calculate load * Calculate load
*/ */

View file

@ -33,43 +33,6 @@ public class BlockGrinderWheel extends BlockRIRotatable implements ITileEntityPr
return RIBlockRenderingHandler.ID; return RIBlockRenderingHandler.ID;
} }
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
this.checkConflicts(world, x, y, z);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int par5)
{
this.checkConflicts(world, x, y, z);
}
/**
* Checks for any conflicting directions with other grinders.
*/
private void checkConflicts(World world, int x, int y, int z)
{
ForgeDirection facing = this.getDirection(world, x, y, z);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
if (dir == facing || dir == facing.getOpposite())
{
VectorWorld checkPos = (VectorWorld) new VectorWorld(world, x, y, z).modifyPositionFromSide(dir);
TileEntity tileEntity = checkPos.getTileEntity();
if (tileEntity instanceof TileGrinderWheel)
{
if (this.getDirection(world, checkPos.intX(), checkPos.intY(), checkPos.intZ()) == facing)
{
this.dropBlockAsItem(world, x, y, z, 0, 0);
world.setBlockToAir(x, y, z);
}
}
}
}
}
@Override @Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{ {
@ -111,10 +74,10 @@ public class BlockGrinderWheel extends BlockRIRotatable implements ITileEntityPr
{ {
// Move entity based on the direction of the block. // Move entity based on the direction of the block.
ForgeDirection dir = this.getDirection(world, x, y, z); ForgeDirection dir = this.getDirection(world, x, y, z);
entity.motionX += dir.offsetX * tile.getNetwork().getAngularVelocity() / 20; dir = ForgeDirection.getOrientation(!(dir.ordinal() % 2 == 0) ? dir.ordinal() - 1 : dir.ordinal());
entity.motionZ += dir.offsetZ * tile.getNetwork().getAngularVelocity() / 20; int inversion = tile.isClockwise() ? -1 : 1;
entity.motionY += Math.random() * tile.getNetwork().getAngularVelocity() / 20; float speed = tile.getNetwork().getAngularVelocity() / 20;
entity.isAirBorne = true; entity.addVelocity(inversion * dir.offsetX * speed, inversion * dir.offsetZ * speed, Math.random() * speed);
} }
} }
} }

View file

@ -136,7 +136,7 @@ public class TileGrinderWheel extends TileMechanical implements IRotatable
{ {
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote)
{ {
EntityItem entityItem = new EntityItem(this.worldObj, entity.posX, entity.posY, entity.posZ, ((ItemStackResource) resource).itemStack.copy()); EntityItem entityItem = new EntityItem(this.worldObj, entity.posX, entity.posY - 1.2, entity.posZ, ((ItemStackResource) resource).itemStack.copy());
entityItem.delayBeforeCanPickup = 20; entityItem.delayBeforeCanPickup = 20;
entityItem.motionX = 0; entityItem.motionX = 0;
entityItem.motionY = 0; entityItem.motionY = 0;