Skip to content

Commit

Permalink
Release mod version 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matshou committed May 26, 2020
2 parents 00aecbf + c2b4b68 commit 34e7eff
Show file tree
Hide file tree
Showing 25 changed files with 622 additions and 148 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ build
eclipse
run

# package
*.jar

# log
*.log

Expand Down
1 change: 1 addition & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/copyright/GPL.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 94 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,111 @@
# Tickrate Changer Mod
# TimeLib
[![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)

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.
TimeLib is a Minecraft modding library for Forge that lets you control game time.

## Where do I download it?
## Motivation

- Check the [releases](https://github.com/yooksi/trcm/releases) section in project repository page to get the latest release.
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.

## How do I install it?
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.

- 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.
## Features

- Allows you to set game tick rate resulting in slower or faster movements and animations
including all mobs and players, but does not affect the camera.

- Allows you to set time cycle speed and control how fast days and nights last.

## Where to get it?

Each repository production and maven artifacts release contains three `jar` types that you can download:

- `-dev.jar` is a non-obfuscated version of the jar used by developers.
- `-sources.jar` contains project source files used by developers.
- `-.jar` is an obfuscated production-ready jar mostly used by players.

**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.

**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).

### Maven

TimeLib is hosted on [JitPack](https://jitpack.io/#yooksi/TimeLib) so head over there and get the latest release.

Here is the **recommended** way of getting the library in your project:

```groovy
// Definines where Gradle should look for declared dependencies
// Declare this AFTER the buildscript block (first script block)
// and BEFORE MinecraftForge Gradle plugin configuration
repositories {
...
maven { url 'https://jitpack.io' }
}
minecraft {
...
}
dependencies {
// Specify the version of Minecraft to use
minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}"
// We need to compile with the api but don't need it during runtime
compileOnly "com.github.yooksi:TimeLib:${timeLibVersion}:api"
// We need the main jar during runtime but not when compiling
runtimeOnly "com.github.yooksi:TimeLib:${timeLibVersion}:dev"
}
```

*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.*

The example above would attempt to resolve the following artifacts from Jitpack:

- 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.

- *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.

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.

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.

### Github

This is the **recommended** way to obtain the production jar for library users.
*Developers should only use this way if JitPack is not working or they feel adventurous.*

Check the [releases](https://github.com/yooksi/TimeLib/releases) section in project repository page to get the latest release.

## How to install it?

- Make sure you have a backward compatible Forge [version](https://github.com/yooksi/trcm/blob/master/gradle.properties#L11) installed.
- Place the mod `jar` in game `mods` folder as per standard mod installation.
- 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.
- 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.

### Why do I need an external mod?

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).
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.

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).

## How do I use it?
## How to use it?

Tick rate is changed through the use of the following game commands:
### Commands

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

## Technical details

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:
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.

- 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.
- 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.
Expand All @@ -50,4 +130,4 @@ The steps above slow down server tick rate but unfortunately result in frame ski

- [Unregkiller](https://github.com/Unregkiller) - for commissioning the creation of this mod.
- [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.
- [MDC](https://www.moddevcafe.com/) and [MMD](https://discordapp.com/invite/EDbExcX) communities - for helping resolve technical issues.
- [MDC](https://www.moddevcafe.com/), [MMD](https://discordapp.com/invite/EDbExcX) and [Mixin](https://discord.gg/sponge) community- for helping resolve technical issues.
120 changes: 82 additions & 38 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,50 @@ buildscript {
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true

// https://github.com/SpongePowered/MixinGradle
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.spongepowered.mixin'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'java-library'

apply plugin: 'org.spongepowered.mixin'

version = "${minecraftVersion}-${modVersion}"
group = "io.${groupName}.${modId}"
group = "io.${groupName}"
archivesBaseName = project.modId

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

repositories {
mavenCentral()
maven { url 'https://repo.spongepowered.org/maven' }
maven {
name "lxgaming"
url "https://dl.bintray.com/lxgaming/maven"
}
maven { url 'https://jitpack.io' }
}

sourceSets {
main { ext.refMap = "main.refmap.json" }
api {
java { srcDir('src/api/java') }
}
main {
java {
compileClasspath += api.output
runtimeClasspath += api.output
}
}
}

// Define which sourceSets will be covered by mixin refmap
mixin {
add sourceSets.main, "mixins.${modId}.refmap.json"
}

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

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

dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft "net.minecraftforge:forge:${minecraftVersion}-${forgeVersion}"

// https://github.com/SpongePowered/Mixin
compile "org.spongepowered:mixin:0.8.1-SNAPSHOT"
implementation "com.github.LXGaming:MixinBootstrap:v${mixinBootstrapVer}"

implementation sourceSets.api.output
}

// Get properties into the manifest for reading by the runtime..
final def jarAttributes = [
"Specification-Title": project.modId,
"Specification-Vendor": "${groupName}",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor": "${groupName}",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs": "${modId}.mixins.json"
]

jar {
manifest {
attributes([
"Specification-Title": project.modId,
"Specification-Vendor": "${groupName}",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor": "${groupName}",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
])
}
from sourceSets.api.output
from sourceSets.main.output
manifest { attributes(jarAttributes) }
}

// Example configuration to allow publishing using the maven-publish task
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')

// API jar for library consumers
task apiJar(type: Jar, dependsOn: classes) {
baseName = project.modId
classifier = 'api'
from sourceSets.api.output
}
apiJar.finalizedBy('reobfJar')

// Non-obfuscated jar for developers
task devJar(type: Jar, dependsOn: classes) {
baseName = project.modId
classifier = 'dev'
from sourceSets.api.output
from sourceSets.main.output
exclude("mixins.${modId}.refmap.json")
manifest { attributes(jarAttributes) }
}

// Generate sources when building mod
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
build.dependsOn sourcesJar

artifacts {
archives sourcesJar, devJar, apiJar
}

publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
mavenJava(MavenPublication) {
artifact apiJar
}
mavenJava(MavenPublication) {
artifact devJar
}
mavenJava(MavenPublication) {
artifact sourcesJar
}
}
repositories {
maven {
Expand All @@ -111,17 +166,6 @@ publishing {
}
}

// Generate sources when building mod
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
build.dependsOn sourcesJar

artifacts {
archives sourcesJar
}

// Process resources on build and make sure that variables are
// correctly inserted into mods.toml when the mod is built or run
processResources {
Expand Down
8 changes: 3 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

modId=timelib
modVersion=0.1.1
modVersion=0.2.0
groupName=yooksi

minecraftVersion=1.15.2
forgeVersion=31.1.46
forgeVersion=31.2.0
mappingMCVersion=1.15.1
mappingBuild=20200225

mixinBootstrapVer=1.0.2
mappingBuild=20200515
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = "TimeLib"
rootProject.name = "timelib"
Loading

0 comments on commit 34e7eff

Please sign in to comment.