Skip to content

Commit

Permalink
1.0.2 make the mod not affect single player
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Dec 23, 2021
1 parent c4a65ac commit a36ffdd
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 87 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Basic time changer mod for Minecraft Forge 1.8.9 that doesn't suck

## Difference:

Disables on Singleplayer (messes up mob spawning)

Doesn't mess up Singleplayer (hopefully)
Doesn't overwrite the getTime method (messes up other mods and debug info)
Doesn't replace the entire NetHandler

## Features:

Expand Down
32 changes: 16 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import net.minecraftforge.gradle.user.TaskSingleReobf
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.6.0"
kotlin("jvm") version "1.6.10"
id("net.minecraftforge.gradle.forge") version "6f5327"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("org.spongepowered.mixin") version "d5f9873d60"
java
}

version = "1.0.1"
version = "1.0.2"
group = "mynameisjeff.simpletimechanger"

minecraft {
Expand Down Expand Up @@ -67,13 +67,8 @@ dependencies {
annotationProcessor("org.spongepowered:mixin:0.7.11-SNAPSHOT")
implementation("org.spongepowered:mixin:0.7.11-SNAPSHOT")

shadowMe("gg.essential:loader-launchwrapper:1.1.2")
implementation("gg.essential:essential-1.8.9-forge:1579") {
exclude(module = "asm")
exclude(module = "asm-commons")
exclude(module = "asm-tree")
exclude(module = "gson")
}
shadowMe("gg.essential:loader-launchwrapper:1.1.3")
implementation("gg.essential:essential-1.8.9-forge:1664")
}

mixin {
Expand All @@ -89,6 +84,14 @@ sourceSets {
}
}

configure<NamedDomainObjectContainer<IReobfuscator>> {
clear()
create("shadowJar") {
mappingType = SEARGE
classpath = sourceSets.main.get().compileClasspath
}
}

tasks {
processResources {
inputs.property("version", project.version)
Expand Down Expand Up @@ -144,16 +147,13 @@ tasks {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
}
kotlinDaemonJvmArguments.set(listOf("-Xmx4G", "-Dkotlin.enableCacheBuilding=true", "-Dkotlin.useParallelTasks=true", "-Dkotlin.enableFastIncremental=true"))
}
named<TaskSingleReobf>("reobfJar") {
dependsOn(shadowJar)
enabled = false
}
}

configure<NamedDomainObjectContainer<IReobfuscator>> {
create("shadowJar") {
mappingType = SEARGE
classpath = sourceSets.main.get().compileClasspath
named<TaskSingleReobf>("reobfShadowJar") {
mustRunAfter(shadowJar)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.storage.WorldInfo;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(World.class)
public abstract class MixinWorld implements IBlockAccess {
@Redirect(method = "getMoonPhase", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/storage/WorldInfo;getWorldTime()J"))
private long setTimeForMoonPhase(WorldInfo worldInfo) {
return SimpleTimeChanger.INSTANCE.isEnabled() ? SimpleTimeChanger.INSTANCE.getWorldTime() : worldInfo.getWorldTime();
}
@Shadow @Final public boolean isRemote;

@Redirect(method = "getCelestialAngle", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/storage/WorldInfo;getWorldTime()J"))
private long setTimeForCelestialAngle(WorldInfo worldInfo) {
return SimpleTimeChanger.INSTANCE.isEnabled() ? SimpleTimeChanger.INSTANCE.getWorldTime() : worldInfo.getWorldTime();
@Redirect(method = {"getMoonPhase", "getCelestialAngle"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/storage/WorldInfo;getWorldTime()J"))
private long setTimeForMoonPhase(WorldInfo worldInfo) {
return SimpleTimeChanger.INSTANCE.isEnabled() && this.isRemote ? SimpleTimeChanger.INSTANCE.getWorldTime() : worldInfo.getWorldTime();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ object SimpleTimeChanger {

const val MODID = "simpletimechanger"
const val MOD_NAME = "SimpleTimeChanger"
const val VERSION = "1.0.1"
const val VERSION = "1.0.2"
val mc: MCMinecraft
get() = UMinecraft.getMinecraft()

val isEnabled
get() = Config.isEnabled && !mc.isSingleplayer
get() = Config.isEnabled
val worldTime: Int
get() {
return if (!Config.useIrlTime) Config.worldTime else {
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/mixins.simpletimechanger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"compatibilityLevel": "JAVA_8",
"package": "mynameisjeff.simpletimechanger.mixins.transformers",
"refmap": "mixins.simpletimechanger.refmap.json",
"plugin": "mynameisjeff.simpletimechanger.mixins.MixinPlugin",
"mixins": [
"MixinCustomSky",
"MixinWorld"
Expand Down

0 comments on commit a36ffdd

Please sign in to comment.