Fixed rotatable blocks in island level other than 0

This commit is contained in:
Esophose 2019-08-17 13:56:58 -06:00
parent af583ed710
commit 15667c8635
2 changed files with 42 additions and 15 deletions

View File

@ -375,7 +375,9 @@ public class LevellingManager {
return materialStorage;
}
private class LevellingData {
private static class LevellingData {
private final static int version = NMSUtil.getVersionNumber();
private final Material material;
private final byte data;
private final EntityType spawnerType;
@ -391,12 +393,32 @@ public class LevellingManager {
if (!(obj instanceof LevellingData)) return false;
LevellingData data = (LevellingData) obj;
if (this == obj) return true;
return this.material == data.material && this.data == data.data && this.spawnerType == data.spawnerType;
if (version > 12) {
return this.material == data.material && this.spawnerType == data.spawnerType;
} else {
if (this.data == 0 && data.data == 0)
return this.material == data.material && this.spawnerType == data.spawnerType;
Materials thisMaterials = Materials.requestMaterials(this.material.name(), this.data);
Materials otherMaterials = Materials.requestMaterials(this.material.name(), (byte) 0);
return thisMaterials == otherMaterials && this.spawnerType == data.spawnerType;
}
}
@Override
public int hashCode() {
return Objects.hash(this.material, this.data, this.spawnerType);
if (version > 12) {
return Objects.hash(this.material, this.spawnerType);
} else {
if (this.data == 0)
return Objects.hash(this.material, true, this.spawnerType);
Materials thisMaterials = Materials.requestMaterials(this.material.name(), this.data);
Materials otherMaterials = Materials.requestMaterials(this.material.name(), (byte) 0);
return Objects.hash(this.material, thisMaterials == otherMaterials, this.spawnerType);
}
}
private Materials getMaterials() {
@ -415,7 +437,7 @@ public class LevellingManager {
}
}
private class QueuedIsland {
private static class QueuedIsland {
private final Player player;
private final Island island;

View File

@ -1125,39 +1125,44 @@ public enum Materials {
private static HashMap<String, Materials> cachedSearch = new HashMap<>();
public static Materials requestMaterials(String name, byte data) {
if (cachedSearch.containsKey(name.toUpperCase() + "," + data)) {
if (cachedSearch.containsKey(name.toUpperCase() + "," + data))
return cachedSearch.get(name.toUpperCase() + "," + data);
Materials pmat = internalRequestMaterials(name, data);
if (pmat != null || data == 0) {
cachedSearch.put(name.toUpperCase() + "," + data, pmat);
return pmat;
}
pmat = internalRequestMaterials(name, (byte) 0);
cachedSearch.put(name.toUpperCase() + "," + data, pmat);
return pmat;
}
private static Materials internalRequestMaterials(String name, byte data) {
Materials pmat = null;
// Try 1.13+ names
for (Materials mat : Materials.values()) {
if (name.equalsIgnoreCase(mat.name())) {
if (pmat == null) {
if (pmat == null)
pmat = mat;
}
if (((byte) mat.data) == data) {
cachedSearch.put(mat.name() + "," + data, mat);
if (((byte) mat.data) == data)
return mat;
}
}
}
// Try 1.12- names
for (Materials mat : Materials.values()) {
if (name.equalsIgnoreCase(mat.old12Mat)) {
if (pmat == null) {
if (pmat == null)
pmat = mat;
}
if (((byte) mat.data) == data) {
cachedSearch.put(mat.old12Mat + "," + data, mat);
if (((byte) mat.data) == data)
return mat;
}
}
}
return pmat;
}