aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/init
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-12-07 13:26:03 +0100
committerLinnea Gräf <nea@nea.moe>2024-12-07 13:26:03 +0100
commitbf7795df22ca7892fae1238403feebb57c005562 (patch)
tree3a49db5bade38498f976321b6e9008203f2d4d3b /src/main/java/moe/nea/firmament/init
parentcdb5e60f52eea9030af9ca2d4a49913664023965 (diff)
downloadFirmament-bf7795df22ca7892fae1238403feebb57c005562.tar.gz
Firmament-bf7795df22ca7892fae1238403feebb57c005562.tar.bz2
Firmament-bf7795df22ca7892fae1238403feebb57c005562.zip
WIP: Port to compilation on 1.21.4
Diffstat (limited to 'src/main/java/moe/nea/firmament/init')
-rw-r--r--src/main/java/moe/nea/firmament/init/EarlyRiser.java2
-rw-r--r--src/main/java/moe/nea/firmament/init/HandledScreenRiser.java1
-rw-r--r--src/main/java/moe/nea/firmament/init/ItemColorsSodiumRiser.java64
3 files changed, 1 insertions, 66 deletions
diff --git a/src/main/java/moe/nea/firmament/init/EarlyRiser.java b/src/main/java/moe/nea/firmament/init/EarlyRiser.java
index 9734e94..5441255 100644
--- a/src/main/java/moe/nea/firmament/init/EarlyRiser.java
+++ b/src/main/java/moe/nea/firmament/init/EarlyRiser.java
@@ -7,6 +7,6 @@ public class EarlyRiser implements Runnable {
new ClientPlayerRiser().addTinkerers();
new HandledScreenRiser().addTinkerers();
new SectionBuilderRiser().addTinkerers();
- new ItemColorsSodiumRiser().addTinkerers();
+// TODO: new ItemColorsSodiumRiser().addTinkerers();
}
}
diff --git a/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java b/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java
index 355a666..f7db18c 100644
--- a/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java
+++ b/src/main/java/moe/nea/firmament/init/HandledScreenRiser.java
@@ -3,7 +3,6 @@ package moe.nea.firmament.init;
import me.shedaniel.mm.api.ClassTinkerers;
import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.ParentElement;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
diff --git a/src/main/java/moe/nea/firmament/init/ItemColorsSodiumRiser.java b/src/main/java/moe/nea/firmament/init/ItemColorsSodiumRiser.java
deleted file mode 100644
index 80ee9aa..0000000
--- a/src/main/java/moe/nea/firmament/init/ItemColorsSodiumRiser.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package moe.nea.firmament.init;
-
-import me.shedaniel.mm.api.ClassTinkerers;
-import moe.nea.firmament.util.ErrorUtil;
-import net.fabricmc.loader.api.FabricLoader;
-import net.minecraft.client.color.item.ItemColorProvider;
-import net.minecraft.client.color.item.ItemColors;
-import net.minecraft.item.ItemStack;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-import org.objectweb.asm.tree.ClassNode;
-import org.objectweb.asm.tree.InsnList;
-import org.objectweb.asm.tree.InsnNode;
-import org.objectweb.asm.tree.MethodInsnNode;
-import org.objectweb.asm.tree.VarInsnNode;
-
-public class ItemColorsSodiumRiser extends RiserUtils {
- @IntermediaryName(ItemColors.class)
- String ItemColors;
- @IntermediaryName(ItemColorProvider.class)
- String ItemColorProvider;
- @IntermediaryName(ItemStack.class)
- String ItemStack;
- String getColorProvider = "sodium$getColorProvider";
- Type getColorProviderDesc = Type.getMethodType(getTypeForClassName(ItemColorProvider),
- getTypeForClassName(ItemStack));
-
- @Override
- public void addTinkerers() {
- ClassTinkerers.addTransformation(ItemColors, this::addSodiumOverride, true);
- }
-
- private void addSodiumOverride(ClassNode classNode) {
- var node = findMethod(classNode, getColorProvider, getColorProviderDesc);
- if (node == null) {
- if (!FabricLoader.getInstance().isModLoaded("sodium"))
- ErrorUtil.INSTANCE.softError("Sodium is present, but sodium color override could not be injected.");
- return;
- }
- var p = node.instructions.getFirst();
- while (p != null) {
- if (p.getOpcode() == Opcodes.ARETURN) {
- node.instructions.insertBefore(
- p,
- mkOverrideSodiumCall()
- );
- }
- p = p.getNext();
- }
- }
-
- private InsnList mkOverrideSodiumCall() {
- var insnList = new InsnList();
- insnList.add(new VarInsnNode(Opcodes.ALOAD, 0));
- insnList.add(new InsnNode(Opcodes.SWAP));
- insnList.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,
- getTypeForClassName(ItemColors).getInternalName(),
- "overrideSodium_firmament",
- Type.getMethodType(getTypeForClassName(ItemColorProvider),
- getTypeForClassName(ItemColorProvider)).getDescriptor(),
- false));
- return insnList;
- }
-}