Fix bitwise negation in CollisionMatrix#clear()

Adds the missing bitwise AND to the clear() method in CollisionMatrix,
so any flags besides the one given are retained.
This commit is contained in:
Gary Tierney
2016-12-30 23:49:17 +00:00
parent 376d36871a
commit 0672fa2ea0
@@ -104,6 +104,18 @@ public final class CollisionMatrix {
return false;
}
/**
* Completely blocks the tile at the specified coordinate pair, while optionally allowing projectiles
* to pass through.
*
* @param x The x coordinate.
* @param y The y coordinate.
* @param impenetrable If projectiles should be permitted to traverse this tile.
*/
public void block(int x, int y, boolean impenetrable) {
set(x, y, impenetrable ? ALL_BLOCKED : ALL_MOBS_BLOCKED);
}
/**
* Completely blocks the tile at the specified coordinate pair.
*
@@ -123,7 +135,7 @@ public final class CollisionMatrix {
* @param flag The CollisionFlag.
*/
public void clear(int x, int y, CollisionFlag flag) {
set(x, y, (byte) ~flag.asByte());
set(x, y, (byte) (matrix[indexOf(x, y)] & ~flag.asByte()));
}
/**