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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class SimpleSkinSwapperConfig {
@JvmField
var pauseMenuButtonSide: ButtonSide? = ButtonSide.RIGHT

@JvmField
var enableMovingLegs: Boolean = true

/** Non-null accessor for callers (e.g. Java mixins): defaults to RIGHT. */
fun titleScreenSide(): ButtonSide = titleScreenButtonSide ?: ButtonSide.RIGHT

Expand Down
18 changes: 12 additions & 6 deletions src/main/kotlin/fr/raconteur/simpleskinswapper/gui/SkinRenderer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import fr.raconteur.simpleskinswapper.SimpleSkinSwapperClient
import net.minecraft.client.gui.GuiGraphicsExtractor
import net.minecraft.client.renderer.entity.state.AvatarRenderState
import net.minecraft.client.renderer.state.gui.pip.GuiEntityRenderState
import net.minecraft.util.Mth
import net.minecraft.world.entity.Pose
import net.minecraft.world.entity.player.PlayerSkin
import org.joml.Quaternionf
Expand Down Expand Up @@ -103,25 +102,32 @@ object SkinRenderer {
context.disableScissor()
}

internal fun buildRenderState(skin: PlayerSkin): AvatarRenderState {
internal fun buildRenderState(
skin: PlayerSkin,
enableMovingLegs: Boolean = fr.raconteur.simpleskinswapper.config.SimpleSkinSwapperConfig.get().enableMovingLegs,
totalTickDelta: Float = SimpleSkinSwapperClient.TOTAL_TICK_DELTA): AvatarRenderState {
val s = AvatarRenderState()

s.boundingBoxWidth = 0.6F
s.boundingBoxHeight = 1.8F
s.eyeHeight = 1.62F
s.scale = 1.0F
s.ageScale = 1.0F
s.ageInTicks = SimpleSkinSwapperClient.TOTAL_TICK_DELTA
s.ageInTicks = totalTickDelta
s.id = 0

s.pose = Pose.STANDING
s.bodyRot = 180.0F
s.yRot = 0.0F
s.xRot = 0.0F

val t = SimpleSkinSwapperClient.TOTAL_TICK_DELTA * 0.067F
s.walkAnimationPos = Mth.sin(t.toDouble()).toFloat() * 0.05F
s.walkAnimationSpeed = 0.1F
// How fast should the legs swing?
val progressFactor = 0.12F
// How far should the legs swing?
val animationSpeed = 0.20F
s.walkAnimationPos = if (enableMovingLegs) totalTickDelta * progressFactor else 0.0F
s.walkAnimationSpeed = if (enableMovingLegs) animationSpeed else 0.0F

//? if <26.3
s.attackTime = 0.0F
s.swimAmount = 0.0F
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import dev.isxander.yacl3.api.ConfigCategory
import dev.isxander.yacl3.api.ListOption
import dev.isxander.yacl3.api.Option
import dev.isxander.yacl3.api.OptionDescription
import dev.isxander.yacl3.api.OptionGroup
import dev.isxander.yacl3.api.YetAnotherConfigLib
import dev.isxander.yacl3.api.controller.EnumControllerBuilder
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder
import fr.raconteur.simpleskinswapper.config.ButtonSide
import fr.raconteur.simpleskinswapper.config.ServerCommand
import fr.raconteur.simpleskinswapper.config.SimpleSkinSwapperConfig
Expand All @@ -27,6 +29,47 @@ object YaclConfigScreen {

return YetAnotherConfigLib.createBuilder()
.title(Component.translatable("simpleskinswapper.config.title"))
.category(
ConfigCategory.createBuilder()
.name(Component.translatable("simpleskinswapper.config.category.options"))
.group(
OptionGroup.createBuilder()
.name(Component.translatable("simpleskinswapper.config.group.menu_buttons"))
.option(
buttonSideOption(
"simpleskinswapper.config.title_screen_button_side",
{ config.titleScreenSide() },
{ config.titleScreenButtonSide = it }
)
)
.option(
buttonSideOption(
"simpleskinswapper.config.pause_menu_button_side",
{ config.pauseMenuSide() },
{ config.pauseMenuButtonSide = it }
)
)
.build()
)
.group(
OptionGroup.createBuilder()
.name(Component.translatable("simpleskinswapper.config.group.player_models"))
.option(
Option.createBuilder<Boolean>()
.name(Component.translatable("simpleskinswapper.config.enable_moving_legs"))
.description(OptionDescription.of(Component.translatable("simpleskinswapper.config.enable_moving_legs.description")))
.binding(
true,
{ config.enableMovingLegs },
{ config.enableMovingLegs = it }
)
.controller { option -> TickBoxControllerBuilder.create(option) }
.build()
)
.build()
)
.build()
)
.category(
ConfigCategory.createBuilder()
.name(Component.translatable("simpleskinswapper.config.category.servers"))
Expand All @@ -49,25 +92,6 @@ object YaclConfigScreen {
)
.build()
)
.category(
ConfigCategory.createBuilder()
.name(Component.translatable("simpleskinswapper.config.category.menu_buttons"))
.option(
buttonSideOption(
"simpleskinswapper.config.title_screen_button_side",
{ config.titleScreenSide() },
{ config.titleScreenButtonSide = it }
)
)
.option(
buttonSideOption(
"simpleskinswapper.config.pause_menu_button_side",
{ config.pauseMenuSide() },
{ config.pauseMenuButtonSide = it }
)
)
.build()
)
.save {
config.applyServerCommandList(staged)
SimpleSkinSwapperConfig.save()
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/assets/simpleskinswapper/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
"simpleskinswapper.config.server_address.hint": "server address",
"simpleskinswapper.config.server_command": "Server command",
"simpleskinswapper.config.server_command.hint": "/command",
"simpleskinswapper.config.category.menu_buttons": "Menu buttons",
"simpleskinswapper.config.category.options": "Options",
"simpleskinswapper.config.group.menu_buttons": "Menu buttons",
"simpleskinswapper.config.title_screen_button_side": "Title screen button side",
"simpleskinswapper.config.title_screen_button_side.description": "Side of the Options/Quit row on which the skin preview button appears on the title screen.",
"simpleskinswapper.config.pause_menu_button_side": "Pause menu button side",
"simpleskinswapper.config.pause_menu_button_side.description": "Side of the Disconnect button on which the skin preview button appears in the pause menu.",
"simpleskinswapper.config.button_side.left": "Left",
"simpleskinswapper.config.button_side.right": "Right",
"simpleskinswapper.config.group.player_models": "Player models",
"simpleskinswapper.config.enable_moving_legs": "Enable moving legs",
"simpleskinswapper.config.enable_moving_legs.description": "Enables moving legs on the player models in the menus.",

"simpleskinswapper.message.applying": "Applying skin...",
"simpleskinswapper.message.success": "Skin applied successfully!",
Expand Down