mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-01 05:18:00 +01:00
Add some safe guards for MC API access.
This commit is contained in:
parent
9ad981d22a
commit
61ab8c124a
@ -884,12 +884,20 @@ public class BlockProperties {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Hiding the API access here.<br>
|
* 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
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final boolean i(final int id) {
|
public static final boolean i(final int id) {
|
||||||
return Block.i(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){
|
public static final long getBLockFlags(final int id){
|
||||||
|
@ -331,24 +331,29 @@ public class PlayerLocation {
|
|||||||
final double d0 = 0; //0.001D;
|
final double d0 = 0; //0.001D;
|
||||||
onGround = BlockProperties.isOnGround(getBlockAccess(), minX - d0, minY - yOnGround, minZ - d0, maxX + d0, minY + 0.25, maxZ + d0);
|
onGround = BlockProperties.isOnGround(getBlockAccess(), minX - d0, minY - yOnGround, minZ - d0, maxX + d0, minY + 0.25, maxZ + d0);
|
||||||
if (!onGround) {
|
if (!onGround) {
|
||||||
// TODO: Probably check other ids too before doing this ?
|
try{
|
||||||
final double d1 = 0.25D;
|
// TODO: Probably check other ids too before doing this ?
|
||||||
final AxisAlignedBB box = useBox.b(minX - d1, minY - getyOnGround() - d1, minZ - d1, maxX + d1, minY + 0.25 + d1, maxZ + d1);
|
final double d1 = 0.25D;
|
||||||
@SuppressWarnings("rawtypes")
|
final AxisAlignedBB box = useBox.b(minX - d1, minY - getyOnGround() - d1, minZ - d1, maxX + d1, minY + 0.25 + d1, maxZ + d1);
|
||||||
final List list = worldServer.getEntities(entityPlayer, box);
|
@SuppressWarnings("rawtypes")
|
||||||
@SuppressWarnings("rawtypes")
|
final List list = worldServer.getEntities(entityPlayer, box);
|
||||||
Iterator iterator = list.iterator();
|
@SuppressWarnings("rawtypes")
|
||||||
while (iterator.hasNext()) {
|
Iterator iterator = list.iterator();
|
||||||
final Entity entity = (Entity) iterator.next();
|
while (iterator.hasNext()) {
|
||||||
final EntityType type = entity.getBukkitEntity().getType();
|
final Entity entity = (Entity) iterator.next();
|
||||||
if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
|
final EntityType type = entity.getBukkitEntity().getType();
|
||||||
final AxisAlignedBB otherBox = entity.boundingBox;
|
if (type != EntityType.BOAT && type != EntityType.MINECART) continue;
|
||||||
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
final AxisAlignedBB otherBox = entity.boundingBox;
|
||||||
else {
|
if (box.a > otherBox.d || box.d < otherBox.a || box.b > otherBox.e || box.e < otherBox.b || box.c > otherBox.f || box.f < otherBox.c) continue;
|
||||||
onGround = true;
|
else {
|
||||||
break;
|
onGround = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Throwable t){
|
||||||
|
// Ignore exceptions (Context: DisguiseCraft).
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return onGround;
|
return onGround;
|
||||||
|
Loading…
Reference in New Issue
Block a user