Skip to content

Commit

Permalink
greatly increase the valid placement setups for a waterwheel, it can now
Browse files Browse the repository at this point in the history
be placed in most setups that would be logical
  • Loading branch information
shadowmage45 committed Oct 5, 2014
1 parent f6dc3c0 commit cb6633a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ public class TileWaterwheel extends TileTorqueSingleCell implements IInteractabl

public boolean validSetup = false;

private byte[] validationGrid;

public TileWaterwheel()
{
torqueCell = new TorqueCell(0, 4, 32, 1.f);
maxWheelRpm = 20;
rotTick = (maxWheelRpm * 360)/60/20;
validationGrid = new byte[9];
}

@Override
Expand Down Expand Up @@ -124,24 +127,62 @@ private boolean validateBlocks()
int z1 = z+dr.offsetZ;
int x2 = x+dl.offsetX;
int z2 = z+dl.offsetZ;
if(!worldObj.isAirBlock(x, y, z) || !worldObj.isAirBlock(x, y+1, z) ||
!worldObj.isAirBlock(x1, y, z1) || !worldObj.isAirBlock(x1, y+1, z1) ||
!worldObj.isAirBlock(x2, y, z2) || !worldObj.isAirBlock(x2, y+1, z2))
{

validationGrid[0] = getValidationType(x2, y+1, z2);
validationGrid[1] = getValidationType(x, y+1, z);
validationGrid[2] = getValidationType(x1, y+1, z1);
validationGrid[3] = getValidationType(x2, y, z2);
validationGrid[4] = getValidationType(x, y, z);
validationGrid[5] = getValidationType(x1, y, z1);
validationGrid[6] = getValidationType(x2, y-1, z2);
validationGrid[7] = getValidationType(x, y-1, z);
validationGrid[8] = getValidationType(x1, y-1, z1);
for(int i = 0;i < 9; i++){if(validationGrid[i]==0){return false;}}//quick check for invalid setup
if(validationGrid[1]!=1 || validationGrid[4]!=1){return false;}//must have air inside the inner two blocks

if((validationGrid[0]==2 || validationGrid[0]==1) && validationGrid[3]==2 && validationGrid[6]==2)//left side water flowing down
{
//check opposite side for air (underneath has already been checked by quick block check above)
if(validationGrid[2]==1 && validationGrid[5]==1)
{
rotationDirection = -1;//TODO check if these are correct rotation directions
return true;
}
return false;
}
Block bl, bm, br;
bl = worldObj.getBlock(x2, y-1, z2);
bm = worldObj.getBlock(x, y-1, z);
br = worldObj.getBlock(x1, y-1, z1);
if(bl.getMaterial()!=Material.water || bm.getMaterial()!=Material.water || br.getMaterial()!=Material.water)
else if((validationGrid[2]==2 || validationGrid[2]==1)&& validationGrid[5]==2 && validationGrid[8]==2)//right side water flowing down
{
//check opposite side for air (underneath has already been checked by quick block check above)
if(validationGrid[0]==1 && validationGrid[3]==1)
{
rotationDirection = 1;
return true;
}
return false;
}
int metaLeft = worldObj.getBlockMetadata(x2, y-1, z2);
int metaRight = worldObj.getBlockMetadata(x1, y-1, z1);
rotationDirection = (byte) (metaLeft<metaRight?-1 : metaRight<metaLeft ? 1 : 0);
return true;
else//not a direct flow downwards, check underneath for flow
{
Block bl, bm, br;
bl = worldObj.getBlock(x2, y-1, z2);
bm = worldObj.getBlock(x, y-1, z);
br = worldObj.getBlock(x1, y-1, z1);
if(bl.getMaterial()!=Material.water || bm.getMaterial()!=Material.water || br.getMaterial()!=Material.water)
{
return false;
}
int metaLeft = worldObj.getBlockMetadata(x2, y-1, z2);
int metaRight = worldObj.getBlockMetadata(x1, y-1, z1);
rotationDirection = (byte) (metaLeft<metaRight?-1 : metaRight<metaLeft ? 1 : 0);
return true;
}
}

private byte getValidationType(int x, int y, int z)
{
if(worldObj.isAirBlock(x, y, z)){return 1;}
Block block = worldObj.getBlock(x, y, z);
if(block.getMaterial()==Material.water){return 2;}
return 0;
}

@Override
Expand Down
17 changes: 6 additions & 11 deletions src/main/java/net/shadowmage/ancientwarfare/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ iron: e3e6e6 (180/5/60 recolor from wood)
steel: d7e4e4 (180/20/50 recolor from wood)
gearhead: 535353

Torque Cleanup
* texture for windmill blade default block
* distributor needs separate output speeds per-output head
* edit instructions regarding submitting bug reports/issues to not mention flagging for certain things
* adjust waterwheel so one of its sides may be 'in' water blocks (for water flowing down onto the wheel)
* animal farm animal gui not synching initial server values to client on gui open
* tree farm will pickup fences, whatever wood blocks are in the area, not just logs... check for initial block extends block-log on block-find query
* tree farm still has efficiency issues as soon as it gets full -- kills server TPS
* fix gap in windmill model (and probably redo texture)
* torque conduits/etc can have mobs spawn on top/need lighting
* torque conduits trigger connection with fences/stone walls/etc
Torque Cleanup
* add donators to credits in instruction manual
* update instruction manual regarding submitting bug reports/issues to not mention flagging for certain things
* update instruction manual with information regarding new torque system
* update instruction manual with information regarding updated traders (screenshots, etc)
C distributor needs separate output speeds per-output head
C fix gap in windmill model (and probably redo texture)


video links
http://youtu.be/0SCxAk2o3co
<iframe width="560" height="315" src="//www.youtube.com/embed/0SCxAk2o3co" frameborder="0" allowfullscreen></iframe>
http://youtu.be/-w2A8EUVBZk
Expand Down

0 comments on commit cb6633a

Please sign in to comment.