Skip to content

Commit

Permalink
feat: 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
wiidotmom committed Mar 19, 2023
1 parent b74cf99 commit 9658c6c
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dev.igalaxy.takeitslow.mixin;

import dev.igalaxy.takeitslow.TakeItSlow;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.GameType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(LivingEntity.class)
public class LivingEntityMixin {
@ModifyVariable(method = "setSprinting(Z)V", at = @At("HEAD"))
private boolean modifySetSprinting(boolean bl) {
if (((Object) this) instanceof LocalPlayer) {
LocalPlayer player = (LocalPlayer) (Object) this;

GameType localPlayerMode = ((LocalPlayerAccessor)player).getMinecraft().gameMode.getPlayerMode();

boolean allowSwimming = TakeItSlow.getConfig().allowSwimming;
boolean allowCreative = TakeItSlow.getConfig().allowCreative;

boolean isUnderwater = player.isUnderWater();
boolean isCreative = localPlayerMode == GameType.CREATIVE;
boolean isSpectator = localPlayerMode == GameType.SPECTATOR;

return (isUnderwater && bl && allowSwimming) || (isCreative && bl && allowCreative) || (isSpectator && bl && allowCreative);
}
return bl;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dev.igalaxy.takeitslow.mixin;

import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(LocalPlayer.class)
public interface LocalPlayerAccessor {
@Accessor
Minecraft getMinecraft();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dev.igalaxy.takeitslow.TakeItSlow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.GameType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -16,21 +17,6 @@
public abstract class LocalPlayerMixin {
@Shadow @Final protected Minecraft minecraft;
@Shadow public abstract boolean isUnderWater();
@Shadow public abstract void setSprinting(boolean bl);

@ModifyVariable(method = "setSprinting(Z)V", at = @At("HEAD"))
private boolean modifySetSprinting(boolean bl) {
GameType localPlayerMode = ((MultiPlayerGameModeAccessor)this.minecraft.gameMode).getLocalPlayerMode();

boolean allowSwimming = TakeItSlow.getConfig().allowSwimming;
boolean allowCreative = TakeItSlow.getConfig().allowCreative;

boolean isUnderwater = this.isUnderWater();
boolean isCreative = localPlayerMode == GameType.CREATIVE;
boolean isSpectator = localPlayerMode == GameType.SPECTATOR;

return (isUnderwater && bl && allowSwimming) || (isCreative && bl && allowCreative) || (isSpectator && bl && allowCreative);
}

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

if (!isUnderwater && !isCreative && !isSpectator) {
this.setSprinting(false);
((LivingEntity) (Object) this).setSprinting(false);
}
}
}
2 changes: 2 additions & 0 deletions common/src/main/resources/takeitslow-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"compatibilityLevel": "JAVA_16",
"client": [
"LocalPlayerMixin",
"LocalPlayerAccessor",
"LivingEntityMixin",
"MultiPlayerGameModeAccessor"
],
"mixins": [
Expand Down
6 changes: 3 additions & 3 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ Who needs sprinting anyways?
[[dependencies.takeitslow]]
modId = "forge"
mandatory = true
versionRange = "[41,)"
versionRange = "[45,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.takeitslow]]
modId = "minecraft"
mandatory = true
versionRange = "[1.19,)"
versionRange = "[1.19.4,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.takeitslow]]
modId = "cloth_config"
mandatory = true
versionRange = "[8,9)"
versionRange = "[10,11)"
ordering = "NONE"
side = "BOTH"
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
org.gradle.jvmargs=-Xmx2048M

minecraft_version=1.19
minecraft_version=1.19.4
enabled_platforms=fabric,forge

archives_base_name=take-it-slow
mod_version=1.0.3
mod_version=1.1.0
maven_group=dev.igalaxy.takeitslow

architectury_version=5.6.22
architectury_version=8.1.73

fabric_loader_version=0.14.7

forge_version=1.19-41.1.0
forge_version=1.19.4-45.0.9

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



0 comments on commit 9658c6c

Please sign in to comment.