Skip to content

Commit

Permalink
Fix scrolling in dialogue screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Oct 28, 2023
1 parent 739e233 commit 50ba619
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import org.ladysnake.blabber.Blabber;
Expand Down Expand Up @@ -177,11 +178,11 @@ private void onBigChoiceMade(boolean yes) {

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
this.scrollDialogueChoice(verticalAmount);
this.scrollDialogueChoice(MathHelper.clamp(verticalAmount, -1.0, 1.0));
return true;
}

private void scrollDialogueChoice(double scrollAmount) {
protected void scrollDialogueChoice(double scrollAmount) {
ImmutableList<AvailableChoice> availableChoices = this.handler.getAvailableChoices();
if (!availableChoices.isEmpty()) {
this.selectedChoice = Math.floorMod((int) (this.selectedChoice - scrollAmount), availableChoices.size());
Expand Down

0 comments on commit 50ba619

Please sign in to comment.