Compare commits
57 Commits
Author | SHA1 | Date |
---|---|---|
Shadowfacts | b64a05e0ad | |
Shadowfacts | 73de26387a | |
Shadowfacts | 33614e0dc6 | |
Shadowfacts | c18af9794b | |
Shadowfacts | 6d97af8bdc | |
Shadowfacts | d527185888 | |
Shadowfacts | 82482ca9c6 | |
Shadowfacts | 9200dea350 | |
Shadowfacts | e88ecd3215 | |
Shadowfacts | 9cbad193e2 | |
Shadowfacts | b416f98ef6 | |
Shadowfacts | b2e794e5a4 | |
Shadowfacts | b21a45fbbb | |
Shadowfacts | ef9aa9e958 | |
Shadowfacts | c5ede3bd62 | |
Shadowfacts | 30300dbc40 | |
Shadowfacts | 5488cc295a | |
Shadowfacts | 172536cdb8 | |
Shadowfacts | 46e00cea97 | |
Shadowfacts | ce511e62e1 | |
Shadowfacts | 5eb948802c | |
Shadowfacts | 7447c89394 | |
Shadowfacts | 87f0bdb85a | |
Shadowfacts | 236d6707f6 | |
Shadowfacts | 961c74de34 | |
Shadowfacts | c278d137ef | |
Shadowfacts | 12e055d645 | |
Shadowfacts | 9d98481ba5 | |
Shadowfacts | e4662b0f6f | |
Shadowfacts | 4fa5a12746 | |
Shadowfacts | 7286efcfc2 | |
Shadowfacts | 7cb0168c2f | |
Shadowfacts | b435948ee3 | |
Shadowfacts | c15700bf5d | |
Shadowfacts | 9418ff8917 | |
Shadowfacts | 6f1f43f36a | |
Shadowfacts | f12965fc6c | |
Shadowfacts | 28e14ae8bf | |
Shadowfacts | e41c9e3ccb | |
Shadowfacts | b87a36caa4 | |
Shadowfacts | 93b082ee55 | |
Shadowfacts | 2466923d96 | |
Shadowfacts | 84e2c6d6e9 | |
Shadowfacts | 2774cabfcc | |
Shadowfacts | 81ce590231 | |
Shadowfacts | f0fe1e4a3d | |
Shadowfacts | f375d157b0 | |
Shadowfacts | cbea57006a | |
Shadowfacts | a1df6cda25 | |
Shadowfacts | 47ff975449 | |
Shadowfacts | 369dcebe1b | |
Shadowfacts | ee6fb1e725 | |
Shadowfacts | bc50017b4a | |
Shadowfacts | 611c4bb0ae | |
Shadowfacts | 4ab6dbbf38 | |
Shadowfacts | f536bf72a9 | |
Shadowfacts | a86058f8bd |
86
build.gradle
86
build.gradle
|
@ -1,8 +1,7 @@
|
|||
plugins {
|
||||
id "fabric-loom" version "0.6.49"
|
||||
id "fabric-loom" version "0.12.9"
|
||||
id "maven-publish"
|
||||
id "org.jetbrains.kotlin.jvm" version "1.4.30"
|
||||
id "com.github.johnrengelman.shadow" version "4.0.4"
|
||||
id "org.jetbrains.kotlin.jvm" version "1.6.10"
|
||||
}
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
|
@ -11,8 +10,8 @@ group = project.maven_group
|
|||
|
||||
allprojects {
|
||||
pluginManager.withPlugin("java") {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +43,8 @@ configure(allprojects.findAll { it.name != "kiwi-java" }) {
|
|||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
||||
options.release = 17
|
||||
}
|
||||
|
||||
java {
|
||||
|
@ -56,20 +57,23 @@ configure(allprojects.findAll { it.name != "kiwi-java" }) {
|
|||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
|
||||
kotlinOptions.jvmTarget = JavaVersion.VERSION_17
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
loom {
|
||||
log4jConfigs.from "PhyConDebugLogging.xml"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://mod-buildcraft.com/maven" }
|
||||
maven { url "http://server.bbkr.space:8081/artifactory/libs-release/" }
|
||||
// maven { url "https://server.bbkr.space:8081/artifactory/libs-release/" }
|
||||
maven { url "https://maven.terraformersmc.com/releases" }
|
||||
jcenter()
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
maven { url "https://maven.siphalor.de/" }
|
||||
maven { url "https://jitpack.io" }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -79,16 +83,28 @@ dependencies {
|
|||
include "alexiil.mc.lib:libblockattributes-core:${project.libblockattributes_version}"
|
||||
include "alexiil.mc.lib:libblockattributes-items:${project.libblockattributes_version}"
|
||||
|
||||
compile project(":kiwi-java")
|
||||
shadow project(":kiwi-java")
|
||||
implementation project(":kiwi-java")
|
||||
include project(":kiwi-java")
|
||||
|
||||
runtimeOnly project(":plugin:rei")
|
||||
include project(":plugin:rei")
|
||||
// modRuntimeOnly "de.siphalor:mousewheelie-1.18:${project.mousewheelie_version}"
|
||||
// runtimeOnly(project(":plugin:mousewheelie")) {
|
||||
// transitive = false
|
||||
// }
|
||||
// include project(":plugin:mousewheelie")
|
||||
//
|
||||
// modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}"
|
||||
// runtimeOnly(project(":plugin:rei")) {
|
||||
// transitive = false
|
||||
// }
|
||||
// include project(":plugin:rei")
|
||||
|
||||
modRuntime("io.github.cottonmc:cotton-resources:${project.cotton_resources_version}") {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
}
|
||||
modRuntime("com.terraformersmc:modmenu:${project.modmenu_version}") {
|
||||
// runtimeOnly project(":plugin:techreborn")
|
||||
// include project(":plugin:techreborn")
|
||||
|
||||
// modRuntime("io.github.cottonmc:cotton-resources:${project.cotton_resources_version}") {
|
||||
// exclude group: "net.fabricmc.fabric-api"
|
||||
// }
|
||||
modRuntimeOnly("com.terraformersmc:modmenu:${project.modmenu_version}") {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
}
|
||||
|
||||
|
@ -102,22 +118,22 @@ jar {
|
|||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
// add all the jars that should be included when publishing to maven
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
artifact(sourcesJar) {
|
||||
builtBy remapSourcesJar
|
||||
}
|
||||
}
|
||||
}
|
||||
// publishing {
|
||||
// publications {
|
||||
// mavenJava(MavenPublication) {
|
||||
// // add all the jars that should be included when publishing to maven
|
||||
// artifact(remapJar) {
|
||||
// builtBy remapJar
|
||||
// }
|
||||
// artifact(sourcesJar) {
|
||||
// builtBy remapSourcesJar
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// select the repositories you want to publish to
|
||||
repositories {
|
||||
// uncomment to publish to the local maven
|
||||
// mavenLocal()
|
||||
}
|
||||
}
|
||||
// // select the repositories you want to publish to
|
||||
// repositories {
|
||||
// // uncomment to publish to the local maven
|
||||
// // mavenLocal()
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
base_color=blue
|
||||
|
||||
modulate() {
|
||||
echo $1, $2
|
||||
mkdir -p src/main/resources/assets/phycon/textures/block/cable/$1
|
||||
for f in src/main/resources/assets/phycon/textures/block/cable/$base_color/*; do
|
||||
echo $f
|
||||
convert $f -modulate $2 src/main/resources/assets/phycon/textures/block/cable/$1/$(basename $f)
|
||||
done
|
||||
echo "---"
|
||||
}
|
||||
|
||||
# modulate <color> <brightness>,<saturation>,<hue>
|
||||
# brightness: 100 is initial, +/- 100
|
||||
# saturnation: 100 is initial, +/- 100
|
||||
# hue: (<gimp hue> / 180) * 100 + 100
|
||||
|
||||
modulate white 200,0,100
|
||||
modulate orange 100,120,200
|
||||
modulate magenta 100,100,146
|
||||
modulate light_blue 140,65,100
|
||||
modulate yellow 100,109,8
|
||||
modulate lime 100,100,53
|
||||
modulate pink 172,50,172
|
||||
modulate gray 60,10,100
|
||||
modulate light_gray 105,3,39
|
||||
modulate cyan 112,65,84
|
||||
modulate purple 109,76,133
|
||||
modulate brown 60,45,190
|
||||
modulate green 60,50,30
|
||||
modulate red 100,100,176
|
||||
modulate black 30,0,100
|
||||
|
|
@ -1,19 +1,21 @@
|
|||
org.gradle.jvmargs=-Xmx1G
|
||||
org.gradle.daemon=false
|
||||
|
||||
minecraft_version=1.16.5
|
||||
yarn_mappings=1.16.5+build.4
|
||||
loader_version=0.11.1
|
||||
minecraft_version=1.18.2
|
||||
yarn_mappings=1.18.2+build.3
|
||||
loader_version=0.14.8
|
||||
|
||||
mod_version=0.1.0
|
||||
mod_version=0.2.0
|
||||
maven_group=net.shadowfacts
|
||||
archives_base_name=PhysicalConnectivity
|
||||
|
||||
fabric_version=0.30.0+1.16
|
||||
fabric_kotlin_version=1.4.30+build.2
|
||||
fabric_version=0.56.0+1.18.2
|
||||
fabric_kotlin_version=1.8.0+kotlin.1.7.0
|
||||
|
||||
libblockattributes_version=0.8.5
|
||||
cotton_resources_version=1.7.4
|
||||
modmenu_version=1.16.8
|
||||
libblockattributes_version=0.10.2
|
||||
# cotton_resources_version=1.7.4
|
||||
modmenu_version=3.2.2
|
||||
rei_version=8.2.481
|
||||
mousewheelie_version=1.9.0+mc1.18.2
|
||||
|
||||
junit_version = 5.4.0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
plugins {
|
||||
id "fabric-loom"
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
archivesBaseName = "PhyCon-Plugin-MouseWheelie"
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://maven.siphalor.de/"
|
||||
}
|
||||
maven {
|
||||
url = "https://jitpack.io"
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":")) {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
modImplementation("de.siphalor:mousewheelie-1.18:${project.mousewheelie_version}") {
|
||||
exclude group: "net.fabricmc"
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
exclude module: "modmenu"
|
||||
exclude group: "me.shedaniel.cloth"
|
||||
}
|
||||
}
|
||||
|
|
@ -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.AbstractTerminalScreen;
|
||||
import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreenHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
@Mixin(AbstractTerminalScreen.class)
|
||||
public abstract class MixinTerminalScreen extends HandledScreen<AbstractTerminalScreenHandler> implements ISpecialScrollableScreen, IContainerScreen {
|
||||
|
||||
private MixinTerminalScreen(AbstractTerminalScreenHandler 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"required": true,
|
||||
"package": "net.shadowfacts.phycon.plugin.mousewheelie.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"MixinTerminalScreen"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ plugins {
|
|||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
archivesBaseName = "PhyCon-Plugin-REI"
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
|
@ -11,16 +11,15 @@ repositories {
|
|||
maven {
|
||||
url = "https://maven.shedaniel.me/"
|
||||
}
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":")
|
||||
|
||||
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:${project.rei_version}") {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
implementation(project(":")) {
|
||||
transitive = false
|
||||
}
|
||||
modRuntime("me.shedaniel:RoughlyEnoughItems:${project.rei_version}") {
|
||||
|
||||
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}") {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
archives_base_name=PhyCon-Plugin-REI
|
||||
|
||||
rei_version=5.10.184
|
|
@ -1,27 +0,0 @@
|
|||
package net.shadowfacts.phycon.plugin.rei
|
||||
|
||||
import me.shedaniel.math.Rectangle
|
||||
import me.shedaniel.rei.api.BaseBoundsHandler
|
||||
import me.shedaniel.rei.api.DisplayHelper
|
||||
import me.shedaniel.rei.api.plugins.REIPluginV0
|
||||
import net.minecraft.client.MinecraftClient
|
||||
import net.minecraft.util.Identifier
|
||||
import net.shadowfacts.phycon.block.terminal.TerminalScreen
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
object PhyConPlugin: REIPluginV0 {
|
||||
const val MODID = "phycon_rei"
|
||||
|
||||
override fun getPluginIdentifier() = Identifier(MODID, "rei_plugin")
|
||||
|
||||
override fun registerBounds(helper: DisplayHelper) {
|
||||
BaseBoundsHandler.getInstance().registerExclusionZones(TerminalScreen::class.java) {
|
||||
val screen = MinecraftClient.getInstance().currentScreen as TerminalScreen
|
||||
listOf(
|
||||
Rectangle(screen.sortButtonX, screen.sortButtonY, 20, 20)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package net.shadowfacts.phycon.plugin.rei
|
||||
|
||||
import dev.architectury.event.EventResult
|
||||
import dev.architectury.event.events.client.ClientScreenInputEvent
|
||||
import me.shedaniel.math.Rectangle
|
||||
import me.shedaniel.rei.api.client.REIRuntime
|
||||
import me.shedaniel.rei.api.client.plugins.REIClientPlugin
|
||||
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry
|
||||
import net.fabricmc.api.ClientModInitializer
|
||||
import net.minecraft.client.MinecraftClient
|
||||
import net.shadowfacts.phycon.PhysicalConnectivityClient
|
||||
import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreen
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import java.lang.invoke.MethodHandle
|
||||
import java.lang.invoke.MethodHandles
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
object PhyConPluginClient: ClientModInitializer, REIClientPlugin, AbstractTerminalScreen.SearchQueryListener {
|
||||
|
||||
private val logger = LogManager.getLogger()
|
||||
private var isHighlightingHandle: MethodHandle? = null
|
||||
|
||||
override fun onInitializeClient() {
|
||||
ClientScreenInputEvent.MOUSE_RELEASED_PRE.register { client, screen, mouseX, mouseY, button ->
|
||||
if (screen is AbstractTerminalScreen<*, *>) {
|
||||
REIRuntime.getInstance().searchTextField?.also {
|
||||
if (it.isFocused) {
|
||||
screen.terminalVC.searchField.resignFirstResponder()
|
||||
} else {
|
||||
screen.terminalVC.searchField.becomeFirstResponder()
|
||||
}
|
||||
}
|
||||
}
|
||||
EventResult.pass()
|
||||
}
|
||||
|
||||
AbstractTerminalScreen.searchQueryListener = this
|
||||
try {
|
||||
val clazz = Class.forName("me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField")
|
||||
isHighlightingHandle = MethodHandles.publicLookup().findStaticGetter(clazz, "isHighlighting", Boolean::class.java)
|
||||
} catch (e: ReflectiveOperationException) {
|
||||
logger.warn("Unable to find OverlaySearchField.isHighlighting, highlight sync will be disabled", e)
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerScreens(registry: ScreenRegistry) {
|
||||
registry.exclusionZones().register(AbstractTerminalScreen::class.java) {
|
||||
val screen = MinecraftClient.getInstance().currentScreen as AbstractTerminalScreen<*, *>
|
||||
val view = screen.terminalVC.settingsView
|
||||
val rect = view.convert(view.bounds, to = null)
|
||||
listOf(
|
||||
Rectangle(rect.left.toInt(), rect.top.toInt(), view.bounds.width.toInt(), view.bounds.height.toInt())
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun terminalSearchQueryChanged(newValue: String) {
|
||||
if (shouldSync()) {
|
||||
REIRuntime.getInstance().searchTextField?.text = newValue
|
||||
}
|
||||
}
|
||||
|
||||
override fun requestTerminalSearchFieldUpdate(): String? {
|
||||
return if (shouldSync()) {
|
||||
REIRuntime.getInstance().searchTextField?.text
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun shouldSync(): Boolean {
|
||||
return when (PhysicalConnectivityClient.terminalSettings[PhyConPluginCommon.REI_SYNC_KEY]) {
|
||||
REISyncMode.OFF -> false
|
||||
REISyncMode.ON -> true
|
||||
REISyncMode.HIGHLIGHT_ONLY -> {
|
||||
if (isHighlightingHandle != null) {
|
||||
isHighlightingHandle!!.invoke() as Boolean
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package net.shadowfacts.phycon.plugin.rei
|
||||
|
||||
import me.shedaniel.rei.api.common.category.CategoryIdentifier
|
||||
import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay
|
||||
import me.shedaniel.rei.api.common.plugins.REIServerPlugin
|
||||
import me.shedaniel.rei.api.common.transfer.info.MenuInfoContext
|
||||
import me.shedaniel.rei.api.common.transfer.info.MenuInfoRegistry
|
||||
import me.shedaniel.rei.api.common.transfer.info.simple.SimpleGridMenuInfo
|
||||
import me.shedaniel.rei.api.common.transfer.info.simple.SimpleMenuInfoProvider
|
||||
import me.shedaniel.rei.api.common.transfer.info.stack.SlotAccessor
|
||||
import net.minecraft.util.Identifier
|
||||
import net.shadowfacts.phycon.api.PhyConAPI
|
||||
import net.shadowfacts.phycon.api.PhyConPlugin
|
||||
import net.shadowfacts.phycon.api.TerminalSettingKey
|
||||
import net.shadowfacts.phycon.block.terminal.CraftingTerminalScreenHandler
|
||||
import java.util.stream.IntStream
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
object PhyConPluginCommon: REIServerPlugin, PhyConPlugin {
|
||||
const val MODID = "phycon_rei"
|
||||
|
||||
lateinit var REI_SYNC_KEY: TerminalSettingKey<REISyncMode>
|
||||
private set
|
||||
|
||||
override fun registerMenuInfo(registry: MenuInfoRegistry) {
|
||||
registry.register(CategoryIdentifier.of("minecraft", "plugins/crafting"), CraftingTerminalScreenHandler::class.java, SimpleMenuInfoProvider.of(::TerminalInfo))
|
||||
}
|
||||
|
||||
override fun initializePhyCon(api: PhyConAPI) {
|
||||
REI_SYNC_KEY = api.registerTerminalSetting(Identifier(MODID, "rei_sync"), REISyncMode.OFF)
|
||||
}
|
||||
|
||||
class TerminalInfo<D: SimpleGridMenuDisplay>(
|
||||
private val display: D,
|
||||
): SimpleGridMenuInfo<CraftingTerminalScreenHandler, D> {
|
||||
|
||||
override fun getCraftingResultSlotIndex(menu: CraftingTerminalScreenHandler): Int {
|
||||
return menu.resultSlot.id
|
||||
}
|
||||
|
||||
override fun getInputStackSlotIds(context: MenuInfoContext<CraftingTerminalScreenHandler, *, D>): IntStream {
|
||||
return IntStream.range(context.menu.craftingSlotsStart, context.menu.craftingSlotsEnd)
|
||||
}
|
||||
|
||||
override fun getInventorySlots(context: MenuInfoContext<CraftingTerminalScreenHandler, *, D>): Iterable<SlotAccessor> {
|
||||
val slots = super.getInventorySlots(context).toMutableList()
|
||||
for (i in (context.menu.bufferSlotsStart until context.menu.bufferSlotsEnd)) {
|
||||
slots.add(SlotAccessor.fromSlot(context.menu.getSlot(i)))
|
||||
}
|
||||
return slots
|
||||
}
|
||||
|
||||
override fun getCraftingWidth(menu: CraftingTerminalScreenHandler): Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
override fun getCraftingHeight(menu: CraftingTerminalScreenHandler): Int {
|
||||
return 3
|
||||
}
|
||||
|
||||
override fun getDisplay(): D {
|
||||
return display
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package net.shadowfacts.phycon.plugin.rei
|
||||
|
||||
import net.minecraft.text.LiteralText
|
||||
import net.minecraft.util.Identifier
|
||||
import net.shadowfacts.phycon.PhysicalConnectivity
|
||||
import net.shadowfacts.phycon.api.TerminalSetting
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
enum class REISyncMode: TerminalSetting {
|
||||
OFF,
|
||||
ON,
|
||||
HIGHLIGHT_ONLY;
|
||||
|
||||
override fun getIconTexture() = Identifier(PhysicalConnectivity.MODID, "textures/gui/terminal.png")
|
||||
|
||||
override fun getUV() = when (this) {
|
||||
OFF -> intArrayOf(0, 240)
|
||||
ON -> intArrayOf(16, 240)
|
||||
HIGHLIGHT_ONLY -> intArrayOf(32, 240)
|
||||
}
|
||||
|
||||
override fun getTooltip() = when (this) {
|
||||
OFF -> LiteralText("Don't sync with REI")
|
||||
ON -> LiteralText("Sync with REI")
|
||||
HIGHLIGHT_ONLY -> LiteralText("Sync in highlight mode")
|
||||
}
|
||||
}
|
|
@ -12,12 +12,27 @@
|
|||
"homepage": "https://git.shadowfacts.net/minecraft/PhysicalConnectivity"
|
||||
},
|
||||
"license": "LGPL-3.0",
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"rei_plugins": [
|
||||
"client": [
|
||||
{
|
||||
"adapter": "kotlin",
|
||||
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPlugin"
|
||||
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginClient"
|
||||
}
|
||||
],
|
||||
"rei": [
|
||||
{
|
||||
"adapter": "kotlin",
|
||||
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginClient"
|
||||
},
|
||||
{
|
||||
"adapter": "kotlin",
|
||||
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginCommon"
|
||||
}
|
||||
],
|
||||
"phycon": [
|
||||
{
|
||||
"adapter": "kotlin",
|
||||
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginCommon"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -28,7 +43,7 @@
|
|||
"fabric": "*",
|
||||
"fabric-language-kotlin": ">=1.3.50",
|
||||
"phycon": "*",
|
||||
"roughlyenoughitems": "*"
|
||||
"roughlyenoughitems": ["^7.0.0", "^8.0.0"]
|
||||
},
|
||||
|
||||
"custom": {
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
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.modmuss50.me/"
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":")) {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
modImplementation("TechReborn:TechReborn-1.16:${project.techreborn_version}") {
|
||||
exclude group: "net.fabricmc.fabric-api"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
archives_base_name=PhyCon-Plugin-TechReborn
|
||||
|
||||
techreborn_version=3.8.2+build.222
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package net.shadowfacts.phycon.plugin.techreborn
|
||||
|
||||
import alexiil.mc.lib.attributes.AttributeList
|
||||
import alexiil.mc.lib.attributes.AttributeSourceType
|
||||
import alexiil.mc.lib.attributes.item.GroupedItemInv
|
||||
import alexiil.mc.lib.attributes.item.ItemAttributes
|
||||
import net.fabricmc.api.ModInitializer
|
||||
import net.minecraft.block.BlockState
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity
|
||||
import techreborn.init.TRContent
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
object PhyConTR: ModInitializer {
|
||||
|
||||
override fun onInitialize() {
|
||||
TRContent.StorageUnit.values().forEach {
|
||||
ItemAttributes.GROUPED_INV.setBlockAdder(AttributeSourceType.COMPAT_WRAPPER, it.block, ::addStorageUnitGroupedInv)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addStorageUnitGroupedInv(world: World, pos: BlockPos, state: BlockState, to: AttributeList<GroupedItemInv>) {
|
||||
(world.getBlockEntity(pos) as? StorageUnitBaseBlockEntity)?.also { su ->
|
||||
to.offer(StorageUnitWrapper(su))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package net.shadowfacts.phycon.plugin.techreborn
|
||||
|
||||
import alexiil.mc.lib.attributes.Simulation
|
||||
import alexiil.mc.lib.attributes.item.GroupedItemInv
|
||||
import alexiil.mc.lib.attributes.item.GroupedItemInvView
|
||||
import alexiil.mc.lib.attributes.item.ItemStackCollections
|
||||
import alexiil.mc.lib.attributes.item.ItemStackUtil
|
||||
import alexiil.mc.lib.attributes.item.filter.ItemFilter
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.shadowfacts.phycon.util.copyWithCount
|
||||
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class StorageUnitWrapper(
|
||||
val be: StorageUnitBaseBlockEntity,
|
||||
): GroupedItemInv {
|
||||
|
||||
override fun getStoredStacks(): Set<ItemStack> {
|
||||
val set = ItemStackCollections.set()
|
||||
if (!be.storedStack.isEmpty) {
|
||||
set.add(be.storedStack)
|
||||
}
|
||||
return set
|
||||
}
|
||||
|
||||
override fun getTotalCapacity(): Int {
|
||||
return be.maxCapacity
|
||||
}
|
||||
|
||||
override fun getStatistics(filter: ItemFilter): GroupedItemInvView.ItemInvStatistic {
|
||||
// todo: should spaceAddable really be zero? that's what SimpleGroupedItemInv does
|
||||
return if (be.storedStack.isEmpty) {
|
||||
GroupedItemInvView.ItemInvStatistic(filter, 0, 0, totalCapacity)
|
||||
} else if (filter.matches(be.storedStack)) {
|
||||
// don't use the storedAmount field, it's only used on the client for rendering
|
||||
val amount = be.getStoredAmount()
|
||||
GroupedItemInvView.ItemInvStatistic(filter, amount, 0, totalCapacity - amount)
|
||||
} else {
|
||||
GroupedItemInvView.ItemInvStatistic(filter, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun attemptInsertion(filter: ItemStack, simulation: Simulation): ItemStack {
|
||||
if (simulation.isAction) {
|
||||
return be.processInput(filter)
|
||||
}
|
||||
|
||||
if (be.storedStack.isEmpty) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
if (!ItemStackUtil.areEqualIgnoreAmounts(be.storedStack, filter)) {
|
||||
return filter
|
||||
}
|
||||
|
||||
val availableCapacity = totalCapacity - be.getStoredAmount()
|
||||
return if (availableCapacity >= filter.count) {
|
||||
ItemStack.EMPTY
|
||||
} else {
|
||||
filter.copyWithCount(filter.count - availableCapacity)
|
||||
}
|
||||
}
|
||||
|
||||
override fun attemptExtraction(filter: ItemFilter, maxAmount: Int, simulation: Simulation): ItemStack {
|
||||
if (be.storedStack.isEmpty || !filter.matches(be.storedStack)) {
|
||||
return ItemStack.EMPTY
|
||||
}
|
||||
|
||||
val extracted = min(maxAmount, be.getStoredAmount())
|
||||
|
||||
if (simulation.isAction) {
|
||||
be.storedStack.decrement(extracted)
|
||||
}
|
||||
|
||||
return be.storedStack.copyWithCount(extracted)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "phycon_techreborn",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "PhyCon TechReborn Integration",
|
||||
"description": "",
|
||||
"authors": [
|
||||
"Shadowfacts"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://git.shadowfacts.net/minecraft/PhysicalConnectivity"
|
||||
},
|
||||
"license": "LGPL-3.0",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
{
|
||||
"adapter": "kotlin",
|
||||
"value": "net.shadowfacts.phycon.plugin.techreborn.PhyConTR"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.4.0",
|
||||
"fabric": "*",
|
||||
"fabric-language-kotlin": ">=1.3.50",
|
||||
"phycon": "*",
|
||||
"techreborn": "*"
|
||||
},
|
||||
|
||||
"custom": {
|
||||
"modmenu:parent": "phycon"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
|
@ -10,4 +10,6 @@ pluginManagement {
|
|||
}
|
||||
|
||||
include("kiwi-java")
|
||||
include("plugin:mousewheelie")
|
||||
include("plugin:rei")
|
||||
// include("plugin:techreborn")
|
||||
|
|
|
@ -16,4 +16,6 @@ public interface Interface {
|
|||
|
||||
void send(@NotNull EthernetFrame frame);
|
||||
|
||||
default void cableDisconnected() {}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package net.shadowfacts.phycon.api;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public interface PhyConAPI {
|
||||
|
||||
@NotNull
|
||||
<E extends Enum<E> & TerminalSetting> TerminalSettingKey<E> registerTerminalSetting(Identifier id, E defaultValue);
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package net.shadowfacts.phycon.api;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public interface PhyConPlugin {
|
||||
|
||||
void initializePhyCon(@NotNull PhyConAPI api);
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package net.shadowfacts.phycon.api;
|
||||
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public interface TerminalSetting {
|
||||
|
||||
Identifier getIconTexture();
|
||||
|
||||
int[] getUV();
|
||||
|
||||
@Nullable Text getTooltip();
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package net.shadowfacts.phycon.api;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public interface TerminalSettingKey<E extends Enum<E> & TerminalSetting> {
|
||||
|
||||
Identifier getID();
|
||||
|
||||
E getValue();
|
||||
|
||||
void setPriority(int priority);
|
||||
|
||||
}
|
|
@ -1,12 +1,18 @@
|
|||
package net.shadowfacts.phycon.mixin.client;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.shadowfacts.phycon.block.terminal.TerminalScreen;
|
||||
import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreen;
|
||||
import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreenHandler;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
|
@ -15,12 +21,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
@Mixin(HandledScreen.class)
|
||||
public class MixinHandledScreen {
|
||||
|
||||
@Inject(method = "drawSlot(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/screen/slot/Slot;)V", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableDepthTest()V"))
|
||||
private void drawSlot(MatrixStack matrixStack, Slot slot, CallbackInfo ci) {
|
||||
if ((Object)this instanceof TerminalScreen) {
|
||||
TerminalScreen self = (TerminalScreen)(Object)this;
|
||||
@Inject(
|
||||
method = "drawSlot(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/screen/slot/Slot;)V",
|
||||
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableDepthTest()V")
|
||||
)
|
||||
private void drawSlotUnderlay(MatrixStack matrixStack, Slot slot, CallbackInfo ci) {
|
||||
if ((Object)this instanceof AbstractTerminalScreen<?, ?> self) {
|
||||
self.drawSlotUnderlay(matrixStack, slot);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "drawSlot(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/screen/slot/Slot;)V",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/ItemRenderer;renderGuiItemOverlay(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V")
|
||||
)
|
||||
private void drawSlotAmount(ItemRenderer itemRenderer, TextRenderer textRenderer, ItemStack stack, int x, int y, @Nullable String countLabel, MatrixStack matrixStack, Slot slot) {
|
||||
if ((Object)this instanceof AbstractTerminalScreen<?, ?> self) {
|
||||
AbstractTerminalScreenHandler<?> handler = self.getScreenHandler();
|
||||
if (slot.id < handler.getNetworkSlotsEnd() && stack.getCount() > 1) {
|
||||
self.drawNetworkSlotAmount(stack, x, y);
|
||||
return;
|
||||
}
|
||||
}
|
||||
itemRenderer.renderGuiItemOverlay(textRenderer, stack, x, y, countLabel);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package net.shadowfacts.phycon.mixin.client;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.shadowfacts.cacao.AbstractCacaoScreen;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
@Mixin(MinecraftClient.class)
|
||||
public class MixinMinecraftClient {
|
||||
|
||||
@Inject(
|
||||
method = "setScreen(Lnet/minecraft/client/gui/screen/Screen;)V",
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER)
|
||||
)
|
||||
private void setScreen(Screen screen, CallbackInfo ci) {
|
||||
if (screen instanceof AbstractCacaoScreen cacaoScreen) {
|
||||
cacaoScreen.screenWillAppear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -14,4 +14,6 @@ interface AbstractCacaoScreen {
|
|||
|
||||
fun removeWindow(window: Window)
|
||||
|
||||
}
|
||||
fun screenWillAppear()
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.shadowfacts.cacao
|
||||
|
||||
import net.minecraft.client.MinecraftClient
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen
|
||||
import net.minecraft.client.util.math.MatrixStack
|
||||
import net.minecraft.entity.player.PlayerInventory
|
||||
|
@ -12,6 +13,8 @@ import net.shadowfacts.cacao.util.MouseButton
|
|||
import net.shadowfacts.cacao.util.RenderHelper
|
||||
import net.shadowfacts.cacao.window.ScreenHandlerWindow
|
||||
import net.shadowfacts.cacao.window.Window
|
||||
import org.lwjgl.glfw.GLFW
|
||||
import org.lwjgl.opengl.GL11
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
|
@ -27,10 +30,16 @@ open class CacaoHandledScreen<Handler: ScreenHandler>(
|
|||
|
||||
override val windows: List<Window> = _windows
|
||||
|
||||
private var hasAppeared = false
|
||||
|
||||
|
||||
override fun <T: Window> addWindow(window: T, index: Int): T {
|
||||
if (window is ScreenHandlerWindow && window.screenHandler != handler) {
|
||||
throw RuntimeException("Adding ScreenHandlerWindow to CacaoHandledScreen with different screen handler is not supported")
|
||||
}
|
||||
if (hasAppeared) {
|
||||
window.viewController.viewWillAppear()
|
||||
}
|
||||
|
||||
_windows.add(index, window)
|
||||
|
||||
|
@ -47,6 +56,15 @@ open class CacaoHandledScreen<Handler: ScreenHandler>(
|
|||
|
||||
override fun removeWindow(window: Window) {
|
||||
_windows.remove(window)
|
||||
if (windows.isEmpty()) {
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
override fun screenWillAppear() {
|
||||
windows.forEach {
|
||||
it.viewController.viewWillAppear()
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
|
@ -57,8 +75,18 @@ open class CacaoHandledScreen<Handler: ScreenHandler>(
|
|||
}
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
super.close()
|
||||
|
||||
windows.forEach {
|
||||
it.viewController.viewWillDisappear()
|
||||
it.viewController.viewDidDisappear()
|
||||
|
||||
it.firstResponder = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun drawBackground(matrixStack: MatrixStack, delta: Float, mouseX: Int, mouseY: Int) {
|
||||
renderBackground(matrixStack)
|
||||
}
|
||||
|
||||
override fun drawForeground(matrixStack: MatrixStack, mouseX: Int, mouseY: Int) {
|
||||
|
@ -67,15 +95,28 @@ open class CacaoHandledScreen<Handler: ScreenHandler>(
|
|||
|
||||
override fun render(matrixStack: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) {
|
||||
val mouse = Point(mouseX, mouseY)
|
||||
windows.forEachIndexed { index, it ->
|
||||
|
||||
matrixStack.push()
|
||||
matrixStack.translate(0.0, 0.0, -350.0)
|
||||
|
||||
for (i in windows.indices) {
|
||||
val it = windows[i]
|
||||
|
||||
if (i == windows.size - 1) {
|
||||
renderBackground(matrixStack)
|
||||
}
|
||||
|
||||
if (it is ScreenHandlerWindow) {
|
||||
if (index == windows.size - 1) {
|
||||
if (i == windows.size - 1) {
|
||||
super.render(matrixStack, mouseX, mouseY, delta)
|
||||
} else {
|
||||
// if the screen handler window is not the frontmost, we fake the mouse x/y to disable the slot mouseover effect
|
||||
super.render(matrixStack, -1, -1, delta)
|
||||
}
|
||||
|
||||
matrixStack.pop()
|
||||
}
|
||||
|
||||
it.draw(matrixStack, mouse, delta)
|
||||
}
|
||||
|
||||
|
@ -95,12 +136,49 @@ open class CacaoHandledScreen<Handler: ScreenHandler>(
|
|||
}
|
||||
}
|
||||
|
||||
override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
|
||||
val modifiersSet by lazy { KeyModifiers(modifiers) }
|
||||
if (findResponder { it.keyPressed(keyCode, modifiersSet) }) {
|
||||
return true
|
||||
override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean {
|
||||
val window = windows.lastOrNull()
|
||||
val startPoint = Point(mouseX, mouseY)
|
||||
val delta = Point(deltaX, deltaY)
|
||||
val result = window?.mouseDragged(startPoint, delta, MouseButton.fromMC(button))
|
||||
return if (result == true) {
|
||||
true
|
||||
} else if (window is ScreenHandlerWindow) {
|
||||
return super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override fun mouseReleased(mouseX: Double, mouseY: Double, button: Int): Boolean {
|
||||
val window = windows.lastOrNull()
|
||||
val result = window?.mouseReleased(Point(mouseX, mouseY), MouseButton.fromMC(button))
|
||||
return if (result == true) {
|
||||
true
|
||||
} else if (window is ScreenHandlerWindow) {
|
||||
super.mouseReleased(mouseX, mouseY, button)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override fun mouseScrolled(mouseX: Double, mouseY: Double, amount: Double): Boolean {
|
||||
val window = windows.lastOrNull()
|
||||
val result = window?.mouseScrolled(Point(mouseX, mouseY), amount)
|
||||
return result == true
|
||||
}
|
||||
|
||||
override fun keyPressed(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
|
||||
if (keyCode == GLFW.GLFW_KEY_ESCAPE) {
|
||||
windows.lastOrNull()?.removeFromScreen()
|
||||
return true
|
||||
} else {
|
||||
val modifiersSet by lazy { KeyModifiers(modifiers) }
|
||||
if (findResponder { it.keyPressed(keyCode, modifiersSet) }) {
|
||||
return true
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, modifiers)
|
||||
}
|
||||
return super.keyPressed(keyCode, scanCode, modifiers)
|
||||
}
|
||||
|
||||
override fun charTyped(char: Char, modifiers: Int): Boolean {
|
||||
|
@ -111,4 +189,8 @@ open class CacaoHandledScreen<Handler: ScreenHandler>(
|
|||
return super.charTyped(char, modifiers)
|
||||
}
|
||||
|
||||
override fun shouldCloseOnEsc(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.shadowfacts.cacao
|
||||