Skip to content

Commit 9658c6c

Browse files
committed
feat: 1.19.4
1 parent b74cf99 commit 9658c6c

File tree

6 files changed

+56
-25
lines changed

6 files changed

+56
-25
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package dev.igalaxy.takeitslow.mixin;
2+
3+
import dev.igalaxy.takeitslow.TakeItSlow;
4+
import net.minecraft.client.player.LocalPlayer;
5+
import net.minecraft.world.entity.LivingEntity;
6+
import net.minecraft.world.level.GameType;
7+
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.injection.At;
9+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
10+
11+
@Mixin(LivingEntity.class)
12+
public class LivingEntityMixin {
13+
@ModifyVariable(method = "setSprinting(Z)V", at = @At("HEAD"))
14+
private boolean modifySetSprinting(boolean bl) {
15+
if (((Object) this) instanceof LocalPlayer) {
16+
LocalPlayer player = (LocalPlayer) (Object) this;
17+
18+
GameType localPlayerMode = ((LocalPlayerAccessor)player).getMinecraft().gameMode.getPlayerMode();
19+
20+
boolean allowSwimming = TakeItSlow.getConfig().allowSwimming;
21+
boolean allowCreative = TakeItSlow.getConfig().allowCreative;
22+
23+
boolean isUnderwater = player.isUnderWater();
24+
boolean isCreative = localPlayerMode == GameType.CREATIVE;
25+
boolean isSpectator = localPlayerMode == GameType.SPECTATOR;
26+
27+
return (isUnderwater && bl && allowSwimming) || (isCreative && bl && allowCreative) || (isSpectator && bl && allowCreative);
28+
}
29+
return bl;
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.igalaxy.takeitslow.mixin;
2+
3+
import net.minecraft.client.Minecraft;
4+
import net.minecraft.client.player.LocalPlayer;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Accessor;
7+
8+
@Mixin(LocalPlayer.class)
9+
public interface LocalPlayerAccessor {
10+
@Accessor
11+
Minecraft getMinecraft();
12+
}

common/src/main/java/dev/igalaxy/takeitslow/mixin/LocalPlayerMixin.java

+2-16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dev.igalaxy.takeitslow.TakeItSlow;
44
import net.minecraft.client.Minecraft;
55
import net.minecraft.client.player.LocalPlayer;
6+
import net.minecraft.world.entity.LivingEntity;
67
import net.minecraft.world.level.GameType;
78
import org.spongepowered.asm.mixin.Final;
89
import org.spongepowered.asm.mixin.Mixin;
@@ -16,21 +17,6 @@
1617
public abstract class LocalPlayerMixin {
1718
@Shadow @Final protected Minecraft minecraft;
1819
@Shadow public abstract boolean isUnderWater();
19-
@Shadow public abstract void setSprinting(boolean bl);
20-
21-
@ModifyVariable(method = "setSprinting(Z)V", at = @At("HEAD"))
22-
private boolean modifySetSprinting(boolean bl) {
23-
GameType localPlayerMode = ((MultiPlayerGameModeAccessor)this.minecraft.gameMode).getLocalPlayerMode();
24-
25-
boolean allowSwimming = TakeItSlow.getConfig().allowSwimming;
26-
boolean allowCreative = TakeItSlow.getConfig().allowCreative;
27-
28-
boolean isUnderwater = this.isUnderWater();
29-
boolean isCreative = localPlayerMode == GameType.CREATIVE;
30-
boolean isSpectator = localPlayerMode == GameType.SPECTATOR;
31-
32-
return (isUnderwater && bl && allowSwimming) || (isCreative && bl && allowCreative) || (isSpectator && bl && allowCreative);
33-
}
3420

3521
@Inject(method = "updateIsUnderwater", at = @At("TAIL"))
3622
private void modifyUpdateIsUnderwater(CallbackInfoReturnable<Boolean> cir) {
@@ -41,7 +27,7 @@ private void modifyUpdateIsUnderwater(CallbackInfoReturnable<Boolean> cir) {
4127
boolean isSpectator = localPlayerMode == GameType.SPECTATOR;
4228

4329
if (!isUnderwater && !isCreative && !isSpectator) {
44-
this.setSprinting(false);
30+
((LivingEntity) (Object) this).setSprinting(false);
4531
}
4632
}
4733
}

common/src/main/resources/takeitslow-common.mixins.json

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"compatibilityLevel": "JAVA_16",
55
"client": [
66
"LocalPlayerMixin",
7+
"LocalPlayerAccessor",
8+
"LivingEntityMixin",
79
"MultiPlayerGameModeAccessor"
810
],
911
"mixins": [

forge/src/main/resources/META-INF/mods.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ Who needs sprinting anyways?
1616
[[dependencies.takeitslow]]
1717
modId = "forge"
1818
mandatory = true
19-
versionRange = "[41,)"
19+
versionRange = "[45,)"
2020
ordering = "NONE"
2121
side = "BOTH"
2222

2323
[[dependencies.takeitslow]]
2424
modId = "minecraft"
2525
mandatory = true
26-
versionRange = "[1.19,)"
26+
versionRange = "[1.19.4,)"
2727
ordering = "NONE"
2828
side = "BOTH"
2929

3030
[[dependencies.takeitslow]]
3131
modId = "cloth_config"
3232
mandatory = true
33-
versionRange = "[8,9)"
33+
versionRange = "[10,11)"
3434
ordering = "NONE"
3535
side = "BOTH"

gradle.properties

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
org.gradle.jvmargs=-Xmx2048M
22

3-
minecraft_version=1.19
3+
minecraft_version=1.19.4
44
enabled_platforms=fabric,forge
55

66
archives_base_name=take-it-slow
7-
mod_version=1.0.3
7+
mod_version=1.1.0
88
maven_group=dev.igalaxy.takeitslow
99

10-
architectury_version=5.6.22
10+
architectury_version=8.1.73
1111

1212
fabric_loader_version=0.14.7
1313

14-
forge_version=1.19-41.1.0
14+
forge_version=1.19.4-45.0.9
1515

16-
cloth_version = 8.+
17-
modmenu_version = 4.0.4
16+
cloth_version = 10.+
17+
modmenu_version = 6.1.0-rc.4
1818

1919

2020

0 commit comments

Comments
 (0)