mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 13:30:10 +00:00
format
This commit is contained in:
1 parent
712ec7b74c
commit
7c30ab095e
2 files changed
+30
-35
No files matched your search
+23
-28
@@ -1,21 +1,5 @@
|
|||||||
package com.dfsek.terra.addons.sponge;
|
package com.dfsek.terra.addons.sponge;
|
||||||
|
|
||||||
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
|
||||||
import com.dfsek.terra.api.addon.TerraAddon;
|
|
||||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
|
||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
|
||||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
|
||||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
|
||||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.util.StringUtil;
|
|
||||||
|
|
||||||
import net.querz.nbt.io.NBTDeserializer;
|
import net.querz.nbt.io.NBTDeserializer;
|
||||||
import net.querz.nbt.tag.ByteArrayTag;
|
import net.querz.nbt.tag.ByteArrayTag;
|
||||||
import net.querz.nbt.tag.CompoundTag;
|
import net.querz.nbt.tag.CompoundTag;
|
||||||
@@ -29,6 +13,18 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.manifest.api.AddonInitializer;
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
|
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||||
|
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||||
|
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||||
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
|
import com.dfsek.terra.api.util.StringUtil;
|
||||||
|
|
||||||
|
|
||||||
public class SpongeSchematicAddon implements AddonInitializer {
|
public class SpongeSchematicAddon implements AddonInitializer {
|
||||||
@Inject
|
@Inject
|
||||||
private Platform platform;
|
private Platform platform;
|
||||||
@@ -36,6 +32,17 @@ public class SpongeSchematicAddon implements AddonInitializer {
|
|||||||
@Inject
|
@Inject
|
||||||
private BaseAddon addon;
|
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);
|
||||||
|
pbis.unread(signature >> 8);
|
||||||
|
pbis.unread(signature & 0xFF);
|
||||||
|
if(signature == GZIPInputStream.GZIP_MAGIC) {
|
||||||
|
return new GZIPInputStream(pbis);
|
||||||
|
}
|
||||||
|
return pbis;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
platform.getEventManager()
|
platform.getEventManager()
|
||||||
@@ -53,7 +60,6 @@ public class SpongeSchematicAddon implements AddonInitializer {
|
|||||||
.failThrough();
|
.failThrough();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SpongeStructure convert(InputStream in, String id) {
|
public SpongeStructure convert(InputStream in, String id) {
|
||||||
try {
|
try {
|
||||||
CompoundTag baseTag = (CompoundTag) new NBTDeserializer(false).fromStream(detectDecompression(in)).getTag();
|
CompoundTag baseTag = (CompoundTag) new NBTDeserializer(false).fromStream(detectDecompression(in)).getTag();
|
||||||
@@ -88,15 +94,4 @@ public class SpongeSchematicAddon implements AddonInitializer {
|
|||||||
throw new IllegalArgumentException("Failed to parse Sponge schematic: ", e);
|
throw new IllegalArgumentException("Failed to parse Sponge schematic: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InputStream detectDecompression(InputStream is) throws IOException {
|
|
||||||
PushbackInputStream pbis = new PushbackInputStream(is, 2);
|
|
||||||
int signature = (pbis.read() & 0xFF) + (pbis.read() << 8);
|
|
||||||
pbis.unread(signature >> 8);
|
|
||||||
pbis.unread(signature & 0xFF);
|
|
||||||
if(signature == GZIPInputStream.GZIP_MAGIC) {
|
|
||||||
return new GZIPInputStream(pbis);
|
|
||||||
}
|
|
||||||
return pbis;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+7
-7
@@ -1,5 +1,9 @@
|
|||||||
package com.dfsek.terra.addons.sponge;
|
package com.dfsek.terra.addons.sponge;
|
||||||
|
|
||||||
|
import net.jafama.FastMath;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.structure.Structure;
|
import com.dfsek.terra.api.structure.Structure;
|
||||||
@@ -12,10 +16,6 @@ import com.dfsek.terra.api.util.vector.Vector3;
|
|||||||
import com.dfsek.terra.api.world.Chunk;
|
import com.dfsek.terra.api.world.Chunk;
|
||||||
import com.dfsek.terra.api.world.World;
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
|
|
||||||
public class SpongeStructure implements Structure {
|
public class SpongeStructure implements Structure {
|
||||||
|
|
||||||
@@ -40,13 +40,13 @@ public class SpongeStructure implements Structure {
|
|||||||
Vector2 r = RotationUtil.rotateVector(new Vector2(x, z), rotation);
|
Vector2 r = RotationUtil.rotateVector(new Vector2(x, z), rotation);
|
||||||
int rX = r.getBlockX();
|
int rX = r.getBlockX();
|
||||||
int rZ = r.getBlockZ();
|
int rZ = r.getBlockZ();
|
||||||
if(FastMath.floorDiv(bX+rX, 16) != chunk.getX() || FastMath.floorDiv(bZ+rZ, 16) != chunk.getZ()) {
|
if(FastMath.floorDiv(bX + rX, 16) != chunk.getX() || FastMath.floorDiv(bZ + rZ, 16) != chunk.getZ()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for(int y = 0; y < blocks[z].length; y++) {
|
for(int y = 0; y < blocks[z].length; y++) {
|
||||||
BlockState state = blocks[x][z][y];
|
BlockState state = blocks[x][z][y];
|
||||||
if(state == null) continue;
|
if(state == null) continue;
|
||||||
world.setBlockData(bX+rX, bY+y, bZ+rZ, state);
|
world.setBlockData(bX + rX, bY + y, bZ + rZ, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ public class SpongeStructure implements Structure {
|
|||||||
for(int y = 0; y < blocks[z].length; y++) {
|
for(int y = 0; y < blocks[z].length; y++) {
|
||||||
BlockState state = blocks[x][z][y];
|
BlockState state = blocks[x][z][y];
|
||||||
if(state == null) continue;
|
if(state == null) continue;
|
||||||
world.setBlockData(bX+rX, bY+y, bZ+rZ, state);
|
world.setBlockData(bX + rX, bY + y, bZ + rZ, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user