fix -ve type ids

This commit is contained in:
REAndroid 2022-12-29 12:05:19 -05:00
parent 54576ea91f
commit 33817b36d8
2 changed files with 11 additions and 13 deletions

View File

@ -171,7 +171,7 @@ public class SpecTypePairArray extends BlockArray<SpecTypePair>
} }
return results; return results;
} }
public byte getSmallestTypeId(){ public int getSmallestTypeId(){
SpecTypePair[] childes=getChildes(); SpecTypePair[] childes=getChildes();
if(childes==null){ if(childes==null){
return 0; return 0;
@ -183,7 +183,7 @@ public class SpecTypePairArray extends BlockArray<SpecTypePair>
if(pair==null){ if(pair==null){
continue; continue;
} }
int id=pair.getTypeId(); int id=pair.getTypeIdInt();
if(!firstFound){ if(!firstFound){
result=id; result=id;
} }
@ -192,30 +192,25 @@ public class SpecTypePairArray extends BlockArray<SpecTypePair>
result=id; result=id;
} }
} }
return (byte) result; return result;
} }
public byte getHighestTypeId(){ public int getHighestTypeId(){
SpecTypePair[] childes=getChildes(); SpecTypePair[] childes=getChildes();
if(childes==null){ if(childes==null){
return 0; return 0;
} }
int result=0; int result=0;
boolean firstFound=false;
for (int i=0;i<childes.length;i++){ for (int i=0;i<childes.length;i++){
SpecTypePair pair=childes[i]; SpecTypePair pair=childes[i];
if(pair==null){ if(pair==null){
continue; continue;
} }
int id=pair.getTypeId(); int id=pair.getTypeIdInt();
if(!firstFound){ if(id>result){
result=id;
}
firstFound=true;
if(id<result){
result=id; result=id;
} }
} }
return (byte) result; return result;
} }
@Override @Override
public JSONArray toJson() { public JSONArray toJson() {

View File

@ -84,6 +84,9 @@ public class SpecTypePair extends BlockContainer<Block>
public byte getTypeId(){ public byte getTypeId(){
return mSpecBlock.getTypeId(); return mSpecBlock.getTypeId();
} }
public int getTypeIdInt(){
return mSpecBlock.getTypeIdInt();
}
public void setTypeId(byte id){ public void setTypeId(byte id){
mSpecBlock.setTypeId(id); mSpecBlock.setTypeId(id);
mTypeBlockArray.setTypeId(id); mTypeBlockArray.setTypeId(id);
@ -201,7 +204,7 @@ public class SpecTypePair extends BlockContainer<Block>
} }
@Override @Override
public int compareTo(SpecTypePair specTypePair) { public int compareTo(SpecTypePair specTypePair) {
return Integer.compare(getTypeId(), specTypePair.getTypeId()); return Integer.compare(getTypeIdInt(), specTypePair.getTypeIdInt());
} }
@Override @Override
public String toString(){ public String toString(){