Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 0 additions & 67 deletions src/main/kotlin/com/coderjoe/atlas/fluid/FluidBlockData.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class FluidBlockRegistry(plugin: JavaPlugin) : BlockRegistry<FluidBlock>(plugin)
companion object {
var instance: FluidBlockRegistry? = null
private set

fun locationKey(location: Location): String = BlockRegistry.locationKey(location)
}

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class FluidSplitter(location: Location, override val facing: BlockFace) : FluidB
}

override val baseBlockId: String = BLOCK_ID
private var nextOutputIndex: Int = 0

override fun getVisualStateBlockId(): String = BLOCK_ID

Expand All @@ -47,13 +48,16 @@ class FluidSplitter(location: Location, override val facing: BlockFace) : FluidB

if (hasFluid()) {
val outputFaces = ADJACENT_FACES.filter { it != facing.oppositeFace }
val faceCount = outputFaces.size

for (face in outputFaces) {
for (i in outputFaces.indices) {
if (!hasFluid()) break
val face = outputFaces[(nextOutputIndex + i) % faceCount]
val target = registry.getAdjacentFluidBlock(location, face) ?: continue
if (!target.hasFluid()) {
val fluid = removeFluid()
if (target.storeFluid(fluid)) {
nextOutputIndex = (nextOutputIndex + i + 1) % faceCount
plugin.logger.atlasInfo(
"FluidSplitter at ${location.coordinates} " +
"pushed ${fluid.name} to ${target::class.simpleName} at ${face.name}",
Expand Down
54 changes: 0 additions & 54 deletions src/main/kotlin/com/coderjoe/atlas/power/PowerBlockData.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class PowerBlockRegistry(plugin: JavaPlugin) : BlockRegistry<PowerBlock>(plugin)
companion object {
var instance: PowerBlockRegistry? = null
private set

fun locationKey(location: Location): String = BlockRegistry.locationKey(location)
}

init {
Expand Down
10 changes: 9 additions & 1 deletion src/main/kotlin/com/coderjoe/atlas/power/block/PowerSplitter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PowerSplitter(location: Location, override val facing: BlockFace) : PowerB
override val baseBlockId: String = BLOCK_ID

override val updateIntervalTicks: Long = 20L
private var nextOutputIndex: Int = 0

override fun getVisualStateBlockId(): String = BLOCK_ID

Expand All @@ -48,21 +49,28 @@ class PowerSplitter(location: Location, override val facing: BlockFace) : PowerB

if (hasPower()) {
val outputFaces = ADJACENT_FACES.filter { it != facing.oppositeFace }
val faceCount = outputFaces.size
var lastPushOffset = -1

for (face in outputFaces) {
for (i in outputFaces.indices) {
if (!hasPower()) break
val face = outputFaces[(nextOutputIndex + i) % faceCount]
val target = registry.getAdjacentPowerBlock(location, face) ?: continue
if (target.canAcceptPower()) {
val pushed = removePower(1)
if (pushed > 0) {
target.addPower(pushed)
lastPushOffset = i
plugin.logger.atlasInfo(
"PowerSplitter at ${location.coordinates} " +
"pushed $pushed power to ${target::class.simpleName} at ${face.name}",
)
}
}
}
if (lastPushOffset >= 0) {
nextOutputIndex = (nextOutputIndex + lastPushOffset + 1) % faceCount
}
}

updatePoweredState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ class SmallSolarPanel(location: Location) : PowerBlock(location, maxStorage = 4)
"generated $generated power (now $currentPower/$maxStorage)",
)
}
} else {
plugin.logger.atlasInfo(
"SmallSolarPanel at ${location.coordinates} " +
"is not generating power because it is not daytime.",
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class TransportBlockRegistry(plugin: JavaPlugin) : BlockRegistry<TransportBlock>
companion object {
var instance: TransportBlockRegistry? = null
private set

fun locationKey(location: Location): String = BlockRegistry.locationKey(location)
}

init {
Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/com/coderjoe/atlas/TestHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ object TestHelper {
@Suppress("UNCHECKED_CAST")
val blockIds = blockIdsField.get(registry) as java.util.concurrent.ConcurrentHashMap<String, String>

val key = PowerBlockRegistry.locationKey(block.location)
val key = BlockRegistry.locationKey(block.location)
blocks[key] = block
blockIds[key] = blockId
}
Expand All @@ -149,7 +149,7 @@ object TestHelper {
@Suppress("UNCHECKED_CAST")
val blockIds = blockIdsField.get(registry) as java.util.concurrent.ConcurrentHashMap<String, String>

val key = TransportBlockRegistry.locationKey(block.location)
val key = BlockRegistry.locationKey(block.location)
blocks[key] = block
blockIds[key] = blockId
}
Expand All @@ -169,7 +169,7 @@ object TestHelper {
@Suppress("UNCHECKED_CAST")
val blockIds = blockIdsField.get(registry) as java.util.concurrent.ConcurrentHashMap<String, String>

val key = FluidBlockRegistry.locationKey(block.location)
val key = BlockRegistry.locationKey(block.location)
blocks[key] = block
blockIds[key] = blockId
}
Expand Down
117 changes: 0 additions & 117 deletions src/test/kotlin/com/coderjoe/atlas/fluid/FluidBlockDataTest.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.coderjoe.atlas.fluid

import com.coderjoe.atlas.TestHelper
import com.coderjoe.atlas.core.AtlasBlockListener
import com.coderjoe.atlas.core.BlockRegistry
import com.coderjoe.atlas.core.BlockSystem
import com.coderjoe.atlas.fluid.block.FluidPump
import io.mockk.every
Expand Down Expand Up @@ -46,7 +47,7 @@ class FluidBlockListenerTest {
@Test
fun `onBlockPlace skips when in updatingLocations`() {
val loc = TestHelper.createLocation()
val key = FluidBlockRegistry.locationKey(loc)
val key = BlockRegistry.locationKey(loc)
registry.updatingLocations.add(key)

val block = mockk<Block>(relaxed = true)
Expand All @@ -61,7 +62,7 @@ class FluidBlockListenerTest {
@Test
fun `onBlockBreak skips when in updatingLocations`() {
val loc = TestHelper.createLocation()
val key = FluidBlockRegistry.locationKey(loc)
val key = BlockRegistry.locationKey(loc)
registry.updatingLocations.add(key)

val block = mockk<Block>(relaxed = true)
Expand Down
Loading
Loading