aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJuuz <6596629+Juuxel@users.noreply.github.com>2021-06-05 00:13:59 +0300
committerJuuz <6596629+Juuxel@users.noreply.github.com>2021-06-05 00:14:22 +0300
commita1bb6316f2d6ecc0019e00438b4cf724dde68f73 (patch)
tree05edeedca30fa5a5a50085b594244aa66ef569cc /src/main
parent1aba27451ce4b95dc7a832938998c9d1581eee97 (diff)
downloadLibGui-a1bb6316f2d6ecc0019e00438b4cf724dde68f73.tar.gz
LibGui-a1bb6316f2d6ecc0019e00438b4cf724dde68f73.tar.bz2
LibGui-a1bb6316f2d6ecc0019e00438b4cf724dde68f73.zip
Switch from accessor to AW, fixes #113
Accessors would be preferred but there is a mixin bug/regression that prevents me from modifying final fields with accessors unless I do some concerning hacky code.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java10
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/access/SlotAccessor.java15
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java4
-rw-r--r--src/main/resources/fabric.mod.json4
-rw-r--r--src/main/resources/libgui.accesswidener6
-rw-r--r--src/main/resources/mixins.libgui.accessors.json14
6 files changed, 11 insertions, 42 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java
index aa6ae36..f51bcad 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java
@@ -7,7 +7,6 @@ import net.minecraft.screen.slot.Slot;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
-import io.github.cottonmc.cotton.gui.impl.access.SlotAccessor;
import io.github.cottonmc.cotton.gui.widget.WItemSlot;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -170,13 +169,12 @@ public class ValidatedSlot extends Slot {
if (this.visible != visible) {
this.visible = visible;
- SlotAccessor accessor = (SlotAccessor) this;
if (visible) {
- accessor.setX(originalX);
- accessor.setY(originalY);
+ x = originalX;
+ y = originalY;
} else {
- accessor.setX(-100000);
- accessor.setY(-100000);
+ x = -100000;
+ y = -100000;
}
}
}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/access/SlotAccessor.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/access/SlotAccessor.java
deleted file mode 100644
index 4b4644c..0000000
--- a/src/main/java/io/github/cottonmc/cotton/gui/impl/access/SlotAccessor.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package io.github.cottonmc.cotton.gui.impl.access;
-
-import net.minecraft.screen.slot.Slot;
-
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Accessor;
-
-@Mixin(Slot.class)
-public interface SlotAccessor {
- @Accessor("x")
- void setX(int x);
-
- @Accessor("y")
- void setY(int y);
-}
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java
deleted file mode 100644
index 8f391fd..0000000
--- a/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Internal implementation classes.
- */
-package io.github.cottonmc.cotton.gui.impl.access;
diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json
index c6e1b4d..9431237 100644
--- a/src/main/resources/fabric.mod.json
+++ b/src/main/resources/fabric.mod.json
@@ -22,9 +22,7 @@
"client": ["io.github.cottonmc.cotton.gui.impl.client.LibGuiClient"],
"modmenu": ["io.github.cottonmc.cotton.gui.impl.modmenu.ModMenuSupport"]
},
- "mixins": [
- "mixins.libgui.accessors.json"
- ],
+ "accessWidener": "libgui.accesswidener",
"depends": {
"fabricloader": ">=0.11.0",
"fabric": "*",
diff --git a/src/main/resources/libgui.accesswidener b/src/main/resources/libgui.accesswidener
new file mode 100644
index 0000000..c290bc6
--- /dev/null
+++ b/src/main/resources/libgui.accesswidener
@@ -0,0 +1,6 @@
+accessWidener v1 named
+
+accessible field net/minecraft/screen/slot/Slot x I
+accessible field net/minecraft/screen/slot/Slot y I
+mutable field net/minecraft/screen/slot/Slot x I
+mutable field net/minecraft/screen/slot/Slot y I
diff --git a/src/main/resources/mixins.libgui.accessors.json b/src/main/resources/mixins.libgui.accessors.json
deleted file mode 100644
index 9ec55f2..0000000
--- a/src/main/resources/mixins.libgui.accessors.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "compatibilityLevel": "JAVA_8",
- "minVersion": "0.7.11",
- "package": "io.github.cottonmc.cotton.gui.impl.access",
- "required": true,
-
- "mixins": [
- "SlotAccessor"
- ],
-
- "injectors": {
- "defaultRequire": 1
- }
-}