Skip to content

Commit a20e9ee

Browse files
committed
Update to work with 1.15
1 parent 45edb2f commit a20e9ee

9 files changed

Lines changed: 136 additions & 128 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ right. Currently it works perfectly for my needs using a Logitech Mouse.
2020

2121
Using MultiMC - all that's required is to:
2222

23-
- Use Minecraft 1.14.4
23+
- Download hscroll-1.0.1.jar from the [Releases Page](https://github.com/andyvanee/hscroll/releases)
24+
- Use Minecraft 1.15
2425
- `Edit Instance`
2526
- `Install Fabric`
26-
- Add hscroll-1.0.0.jar to 'Loader Mods'
27+
- Add hscroll-1.0.1.jar to 'Loader Mods'
2728

2829
## Build
2930

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '0.2.5-SNAPSHOT'
2+
id 'fabric-loom' version '0.2.6-SNAPSHOT'
33
id 'maven-publish'
44
}
55

@@ -16,7 +16,7 @@ minecraft {
1616
dependencies {
1717
//to change the versions see the gradle.properties file
1818
minecraft "com.mojang:minecraft:${project.minecraft_version}"
19-
mappings "net.fabricmc:yarn:${project.yarn_mappings}"
19+
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
2020
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
2121

2222
// Fabric API. This is technically optional, but you probably want it anyway.

gradle.properties

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/use
6-
minecraft_version=1.14.4
7-
yarn_mappings=1.14.4+build.12
8-
loader_version=0.6.1+build.164
9-
6+
minecraft_version=1.15
7+
yarn_mappings=1.15+build.2
8+
loader_version=0.7.2+build.175
109
# Mod Properties
11-
mod_version = 1.0.0
10+
mod_version = 1.0.1
1211
maven_group = net.fabricmc
1312
archives_base_name = hscroll
1413

1514
# Dependencies
1615
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
17-
fabric_version=0.3.2+build.218-1.14
16+
fabric_version=0.4.25+build.282-1.15
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 100 additions & 100 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hscroll-1.0.0.jar

-8.2 KB
Binary file not shown.

src/main/java/net/fabricmc/andyvanee/mixin/MinecraftClientMixin.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,31 @@
77
import org.spongepowered.asm.mixin.injection.At;
88
import org.spongepowered.asm.mixin.injection.Inject;
99
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
10+
import net.minecraft.client.util.Window;
1011

1112
@Mixin(MinecraftClient.class)
1213
public class MinecraftClientMixin {
1314
private MinecraftClient client;
1415
private double eventDeltaWheel;
16+
private boolean mixinConfigured;
1517

16-
@Inject(at = @At("RETURN"), method = "init")
18+
@Inject(at = @At("RETURN"), method = "openScreen")
1719
private void init(CallbackInfo info) {
18-
this.client = MinecraftClient.getInstance();
19-
this.eventDeltaWheel = 0.0D;
20-
// Override MC scroll callback with our own
21-
GLFW.glfwSetScrollCallback(this.client.window.getHandle(), this::onMouseScroll);
20+
if (!mixinConfigured) {
21+
this.client = MinecraftClient.getInstance();
22+
this.eventDeltaWheel = 0.0D;
23+
// Override MC scroll callback with our own
24+
GLFW.glfwSetScrollCallback(this.client.getWindow().getHandle(), this::onMouseScroll);
25+
}
26+
mixinConfigured = true;
2227
}
2328

2429
private void onMouseScroll(long window, double xoffset, double yoffset) {
2530
// TODO: implement these as minecraft settings?
2631
boolean translateHorizontalScroll = true;
2732
double horizontalScrollSensitivity = 1.0D;
2833

29-
if (window == MinecraftClient.getInstance().window.getHandle()) {
34+
if (window == MinecraftClient.getInstance().getWindow().getHandle()) {
3035
double delta;
3136

3237
if (translateHorizontalScroll) {
@@ -42,11 +47,13 @@ private void onMouseScroll(long window, double xoffset, double yoffset) {
4247
}
4348

4449
if (this.client.overlay == null) {
50+
Window clientWindow = MinecraftClient.getInstance().getWindow();
51+
4552
if (this.client.currentScreen != null) {
46-
double xposition = this.client.mouse.getX() * (double) this.client.window.getScaledWidth()
47-
/ (double) this.client.window.getWidth();
48-
double yposition = this.client.mouse.getY() * (double) this.client.window.getScaledHeight()
49-
/ (double) this.client.window.getHeight();
53+
double xposition = this.client.mouse.getX() * (double) clientWindow.getScaledWidth()
54+
/ (double) clientWindow.getWidth();
55+
double yposition = this.client.mouse.getY() * (double) clientWindow.getScaledHeight()
56+
/ (double) clientWindow.getHeight();
5057
this.client.currentScreen.mouseScrolled(xposition, yposition, delta);
5158
} else if (this.client.player != null) {
5259
if (this.eventDeltaWheel != 0.0D && Math.signum(delta) != Math.signum(this.eventDeltaWheel)) {
@@ -61,13 +68,13 @@ private void onMouseScroll(long window, double xoffset, double yoffset) {
6168

6269
this.eventDeltaWheel -= (double) currentWheelDelta;
6370
if (this.client.player.isSpectator()) {
64-
if (this.client.inGameHud.getSpectatorWidget().method_1980()) {
65-
this.client.inGameHud.getSpectatorWidget().method_1976((double) (-currentWheelDelta));
71+
if (this.client.inGameHud.getSpectatorHud().isOpen()) {
72+
this.client.inGameHud.getSpectatorHud().cycleSlot((double) (-currentWheelDelta));
6673
} else {
67-
float float_2 = MathHelper.clamp(
74+
float j = MathHelper.clamp(
6875
this.client.player.abilities.getFlySpeed() + currentWheelDelta * 0.005F, 0.0F,
6976
0.2F);
70-
this.client.player.abilities.setFlySpeed(float_2);
77+
this.client.player.abilities.setFlySpeed(j);
7178
}
7279
} else {
7380
this.client.player.inventory.scrollInHotbar((double) currentWheelDelta);

src/main/resources/fabric.mod.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"mixins": ["hscroll.mixins.json"],
2222

2323
"depends": {
24-
"fabricloader": ">=0.4.0"
24+
"fabricloader": ">=0.7.2",
25+
"minecraft": "1.15.x"
2526
},
2627
"suggests": {
2728
"flamingo": "*"

0 commit comments

Comments
 (0)