Skip to content

Commit 434e9b7

Browse files
committed
init: add files
0 parents  commit 434e9b7

28 files changed

+891
-0
lines changed

.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
build/
2+
*.ipr
3+
run/
4+
*.iws
5+
out/
6+
*.iml
7+
.gradle/
8+
output/
9+
bin/
10+
libs/
11+
12+
.classpath
13+
.project
14+
.idea/
15+
classes/
16+
.metadata
17+
.vscode
18+
.settings
19+
*.launch

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# 🐢 Take it Slow
2+
3+
A Fabric/Quilt/Forge mod that disables sprinting and, optionally, swimming
4+
5+
Who needed sprinting anyways?
6+
7+
### Dependencies
8+
- Cloth Config v6
9+
- (Optional, Fabric/Quilt) Mod Menu
10+
11+
*Mod icon taken from Twemoji under the [Creative Commons Attribution 4.0 International license](https://github.com/twitter/twemoji/blob/master/LICENSE-GRAPHICS)*

build.gradle

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
plugins {
2+
id "architectury-plugin" version "3.4-SNAPSHOT"
3+
id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false
4+
}
5+
6+
architectury {
7+
minecraft = rootProject.minecraft_version
8+
}
9+
10+
subprojects {
11+
apply plugin: "dev.architectury.loom"
12+
13+
loom {
14+
silentMojangMappingsLicense()
15+
}
16+
17+
dependencies {
18+
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
19+
// The following line declares the mojmap mappings, you may use other mappings as well
20+
mappings loom.officialMojangMappings()
21+
// The following line declares the yarn mappings you may select this one as well.
22+
// mappings "net.fabricmc:yarn:1.18.2+build.3:v2"
23+
}
24+
}
25+
26+
allprojects {
27+
apply plugin: "java"
28+
apply plugin: "architectury-plugin"
29+
apply plugin: "maven-publish"
30+
31+
archivesBaseName = rootProject.archives_base_name
32+
version = rootProject.mod_version
33+
group = rootProject.maven_group
34+
35+
repositories {
36+
// Add repositories to retrieve artifacts from in here.
37+
// You should only use this when depending on other mods because
38+
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
39+
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
40+
// for more information about repositories.
41+
maven {
42+
url "https://maven.terraformersmc.com/"
43+
}
44+
}
45+
46+
tasks.withType(JavaCompile) {
47+
options.encoding = "UTF-8"
48+
options.release = 17
49+
}
50+
51+
java {
52+
withSourcesJar()
53+
}
54+
}

common/build.gradle

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
architectury {
2+
common(rootProject.enabled_platforms.split(","))
3+
}
4+
5+
loom {
6+
7+
}
8+
9+
dependencies {
10+
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
11+
// Do NOT use other classes from fabric loader
12+
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
13+
modImplementation "me.shedaniel.cloth:cloth-config:${rootProject.cloth_version}"
14+
}
15+
16+
publishing {
17+
publications {
18+
mavenCommon(MavenPublication) {
19+
artifactId = rootProject.archives_base_name
20+
from components.java
21+
}
22+
}
23+
24+
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
25+
repositories {
26+
// Add repositories to publish to here.
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package dev.igalaxy.takeitslow;
2+
3+
import dev.igalaxy.takeitslow.config.TakeItSlowConfig;
4+
import me.shedaniel.autoconfig.AutoConfig;
5+
import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer;
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
8+
9+
public class TakeItSlow {
10+
private static final Logger logger = LoggerFactory.getLogger("Take It Slow");
11+
12+
public static void onInitialize() {
13+
AutoConfig.register(TakeItSlowConfig.class, JanksonConfigSerializer::new);
14+
15+
logger.info("Remember to take it slow!");
16+
}
17+
18+
public static TakeItSlowConfig getConfig() {
19+
return AutoConfig.getConfigHolder(TakeItSlowConfig.class).getConfig();
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package dev.igalaxy.takeitslow.config;
2+
3+
import me.shedaniel.autoconfig.ConfigData;
4+
import me.shedaniel.autoconfig.annotation.Config;
5+
import me.shedaniel.autoconfig.annotation.ConfigEntry;
6+
7+
@Config(name = "takeitslow")
8+
public class TakeItSlowConfig implements ConfigData {
9+
@ConfigEntry.Category("Movement")
10+
public boolean allowSwimming = true;
11+
12+
@ConfigEntry.Category("Movement")
13+
public boolean allowCreative = true;
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package dev.igalaxy.takeitslow.mixin;
2+
3+
import dev.igalaxy.takeitslow.TakeItSlow;
4+
import net.minecraft.client.Minecraft;
5+
import net.minecraft.client.player.LocalPlayer;
6+
import net.minecraft.world.level.GameType;
7+
import org.spongepowered.asm.mixin.Final;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.Shadow;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.ModifyVariable;
13+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
14+
15+
@Mixin(LocalPlayer.class)
16+
public abstract class LocalPlayerMixin {
17+
@Shadow @Final protected Minecraft minecraft;
18+
@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+
}
34+
35+
@Inject(method = "updateIsUnderwater", at = @At("TAIL"))
36+
private void modifyUpdateIsUnderwater(CallbackInfoReturnable<Boolean> cir) {
37+
GameType localPlayerMode = ((MultiPlayerGameModeAccessor)this.minecraft.gameMode).getLocalPlayerMode();
38+
39+
boolean isUnderwater = this.isUnderWater();
40+
boolean isCreative = localPlayerMode == GameType.CREATIVE;
41+
boolean isSpectator = localPlayerMode == GameType.SPECTATOR;
42+
43+
if (!isUnderwater && !isCreative && !isSpectator) {
44+
this.setSprinting(false);
45+
}
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.igalaxy.takeitslow.mixin;
2+
3+
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
4+
import net.minecraft.world.level.GameType;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.gen.Accessor;
7+
8+
@Mixin(MultiPlayerGameMode.class)
9+
public interface MultiPlayerGameModeAccessor {
10+
@Accessor
11+
GameType getLocalPlayerMode();
12+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"text.autoconfig.takeitslow.title": "Take it Slow Config",
3+
"text.autoconfig.takeitslow.option.allowSwimming": "Allow Swimming",
4+
"text.autoconfig.takeitslow.option.allowCreative": "Allow in Creative/Spectator Mode"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"required": true,
3+
"package": "dev.igalaxy.takeitslow.mixin",
4+
"compatibilityLevel": "JAVA_16",
5+
"client": [
6+
"LocalPlayerMixin",
7+
"MultiPlayerGameModeAccessor"
8+
],
9+
"mixins": [
10+
],
11+
"injectors": {
12+
"defaultRequire": 1
13+
}
14+
}

fabric/build.gradle

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
plugins {
2+
id "com.github.johnrengelman.shadow" version "7.1.2"
3+
}
4+
5+
architectury {
6+
platformSetupLoomIde()
7+
fabric()
8+
}
9+
10+
configurations {
11+
common
12+
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
13+
compileClasspath.extendsFrom common
14+
runtimeClasspath.extendsFrom common
15+
developmentFabric.extendsFrom common
16+
}
17+
18+
dependencies {
19+
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
20+
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
21+
22+
common(project(path: ":common", configuration: "namedElements")) { transitive false }
23+
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
24+
25+
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}") { exclude module: "fabric-api" }
26+
modImplementation("com.terraformersmc:modmenu:3.+")
27+
}
28+
29+
processResources {
30+
inputs.property "version", project.version
31+
32+
filesMatching("fabric.mod.json") {
33+
expand "version": project.version
34+
}
35+
}
36+
37+
shadowJar {
38+
exclude "architectury.common.json"
39+
40+
configurations = [project.configurations.shadowCommon]
41+
classifier "dev-shadow"
42+
}
43+
44+
remapJar {
45+
input.set shadowJar.archiveFile
46+
dependsOn shadowJar
47+
classifier null
48+
}
49+
50+
jar {
51+
classifier "dev"
52+
}
53+
54+
sourcesJar {
55+
def commonSources = project(":common").sourcesJar
56+
dependsOn commonSources
57+
from commonSources.archiveFile.map { zipTree(it) }
58+
}
59+
60+
components.java {
61+
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
62+
skip()
63+
}
64+
}
65+
66+
publishing {
67+
publications {
68+
mavenFabric(MavenPublication) {
69+
artifactId = rootProject.archives_base_name + "-" + project.name
70+
from components.java
71+
}
72+
}
73+
74+
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
75+
repositories {
76+
// Add repositories to publish to here.
77+
}
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package dev.igalaxy.takeitslow.fabric;
2+
3+
import dev.igalaxy.takeitslow.TakeItSlow;
4+
import net.fabricmc.api.ModInitializer;
5+
6+
public class FabricEntrypoint implements ModInitializer {
7+
@Override
8+
public void onInitialize() {
9+
TakeItSlow.onInitialize();
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package dev.igalaxy.takeitslow.fabric;
2+
3+
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
4+
import com.terraformersmc.modmenu.api.ModMenuApi;
5+
import dev.igalaxy.takeitslow.config.TakeItSlowConfig;
6+
import me.shedaniel.autoconfig.AutoConfig;
7+
8+
public class ModMenuIntegration implements ModMenuApi {
9+
@Override
10+
public ConfigScreenFactory<?> getModConfigScreenFactory() {
11+
return parent -> AutoConfig.getConfigScreen(TakeItSlowConfig.class, parent).get();
12+
}
13+
}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"schemaVersion": 1,
3+
"id": "takeitslow",
4+
"version": "${version}",
5+
"name": "Take it Slow",
6+
"description": "Who needs sprinting anyways?",
7+
"authors": [
8+
"iGalaxy"
9+
],
10+
"contact": {
11+
"homepage": "https://github.com/iGalaxyYT/take-it-slow",
12+
"sources": "https://github.com/iGalaxyYT/take-it-slow"
13+
},
14+
"license": "MIT",
15+
"icon": "assets/takeitslow/icon.png",
16+
"environment": "*",
17+
"entrypoints": {
18+
"main": [
19+
"dev.igalaxy.takeitslow.fabric.FabricEntrypoint"
20+
],
21+
"modmenu": [
22+
"dev.igalaxy.takeitslow.fabric.ModMenuIntegration"
23+
]
24+
},
25+
"mixins": [
26+
"takeitslow.mixins.json",
27+
"takeitslow-common.mixins.json"
28+
],
29+
"depends": {
30+
"fabric": "*",
31+
"minecraft": ">=1.18.2",
32+
"java": ">=17",
33+
"cloth-config2": ">=6.0.0"
34+
},
35+
"suggests": {
36+
"modmenu": ">=3.0.0"
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"required": true,
3+
"package": "dev.igalaxy.takeitslow.fabric.mixin",
4+
"compatibilityLevel": "JAVA_16",
5+
"client": [
6+
],
7+
"mixins": [
8+
],
9+
"injectors": {
10+
"defaultRequire": 1
11+
}
12+
}

0 commit comments

Comments
 (0)