Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions common/src/main/java/dev/ryanhcode/sable/SableConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.neoforged.neoforge.common.ModConfigSpec;

public final class SableConfig {
public enum SubLevelStartPos { FIXED, DYNAMIC, MIDPOINT }

public static final ModConfigSpec SPEC;

Expand All @@ -19,6 +20,8 @@ public final class SableConfig {
public static final ModConfigSpec.BooleanValue ATTEMPT_UDP_NETWORKING;
public static final ModConfigSpec.BooleanValue VERBOSE_SERIALIZATION_LOGGING;
public static final ModConfigSpec.BooleanValue SUB_LEVEL_SAVING_LOG_MESSAGE;
public static final ModConfigSpec.EnumValue<SubLevelStartPos> SUB_LEVEL_START_POS;
public static final ModConfigSpec.IntValue SUB_LEVEL_FIXED_START_HEIGHT;

static {
final ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
Expand Down Expand Up @@ -64,6 +67,12 @@ public final class SableConfig {
VERBOSE_SERIALIZATION_LOGGING = builder
.comment("If Sable should use verbose logging for its serialization system and the holding chunk-map. Not recommended- for debugging purposes only.")
.define("verbose_serialization_logging", false);
SUB_LEVEL_START_POS = builder
.comment("When a sub-level is created, how to determine the height within the sub-level that the first block should be placed at.")
.defineEnum("sub_level_start_pos", SubLevelStartPos.FIXED);
SUB_LEVEL_FIXED_START_HEIGHT = builder
.comment("If 'sub_level_start_pos' is set to 'FIXED', the fixed height to use.")
.defineInRange("sub_level_fixed_start_height", 128, Integer.MIN_VALUE, Integer.MAX_VALUE);

SPEC = builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.ryanhcode.sable.api;

import dev.ryanhcode.sable.Sable;
import dev.ryanhcode.sable.SableConfig;
import dev.ryanhcode.sable.api.block.BlockSubLevelAssemblyListener;
import dev.ryanhcode.sable.api.physics.PhysicsPipeline;
import dev.ryanhcode.sable.api.physics.handle.RigidBodyHandle;
Expand Down Expand Up @@ -84,7 +85,14 @@ public static ServerSubLevel assembleBlocks(final ServerLevel level, final Block
final LevelPlot plot = subLevel.getPlot();
plot.newEmptyChunk(plot.getCenterChunk());

final BlockPos plotAnchor = plot.getCenterBlock();
Integer yPos = 128;
switch (SableConfig.SUB_LEVEL_START_POS.get()) {
case FIXED -> yPos = SableConfig.SUB_LEVEL_FIXED_START_HEIGHT.getAsInt();
case DYNAMIC -> yPos = anchor.getY();
case MIDPOINT -> yPos = (level.getMinBuildHeight() + level.getMaxBuildHeight()) >> 1;
}

final BlockPos plotAnchor = plot.getCenterBlock().atY(yPos);
final SubLevelAssemblyHelper.AssemblyTransform transform = new SubLevelAssemblyHelper.AssemblyTransform(anchor, plotAnchor, 0, Rotation.NONE, level);
SubLevelAssemblyHelper.moveOtherStuff(level, transform, blocks, bounds);
SubLevelAssemblyHelper.moveBlocks(level, transform, blocks);
Expand Down