Skip to content

Commit

Permalink
reformat all code
Browse files Browse the repository at this point in the history
  • Loading branch information
dfsek committed Jul 7, 2022
1 parent dc5e71e commit b3a8f37
Show file tree
Hide file tree
Showing 111 changed files with 672 additions and 619 deletions.
12 changes: 8 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@

- [ ] Bug Fix <!-- Anything which fixes an issue in Terra. -->
- [ ] Build system <!-- Anything which pretain to the build system. -->
- [ ] Documentation <!-- Anything which adds or improves documentation for existing features. -->
- [ ]
Documentation <!-- Anything which adds or improves documentation for existing features. -->
- [ ] New Feature <!-- Anything which adds new functionality to Terra. -->
- [ ] Performance <!-- Anything which is imrpoves the performance of Terra. -->
- [ ] Refactoring <!-- Anything which does not add any new code, only moves code around. -->
- [ ] Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
- [ ]
Refactoring <!-- Anything which does not add any new code, only moves code around. -->
- [ ]
Repository <!-- Anything which affects the repository. Eg. changes to the `README.md` file. -->
- [ ] Revert <!-- Anything which reverts previous commits. -->
- [ ] Style <!-- Anything which updates style. -->
- [ ] Tests <!-- Anything which adds or updates tests. -->
- [ ] Translation <!-- Anything which is internationalizing the Terra program to other languages. -->
- [ ]
Translation <!-- Anything which is internationalizing the Terra program to other languages. -->

#### Compatiblity

