Skip to content

Commit

Permalink
Change behaviour so that squishing happens within dimension bounds, a…
Browse files Browse the repository at this point in the history
…s provided by the original biome map
  • Loading branch information
lukebemish committed Nov 4, 2023
1 parent 7b4564e commit 31ea551
Show file tree
Hide file tree
Showing 14 changed files with 263 additions and 176 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,7 @@ Each squisher referenced by a series should be placed at `data/[namespace]/biome
* `"temperature"`, `"humidity"`, `"erosion"`, `"weirdness"`: one of `"start"`, `"center"`, or `"end"`. When resolving which side of an opened hole to move a biome injection to, Biome Squisher will go through the relatives one by one till
it finds one with a non-`"center"` dimension that the squisher in the same location squishes in. This means that the list of relatives must give a non-`"center"` value to each dimension _exactly once_.

Biome Squisher applies registered `series` in alphabetical order, so that biome injection is platform-independent and deterministic. Additionally, the mod provides the `/biomesquisher dump` command, which takes the names of two axes and values
at the remaining four axes, and saves a PNG image slice through the biome space along the specified axes, which may be useful for debugging or generally inspecting the biome space.
Biome Squisher applies registered `series` in alphabetical order, so that biome injection is platform-independent and
deterministic. Additionally, the mod provides the `/biomesquisher dump` command, which takes the names of two axes,
values at the remaining four axes, and bounds to view within the two axes, and saves a PNG image slice through the biome
space along the specified axes, which may be useful for debugging or generally inspecting the biome space.
6 changes: 4 additions & 2 deletions SHORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@ Each squisher referenced by a series should be placed at `data/[namespace]/biome
* `"temperature"`, `"humidity"`, `"erosion"`, `"weirdness"`: one of `"start"`, `"center"`, or `"end"`. When resolving which side of an opened hole to move a biome injection to, Biome Squisher will go through the relatives one by one till
it finds one with a non-`"center"` dimension that the squisher in the same location squishes in. This means that the list of relatives must give a non-`"center"` value to each dimension *exactly once*.

Biome Squisher applies registered `series` in alphabetical order, so that biome injection is platform-independent and deterministic. Additionally, the mod provides the `/biomesquisher dump` command, which takes the names of two axes and values
at the remaining four axes, and saves a PNG image slice through the biome space along the specified axes, which may be useful for debugging or generally inspecting the biome space.
Biome Squisher applies registered `series` in alphabetical order, so that biome injection is platform-independent and
deterministic. Additionally, the mod provides the `/biomesquisher dump` command, which takes the names of two axes,
values at the remaining four axes, and bounds to view within the two axes, and saves a PNG image slice through the biome
space along the specified axes, which may be useful for debugging or generally inspecting the biome space.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import com.google.common.collect.ImmutableBiMap;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import dev.lukebemish.biomesquisher.impl.Context;
import dev.lukebemish.biomesquisher.impl.Dimension;
import dev.lukebemish.biomesquisher.impl.Utils;
import net.minecraft.util.StringRepresentable;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -34,7 +38,13 @@ default boolean isSquish() {
return false;
}

double center();
double globalCenter();

@ApiStatus.Internal
default double center(Context context, Dimension dimension) {
return Utils.recontext(globalCenter(), context, dimension);
}

Codec<? extends DimensionBehaviour> codec();

enum Type implements StringRepresentable {
Expand All @@ -51,8 +61,8 @@ enum Type implements StringRepresentable {

final class Range implements DimensionBehaviour {
public static final Codec<Range> CODEC = RecordCodecBuilder.create(i -> i.group(
Codec.DOUBLE.fieldOf("min").forGetter(Range::min),
Codec.DOUBLE.fieldOf("max").forGetter(Range::max)
Codec.DOUBLE.fieldOf("min").forGetter(Range::globalMin),
Codec.DOUBLE.fieldOf("max").forGetter(Range::globalMax)
).apply(i, Range::new));

private final double min;
Expand All @@ -64,14 +74,24 @@ public Range(double min, double max) {
if (min >= max) throw new IllegalArgumentException("min must be less than max");
}

public double min() {
public double globalMin() {
return min;
}

public double max() {
public double globalMax() {
return max;
}

@ApiStatus.Internal
public double min(Context context, Dimension dimension) {
return Utils.recontext(min, context, dimension);
}

@ApiStatus.Internal
public double max(Context context, Dimension dimension) {
return Utils.recontext(max, context, dimension);
}

@Override
public Range asRange() {
return this;
Expand All @@ -83,7 +103,7 @@ public boolean isRange() {
}

@Override
public double center() {
public double globalCenter() {
return (min + max) / 2f;
}

Expand All @@ -103,7 +123,7 @@ public String toString() {

final class Squish implements DimensionBehaviour {
public static final Codec<Squish> CODEC = RecordCodecBuilder.create(i -> i.group(
Codec.DOUBLE.fieldOf("position").forGetter(Squish::position),
Codec.DOUBLE.fieldOf("position").forGetter(Squish::globalPosition),
Codec.DOUBLE.optionalFieldOf("degree", 1d).forGetter(Squish::degree)
).apply(i, Squish::new));

Expand All @@ -115,10 +135,15 @@ public Squish(double position, double degree) {
this.degree = degree;
}

public double position() {
public double globalPosition() {
return position;
}

@ApiStatus.Internal
public double position(Context context, Dimension dimension) {
return Utils.recontext(position, context, dimension);
}

@Override
public Squish asSquish() {
return this;
Expand All @@ -130,7 +155,7 @@ public boolean isSquish() {
}

@Override
public double center() {
public double globalCenter() {
return position;
}

Expand Down
Loading

0 comments on commit 31ea551

Please sign in to comment.