Add basic Mouse Wheelie integration

This commit is contained in:
Shadowfacts 2021-03-18 18:12:01 -04:00
parent a1df6cda25
commit cbea57006a
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
8 changed files with 125 additions and 0 deletions

View File

@ -81,6 +81,8 @@ dependencies {
compile project(":kiwi-java") compile project(":kiwi-java")
include project(":kiwi-java") include project(":kiwi-java")
runtimeOnly project(":plugin:mousewheelie")
include project(":plugin:mousewheelie")
runtimeOnly project(":plugin:rei") runtimeOnly project(":plugin:rei")
include project(":plugin:rei") include project(":plugin:rei")

View File

@ -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"
}
}

View File

@ -0,0 +1,4 @@
archives_base_name=PhyCon-Plugin-MouseWheelie
mousewheelie_version=1.6.4+mc1.16.4

View File

@ -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<TerminalScreenHandler> 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;
}
}
}

View File

@ -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"
}
}

View File

@ -0,0 +1,11 @@
{
"required": true,
"package": "net.shadowfacts.phycon.plugin.mousewheelie.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"MixinTerminalScreen"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -10,4 +10,5 @@ pluginManagement {
} }
include("kiwi-java") include("kiwi-java")
include("plugin:mousewheelie")
include("plugin:rei") include("plugin:rei")

View File

@ -236,7 +236,10 @@ class TerminalScreenHandler(syncId: Int, val playerInv: PlayerInventory, val ter
return slotsInsertedInto return slotsInsertedInto
} }
val networkSlotsStart = 0
val networkSlotsEnd = 54
val bufferSlotsStart = 54 val bufferSlotsStart = 54
val bufferSlotsEnd = 72
val playerSlotsStart = 72 val playerSlotsStart = 72
val playerSlotsEnd = 72 + 36 val playerSlotsEnd = 72 + 36
fun isNetworkSlot(id: Int) = id in 0 until bufferSlotsStart fun isNetworkSlot(id: Int) = id in 0 until bufferSlotsStart