Expand Down
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ to [Terra global moderation team](CODE_OF_CONDUCT.md#Reporting).

## I don't want to read this whole thing I just have a question!!!

> **Note:** Please don't file an issue to ask a question. You'll get faster results by using the resources below.
> **Note:** Please don't file an issue to ask a question. You'll get faster
> results by using the resources below.
We have an official discord server where you can request help from various users

Expand Down Expand Up @@ -103,7 +104,9 @@ you don't need to create one. When you are creating a bug report,
please [include as many details as possible](#how-do-i-submit-a-good-bug-report)
.

> **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one.
> **Note:** If you find a **Closed** issue that seems like it is the same thing
> that you're experiencing, open a new issue and include a link to the original
> issue in the body of your new one.
#### Before Submitting A Bug Report

Expand Down
44 changes: 22 additions & 22 deletions buildSrc/src/main/kotlin/AddonConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ import kotlin.streams.asStream
*/
fun Project.addonDir(dir: File, task: Task) {
val moveAddons = tasks.register("moveAddons" + task.name) {
dependsOn("compileAddons")
doLast {
dir.parentFile.mkdirs()
matchingAddons(dir) {
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
}.forEach {
println("Deleting old addon: " + it.absolutePath)
it.delete()
}
forSubProjects(":common:addons") {
val jar = tasks.named("shadowJar").get() as ShadowJar

val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val target = File(dir, boot + jar.archiveFileName.get())

val base = "${jar.archiveBaseName.get()}-${version}"

println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")

jar.archiveFile.orNull?.asFile?.copyTo(target)
}
dependsOn("compileAddons")
doLast {
dir.parentFile.mkdirs()
matchingAddons(dir) {
it.name.startsWith("Terra-") // Assume everything that starts with Terra- is a core addon.
}.forEach {
println("Deleting old addon: " + it.absolutePath)
it.delete()
}
forSubProjects(":common:addons") {
val jar = tasks.named("shadowJar").get() as ShadowJar

val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val target = File(dir, boot + jar.archiveFileName.get())

val base = "${jar.archiveBaseName.get()}-${version}"

println("Copying addon ${jar.archiveFileName.get()} to ${target.absolutePath}. Base name: $base")

jar.archiveFile.orNull?.asFile?.copyTo(target)
}

}

}

task.dependsOn(moveAddons)
}
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/DependencyConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ fun Project.configureDependencies() {
maven("https://papermc.io/repo/repository/maven-public/") {
name = "PaperMC"
}
maven ( "https://files.minecraftforge.net/maven/" ) {
maven("https://files.minecraftforge.net/maven/") {
name = "Forge"
}
maven ("https://maven.quiltmc.org/repository/release/") {
maven("https://maven.quiltmc.org/repository/release/") {
name = "Quilt"
}
maven("https://jitpack.io") {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/DistributionConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fun Project.configureDistribution() {

val boot = if (extra.has("bootstrap") && extra.get("bootstrap") as Boolean) "bootstrap/" else ""
val addonPath = fs.getPath("/addons/$boot${jar.archiveFileName.get()}")

if (!Files.exists(addonPath)) {
Files.createDirectories(addonPath.parent)
Files.createFile(addonPath)
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ object Versions {
const val minecraft = "1.19"
const val yarn = "$minecraft+build.1"
const val fabricLoader = "0.14.2"

const val architecuryLoom = "0.12.0-SNAPSHOT"
const val architecturyPlugin = "3.4-SNAPSHOT"

const val loomQuiltflower = "1.7.1"

const val lazyDfu = "0.1.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public BiomeExtrusionProvider(BiomeProvider delegate, List<Extrusion> extrusions
@Override
public Biome getBiome(int x, int y, int z, long seed) {
Biome delegated = delegate.getBiome(x, y, z, seed);

return extrude(delegated, x, y, z, seed);
}

Expand All @@ -42,8 +42,8 @@ public Biome extrude(Biome original, int x, int y, int z, long seed) {
@Override
public Column<Biome> getColumn(int x, int z, long seed, int min, int max) {
return delegate.getBaseBiome(x, z, seed)
.map(base -> (Column<Biome>) new BaseBiomeColumn(this, base, min, max, x, z, seed))
.orElseGet(() -> BiomeProvider.super.getColumn(x, z, seed, min, max));
.map(base -> (Column<Biome>) new BaseBiomeColumn(this, base, min, max, x, z, seed))
.orElseGet(() -> BiomeProvider.super.getColumn(x, z, seed, min, max));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
* Basically just a specialised implementation of {@link Optional} for biomes where a biome may be a "self" reference.
*/
public sealed interface ReplaceableBiome permits PresentBiome, SelfBiome {
static ReplaceableBiome of(Biome biome) {
return new PresentBiome(biome);
}

static ReplaceableBiome self() {
return SelfBiome.INSTANCE;
}

Biome get(Biome existing);

default Biome get() {
Expand All @@ -20,12 +28,4 @@ default Biome get() {
}

boolean isSelf();

static ReplaceableBiome of(Biome biome) {
return new PresentBiome(biome);
}

static ReplaceableBiome self() {
return SelfBiome.INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public Biome getBiome(int x, int y, int z, long seed) {
public Biome getBiome(int x, int z, long seed) {
x += mutator.noise(seed + 1, x, z) * noiseAmp;
z += mutator.noise(seed + 2, x, z) * noiseAmp;


x /= resolution;
z /= resolution;

int fdX = FastMath.floorDiv(x, pipeline.getSize());
int fdZ = FastMath.floorDiv(z, pipeline.getSize());
return holderCache.get(new SeededVector(fdX, fdZ, seed)).getBiome(x - fdX * pipeline.getSize(),
Expand Down Expand Up @@ -120,7 +120,7 @@ public boolean equals(Object obj) {
}
return false;
}

@Override
public int hashCode() {
int code = x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class BiomeProviderTemplate implements ObjectTemplate<BiomeProvi
@Default
@Description("""
The resolution at which to sample biomes.
Larger values are quadratically faster, but produce lower quality results.
For example, a value of 3 would sample every 3 blocks.""")
protected @Meta int resolution = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@


public class BiomeQueryAPIAddon implements AddonInitializer {
public static PropertyKey<BiomeTagHolder> BIOME_TAG_KEY = Context.create(BiomeTagHolder.class);
@Inject
private Platform platform;

@Inject
private BaseAddon addon;

public static PropertyKey<BiomeTagHolder> BIOME_TAG_KEY = Context.create(BiomeTagHolder.class);

@Override
public void initialize() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public final class BiomeQueries {
private BiomeQueries() {

}

public static Predicate<Biome> has(String tag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


public class SingleTagQuery implements Predicate<Biome> {
private int tagIndex = -1;
private final String tag;
private int tagIndex = -1;

public SingleTagQuery(String tag) {
this.tag = tag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public void initialize() {
.getOrCreateRegistry(ChunkGeneratorProvider.class)
.register(addon.key("NOISE_3D"),
pack -> new NoiseChunkGenerator3D(pack, platform, config.getElevationBlend(),
config.getHorizontalRes(),
config.getVerticalRes(), noisePropertiesPropertyKey,
paletteInfoPropertyKey));
config.getHorizontalRes(),
config.getVerticalRes(), noisePropertiesPropertyKey,
paletteInfoPropertyKey));
event.getPack()
.applyLoader(SlantLayer.class, SlantLayer::new);
})
Expand All @@ -62,8 +62,10 @@ public void initialize() {
.register(addon, ConfigurationLoadEvent.class)
.then(event -> {
if(event.is(Biome.class)) {
event.getLoadedObject(Biome.class).getContext().put(paletteInfoPropertyKey, event.load(new BiomePaletteTemplate(platform)).get());
event.getLoadedObject(Biome.class).getContext().put(noisePropertiesPropertyKey, event.load(new BiomeNoiseConfigTemplate()).get());
event.getLoadedObject(Biome.class).getContext().put(paletteInfoPropertyKey,
event.load(new BiomePaletteTemplate(platform)).get());
event.getLoadedObject(Biome.class).getContext().put(noisePropertiesPropertyKey,
event.load(new BiomeNoiseConfigTemplate()).get());
}
})
.failThrough();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public double getNoise(NoiseSampler sampler, int x, int y, int z, long seed) {
if(holder.init && holder.y == y && holder.z == z && holder.x == x && holder.seed == seed) {
return holder.noise;
}

double noise = sampler.noise(seed, x, y, z);
holder.noise = noise;
holder.x = x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public PaletteInfo get() {
slantLayers.put(threshold, layer.getPalette());
}

return new PaletteInfo(builder.build(), SlantHolder.of(slantLayers, minThreshold), oceanPalette, seaLevel, slantDepth, updatePalette);
return new PaletteInfo(builder.build(), SlantHolder.of(slantLayers, minThreshold), oceanPalette, seaLevel, slantDepth,
updatePalette);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public ChunkInterpolator(long seed, int chunkX, int chunkZ, BiomeProvider provid
for(int zi = -blend; zi <= blend; zi++) {
int blendX = (xi * step);
int blendZ = (zi * step);

int localIndex = (scaledX + maxBlend + blendX) + maxBlendAndChunk * (scaledZ + maxBlend + blendZ);
Column<Biome> column = columns[localIndex];

if(column == null) {
column = provider.getColumn(absoluteX + blendX, absoluteZ + blendZ, seed, min, max);
columns[localIndex] = column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class LazilyEvaluatedInterpolator {
private final int min, max;

private final int zMul, yMul;

public LazilyEvaluatedInterpolator(BiomeProvider biomeProvider, int cx, int cz, int max,
PropertyKey<BiomeNoiseProperties> noisePropertiesKey, int min, int horizontalRes, int verticalRes,
long seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Sampler3D get(int x, int z, WorldProperties world, BiomeProvider provider
public Sampler3D getChunk(int cx, int cz, WorldProperties world, BiomeProvider provider) {
WorldContext context = new WorldContext(cx, cz, world.getSeed(), world.getMinHeight(), world.getMaxHeight());
return cache.get(context, c -> new Sampler3D(c.cx, c.cz, c.seed, c.minHeight, c.maxHeight, provider,
elevationSmooth, noisePropertiesKey, maxBlend));
elevationSmooth, noisePropertiesKey, maxBlend));
}

private record WorldContext(int cx, int cz, long seed, int minHeight, int maxHeight) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ public SamplerLocator(List<NoiseSampler> samplers) {
this.samplers = samplers;
}

private static int floorToInt(double value) {
int valueInt = (int) value;
if(value < 0.0) {
if(value == (double) valueInt) {
return valueInt;
} else {
return valueInt == Integer.MIN_VALUE ? valueInt : valueInt - 1;
}
} else {
return valueInt;
}
}

@Override
public BinaryColumn getSuitableCoordinates(Column<?> column) {
BinaryColumnBuilder results = column.newBinaryColumn();
Expand All @@ -36,17 +49,4 @@ public BinaryColumn getSuitableCoordinates(Column<?> column) {

return results.build();
}

private static int floorToInt(double value) {
int valueInt = (int)value;
if (value < 0.0) {
if (value == (double)valueInt) {
return valueInt;
} else {
return valueInt == Integer.MIN_VALUE ? valueInt : valueInt - 1;
}
} else {
return valueInt;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@


public class UserDefinedFunction implements DynamicFunction {
private static final Map<FunctionTemplate, UserDefinedFunction> CACHE = new HashMap<>();
private final Expression expression;
private final int args;

private static final Map<FunctionTemplate, UserDefinedFunction> CACHE = new HashMap<>();

protected UserDefinedFunction(Expression expression, int args) {
this.expression = expression;
this.args = args;
Expand All @@ -38,17 +37,17 @@ public static UserDefinedFunction newInstance(FunctionTemplate template) throws
if(function == null) {
Parser parser = new Parser();
Scope parent = new Scope();

Scope functionScope = new Scope().withParent(parent);

template.getArgs().forEach(functionScope::addInvocationVariable);

for(Entry<String, FunctionTemplate> entry : template.getFunctions().entrySet()) {
String id = entry.getKey();
FunctionTemplate nest = entry.getValue();
parser.registerFunction(id, newInstance(nest));
}

function = new UserDefinedFunction(parser.parse(template.getFunction(), functionScope), template.getArgs().size());
CACHE.put(template, function);
}
Expand Down
Loading

0 comments on commit b3a8f37

Please sign in to comment.