-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b876030
commit 1f586d1
Showing
25 changed files
with
528 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 31 additions & 2 deletions
33
src/main/java/com/projecturanus/foodcraft/client/gui/GuiContainerPan.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
package com.projecturanus.foodcraft.client.gui | ||
|
||
import com.projecturanus.foodcraft.MODID | ||
import com.projecturanus.foodcraft.common.block.container.ContainerMachine | ||
import com.projecturanus.foodcraft.client.gui.widget.WidgetCookBar | ||
import com.projecturanus.foodcraft.client.gui.widget.WidgetHeat | ||
import com.projecturanus.foodcraft.client.gui.widget.WidgetProgressBar | ||
import com.projecturanus.foodcraft.common.block.container.ContainerPan | ||
import net.minecraft.util.ResourceLocation | ||
|
||
val PAN_TEXTURES = ResourceLocation(MODID, "textures/gui/container/pan.png") | ||
|
||
class GuiContainerPan(container: ContainerMachine) : GuiContainerMachine(container, PAN_TEXTURES) { | ||
class GuiContainerPan(override val container: ContainerPan) : GuiContainerMachine(container, PAN_TEXTURES) { | ||
val tileEntity by lazy { container.tileEntity } | ||
val heatHandler by lazy { tileEntity.heatHandler } | ||
val progress get() = container.progress / container.minProgress.toDouble() | ||
val overcookProgress get() = (container.progress - container.minProgress) / (container.maxProgress - container.minProgress).toDouble() | ||
|
||
val widgetHeat = WidgetHeat(176, 0, container::heat.getter) | ||
val widgetProgress by lazy { WidgetProgressBar(176, 14, this::progress.getter) } | ||
val widgetCookBar by lazy { WidgetCookBar(176, 31, this::overcookProgress.getter) } | ||
|
||
override fun initGui() { | ||
super.initGui() | ||
widgetHeat.temperature = heatHandler | ||
widgetHeat.setWorldAndResolution(mc, width, height) | ||
widgetProgress.setWorldAndResolution(mc, width, height) | ||
widgetCookBar.setWorldAndResolution(mc, width, height) | ||
} | ||
|
||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int) { | ||
super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY) | ||
val i = (width - xSize) / 2 | ||
val j = (height - ySize) / 2 | ||
|
||
widgetHeat.draw(i + 81, j + 19, mouseX, mouseY, partialTicks) | ||
widgetProgress.draw(i + 72, j + 39, mouseX, mouseY, partialTicks) | ||
widgetCookBar.draw(i + 46, j + 62, mouseX, mouseY, partialTicks) | ||
} | ||
} |
33 changes: 31 additions & 2 deletions
33
src/main/java/com/projecturanus/foodcraft/client/gui/GuiContainerPot.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
package com.projecturanus.foodcraft.client.gui | ||
|
||
import com.projecturanus.foodcraft.MODID | ||
import com.projecturanus.foodcraft.common.block.container.ContainerMachine | ||
import com.projecturanus.foodcraft.client.gui.widget.WidgetCookBar | ||
import com.projecturanus.foodcraft.client.gui.widget.WidgetHeat | ||
import com.projecturanus.foodcraft.client.gui.widget.WidgetProgressBar | ||
import com.projecturanus.foodcraft.common.block.container.ContainerPot | ||
import net.minecraft.util.ResourceLocation | ||
|
||
val POT_TEXTURES = ResourceLocation(MODID, "textures/gui/container/pot.png") | ||
|
||
class GuiContainerPot(container: ContainerMachine) : GuiContainerMachine(container, POT_TEXTURES) { | ||
class GuiContainerPot(override val container: ContainerPot) : GuiContainerMachine(container, POT_TEXTURES) { | ||
val tileEntity by lazy { container.tileEntity } | ||
val heatHandler by lazy { tileEntity.heatHandler } | ||
val progress get() = container.progress / container.minProgress.toDouble() | ||
val overcookProgress get() = (container.progress - container.minProgress) / (container.maxProgress - container.minProgress).toDouble() | ||
|
||
val widgetHeat = WidgetHeat(176, 0, container::heat.getter) | ||
val widgetProgress by lazy { WidgetProgressBar(176, 15, this::progress.getter) } | ||
val widgetCookBar by lazy { WidgetCookBar(176, 31, this::overcookProgress.getter) } | ||
|
||
override fun initGui() { | ||
super.initGui() | ||
widgetHeat.temperature = heatHandler | ||
widgetHeat.setWorldAndResolution(mc, width, height) | ||
widgetProgress.setWorldAndResolution(mc, width, height) | ||
widgetCookBar.setWorldAndResolution(mc, width, height) | ||
} | ||
|
||
override fun drawGuiContainerBackgroundLayer(partialTicks: Float, mouseX: Int, mouseY: Int) { | ||
super.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY) | ||
val i = (width - xSize) / 2 | ||
val j = (height - ySize) / 2 | ||
|
||
widgetHeat.draw(i + 81, j + 64, mouseX, mouseY, partialTicks) | ||
widgetProgress.draw(i + 93, j + 20, mouseX, mouseY, partialTicks) | ||
widgetCookBar.draw(i + 48, j + 38, mouseX, mouseY, partialTicks) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/projecturanus/foodcraft/client/gui/widget/WidgetCookBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.projecturanus.foodcraft.client.gui.widget | ||
|
||
import kotlin.reflect.KProperty0 | ||
|
||
class WidgetCookBar(val x: Int, val y: Int, val progress: KProperty0.Getter<Double>) : Widget() { | ||
|
||
companion object { | ||
const val WIDTH = 78 | ||
const val HEIGHT = 3 | ||
} | ||
|
||
override fun isMouseIn(x: Int, y: Int, mouseX: Int, mouseY: Int): Boolean { | ||
return mouseX > x && mouseY > y && mouseX < x + WIDTH && mouseY < y + HEIGHT | ||
} | ||
|
||
override fun draw(x: Int, y: Int, mouseX: Int, mouseY: Int, partialTicks: Float) { | ||
val l: Int = (progress.invoke() * WIDTH).toInt() | ||
this.drawTexturedModalRect(x, y, this.x, this.y, l, HEIGHT) | ||
if (isMouseIn(x, y, mouseX, mouseY) && l >= 0) { | ||
this.drawHoveringText(listOf("Overcooked progress: ${progress.invoke()}"), x, y, fontRenderer) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 73 additions & 1 deletion
74
src/main/java/com/projecturanus/foodcraft/common/block/entity/TileEntityPan.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,76 @@ | ||
package com.projecturanus.foodcraft.common.block.entity | ||
|
||
class TileEntityPan : TileEntityMachine(4) { | ||
import com.projecturanus.foodcraft.common.heat.FuelHeatHandler | ||
import com.projecturanus.foodcraft.common.init.FCRItems | ||
import com.projecturanus.foodcraft.common.recipe.PAN_RECIPES | ||
import com.projecturanus.foodcraft.common.recipe.PanRecipe | ||
import com.projecturanus.foodcraft.common.util.get | ||
import com.projecturanus.foodcraft.common.util.shrink | ||
import net.minecraft.item.ItemStack | ||
import org.cyclops.commoncapabilities.api.capability.temperature.ITemperature | ||
|
||
class TileEntityPan : TileEntityHeatRecipeMachine<PanRecipe>(PAN_RECIPES, 0..0, 1..1, 3) { | ||
var waitingExtract = false | ||
|
||
init { | ||
inventory.contentChangedListener += { | ||
if (it == 1 && inventory[1].isEmpty) { | ||
reset() | ||
} | ||
} | ||
} | ||
|
||
override fun update() { | ||
// Don't run tick on client | ||
if (world.isRemote) return | ||
|
||
beforeProgress() | ||
|
||
if (recipe != null) { | ||
// Finish | ||
if (canFinish()) { | ||
consumeInput() | ||
working = false | ||
val stack = recipe?.getRecipeOutput()?.copy()?: ItemStack.EMPTY | ||
inventory.insertItem(1, stack, false) | ||
waitingExtract = true | ||
markDirty() | ||
} else if (waitingExtract && progress > recipe!!.maxTime) { // Overcooked | ||
inventory.shrink(1) | ||
inventory.insertItem(2, ItemStack(FCRItems.OVERCOOKED_FOOD), false) | ||
reset() | ||
} else { | ||
if (canProgress()) | ||
progress++ | ||
working = true | ||
} | ||
} else if (progress > 0) { | ||
progress = 0 | ||
working = false | ||
} | ||
} | ||
|
||
override fun reset() { | ||
waitingExtract = false | ||
progress = 0 | ||
markDirty() | ||
recipe = findRecipe() | ||
} | ||
|
||
override fun beforeProgress() { | ||
heatHandler.update(0.0) | ||
} | ||
|
||
override fun canProgress(): Boolean = heatHandler.temperature > ITemperature.ZERO_CELCIUS + 80 | ||
|
||
override fun canFinish(): Boolean = progress > recipe?.minTime ?: Int.MAX_VALUE && progress < recipe?.maxTime ?: -1 && !waitingExtract | ||
|
||
override fun createFuelHandler(): FuelHeatHandler { | ||
val heatHandler = FuelHeatHandler() | ||
heatHandler.radiation = 0.02 | ||
heatHandler.heatPower = 1.0 | ||
heatHandler.minHeat = ITemperature.ZERO_CELCIUS | ||
heatHandler.setMaxHeat(ITemperature.ZERO_CELCIUS + 160) | ||
return heatHandler | ||
} | ||
} |
Oops, something went wrong.