Skip to content

Commit

Permalink
Open crafting table when the crafting table button is pressed.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenWoodworth committed Jan 21, 2020
1 parent 5003c07 commit 39ddc3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,8 @@ class FastCraftGuiModel(
}
}
}

fun openCraftingTable() {
player.openCraftingTable()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import net.benwoodworth.fastcraft.crafting.model.FastCraftRecipe
import net.benwoodworth.fastcraft.crafting.view.FastCraftGuiView
import net.benwoodworth.fastcraft.crafting.view.buttons.PageButtonView
import net.benwoodworth.fastcraft.crafting.view.buttons.RecipeButtonView
import net.benwoodworth.fastcraft.crafting.view.buttons.WorkbenchButtonView
import kotlin.math.ceil

class FastCraftGuiPresenter(
Expand All @@ -23,6 +24,7 @@ class FastCraftGuiPresenter(
get() = (recipesPage - 1) * recipesPerPage

init {
view.workbenchButton.listener = WorkbenchButtonListener()
view.pageButton.listener = PageButtonListener()

view.recipeButtons.forEachIndexed { i, button ->
Expand Down Expand Up @@ -50,6 +52,12 @@ class FastCraftGuiPresenter(
}
}

private inner class WorkbenchButtonListener : WorkbenchButtonView.Listener {
override fun onOpenWorkbench() {
model.openCraftingTable()
}
}

private inner class PageButtonListener : PageButtonView.Listener {
override fun onPageNext() {
recipesPage = when (val page = recipesPage) {
Expand Down

0 comments on commit 39ddc3b

Please sign in to comment.