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)));
}
}

View File

@ -80,7 +80,7 @@ public class FabricWorld implements World, FabricWorldHandle {
@Override
public boolean equals(Object obj) {
if(!(obj instanceof FabricWorld)) return false;
return ((ServerWorldAccess) ((FabricWorld) obj).delegate.world).toServerWorld().equals(((ServerWorldAccess) delegate.world).toServerWorld()); // FIXME this method is cursed.
return ((ServerWorldAccess) ((FabricWorld) obj).delegate.world).toServerWorld().equals(((ServerWorldAccess) delegate.world).toServerWorld());
}
@Override

View File

@ -78,8 +78,7 @@ public class FabricWorldChunkRegion implements World, FabricWorldHandle {
@Override
public boolean equals(Object obj) {
if(!(obj instanceof FabricWorldChunkRegion)) return false;
return delegate.chunk.equals(((FabricWorldChunkRegion) obj).delegate.chunk);
//return ((ServerWorldAccess) ((FabricWorldChunkRegion) obj).delegate.chunk).toServerWorld().equals(((ServerWorldAccess) delegate.chunk).toServerWorld());
return ((ServerWorldAccess) ((FabricWorldChunkRegion) obj).delegate.chunk).toServerWorld().equals(((ServerWorldAccess) delegate.chunk).toServerWorld());
}
@Override