fix structure buffer weirdness

This commit is contained in:
dfsek
2021-02-24 08:51:35 -07:00
parent 3c56813d6b
commit bb6dcb3880
6 changed files with 9 additions and 7 deletions

View File

@@ -123,7 +123,6 @@ public class StructureScript {
private StructureBuffer computeBuffer(Location location, Random random, Rotation rotation) {
try {
return cache.get(location, () -> {
System.out.println("{" + FastMath.floorDiv(location.getBlockX(), 16) + ", " + FastMath.floorDiv(location.getBlockZ(), 16) + "} : " + cache.size() + " : " + location.hashCode());
StructureBuffer buf = new StructureBuffer(location);
buf.setSucceeded(applyBlock(new TerraImplementationArguments(buf, rotation, random, 0)));
return buf;

View File

@@ -26,7 +26,7 @@ public class StructureBuffer implements Buffer {
Location current = origin.clone().add(location);
if(FastMath.floorDiv(current.getBlockX(), 16) != chunk.getX() || FastMath.floorDiv(current.getBlockZ(), 16) != chunk.getZ())
return;
item.paste(current);
item.paste(chunk, current);
}));
}

View File

@@ -1,7 +1,13 @@
package com.dfsek.terra.api.structures.structure.buffer.items;
import com.dfsek.terra.api.math.vector.Location;
import com.dfsek.terra.api.platform.world.Chunk;
public interface BufferedItem {
void paste(Location origin);
default void paste(Chunk chunk, Location origin) {
origin.setWorld(chunk.getWorld()); // Fabric weirdness
paste(origin);
}
}

View File

@@ -42,8 +42,6 @@ public class StructurePopulator implements TerraBlockPopulator {
if(!((UserDefinedBiome) provider.getBiome(spawn)).getConfig().getStructures().contains(conf))
continue;
Random random = new FastRandom(MathUtil.getCarverChunkSeed(FastMath.floorDiv(spawn.getBlockX(), 16), FastMath.floorDiv(spawn.getBlockZ(), 16), world.getSeed()));
System.out.println("chunk: {" + chunk.getX() + ", " + chunk.getZ() + "}");
System.out.println(world.getBlockAt(cx, 255, cz).getBlockData());
conf.getStructure().get(random).execute(spawn.setY(conf.getSpawnStart().get(random)), chunk, random, Rotation.fromDegrees(90 * random.nextInt(4)));
}
}