Config test
This commit is contained in:
parent
ffb3d651b0
commit
bab6447a1d
@ -8,7 +8,9 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@ -87,6 +89,8 @@ public final class OverdriveThatMatters {
|
||||
modBus.addListener(EventPriority.HIGHEST, this::setup);
|
||||
modBus.addListener(EventPriority.NORMAL, this::setupClient);
|
||||
modBus.addListener(EventPriority.NORMAL, MatteryCapability::register);
|
||||
|
||||
ClientConfig.INSTANCE.register();
|
||||
}
|
||||
|
||||
private void setup(final FMLCommonSetupEvent event) {
|
||||
|
45
src/main/kotlin/ru/dbotthepony/mc/otm/MConfig.kt
Normal file
45
src/main/kotlin/ru/dbotthepony/mc/otm/MConfig.kt
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
@file:Suppress("ObjectPropertyName")
|
||||
|
||||
package ru.dbotthepony.mc.otm
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec
|
||||
import net.minecraftforge.common.ForgeConfigSpec.IntValue
|
||||
import net.minecraftforge.fml.ModLoadingContext
|
||||
import net.minecraftforge.fml.config.ModConfig
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
object ClientConfig {
|
||||
private val spec: ForgeConfigSpec
|
||||
private var registered = false
|
||||
|
||||
private val _exosuitInventoryRows: IntValue
|
||||
|
||||
init {
|
||||
val specBuilder = ForgeConfigSpec.Builder()
|
||||
specBuilder.comment("Clientside Config").push("client")
|
||||
|
||||
_exosuitInventoryRows = specBuilder
|
||||
.comment("Amount of inventory rows to show when wearing Exosuit")
|
||||
.defineInRange("exosuitInventoryRows", 3, 3, 6)
|
||||
|
||||
specBuilder.pop()
|
||||
spec = specBuilder.build()
|
||||
}
|
||||
|
||||
var exosuitInventoryRows: Int by _exosuitInventoryRows
|
||||
|
||||
fun register() {
|
||||
check(!registered) { "Already registered config" }
|
||||
registered = true
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, spec)
|
||||
}
|
||||
}
|
||||
|
||||
private operator fun <T> ForgeConfigSpec.ConfigValue<T>.setValue(config: ClientConfig, property: KProperty<*>, value: T) {
|
||||
set(value)
|
||||
}
|
||||
|
||||
private operator fun <T : Any> ForgeConfigSpec.ConfigValue<T>.getValue(config: Any, property: KProperty<*>): T {
|
||||
return get()
|
||||
}
|
@ -16,6 +16,7 @@ import net.minecraftforge.client.event.ContainerScreenEvent.Render.Foreground
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import org.lwjgl.opengl.GL11
|
||||
import org.lwjgl.opengl.GL13
|
||||
import ru.dbotthepony.mc.otm.ClientConfig
|
||||
import ru.dbotthepony.mc.otm.client.moveMousePosScaled
|
||||
import ru.dbotthepony.mc.otm.client.screen.panels.*
|
||||
import ru.dbotthepony.mc.otm.core.maxScrollDivision
|
||||
@ -552,6 +553,6 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
|
||||
const val MAX_ROWS = 6
|
||||
|
||||
var lastScroll = 0
|
||||
var lastRows = 3
|
||||
var lastRows by ClientConfig::exosuitInventoryRows
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user