Created
May 31, 2018 20:17
-
-
Save AmazigJj/234d9e4cc936eb6a0fd0114560226e4c to your computer and use it in GitHub Desktop.
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
package amazigjj.longerdays; | |
import net.minecraftforge.common.config.Config; | |
import net.minecraftforge.common.config.ConfigManager; | |
import net.minecraftforge.fml.client.event.ConfigChangedEvent; | |
import net.minecraftforge.fml.common.Mod; | |
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | |
import net.minecraftforge.fml.common.gameevent.TickEvent; | |
import static amazigjj.longerdays.LongerDays.LongerDaysConfig.*; | |
@Mod(modid="longerdays", name="Longer Days", version = "1.0.5", acceptedMinecraftVersions = "1.12, 1.13", acceptableRemoteVersions = "*") | |
@Mod.EventBusSubscriber | |
public class LongerDays { | |
@SubscribeEvent | |
public static void onWorldTick(TickEvent.WorldTickEvent event) { | |
if ((event.phase == TickEvent.Phase.START) && (event.world.provider.getDimension() == 0)) { | |
if(event.world.getWorldTime() % 24000 >= 1000 && event.world.getWorldTime() % 24000 < 13000) { | |
if (longerDays) { | |
if (!(event.world.getTotalWorldTime() % dayTimeMultiplier == 0)) { | |
event.world.setWorldTime(event.world.getWorldTime() - 1); | |
} | |
} else { | |
event.world.setWorldTime(event.world.getWorldTime() + (dayTimeMultiplier - 1)); | |
} | |
} else{ | |
if (longerNights) { | |
if (!(event.world.getTotalWorldTime() % nightTimeMultiplier == 0)) { | |
event.world.setWorldTime(event.world.getWorldTime() - 1); | |
} | |
} else { | |
event.world.setWorldTime(event.world.getWorldTime() + (nightTimeMultiplier - 1)); | |
} | |
} | |
} | |
} | |
@SubscribeEvent | |
public static void configReload(ConfigChangedEvent.OnConfigChangedEvent event){ | |
if(event.getModID().equals("longerdays")) ConfigManager.sync("longerdays", Config.Type.INSTANCE); | |
} | |
@Config(modid="longerdays") | |
public static class LongerDaysConfig{ | |
@Config.Name("Longer Days") | |
@Config.Comment("Whether to make days longer or shorter,\nif set to true days shall be longer (according to Day Time Multiplier),\nif set to false days shall be shorter (according to Day Time Multiplier)") | |
public static boolean longerDays = true; | |
@Config.Name("Day Time Multiplier") | |
@Config.Comment("Rhe multiplier by which to make days longer or shorter") | |
public static byte dayTimeMultiplier = 3; | |
@Config.Name("Longer Nights") | |
@Config.Comment("Whether to make night longer or shorter,\nif set to true nights shall be longer (according to Night Time Multiplier),\nif set to false nights shall be shorter (according to Night Time Multiplier)") | |
public static boolean longerNights = true; | |
@Config.Name("Night Time Multiplier") | |
@Config.Comment("The multiplier by which to make nights longer or shorter") | |
public static byte nightTimeMultiplier = 3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment