Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(JOML): migrate world generation #5

Merged
merged 4 commits into from
Dec 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion module.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "AlchemyPlantGenerator",
"version": "1.0.0",
"version": "1.0.0-SNAPSHOT",
"author": "Thomas O'Keeffe",
"displayName": "Alchemy - Plant Generator",
"description": "Simple module for spawning plants from the Alchemy module into the world.",
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/terasology/AlchemyPlantFacet.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.terasology;

import org.terasology.math.Region3i;
import org.terasology.world.block.BlockRegion;
import org.terasology.world.generation.Border3D;
import org.terasology.world.generation.facets.base.BaseBooleanFieldFacet3D;

public class AlchemyPlantFacet extends BaseBooleanFieldFacet3D {

public AlchemyPlantFacet(Region3i targetRegion, Border3D border) {
public AlchemyPlantFacet(BlockRegion targetRegion, Border3D border) {
super(targetRegion, border);
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/terasology/AlchemyPlantProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void process(GeneratingRegion region) {
for (int x = surfacesFacet.getWorldRegion().minX(); x <= surfacesFacet.getWorldRegion().maxX(); x++) {
for (int z = surfacesFacet.getWorldRegion().minZ(); z <= surfacesFacet.getWorldRegion().maxZ(); z++) {
for (int surfaceHeight : surfacesFacet.getWorldColumn(x, z)) {
if (facet.getWorldRegion().encompasses(x, surfaceHeight + 1, z)
if (facet.getWorldRegion().contains(x, surfaceHeight + 1, z)
&& noise.noise(x, surfaceHeight, z) > configMap.get(configuration.plantRarity)) {
facet.setWorld(x, surfaceHeight + 1, z, true);
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/terasology/AlchemyPlantRasterizer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.terasology;

import org.joml.Vector3i;
import org.joml.Vector3ic;
import org.terasology.math.ChunkMath;
import org.terasology.math.geom.Vector3i;
import org.terasology.registry.CoreRegistry;
import org.terasology.world.block.Block;
import org.terasology.world.block.BlockManager;
Expand Down Expand Up @@ -62,9 +63,9 @@ public void initialize() {
public void generateChunk(CoreChunk chunk, Region chunkRegion) {
AlchemyPlantFacet alchemyPlantFacet = chunkRegion.getFacet(AlchemyPlantFacet.class);

for (Vector3i block : alchemyPlantFacet.getWorldRegion()) {
for (Vector3ic block : alchemyPlantFacet.getWorldRegion()) {
if (alchemyPlantFacet.getWorld(block)) {
chunk.setBlock(ChunkMath.calcRelativeBlockPos(block), block_map.get(rand.nextInt(8)));
chunk.setBlock(ChunkMath.calcRelativeBlockPos(block, new Vector3i()), block_map.get(rand.nextInt(8)));
}
}
}
Expand Down