generated from Legacy-Fabric/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
97 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
if [[ -z "$RUNCOMMAND" ]]; then | ||
echo "RUNCOMMAND is not set" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$RUNDIR" ]]; then | ||
echo "RUNDIR is not set" | ||
exit 1 | ||
fi | ||
|
||
echo "copying files" | ||
cp "sanitycheck.jar" "$RUNDIR/mods/sanitycheck.jar" | ||
|
||
$RUNCOMMAND | ||
|
||
if [[ $? -ne 0 ]]; then | ||
echo "command failed" | ||
exit 1 | ||
fi | ||
|
||
if [[ -e "$RUNDIR/sane" ]]; then | ||
echo "sane file exists" | ||
exit 0 | ||
else | ||
echo "sane file does not exist" | ||
exit 1 | ||
fi |
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/main/java/net/fabricmc/example/mixin/ExampleMixin.java
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
src/main/java/net/legacyfabric/sanitychecker/SanityChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.legacyfabric.sanitychecker; | ||
|
||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
|
||
public class SanityChecker | ||
{ | ||
public static void markSane() | ||
{ | ||
Path runDir = FabricLoader.getInstance().getGameDir(); | ||
Path target = runDir.resolve("sane"); | ||
try { | ||
Files.createFile(target); | ||
} catch (IOException e) { | ||
// what | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/net/legacyfabric/sanitychecker/mixin/TitleScreenMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.legacyfabric.sanitychecker.mixin; | ||
|
||
import net.legacyfabric.sanitychecker.SanityChecker; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.TitleScreen; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(TitleScreen.class) | ||
public class TitleScreenMixin | ||
{ | ||
@Unique | ||
private static long initialTime; | ||
|
||
@Inject(at = @At("TAIL"), method = "render") | ||
private void init(CallbackInfo info) | ||
{ | ||
if (initialTime == 0) | ||
{ | ||
initialTime = System.currentTimeMillis(); | ||
} | ||
|
||
long currentTime = System.currentTimeMillis(); | ||
long timeElapsed = currentTime - initialTime; | ||
|
||
if (timeElapsed > 5000) | ||
{ | ||
System.out.println("sane"); | ||
SanityChecker.markSane(); | ||
MinecraftClient.getInstance().scheduleStop(); | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "modid", | ||
"version": "${version}", | ||
"name": "Example Mod", | ||
"description": "This is an example description! Tell everyone what your mod is about!", | ||
"authors": [ | ||
"Me!" | ||
], | ||
"contact": { | ||
"homepage": "https://legacyfabric.net/", | ||
"sources": "https://github.com/Legacy-Fabric/fabric-example-mod" | ||
}, | ||
"license": "CC0-1.0", | ||
"icon": "assets/modid/icon.png", | ||
"environment": "*", | ||
"entrypoints": { | ||
"main": [ | ||
"net.fabricmc.example.ExampleMod" | ||
] | ||
}, | ||
"id": "sanitychecker", | ||
"version": "1.0.0", | ||
"mixins": [ | ||
"modid.mixins.json" | ||
"sanitychecker.mixins.json" | ||
], | ||
"depends": { | ||
"fabricloader": ">=0.14.19", | ||
"minecraft": "1.8.9" | ||
}, | ||
"suggests": { | ||
"another-mod": "*" | ||
"minecraft": ">=1.3.2" | ||
} | ||
} |
6 changes: 2 additions & 4 deletions
6
src/main/resources/modid.mixins.json → src/main/resources/sanitychecker.mixins.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters