aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorVixid <52578495+VixidDev@users.noreply.github.com>2023-03-11 23:51:41 +0000
committerGitHub <noreply@github.com>2023-03-12 10:51:41 +1100
commit5f147d6adbe9898239a0cb86e4daaa74c9e4c08a (patch)
treedb16c1b2499e8268ebad7015436ae582c0f130d9 /src/main/java
parenta5433dc40dee8517fc0bd8105ae10e0f29778c40 (diff)
downloadNotEnoughUpdates-5f147d6adbe9898239a0cb86e4daaa74c9e4c08a.tar.gz
NotEnoughUpdates-5f147d6adbe9898239a0cb86e4daaa74c9e4c08a.tar.bz2
NotEnoughUpdates-5f147d6adbe9898239a0cb86e4daaa74c9e4c08a.zip
Dynamic Light Items (#646)
Co-authored-by: Vixid <52578495+Vixid1@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/envcheck/NEUMixinConfigPlugin.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinOFDynamicLights.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java4
3 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/envcheck/NEUMixinConfigPlugin.java b/src/main/java/io/github/moulberry/notenoughupdates/envcheck/NEUMixinConfigPlugin.java
index 44e24ff4..1d12813c 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/envcheck/NEUMixinConfigPlugin.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/envcheck/NEUMixinConfigPlugin.java
@@ -1,5 +1,6 @@
package io.github.moulberry.notenoughupdates.envcheck;
+import io.github.moulberry.notenoughupdates.miscgui.DynamicLightItemsEditor;
import org.spongepowered.asm.lib.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
@@ -42,5 +43,8 @@ public class NEUMixinConfigPlugin implements IMixinConfigPlugin {
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
+ if ("io.github.moulberry.notenoughupdates.mixins.MixinOFDynamicLights".equals(mixinClassName)) {
+ DynamicLightItemsEditor.setDidApplyMixin(true);
+ }
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinOFDynamicLights.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinOFDynamicLights.java
new file mode 100644
index 00000000..68f75d49
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinOFDynamicLights.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2023 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.mixins;
+
+import io.github.moulberry.notenoughupdates.miscgui.DynamicLightItemsEditor;
+import net.minecraft.item.ItemStack;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Pseudo;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Pseudo
+@Mixin(targets = "net.optifine.DynamicLights", remap = false)
+public class MixinOFDynamicLights {
+
+ @Inject(method = "getLightLevel(Lnet/minecraft/item/ItemStack;)I", at = @At("TAIL"), cancellable = true)
+ private static void getLightLevel(ItemStack itemStack, CallbackInfoReturnable<Integer> cir) {
+ int lightLevel = DynamicLightItemsEditor.findDynamicLightItems(itemStack);
+ if (lightLevel != 0) cir.setReturnValue(lightLevel);
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
index e2a483f7..498b3b0d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java
@@ -82,9 +82,11 @@ import net.minecraftforge.client.ClientCommandHandler;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
public class NEUConfig extends Config {
public void editOverlay() {
@@ -471,6 +473,8 @@ public class NEUConfig extends Config {
public ArrayList<String> quickCommands = createDefaultQuickCommands();
@Expose
public ArrayList<String> enchantColours = createDefaultEnchantColours();
+ @Expose
+ public Set<String> dynamicLightItems = new HashSet<>();
@Expose
public boolean firstTimeSearchFocus = true;