parent
90544b1ea8
commit
a7c253e986
|
@ -13,7 +13,9 @@ import net.minecraft.world.World
|
|||
import net.minecraftforge.fluids.FluidUtil
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry
|
||||
import net.shadowfacts.extrahoppers.ExtraHoppers
|
||||
import net.shadowfacts.extrahoppers.block.base.BlockHopperBase
|
||||
import net.shadowfacts.extrahoppers.gui.GUIHandler
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
|
@ -27,8 +29,9 @@ class BlockFluidHopper: BlockHopperBase<TileEntityFluidHopper>("fluid_hopper", m
|
|||
}
|
||||
|
||||
override fun onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean {
|
||||
// TODO: GUI
|
||||
if (!player.isSneaking) {
|
||||
if (player.isSneaking) {
|
||||
player.openGui(ExtraHoppers, GUIHandler.FLUID_HOPPER, world, pos.x, pos.y, pos.z)
|
||||
} else {
|
||||
val te = getTileEntity(world, pos)
|
||||
val stack = player.getHeldItem(hand)
|
||||
val result = FluidUtil.interactWithFluidHandler(stack, te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.NORTH), player)
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package net.shadowfacts.extrahoppers.block.fluid
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer
|
||||
import net.minecraft.inventory.Container
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.shadowfacts.extrahoppers.MOD_ID
|
||||
import net.shadowfacts.extrahoppers.gui.element.UIFluidIndicator
|
||||
import net.shadowfacts.shadowmc.ui.dsl.*
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
object GUIFluidHopper {
|
||||
|
||||
private val BG = ResourceLocation("shadowmc", "textures/gui/blank.png")
|
||||
|
||||
fun create(hopper: TileEntityFluidHopper, container: Container): GuiContainer {
|
||||
return container(container) {
|
||||
fixed {
|
||||
id = "root"
|
||||
width = 176
|
||||
height = 166
|
||||
|
||||
image {
|
||||
id = "bg"
|
||||
width = 176
|
||||
height = 166
|
||||
texture = BG
|
||||
}
|
||||
|
||||
fixed {
|
||||
id = "top"
|
||||
width = 176
|
||||
height = 166 / 2
|
||||
|
||||
add(UIFluidIndicator(hopper.tank, "fluidIndicator"))
|
||||
}
|
||||
}
|
||||
|
||||
style("$MOD_ID:fluid_hopper")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -5,9 +5,12 @@ import net.minecraft.inventory.Container
|
|||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler
|
||||
import net.shadowfacts.extrahoppers.block.fluid.GUIFluidHopper
|
||||
import net.shadowfacts.extrahoppers.block.fluid.TileEntityFluidHopper
|
||||
import net.shadowfacts.extrahoppers.block.wooden.ContainerWoodenHopper
|
||||
import net.shadowfacts.extrahoppers.block.wooden.GUIWoodenHopper
|
||||
import net.shadowfacts.extrahoppers.block.wooden.TileEntityWoodenHopper
|
||||
import net.shadowfacts.shadowmc.inventory.ContainerPlayerInv
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
|
@ -18,7 +21,9 @@ object GUIHandler: IGuiHandler {
|
|||
val WOODEN_HOPPER = 1
|
||||
|
||||
override fun getClientGuiElement(ID: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): Any? {
|
||||
val pos = BlockPos(x, y, z)
|
||||
return when (ID) {
|
||||
FLUID_HOPPER -> GUIFluidHopper.create(world.getTileEntity(pos) as TileEntityFluidHopper, getServerGuiElement(ID, player, world, x, y, z)!!)
|
||||
WOODEN_HOPPER -> GUIWoodenHopper(getServerGuiElement(ID, player, world, x, y, z)!!)
|
||||
else -> null
|
||||
}
|
||||
|
@ -27,6 +32,7 @@ object GUIHandler: IGuiHandler {
|
|||
override fun getServerGuiElement(ID: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): Container? {
|
||||
val pos = BlockPos(x, y, z)
|
||||
return when (ID) {
|
||||
FLUID_HOPPER -> ContainerPlayerInv(pos, player.inventory)
|
||||
WOODEN_HOPPER -> ContainerWoodenHopper(world.getTileEntity(pos) as TileEntityWoodenHopper, player.inventory, pos)
|
||||
else -> null
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package net.shadowfacts.extrahoppers.gui.element
|
||||
|
||||
import net.minecraftforge.fluids.IFluidTank
|
||||
import net.shadowfacts.shadowmc.ui.UIDimensions
|
||||
import net.shadowfacts.shadowmc.ui.element.UIFluidIndicator
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
class UIFluidIndicator(tank: IFluidTank, id: String, vararg classes: String): UIFluidIndicator(tank, id, *classes) {
|
||||
|
||||
override fun getPreferredDimensions(): UIDimensions {
|
||||
return UIDimensions(20, 73)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
#top {
|
||||
vertical-layout: top
|
||||
}
|
Loading…
Reference in New Issue