mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 18:45:34 +01:00
Method to get material using also data
This commit is contained in:
parent
9ec971e219
commit
96a6f33958
@ -1372,13 +1372,40 @@ public enum CompatibleMaterial {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup a Material by Material and data, corrected for legacy
|
||||
*
|
||||
* @param mat material to check
|
||||
* @param data data of the block
|
||||
* @return LegacyMaterial or null if none found
|
||||
*/
|
||||
public static CompatibleMaterial getMaterial(Material mat, byte data) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) { // Flattening
|
||||
return CompatibleMaterial.getMaterial(mat);
|
||||
} else { // Pre-Flattening
|
||||
if(mat != null){
|
||||
if (data != 0) {
|
||||
for (CompatibleMaterial cm : CompatibleMaterial.values()) {
|
||||
if (cm.getMaterial() != null
|
||||
&& cm.getMaterial().equals(mat)) {
|
||||
if (cm.getData() == data) {
|
||||
return cm;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return CompatibleMaterial.getMaterial(mat);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static CompatibleMaterial getMaterialFromNewBlock(Block block) {
|
||||
if (block == null) {
|
||||
return null;
|
||||
}
|
||||
Material mat = block.getType();
|
||||
if (mat == null) return null;
|
||||
else if (useLegacy) {
|
||||
if (useLegacy) {
|
||||
LegacyMaterialBlockType legacyBlock = LegacyMaterialBlockType.getFromLegacy(mat.name());
|
||||
if (legacyBlock != null) {
|
||||
return lookupMap.get(legacyBlock.name());
|
||||
|
Loading…
Reference in New Issue
Block a user