9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-25 18:19:14 +00:00

Blockdata backups

This commit is contained in:
Daniel Mills
2020-09-10 00:17:13 -04:00
parent eb0de84ce3
commit b0ee9b27a1

View File

@@ -41,6 +41,10 @@ public class IrisBlockData
@Desc("The weight is used when this block data is inside of a list of blockdata. A weight of two is just as if you placed two of the same block data values in the same list making it more common when randomly picked.")
private int weight = 1;
@DontObfuscate
@Desc("If the block cannot be created on this version, Iris will attempt to use this backup block data instead.")
private IrisBlockData backup = null;
@DontObfuscate
@Desc("Optional properties for this block data such as 'waterlogged': true")
private KMap<String, Object> data = new KMap<>();
@@ -81,6 +85,11 @@ public class IrisBlockData
return b;
}
if(backup != null)
{
return backup.getBlockData();
}
return B.get("AIR");
});
}
@@ -89,46 +98,46 @@ public class IrisBlockData
{
IrisBlockData b = new IrisBlockData();
String m = j.toLowerCase().trim();
if(m.contains(":"))
{
b.setKey(m.split("\\Q:\\E")[0]);
String v = m.split("\\Q:\\E")[1];
if(v.contains("["))
{
KList<String> props = new KList<>();
String rp = v.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", "");
b.setBlock(v.split("\\Q[\\E")[0]);
if(rp.contains(","))
{
props.add(rp.split("\\Q,\\E"));
}
else
{
props.add(rp);
}
for(String i : props)
{
Object kg = filter(i.split("\\Q=\\E")[1]);
b.data.put(i.split("\\Q=\\E")[0], kg);
}
}
else
{
b.setBlock(v);
}
}
else
{
b.setBlock(m);
}
return b;
}