Blockdata backups

This commit is contained in:
Daniel Mills
2020-09-10 00:17:13 -04:00
parent eb0de84ce3
commit b0ee9b27a1
@@ -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.") @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; 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 @DontObfuscate
@Desc("Optional properties for this block data such as 'waterlogged': true") @Desc("Optional properties for this block data such as 'waterlogged': true")
private KMap<String, Object> data = new KMap<>(); private KMap<String, Object> data = new KMap<>();
@@ -81,6 +85,11 @@ public class IrisBlockData
return b; return b;
} }
if(backup != null)
{
return backup.getBlockData();
}
return B.get("AIR"); return B.get("AIR");
}); });
} }
@@ -89,46 +98,46 @@ public class IrisBlockData
{ {
IrisBlockData b = new IrisBlockData(); IrisBlockData b = new IrisBlockData();
String m = j.toLowerCase().trim(); String m = j.toLowerCase().trim();
if(m.contains(":")) if(m.contains(":"))
{ {
b.setKey(m.split("\\Q:\\E")[0]); b.setKey(m.split("\\Q:\\E")[0]);
String v = m.split("\\Q:\\E")[1]; String v = m.split("\\Q:\\E")[1];
if(v.contains("[")) if(v.contains("["))
{ {
KList<String> props = new KList<>(); KList<String> props = new KList<>();
String rp = v.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", ""); String rp = v.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", "");
b.setBlock(v.split("\\Q[\\E")[0]); b.setBlock(v.split("\\Q[\\E")[0]);
if(rp.contains(",")) if(rp.contains(","))
{ {
props.add(rp.split("\\Q,\\E")); props.add(rp.split("\\Q,\\E"));
} }
else else
{ {
props.add(rp); props.add(rp);
} }
for(String i : props) for(String i : props)
{ {
Object kg = filter(i.split("\\Q=\\E")[1]); Object kg = filter(i.split("\\Q=\\E")[1]);
b.data.put(i.split("\\Q=\\E")[0], kg); b.data.put(i.split("\\Q=\\E")[0], kg);
} }
} }
else else
{ {
b.setBlock(v); b.setBlock(v);
} }
} }
else else
{ {
b.setBlock(m); b.setBlock(m);
} }
return b; return b;
} }