mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-21 07:40:27 +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:
@@ -36,10 +36,10 @@ import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
public class SpongeSchematicAddon implements AddonInitializer {
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
|
||||
@Inject
|
||||
private BaseAddon addon;
|
||||
|
||||
|
||||
private static InputStream detectDecompression(InputStream is) throws IOException {
|
||||
PushbackInputStream pbis = new PushbackInputStream(is, 2);
|
||||
int signature = (pbis.read() & 0xFF) + (pbis.read() << 8);
|
||||
@@ -50,25 +50,25 @@ public class SpongeSchematicAddon implements AddonInitializer {
|
||||
}
|
||||
return pbis;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Structure> structureRegistry = event.getPack().getOrCreateRegistry(Structure.class);
|
||||
event.getPack()
|
||||
.getLoader()
|
||||
.open("", ".schem")
|
||||
.thenEntries(entries -> entries
|
||||
.stream()
|
||||
.map(entry -> convert(entry.getValue(), StringUtil.fileName(entry.getKey())))
|
||||
.forEach(structureRegistry::register)).close();
|
||||
})
|
||||
.failThrough();
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Structure> structureRegistry = event.getPack().getOrCreateRegistry(Structure.class);
|
||||
event.getPack()
|
||||
.getLoader()
|
||||
.open("", ".schem")
|
||||
.thenEntries(entries -> entries
|
||||
.stream()
|
||||
.map(entry -> convert(entry.getValue(), StringUtil.fileName(entry.getKey())))
|
||||
.forEach(structureRegistry::register)).close();
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
|
||||
|
||||
public SpongeStructure convert(InputStream in, String id) {
|
||||
try {
|
||||
CompoundTag baseTag = (CompoundTag) new NBTDeserializer(false).fromStream(detectDecompression(in)).getTag();
|
||||
@@ -76,9 +76,9 @@ public class SpongeSchematicAddon implements AddonInitializer {
|
||||
int wid = baseTag.getShort("Width");
|
||||
int len = baseTag.getShort("Length");
|
||||
int hei = baseTag.getShort("Height");
|
||||
|
||||
|
||||
CompoundTag metadata = baseTag.getCompoundTag("Metadata");
|
||||
|
||||
|
||||
Vector3Int offset = switch(ver) {
|
||||
case 2 -> {
|
||||
// Use WorldEdit defined legacy relative offset if it exists in schematic metadata
|
||||
@@ -102,18 +102,18 @@ public class SpongeSchematicAddon implements AddonInitializer {
|
||||
}
|
||||
default -> throw new IllegalArgumentException("Failed to parse Sponge schematic: Unsupported format version: " + ver);
|
||||
};
|
||||
|
||||
|
||||
ByteArrayTag blocks = baseTag.getByteArrayTag("BlockData");
|
||||
|
||||
|
||||
CompoundTag palette = (CompoundTag) baseTag.get("Palette");
|
||||
Map<Integer, String> data = new HashMap<>();
|
||||
|
||||
|
||||
for(Map.Entry<String, Tag<?>> entry : palette.entrySet()) {
|
||||
data.put(((IntTag) entry.getValue()).asInt(), entry.getKey());
|
||||
}
|
||||
|
||||
|
||||
BlockState[][][] states = new BlockState[wid][len][hei];
|
||||
|
||||
|
||||
byte[] arr = blocks.getValue();
|
||||
for(int x = 0; x < wid; x++) {
|
||||
for(int z = 0; z < len; z++) {
|
||||
@@ -124,7 +124,7 @@ public class SpongeSchematicAddon implements AddonInitializer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new SpongeStructure(states, offset, addon.key(id));
|
||||
} catch(IOException e) {
|
||||
throw new IllegalArgumentException("Failed to parse Sponge schematic: ", e);
|
||||
|
||||
@@ -20,13 +20,13 @@ import com.dfsek.terra.api.world.WritableWorld;
|
||||
|
||||
|
||||
public class SpongeStructure implements Structure, Keyed<SpongeStructure> {
|
||||
|
||||
|
||||
private final BlockState[][][] blocks;
|
||||
|
||||
|
||||
private final int offsetX, offsetY, offsetZ;
|
||||
|
||||
|
||||
private final RegistryKey id;
|
||||
|
||||
|
||||
public SpongeStructure(BlockState[][][] blocks, Vector3Int offset, RegistryKey id) {
|
||||
this.blocks = blocks;
|
||||
this.offsetX = offset.getX();
|
||||
@@ -34,7 +34,7 @@ public class SpongeStructure implements Structure, Keyed<SpongeStructure> {
|
||||
this.offsetZ = offset.getZ();
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean generate(Vector3Int location, WritableWorld world, Random random, Rotation rotation) {
|
||||
int bX = location.getX();
|
||||
@@ -56,7 +56,7 @@ public class SpongeStructure implements Structure, Keyed<SpongeStructure> {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RegistryKey getRegistryKey() {
|
||||
return id;
|
||||
|
||||
Reference in New Issue
Block a user