1
0
mirror of https://github.com/chylex/Hardcore-Ender-Expansion-2.git synced 2025-03-16 11:15:42 +01:00

Remove unused code & minor refactoring

This commit is contained in:
chylex 2019-10-16 17:08:44 +02:00
parent f0ce92a9f4
commit 6915d4a14e
8 changed files with 11 additions and 32 deletions
src/main/java/chylex/hee

View File

@ -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

View File

@ -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
}
}

View File

@ -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)
)

View File

@ -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(

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)
}