mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 08:25:31 +00:00
feat: surface decoration generation but only in even chunks
This commit is contained in:
parent
fa6e0e0ae4
commit
bfc1c32d46
@ -13,6 +13,9 @@ import com.dfsek.terra.api.block.state.BlockState;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a type of block
|
* 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 {
|
public interface BlockType extends Handle {
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,8 @@ public class TerraMinestomExample {
|
|||||||
.createInstanceContainer();
|
.createInstanceContainer();
|
||||||
|
|
||||||
TerraMinestomWorldBuilder.from(instance)
|
TerraMinestomWorldBuilder.from(instance)
|
||||||
.packById("OVERWORLD")
|
.packById("DEFMOD")
|
||||||
|
.seed(0)
|
||||||
.attach();
|
.attach();
|
||||||
|
|
||||||
for(int x = -1; x <= 1; x++) {
|
for(int x = -1; x <= 1; x++) {
|
||||||
|
@ -7,6 +7,7 @@ import com.dfsek.terra.api.block.state.properties.Property;
|
|||||||
import net.minestom.server.instance.block.Block;
|
import net.minestom.server.instance.block.Block;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ public class MinestomBlockState implements BlockState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(BlockState other) {
|
public boolean matches(BlockState other) {
|
||||||
return ((MinestomBlockState) other).block == block;
|
return ((MinestomBlockState) other).block.compare(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,7 +71,7 @@ public class MinestomBlockState implements BlockState {
|
|||||||
@Override
|
@Override
|
||||||
public String getAsString(boolean properties) {
|
public String getAsString(boolean properties) {
|
||||||
String name = block.namespace().asString();
|
String name = block.namespace().asString();
|
||||||
if (!properties) {
|
if (!properties || block.properties().isEmpty()) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,4 +96,9 @@ public class MinestomBlockState implements BlockState {
|
|||||||
public Object getHandle() {
|
public Object getHandle() {
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(block.id());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,4 +32,17 @@ public class MinestomBlockType implements BlockType {
|
|||||||
public Object getHandle() {
|
public Object getHandle() {
|
||||||
return block;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@ public class MinestomChunkGeneratorWrapper implements Generator {
|
|||||||
Point start = unit.absoluteStart();
|
Point start = unit.absoluteStart();
|
||||||
CachedChunk chunk = cache.at(start.chunkX(), start.chunkZ());
|
CachedChunk chunk = cache.at(start.chunkX(), start.chunkZ());
|
||||||
|
|
||||||
//chunk.writeRelative(unit.modifier());
|
chunk.writeRelative(unit.modifier());
|
||||||
|
|
||||||
if (start.chunkX() % 2 == 0 && start.chunkZ() % 2 == 0) {
|
//if (start.chunkX() % 2 == 0 && start.chunkZ() % 2 == 0) {
|
||||||
chunk.writeRelative(unit.modifier());
|
//chunk.writeRelative(unit.modifier());
|
||||||
}
|
//}
|
||||||
|
|
||||||
unit.fork(setter -> {
|
unit.fork(setter -> {
|
||||||
MinestomProtoWorld protoWorld = new MinestomProtoWorld(
|
MinestomProtoWorld protoWorld = new MinestomProtoWorld(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user