convert several files to Java 8

There may be additional files that require changing
This commit is contained in:
James Seibel
2023-02-23 19:52:51 -06:00
parent 8f9524a319
commit 95d0765ccb
3 changed files with 40 additions and 19 deletions
@@ -59,22 +59,41 @@ public class McObjectConverter
ELodDirection[] lodDirs = ELodDirection.values();
directions = new Direction[lodDirs.length];
lodDirections = new ELodDirection[lodDirs.length];
for (ELodDirection lodDir : lodDirs) {
Direction dir = switch (lodDir.name().toUpperCase()) {
case "DOWN" -> Direction.DOWN;
case "UP" -> Direction.UP;
case "NORTH" -> Direction.NORTH;
case "SOUTH" -> Direction.SOUTH;
case "WEST" -> Direction.WEST;
case "EAST" -> Direction.EAST;
default -> null;
};
if (dir == null) {
throw new IllegalArgumentException("Invalid direction on init mapping: " + lodDir);
}
directions[lodDir.ordinal()] = dir;
lodDirections[dir.ordinal()] = lodDir;
}
for (ELodDirection lodDir : lodDirs)
{
Direction dir;
switch (lodDir.name().toUpperCase())
{
case "DOWN":
dir = Direction.DOWN;
break;
case "UP":
dir = Direction.UP;
break;
case "NORTH":
dir = Direction.NORTH;
break;
case "SOUTH":
dir = Direction.SOUTH;
break;
case "WEST":
dir = Direction.WEST;
break;
case "EAST":
dir = Direction.EAST;
break;
default:
dir = null;
break;
}
if (dir == null)
{
throw new IllegalArgumentException("Invalid direction on init mapping: " + lodDir);
}
directions[lodDir.ordinal()] = dir;
lodDirections[dir.ordinal()] = lodDir;
}
}
public static BlockPos Convert(DhBlockPos wrappedPos) {
@@ -97,16 +97,18 @@ public class WrapperFactory implements IWrapperFactory
else if (objectArray.length == 2)
{
// chunk
if (!(objectArray[0] instanceof ChunkAccess chunk))
if (!(objectArray[0] instanceof ChunkAccess))
{
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
}
ChunkAccess chunk = (ChunkAccess) objectArray[0];
// light source
if (!(objectArray[1] instanceof LevelReader lightSource))
if (!(objectArray[1] instanceof LevelReader))
{
throw new ClassCastException(createChunkWrapperErrorMessage(objectArray));
}
LevelReader lightSource = (LevelReader) objectArray[1];
return new ChunkWrapper(chunk, lightSource, /*A DH wrapped level isn't necessary*/null);