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:
Astrashh
2023-11-13 11:57:01 +11:00
committed by GitHub
parent a73fda7d04
commit defd775f13
793 changed files with 7579 additions and 7577 deletions

View File

@@ -18,41 +18,41 @@ import com.dfsek.terra.cli.handle.CLIWorldHandle;
public class CLIPlatform extends AbstractPlatform {
private static final Logger LOGGER = LoggerFactory.getLogger(CLIPlatform.class);
private final CLIWorldHandle worldHandle = new CLIWorldHandle();
private final CLIItemHandle itemHandle = new CLIItemHandle();
public CLIPlatform() {
LOGGER.info("Root directory: {}", getDataFolder().getAbsoluteFile());
load();
LOGGER.info("Initialized Terra platform.");
}
@Override
public boolean reload() {
return false;
}
@Override
public @NotNull String platformName() {
return "CLI";
}
@Override
public @NotNull WorldHandle getWorldHandle() {
return worldHandle;
}
@Override
public @NotNull File getDataFolder() {
return new File("./");
}
@Override
public @NotNull ItemHandle getItemHandle() {
return itemHandle;
}
@Override
public void register(TypeRegistry registry) {
super.register(registry);

View File

@@ -14,24 +14,24 @@ import com.dfsek.terra.cli.world.CLIWorld;
public final class TerraCLI {
private static final Logger LOGGER = LoggerFactory.getLogger(TerraCLI.class);
public static void main(String... args) {
LOGGER.info("Starting Terra CLI...");
CLIPlatform platform = new CLIPlatform();
platform.getEventManager().callEvent(new PlatformInitializationEvent());
ConfigPack generate = platform.getConfigRegistry().getByID("OVERWORLD").orElseThrow(); // TODO: make this a cli argument
CLIWorld world = new CLIWorld(2, 2, 384, -64, generate);
world.generate();
world.serialize().parallel().forEach(mcaFile -> {
Vector2Int pos = mcaFile.getLeft();
String name = MCAUtil.createNameFromRegionLocation(pos.getX(), pos.getZ());
LOGGER.info("Writing region ({}, {}) to {}", pos.getX(), pos.getZ(), name);
try {
MCAUtil.write(mcaFile.getRight(), name);
} catch(IOException e) {

View File

@@ -12,13 +12,13 @@ public class CLIBlockState implements BlockState {
private final CLIBlockType type;
private final boolean isAir;
private final CompoundTag nbt;
public CLIBlockState(String value) {
this.value = value;
if(value.contains("[")) {
} else {
}
this.isAir = value.startsWith("minecraft:air");
this.nbt = new CompoundTag();
@@ -30,54 +30,54 @@ public class CLIBlockState implements BlockState {
for(String property : props) {
String name = property.substring(0, property.indexOf('='));
String val = property.substring(property.indexOf('=') + 1);
pTag.putString(name, val);
}
this.nbt.put("Properties", pTag);
} else this.type = new CLIBlockType(value);
this.nbt.putString("Name", type.getHandle());
}
@Override
public Object getHandle() {
return value;
}
@Override
public boolean matches(BlockState other) {
return false;
}
@Override
public <T extends Comparable<T>> boolean has(Property<T> property) {
return false;
}
@Override
public <T extends Comparable<T>> T get(Property<T> property) {
return null;
}
@Override
public <T extends Comparable<T>> BlockState set(Property<T> property, T value) {
return null;
}
@Override
public BlockType getBlockType() {
return type;
}
@Override
public String getAsString(boolean properties) {
return value;
}
@Override
public boolean isAir() {
return isAir;
}
public CompoundTag getNbt() {
return nbt;
}

View File

@@ -10,7 +10,7 @@ public class CLIBlockType implements BlockType {
private final boolean solid;
private final boolean water;
private final Lazy<CLIBlockState> defaultState;
public CLIBlockType(String value) {
if(value.contains("[")) throw new IllegalArgumentException("Block Type must not contain properties");
this.value = value;
@@ -18,22 +18,22 @@ public class CLIBlockType implements BlockType {
this.water = value.equals("minecraft:water");
this.defaultState = Lazy.lazy(() -> new CLIBlockState(value));
}
@Override
public String getHandle() {
return value;
}
@Override
public BlockState getDefaultState() {
return defaultState.value();
}
@Override
public boolean isSolid() {
return solid;
}
@Override
public boolean isWater() {
return water;

View File

@@ -1,23 +1,23 @@
package com.dfsek.terra.cli.handle;
import java.util.Set;
import com.dfsek.terra.api.handle.ItemHandle;
import com.dfsek.terra.api.inventory.Item;
import com.dfsek.terra.api.inventory.item.Enchantment;
import java.util.Set;
public class CLIItemHandle implements ItemHandle {
@Override
public Item createItem(String data) {
return null;
}
@Override
public Enchantment getEnchantment(String id) {
return null;
}
@Override
public Set<Enchantment> getEnchantments() {
return null;

View File

@@ -10,21 +10,21 @@ import com.dfsek.terra.cli.block.CLIBlockState;
public class CLIWorldHandle implements WorldHandle {
private static final CLIBlockState AIR = new CLIBlockState("minecraft:air");
public static CLIBlockState getAIR() {
return AIR;
}
@Override
public @NotNull BlockState createBlockState(@NotNull String data) {
return new CLIBlockState(data);
}
@Override
public @NotNull BlockState air() {
return AIR;
}
@Override
public @NotNull EntityType getEntity(@NotNull String id) {
return null;

View File

@@ -44,9 +44,9 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
private final BiomeProvider biomeProvider;
private final ConfigPack pack;
private final AtomicInteger amount = new AtomicInteger(0);
private final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() - 1);
public CLIWorld(int size,
long seed,
int maxHeight,
@@ -59,8 +59,8 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
this.chunkGenerator = pack.getGeneratorProvider().newInstance(pack);
this.biomeProvider = pack.getBiomeProvider();
this.pack = pack;
size += 1;
this.regions = new Region[size * size];
this.negativeRegions = new Region[size * size];
@@ -71,7 +71,7 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
}
}
}
public void generate() {
int sizeChunks = size * 32;
List<Future<?>> futures = new ArrayList<>();
@@ -101,7 +101,7 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
}));
}
}
for(Future<?> future : futures) {
try {
future.get();
@@ -110,18 +110,18 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
}
}
}
@Override
public Object getHandle() {
return this;
}
@Override
public BlockState getBlockState(int x, int y, int z) {
return getChunkAt(Math.floorDiv(x, 16), Math.floorDiv(z, 16))
.getBlock(Math.floorMod(x, 16), y, Math.floorMod(z, 16));
.getBlock(Math.floorMod(x, 16), y, Math.floorMod(z, 16));
}
@Override
public BlockEntity getBlockEntity(int x, int y, int z) {
return new BlockEntity() {
@@ -129,176 +129,176 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
public boolean update(boolean applyPhysics) {
return false;
}
@Override
public Vector3 getPosition() {
return Vector3.of(x, y, z);
}
@Override
public int getX() {
return x;
}
@Override
public int getY() {
return y;
}
@Override
public int getZ() {
return z;
}
@Override
public BlockState getBlockState() {
return CLIWorld.this.getBlockState(x, y, z);
}
@Override
public Object getHandle() {
return this;
}
};
}
@Override
public CLIChunk getChunkAt(int x, int z) {
return getRegion(Math.floorDiv(x, 32), Math.floorDiv(z, 32))
.get(Math.floorMod(x, 32), Math.floorMod(z, 32));
.get(Math.floorMod(x, 32), Math.floorMod(z, 32));
}
public Region getRegion(int x, int z) {
int key = x + z * size;
if(key >= 0) return regions[key];
else return negativeRegions[-key];
}
@Override
public long getSeed() {
return seed;
}
@Override
public int getMaxHeight() {
return maxHeight;
}
@Override
public int getMinHeight() {
return minHeight;
}
@Override
public ChunkGenerator getGenerator() {
return chunkGenerator;
}
@Override
public BiomeProvider getBiomeProvider() {
return biomeProvider;
}
@Override
public ConfigPack getPack() {
return pack;
}
@Override
public void setBlockState(int x, int y, int z, BlockState data, boolean physics) {
getChunkAt(Math.floorDiv(x, 16), Math.floorDiv(z, 16))
.setBlock(Math.floorMod(x, 16), y, Math.floorMod(z, 16), data, physics);
.setBlock(Math.floorMod(x, 16), y, Math.floorMod(z, 16), data, physics);
}
@Override
public Entity spawnEntity(double x, double y, double z, EntityType entityType) {
return null;
}
@Override
public Stream<Pair<Vector2Int, MCAFile>> serialize() {
return Streams
.concat(Arrays.stream(regions), Arrays.stream(negativeRegions))
.map(region -> Pair.of(Vector2Int.of(region.getX(), region.getZ()), region.serialize()));
.concat(Arrays.stream(regions), Arrays.stream(negativeRegions))
.map(region -> Pair.of(Vector2Int.of(region.getX(), region.getZ()), region.serialize()));
}
private static final class CLIProtoWorld implements ProtoWorld {
private final CLIWorld delegate;
private final BiomeProvider biomeProvider;
private final int x, z;
private CLIProtoWorld(CLIWorld delegate, BiomeProvider biomeProvider, int x, int z) {
this.delegate = delegate;
this.biomeProvider = biomeProvider;
this.x = x;
this.z = z;
}
@Override
public Object getHandle() {
return this;
}
@Override
public BlockState getBlockState(int x, int y, int z) {
return delegate.getBlockState(x, y, z);
}
@Override
public BlockEntity getBlockEntity(int x, int y, int z) {
return delegate.getBlockEntity(x, y, z);
}
@Override
public long getSeed() {
return delegate.seed;
}
@Override
public int getMaxHeight() {
return delegate.maxHeight;
}
@Override
public int getMinHeight() {
return delegate.minHeight;
}
@Override
public ChunkGenerator getGenerator() {
return delegate.chunkGenerator;
}
@Override
public BiomeProvider getBiomeProvider() {
return biomeProvider;
}
@Override
public ConfigPack getPack() {
return delegate.pack;
}
@Override
public void setBlockState(int x, int y, int z, BlockState data, boolean physics) {
delegate.setBlockState(x, y, z, data, physics);
}
@Override
public Entity spawnEntity(double x, double y, double z, EntityType entityType) {
return delegate.spawnEntity(x, y, z, entityType);
}
@Override
public int centerChunkX() {
return x;
}
@Override
public int centerChunkZ() {
return z;
}
@Override
public ServerWorld getWorld() {
return delegate;

View File

@@ -10,14 +10,14 @@ public class Region implements NBTSerializable<MCAFile> {
private final CLIChunk[] chunks;
private final int x, z;
private final CLIWorld world;
public Region(CLIWorld world, int x, int z) {
this.x = x;
this.z = z;
this.world = world;
this.chunks = new CLIChunk[32 * 32];
}
public CLIChunk get(int x, int z) {
int key = x + z * 32;
CLIChunk chunk = chunks[key];
@@ -27,7 +27,7 @@ public class Region implements NBTSerializable<MCAFile> {
}
return chunk;
}
@Override
public MCAFile serialize() {
MCAFile mcaFile = new MCAFile(x, z);
@@ -46,11 +46,11 @@ public class Region implements NBTSerializable<MCAFile> {
}
return mcaFile;
}
public int getX() {
return x;
}
public int getZ() {
return z;
}

View File

@@ -20,7 +20,7 @@ public class CLIChunk implements Chunk, ProtoChunk, NBTSerializable<net.querz.mc
private final int minHeight;
private final int maxHeight;
private final CLIWorld world;
public CLIChunk(int x, int z, CLIWorld world) {
this.x = x;
this.z = z;
@@ -29,39 +29,39 @@ public class CLIChunk implements Chunk, ProtoChunk, NBTSerializable<net.querz.mc
this.world = world;
this.blocks = new CLIBlockState[16][16][maxHeight - minHeight];
}
@Override
public Object getHandle() {
return null;
}
@Override
public void setBlock(int x, int y, int z, BlockState data, boolean physics) {
blocks[x][z][y - minHeight] = (CLIBlockState) data;
}
@Override
public @NotNull CLIBlockState getBlock(int x, int y, int z) {
CLIBlockState blockState = blocks[x][z][y - minHeight];
if(blockState == null) return getAIR();
return blockState;
}
@Override
public int getX() {
return x;
}
@Override
public int getZ() {
return z;
}
@Override
public ServerWorld getWorld() {
return world;
}
@Override
public net.querz.mca.Chunk serialize() {
net.querz.mca.Chunk chunk = net.querz.mca.Chunk.newChunk(2230);
@@ -80,7 +80,7 @@ public class CLIChunk implements Chunk, ProtoChunk, NBTSerializable<net.querz.mc
chunk.setStatus("features");
return chunk;
}
@Override
public int getMaxHeight() {
return maxHeight;