diff --git a/build.gradle b/build.gradle index d5691bd..496256d 100644 --- a/build.gradle +++ b/build.gradle @@ -17,12 +17,9 @@ minecraft { } repositories { - maven { - url = "https://mod-buildcraft.com/maven" - } - maven { - url = "http://server.bbkr.space:8081/artifactory/libs-release/" - } + maven { url "https://mod-buildcraft.com/maven" } + maven { url "http://server.bbkr.space:8081/artifactory/libs-release/" } + maven { url "https://maven.terraformersmc.com/releases" } jcenter() } @@ -42,10 +39,15 @@ dependencies { include "alexiil.mc.lib:libblockattributes-core:${project.libblockattributes_version}" include "alexiil.mc.lib:libblockattributes-items:${project.libblockattributes_version}" - modImplementation "io.github.cottonmc:cotton-resources:${project.cotton_resources_version}" - + compile project(":kiwi-java") shadow project(":kiwi-java") + runtimeOnly project(":plugin:rei") + include project(":plugin:rei") + + modRuntime "io.github.cottonmc:cotton-resources:${project.cotton_resources_version}" + modRuntime "com.terraformersmc:modmenu:${project.modmenu_version}" + testImplementation "org.junit.jupiter:junit-jupiter:${project.junit_version}" } @@ -64,6 +66,10 @@ tasks.withType(JavaCompile) { options.encoding = "UTF-8" } +compileKotlin { + kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8 +} + java { // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. diff --git a/gradle.properties b/gradle.properties index fac6c94..b8bded0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,6 @@ fabric_kotlin_version=1.4.30+build.2 libblockattributes_version=0.8.5 cotton_resources_version=1.7.4 +modmenu_version=1.16.8 junit_version = 5.4.0 diff --git a/plugin/rei/build.gradle b/plugin/rei/build.gradle new file mode 100644 index 0000000..c485455 --- /dev/null +++ b/plugin/rei/build.gradle @@ -0,0 +1,66 @@ +plugins { + id "fabric-loom" + id "org.jetbrains.kotlin.jvm" +} + +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 + +archivesBaseName = project.archives_base_name +version = project.mod_version +group = project.maven_group + +minecraft { + log4jConfigs.from "PhyConDebugLogging.xml" +} + +repositories { + maven { + url = "https://maven.shedaniel.me/" + } + jcenter() +} + +dependencies { + //to change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}" + + implementation project(":") + + modCompileOnly "me.shedaniel:RoughlyEnoughItems-api:${project.rei_version}" + modRuntime "me.shedaniel:RoughlyEnoughItems:${project.rei_version}" +} + +processResources { + inputs.property "version", project.version + + filesMatching("fabric.mod.json") { + expand "version": project.version + } +} + +// ensure that the encoding is set to UTF-8, no matter what the system default is +// this fixes some edge cases with special characters not displaying correctly +// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() +} + +jar { + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}" } + } +} diff --git a/plugin/rei/gradle.properties b/plugin/rei/gradle.properties new file mode 100644 index 0000000..15f3835 --- /dev/null +++ b/plugin/rei/gradle.properties @@ -0,0 +1,3 @@ +archives_base_name=PhyCon-Plugin-REI + +rei_version=5.10.184 diff --git a/plugin/rei/src/main/kotlin/net/shadowfacts/phycon/plugin/rei/PhyConPlugin.kt b/plugin/rei/src/main/kotlin/net/shadowfacts/phycon/plugin/rei/PhyConPlugin.kt new file mode 100644 index 0000000..7ac874f --- /dev/null +++ b/plugin/rei/src/main/kotlin/net/shadowfacts/phycon/plugin/rei/PhyConPlugin.kt @@ -0,0 +1,27 @@ +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) + ) + } + } +} diff --git a/plugin/rei/src/main/resources/fabric.mod.json b/plugin/rei/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..5157665 --- /dev/null +++ b/plugin/rei/src/main/resources/fabric.mod.json @@ -0,0 +1,32 @@ +{ + "schemaVersion": 1, + "id": "phycon_rei", + "version": "${version}", + + "name": "PhyCon REI Integration", + "description": "", + "authors": [ + "Shadowfacts" + ], + "contact": { + "homepage": "https://git.shadowfacts.net/minecraft/PhysicalConnectivity" + }, + "license": "LGPL-3.0", + "environment": "client", + "entrypoints": { + "rei_plugins": [ + { + "adapter": "kotlin", + "value": "net.shadowfacts.phycon.plugin.rei.PhyConPlugin" + } + ] + }, + "mixins": [ + ], + "depends": { + "fabricloader": ">=0.4.0", + "fabric": "*", + "fabric-language-kotlin": ">=1.3.50", + "phycon": "*" + } +} diff --git a/settings.gradle b/settings.gradle index c5faca1..4fac6d3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,3 +10,4 @@ pluginManagement { } include("kiwi-java") +include("plugin:rei") diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalScreen.kt b/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalScreen.kt index f6a23e5..151b144 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalScreen.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalScreen.kt @@ -43,6 +43,10 @@ class TerminalScreen(handler: TerminalScreenHandler, playerInv: PlayerInventory, private lateinit var searchBox: TextFieldWidget private lateinit var sortButton: SortButton + var sortButtonX: Int = 0 + private set + var sortButtonY = 0 + private set private lateinit var amountBox: TextFieldWidget private var dialogStack = ItemStack.EMPTY private var showingAmountDialog = false @@ -95,7 +99,9 @@ class TerminalScreen(handler: TerminalScreenHandler, playerInv: PlayerInventory, searchBox.setEditableColor(0xffffff) addChild(searchBox) - sortButton = SortButton(x + 256, y + 0, handler.sortMode, { + sortButtonX = x + 256 + sortButtonY = y + sortButton = SortButton(sortButtonX, sortButtonY, handler.sortMode, { requestUpdatedItems() }, ::renderTooltip) addButton(sortButton)