Class ForgeSlider
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.AbstractSliderButton
net.minecraftforge.client.gui.widget.ForgeSlider
- All Implemented Interfaces:
- GuiEventListener,- Renderable,- TabOrderedElement,- LayoutElement,- NarratableEntry,- NarrationSupplier
Slider widget implementation which allows inputting values in a certain range with optional step size.
- 
Nested Class SummaryNested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntryNarratableEntry.NarrationPriority
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanprivate final DecimalFormatprotected doubleprotected doubleprotected Componentprotected doubleAllows input of discontinuous values with a certain stepprotected ComponentFields inherited from class net.minecraft.client.gui.components.AbstractSliderButtonTEXT_MARGIN, valueFields inherited from class net.minecraft.client.gui.components.AbstractWidgetactive, alpha, height, isHovered, packedFGColor, UNSET_FG_COLOR, visible, widthFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListenerDOUBLE_CLICK_THRESHOLD_MS
- 
Constructor SummaryConstructorsConstructorDescriptionForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, boolean drawString) Overload withstepSizeset to 1, useful for sliders with whole number values.ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected voiddoublegetValue()intlongbooleankeyPressed(int keyCode, int scanCode, int modifiers) voidonClick(double mouseX, double mouseY) protected voidonDrag(double mouseX, double mouseY, double dragX, double dragY) voidrenderWidget(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick) private voidsetSliderValue(double value) voidsetValue(double value) private voidsetValueFromMouse(double mouseX) private doublesnapToNearest(double value) Snaps the value, so that the displayed value is the nearest multiple ofstepSize.protected voidMethods inherited from class net.minecraft.client.gui.components.AbstractSliderButtoncreateNarrationMessage, getHandleSprite, getSprite, onRelease, playDownSound, setFocused, updateWidgetNarrationMethods inherited from class net.minecraft.client.gui.components.AbstractWidgetclearFGColor, clicked, createTooltipPositioner, defaultButtonNarrationText, getFGColor, getHeight, getMessage, getRectangle, getTabOrderGroup, getTooltip, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isMouseOver, isValidClickButton, mouseClicked, mouseDragged, mouseReleased, narrationPriority, nextFocusPath, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setHeight, setMessage, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessageMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListenercharTyped, getCurrentFocusPath, keyReleased, mouseMoved, mouseScrolledMethods inherited from interface net.minecraft.client.gui.layouts.LayoutElementsetPosition
- 
Field Details- 
prefix
- 
suffix
- 
minValueprotected double minValue
- 
maxValueprotected double maxValue
- 
stepSizeprotected double stepSizeAllows input of discontinuous values with a certain step
- 
drawStringprotected boolean drawString
- 
format
 
- 
- 
Constructor Details- 
ForgeSliderpublic ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, double stepSize, int precision, boolean drawString) - Parameters:
- x- x position of upper left corner
- y- y position of upper left corner
- width- Width of the widget
- height- Height of the widget
- prefix-- Componentdisplayed before the value string
- suffix-- Componentdisplayed after the value string
- minValue- Minimum (left) value of slider
- maxValue- Maximum (right) value of slider
- currentValue- Starting value when widget is first displayed
- stepSize- Size of step used. Precision will automatically be calculated based on this value if this value is not 0.
- precision- Only used when- stepSizeis 0. Limited to a maximum of 4 (inclusive).
- drawString- Should text be displayed on the widget
 
- 
ForgeSliderpublic ForgeSlider(int x, int y, int width, int height, Component prefix, Component suffix, double minValue, double maxValue, double currentValue, boolean drawString) Overload withstepSizeset to 1, useful for sliders with whole number values.
 
- 
- 
Method Details- 
getValuepublic double getValue()- Returns:
- Current slider value as a double
 
- 
getValueLongpublic long getValueLong()- Returns:
- Current slider value as an long
 
- 
getValueIntpublic int getValueInt()- Returns:
- Current slider value as an int
 
- 
setValuepublic void setValue(double value) - Parameters:
- value- The new slider value
 
- 
getValueString
- 
onClickpublic void onClick(double mouseX, double mouseY) - Overrides:
- onClickin class- AbstractSliderButton
 
- 
onDragprotected void onDrag(double mouseX, double mouseY, double dragX, double dragY) - Overrides:
- onDragin class- AbstractSliderButton
 
- 
keyPressedpublic boolean keyPressed(int keyCode, int scanCode, int modifiers) - Specified by:
- keyPressedin interface- GuiEventListener
- Overrides:
- keyPressedin class- AbstractSliderButton
 
- 
setValueFromMouseprivate void setValueFromMouse(double mouseX) 
- 
setSliderValueprivate void setSliderValue(double value) - Parameters:
- value- Percentage of slider range
 
- 
snapToNearestprivate double snapToNearest(double value) Snaps the value, so that the displayed value is the nearest multiple ofstepSize. IfstepSizeis 0, no snapping occurs.
- 
updateMessageprotected void updateMessage()- Specified by:
- updateMessagein class- AbstractSliderButton
 
- 
applyValueprotected void applyValue()- Specified by:
- applyValuein class- AbstractSliderButton
 
- 
renderWidget- Overrides:
- renderWidgetin class- AbstractSliderButton
 
 
-