forked from mirrors/cobblemon
preview item no longer drops, but also doesnt display
This commit is contained in:
@@ -46,6 +46,7 @@ class CookingPotMenu : RecipeBookMenu<CraftingInput, CookingPotRecipeBase>, Cont
|
||||
val containerData: ContainerData
|
||||
private val recipeType: RecipeType<CookingPotRecipe> = CobblemonRecipeTypes.COOKING_POT_COOKING
|
||||
private val quickCheck = RecipeManager.createCheck(CobblemonRecipeTypes.COOKING_POT_COOKING)
|
||||
val blockEntity: CampfireBlockEntity?
|
||||
|
||||
constructor(containerId: Int, playerInventory: Inventory) : super(CobblemonMenuType.COOKING_POT, containerId) {
|
||||
this.playerInventory = playerInventory
|
||||
@@ -53,6 +54,7 @@ class CookingPotMenu : RecipeBookMenu<CraftingInput, CookingPotRecipeBase>, Cont
|
||||
CampfireBlockEntity.Companion.CRAFTING_GRID_WIDTH,
|
||||
CampfireBlockEntity.Companion.CRAFTING_GRID_WIDTH
|
||||
)
|
||||
this.blockEntity = null
|
||||
this.resultContainer = ResultContainer()
|
||||
this.containerData = SimpleContainerData(3)
|
||||
this.addDataSlots(containerData)
|
||||
@@ -61,11 +63,12 @@ class CookingPotMenu : RecipeBookMenu<CraftingInput, CookingPotRecipeBase>, Cont
|
||||
initializeSlots(playerInventory)
|
||||
}
|
||||
|
||||
constructor(containerId: Int, playerInventory: Inventory, container: CraftingContainer, containerData: ContainerData) : super(
|
||||
constructor(containerId: Int, playerInventory: Inventory, container: CraftingContainer, containerData: ContainerData, blockEntity: CampfireBlockEntity) : super(
|
||||
CobblemonMenuType.COOKING_POT, containerId) {
|
||||
this.playerInventory = playerInventory
|
||||
this.container = container
|
||||
this.containerData = containerData
|
||||
this.blockEntity = blockEntity
|
||||
this.addDataSlots(containerData)
|
||||
this.resultContainer = ResultContainer()
|
||||
this.player = playerInventory.player
|
||||
@@ -92,7 +95,7 @@ class CookingPotMenu : RecipeBookMenu<CraftingInput, CookingPotRecipeBase>, Cont
|
||||
}
|
||||
|
||||
addSlot(CookingPotPreviewSlot(this.container,
|
||||
CampfireBlockEntity.Companion.PREVIEW_ITEM_SLOT, resultSlotX, resultSlotY))
|
||||
CampfireBlockEntity.Companion.PREVIEW_ITEM_SLOT, resultSlotX, resultSlotY) {blockEntity?.previewItem ?: ItemStack.EMPTY})
|
||||
|
||||
for ((index, _) in CampfireBlockEntity.Companion.PLAYER_INVENTORY_SLOTS.withIndex()) {
|
||||
val i = index / CampfireBlockEntity.Companion.PLAYER_INVENTORY_WIDTH
|
||||
|
||||
+3
-1
@@ -18,12 +18,14 @@ class CookingPotPreviewSlot(
|
||||
container: CraftingContainer,
|
||||
index: Int,
|
||||
x: Int,
|
||||
y: Int
|
||||
y: Int,
|
||||
val getPreviewItem: () -> ItemStack
|
||||
) : Slot(container, index, x, y) {
|
||||
override fun isActive(): Boolean {
|
||||
return container.getItem(RESULT_SLOT).isEmpty
|
||||
}
|
||||
|
||||
override fun getItem(): ItemStack = getPreviewItem()
|
||||
override fun isFake(): Boolean = true
|
||||
override fun mayPlace(stack: ItemStack): Boolean = false
|
||||
override fun mayPickup(player: Player): Boolean = false
|
||||
|
||||
@@ -160,7 +160,7 @@ class CampfireBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlock
|
||||
|
||||
recipe.applySeasoning(cookedItem, campfireBlockEntity.getSeasonings())
|
||||
|
||||
campfireBlockEntity.setItem(PREVIEW_ITEM_SLOT, cookedItem)
|
||||
campfireBlockEntity.previewItem = cookedItem
|
||||
|
||||
if (campfireBlockEntity.isLidOpen) {
|
||||
campfireBlockEntity.cookingProgress = 0
|
||||
@@ -204,6 +204,7 @@ class CampfireBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlock
|
||||
}
|
||||
}
|
||||
|
||||
var previewItem: ItemStack = ItemStack.EMPTY
|
||||
private val runningSound = CobblemonSounds.CAMPFIRE_POT_COOK
|
||||
private var cookingProgress: Int = 0
|
||||
private var cookingTotalTime: Int = COOKING_TOTAL_TIME
|
||||
@@ -339,7 +340,7 @@ class CampfireBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlock
|
||||
containerId: Int,
|
||||
inventory: Inventory
|
||||
): AbstractContainerMenu {
|
||||
return CookingPotMenu(containerId, inventory, this, this.dataAccess)
|
||||
return CookingPotMenu(containerId, inventory, this, this.dataAccess, this)
|
||||
}
|
||||
|
||||
override fun getContainerSize() = this.items.size
|
||||
|
||||
Reference in New Issue
Block a user