use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class SparseFieldFacet3D method getWorldEntries.
/**
* @return a <b>new</b> map with world-based position entries
*/
public Map<Vector3i, Number> getWorldEntries() {
Map<Vector3i, Number> result = Maps.newLinkedHashMap();
for (Entry<Vector3i, Number> entry : relData.entrySet()) {
Vector3i relPos = entry.getKey();
Vector3i worldPos = relativeToWorld(relPos.x, relPos.y, relPos.z);
result.put(worldPos, entry.getValue());
}
return result;
}
use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class SparseObjectFacet3D method getWorld.
@Override
public T getWorld(int x, int y, int z) {
checkWorldCoords(x, y, z);
Vector3i index = worldToRelative(x, y, z);
return relData.get(index);
}
use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class ChunkViewCoreImpl method getBiome.
@Override
public Biome getBiome(int blockX, int blockY, int blockZ) {
if (!blockRegion.encompasses(blockX, blockY, blockZ)) {
return BiomeManager.getUnknownBiome();
}
int chunkIndex = relChunkIndex(blockX, blockY, blockZ);
Vector3i blockPos = ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize);
return chunks[chunkIndex].getBiome(blockPos.x, blockPos.y, blockPos.z);
}
use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class ChunkViewCoreImpl method setBiome.
@Override
public void setBiome(int blockX, int blockY, int blockZ, Biome biome) {
if (blockRegion.encompasses(blockX, blockY, blockZ)) {
int chunkIndex = relChunkIndex(blockX, blockY, blockZ);
Vector3i pos = ChunkMath.calcBlockPos(blockX, blockY, blockZ, chunkFilterSize);
chunks[chunkIndex].setBiome(pos.x, pos.y, pos.z, biome);
} else {
logger.warn("Attempt to modify biome outside of the view");
}
}
use of org.terasology.math.geom.Vector3i in project Terasology by MovingBlocks.
the class EntityAwareWorldProvider method updateBlockEntity.
private void updateBlockEntity(EntityRef blockEntity, Vector3i pos, Block oldType, Block type, boolean forceEntityUpdate, Set<Class<? extends Component>> retainComponents) {
if (type.isKeepActive()) {
temporaryBlockEntities.remove(blockEntity);
} else if (oldType.isKeepActive() && isTemporaryBlock(blockEntity, type)) {
temporaryBlockEntities.add(blockEntity);
}
if (forceEntityUpdate || !(Objects.equal(oldType.getBlockFamily(), type.getBlockFamily()) && Objects.equal(oldType.getPrefab(), type.getPrefab()))) {
updateBlockEntityComponents(blockEntity, oldType, type, retainComponents);
}
EntityRef regionEntity = blockRegionLookup.get(pos);
if (regionEntity != null) {
regionEntity.send(new OnChangedBlock(pos, type, oldType));
}
blockEntity.send(new OnChangedBlock(new Vector3i(pos), type, oldType));
}
Aggregations