Skip to content

Commit

Permalink
Fix compilation error & improve understandability of pie code
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixaurora committed Oct 24, 2023
1 parent 2f15254 commit f7ae5f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public boolean generateStructures() {
public List<ShadeData> shadesIn(ChunkPos chunk) {
GraphedChunk graph = this.grapher.getChunkGraph(chunk);

List<ShadeData> shades = new ArrayList<>(this.shadingMethod.shadeIn(graph.getShaded()));
this.outlineShading.ifPresent(outline -> shades.addAll(outline.shadeIn(graph.getOutlines())));
List<ShadeData> shades = new ArrayList<>(this.shadingMethod.shadeIn(graph.getShaded(), chunk));
this.outlineShading.ifPresent(outline -> shades.addAll(outline.shadeIn(graph.getOutlines(), chunk)));

return shades;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public class PieShading implements SimpleShadingMethod {

private final List<String> generatorKeys;

private final double stepAmount;
private final int maxSlice;
private final double sliceArcLength;
private final int lastSliceIndex;

public PieShading(List<String> generatorKeys) {
this.generatorKeys = generatorKeys;

this.stepAmount = 2 * Math.PI / (generatorKeys.size());
this.maxSlice = generatorKeys.size() - 1;
this.sliceArcLength = 2 * Math.PI / (generatorKeys.size());
this.lastSliceIndex = generatorKeys.size() - 1;
}

@Override
Expand All @@ -40,8 +40,8 @@ public List<String> involvedGeneratorKeys() {
}

private int getSlice(Coordinate pos) {
int slice = Mth.floor((pos.angle() + Math.PI) / this.stepAmount);
return Math.min(slice, maxSlice); // Because there is a straight 1-thick line that is out of bounds otherwise
int currentSlice = Mth.floor((pos.angle() + Math.PI) / this.sliceArcLength);
return Math.min(currentSlice, lastSliceIndex); // Because there is a straight 1-thick line that is out of bounds otherwise
}

@Override
Expand Down

0 comments on commit f7ae5f0

Please sign in to comment.