diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index d5648ea5..7b62847c 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1549,6 +1549,7 @@ Fab tool can show transparent, loaded version of fab file Interaction target tooltip at top of window Interaction target tooltip shows entity target, voxel targets Fix bug where inventory items aren't destroying physics on server +Align voxel lookups for movement audio and interaction targeting diff --git a/src/main/java/electrosphere/client/interact/ClientInteractionEngine.java b/src/main/java/electrosphere/client/interact/ClientInteractionEngine.java index d7c62a30..4aa59fda 100644 --- a/src/main/java/electrosphere/client/interact/ClientInteractionEngine.java +++ b/src/main/java/electrosphere/client/interact/ClientInteractionEngine.java @@ -261,7 +261,11 @@ public class ClientInteractionEngine { } if(!set){ Vector3d collisionPosition = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(centerPos, new Vector3d(eyePos).mul(-1), CollisionEngine.DEFAULT_INTERACT_DISTANCE); - if(collisionPosition != null && collisionPosition.distance(centerPos) < CollisionEngine.DEFAULT_INTERACT_DISTANCE){ + if( + collisionPosition != null && + collisionPosition.distance(centerPos) < CollisionEngine.DEFAULT_INTERACT_DISTANCE && + collisionPosition.x >= 0 && collisionPosition.y >= 0 && collisionPosition.z >= 0 + ){ //grab block at point BlockChunkData blockChunkData = Globals.clientBlockManager.getChunkDataAtWorldPoint(Globals.clientWorldData.convertRealToWorldSpace(collisionPosition), 0); if(blockChunkData != null){ @@ -277,7 +281,7 @@ public class ClientInteractionEngine { if(!set){ ChunkData chunkData = Globals.clientTerrainManager.getChunkDataAtWorldPoint(Globals.clientWorldData.convertRealToWorldSpace(collisionPosition), 0); if(chunkData != null){ - int voxelType = chunkData.getType(Globals.clientWorldData.convertRealToVoxelSpace(collisionPosition)); + int voxelType = chunkData.getType(Globals.clientWorldData.convertRealToVoxelSpace(new Vector3d(collisionPosition).add(new Vector3d(ServerTerrainChunk.VOXEL_SIZE / 2.0f)))); if(voxelType != ServerTerrainChunk.VOXEL_TYPE_AIR){ String text = Globals.gameConfigCurrent.getVoxelData().getTypeFromId(voxelType).getName(); InteractionTargetMenu.setInteractionTargetString(text); diff --git a/src/main/java/electrosphere/client/terrain/sampling/ClientVoxelSampler.java b/src/main/java/electrosphere/client/terrain/sampling/ClientVoxelSampler.java index d8fd6dab..b60bf00c 100644 --- a/src/main/java/electrosphere/client/terrain/sampling/ClientVoxelSampler.java +++ b/src/main/java/electrosphere/client/terrain/sampling/ClientVoxelSampler.java @@ -7,6 +7,7 @@ import electrosphere.client.terrain.cache.ChunkData; import electrosphere.engine.Globals; import electrosphere.entity.Entity; import electrosphere.entity.EntityUtils; +import electrosphere.server.physics.terrain.manager.ServerTerrainChunk; /** * Samples voxels @@ -24,7 +25,7 @@ public class ClientVoxelSampler { * @return The voxel type, INVALID_POSITION if the position queried is invalid */ public static int getVoxelTypeBeneathEntity(Entity entity){ - return ClientVoxelSampler.getVoxelType(EntityUtils.getPosition(entity)); + return ClientVoxelSampler.getVoxelType(new Vector3d(EntityUtils.getPosition(entity)).add(new Vector3d(ServerTerrainChunk.VOXEL_SIZE / 2.0f))); } /** diff --git a/src/main/java/electrosphere/server/datacell/ServerDataCell.java b/src/main/java/electrosphere/server/datacell/ServerDataCell.java index f861a3a6..b97f3e34 100644 --- a/src/main/java/electrosphere/server/datacell/ServerDataCell.java +++ b/src/main/java/electrosphere/server/datacell/ServerDataCell.java @@ -168,6 +168,9 @@ public class ServerDataCell { case COMMON: { CommonEntityUtils.sendEntityToPlayer(player, entity); } break; + case ENGINE: { + //silently ignore + } break; } } } diff --git a/src/main/java/electrosphere/server/physics/terrain/manager/ServerTerrainChunk.java b/src/main/java/electrosphere/server/physics/terrain/manager/ServerTerrainChunk.java index 81db8ec1..ce0c46ad 100644 --- a/src/main/java/electrosphere/server/physics/terrain/manager/ServerTerrainChunk.java +++ b/src/main/java/electrosphere/server/physics/terrain/manager/ServerTerrainChunk.java @@ -12,10 +12,15 @@ import electrosphere.server.physics.terrain.models.TerrainModification; */ public class ServerTerrainChunk { + /** + * Size of a single voxel + */ + public static final int VOXEL_SIZE = 1; + /** * All chunks are 16x16x16 */ - public static final int CHUNK_DIMENSION = 16; + public static final int CHUNK_DIMENSION = 16 * VOXEL_SIZE; /** * The size of the data passed into marching cubes/transvoxel to generate a fully connected and seamless chunk