diff --git a/build.gradle b/build.gradle index f7f0f41..908cb37 100644 --- a/build.gradle +++ b/build.gradle @@ -81,6 +81,8 @@ dependencies { compile project(":kiwi-java") include project(":kiwi-java") + runtimeOnly project(":plugin:mousewheelie") + include project(":plugin:mousewheelie") runtimeOnly project(":plugin:rei") include project(":plugin:rei") diff --git a/plugin/mousewheelie/build.gradle b/plugin/mousewheelie/build.gradle new file mode 100644 index 0000000..c651db7 --- /dev/null +++ b/plugin/mousewheelie/build.gradle @@ -0,0 +1,27 @@ +plugins { + id "fabric-loom" + id "org.jetbrains.kotlin.jvm" +} + +archivesBaseName = project.archives_base_name +version = project.mod_version +group = project.maven_group + +repositories { + maven { + url = "https://maven.siphalor.de/" + } + jcenter() +} + +dependencies { + implementation project(":") + + modImplementation("de.siphalor:mousewheelie-1.16:${project.mousewheelie_version}") { + exclude group: "net.fabricmc" + exclude group: "net.fabricmc.fabric-api" + exclude module: "modmenu" + exclude group: "me.shedaniel.cloth" + } +} + diff --git a/plugin/mousewheelie/gradle.properties b/plugin/mousewheelie/gradle.properties new file mode 100644 index 0000000..3c935bc --- /dev/null +++ b/plugin/mousewheelie/gradle.properties @@ -0,0 +1,4 @@ +archives_base_name=PhyCon-Plugin-MouseWheelie + +mousewheelie_version=1.6.4+mc1.16.4 + diff --git a/plugin/mousewheelie/src/main/java/net/shadowfacts/phycon/plugin/mousewheelie/mixin/MixinTerminalScreen.java b/plugin/mousewheelie/src/main/java/net/shadowfacts/phycon/plugin/mousewheelie/mixin/MixinTerminalScreen.java new file mode 100644 index 0000000..2f48ff3 --- /dev/null +++ b/plugin/mousewheelie/src/main/java/net/shadowfacts/phycon/plugin/mousewheelie/mixin/MixinTerminalScreen.java @@ -0,0 +1,41 @@ +package net.shadowfacts.phycon.plugin.mousewheelie.mixin; + +import de.siphalor.mousewheelie.client.util.ScrollAction; +import de.siphalor.mousewheelie.client.util.accessors.IContainerScreen; +import de.siphalor.mousewheelie.client.util.accessors.ISpecialScrollableScreen; +import net.minecraft.client.gui.screen.ingame.HandledScreen; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.screen.slot.Slot; +import net.minecraft.text.Text; +import net.shadowfacts.phycon.block.terminal.TerminalScreen; +import net.shadowfacts.phycon.block.terminal.TerminalScreenHandler; +import org.spongepowered.asm.mixin.Mixin; + +/** + * @author shadowfacts + */ +@Mixin(TerminalScreen.class) +public abstract class MixinTerminalScreen extends HandledScreen implements ISpecialScrollableScreen, IContainerScreen { + + private MixinTerminalScreen(TerminalScreenHandler screenHandler, PlayerInventory playerInventory, Text text) { + super(screenHandler, playerInventory, text); + } + + @Override + public ScrollAction mouseWheelie_onMouseScrolledSpecial(double mouseX, double mouseY, double scrollAmount) { + Slot slot = mouseWheelie_getSlotAt(mouseX, mouseY); + if (slot == null) { + return ScrollAction.PASS; + } + + if (slot.id < handler.getBufferSlotsEnd()) { + // scrolling in the network inventory is never allowed + // scrolling out of the buffer is theoretically possible, but there isn't a straightforward way + // of telling the server not to mark the buffer slot as TO_NETWORK after mouse wheelie's song and dance + return ScrollAction.ABORT; + } else { + return ScrollAction.PASS; + } + } + +} diff --git a/plugin/mousewheelie/src/main/resources/fabric.mod.json b/plugin/mousewheelie/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..009fbab --- /dev/null +++ b/plugin/mousewheelie/src/main/resources/fabric.mod.json @@ -0,0 +1,36 @@ +{ + "schemaVersion": 1, + "id": "phycon_mousewheelie", + "version": "${version}", + + "name": "PhyCon Mouse Wheelie Integration", + "description": "", + "authors": [ + "Shadowfacts" + ], + "contact": { + "homepage": "https://git.shadowfacts.net/minecraft/PhysicalConnectivity" + }, + "license": "LGPL-3.0", + "environment": "client", + "entrypoints": { + }, + "mixins": [ + { + "config": "phycon-mousewheelie-client.mixins.json", + "environment": "client" + } + ], + "depends": { + "fabricloader": ">=0.4.0", + "fabric": "*", + "fabric-language-kotlin": ">=1.3.50", + "phycon": "*", + "mousewheelie": "*" + }, + + "custom": { + "modmenu:parent": "phycon" + } +} + diff --git a/plugin/mousewheelie/src/main/resources/phycon-mousewheelie-client.mixins.json b/plugin/mousewheelie/src/main/resources/phycon-mousewheelie-client.mixins.json new file mode 100644 index 0000000..174bcdd --- /dev/null +++ b/plugin/mousewheelie/src/main/resources/phycon-mousewheelie-client.mixins.json @@ -0,0 +1,11 @@ +{ + "required": true, + "package": "net.shadowfacts.phycon.plugin.mousewheelie.mixin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "MixinTerminalScreen" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/settings.gradle b/settings.gradle index 4fac6d3..d0d36ac 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,4 +10,5 @@ pluginManagement { } include("kiwi-java") +include("plugin:mousewheelie") include("plugin:rei") diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalScreenHandler.kt b/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalScreenHandler.kt index 5137ad9..49e47dc 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalScreenHandler.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalScreenHandler.kt @@ -236,7 +236,10 @@ class TerminalScreenHandler(syncId: Int, val playerInv: PlayerInventory, val ter return slotsInsertedInto } + val networkSlotsStart = 0 + val networkSlotsEnd = 54 val bufferSlotsStart = 54 + val bufferSlotsEnd = 72 val playerSlotsStart = 72 val playerSlotsEnd = 72 + 36 fun isNetworkSlot(id: Int) = id in 0 until bufferSlotsStart