mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 14:21:08 +00:00
Change Java whitespace handling in .editorconfig (#425)
* Change whitespace handling in .editorconfig * Reformat code * fix format error * Reformat code --------- Co-authored-by: Zoë Gidiere <duplexsys@protonmail.com>
This commit is contained in:
@@ -18,17 +18,17 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
public class OreAddon implements AddonInitializer {
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
|
||||
@Inject
|
||||
private BaseAddon addon;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().registerConfigType(new OreConfigType(), addon.key("ORE"), 1))
|
||||
.then(event -> event.getPack().registerConfigType(new ScatteredOreConfigType(), addon.key("SCATTERED_ORE"), 1))
|
||||
.failThrough();
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack().registerConfigType(new OreConfigType(), addon.key("ORE"), 1))
|
||||
.then(event -> event.getPack().registerConfigType(new ScatteredOreConfigType(), addon.key("SCATTERED_ORE"), 1))
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -19,17 +19,17 @@ public class OreConfigType implements ConfigType<OreTemplate, Structure> {
|
||||
public static final TypeKey<Structure> ORE_TYPE_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
private final OreFactory factory = new OreFactory();
|
||||
|
||||
|
||||
@Override
|
||||
public OreTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new OreTemplate();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ConfigFactory<OreTemplate, Structure> getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TypeKey<Structure> getTypeKey() {
|
||||
return ORE_TYPE_TOKEN;
|
||||
|
||||
@@ -19,6 +19,6 @@ public class OreFactory implements ConfigFactory<OreTemplate, Structure> {
|
||||
public VanillaOre build(OreTemplate config, Platform platform) {
|
||||
BlockState m = config.getMaterial();
|
||||
return new VanillaOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.isExposed(),
|
||||
config.getMaterialOverrides());
|
||||
config.getMaterialOverrides());
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -27,53 +27,53 @@ public class OreTemplate implements AbstractableTemplate {
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
|
||||
@Value("material")
|
||||
private @Meta BlockState material;
|
||||
|
||||
|
||||
@Value("material-overrides")
|
||||
@Default
|
||||
private @Meta Map<@Meta BlockType, @Meta BlockState> materials = new HashMap<>();
|
||||
|
||||
|
||||
@Value("replace")
|
||||
private @Meta MaterialSet replaceable;
|
||||
|
||||
|
||||
@Value("physics")
|
||||
@Default
|
||||
private @Meta boolean physics = false;
|
||||
|
||||
|
||||
@Value("size")
|
||||
private @Meta double size;
|
||||
|
||||
|
||||
@Value("exposed")
|
||||
@Default
|
||||
@Description("The chance that ore blocks bordering air will be exposed. 0 = 0%, 1 = 100%")
|
||||
private @Meta double exposed = 1;
|
||||
|
||||
|
||||
public boolean doPhysics() {
|
||||
return physics;
|
||||
}
|
||||
|
||||
|
||||
public double getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
public BlockState getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
|
||||
public MaterialSet getReplaceable() {
|
||||
return replaceable;
|
||||
}
|
||||
|
||||
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public Map<BlockType, BlockState> getMaterialOverrides() {
|
||||
return materials;
|
||||
}
|
||||
|
||||
|
||||
public double isExposed() {
|
||||
return exposed;
|
||||
}
|
||||
|
||||
+3
-3
@@ -19,17 +19,17 @@ public class ScatteredOreConfigType implements ConfigType<ScatteredOreTemplate,
|
||||
public static final TypeKey<Structure> ORE_TYPE_TOKEN = new TypeKey<>() {
|
||||
};
|
||||
private final ScatteredOreFactory factory = new ScatteredOreFactory();
|
||||
|
||||
|
||||
@Override
|
||||
public ScatteredOreTemplate getTemplate(ConfigPack pack, Platform platform) {
|
||||
return new ScatteredOreTemplate();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ConfigFactory<ScatteredOreTemplate, Structure> getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TypeKey<Structure> getTypeKey() {
|
||||
return ORE_TYPE_TOKEN;
|
||||
|
||||
+1
-1
@@ -21,6 +21,6 @@ public class ScatteredOreFactory implements ConfigFactory<ScatteredOreTemplate,
|
||||
public Structure build(ScatteredOreTemplate config, Platform platform) throws LoadException {
|
||||
BlockState m = config.getMaterial();
|
||||
return new VanillaScatteredOre(m, config.getSize(), config.getReplaceable(), config.doPhysics(), config.isExposed(),
|
||||
config.getMaterialOverrides(), config.getSpread());
|
||||
config.getMaterialOverrides(), config.getSpread());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ import com.dfsek.terra.api.config.meta.Meta;
|
||||
public class ScatteredOreTemplate extends OreTemplate {
|
||||
@Value("size")
|
||||
private @Meta int spread = 7;
|
||||
|
||||
|
||||
|
||||
|
||||
public int getSpread() {
|
||||
return spread;
|
||||
}
|
||||
|
||||
+25
-25
@@ -24,15 +24,15 @@ import static com.dfsek.terra.addons.ore.utils.VanillaOreUtils.shouldPlace;
|
||||
|
||||
|
||||
public class VanillaOre implements Structure {
|
||||
|
||||
|
||||
protected final BlockState material;
|
||||
|
||||
|
||||
protected final double size;
|
||||
protected final MaterialSet replaceable;
|
||||
protected final boolean applyGravity;
|
||||
protected final double exposed;
|
||||
protected final Map<BlockType, BlockState> materials;
|
||||
|
||||
|
||||
public VanillaOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity,
|
||||
double exposed, Map<BlockType, BlockState> materials) {
|
||||
this.material = material;
|
||||
@@ -42,25 +42,25 @@ public class VanillaOre implements Structure {
|
||||
this.exposed = exposed;
|
||||
this.materials = materials;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
float randomRadian = random.nextFloat() * (float) Math.PI;
|
||||
double eighthSize = size / 8.0F;
|
||||
|
||||
|
||||
// Place points to form a line segment
|
||||
double startX = (double) location.getX() + MathUtil.sin(randomRadian) * eighthSize;
|
||||
double endX = (double) location.getX() - MathUtil.sin(randomRadian) * eighthSize;
|
||||
|
||||
|
||||
double startZ = (double) location.getZ() + MathUtil.cos(randomRadian) * eighthSize;
|
||||
double endZ = (double) location.getZ() - MathUtil.cos(randomRadian) * eighthSize;
|
||||
|
||||
|
||||
double startY = location.getY() + random.nextInt(3) - 2;
|
||||
double endY = location.getY() + random.nextInt(3) - 2;
|
||||
|
||||
|
||||
int sizeInt = (int) size;
|
||||
double[] points = new double[sizeInt * 4];
|
||||
|
||||
|
||||
// Compute initial point positions and radius
|
||||
for(int i = 0; i < sizeInt; ++i) {
|
||||
float t = (float) i / (float) sizeInt;
|
||||
@@ -75,7 +75,7 @@ public class VanillaOre implements Structure {
|
||||
points[i * 4 + 2] = zt;
|
||||
points[i * 4 + 3] = radius;
|
||||
}
|
||||
|
||||
|
||||
// Compare every point to every other point
|
||||
for(int a = 0; a < sizeInt - 1; ++a) {
|
||||
double radiusA = points[a * 4 + 3];
|
||||
@@ -87,7 +87,7 @@ public class VanillaOre implements Structure {
|
||||
double dyt = points[a * 4 + 1] - points[b * 4 + 1];
|
||||
double dzt = points[a * 4 + 2] - points[b * 4 + 2];
|
||||
double dRadius = radiusA - radiusB;
|
||||
|
||||
|
||||
// If the radius difference is greater than the distance between the two points
|
||||
if(dRadius * dRadius > dxt * dxt + dyt * dyt + dzt * dzt) {
|
||||
// Set smaller of two radii to -1
|
||||
@@ -101,18 +101,18 @@ public class VanillaOre implements Structure {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int outset = (int) Math.ceil((size / 16.0F * 2.0F + 1.0F) / 2.0F);
|
||||
int x = (int) (location.getX() - Math.ceil(eighthSize) - outset);
|
||||
int y = location.getY() - 2 - outset;
|
||||
int z = (int) (location.getZ() - Math.ceil(eighthSize) - outset);
|
||||
|
||||
|
||||
int horizontalSize = (int) (2 * (Math.ceil(eighthSize) + outset));
|
||||
int verticalSize = 2 * (2 + outset);
|
||||
|
||||
|
||||
int blockCount = 0;
|
||||
BitSet visited = new BitSet(horizontalSize * verticalSize * horizontalSize);
|
||||
|
||||
|
||||
// Generate a sphere at each point
|
||||
for(int i = 0; i < sizeInt; ++i) {
|
||||
double radius = points[i * 4 + 3];
|
||||
@@ -120,16 +120,16 @@ public class VanillaOre implements Structure {
|
||||
double xt = points[i * 4];
|
||||
double yt = points[i * 4 + 1];
|
||||
double zt = points[i * 4 + 2];
|
||||
|
||||
|
||||
int xLowerBound = (int) Math.max(Math.floor(xt - radius), x);
|
||||
int xUpperBound = (int) Math.max(Math.floor(xt + radius), xLowerBound);
|
||||
|
||||
|
||||
int yLowerBound = (int) Math.max(Math.floor(yt - radius), y);
|
||||
int yUpperBound = (int) Math.max(Math.floor(yt + radius), yLowerBound);
|
||||
|
||||
|
||||
int zLowerBound = (int) Math.max(Math.floor(zt - radius), z);
|
||||
int zUpperBound = (int) Math.max(Math.floor(zt + radius), zLowerBound);
|
||||
|
||||
|
||||
// Iterate over coordinates within bounds
|
||||
for(int xi = xLowerBound; xi <= xUpperBound; ++xi) {
|
||||
double dx = ((double) xi + 0.5 - xt) / radius;
|
||||
@@ -139,12 +139,12 @@ public class VanillaOre implements Structure {
|
||||
if(dx * dx + dy * dy < 1.0) {
|
||||
for(int zi = zLowerBound; zi <= zUpperBound; ++zi) {
|
||||
double dz = ((double) zi + 0.5 - zt) / radius;
|
||||
|
||||
|
||||
// If position is inside the sphere
|
||||
if(dx * dx + dy * dy + dz * dz < 1.0 && !(yi < world.getMinHeight() || yi >= world.getMaxHeight())) {
|
||||
int index = xi - x + (yi - y) * horizontalSize + (zi - z) * horizontalSize * verticalSize;
|
||||
if(!visited.get(index)) { // Skip blocks that have already been visited
|
||||
|
||||
|
||||
visited.set(index);
|
||||
BlockType block = world.getBlockState(xi, yi, zi).getBlockType();
|
||||
if(shouldPlace(getReplaceable(), block, exposed, random, world, xi, yi, zi)) {
|
||||
@@ -160,18 +160,18 @@ public class VanillaOre implements Structure {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return blockCount > 0;
|
||||
}
|
||||
|
||||
|
||||
public BlockState getMaterial(BlockType replace) {
|
||||
return materials.getOrDefault(replace, material);
|
||||
}
|
||||
|
||||
|
||||
public MaterialSet getReplaceable() {
|
||||
return replaceable;
|
||||
}
|
||||
|
||||
|
||||
public boolean isApplyGravity() {
|
||||
return applyGravity;
|
||||
}
|
||||
|
||||
+7
-7
@@ -15,19 +15,19 @@ import static com.dfsek.terra.addons.ore.utils.VanillaOreUtils.shouldPlace;
|
||||
|
||||
public class VanillaScatteredOre extends VanillaOre {
|
||||
protected final int spread;
|
||||
|
||||
|
||||
public VanillaScatteredOre(BlockState material, double size, MaterialSet replaceable, boolean applyGravity, double exposed,
|
||||
Map<BlockType, BlockState> materials, int spread) {
|
||||
super(material, size, replaceable, applyGravity, exposed, materials);
|
||||
|
||||
|
||||
this.spread = spread;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
int i = random.nextInt((int) (size + 1));
|
||||
Vector3Int.Mutable mutable = Vector3Int.zero().mutable();
|
||||
|
||||
|
||||
for(int j = 0; j < i; ++j) {
|
||||
this.setPos(mutable, random, location, Math.min(j, spread));
|
||||
BlockType block = world.getBlockState(mutable).getBlockType();
|
||||
@@ -35,10 +35,10 @@ public class VanillaScatteredOre extends VanillaOre {
|
||||
world.setBlockState(mutable, getMaterial(block), isApplyGravity());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void setPos(Vector3Int.Mutable mutable, Random random, Vector3Int location, int spread) {
|
||||
int x = this.getSpread(random, spread);
|
||||
int y = this.getSpread(random, spread);
|
||||
@@ -47,7 +47,7 @@ public class VanillaScatteredOre extends VanillaOre {
|
||||
mutable.setY(location.getY() + y);
|
||||
mutable.setZ(location.getZ() + z);
|
||||
}
|
||||
|
||||
|
||||
private int getSpread(Random random, int spread) {
|
||||
return Math.round((random.nextFloat() - random.nextFloat()) * (float) spread);
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ public class VanillaOreUtils {
|
||||
return random.nextFloat() >= chance;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean shouldPlace(MaterialSet replaceable, BlockType type, Double exposed, Random random, WritableWorld world, int x,
|
||||
int y, int z) {
|
||||
if(!replaceable.contains(type)) {
|
||||
@@ -33,6 +33,6 @@ public class VanillaOreUtils {
|
||||
world.getBlockState(x + 1, y, z).isAir());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user