mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
remove world field from FabricChunkGeneratorWrapper
This commit is contained in:
parent
b4e6f2775e
commit
3d9d0d46fb
@ -24,6 +24,7 @@ import com.dfsek.tectonic.api.TypeRegistry;
|
|||||||
import com.dfsek.tectonic.api.exception.LoadException;
|
import com.dfsek.tectonic.api.exception.LoadException;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.MinecraftVersion;
|
import net.minecraft.MinecraftVersion;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.BuiltinRegistries;
|
import net.minecraft.util.registry.BuiltinRegistries;
|
||||||
|
@ -27,6 +27,8 @@ import com.dfsek.terra.api.world.chunk.generation.util.GeneratorWrapper;
|
|||||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||||
import com.dfsek.terra.fabric.mixin.access.StructureAccessorAccessor;
|
import com.dfsek.terra.fabric.mixin.access.StructureAccessorAccessor;
|
||||||
|
|
||||||
|
import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||||
|
|
||||||
import com.mojang.serialization.Codec;
|
import com.mojang.serialization.Codec;
|
||||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
@ -88,7 +90,6 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
|||||||
private final TerraBiomeSource biomeSource;
|
private final TerraBiomeSource biomeSource;
|
||||||
private ChunkGenerator delegate;
|
private ChunkGenerator delegate;
|
||||||
private ConfigPack pack;
|
private ConfigPack pack;
|
||||||
private net.minecraft.server.world.ServerWorld world;
|
|
||||||
private final Supplier<ChunkGeneratorSettings> settingsSupplier;
|
private final Supplier<ChunkGeneratorSettings> settingsSupplier;
|
||||||
|
|
||||||
public FabricChunkGeneratorWrapper(TerraBiomeSource biomeSource, long seed, ConfigPack configPack,
|
public FabricChunkGeneratorWrapper(TerraBiomeSource biomeSource, long seed, ConfigPack configPack,
|
||||||
@ -210,22 +211,22 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView heightmapType) {
|
public int getHeight(int x, int z, Heightmap.Type heightmap, HeightLimitView height) {
|
||||||
int height = getMinimumY() + getWorldHeight();
|
int y = height.getTopY();
|
||||||
while(height >= getMinimumY() && !heightmap.getBlockPredicate().test(
|
while(y >= getMinimumY() && !heightmap.getBlockPredicate().test(
|
||||||
(BlockState) delegate.getBlock((ServerWorld) world, x, height - 1, z))) {
|
(BlockState) delegate.getBlock(FabricAdapter.adapt(height, seed), x, y - 1, z))) {
|
||||||
height--;
|
y--;
|
||||||
}
|
}
|
||||||
return height;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView view) {
|
public VerticalBlockSample getColumnSample(int x, int z, HeightLimitView height) {
|
||||||
BlockState[] array = new BlockState[view.getHeight()];
|
BlockState[] array = new BlockState[height.getHeight()];
|
||||||
for(int y = view.getTopY() - 1; y >= view.getBottomY(); y--) {
|
for(int y = height.getTopY() - 1; y >= height.getBottomY(); y--) {
|
||||||
array[y - view.getBottomY()] = (BlockState) delegate.getBlock((ServerWorld) world, x, y, z);
|
array[y - height.getBottomY()] = (BlockState) delegate.getBlock(FabricAdapter.adapt(height, seed), x, y, z);
|
||||||
}
|
}
|
||||||
return new VerticalBlockSample(view.getBottomY(), array);
|
return new VerticalBlockSample(height.getBottomY(), array);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigPack getPack() {
|
public ConfigPack getPack() {
|
||||||
@ -246,10 +247,6 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorld(net.minecraft.server.world.ServerWorld world) {
|
|
||||||
this.world = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkGenerator getHandle() {
|
public ChunkGenerator getHandle() {
|
||||||
return delegate;
|
return delegate;
|
||||||
|
@ -43,7 +43,7 @@ import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
|||||||
|
|
||||||
@Mixin(ServerWorld.class)
|
@Mixin(ServerWorld.class)
|
||||||
public abstract class ServerWorldMixin {
|
public abstract class ServerWorldMixin {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ServerWorldMixin.class);
|
private static final Logger logger = LoggerFactory.getLogger(ServerWorld.class);
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Inject(method = "<init>", at = @At("RETURN"))
|
||||||
public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session,
|
public void injectConstructor(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session,
|
||||||
@ -51,7 +51,6 @@ public abstract class ServerWorldMixin {
|
|||||||
WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator,
|
WorldGenerationProgressListener worldGenerationProgressListener, ChunkGenerator chunkGenerator,
|
||||||
boolean debugWorld, long l, List<Spawner> list, boolean bl, CallbackInfo ci) {
|
boolean debugWorld, long l, List<Spawner> list, boolean bl, CallbackInfo ci) {
|
||||||
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
if(chunkGenerator instanceof FabricChunkGeneratorWrapper) {
|
||||||
((FabricChunkGeneratorWrapper) chunkGenerator).setWorld((ServerWorld) (Object) this);
|
|
||||||
FabricEntryPoint.getPlatform().addWorld((ServerWorld) (Object) this);
|
FabricEntryPoint.getPlatform().addWorld((ServerWorld) (Object) this);
|
||||||
logger.info("Registered world {}", this);
|
logger.info("Registered world {}", this);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.fabric.util;
|
package com.dfsek.terra.fabric.util;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||||
|
|
||||||
import net.minecraft.block.enums.BlockHalf;
|
import net.minecraft.block.enums.BlockHalf;
|
||||||
import net.minecraft.block.enums.WallShape;
|
import net.minecraft.block.enums.WallShape;
|
||||||
import net.minecraft.block.enums.WireConnection;
|
import net.minecraft.block.enums.WireConnection;
|
||||||
@ -30,6 +32,8 @@ import com.dfsek.terra.api.block.state.properties.enums.RedstoneConnection;
|
|||||||
import com.dfsek.terra.api.block.state.properties.enums.WallHeight;
|
import com.dfsek.terra.api.block.state.properties.enums.WallHeight;
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
import com.dfsek.terra.api.util.vector.Vector3;
|
||||||
|
|
||||||
|
import net.minecraft.world.HeightLimitView;
|
||||||
|
|
||||||
|
|
||||||
public final class FabricAdapter {
|
public final class FabricAdapter {
|
||||||
public static BlockPos adapt(Vector3 v) {
|
public static BlockPos adapt(Vector3 v) {
|
||||||
@ -51,6 +55,30 @@ public final class FabricAdapter {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WorldProperties adapt(HeightLimitView height, long seed) {
|
||||||
|
return new WorldProperties() {
|
||||||
|
@Override
|
||||||
|
public long getSeed() {
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxHeight() {
|
||||||
|
return height.getTopY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMinHeight() {
|
||||||
|
return height.getBottomY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getHandle() {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static com.dfsek.terra.api.block.state.properties.enums.Direction adapt(Direction direction) {
|
public static com.dfsek.terra.api.block.state.properties.enums.Direction adapt(Direction direction) {
|
||||||
return switch(direction) {
|
return switch(direction) {
|
||||||
case SOUTH -> com.dfsek.terra.api.block.state.properties.enums.Direction.SOUTH;
|
case SOUTH -> com.dfsek.terra.api.block.state.properties.enums.Direction.SOUTH;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user