From 9719576bda09c8f6948eaa50d3aba6b92febcaeb Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 4 May 2025 22:57:44 -0400 Subject: [PATCH] reduce unused imports --- .../collision/CollisionWorldData.java | 4 +-- .../state/hitbox/HitboxCollectionState.java | 6 ++--- .../entity/types/tree/ProceduralTree.java | 2 +- .../transport/StateCollection.java | 1 - .../electrosphere/script/ScriptEngine.java | 9 ------- .../server/entity/EnvironmentGenerator.java | 8 +++--- .../server/entity/ServerContentGenerator.java | 9 ++++--- .../terrain/generation/JSChunkGenerator.java | 8 +++--- .../generation/ProceduralChunkGenerator.java | 26 +++++++++---------- .../server/simulation/MacroSimulation.java | 5 ++-- .../recast/NavMeshConstructorTests.java | 1 - 11 files changed, 34 insertions(+), 45 deletions(-) diff --git a/src/main/java/electrosphere/collision/CollisionWorldData.java b/src/main/java/electrosphere/collision/CollisionWorldData.java index 3ab85e4a..bffe31df 100644 --- a/src/main/java/electrosphere/collision/CollisionWorldData.java +++ b/src/main/java/electrosphere/collision/CollisionWorldData.java @@ -48,7 +48,7 @@ public class CollisionWorldData { if(clientWorldData != null){ return clientWorldData.convertRealToChunkSpace(real); } else { - return serverWorldData.convertRealToChunkSpace(real); + return ServerWorldData.convertRealToChunkSpace(real); } } @@ -56,7 +56,7 @@ public class CollisionWorldData { if(clientWorldData != null){ return clientWorldData.convertChunkToRealSpace(world); } else { - return serverWorldData.convertChunkToRealSpace(world); + return ServerWorldData.convertChunkToRealSpace(world); } } diff --git a/src/main/java/electrosphere/entity/state/hitbox/HitboxCollectionState.java b/src/main/java/electrosphere/entity/state/hitbox/HitboxCollectionState.java index ec936f98..eb1f57c3 100644 --- a/src/main/java/electrosphere/entity/state/hitbox/HitboxCollectionState.java +++ b/src/main/java/electrosphere/entity/state/hitbox/HitboxCollectionState.java @@ -759,7 +759,7 @@ public class HitboxCollectionState { * @param data The data * @return The type of hitbox */ - private static HitboxType getType(HitboxData data){ + protected static HitboxType getType(HitboxData data){ switch(data.getType()){ case HitboxData.HITBOX_TYPE_HIT: { return HitboxType.HIT; @@ -788,7 +788,7 @@ public class HitboxCollectionState { * @param data The data * @return The shape type */ - private static HitboxShapeType getShapeType(HitboxData data){ + protected static HitboxShapeType getShapeType(HitboxData data){ switch(data.getType()){ case HitboxData.HITBOX_TYPE_HIT: case HitboxData.HITBOX_TYPE_HURT: { @@ -813,7 +813,7 @@ public class HitboxCollectionState { * @param data The data * @return The subtype */ - private static HitboxSubtype getSubType(HitboxData data){ + protected static HitboxSubtype getSubType(HitboxData data){ switch(data.getSubType()){ case HitboxData.HITBOX_SUBTYPE_SWEET: { return HitboxSubtype.SWEET; diff --git a/src/main/java/electrosphere/entity/types/tree/ProceduralTree.java b/src/main/java/electrosphere/entity/types/tree/ProceduralTree.java index 4c1d71c3..5f0480a9 100644 --- a/src/main/java/electrosphere/entity/types/tree/ProceduralTree.java +++ b/src/main/java/electrosphere/entity/types/tree/ProceduralTree.java @@ -1127,7 +1127,7 @@ public class ProceduralTree { //calculates the bone transform matrix - Matrix4d boneTransform = new Matrix4d().identity().rotate(boneRotation); + // Matrix4d boneTransform = new Matrix4d().identity().rotate(boneRotation); //new position transform Matrix4d newPositionTransform = new Matrix4d().rotate(boneRotation).translate(0,type.getBranchHeight(),0); diff --git a/src/main/java/electrosphere/net/synchronization/transport/StateCollection.java b/src/main/java/electrosphere/net/synchronization/transport/StateCollection.java index c92a0b51..68b7500c 100644 --- a/src/main/java/electrosphere/net/synchronization/transport/StateCollection.java +++ b/src/main/java/electrosphere/net/synchronization/transport/StateCollection.java @@ -3,7 +3,6 @@ package electrosphere.net.synchronization.transport; import electrosphere.entity.state.furniture.ServerDoorState; import electrosphere.entity.state.furniture.ClientDoorState; -import electrosphere.util.Utilities; import electrosphere.entity.state.item.ServerChargeState; import electrosphere.entity.state.item.ClientChargeState; import electrosphere.entity.state.movement.editor.ServerEditorMovementTree; diff --git a/src/main/java/electrosphere/script/ScriptEngine.java b/src/main/java/electrosphere/script/ScriptEngine.java index e4f8f4b9..b2cc57df 100644 --- a/src/main/java/electrosphere/script/ScriptEngine.java +++ b/src/main/java/electrosphere/script/ScriptEngine.java @@ -3,19 +3,10 @@ package electrosphere.script; import java.io.File; import java.io.IOException; import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.FileVisitResult; import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.StandardWatchEventKinds; -import java.nio.file.WatchEvent; -import java.nio.file.WatchKey; import java.nio.file.WatchService; -import java.nio.file.attribute.BasicFileAttributes; import java.security.NoSuchAlgorithmException; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.graalvm.polyglot.Source; diff --git a/src/main/java/electrosphere/server/entity/EnvironmentGenerator.java b/src/main/java/electrosphere/server/entity/EnvironmentGenerator.java index 524232f7..5c1bd5e5 100644 --- a/src/main/java/electrosphere/server/entity/EnvironmentGenerator.java +++ b/src/main/java/electrosphere/server/entity/EnvironmentGenerator.java @@ -1,10 +1,10 @@ package electrosphere.server.entity; -import electrosphere.entity.Entity; import electrosphere.entity.types.foliage.FoliageUtils; import electrosphere.logger.LoggerInterface; import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.ServerDataCell; +import electrosphere.server.datacell.ServerWorldData; import java.util.Random; @@ -39,11 +39,11 @@ public class EnvironmentGenerator { LoggerInterface.loggerGameLogic.DEBUG("generate forest"); for(int i = 0; i < targetNum; i++){ Vector3d position = new Vector3d( - realm.getServerWorldData().convertWorldToReal(worldPos.x) + rand.nextFloat() * 16, + ServerWorldData.convertWorldToReal(worldPos.x) + rand.nextFloat() * 16, 0, - realm.getServerWorldData().convertWorldToReal(worldPos.z) + rand.nextFloat() * 16 + ServerWorldData.convertWorldToReal(worldPos.z) + rand.nextFloat() * 16 ); - Entity tree = FoliageUtils.serverSpawnTreeFoliage(realm, position, "oak", rand.nextLong()); + FoliageUtils.serverSpawnTreeFoliage(realm, position, "oak", rand.nextLong()); } } } diff --git a/src/main/java/electrosphere/server/entity/ServerContentGenerator.java b/src/main/java/electrosphere/server/entity/ServerContentGenerator.java index 7b5121bb..eea6179c 100644 --- a/src/main/java/electrosphere/server/entity/ServerContentGenerator.java +++ b/src/main/java/electrosphere/server/entity/ServerContentGenerator.java @@ -11,6 +11,7 @@ import electrosphere.game.data.biome.BiomeData; import electrosphere.game.data.biome.BiomeFoliageDescription; import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.ServerDataCell; +import electrosphere.server.datacell.ServerWorldData; import electrosphere.server.macro.MacroData; import electrosphere.server.macro.spatial.MacroAreaObject; import electrosphere.server.physics.terrain.manager.ServerTerrainChunk; @@ -69,13 +70,13 @@ public class ServerContentGenerator { for(int z = 0; z < ServerTerrainChunk.CHUNK_DIMENSION; z++){ double height = realm.getServerWorldData().getServerTerrainManager().getElevation(worldPos.x, worldPos.z, x, z) + HEIGHT_MANUAL_ADJUSTMENT; if( - realm.getServerWorldData().convertVoxelToRealSpace(0, worldPos.y) < height && - realm.getServerWorldData().convertVoxelToRealSpace(ServerTerrainChunk.CHUNK_DIMENSION, worldPos.y) > height + ServerWorldData.convertVoxelToRealSpace(0, worldPos.y) < height && + ServerWorldData.convertVoxelToRealSpace(ServerTerrainChunk.CHUNK_DIMENSION, worldPos.y) > height ){ BiomeFoliageDescription toPlace = null; double foundPriority = -1; - double realX = realm.getServerWorldData().convertVoxelToRealSpace(x, worldPos.x); - double realZ = realm.getServerWorldData().convertVoxelToRealSpace(z, worldPos.z); + double realX = ServerWorldData.convertVoxelToRealSpace(x, worldPos.x); + double realZ = ServerWorldData.convertVoxelToRealSpace(z, worldPos.z); //check if a macro object is blocking content here boolean macroBlockingContent = false; diff --git a/src/main/java/electrosphere/server/physics/terrain/generation/JSChunkGenerator.java b/src/main/java/electrosphere/server/physics/terrain/generation/JSChunkGenerator.java index 7cc6e697..7dfdf424 100644 --- a/src/main/java/electrosphere/server/physics/terrain/generation/JSChunkGenerator.java +++ b/src/main/java/electrosphere/server/physics/terrain/generation/JSChunkGenerator.java @@ -142,8 +142,8 @@ public class JSChunkGenerator implements ChunkGenerator { int finalChunkZ = (z * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION; heightfield[x][z] = heightmapGen.getHeight( this.terrainModel.getSeed(), - this.serverWorldData.convertVoxelToRealSpace(finalChunkX, finalWorldX), - this.serverWorldData.convertVoxelToRealSpace(finalChunkZ, finalWorldZ) + ServerWorldData.convertVoxelToRealSpace(finalChunkX, finalWorldX), + ServerWorldData.convertVoxelToRealSpace(finalChunkZ, finalWorldZ) ); } } @@ -227,8 +227,8 @@ public class JSChunkGenerator implements ChunkGenerator { } double rVal = heightmapGen.getHeight( this.terrainModel.getSeed(), - this.serverWorldData.convertVoxelToRealSpace(chunkX, worldX), - this.serverWorldData.convertVoxelToRealSpace(chunkZ, worldZ) + ServerWorldData.convertVoxelToRealSpace(chunkX, worldX), + ServerWorldData.convertVoxelToRealSpace(chunkZ, worldZ) ); return rVal; } diff --git a/src/main/java/electrosphere/server/physics/terrain/generation/ProceduralChunkGenerator.java b/src/main/java/electrosphere/server/physics/terrain/generation/ProceduralChunkGenerator.java index e5830a92..e7c22165 100644 --- a/src/main/java/electrosphere/server/physics/terrain/generation/ProceduralChunkGenerator.java +++ b/src/main/java/electrosphere/server/physics/terrain/generation/ProceduralChunkGenerator.java @@ -175,7 +175,7 @@ public class ProceduralChunkGenerator implements ChunkGenerator { for(int x = 0; x < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; x++){ int finalWorldX = worldX + ((x * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION); int finalChunkX = (x * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION; - double realX = generationContext.getServerWorldData().convertVoxelToRealSpace(finalChunkX,finalWorldX); + double realX = ServerWorldData.convertVoxelToRealSpace(finalChunkX,finalWorldX); for(int z = 0; z < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; z++){ BiomeData surfaceBiome = surfaceBiomeMap[x][z]; @@ -184,7 +184,7 @@ public class ProceduralChunkGenerator implements ChunkGenerator { int finalWorldZ = worldZ + ((z * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION); int finalChunkZ = (z * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION; - double realZ = generationContext.getServerWorldData().convertVoxelToRealSpace(finalChunkZ,finalWorldZ); + double realZ = ServerWorldData.convertVoxelToRealSpace(finalChunkZ,finalWorldZ); double surfaceHeight = heightfield[x][z]; double gradient = gradientField[x][z]; double surfaceSelection = this.calculateSurfaceNoise(surfaceParams, finalWorldX, finalWorldZ, finalChunkX, finalChunkZ, strideValue, this.terrainModel.getSeed()); @@ -192,7 +192,7 @@ public class ProceduralChunkGenerator implements ChunkGenerator { for(int y = 0; y < ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE; y++){ int finalWorldY = worldY + ((y * strideValue) / ServerTerrainChunk.CHUNK_DIMENSION); int finalChunkY = (y * strideValue) % ServerTerrainChunk.CHUNK_DIMENSION; - double realY = generationContext.getServerWorldData().convertVoxelToRealSpace(finalChunkY,finalWorldY); + double realY = ServerWorldData.convertVoxelToRealSpace(finalChunkY,finalWorldY); voxelGenerator.getVoxel( voxel, @@ -259,13 +259,13 @@ public class ProceduralChunkGenerator implements ChunkGenerator { heightfield[x][z] = this.getMultisampleElevation(finalWorldX, finalWorldZ, finalChunkX, finalChunkZ); //calculate real pos - double realX = serverWorldData.convertVoxelToRealSpace(finalChunkX, finalWorldX); - double realZ = serverWorldData.convertVoxelToRealSpace(finalChunkZ, finalWorldZ); + double realX = ServerWorldData.convertVoxelToRealSpace(finalChunkX, finalWorldX); + double realZ = ServerWorldData.convertVoxelToRealSpace(finalChunkZ, finalWorldZ); //clamped macro pos int macroDataScale = terrainModel.getMacroDataScale(); - double macroWorldPosX = serverWorldData.convertWorldToReal(serverWorldData.clampWorldToMacro(finalWorldX)); - double macroWorldPosZ = serverWorldData.convertWorldToReal(serverWorldData.clampWorldToMacro(finalWorldZ)); + double macroWorldPosX = ServerWorldData.convertWorldToReal(serverWorldData.clampWorldToMacro(finalWorldX)); + double macroWorldPosZ = ServerWorldData.convertWorldToReal(serverWorldData.clampWorldToMacro(finalWorldZ)); double macroWidth = this.terrainModel.getMacroWidthInRealTerms(); double percent1 = (realX - macroWorldPosX) / macroWidth; double percent2 = (realZ - macroWorldPosZ) / macroWidth; @@ -299,8 +299,8 @@ public class ProceduralChunkGenerator implements ChunkGenerator { * @return */ private double calculateSurfaceNoise(BiomeSurfaceGenerationParams surfaceParams, int worldX, int worldZ, int chunkX, int chunkZ, int strideValue, long seed){ - double realX = serverWorldData.convertVoxelToRealSpace(chunkX, worldX); - double realZ = serverWorldData.convertVoxelToRealSpace(chunkZ, worldZ); + double realX = ServerWorldData.convertVoxelToRealSpace(chunkX, worldX); + double realZ = ServerWorldData.convertVoxelToRealSpace(chunkZ, worldZ); float noiseScale = surfaceParams.getNoiseScale(); float warpScale = surfaceParams.getWarpScale(); @@ -332,13 +332,13 @@ public class ProceduralChunkGenerator implements ChunkGenerator { HeightmapGenerator heightmapGen = null; //calculate real pos - double realX = serverWorldData.convertVoxelToRealSpace(finalChunkX, finalWorldX); - double realZ = serverWorldData.convertVoxelToRealSpace(finalChunkZ, finalWorldZ); + double realX = ServerWorldData.convertVoxelToRealSpace(finalChunkX, finalWorldX); + double realZ = ServerWorldData.convertVoxelToRealSpace(finalChunkZ, finalWorldZ); //clamped macro pos int macroDataScale = terrainModel.getMacroDataScale(); - double macroWorldPosX = serverWorldData.convertWorldToReal(serverWorldData.clampWorldToMacro(finalWorldX)); - double macroWorldPosZ = serverWorldData.convertWorldToReal(serverWorldData.clampWorldToMacro(finalWorldZ)); + double macroWorldPosX = ServerWorldData.convertWorldToReal(serverWorldData.clampWorldToMacro(finalWorldX)); + double macroWorldPosZ = ServerWorldData.convertWorldToReal(serverWorldData.clampWorldToMacro(finalWorldZ)); double macroWidth = this.terrainModel.getMacroWidthInRealTerms(); double percent1 = (realX - macroWorldPosX) / macroWidth; double percent2 = (realZ - macroWorldPosZ) / macroWidth; diff --git a/src/main/java/electrosphere/server/simulation/MacroSimulation.java b/src/main/java/electrosphere/server/simulation/MacroSimulation.java index 70447372..a70aabf8 100644 --- a/src/main/java/electrosphere/server/simulation/MacroSimulation.java +++ b/src/main/java/electrosphere/server/simulation/MacroSimulation.java @@ -1,6 +1,5 @@ package electrosphere.server.simulation; -import electrosphere.engine.Globals; import electrosphere.server.macro.character.Character; import electrosphere.server.macro.character.CharacterDataStrings; @@ -46,7 +45,7 @@ public class MacroSimulation { */ static final int MAX_PLACE_ATTEMPTS = 10; - private static void checkForShelter(Character chara){ + protected static void checkForShelter(Character chara){ // for(Character chara : Globals.macroData.getAliveCharacters()){ /* If doesn’t have shelter, check if in town @@ -100,7 +99,7 @@ public class MacroSimulation { // } } - private static void checkTownMembership(Character chara){ + protected static void checkTownMembership(Character chara){ //TODO: eventually exclude people who shouldn't belong to a town (traders, bandits, etc) // for(Character chara : Globals.macroData.getAliveCharacters()){ boolean hasHometown = chara.containsKey(CharacterDataStrings.HOMETOWN); diff --git a/src/test/java/electrosphere/server/pathfinding/recast/NavMeshConstructorTests.java b/src/test/java/electrosphere/server/pathfinding/recast/NavMeshConstructorTests.java index c8b74a8c..b3df9d64 100644 --- a/src/test/java/electrosphere/server/pathfinding/recast/NavMeshConstructorTests.java +++ b/src/test/java/electrosphere/server/pathfinding/recast/NavMeshConstructorTests.java @@ -11,7 +11,6 @@ import org.recast4j.recast.RecastBuilder.RecastBuilderResult; import org.recast4j.recast.geom.SingleTrimeshInputGeomProvider; import electrosphere.entity.state.collidable.TriGeomData; -import electrosphere.server.pathfinding.recast.NavMeshConstructor; import electrosphere.test.annotations.UnitTest; import electrosphere.util.math.GeomUtils;