Skip to content

Commit

Permalink
pass absolute coordinates to simple shading methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixaurora committed Oct 18, 2023
1 parent e528e94 commit d74a38c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,18 @@ public Coordinate makeLegal() {
return this.makeLegal(16);
}

public double angle() {
return Math.atan2(this.z, this.x);
}

public Coordinate offset(int x, int z) {
return new Coordinate(this.x + x, this.z + z);
}

public Coordinate offset(Coordinate amount) {
return this.offset(amount.x, amount.z);
}

public Coordinate offsetIn(Direction8 direction) {
return this.offset(direction.getStepX(), direction.getStepZ());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package net.pixaurora.janerator.graphing;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public SerialType<? extends ShadingMethod> type() {
}

@Override
public ShadeData getShade(Coordinate pos) {
return new ShadeData(pos, this.generatorKey);
public String getShade(Coordinate pos) {
return this.generatorKey;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec;

import net.minecraft.world.level.ChunkPos;
import net.pixaurora.janerator.config.SerialType;
import net.pixaurora.janerator.config.SpecifiesType;
import net.pixaurora.janerator.graphing.Coordinate;
Expand All @@ -28,7 +29,7 @@ public interface ShadingMethod extends SpecifiesType<ShadingMethod> {
}
);

public List<ShadeData> shadeIn(List<Coordinate> points);
public List<ShadeData> shadeIn(List<Coordinate> points, ChunkPos chunk);

public List<String> involvedGeneratorKeys();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import java.util.ArrayList;
import java.util.List;

import net.minecraft.world.level.ChunkPos;
import net.pixaurora.janerator.graphing.Coordinate;

public interface SimpleShadingMethod extends ShadingMethod {
public ShadeData getShade(Coordinate pos);
public String getShade(Coordinate pos);

public default List<ShadeData> shadeIn(List<Coordinate> points, ChunkPos chunk) {
Coordinate offsetAmount = new Coordinate(chunk.getBlockAt(0, 0, 0));

public default List<ShadeData> shadeIn(List<Coordinate> points) {
List<ShadeData> shading = new ArrayList<>(points.size());
for (Coordinate pos : points) {
shading.add(this.getShade(pos));
shading.add(new ShadeData(pos, this.getShade(pos.offset(offsetAmount))));
}

return shading;
Expand Down

0 comments on commit d74a38c

Please sign in to comment.