Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix call of setValue instead of setSliderValue in ExtendedSlider #1919

Open
wants to merge 1 commit into
base: 1.21.x
Choose a base branch
from

Conversation

Matyrobbrt
Copy link
Member

Fixes #1891

@Matyrobbrt Matyrobbrt added bug A bug or error 1.21.4 Targeted at Minecraft 1.21.4 labels Jan 26, 2025
@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Jan 26, 2025

  • Publish PR to GitHub Packages

Last commit published: 9ddf4dd33e8064500a2bd02eedad74efaf6af44a.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #1919' // https://github.com/neoforged/NeoForge/pull/1919
        url 'https://prmaven.neoforged.net/NeoForge/pr1919'
        content {
            includeModule('net.neoforged', 'neoforge')
            includeModule('net.neoforged', 'testframework')
        }
    }
}

MDK installation

In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr1919.
On Powershell you will need to remove the -L flag from the curl invocation.

mkdir NeoForge-pr1919
cd NeoForge-pr1919
curl -L https://prmaven.neoforged.net/NeoForge/pr1919/net/neoforged/neoforge/21.4.78-beta-pr-1919-fixslidervalue/mdk-pr1919.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip

To test a production environment, you can download the installer from here.

@KnightMiner
Copy link
Contributor

Why are there two such similarly named methods? Is this a mojang problem or a Neo one?

@ChampionAsh5357
Copy link
Contributor

This whole class is just confusing since half seems replicated from vanilla due to the internal private methods. From what I understand, value is a number between 0 and 1 used to represent the scroll amount of the slider. setValue, which is used only in keyPressed, basically takes in the raw external number and converts it into a percentage to stick into value. setSliderValue, on the other hand, takes in the percentage and updates accordingly.

Now, what does that mean about changing setValue to setSliderValue? Well, if we look at the logic passed in, getValue returns the actual number instead of the percentage, which is then moved by some step size. So, changing that to setSliderValue will just have the bar snap around incorrectly.

The proper fix seems to be just having setValue internally delegate to setSliderValue with the value converted to a percentage. Of course, I think the entire class should be rewritten to something a bit more sane and renamed to something less confusing than value, but I digress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.4 Targeted at Minecraft 1.21.4 bug A bug or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ExtendedSlider calls wrong method when using arrow keys and stepSize > 0
3 participants