Is it possible to build a CraftingInventory
object with an Inventory.Builder
?
I’m trying to make a CraftingInventory
with a crafting grid of whatever size I choose, e.g. 3x4. And ultimately, I would like to be able to pass the custom inventory to CraftingRecipe::isValid
.
I’m currently attempting to query for a CraftingInventory, but a ClassCastException
is being thrown.
val craftingInv = Inventory.builder()
.of(InventoryArchetypes.WORKBENCH)
.property(
InventoryDimension.PROPERTY_NAME,
InventoryDimension(3, 4)
)
.build(this)
.query<CraftingInventory>(CraftingInventory::class.java)
java.lang.ClassCastException: org.spongepowered.common.item.inventory.EmptyInventoryImpl cannot be cast to org.spongepowered.api.item.inventory.crafting.CraftingInventory
at net.benwoodworth.fastcraft.impl.sponge.SpongeFastCraft.onPreInit(SpongeFastCraft.kt:48) ~[SpongeFastCraft.class:?]
at org.spongepowered.common.event.listener.GamePreInitializationEventListener_SpongeFastCraft_onPreInit3.handle(Unknown Source) ~[?:?]
at org.spongepowered.common.event.RegisteredListener.handle(RegisteredListener.java:95) ~[RegisteredListener.class:1.12-7.0.0-BETA-300]
at org.spongepowered.common.event.SpongeEventManager.post(SpongeEventManager.java:349) [SpongeEventManager.class:1.12-7.0.0-BETA-300]
at org.spongepowered.common.event.SpongeEventManager.post(SpongeEventManager.java:366) [SpongeEventManager.class:1.12-7.0.0-BETA-300]
at org.spongepowered.common.event.SpongeEventManager.post(SpongeEventManager.java:370) [SpongeEventManager.class:1.12-7.0.0-BETA-300]
at org.spongepowered.common.SpongeImpl.postState(SpongeImpl.java:205) [SpongeImpl.class:1.12-7.0.0-BETA-300]
at org.spongepowered.server.SpongeVanilla.preInitialize(SpongeVanilla.java:125) [SpongeVanilla.class:1.12-7.0.0-BETA-300]
at net.minecraft.server.dedicated.DedicatedServer.handler$onServerLoad$zog000(SourceFile:1228) [nx.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(SourceFile:114) [nx.class:?]
at net.minecraft.server.MinecraftServer.run(SourceFile:434) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]