Skip to content

Commit

Permalink
style: update to new spotless requirements for my poor code
Browse files Browse the repository at this point in the history
  • Loading branch information
SirEdvin committed Aug 20, 2024
1 parent 9df8dd6 commit e830127
Show file tree
Hide file tree
Showing 37 changed files with 280 additions and 277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import site.siredvin.turtlematic.xplat.TurtlematicCommonHooks
object TurtlematicCore {
const val MOD_ID = "turtlematic"

var LOGGER: Logger = LogManager.getLogger(MOD_ID)
var logger: Logger = LogManager.getLogger(MOD_ID)

fun configureCreativeTab(builder: CreativeModeTab.Builder): CreativeModeTab.Builder {
return builder.icon { Items.AUTOMATA_CORE.get().defaultInstance }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,31 @@ object TurtlematicCoreClient {
consumer.accept(
TurtleUpgradeSerializers.TURTLE_CHATTER.get(),
TurtleUpgradeModeller.sided(
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${TurtleChatterPeripheral.UPGRADE_ID.path}_left"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${TurtleChatterPeripheral.UPGRADE_ID.path}_right"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${TurtleChatterPeripheral.upgradeID.path}_left"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${TurtleChatterPeripheral.upgradeID.path}_right"),
),
)

consumer.accept(
TurtleUpgradeSerializers.MIMIC.get(),
TurtleUpgradeModeller.sided(
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${MimicPeripheral.UPGRADE_ID.path}_left"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${MimicPeripheral.UPGRADE_ID.path}_right"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${MimicPeripheral.upgradeID.path}_left"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${MimicPeripheral.upgradeID.path}_right"),
),
)

consumer.accept(
TurtleUpgradeSerializers.CREATIVE_CHEST.get(),
TurtleUpgradeModeller.sided(
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${CreativeChestPeripheral.UPGRADE_ID.path}_left"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${CreativeChestPeripheral.UPGRADE_ID.path}_right"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${CreativeChestPeripheral.upgradeID.path}_left"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${CreativeChestPeripheral.upgradeID.path}_right"),
),
)
consumer.accept(
TurtleUpgradeSerializers.CHUNK_VIAL.get(),
TurtleUpgradeModeller.sided(
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${ChunkVialPeripheral.UPGRADE_ID.path}_left"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${ChunkVialPeripheral.UPGRADE_ID.path}_right"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${ChunkVialPeripheral.upgradeID.path}_left"),
ResourceLocation(TurtlematicCore.MOD_ID, "turtle/${ChunkVialPeripheral.upgradeID.path}_right"),
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import site.siredvin.turtlematic.TurtlematicCore
import site.siredvin.turtlematic.util.camelToSnakeCase

interface PeripheralConfiguration {
val TYPE: String
val UPGRADE_ID: ResourceLocation
get() = ResourceLocation(TurtlematicCore.MOD_ID, TYPE.camelToSnakeCase())
val type: String
val upgradeID: ResourceLocation
get() = ResourceLocation(TurtlematicCore.MOD_ID, type.camelToSnakeCase())
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import net.minecraftforge.common.ForgeConfigSpec
import site.siredvin.turtlematic.common.configuration.TurtlematicConfig.CommonConfig

object ConfigHolder {
var COMMON_SPEC: ForgeConfigSpec
var COMMON_CONFIG: CommonConfig
var commonConfigSpec: ForgeConfigSpec
var commonConfig: CommonConfig

init {
val (key, value) = ForgeConfigSpec.Builder()
.configure { builder: ForgeConfigSpec.Builder -> CommonConfig(builder) }
COMMON_CONFIG = key
COMMON_SPEC = value
commonConfig = key
commonConfigSpec = value
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ enum class CountOperation(
;

enum class CountPolicy(private val factorFunction: Function<Int, Int>) {
MULTIPLY(Function { c: Int -> c }), IGNORE(Function { 1 });
MULTIPLY(Function { c: Int -> c }),
IGNORE(Function { 1 }),
;

fun getFactor(count: Int): Int {
return factorFunction.apply(count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum class PowerOperation(
THROW_POTION(1_000, 10, ScalePolicy.EXP),
SHOOT(1_000, 10, ScalePolicy.EXP),
;

enum class ScalePolicy(private val factorFunction: Function<Double, Double>) {
EXP({ d: Double -> kotlin.math.exp(d) }),
;
Expand All @@ -32,7 +33,7 @@ enum class PowerOperation(

override fun getCost(context: PowerOperationContext): Int {
val fullCost = (cost!!.get() * scalePolicy.getFactor(context.power)).toInt()
TurtlematicCore.LOGGER.info("Real cost $fullCost")
TurtlematicCore.logger.info("Real cost $fullCost")
return (cost!!.get() * scalePolicy.getFactor(context.power)).toInt()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@ enum class SphereOperation(
;

private var cooldown: ForgeConfigSpec.IntValue? = null
private var max_free_radius: ForgeConfigSpec.IntValue? = null
private var max_cost_radius: ForgeConfigSpec.IntValue? = null
private var extra_block_cost: ForgeConfigSpec.DoubleValue? = null
private var maxFreeRadiusConfig: ForgeConfigSpec.IntValue? = null
private var maxCostRadiusConfig: ForgeConfigSpec.IntValue? = null
private var extraBlockCostConfig: ForgeConfigSpec.DoubleValue? = null
override fun addToConfig(builder: ForgeConfigSpec.Builder) {
cooldown = builder.defineInRange(
settingsName() + "Cooldown",
defaultCooldown,
1000,
Int.MAX_VALUE,
)
max_free_radius = builder.defineInRange(
maxFreeRadiusConfig = builder.defineInRange(
settingsName() + "MaxFreeRadius",
defaultMaxFreeRadius,
1,
64,
)
max_cost_radius = builder.defineInRange(
maxCostRadiusConfig = builder.defineInRange(
settingsName() + "MaxCostRadius",
defaultMaxCostRadius,
1,
64,
)
extra_block_cost = builder.defineInRange(
extraBlockCostConfig = builder.defineInRange(
settingsName() + "ExtraBlockCost",
defaultExtraBlockCost,
0.1,
Expand All @@ -52,25 +52,25 @@ enum class SphereOperation(
}

override fun getCost(context: SphereOperationContext): Int {
if (context.radius <= max_free_radius!!.get()) return 0
val freeBlockCount = IntMath.pow(2 * max_free_radius!!.get() + 1, 3)
if (context.radius <= maxFreeRadiusConfig!!.get()) return 0
val freeBlockCount = IntMath.pow(2 * maxFreeRadiusConfig!!.get() + 1, 3)
val allBlockCount = IntMath.pow(2 * context.radius + 1, 3)
return Math.floor((allBlockCount - freeBlockCount) * extra_block_cost!!.get()).toInt()
return Math.floor((allBlockCount - freeBlockCount) * extraBlockCostConfig!!.get()).toInt()
}

val maxFreeRadius: Int
get() = max_free_radius!!.get()
get() = maxFreeRadiusConfig!!.get()
val maxCostRadius: Int
get() = max_cost_radius!!.get()
get() = maxCostRadiusConfig!!.get()

override fun computerDescription(): Map<String, Any> {
val data: MutableMap<String, Any> = HashMap()
data["name"] = settingsName()
data["type"] = javaClass.name
data["cooldown"] = cooldown!!.get()
data["maxFreeRadius"] = max_free_radius!!.get()
data["maxCostRadius"] = max_cost_radius!!.get()
data["extraBlockCost"] = extra_block_cost!!.get()
data["maxFreeRadius"] = maxFreeRadiusConfig!!.get()
data["maxCostRadius"] = maxCostRadiusConfig!!.get()
data["extraBlockCost"] = extraBlockCostConfig!!.get()
return data
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AutomataCorePeripheral(
side: TurtleSide,
tier: IAutomataCoreTier,
) : BaseAutomataCorePeripheral(
TYPE,
type,
turtle,
side,
tier,
Expand All @@ -36,7 +36,7 @@ class AutomataCorePeripheral(
}

companion object : PeripheralConfiguration {
override val TYPE = "automata"
override val type = "automata"
}

override val isEnabled: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EndAutomataCorePeripheral(
side: TurtleSide,
tier: IAutomataCoreTier,
) : BaseAutomataCorePeripheral(
TYPE,
type,
turtle,
side,
tier,
Expand All @@ -37,7 +37,7 @@ class EndAutomataCorePeripheral(
}

companion object : PeripheralConfiguration {
override val TYPE = "endAutomata"
override val type = "endAutomata"
}

override val isEnabled: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EnormousAutomataCorePeripheral(
side: TurtleSide,
tier: IAutomataCoreTier,
) : BaseAutomataCorePeripheral(
TYPE,
type,
turtle,
side,
tier,
Expand Down Expand Up @@ -51,7 +51,7 @@ class EnormousAutomataCorePeripheral(
}

companion object : PeripheralConfiguration {
override val TYPE = "enormousAutomata"
override val type = "enormousAutomata"
}

override val isEnabled: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class HusbandryAutomataCorePeripheral(
side: TurtleSide,
tier: IAutomataCoreTier,
) : BaseAutomataCorePeripheral(
TYPE,
type,
turtle,
side,
tier,
Expand Down Expand Up @@ -75,7 +75,7 @@ class HusbandryAutomataCorePeripheral(
}

companion object : PeripheralConfiguration {
override val TYPE = "husbandryAutomata"
override val type = "husbandryAutomata"
val isAnimal =
Predicate { entity1: Entity ->
entity1.type.category.isFriendly || entity1.type.category == MobCategory.CREATURE || entity1.type.`is`(EntityTags.ANIMAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ProtectiveAutomataCorePeripheral(
side: TurtleSide,
tier: IAutomataCoreTier,
) : BaseAutomataCorePeripheral(
TYPE,
type,
turtle,
side,
tier,
Expand Down Expand Up @@ -53,7 +53,7 @@ class ProtectiveAutomataCorePeripheral(
}

companion object : PeripheralConfiguration {
override val TYPE = "protectiveAutomata"
override val type = "protectiveAutomata"
private val isLivingEntity =
Predicate { entity1: Entity? -> entity1 is LivingEntity }
private val isNotPlayer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ import site.siredvin.turtlematic.util.TurtleDispenseBehavior
import java.util.function.Predicate

class BrewingAutomataCorePeripheral(turtle: ITurtleAccess, side: TurtleSide, tier: IAutomataCoreTier) :
ExperienceAutomataCorePeripheral(TYPE, turtle, side, tier) {
ExperienceAutomataCorePeripheral(type, turtle, side, tier) {

companion object : PeripheralConfiguration {
override val TYPE = "brewingAutomata"
override val type = "brewingAutomata"
private val suitableEntity: Predicate<Entity> = Predicate<Entity> { entity: Entity -> entity is ZombieVillager }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import site.siredvin.turtlematic.tags.BlockTags
import kotlin.math.max

open class EnchantingAutomataCorePeripheral(turtle: ITurtleAccess, side: TurtleSide, tier: IAutomataCoreTier) :
ExperienceAutomataCorePeripheral(TYPE, turtle, side, tier) {
ExperienceAutomataCorePeripheral(type, turtle, side, tier) {
companion object : PeripheralConfiguration {
override val TYPE = "enchantingAutomata"
override val type = "enchantingAutomata"

private const val MAX_ENCHANTMENT_LEVEL = 30
}
Expand All @@ -49,7 +49,9 @@ open class EnchantingAutomataCorePeripheral(turtle: ITurtleAccess, side: TurtleS
}
return storedEnchantmentSeed
}
set(value) { storedEnchantmentSeed = value }
set(value) {
storedEnchantmentSeed = value
}

override val peripheralConfiguration: MutableMap<String, Any>
get() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import site.siredvin.turtlematic.computercraft.plugins.AutomataLookPlugin
import java.util.function.Predicate

class MasonAutomataCorePeripheral(turtle: ITurtleAccess, side: TurtleSide, tier: IAutomataCoreTier) :
ExperienceAutomataCorePeripheral(TYPE, turtle, side, tier) {
ExperienceAutomataCorePeripheral(type, turtle, side, tier) {

interface MasonRecipeHandler {
fun getAlternatives(level: Level, fakeContainer: Container): List<ItemStack>
Expand Down Expand Up @@ -100,7 +100,7 @@ class MasonAutomataCorePeripheral(turtle: ITurtleAccess, side: TurtleSide, tier:
}

companion object : PeripheralConfiguration {
override val TYPE = "masonAutomata"
override val type = "masonAutomata"

private val HANDLERS = mutableMapOf<String, MasonRecipeHandler>()
private val RECIPE_TO_ID = mutableMapOf<Class<*>, String>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MercantileAutomataCorePeripheral(
side: TurtleSide,
tier: IAutomataCoreTier,
) : ExperienceAutomataCorePeripheral(
TYPE,
type,
turtle,
side,
tier,
Expand Down Expand Up @@ -70,7 +70,7 @@ class MercantileAutomataCorePeripheral(
}

companion object : PeripheralConfiguration {
override val TYPE = "mercantileAutomata"
override val type = "mercantileAutomata"

private val isMerchant =
Predicate { entity1: Entity -> entity1 is Merchant }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ import java.util.*
import kotlin.math.min

class SmithingAutomataCorePeripheral(turtle: ITurtleAccess, side: TurtleSide, tier: IAutomataCoreTier) :
ExperienceAutomataCorePeripheral(TYPE, turtle, side, tier) {
ExperienceAutomataCorePeripheral(type, turtle, side, tier) {

companion object : PeripheralConfiguration {
override val TYPE = "smithingAutomata"
override val type = "smithingAutomata"
}

override val isEnabled: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import site.siredvin.turtlematic.util.TurtleDispenseBehavior
import java.util.*

class BowPeripheral(turtle: ITurtleAccess, side: TurtleSide) :
OwnedPeripheral<TurtlePeripheralOwner>(TYPE, TurtlePeripheralOwner(turtle, side)) {
OwnedPeripheral<TurtlePeripheralOwner>(type, TurtlePeripheralOwner(turtle, side)) {

companion object : PeripheralConfiguration {
override val TYPE = "bow"
override val type = "bow"
}

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import site.siredvin.turtlematic.util.ChunkManager
import java.util.*

class ChunkVialPeripheral(peripheralOwner: TurtlePeripheralOwner) :
OwnedPeripheral<TurtlePeripheralOwner>(TYPE, peripheralOwner) {
OwnedPeripheral<TurtlePeripheralOwner>(type, peripheralOwner) {
companion object : PeripheralConfiguration {
override val TYPE = "chunk_vial"
override val type = "chunk_vial"
private const val UUID_TAG = "uuid"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import site.siredvin.turtlematic.common.configuration.TurtlematicConfig
import java.util.Optional

class CreativeChestPeripheral(turtle: ITurtleAccess, side: TurtleSide) :
OwnedPeripheral<TurtlePeripheralOwner>(TYPE, TurtlePeripheralOwner(turtle, side)) {
OwnedPeripheral<TurtlePeripheralOwner>(type, TurtlePeripheralOwner(turtle, side)) {

companion object : PeripheralConfiguration {
override val TYPE = "creative_chest"
override val type = "creative_chest"
}

override val isEnabled: Boolean
Expand Down
Loading

0 comments on commit e830127

Please sign in to comment.