e
This commit is contained in:
commit
fe619a10d4
29 changed files with 1302 additions and 0 deletions
16
src/main/java/glowredman/darkerer/Darkerer.java
Normal file
16
src/main/java/glowredman/darkerer/Darkerer.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package glowredman.darkerer;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
|
||||
@Mod(
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
acceptableRemoteVersions = Tags.VERSION,
|
||||
dependencies = "required-after:gtnhlib@[0.6.3,);required-after:unimixins",
|
||||
modid = Darkerer.MODID,
|
||||
name = "Darkerer",
|
||||
version = Tags.VERSION)
|
||||
public class Darkerer {
|
||||
|
||||
public static final String MODID = "darkerer";
|
||||
|
||||
}
|
36
src/main/java/glowredman/darkerer/DarkererConfig.java
Normal file
36
src/main/java/glowredman/darkerer/DarkererConfig.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package glowredman.darkerer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.Config;
|
||||
|
||||
@Config(modid = Darkerer.MODID)
|
||||
@Config.Sync
|
||||
public class DarkererConfig {
|
||||
|
||||
@Config.Comment("""
|
||||
How Darkerer should behave
|
||||
EVERYWHERE: complete darkness at night, except near block light sources (torches, lava, etc.)
|
||||
ONLY_INSIDE: a small amount of light remains at the surface, even during the night
|
||||
MOON_PHASE: like ONLY_INSIDE but the remaining light depends on the moon phase""")
|
||||
@Config.DefaultEnum("EVERYWHERE")
|
||||
public static Mode mode;
|
||||
|
||||
@Config.Comment("Whether or not the Nether should be dark")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean darkNether;
|
||||
|
||||
@Config.Comment("Whether or not the End should be dark")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean darkEnd;
|
||||
|
||||
@Config.Comment("Whether or not the Twilight Forest should be dark")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean darkTwilightForest;
|
||||
|
||||
@Config.Comment("Attempts to remove the blue sky light that occurs when using mode NO_MIN_BLOCK_LIGHT or MOON_PHASE")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean removeBlueSkyLight;
|
||||
|
||||
@Config.Comment("A list of dimension ids in which Darkerer will be completely disabled")
|
||||
@Config.DefaultIntList({})
|
||||
public static int[] dimBlocklist;
|
||||
}
|
72
src/main/java/glowredman/darkerer/DarkererCore.java
Normal file
72
src/main/java/glowredman/darkerer/DarkererCore.java
Normal file
|
@ -0,0 +1,72 @@
|
|||
package glowredman.darkerer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigException;
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.Name;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@TransformerExclusions("glowredman.darkerer.DarkererCore")
|
||||
@MCVersion("1.7.10")
|
||||
@Name("Darkerer")
|
||||
public class DarkererCore implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
public static boolean enabled;
|
||||
|
||||
static {
|
||||
if (FMLLaunchHandler.side() == Side.CLIENT) {
|
||||
try {
|
||||
ConfigurationManager.registerConfig(DarkererConfig.class);
|
||||
} catch (ConfigException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMixinConfig() {
|
||||
return "mixins.darkerer.early.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins(Set<String> loadedCoreMods) {
|
||||
if (FMLLaunchHandler.side() == Side.CLIENT) {
|
||||
return Arrays.asList("MixinEntityRenderer", "MixinWorld", "MixinWorldProviderHell");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
28
src/main/java/glowredman/darkerer/DarkererEventHandler.java
Normal file
28
src/main/java/glowredman/darkerer/DarkererEventHandler.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package glowredman.darkerer;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.eventbus.EventBusSubscriber;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@EventBusSubscriber(side = Side.CLIENT)
|
||||
public class DarkererEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onClientTick(ClientTickEvent event) {
|
||||
if (event.phase == Phase.START) {
|
||||
return;
|
||||
}
|
||||
EntityPlayer player = FMLClientHandler.instance()
|
||||
.getClientPlayerEntity();
|
||||
DarkererCore.enabled = player != null && !ArrayUtils.contains(DarkererConfig.dimBlocklist, player.dimension);
|
||||
}
|
||||
|
||||
}
|
25
src/main/java/glowredman/darkerer/DarkererLateMixins.java
Normal file
25
src/main/java/glowredman/darkerer/DarkererLateMixins.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package glowredman.darkerer;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.ILateMixinLoader;
|
||||
import com.gtnewhorizon.gtnhmixins.LateMixin;
|
||||
|
||||
@LateMixin
|
||||
public class DarkererLateMixins implements ILateMixinLoader {
|
||||
|
||||
@Override
|
||||
public String getMixinConfig() {
|
||||
return "mixins.darkerer.late.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins(Set<String> loadedMods) {
|
||||
if (loadedMods.contains("TwilightForest")) {
|
||||
return Collections.singletonList("MixinWorldProviderTwilightForest");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
7
src/main/java/glowredman/darkerer/Mode.java
Normal file
7
src/main/java/glowredman/darkerer/Mode.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package glowredman.darkerer;
|
||||
|
||||
public enum Mode {
|
||||
EVERYWHERE,
|
||||
ONLY_INSIDE,
|
||||
MOON_PHASE;
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package glowredman.darkerer.mixins;
|
||||
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.llamalad7.mixinextras.sugar.ref.LocalFloatRef;
|
||||
|
||||
import glowredman.darkerer.DarkererConfig;
|
||||
import glowredman.darkerer.DarkererCore;
|
||||
import glowredman.darkerer.Mode;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public class MixinEntityRenderer {
|
||||
|
||||
@Shadow
|
||||
private @Final int[] lightmapColors;
|
||||
|
||||
@ModifyExpressionValue(
|
||||
at = { @At(args = "floatValue=0.03", value = "CONSTANT"), @At(args = "floatValue=0.05", value = "CONSTANT"),
|
||||
@At(args = "floatValue=0.35", value = "CONSTANT") },
|
||||
expect = 9,
|
||||
method = "updateLightmap")
|
||||
private float modifyMin(float original) {
|
||||
return DarkererCore.enabled ? 0.0f : original;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(
|
||||
at = { @At(args = "floatValue=0.96", value = "CONSTANT"), @At(args = "floatValue=0.95", value = "CONSTANT"),
|
||||
@At(args = "floatValue=0.65", value = "CONSTANT") },
|
||||
expect = 9,
|
||||
method = "updateLightmap")
|
||||
private float modifyMax(float original) {
|
||||
return DarkererCore.enabled ? 1.0f : original;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(
|
||||
at = @At(
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "Lnet/minecraft/world/WorldProvider;dimensionId:I",
|
||||
value = "FIELD"),
|
||||
expect = 1,
|
||||
method = "updateLightmap")
|
||||
private int darkenEnd(int original) {
|
||||
return DarkererCore.enabled && DarkererConfig.darkEnd ? 0 : original;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
at = @At(
|
||||
opcode = Opcodes.GETFIELD,
|
||||
ordinal = 2,
|
||||
target = "Lnet/minecraft/client/renderer/EntityRenderer;mc:Lnet/minecraft/client/Minecraft;",
|
||||
value = "FIELD"),
|
||||
expect = 1,
|
||||
method = "updateLightmap")
|
||||
private void adjustNightVisionColor(CallbackInfo ci, @Local(ordinal = 8) LocalFloatRef r,
|
||||
@Local(ordinal = 9) LocalFloatRef g, @Local(ordinal = 10) LocalFloatRef b) {
|
||||
r.set(r.get() * 0.9f + 0.1f);
|
||||
g.set(g.get() * 0.9f + 0.1f);
|
||||
b.set(b.get() * 0.9f + 0.1f);
|
||||
}
|
||||
|
||||
@Inject(
|
||||
at = @At(
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "Lnet/minecraft/client/renderer/EntityRenderer;lightmapTexture:Lnet/minecraft/client/renderer/texture/DynamicTexture;",
|
||||
value = "FIELD"),
|
||||
expect = 1,
|
||||
method = "updateLightmap")
|
||||
private void modifyLightmap(CallbackInfo ci) {
|
||||
if (!DarkererCore.enabled || !DarkererConfig.removeBlueSkyLight || DarkererConfig.mode == Mode.EVERYWHERE) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < this.lightmapColors.length; i++) {
|
||||
int height = i / 16;
|
||||
if (height > 0 && height < 16) {
|
||||
int red = (this.lightmapColors[i] >> 16) & 0xFF;
|
||||
if (DarkererConfig.mode == Mode.ONLY_INSIDE) {
|
||||
red = Math.min(0xFF, red + 25);
|
||||
}
|
||||
this.lightmapColors[i] = this.lightmapColors[i] & 0xFF000000 | red << 16 | red << 8 | red;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
59
src/main/java/glowredman/darkerer/mixins/MixinWorld.java
Normal file
59
src/main/java/glowredman/darkerer/mixins/MixinWorld.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
package glowredman.darkerer.mixins;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.sugar.Share;
|
||||
import com.llamalad7.mixinextras.sugar.ref.LocalFloatRef;
|
||||
|
||||
import glowredman.darkerer.DarkererConfig;
|
||||
import glowredman.darkerer.DarkererCore;
|
||||
|
||||
@Mixin(World.class)
|
||||
public class MixinWorld {
|
||||
|
||||
@ModifyExpressionValue(
|
||||
at = @At(args = "floatValue=0.2", ordinal = 1, value = "CONSTANT"),
|
||||
expect = 1,
|
||||
method = "getSunBrightnessBody",
|
||||
remap = false)
|
||||
private float modifyMin(float original, @Share("min") LocalFloatRef min) {
|
||||
if (!DarkererCore.enabled) {
|
||||
return original;
|
||||
}
|
||||
switch (DarkererConfig.mode) {
|
||||
case EVERYWHERE:
|
||||
return 0.0f;
|
||||
case MOON_PHASE:
|
||||
return min.get();
|
||||
default:
|
||||
return original;
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(
|
||||
at = @At(args = "floatValue=0.8", value = "CONSTANT"),
|
||||
expect = 1,
|
||||
method = "getSunBrightnessBody",
|
||||
remap = false)
|
||||
private float modifyMax(float original, @Share("min") LocalFloatRef min) {
|
||||
if (!DarkererCore.enabled) {
|
||||
return original;
|
||||
}
|
||||
switch (DarkererConfig.mode) {
|
||||
case EVERYWHERE:
|
||||
return 1.0f;
|
||||
case MOON_PHASE:
|
||||
int phase = (int) (Minecraft.getMinecraft().theWorld.getCurrentMoonPhaseFactorBody() * 10.0f);
|
||||
float max = 0.7f + (10 - phase) * 0.03f;
|
||||
min.set(1.0f - max);
|
||||
return max;
|
||||
default:
|
||||
return original;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package glowredman.darkerer.mixins;
|
||||
|
||||
import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.WorldProviderHell;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import glowredman.darkerer.DarkererConfig;
|
||||
import glowredman.darkerer.DarkererCore;
|
||||
|
||||
@Mixin(WorldProviderHell.class)
|
||||
public abstract class MixinWorldProviderHell extends WorldProvider {
|
||||
|
||||
@Inject(at = @At("HEAD"), cancellable = true, method = "generateLightBrightnessTable")
|
||||
private void replaceNetherLightCalc(CallbackInfo ci) {
|
||||
if (DarkererCore.enabled && DarkererConfig.darkNether) {
|
||||
super.generateLightBrightnessTable();
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package glowredman.darkerer.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
|
||||
import glowredman.darkerer.DarkererConfig;
|
||||
import glowredman.darkerer.DarkererCore;
|
||||
import twilightforest.world.WorldProviderTwilightForest;
|
||||
|
||||
@Mixin(WorldProviderTwilightForest.class)
|
||||
public class MixinWorldProviderTwilightForest {
|
||||
|
||||
@ModifyExpressionValue(at = @At(args = "floatValue=0.225", value = "CONSTANT"), method = "calculateCelestialAngle")
|
||||
private float modifyCelestialAngle(float original) {
|
||||
return DarkererCore.enabled && DarkererConfig.darkTwilightForest ? 0.5f : original;
|
||||
}
|
||||
}
|
21
src/main/resources/mcmod.info
Normal file
21
src/main/resources/mcmod.info
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"modListVersion": 2,
|
||||
"modList": [{
|
||||
"modid": "${modId}",
|
||||
"name": "${modName}",
|
||||
"description": "Makes the world a lot darker",
|
||||
"version": "${modVersion}",
|
||||
"mcversion": "${minecraftVersion}",
|
||||
"url": "https://github.com/glowredman/Darkerer",
|
||||
"updateUrl": "",
|
||||
"authorList": ["glowredman"],
|
||||
"credits": "lumien (author of Hardcore Darkness)",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"parent": "",
|
||||
"requiredMods": [],
|
||||
"dependencies": [],
|
||||
"dependants": [],
|
||||
"useDependencyInformation": false
|
||||
}]
|
||||
}
|
8
src/main/resources/mixins.darkerer.early.json
Normal file
8
src/main/resources/mixins.darkerer.early.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.3-GTNH",
|
||||
"package": "glowredman.darkerer.mixins",
|
||||
"refmap": "mixins.darkerer.refmap.json",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
}
|
11
src/main/resources/mixins.darkerer.json
Normal file
11
src/main/resources/mixins.darkerer.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.3-GTNH",
|
||||
"package": "glowredman.darkerer.mixins",
|
||||
"refmap": "mixins.darkerer.refmap.json",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [],
|
||||
"client": [],
|
||||
"server": []
|
||||
}
|
8
src/main/resources/mixins.darkerer.late.json
Normal file
8
src/main/resources/mixins.darkerer.late.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8.3-GTNH",
|
||||
"package": "glowredman.darkerer.mixins",
|
||||
"refmap": "mixins.darkerer.refmap.json",
|
||||
"target": "@env(DEFAULT)",
|
||||
"compatibilityLevel": "JAVA_8"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue