ExtraHoppers-forge/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/GUIFluidHopper.kt

96 lines
2.2 KiB
Kotlin
Raw Normal View History

2017-01-15 00:41:01 +00:00
package net.shadowfacts.extrahoppers.block.fluid
import net.minecraft.client.gui.inventory.GuiContainer
import net.minecraft.inventory.Container
import net.minecraft.util.ResourceLocation
2017-07-02 17:59:13 +00:00
import net.shadowfacts.extrahoppers.ExtraHoppers
2017-01-15 00:41:01 +00:00
import net.shadowfacts.extrahoppers.MOD_ID
import net.shadowfacts.extrahoppers.gui.element.UIFilterButton
2017-01-15 00:41:01 +00:00
import net.shadowfacts.extrahoppers.gui.element.UIFluidIndicator
2017-07-02 17:59:13 +00:00
import net.shadowfacts.extrahoppers.network.PacketSetHopperFilterMode
import net.shadowfacts.extrahoppers.network.PacketSetHopperRedstoneMode
import net.shadowfacts.extrahoppers.util.filter.FilterMode
2017-01-15 16:46:04 +00:00
import net.shadowfacts.shadowmc.ui.dsl.container
2017-01-15 00:41:01 +00:00
/**
* @author shadowfacts
*/
object GUIFluidHopper {
2017-07-02 15:50:39 +00:00
private val BG = ResourceLocation(MOD_ID, "textures/gui/fluid_hopper.png")
2017-07-02 17:59:13 +00:00
private val FILTER_BG = ResourceLocation(MOD_ID, "textures/gui/filter.png")
2017-01-15 00:41:01 +00:00
2017-07-02 17:59:13 +00:00
fun create(tile: TileEntityFluidHopper, container: Container): GuiContainer {
2017-01-15 00:41:01 +00:00
return container(container) {
fixed {
id = "root"
2017-07-02 17:59:13 +00:00
width = 176 + 83 * 2
2017-01-15 00:41:01 +00:00
height = 166
image {
id = "bg"
width = 176
height = 166
texture = BG
}
fixed {
id = "top"
width = 176
height = 166 / 2
2017-07-02 17:59:13 +00:00
add(UIFluidIndicator(tile.tank, "fluidIndicator"))
if (tile.advanced) {
add(UIFilterButton({
// TODO
}, "filter"))
buttonRedstoneMode {
id = "mode"
2017-07-02 17:59:13 +00:00
mode = tile.mode
callback = {
2017-07-02 17:59:13 +00:00
tile.mode = it
ExtraHoppers.network.sendToServer(PacketSetHopperRedstoneMode(tile))
}
}
2017-07-02 17:59:13 +00:00
}
}
2017-07-02 17:59:13 +00:00
if (tile.advanced) {
fixed {
id = "filter-container"
width = 83
height = 86
image {
id = "filter-bg"
width = 83
height = 86
texture = FILTER_BG
}
fixed {
id = "filter-bottom"
width = 83
height = 34
buttonEnum(FilterMode::class.java) {
id = "filter-mode"
value = tile.filterMode
localizer = FilterMode::localize
clickHandler = {
tile.filterMode = it.value
ExtraHoppers.network.sendToServer(PacketSetHopperFilterMode(tile))
}
}
}
}
2017-01-15 00:41:01 +00:00
}
}
style("$MOD_ID:fluid_hopper")
}
}
}