My friends in the same project told me that I needed to improve this code's complexty, so I tried but couldn't figure out how to do more.. They also said that I needed to change my coding style and background... This is my code and I have it's picture.
case Terrain ->{
ConclusiveTileSet tileSet=GameLogic.getGameLogic().getTileSet();
ArrayList list=new ArrayList();
for(int i=0;i<2305;i++){
list.add(0);
}
list.set(2065,15);
list.set(2080,10);
list.set(2074,5);
int maxX=Math.max(blockPos1.x(),blockPos2.x());
int minX=Math.min(blockPos1.x(),blockPos2.x());
int maxY=Math.max(blockPos1.y(),blockPos2.y());
int minY=Math.min(blockPos1.y(),blockPos2.y());
int Z=blockPos1.z();
for(int i=minX;i<=maxX;i++){
for (int j=minY;j<=maxY;j++){
int d=GameLogic.getGameLogic().getWorldLogic().blockAt(new VectorInt3D(i,j,Z)).getId();
if (d==2074||d==2080||d==2065){
int h= (int) list.get(d);
for(int k=99-h;k>=0;k--){
GameLogic.getGameLogic().getWorldLogic().erase(new VectorInt3D(i,j,k+h));
GameLogic.getGameLogic().getWorldLogic().writeEdit(new VectorInt3D(i,j,k+h),GameLogic.getGameLogic().getWorldLogic().blockAt(new VectorInt3D(i,j,k)).getId(),tileSet.getVoxelData(block.get()).getCollisionType().createDataStorage());
}
for(int k=h-1;k>=0;k--){
GameLogic.getGameLogic().getWorldLogic().erase(new VectorInt3D(i,j,k));
}
}
}
}
}
This is the code. I created a function that builds terrain height based on the selected area's block, from highest to lowest. I really don't know about the other functions since I didn't code it, but my friends have confirmed that they are not wrong...