Distinguish solid and ground materials, add diode to gorund (fixes

ticket #280).
This commit is contained in:
asofold 2012-10-21 22:20:42 +02:00
parent f0ba361968
commit 41dd43f0de

View File

@ -253,6 +253,8 @@ public class BlockProperties {
public static final int F_LAVA = 0x20;
/** 150% height, like fences.*/
public static final int F_HEIGHT150 = 0x40;
/** The player can stand on these, sneaking or not. */
public static final int F_GROUND = 0x80;
static{
init();
@ -309,7 +311,9 @@ public class BlockProperties {
if (block != null){
if (block.material != null){
final net.minecraft.server.Material material = block.material;
if (material.isSolid()) blockFlags[i] |= F_SOLID;
if (material.isSolid()){
blockFlags[i] |= F_SOLID | F_GROUND;
}
if (material.isLiquid()) blockFlags[i] |= F_LIQUID;
}
}
@ -342,8 +346,9 @@ public class BlockProperties {
// Workarounds.
for (final Material mat : new Material[]{
Material.WATER_LILY, Material.LADDER,
Material.DIODE_BLOCK_OFF, Material.DIODE_BLOCK_ON,
}){
blockFlags[mat.getId()] |= F_SOLID;
blockFlags[mat.getId()] |= F_GROUND;
}
// Ignore for passable.
for (final Material mat : new Material[]{
@ -841,6 +846,15 @@ public class BlockProperties {
return (blockFlags[id] & F_SOLID) != 0;
}
/**
* Might hold true for liquids too.
* @param id
* @return
*/
public static final boolean isGround(final int id){
return (blockFlags[id] & F_GROUND) != 0;
}
/**
* Just check if a position is not inside of a block that has a bounding box.<br>
* This is an inaccurate check, it also returns false for doors etc.
@ -1054,11 +1068,11 @@ public class BlockProperties {
for (int z = Location.locToBlock(minZ); z <= Location.locToBlock(maxZ); z++){
for (int y = Location.locToBlock(minY - 0.5626); y <= Location.locToBlock(maxY); y++){
final int id = access.getTypeId(x, y, z);
if ((BlockProperties.getBLockFlags(id) & F_SOLID) != 0){
if ((BlockProperties.getBLockFlags(id) & F_GROUND) != 0){
// Might collide.
if (collidesBlock(access, minX, minY, minZ, maxX, maxY, maxZ, x, y, z, id)){
final int aboveId = access.getTypeId(x, y + 1, z);
if ((BlockProperties.getBLockFlags(aboveId) & F_SOLID) != 0){
if ((BlockProperties.getBLockFlags(aboveId) & F_GROUND) != 0){
// Check against spider type hacks.
if (collidesBlock(access, minX, minY, minZ, maxX, Math.max(maxY, 1.49 + y), maxZ, x, y + 1, z, aboveId)){
// TODO: This might be seen as a violation for many block types.