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

View File

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