Add some safe guards for MC API access.

This commit is contained in:
asofold 2012-11-16 17:37:31 +01:00
parent 9ad981d22a
commit 61ab8c124a
2 changed files with 31 additions and 18 deletions

View File

@ -884,13 +884,21 @@ public class BlockProperties {
/**
* Hiding the API access here.<br>
* TODO: Find description of this and use block properties from here, as well as a speaking method name.
* TODO: Find description of this and use block properties from here, as well as a speaking method name.<br>
* Assumption: This is something like "can stand on this type of block".
* @param id
* @return
*/
public static final boolean i(final int id) {
// TODO: Replace by independent method.
try{
return Block.i(id);
}
catch(Throwable t){
// Minecraft default value.
return true;
}
}
public static final long getBLockFlags(final int id){
return blockFlags[id];

View File

@ -331,6 +331,7 @@ public class PlayerLocation {
final double d0 = 0; //0.001D;
onGround = BlockProperties.isOnGround(getBlockAccess(), minX - d0, minY - yOnGround, minZ - d0, maxX + d0, minY + 0.25, maxZ + d0);
if (!onGround) {
try{
// TODO: Probably check other ids too before doing this ?
final double d1 = 0.25D;
final AxisAlignedBB box = useBox.b(minX - d1, minY - getyOnGround() - d1, minZ - d1, maxX + d1, minY + 0.25 + d1, maxZ + d1);
@ -350,6 +351,10 @@ public class PlayerLocation {
}
}
}
catch (Throwable t){
// Ignore exceptions (Context: DisguiseCraft).
}
}
}
return onGround;
}