Compare commits

..

2 Commits

6 changed files with 63 additions and 4 deletions

View File

@ -41,4 +41,5 @@ object PhyConPlugin: ClientModInitializer, REIPluginV0 {
)
}
}
}

View File

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

View File

@ -12,8 +12,13 @@
"homepage": "https://git.shadowfacts.net/minecraft/PhysicalConnectivity"
},
"license": "LGPL-3.0",
"environment": "client",
"entrypoints": {
"main": [
{
"adapter": "kotlin",
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginCommon"
}
],
"client": [
{
"adapter": "kotlin",
@ -34,7 +39,7 @@
"fabric": "*",
"fabric-language-kotlin": ">=1.3.50",
"phycon": "*",
"roughlyenoughitems": "*"
"roughlyenoughitems": "^5.0.0"
},
"custom": {

View File

@ -171,7 +171,7 @@ abstract class AbstractTerminalScreen<BE: AbstractTerminalBlockEntity, T: Abstra
override fun onMouseClick(slot: Slot?, invSlot: Int, clickData: Int, type: SlotActionType?) {
super.onMouseClick(slot, invSlot, clickData, type)
if (slot != null && !slot.stack.isEmpty && handler.isNetworkSlot(slot.id)) {
if (slot != null && !slot.stack.isEmpty && handler.isNetworkSlot(slot.id) && playerInventory.cursorStack.isEmpty) {
val stack = slot.stack
if (type == SlotActionType.QUICK_MOVE) {

View File

@ -29,6 +29,10 @@ class CraftingTerminalScreenHandler(
val result = CraftingResultInventory()
val resultSlot: CraftingResultSlot
val craftingSlotsStart: Int
val craftingSlotsEnd: Int
get() = craftingSlotsStart + 9
override val xOffset: Int
get() = 5
@ -40,6 +44,7 @@ class CraftingTerminalScreenHandler(
)
init {
craftingSlotsStart = slots.size
for (y in 0 until 3) {
for (x in 0 until 3) {
this.addSlot(Slot(craftingInv, x + y * 3, 13 + x * 18, 140 + y * 18))

View File

@ -1,6 +1,7 @@
package net.shadowfacts.phycon.block.terminal
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.screen.Screen
import net.minecraft.client.util.InputUtil
import net.minecraft.text.TranslatableText
import net.minecraft.util.Identifier
@ -89,7 +90,7 @@ class CraftingTerminalViewController(
private fun plusPressed(button: Button) {
val client = MinecraftClient.getInstance()
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
} else {
C2STerminalCraftingButton.Action.REQUEST_ONE_MORE