Skip to content

Commit

Permalink
Adjust scrolling code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrbysco committed Nov 25, 2024
1 parent a47af67 commit 5cd7b3d
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import net.minecraft.world.entity.decoration.ArmorStand;
import net.minecraft.world.phys.Vec3;

import java.util.Locale;

public class ArmorStandScreen extends Screen {
private static final WidgetSprites MIRROR_POSE_SPRITES = new WidgetSprites(
ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "widget/mirror_pose"), ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "widget/mirror_pose_highlighted")
Expand Down Expand Up @@ -641,7 +643,7 @@ public boolean mouseScrolled(double mouseX, double mouseY, double xScroll, doubl
if (allowScrolling && yScroll > 0) {
//Add 1 to the value
if (rotationTextField.canConsumeInput()) {
float nextValue = (rotationTextField.getFloat() + multiplier * rotationTextField.scrollMultiplier) % rotationTextField.modValue;
int nextValue = (int) (rotationTextField.getFloat() + (1 * multiplier));
rotationTextField.setValue(String.valueOf(nextValue));
rotationTextField.setCursorPosition(0);
rotationTextField.setHighlightPos(0);
Expand Down Expand Up @@ -670,7 +672,7 @@ public boolean mouseScrolled(double mouseX, double mouseY, double xScroll, doubl
} else if (allowScrolling && yScroll < 0) {
//Remove 1 to the value
if (rotationTextField.canConsumeInput()) {
float previousValue = (rotationTextField.getFloat() - multiplier * rotationTextField.scrollMultiplier) % rotationTextField.modValue;
int previousValue = (int) (rotationTextField.getFloat() - (1 * multiplier));
rotationTextField.setValue(String.valueOf(previousValue));
rotationTextField.setCursorPosition(0);
rotationTextField.setHighlightPos(0);
Expand Down Expand Up @@ -798,12 +800,12 @@ protected CompoundTag writeFieldsToNBT() {
poseTag.put("RightArm", poseRightArmTag);


var offsetX = this.poseTextFields[18].getFloat();
var offsetY = this.poseTextFields[19].getFloat();
var offsetZ = this.poseTextFields[20].getFloat();
var offsetXDiff = offsetX - this.lastSendOffset.x;
var offsetYDiff = offsetY - this.lastSendOffset.y;
var offsetZDiff = offsetZ - this.lastSendOffset.z;
float offsetX = this.poseTextFields[18].getFloat();
float offsetY = this.poseTextFields[19].getFloat();
float offsetZ = this.poseTextFields[20].getFloat();
double offsetXDiff = offsetX - this.lastSendOffset.x;
double offsetYDiff = offsetY - this.lastSendOffset.y;
double offsetZDiff = offsetZ - this.lastSendOffset.z;
ListTag positionOffset = new ListTag();
positionOffset.add(DoubleTag.valueOf(offsetXDiff));
positionOffset.add(DoubleTag.valueOf(offsetYDiff));
Expand Down

0 comments on commit 5cd7b3d

Please sign in to comment.