Revert too fast return, add other, comments, indentation.

This commit is contained in:
asofold 2013-03-07 03:28:40 +01:00
parent 08de1cb576
commit eb4c537e65

View File

@ -376,6 +376,8 @@ public class BlockProperties {
/////////////////////////// ///////////////////////////
// Initalize block flags // Initalize block flags
/////////////////////////// ///////////////////////////
// Generic initialization.
for (int i = 0; i <maxBlocks; i++){ for (int i = 0; i <maxBlocks; i++){
blockFlags[i] = 0; blockFlags[i] = 0;
@ -396,32 +398,38 @@ public class BlockProperties {
Material.SPRUCE_WOOD_STAIRS, Material.BIRCH_WOOD_STAIRS, Material.JUNGLE_WOOD_STAIRS }) { Material.SPRUCE_WOOD_STAIRS, Material.BIRCH_WOOD_STAIRS, Material.JUNGLE_WOOD_STAIRS }) {
blockFlags[mat.getId()] |= F_STAIRS | F_HEIGHT100 | F_GROUND; // Set ground too, to be sure. blockFlags[mat.getId()] |= F_STAIRS | F_HEIGHT100 | F_GROUND; // Set ground too, to be sure.
} }
// WATER. // WATER.
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.STATIONARY_WATER, Material.WATER, Material.STATIONARY_WATER, Material.WATER,
}) { }) {
blockFlags[mat.getId()] |= F_LIQUID | F_WATER; blockFlags[mat.getId()] |= F_LIQUID | F_WATER;
} }
// LAVA. // LAVA.
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.LAVA, Material.STATIONARY_LAVA, Material.LAVA, Material.STATIONARY_LAVA,
}) { }) {
blockFlags[mat.getId()] |= F_LIQUID | F_LAVA; blockFlags[mat.getId()] |= F_LIQUID | F_LAVA;
} }
// Fence types (150% height).
// 1.5 block high.
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.FENCE, Material.FENCE_GATE, Material.FENCE, Material.FENCE_GATE,
Material.NETHER_FENCE, Material.NETHER_FENCE,
}){ }){
blockFlags[mat.getId()] |= F_HEIGHT150; blockFlags[mat.getId()] |= F_HEIGHT150;
} }
// Climbable // Climbable
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.VINE, Material.LADDER, Material.VINE, Material.LADDER,
}){ }){
blockFlags[mat.getId()] |= F_CLIMBABLE; blockFlags[mat.getId()] |= F_CLIMBABLE;
} }
// Workarounds. // Workarounds.
// Ground (can stand on).
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.WATER_LILY, Material.LADDER, Material.WATER_LILY, Material.LADDER,
Material.DIODE_BLOCK_OFF, Material.DIODE_BLOCK_ON, Material.DIODE_BLOCK_OFF, Material.DIODE_BLOCK_ON,
@ -431,36 +439,41 @@ public class BlockProperties {
}){ }){
blockFlags[mat.getId()] |= F_GROUND; blockFlags[mat.getId()] |= F_GROUND;
} }
// Full block height.
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.ENDER_PORTAL_FRAME, Material.BREWING_STAND, Material.ENDER_PORTAL_FRAME, Material.BREWING_STAND,
Material.PISTON_EXTENSION, Material.PISTON_EXTENSION,
}){ }){
blockFlags[mat.getId()] |= F_HEIGHT100; blockFlags[mat.getId()] |= F_HEIGHT100;
} }
// Full xz-bounds.
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.PISTON_EXTENSION, Material.PISTON_EXTENSION,
}){ }){
blockFlags[mat.getId()] |= F_XZ100; blockFlags[mat.getId()] |= F_XZ100;
} }
// Ignore for passable. // Not ground (!).
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.WALL_SIGN, Material.SIGN_POST, Material.WALL_SIGN, Material.SIGN_POST,
}){ }){
blockFlags[mat.getId()] &= ~(F_GROUND | F_SOLID); blockFlags[mat.getId()] &= ~(F_GROUND | F_SOLID);
} }
// Not ground (!).
// Ignore for passable.
for (final Material mat : new Material[]{
Material.WOOD_PLATE, Material.STONE_PLATE,
Material.WALL_SIGN, Material.SIGN_POST,
Material.DIODE_BLOCK_ON, Material.DIODE_BLOCK_OFF,
Material.LADDER, Material.CAKE_BLOCK,
Material.COCOA,
}){
blockFlags[mat.getId()] |= F_IGN_PASSABLE;
}
// Ignore for passable.
for (final Material mat : new Material[]{
Material.WOOD_PLATE, Material.STONE_PLATE,
Material.WALL_SIGN, Material.SIGN_POST,
Material.DIODE_BLOCK_ON, Material.DIODE_BLOCK_OFF,
Material.LADDER, Material.CAKE_BLOCK,
Material.COCOA,
}){
blockFlags[mat.getId()] |= F_IGN_PASSABLE;
}
// Blocks changing depending on neighbor blocks.
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.FENCE, Material.FENCE_GATE, Material.COBBLE_WALL, Material.FENCE, Material.FENCE_GATE, Material.COBBLE_WALL,
Material.NETHER_FENCE, Material.NETHER_FENCE,
@ -468,6 +481,7 @@ public class BlockProperties {
}){ }){
blockFlags[mat.getId()] |= F_VARIABLE; blockFlags[mat.getId()] |= F_VARIABLE;
} }
// Flexible ground (height): // Flexible ground (height):
for (final Material mat : new Material[]{ for (final Material mat : new Material[]{
Material.PISTON_EXTENSION, Material.ANVIL, Material.PISTON_EXTENSION, Material.ANVIL,
@ -479,7 +493,7 @@ public class BlockProperties {
} }
//////////////////////////////// ////////////////////////////////
// Set block props. // Set block break properties.
//////////////////////////////// ////////////////////////////////
// Instantly breakable. // Instantly breakable.
for (final Material mat : instantMat){ for (final Material mat : instantMat){
@ -607,6 +621,7 @@ public class BlockProperties {
blocks[Material.OBSIDIAN.getId()] = new BlockProps(diamondPickaxe, 50, secToMs(250, 250, 250, 250, 9.4, 250)); blocks[Material.OBSIDIAN.getId()] = new BlockProps(diamondPickaxe, 50, secToMs(250, 250, 250, 250, 9.4, 250));
// More 1.4 (not insta). // More 1.4 (not insta).
// TODO: Either move all to an extra setup class, or integrate above.
blocks[Material.BEACON.getId()] = new BlockProps(noTool, 25f, secToMs(4.45)); // TODO blocks[Material.BEACON.getId()] = new BlockProps(noTool, 25f, secToMs(4.45)); // TODO
blocks[Material.COBBLE_WALL.getId()] = brickType; blocks[Material.COBBLE_WALL.getId()] = brickType;
blockFlags[Material.COBBLE_WALL.getId()] |= F_HEIGHT150; blockFlags[Material.COBBLE_WALL.getId()] |= F_HEIGHT150;
@ -1673,7 +1688,7 @@ public class BlockProperties {
* @param minY * @param minY
* @param minZ * @param minZ
* @param maxX * @param maxX
* @param maxY Meant to be the foot-position. * @param maxY Meant to be the foot-level.
* @param maxZ * @param maxZ
* @param ignoreFlags Blocks with these flags are not counted as ground. * @param ignoreFlags Blocks with these flags are not counted as ground.
* @return * @return
@ -1690,6 +1705,9 @@ public class BlockProperties {
final int iMaxZ = Location.locToBlock(maxZ); final int iMaxZ = Location.locToBlock(maxZ);
for (int x = iMinX; x <= iMaxX; x++){ for (int x = iMinX; x <= iMaxX; x++){
for (int z = iMinZ; z <= iMaxZ; z++){ for (int z = iMinZ; z <= iMaxZ; z++){
// TODO: Might move above block check right here.
for (int y = iMaxY; y >= iMinY; y --){ for (int y = iMaxY; y >= iMinY; y --){
// TODO: Remember the state of the last block below instead of checking the block above. // TODO: Remember the state of the last block below instead of checking the block above.
@ -1700,7 +1718,7 @@ public class BlockProperties {
if ((flags & F_GROUND) == 0 || (flags & ignoreFlags) != 0){ if ((flags & F_GROUND) == 0 || (flags & ignoreFlags) != 0){
continue; continue;
} }
// Might collide. // Might collide.
final double[] bounds = access.getBounds(x, y, z); final double[] bounds = access.getBounds(x, y, z);
@ -1718,6 +1736,7 @@ public class BlockProperties {
// Spider ! // Spider !
// Not nice but... // Not nice but...
// TODO: GROUND_HEIGHT: would have to check passable workaround again ? // TODO: GROUND_HEIGHT: would have to check passable workaround again ?
// height >= ?
if ((flags & F_GROUND_HEIGHT) == 0 || getBlockHeight(access, x, y, z, id, bounds, flags) > maxY - y){ if ((flags & F_GROUND_HEIGHT) == 0 || getBlockHeight(access, x, y, z, id, bounds, flags) > maxY - y){
// Don't break, though could for some cases (?), since a block below still can be ground. // Don't break, though could for some cases (?), since a block below still can be ground.
continue; continue;
@ -1725,24 +1744,22 @@ public class BlockProperties {
} }
// Don't count as ground if a block contains the foot. // Don't count as ground if a block contains the foot.
// if (y == iMaxY){ // height >= ?
// TODO: This could be a check before looping. if (getBlockHeight(access, x, y, z, id, bounds, flags) > maxY - y){
// if (maxY - y < ((flags & F_HEIGHT150) == 0 ? bounds[4] : 1.5)){ // Within block, this x and z is no candidate for ground.
if (getBlockHeight(access, x, y, z, id, bounds, flags) > maxY - y){ if (isFullBounds(bounds)){
// Within block, this x and z is no candidate for ground. break;
if (isFullBounds(bounds)){ }
break; else{
} continue;
else{ }
continue; }
}
} if (maxY - y < 1.0){
// } // No need to check the block above (half slabs, stairs).
// } return true;
}
// return true;
// Check if the block above allows this to be ground. // Check if the block above allows this to be ground.
if (y >= maxBlockY){ if (y >= maxBlockY){
@ -1750,10 +1767,11 @@ public class BlockProperties {
return true; return true;
} }
if (y != iMaxY){ // TODO: This can be a problem with glass panes etc.
// Ground found and the block above is passable, no need to check above. // if (y != iMaxY){
return true; // // Ground found and the block above is passable, no need to check above.
} // return true;
// }
final int aboveId = access.getTypeId(x, y + 1, z); final int aboveId = access.getTypeId(x, y + 1, z);
final long aboveFlags = blockFlags[aboveId]; final long aboveFlags = blockFlags[aboveId];