diff --git a/src/main/java/chylex/hee/game/block/BlockEnergyCluster.kt b/src/main/java/chylex/hee/game/block/BlockEnergyCluster.kt index 90c138f1..1ff83a5c 100644 --- a/src/main/java/chylex/hee/game/block/BlockEnergyCluster.kt +++ b/src/main/java/chylex/hee/game/block/BlockEnergyCluster.kt @@ -1,7 +1,6 @@ package chylex.hee.game.block import chylex.hee.game.block.entity.TileEntityEnergyCluster import chylex.hee.game.block.info.BlockBuilder -import chylex.hee.game.mechanics.energy.IClusterGenerator import chylex.hee.game.mechanics.energy.IEnergyQuantity import chylex.hee.game.mechanics.instability.Instability import chylex.hee.init.ModBlocks diff --git a/src/main/java/chylex/hee/game/block/entity/TileEntityTablePedestal.kt b/src/main/java/chylex/hee/game/block/entity/TileEntityTablePedestal.kt index 6c5b1131..c7053f8c 100644 --- a/src/main/java/chylex/hee/game/block/entity/TileEntityTablePedestal.kt +++ b/src/main/java/chylex/hee/game/block/entity/TileEntityTablePedestal.kt @@ -30,6 +30,7 @@ import chylex.hee.system.util.color.IntColor import chylex.hee.system.util.delegate.NotifyOnChange import chylex.hee.system.util.getIntegerOrNull import chylex.hee.system.util.getPosOrNull +import chylex.hee.system.util.getState import chylex.hee.system.util.getTile import chylex.hee.system.util.isLoaded import chylex.hee.system.util.isNotEmpty @@ -37,8 +38,8 @@ import chylex.hee.system.util.nextFloat import chylex.hee.system.util.playClient import chylex.hee.system.util.posVec import chylex.hee.system.util.setPos +import chylex.hee.system.util.setState import chylex.hee.system.util.totalTime -import chylex.hee.system.util.updateState import chylex.hee.system.util.with import net.minecraft.block.state.IBlockState import net.minecraft.entity.item.EntityItem @@ -199,7 +200,12 @@ class TileEntityTablePedestal : TileEntityBase(){ private fun onLinkedStatusChanged(){ if (world != null){ - pos.updateState(world, ModBlocks.TABLE_PEDESTAL, FLAG_SYNC_CLIENT){ it.with(IS_LINKED, linkedTable != null) } + val state = pos.getState(world) + + if (state.block === ModBlocks.TABLE_PEDESTAL){ + pos.setState(world, state.with(IS_LINKED, linkedTable != null)) + } + statusIndicator.process = null } } diff --git a/src/main/java/chylex/hee/game/mechanics/energy/IClusterGenerator.kt b/src/main/java/chylex/hee/game/mechanics/energy/IClusterGenerator.kt index 926f8d44..52a9edbf 100644 --- a/src/main/java/chylex/hee/game/mechanics/energy/IClusterGenerator.kt +++ b/src/main/java/chylex/hee/game/mechanics/energy/IClusterGenerator.kt @@ -15,9 +15,7 @@ interface IClusterGenerator{ fun generate(rand: Random): ClusterSnapshot companion object{ - private class SimpleGenerator(level: Pair<Int, Int>, capacity: Pair<Int, Int>, private val health: (Random) -> HealthStatus) : IClusterGenerator{ - constructor(level: Pair<Int, Int>, capacity: Pair<Int, Int>, health: WeightedList<HealthStatus>) : this(level, capacity, health::generateItem) - + private class SimpleGenerator(level: Pair<Int, Int>, capacity: Pair<Int, Int>, private val health: WeightedList<HealthStatus>) : IClusterGenerator{ private val levelMin = Units(level.first).floating.value private val levelMax = Units(level.second).floating.value @@ -31,7 +29,7 @@ interface IClusterGenerator{ return ClusterSnapshot( energyLevel = minOf(generatedLevel, generatedCapacity), energyCapacity = generatedCapacity, - healthStatus = health(rand), + healthStatus = health.generateItem(rand), healthOverride = null, color = ClusterColor.generate(rand) ) diff --git a/src/main/java/chylex/hee/game/world/feature/basic/ores/OreGenerator.kt b/src/main/java/chylex/hee/game/world/feature/basic/ores/OreGenerator.kt index e7c4daaf..3b024069 100644 --- a/src/main/java/chylex/hee/game/world/feature/basic/ores/OreGenerator.kt +++ b/src/main/java/chylex/hee/game/world/feature/basic/ores/OreGenerator.kt @@ -27,7 +27,7 @@ class OreGenerator( var clustersGenerated = 0 for(chunkX in 0 until sizeX step chunkSize) for(chunkZ in 0 until sizeZ step chunkSize){ - var clustersLeft = clustersPerChunk(rand) + var clustersLeft = clustersPerChunk(rand).takeIf { it > 0 } ?: continue for(attempt in 1..attemptsPerChunk){ val pos = Pos( diff --git a/src/main/java/chylex/hee/game/world/territory/TerritoryInstance.kt b/src/main/java/chylex/hee/game/world/territory/TerritoryInstance.kt index efdc2dc0..47e2a3fb 100644 --- a/src/main/java/chylex/hee/game/world/territory/TerritoryInstance.kt +++ b/src/main/java/chylex/hee/game/world/territory/TerritoryInstance.kt @@ -101,9 +101,6 @@ data class TerritoryInstance(val territory: TerritoryType, val index: Int){ ChunkPos(chunkOffX + CHUNK_X_OFFSET, chunkOffZ) } - private val bottomRightChunk: ChunkPos - get() = topLeftChunk.let { ChunkPos(it.x + chunks - 1, it.z + chunks - 1) } - private val bottomCenterPos: BlockPos get() = topLeftChunk.getBlock(chunks * 8, territory.height.first, chunks * 8) diff --git a/src/main/java/chylex/hee/init/ModRendering.kt b/src/main/java/chylex/hee/init/ModRendering.kt index 06ddebbe..5c622538 100644 --- a/src/main/java/chylex/hee/init/ModRendering.kt +++ b/src/main/java/chylex/hee/init/ModRendering.kt @@ -258,12 +258,6 @@ object ModRendering{ setModel(Item.getItemFromBlock(block), metadata, location, variant) } - private fun setModel(item: Item, metadatas: IntRange, location: ResourceLocation = item.registryName!!, variant: String = "inventory"){ - for(metadata in metadatas){ - setModel(item, metadata, location, variant) - } - } - private fun setModel(block: Block, metadatas: IntRange, location: ResourceLocation = block.registryName!!, variant: String = "inventory"){ for(metadata in metadatas){ setModel(block, metadata, location, variant) diff --git a/src/main/java/chylex/hee/system/collection/MutableWeightedList.kt b/src/main/java/chylex/hee/system/collection/MutableWeightedList.kt index 057d5b59..5fefc7d5 100644 --- a/src/main/java/chylex/hee/system/collection/MutableWeightedList.kt +++ b/src/main/java/chylex/hee/system/collection/MutableWeightedList.kt @@ -18,11 +18,6 @@ class MutableWeightedList<T>(private val items: MutableList<Pair<Int, T>>){ val values: List<T> get() = items.map { it.second } - fun addItem(entry: Pair<Int, T>){ - items.add(entry) - isDirty = true - } - fun addItem(weight: Int, item: T){ items.add(Pair(weight, item)) isDirty = true diff --git a/src/main/java/chylex/hee/system/util/PosExt.kt b/src/main/java/chylex/hee/system/util/PosExt.kt index 959af58e..9f36c7f7 100644 --- a/src/main/java/chylex/hee/system/util/PosExt.kt +++ b/src/main/java/chylex/hee/system/util/PosExt.kt @@ -98,16 +98,6 @@ inline fun BlockPos.setState(world: World, state: IBlockState, flags: Int): Bool return world.setBlockState(this, state, flags) } -inline fun BlockPos.updateState(world: World, expectedBlock: Block, stateMapper: (IBlockState) -> IBlockState): Boolean{ - val currentState = this.getState(world) - return currentState.block === expectedBlock && this.setState(world, stateMapper(currentState)) -} - -inline fun BlockPos.updateState(world: World, expectedBlock: Block, flags: Int, stateMapper: (IBlockState) -> IBlockState): Boolean{ - val currentState = this.getState(world) - return currentState.block === expectedBlock && this.setState(world, stateMapper(currentState), flags) -} - inline fun BlockPos.breakBlock(world: World, drops: Boolean): Boolean{ return world.destroyBlock(this, drops) }