Update REI plugin

This commit is contained in:
Shadowfacts 2021-12-22 22:17:25 -05:00
parent 5488cc295a
commit 30300dbc40
3 changed files with 51 additions and 42 deletions

View File

@ -11,7 +11,7 @@ import net.shadowfacts.phycon.block.terminal.AbstractTerminalScreen
/** /**
* @author shadowfacts * @author shadowfacts
*/ */
object PhyConPlugin: ClientModInitializer, REIClientPlugin { object PhyConPluginClient: ClientModInitializer, REIClientPlugin {
const val MODID = "phycon_rei" const val MODID = "phycon_rei"
override fun onInitializeClient() { override fun onInitializeClient() {

View File

@ -1,45 +1,56 @@
package net.shadowfacts.phycon.plugin.rei package net.shadowfacts.phycon.plugin.rei
import me.shedaniel.rei.api.common.display.Display import me.shedaniel.rei.api.common.category.CategoryIdentifier
import me.shedaniel.rei.api.common.transfer.info.MenuInfo import me.shedaniel.rei.api.common.display.SimpleGridMenuDisplay
import net.fabricmc.api.ModInitializer import me.shedaniel.rei.api.common.plugins.REIServerPlugin
import net.minecraft.util.Identifier 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.shadowfacts.phycon.block.terminal.CraftingTerminalScreenHandler import net.shadowfacts.phycon.block.terminal.CraftingTerminalScreenHandler
import java.util.stream.IntStream
/** /**
* @author shadowfacts * @author shadowfacts
*/ */
object PhyConPluginCommon: ModInitializer { object PhyConPluginCommon: REIServerPlugin {
override fun onInitialize() { override fun registerMenuInfo(registry: MenuInfoRegistry) {
// ContainerInfoHandler.registerContainerInfo(Identifier("minecraft", "plugins/crafting"), TerminalInfo) registry.register(CategoryIdentifier.of("minecraft", "plugins/crafting"), CraftingTerminalScreenHandler::class.java, SimpleMenuInfoProvider.of(::TerminalInfo))
} }
// object TerminalInfo: ContainerInfo<CraftingTerminalScreenHandler> { class TerminalInfo<D: SimpleGridMenuDisplay>(
// override fun getContainerClass() = CraftingTerminalScreenHandler::class.java private val display: D,
// ): SimpleGridMenuInfo<CraftingTerminalScreenHandler, D> {
// override fun getCraftingResultSlotIndex(container: CraftingTerminalScreenHandler): Int {
// return container.resultSlot.id override fun getCraftingResultSlotIndex(menu: CraftingTerminalScreenHandler): Int {
// } return menu.resultSlot.id
// }
// override fun getCraftingWidth(container: CraftingTerminalScreenHandler): Int {
// return 3 override fun getInputStackSlotIds(context: MenuInfoContext<CraftingTerminalScreenHandler, *, D>): IntStream {
// } return IntStream.range(context.menu.craftingSlotsStart, context.menu.craftingSlotsEnd)
// }
// override fun getCraftingHeight(container: CraftingTerminalScreenHandler): Int {
// return 3 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)) {
// override fun getGridStacks(context: ContainerContext<CraftingTerminalScreenHandler>): List<StackAccessor> { slots.add(SlotAccessor.fromSlot(context.menu.getSlot(i)))
// val handler = context.container }
// return (handler.craftingSlotsStart until handler.craftingSlotsEnd).map(context::getStack) return slots
// } }
//
// override fun getInventoryStacks(context: ContainerContext<CraftingTerminalScreenHandler>): List<StackAccessor> { override fun getCraftingWidth(menu: CraftingTerminalScreenHandler): Int {
// val handler = context.container return 3
// val slots = (handler.playerSlotsStart until handler.playerSlotsEnd) + (handler.bufferSlotsStart until handler.bufferSlotsEnd) }
// return slots.map(context::getStack)
// } override fun getCraftingHeight(menu: CraftingTerminalScreenHandler): Int {
// } return 3
}
override fun getDisplay(): D {
return display
}
}
} }

View File

@ -13,22 +13,20 @@
}, },
"license": "LGPL-3.0", "license": "LGPL-3.0",
"entrypoints": { "entrypoints": {
"main": [
{
"adapter": "kotlin",
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginCommon"
}
],
"client": [ "client": [
{ {
"adapter": "kotlin", "adapter": "kotlin",
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPlugin" "value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginClient"
} }
], ],
"rei": [ "rei": [
{ {
"adapter": "kotlin", "adapter": "kotlin",
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPlugin" "value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginClient"
},
{
"adapter": "kotlin",
"value": "net.shadowfacts.phycon.plugin.rei.PhyConPluginCommon"
} }
] ]
}, },