Fixed entity positioning
This commit is contained in:
@@ -9,8 +9,6 @@ class Entity:
|
||||
self.localY = localY % CHUNK_HEIGHT
|
||||
self.localZ = localZ % CHUNK_DEPTH
|
||||
|
||||
print(f"Raw localX: {localX}, adjusted localX: {self.localX}")
|
||||
|
||||
self.chunk = chunk
|
||||
self.vertexBuffer = VertexBuffer()
|
||||
pass
|
||||
|
||||
@@ -82,11 +82,18 @@ class EntityPanel(QWidget):
|
||||
chunk = self.parent.map.getChunkAtWorldPos(*self.parent.map.position)
|
||||
if chunk is None:
|
||||
return
|
||||
ent = chunk.addEntity(
|
||||
self.parent.map.position[0] - chunk.x,
|
||||
self.parent.map.position[1] - chunk.y,
|
||||
self.parent.map.position[2] - chunk.z
|
||||
)
|
||||
|
||||
localX = (self.parent.map.position[0] - (chunk.x * CHUNK_WIDTH)) % CHUNK_WIDTH
|
||||
localY = (self.parent.map.position[1] - (chunk.y * CHUNK_HEIGHT)) % CHUNK_HEIGHT
|
||||
localZ = (self.parent.map.position[2] - (chunk.z * CHUNK_DEPTH)) % CHUNK_DEPTH
|
||||
|
||||
# Make sure there's not already an entity here
|
||||
for ent in chunk.entities.values():
|
||||
if ent.localX == localX and ent.localY == localY and ent.localZ == localZ:
|
||||
print("Entity already exists at this location")
|
||||
return
|
||||
|
||||
ent = chunk.addEntity(localX, localY, localZ)
|
||||
|
||||
def onRemoveEntity(self):
|
||||
item = self.entityList.currentItem()
|
||||
@@ -119,9 +126,9 @@ class EntityPanel(QWidget):
|
||||
if chunk is None:
|
||||
return
|
||||
|
||||
localX = (position[0] - chunk.x) % CHUNK_WIDTH
|
||||
localY = (position[1] - chunk.y) % CHUNK_HEIGHT
|
||||
localZ = (position[2] - chunk.z) % CHUNK_DEPTH
|
||||
localX = (position[0] - (chunk.x * CHUNK_WIDTH)) % CHUNK_WIDTH
|
||||
localY = (position[1] - (chunk.y * CHUNK_HEIGHT)) % CHUNK_HEIGHT
|
||||
localZ = (position[2] - (chunk.z * CHUNK_DEPTH)) % CHUNK_DEPTH
|
||||
|
||||
for ent in chunk.entities.values():
|
||||
if ent.localX != localX or ent.localY != localY or ent.localZ != localZ:
|
||||
|
||||
Reference in New Issue
Block a user