REI: Add support for filling recipes in the Crafting Terminal
This commit is contained in:
parent
236d6707f6
commit
87f0bdb85a
|
@ -41,4 +41,5 @@ object PhyConPlugin: ClientModInitializer, REIPluginV0 {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package net.shadowfacts.phycon.plugin.rei
|
||||||
|
|
||||||
|
import me.shedaniel.rei.server.ContainerContext
|
||||||
|
import me.shedaniel.rei.server.ContainerInfo
|
||||||
|
import me.shedaniel.rei.server.ContainerInfoHandler
|
||||||
|
import me.shedaniel.rei.server.StackAccessor
|
||||||
|
import net.fabricmc.api.ModInitializer
|
||||||
|
import net.minecraft.util.Identifier
|
||||||
|
import net.shadowfacts.phycon.block.terminal.CraftingTerminalScreenHandler
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author shadowfacts
|
||||||
|
*/
|
||||||
|
object PhyConPluginCommon: ModInitializer {
|
||||||
|
|
||||||
|
override fun onInitialize() {
|
||||||
|
ContainerInfoHandler.registerContainerInfo(Identifier("minecraft", "plugins/crafting"), TerminalInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
object TerminalInfo: ContainerInfo<CraftingTerminalScreenHandler> {
|
||||||
|
override fun getContainerClass() = CraftingTerminalScreenHandler::class.java
|
||||||
|
|
||||||
|
override fun getCraftingResultSlotIndex(container: CraftingTerminalScreenHandler): Int {
|
||||||
|
return container.resultSlot.id
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCraftingWidth(container: CraftingTerminalScreenHandler): Int {
|
||||||
|
return 3
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getCraftingHeight(container: CraftingTerminalScreenHandler): Int {
|
||||||
|
return 3
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getGridStacks(context: ContainerContext<CraftingTerminalScreenHandler>): List<StackAccessor> {
|
||||||
|
val handler = context.container
|
||||||
|
return (handler.craftingSlotsStart until handler.craftingSlotsEnd).map(context::getStack)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getInventoryStacks(context: ContainerContext<CraftingTerminalScreenHandler>): List<StackAccessor> {
|
||||||
|
val handler = context.container
|
||||||
|
val slots = (handler.playerSlotsStart until handler.playerSlotsEnd) + (handler.bufferSlotsStart until handler.bufferSlotsEnd)
|
||||||
|
return slots.map(context::getStack)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,8 +12,13 @@
|
||||||
"homepage": "https://git.shadowfacts.net/minecraft/PhysicalConnectivity"
|
"homepage": "https://git.shadowfacts.net/minecraft/PhysicalConnectivity"
|
||||||
},
|
},
|
||||||
"license": "LGPL-3.0",
|
"license": "LGPL-3.0",
|
||||||
"environment": "client",
|
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
|
"main": [
|
||||||
|
{
|
||||||
|
"adapter": "kotlin",
|
||||||
|
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginCommon"
|
||||||
|
}
|
||||||
|
],
|
||||||
"client": [
|
"client": [
|
||||||
{
|
{
|
||||||
"adapter": "kotlin",
|
"adapter": "kotlin",
|
||||||
|
@ -34,7 +39,7 @@
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"fabric-language-kotlin": ">=1.3.50",
|
"fabric-language-kotlin": ">=1.3.50",
|
||||||
"phycon": "*",
|
"phycon": "*",
|
||||||
"roughlyenoughitems": "*"
|
"roughlyenoughitems": "^5.0.0"
|
||||||
},
|
},
|
||||||
|
|
||||||
"custom": {
|
"custom": {
|
||||||
|
|
|
@ -29,6 +29,10 @@ class CraftingTerminalScreenHandler(
|
||||||
val result = CraftingResultInventory()
|
val result = CraftingResultInventory()
|
||||||
val resultSlot: CraftingResultSlot
|
val resultSlot: CraftingResultSlot
|
||||||
|
|
||||||
|
val craftingSlotsStart: Int
|
||||||
|
val craftingSlotsEnd: Int
|
||||||
|
get() = craftingSlotsStart + 9
|
||||||
|
|
||||||
override val xOffset: Int
|
override val xOffset: Int
|
||||||
get() = 5
|
get() = 5
|
||||||
|
|
||||||
|
@ -40,6 +44,7 @@ class CraftingTerminalScreenHandler(
|
||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
craftingSlotsStart = slots.size
|
||||||
for (y in 0 until 3) {
|
for (y in 0 until 3) {
|
||||||
for (x in 0 until 3) {
|
for (x in 0 until 3) {
|
||||||
this.addSlot(Slot(craftingInv, x + y * 3, 13 + x * 18, 140 + y * 18))
|
this.addSlot(Slot(craftingInv, x + y * 3, 13 + x * 18, 140 + y * 18))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.shadowfacts.phycon.block.terminal
|
package net.shadowfacts.phycon.block.terminal
|
||||||
|
|
||||||
import net.minecraft.client.MinecraftClient
|
import net.minecraft.client.MinecraftClient
|
||||||
|
import net.minecraft.client.gui.screen.Screen
|
||||||
import net.minecraft.client.util.InputUtil
|
import net.minecraft.client.util.InputUtil
|
||||||
import net.minecraft.text.TranslatableText
|
import net.minecraft.text.TranslatableText
|
||||||
import net.minecraft.util.Identifier
|
import net.minecraft.util.Identifier
|
||||||
|
@ -89,7 +90,7 @@ class CraftingTerminalViewController(
|
||||||
private fun plusPressed(button: Button) {
|
private fun plusPressed(button: Button) {
|
||||||
val client = MinecraftClient.getInstance()
|
val client = MinecraftClient.getInstance()
|
||||||
val action =
|
val action =
|
||||||
if (InputUtil.isKeyPressed(client.window.handle, GLFW.GLFW_KEY_LEFT_SHIFT) || InputUtil.isKeyPressed(client.window.handle, GLFW.GLFW_KEY_RIGHT_SHIFT)) {
|
if (Screen.hasShiftDown()) {
|
||||||
C2STerminalCraftingButton.Action.REQUEST_MAX_MORE
|
C2STerminalCraftingButton.Action.REQUEST_MAX_MORE
|
||||||
} else {
|
} else {
|
||||||
C2STerminalCraftingButton.Action.REQUEST_ONE_MORE
|
C2STerminalCraftingButton.Action.REQUEST_ONE_MORE
|
||||||
|
|
Loading…
Reference in New Issue