feat: surface decoration generation but only in even chunks

This commit is contained in:
Christian Bergschneider 2024-12-29 15:17:35 +01:00
parent fa6e0e0ae4
commit bfc1c32d46
5 changed files with 30 additions and 7 deletions

View File

@ -13,6 +13,9 @@ import com.dfsek.terra.api.block.state.BlockState;
/**
* Represents a type of block
* <p>
* Important! You <b>need</b> to implement a proper equals() and hashCode() here in
* your platform implementation for surface decorations to show up
*/
public interface BlockType extends Handle {
/**

View File

@ -18,7 +18,8 @@ public class TerraMinestomExample {
.createInstanceContainer();
TerraMinestomWorldBuilder.from(instance)
.packById("OVERWORLD")
.packById("DEFMOD")
.seed(0)
.attach();
for(int x = -1; x <= 1; x++) {

View File

@ -7,6 +7,7 @@ import com.dfsek.terra.api.block.state.properties.Property;
import net.minestom.server.instance.block.Block;
import java.util.HashMap;
import java.util.Objects;
import java.util.stream.Collectors;
@ -44,7 +45,7 @@ public class MinestomBlockState implements BlockState {
@Override
public boolean matches(BlockState other) {
return ((MinestomBlockState) other).block == block;
return ((MinestomBlockState) other).block.compare(block);
}
@Override
@ -70,7 +71,7 @@ public class MinestomBlockState implements BlockState {
@Override
public String getAsString(boolean properties) {
String name = block.namespace().asString();
if (!properties) {
if (!properties || block.properties().isEmpty()) {
return name;
}
@ -95,4 +96,9 @@ public class MinestomBlockState implements BlockState {
public Object getHandle() {
return block;
}
@Override
public int hashCode() {
return Objects.hashCode(block.id());
}
}

View File

@ -32,4 +32,17 @@ public class MinestomBlockType implements BlockType {
public Object getHandle() {
return block;
}
@Override
public int hashCode() {
return block.id();
}
@Override
public boolean equals(Object obj) {
if (obj instanceof MinestomBlockType other) {
return block.id() == other.block.id();
}
return false;
}
}

View File

@ -32,11 +32,11 @@ public class MinestomChunkGeneratorWrapper implements Generator {
Point start = unit.absoluteStart();
CachedChunk chunk = cache.at(start.chunkX(), start.chunkZ());
//chunk.writeRelative(unit.modifier());
if (start.chunkX() % 2 == 0 && start.chunkZ() % 2 == 0) {
chunk.writeRelative(unit.modifier());
}
//if (start.chunkX() % 2 == 0 && start.chunkZ() % 2 == 0) {
//chunk.writeRelative(unit.modifier());
//}
unit.fork(setter -> {
MinestomProtoWorld protoWorld = new MinestomProtoWorld(