Fix direction id.

This commit is contained in:
Lixfel
2024-12-10 12:57:21 +01:00
parent 7ce5e319b5
commit f81b95e39f
@@ -69,7 +69,7 @@ public class Hull {
branchDirections = IntStream.range(0, 27)
.mapToObj(v -> new IntVector(v%3 -1, (v/3)%3 -1, v/9 -1))
.filter(v -> v.x*primaryDirection.x + v.y*primaryDirection.y + v.z*primaryDirection.z == 1) // Pointing towards primary direction
.filter(v -> v.x*primaryDirection.x + v.y*primaryDirection.y + v.z*primaryDirection.z >= 0) // Not pointing away from primary direction
.filter(v -> v.x*v.x + v.y*v.y + v.z*v.z == 2) // Diagonal
.toArray(IntVector[]::new);
}
@@ -87,6 +87,7 @@ public class Hull {
}
public void addPlayer(Player player) {
System.out.println("Added " + player + " to " + region.centerZ());
if(players.add(player)) {
for(Entity entity : entities)
BlockIdWrapper.impl.untrackEntity(player, entity.getEntityId());
@@ -94,6 +95,7 @@ public class Hull {
}
public void removePlayer(Player player, boolean activeRemoval) {
System.out.println("Removed " + player + " from " + region.centerZ());
if(players.remove(player) && activeRemoval) {
for(Entity entity : entities)
BlockIdWrapper.impl.trackEntity(player, entity.getEntityId());
@@ -266,7 +268,7 @@ public class Hull {
}
private int directionId(IntVector v) {
return 9*(v.z+1) + 3*(v.y+1) + (v.x+1);
return 1 << (9*(v.z+1) + 3*(v.y+1) + (v.x+1));
}