-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22de70b
commit 97f7ec8
Showing
20 changed files
with
480 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package skylands.config; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonWriter; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Vec3i; | ||
|
||
import java.io.IOException; | ||
|
||
public class BlockPosition { | ||
public int x; | ||
public int y; | ||
public int z; | ||
|
||
public BlockPosition(int x, int y, int z) { | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
} | ||
|
||
public Vec3i toVec() { | ||
return new Vec3i(this.x, this.y, this.z); | ||
} | ||
|
||
public BlockPos toBlockPos() { | ||
return new BlockPos(x, y, z); | ||
} | ||
|
||
public static class JsonAdapter extends TypeAdapter<BlockPosition> { | ||
|
||
public static final Gson GSON = new GsonBuilder().setLenient().create(); | ||
|
||
@Override | ||
public void write(JsonWriter out, BlockPosition value) throws IOException { | ||
out.jsonValue(GSON.toJson(value).replaceAll(",", ", ") | ||
.replaceAll("\\{", "{ ") | ||
.replaceAll("}", " }").replaceAll(":", ": ")); | ||
} | ||
|
||
@Override | ||
public BlockPosition read(JsonReader in) { | ||
return GSON.fromJson(in, BlockPosition.class); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package skylands.config; | ||
|
||
public class HubTemplate extends Template { | ||
|
||
public HubTemplate(String type, Metadata metadata) { | ||
super(null, type, metadata, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package skylands.config; | ||
|
||
public class IslandTemplate extends Template { | ||
public String netherTemplate; | ||
|
||
public IslandTemplate(String name, String type, Metadata metadata, PlayerPosition playerSpawnPosition, String netherTemplate) { | ||
super(name, type, metadata, playerSpawnPosition); | ||
this.netherTemplate = netherTemplate; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package skylands.config; | ||
|
||
import com.google.gson.annotations.JsonAdapter; | ||
import net.minecraft.util.BlockRotation; | ||
import net.minecraft.util.math.BlockPos; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class Metadata { | ||
|
||
public String structure; | ||
@JsonAdapter(BlockPosition.JsonAdapter.class) | ||
public BlockPosition position; | ||
@Nullable | ||
public BlockPosition pivot; | ||
@Nullable | ||
public String rotation; | ||
|
||
public String path; | ||
|
||
public Metadata(String structureId, BlockPosition position) { | ||
this.structure = structureId; | ||
this.position = position; | ||
} | ||
|
||
public Metadata(String path) { | ||
this.path = path; | ||
} | ||
|
||
public BlockRotation getRotation() { | ||
BlockRotation rot = BlockRotation.NONE; | ||
|
||
if(rotation != null) { | ||
switch (rotation.toLowerCase()) { | ||
case "clockwise_90" -> rot = BlockRotation.CLOCKWISE_90; | ||
case "180" -> rot = BlockRotation.CLOCKWISE_180; | ||
case "counterclockwise_90" -> rot = BlockRotation.COUNTERCLOCKWISE_90; | ||
} | ||
} | ||
|
||
return rot; | ||
} | ||
|
||
public BlockPos getPivot() { | ||
if(pivot != null) { | ||
return pivot.toBlockPos(); | ||
} | ||
return new BlockPos(0, 0, 0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.