Skip to content

Commit 34e7eff

Browse files
committed
Release mod version 0.2.0
2 parents 00aecbf + c2b4b68 commit 34e7eff

25 files changed

+622
-148
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ build
2020
eclipse
2121
run
2222

23-
# package
24-
*.jar
25-
2623
# log
2724
*.log
2825

.idea/.gitignore

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

.idea/copyright/GPL.xml

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

.idea/copyright/profiles_settings.xml

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

README.md

Lines changed: 94 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,111 @@
1-
# Tickrate Changer Mod
1+
# TimeLib
2+
[![JitPack](https://jitpack.io/v/yooksi/TimeLib.svg)](https://jitpack.io/#yooksi/TimeLib) [![License](https://img.shields.io/github/license/yooksi/TimeLib)](https://www.gnu.org/licenses/) [![Discord](https://img.shields.io/discord/710517912485494794)](https://discord.gg/dKY9xW)
23

3-
This is a Forge mod for Mincraft version 1.15 that lets you slow down time making everything in your environment move slower. This includes all game animations (including the player), but does not affect the camera.
4+
TimeLib is a Minecraft modding library for Forge that lets you control game time.
45

5-
## Where do I download it?
6+
## Motivation
67

7-
- Check the [releases](https://github.com/yooksi/trcm/releases) section in project repository page to get the latest release.
8+
Time is a very powerful game aspect that is often neglected. Changing how time behaves has the potential to dramatically alter game experience. For example, longer days and night could give players a greater sense of adventure by promoting immersion over fast-paced action, slow-motion effects applied in critical moments of battle could create a great feeling of excitement.
89

9-
## How do I install it?
10+
Through the use of Mixin and a simple to use API to configure various time related settings TimeLib gives developers the tools they need to create game changing mods.
1011

11-
- Make sure you have the appropriate Forge [version](https://github.com/yooksi/trcm/blob/master/gradle.properties#L9)-[build](https://github.com/yooksi/trcm/blob/master/gradle.properties#L10) installed.
12+
## Features
13+
14+
- Allows you to set game tick rate resulting in slower or faster movements and animations
15+
including all mobs and players, but does not affect the camera.
16+
17+
- Allows you to set time cycle speed and control how fast days and nights last.
18+
19+
## Where to get it?
20+
21+
Each repository production and maven artifacts release contains three `jar` types that you can download:
22+
23+
- `-dev.jar` is a non-obfuscated version of the jar used by developers.
24+
- `-sources.jar` contains project source files used by developers.
25+
- `-.jar` is an obfuscated production-ready jar mostly used by players.
26+
27+
**Developers** will want either the dev or production jar (optionally) accompanied by sources jar to make reading and understanding the library code easier when working with their mods.
28+
29+
**Players** will want only the production jar found in the repository release section on [Github](#github) which they should treat as a standard game mod (see [installation](#how-to-install-it) section for more information).
30+
31+
### Maven
32+
33+
TimeLib is hosted on [JitPack](https://jitpack.io/#yooksi/TimeLib) so head over there and get the latest release.
34+
35+
Here is the **recommended** way of getting the library in your project:
36+
37+
```groovy
38+
// Definines where Gradle should look for declared dependencies
39+
// Declare this AFTER the buildscript block (first script block)
40+
// and BEFORE MinecraftForge Gradle plugin configuration
41+
repositories {
42+
...
43+
maven { url 'https://jitpack.io' }
44+
}
45+
46+
minecraft {
47+
...
48+
}
49+
50+
dependencies {
51+
// Specify the version of Minecraft to use
52+
minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}"
53+
54+
// We need to compile with the api but don't need it during runtime
55+
compileOnly "com.github.yooksi:TimeLib:${timeLibVersion}:api"
56+
// We need the main jar during runtime but not when compiling
57+
runtimeOnly "com.github.yooksi:TimeLib:${timeLibVersion}:dev"
58+
}
59+
```
60+
61+
*Note that the `timeLibVersion` property in this example was defined in `gradle.properties` to make accessing and reading version numbers easier. You should update the property (or just replace the variable) to a fully qualified version of the library you want to use.*
62+
63+
The example above would attempt to resolve the following artifacts from Jitpack:
64+
65+
- API library module for other mods to interact with. We need this jar when we are writing and compiling our mod so we use the `compileOnly` strategy. It is also needed during runtime but it's already included in the dev jar which is on runtime classpath.
66+
67+
- *Deobfuscated* version of our mod built for use by developers (indicated by the `dev` classifier). The dependency will be exposed only during runtime because we added it to `runtimeOnly` configuration.
68+
69+
Another way to get the library would be to use `fg.deobf` right after declaring the configuration type to indicate that the production jar should be deobfuscated after being resolved.
70+
71+
This is not necessary and just adds extra work during build phase and makes deal with manually attaching source files. This is why the project provides a compiled `dev` jar.
72+
73+
### Github
74+
75+
This is the **recommended** way to obtain the production jar for library users.
76+
*Developers should only use this way if JitPack is not working or they feel adventurous.*
77+
78+
Check the [releases](https://github.com/yooksi/TimeLib/releases) section in project repository page to get the latest release.
79+
80+
## How to install it?
81+
82+
- Make sure you have a backward compatible Forge [version](https://github.com/yooksi/trcm/blob/master/gradle.properties#L11) installed.
1283
- Place the mod `jar` in game `mods` folder as per standard mod installation.
13-
- Download the appropriate MixinBootstrap [version](https://github.com/yooksi/trcm/blob/master/gradle.properties#L13) from the [releases](https://github.com/LXGaming/MixinBootstrap/releases) section of the project repository page and place it in game `mods` folder alongside the mod `jar` as instructed by the previous step.
84+
- Download a backward compatible [version](https://github.com/yooksi/trcm/blob/master/gradle.properties#L15) of MixinBootstrap from the [releases](https://github.com/LXGaming/MixinBootstrap/releases) section of the project repository page and place it in game `mods` folder alongside the mod `jar` as previously instructed.
1485

1586
### Why do I need an external mod?
1687

17-
Due to the nature of how Forge works Mixin needs a bit of help to work in production environment with Forge. MixinBootstrap does just that, it's only function is to enable Mixin to work with Forge, that's it. If you are interested in learning more about Mixin environment read [Introduction to Mixins: The Mixin Environment](https://github.com/SpongePowered/Mixin/wiki/Introduction-to-Mixins---The-Mixin-Environment).
88+
Forge and [Mixin](https://github.com/SpongePowered/Mixin) are not compatible straight out of the box so they need a bit of help to work in production environment. MixinBootstrap does just that, it's only function is to enable Mixin to work with Forge, that's it.
89+
90+
If you are interested in learning more about Mixin environment read [Introduction to Mixins: The Mixin Environment](https://github.com/SpongePowered/Mixin/wiki/Introduction-to-Mixins---The-Mixin-Environment).
1891

19-
## How do I use it?
92+
## How to use it?
2093

21-
Tick rate is changed through the use of the following game commands:
94+
### Commands
2295

23-
- `\t <rate>` - change tick rate to a desired value (min 0.1, max 20).
24-
- `\t` - reset tick rate to game default value (20).
96+
- `\tickrate set <rate>` - change tick rate to a desired value (min 0.1, max 500).
97+
- `slow` - 50% slower tick rate (10).
98+
- `normal` - game default value (20).
99+
- `fast` - 50% faster tick rate (30).
100+
- `\tickrate reset` - resets tick rate to game default value (20).
101+
- `\timecycle speed <value>` - change the speed for day/night time cycle (min -72, max 72)
102+
- `slow` - skip 1 tick when updating day time (x2 longer cycle).
103+
- `normal` - do not skip ticks when updating day time (game default).
104+
- `fast` - add 1 additional tick when updating day time (x2 faster cycle).
25105

26106
## Technical details
27107

28-
The process used to accomplish this is complex and involves bytecode manipulation using [Mixin](https://github.com/SpongePowered/Mixin). The technical side of things can be difficult to understand if you are not familiar with [ASM](https://asm.ow2.io/), however this is the simple version of what happens inside the mod that allows us to slow down time:
108+
The following section is a brief technical explanation of how TimeLib is able to slow down game time. It is written in hopes that some developers might find it useful when learning to work with Mixin. Note that the process used to accomplish this involves bytecode manipulation and as such is not recommended as a starting point for beginners to learn about Java or Forge.
29109

30110
- During runtime Mixin will redirect method flow at a particular point in `MinecraftServer.run()` method and inject a callback to itself. The point of injection is the `while` loop that handles the server time calculation and determines when each tick should happen.
31111
- We then do a series of calculations and determine how much milliseconds passed this tick based on the `mspt` (milliseconds per tick) rate calculated from tick rate set by the player via game command.
@@ -50,4 +130,4 @@ The steps above slow down server tick rate but unfortunately result in frame ski
50130

51131
- [Unregkiller](https://github.com/Unregkiller) - for commissioning the creation of this mod.
52132
- [gnembon](https://github.com/gnembon) - for creating [Carpet](https://github.com/gnembon/fabric-carpet/blob/master/src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java) on which this mod is based of.
53-
- [MDC](https://www.moddevcafe.com/) and [MMD](https://discordapp.com/invite/EDbExcX) communities - for helping resolve technical issues.
133+
- [MDC](https://www.moddevcafe.com/), [MMD](https://discordapp.com/invite/EDbExcX) and [Mixin](https://discord.gg/sponge) community- for helping resolve technical issues.

build.gradle

Lines changed: 82 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,50 @@ buildscript {
77
}
88
dependencies {
99
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
10+
11+
// https://github.com/SpongePowered/MixinGradle
1012
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
1113
}
1214
}
1315
apply plugin: 'net.minecraftforge.gradle'
14-
apply plugin: 'org.spongepowered.mixin'
1516
apply plugin: 'eclipse'
17+
apply plugin: 'maven'
1618
apply plugin: 'maven-publish'
19+
apply plugin: 'java-library'
20+
21+
apply plugin: 'org.spongepowered.mixin'
1722

1823
version = "${minecraftVersion}-${modVersion}"
19-
group = "io.${groupName}.${modId}"
24+
group = "io.${groupName}"
2025
archivesBaseName = project.modId
2126

2227
// Need this here so eclipse task generates correctly.
2328
compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
2429
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility
2530

2631
repositories {
27-
mavenCentral()
2832
maven { url 'https://repo.spongepowered.org/maven' }
29-
maven {
30-
name "lxgaming"
31-
url "https://dl.bintray.com/lxgaming/maven"
32-
}
33-
maven { url 'https://jitpack.io' }
3433
}
3534

3635
sourceSets {
37-
main { ext.refMap = "main.refmap.json" }
36+
api {
37+
java { srcDir('src/api/java') }
38+
}
39+
main {
40+
java {
41+
compileClasspath += api.output
42+
runtimeClasspath += api.output
43+
}
44+
}
45+
}
46+
47+
// Define which sourceSets will be covered by mixin refmap
48+
mixin {
49+
add sourceSets.main, "mixins.${modId}.refmap.json"
3850
}
3951

4052
minecraft {
41-
// The mappings can be changed at any time, and must be in the following format.
42-
// snapshot_YYYYMMDD Snapshot are built nightly.
43-
// stable_# Stables are built at the discretion of the MCP team.
44-
// Use non-default mappings at your own risk. they may not always work.
53+
// The mappings can be changed at any time, use non-default mappings at your own risk.
4554
// Simply re-run your setup task after changing the mappings to update your workspace.
4655
mappings channel: 'snapshot', version: "${mappingBuild}-${mappingMCVersion}"
4756
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
@@ -61,6 +70,7 @@ minecraft {
6170
}
6271
server {
6372
workingDirectory project.file('run')
73+
arg "-mixin.config=" + archivesBaseName + ".mixins.json"
6474

6575
// Recommended logging data for a userdev environment
6676
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
@@ -74,35 +84,80 @@ minecraft {
7484
}
7585

7686
dependencies {
87+
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
88+
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
89+
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
7790
minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}"
91+
92+
// https://github.com/SpongePowered/Mixin
7893
compile "org.spongepowered:mixin:0.8.1-SNAPSHOT"
79-
implementation "com.github.LXGaming:MixinBootstrap:v${mixinBootstrapVer}"
94+
95+
implementation sourceSets.api.output
8096
}
8197

82-
// Get properties into the manifest for reading by the runtime..
98+
final def jarAttributes = [
99+
"Specification-Title": project.modId,
100+
"Specification-Vendor": "${groupName}",
101+
"Specification-Version": "1", // We are version 1 of ourselves
102+
"Implementation-Title": project.name,
103+
"Implementation-Version": "${version}",
104+
"Implementation-Vendor": "${groupName}",
105+
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
106+
"MixinConfigs": "${modId}.mixins.json"
107+
]
108+
83109
jar {
84-
manifest {
85-
attributes([
86-
"Specification-Title": project.modId,
87-
"Specification-Vendor": "${groupName}",
88-
"Specification-Version": "1", // We are version 1 of ourselves
89-
"Implementation-Title": project.name,
90-
"Implementation-Version": "${version}",
91-
"Implementation-Vendor": "${groupName}",
92-
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
93-
])
94-
}
110+
from sourceSets.api.output
111+
from sourceSets.main.output
112+
manifest { attributes(jarAttributes) }
95113
}
96-
97114
// Example configuration to allow publishing using the maven-publish task
98115
// This is the preferred method to reobfuscate your jar file
99116
jar.finalizedBy('reobfJar')
100117

118+
// API jar for library consumers
119+
task apiJar(type: Jar, dependsOn: classes) {
120+
baseName = project.modId
121+
classifier = 'api'
122+
from sourceSets.api.output
123+
}
124+
apiJar.finalizedBy('reobfJar')
125+
126+
// Non-obfuscated jar for developers
127+
task devJar(type: Jar, dependsOn: classes) {
128+
baseName = project.modId
129+
classifier = 'dev'
130+
from sourceSets.api.output
131+
from sourceSets.main.output
132+
exclude("mixins.${modId}.refmap.json")
133+
manifest { attributes(jarAttributes) }
134+
}
135+
136+
// Generate sources when building mod
137+
task sourcesJar(type: Jar, dependsOn: classes) {
138+
classifier = 'sources'
139+
from sourceSets.main.allSource
140+
}
141+
build.dependsOn sourcesJar
142+
143+
artifacts {
144+
archives sourcesJar, devJar, apiJar
145+
}
146+
101147
publishing {
102148
publications {
103149
mavenJava(MavenPublication) {
104150
artifact jar
105151
}
152+
mavenJava(MavenPublication) {
153+
artifact apiJar
154+
}
155+
mavenJava(MavenPublication) {
156+
artifact devJar
157+
}
158+
mavenJava(MavenPublication) {
159+
artifact sourcesJar
160+
}
106161
}
107162
repositories {
108163
maven {
@@ -111,17 +166,6 @@ publishing {
111166
}
112167
}
113168

114-
// Generate sources when building mod
115-
task sourcesJar(type: Jar, dependsOn: classes) {
116-
classifier = 'sources'
117-
from sourceSets.main.allSource
118-
}
119-
build.dependsOn sourcesJar
120-
121-
artifacts {
122-
archives sourcesJar
123-
}
124-
125169
// Process resources on build and make sure that variables are
126170
// correctly inserted into mods.toml when the mod is built or run
127171
processResources {

gradle.properties

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ org.gradle.jvmargs=-Xmx3G
44
org.gradle.daemon=false
55

66
modId=timelib
7-
modVersion=0.1.1
7+
modVersion=0.2.0
88
groupName=yooksi
99

1010
minecraftVersion=1.15.2
11-
forgeVersion=31.1.46
11+
forgeVersion=31.2.0
1212
mappingMCVersion=1.15.1
13-
mappingBuild=20200225
14-
15-
mixinBootstrapVer=1.0.2
13+
mappingBuild=20200515

gradle/wrapper/gradle-wrapper.jar

53.4 KB
Binary file not shown.

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = "TimeLib"
1+
rootProject.name = "timelib"

0 commit comments

Comments
 (0)