mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Beautify updates keys
This commit is contained in:
parent
e9f4c3d0c7
commit
a2a7689881
@ -23,11 +23,13 @@ import com.volmit.iris.core.IrisSettings;
|
|||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.format.Form;
|
import com.volmit.iris.util.format.Form;
|
||||||
import com.volmit.iris.util.io.IO;
|
import com.volmit.iris.util.io.IO;
|
||||||
|
import com.volmit.iris.util.json.JSONArray;
|
||||||
import com.volmit.iris.util.json.JSONObject;
|
import com.volmit.iris.util.json.JSONObject;
|
||||||
import com.volmit.iris.util.plugin.MortarCommand;
|
import com.volmit.iris.util.plugin.MortarCommand;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CommandIrisStudioBeautify extends MortarCommand {
|
public class CommandIrisStudioBeautify extends MortarCommand {
|
||||||
public CommandIrisStudioBeautify() {
|
public CommandIrisStudioBeautify() {
|
||||||
@ -80,7 +82,7 @@ public class CommandIrisStudioBeautify extends MortarCommand {
|
|||||||
}
|
}
|
||||||
} else if (clean.getName().endsWith(".json")) {
|
} else if (clean.getName().endsWith(".json")) {
|
||||||
try {
|
try {
|
||||||
IO.writeAll(clean, new JSONObject(IO.readAll(clean)).toString(4));
|
clean(clean);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
Iris.error("Failed to beautify " + clean.getAbsolutePath() + " You may have errors in your json!");
|
Iris.error("Failed to beautify " + clean.getAbsolutePath() + " You may have errors in your json!");
|
||||||
@ -92,6 +94,54 @@ public class CommandIrisStudioBeautify extends MortarCommand {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clean(File clean) throws IOException {
|
||||||
|
JSONObject obj = new JSONObject(IO.readAll(clean));
|
||||||
|
fixBlocks(obj, clean);
|
||||||
|
|
||||||
|
IO.writeAll(clean, obj.toString(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixBlocks(JSONObject obj, File f) {
|
||||||
|
for(String i : obj.keySet())
|
||||||
|
{
|
||||||
|
Object o = obj.get(i);
|
||||||
|
|
||||||
|
if(i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":"))
|
||||||
|
{
|
||||||
|
obj.put(i, "minecraft:" + o);
|
||||||
|
Iris.debug("Updated Block Key: " + o + " to " + obj.getString(i) + " in " + f.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(o instanceof JSONObject)
|
||||||
|
{
|
||||||
|
fixBlocks((JSONObject) o, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(o instanceof JSONArray)
|
||||||
|
{
|
||||||
|
fixBlocks((JSONArray) o, f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixBlocks(JSONArray obj, File f) {
|
||||||
|
for(int i = 0; i < obj.length(); i++)
|
||||||
|
{
|
||||||
|
Object o = obj.get(i);
|
||||||
|
|
||||||
|
if(o instanceof JSONObject)
|
||||||
|
{
|
||||||
|
fixBlocks((JSONObject) o, f);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(o instanceof JSONArray)
|
||||||
|
{
|
||||||
|
fixBlocks((JSONArray) o, f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getArgsUsage() {
|
protected String getArgsUsage() {
|
||||||
return "[project]";
|
return "[project]";
|
||||||
|
@ -38,6 +38,8 @@ import com.volmit.iris.util.math.RNG;
|
|||||||
import com.volmit.iris.util.scheduling.IrisLock;
|
import com.volmit.iris.util.scheduling.IrisLock;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -56,26 +58,38 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
@SuppressWarnings("DefaultAnnotationParam")
|
@SuppressWarnings("DefaultAnnotationParam")
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class IrisObject extends IrisRegistrant {
|
public class IrisObject extends IrisRegistrant {
|
||||||
private static final Vector HALF = new Vector(0.5, 0.5, 0.5);
|
protected static final Vector HALF = new Vector(0.5, 0.5, 0.5);
|
||||||
private static final BlockData AIR = B.get("CAVE_AIR");
|
protected static final BlockData AIR = B.get("CAVE_AIR");
|
||||||
private static final BlockData VAIR = B.get("VOID_AIR");
|
protected static final BlockData VAIR = B.get("VOID_AIR");
|
||||||
private static final BlockData VAIR_DEBUG = B.get("COBWEB");
|
protected static final BlockData VAIR_DEBUG = B.get("COBWEB");
|
||||||
private static final BlockData[] SNOW_LAYERS = new BlockData[]{B.get("minecraft:snow[layers=1]"), B.get("minecraft:snow[layers=2]"), B.get("minecraft:snow[layers=3]"), B.get("minecraft:snow[layers=4]"), B.get("minecraft:snow[layers=5]"), B.get("minecraft:snow[layers=6]"), B.get("minecraft:snow[layers=7]"), B.get("minecraft:snow[layers=8]")};
|
protected static final BlockData[] SNOW_LAYERS = new BlockData[]{B.get("minecraft:snow[layers=1]"), B.get("minecraft:snow[layers=2]"), B.get("minecraft:snow[layers=3]"), B.get("minecraft:snow[layers=4]"), B.get("minecraft:snow[layers=5]"), B.get("minecraft:snow[layers=6]"), B.get("minecraft:snow[layers=7]"), B.get("minecraft:snow[layers=8]")};
|
||||||
public static boolean shitty = false;
|
|
||||||
private KMap<BlockVector, BlockData> blocks;
|
private KMap<BlockVector, BlockData> blocks;
|
||||||
private KMap<BlockVector, TileData<? extends TileState>> states;
|
private KMap<BlockVector, TileData<? extends TileState>> states;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
private int w;
|
private int w;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
private int d;
|
private int d;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
private int h;
|
private int h;
|
||||||
private transient final IrisLock readLock = new IrisLock("read-conclock");
|
protected transient final IrisLock readLock = new IrisLock("read-conclock");
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
private transient BlockVector center;
|
private transient BlockVector center;
|
||||||
private transient volatile boolean smartBored = false;
|
@Getter
|
||||||
private transient IrisLock lock = new IrisLock("Preloadcache");
|
@Setter
|
||||||
private transient AtomicCache<AxisAlignedBB> aabb = new AtomicCache<>();
|
protected transient volatile boolean smartBored = false;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
protected transient IrisLock lock = new IrisLock("Preloadcache");
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
protected transient AtomicCache<AxisAlignedBB> aabb = new AtomicCache<>();
|
||||||
|
|
||||||
public IrisObject(int w, int h, int d) {
|
public IrisObject(int w, int h, int d) {
|
||||||
blocks = new KMap<>();
|
blocks = new KMap<>();
|
||||||
@ -330,10 +344,6 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void read(File file) throws IOException {
|
public void read(File file) throws IOException {
|
||||||
if (shitty) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileInputStream fin = new FileInputStream(file);
|
FileInputStream fin = new FileInputStream(file);
|
||||||
try {
|
try {
|
||||||
read(fin);
|
read(fin);
|
||||||
@ -861,7 +871,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setBlocks(b);
|
blocks = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tricubic(int rad) {
|
public void tricubic(int rad) {
|
||||||
@ -890,7 +900,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setBlocks(b);
|
blocks = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void trihermite(int rad) {
|
public void trihermite(int rad) {
|
||||||
@ -923,7 +933,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setBlocks(b);
|
blocks = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockData nearestBlockData(int x, int y, int z) {
|
private BlockData nearestBlockData(int x, int y, int z) {
|
||||||
|
@ -1401,4 +1401,9 @@ public interface Hunk<T> {
|
|||||||
c[0] = x;
|
c[0] = x;
|
||||||
c[1] = y;
|
c[1] = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean isEmpty()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,11 @@ public class MappedHunk<T> extends StorageHunk<T> implements Hunk<T> {
|
|||||||
return data.size();
|
return data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty()
|
||||||
|
{
|
||||||
|
return data.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRaw(int x, int y, int z, T t) {
|
public void setRaw(int x, int y, int z, T t) {
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
|
@ -332,4 +332,16 @@ public interface Matter {
|
|||||||
|
|
||||||
return matter;
|
return matter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default int getTotalCount()
|
||||||
|
{
|
||||||
|
int m = 0;
|
||||||
|
|
||||||
|
for(MatterSlice<?> i : getSliceMap().values())
|
||||||
|
{
|
||||||
|
m+= i.getCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.util.BlockVector;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@ -145,4 +146,19 @@ public interface MatterSlice<T> extends Hunk<T> {
|
|||||||
default void rotateSliceInto(Matter n, double x, double y, double z) {
|
default void rotateSliceInto(Matter n, double x, double y, double z) {
|
||||||
rotate(x, y, z, (_x, _y, _z) -> n.slice(getType()));
|
rotate(x, y, z, (_x, _y, _z) -> n.slice(getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean containsKey(BlockVector v)
|
||||||
|
{
|
||||||
|
return get(v.getBlockX(), v.getBlockY(), v.getBlockZ()) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
default void put(BlockVector v, T d)
|
||||||
|
{
|
||||||
|
set(v.getBlockX(), v.getBlockY(), v.getBlockZ(), d);
|
||||||
|
}
|
||||||
|
|
||||||
|
default T get(BlockVector v)
|
||||||
|
{
|
||||||
|
return get(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user