Closes #13
This commit is contained in:
Shadowfacts 2017-01-15 12:19:44 -05:00
parent d553f45539
commit 92cb972d67
7 changed files with 38 additions and 2 deletions

View File

@ -11,6 +11,10 @@ abstract class TileEntityHopperBase(var inverted: Boolean): BaseTileEntity() {
constructor(): this(false) constructor(): this(false)
fun isPowered(): Boolean {
return world.isBlockPowered(pos)
}
fun getHopperFacing(): EnumFacing { fun getHopperFacing(): EnumFacing {
return world.getBlockState(pos).getValue(BlockHopperBase.FACING) return world.getBlockState(pos).getValue(BlockHopperBase.FACING)
} }

View File

@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack
import net.minecraft.util.EnumFacing import net.minecraft.util.EnumFacing
import net.minecraft.util.EnumHand import net.minecraft.util.EnumHand
import net.minecraft.util.math.BlockPos import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.MathHelper
import net.minecraft.world.World import net.minecraft.world.World
import net.minecraftforge.fluids.FluidUtil import net.minecraftforge.fluids.FluidUtil
import net.minecraftforge.fluids.capability.CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY import net.minecraftforge.fluids.capability.CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY
@ -27,6 +28,21 @@ open class BlockFluidHopper(inverted: Boolean, name: String = "fluid_hopper", ma
soundType = SoundType.METAL soundType = SoundType.METAL
} }
@Deprecated("")
override fun hasComparatorInputOverride(state: IBlockState): Boolean {
return true
}
@Deprecated("")
override fun getComparatorInputOverride(blockState: IBlockState, world: World, pos: BlockPos): Int {
val tank = getTileEntity(world, pos).tank
if (tank.fluidAmount == 0) {
return 0
} else {
return MathHelper.floor((tank.fluidAmount / tank.capacity) * 14.0) + 1
}
}
override fun onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean { override fun onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean {
if (player.isSneaking) { if (player.isSneaking) {
player.openGui(ExtraHoppers, GUIHandler.FLUID_HOPPER, world, pos.x, pos.y, pos.z) player.openGui(ExtraHoppers, GUIHandler.FLUID_HOPPER, world, pos.x, pos.y, pos.z)

View File

@ -57,7 +57,8 @@ open class TileEntityFluidHopper(inverted: Boolean): TileEntityHopperBase(invert
override fun update() { override fun update() {
if (!world.isRemote) { if (!world.isRemote) {
// TODO: redstone me if (isPowered()) return
handlerCooldown-- handlerCooldown--
if (handlerCooldown <= 0) { if (handlerCooldown <= 0) {
handleFluidHandlers() handleFluidHandlers()

View File

@ -8,6 +8,7 @@ import net.minecraft.util.EnumFacing
import net.minecraft.util.EnumHand import net.minecraft.util.EnumHand
import net.minecraft.util.math.BlockPos import net.minecraft.util.math.BlockPos
import net.minecraft.world.World import net.minecraft.world.World
import net.minecraftforge.items.ItemHandlerHelper
import net.shadowfacts.extrahoppers.ExtraHoppers import net.shadowfacts.extrahoppers.ExtraHoppers
import net.shadowfacts.extrahoppers.block.base.BlockHopperBase import net.shadowfacts.extrahoppers.block.base.BlockHopperBase
import net.shadowfacts.extrahoppers.gui.GUIHandler import net.shadowfacts.extrahoppers.gui.GUIHandler
@ -23,6 +24,16 @@ class BlockInvertedHopper: BlockHopperBase<TileEntityInvertedHopper>(true, "hopp
soundType = SoundType.METAL soundType = SoundType.METAL
} }
@Deprecated("")
override fun hasComparatorInputOverride(state: IBlockState): Boolean {
return true
}
@Deprecated("")
override fun getComparatorInputOverride(blockState: IBlockState, world: World, pos: BlockPos): Int {
return ItemHandlerHelper.calcRedstoneFromInventory(getTileEntity(world, pos).inventory)
}
override fun onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, facing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean { override fun onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, hand: EnumHand, facing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean {
player.openGui(ExtraHoppers, GUIHandler.INVERTED_HOPPER, world, pos.x, pos.y, pos.z) player.openGui(ExtraHoppers, GUIHandler.INVERTED_HOPPER, world, pos.x, pos.y, pos.z)
return true return true

View File

@ -30,6 +30,8 @@ class TileEntityInvertedHopper: TileEntityHopperBase(), ITickable {
override fun update() { override fun update() {
if (!world.isRemote) { if (!world.isRemote) {
if (isPowered()) return
cooldown-- cooldown--
if (cooldown <= 0) { if (cooldown <= 0) {
val pulled = pull() val pulled = pull()

View File

@ -29,7 +29,8 @@ class TileEntityWoodenHopper: TileEntityHopperBase(), ITickable {
override fun update() { override fun update() {
if (!world.isRemote) { if (!world.isRemote) {
// TODO: redstone if (isPowered()) return
cooldown-- cooldown--
if (cooldown <= 0) { if (cooldown <= 0) {
val pulled = pull() val pulled = pull()

View File

@ -10,4 +10,5 @@ import net.shadowfacts.extrahoppers.block.fluid.TileEntityFluidHopper
class TileEntityWoodenFluidHopper: TileEntityFluidHopper() { class TileEntityWoodenFluidHopper: TileEntityFluidHopper() {
override val fluidValiator: (FluidStack) -> Boolean = { it.fluid.temperature <= EHConfig.wfhMaxTemperature } override val fluidValiator: (FluidStack) -> Boolean = { it.fluid.temperature <= EHConfig.wfhMaxTemperature }
} }