Skip to content

Commit

Permalink
fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubydesic committed Oct 22, 2023
1 parent ef2e167 commit 76b9ad4
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.apache.commons.lang3.mutable.MutableObject
import org.valkyrienskies.core.apigame.world.ServerShipWorldCore
import org.valkyrienskies.core.apigame.world.chunks.ChunkUnwatchTask
import org.valkyrienskies.core.apigame.world.chunks.ChunkWatchTask
import org.valkyrienskies.mod.common.executeIf
import org.valkyrienskies.mod.common.getLevelFromDimensionId
import org.valkyrienskies.mod.common.isTickingChunk
import org.valkyrienskies.mod.common.mcPlayer
Expand All @@ -20,7 +21,6 @@ object ChunkManagement {
val (chunkWatchTasks, chunkUnwatchTasks) = shipWorld.getChunkWatchTasks()

// for now, just do all the watch tasks

chunkWatchTasks.forEach { chunkWatchTask: ChunkWatchTask ->
logger.debug(
"Watch task for dimension " + chunkWatchTask.dimensionId + ": " +
Expand All @@ -32,22 +32,19 @@ object ChunkManagement {
val level = server.getLevelFromDimensionId(chunkWatchTask.dimensionId)!!
level.chunkSource.updateChunkForced(chunkPos, true)

// level.server.executeIf({ level.isTickingChunk(chunkPos) }) {
if (!level.isTickingChunk(chunkPos))
logger.error("chunk $chunkPos is not ticking!!")

for (player in chunkWatchTask.playersNeedWatching) {
val minecraftPlayer = player as MinecraftPlayer
val serverPlayer = minecraftPlayer.playerEntityReference.get() as ServerPlayer?
if (serverPlayer != null) {
if (chunkWatchTask.dimensionId != player.dimension) {
logger.warn("Player received watch task for chunk in dimension that they are not also in!")
level.server.executeIf({ level.isTickingChunk(chunkPos) }) {
for (player in chunkWatchTask.playersNeedWatching) {
val minecraftPlayer = player as MinecraftPlayer
val serverPlayer = minecraftPlayer.playerEntityReference.get() as ServerPlayer?
if (serverPlayer != null) {
if (chunkWatchTask.dimensionId != player.dimension) {
logger.warn("Player received watch task for chunk in dimension that they are not also in!")
}
val map = level.chunkSource.chunkMap as ChunkMapAccessor
map.callUpdateChunkTracking(serverPlayer, chunkPos, MutableObject(), false, true)
}
val map = level.chunkSource.chunkMap as ChunkMapAccessor
map.callUpdateChunkTracking(serverPlayer, chunkPos, MutableObject(), false, true)
}
}
// }
}

chunkUnwatchTasks.forEach { chunkUnwatchTask: ChunkUnwatchTask ->
Expand Down

0 comments on commit 76b9ad4

Please sign in to comment.