parent
d553f45539
commit
92cb972d67
|
@ -11,6 +11,10 @@ abstract class TileEntityHopperBase(var inverted: Boolean): BaseTileEntity() {
|
|||
|
||||
constructor(): this(false)
|
||||
|
||||
fun isPowered(): Boolean {
|
||||
return world.isBlockPowered(pos)
|
||||
}
|
||||
|
||||
fun getHopperFacing(): EnumFacing {
|
||||
return world.getBlockState(pos).getValue(BlockHopperBase.FACING)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack
|
|||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraft.util.EnumHand
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.util.math.MathHelper
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.fluids.FluidUtil
|
||||
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
|
||||
}
|
||||
|
||||
@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 {
|
||||
if (player.isSneaking) {
|
||||
player.openGui(ExtraHoppers, GUIHandler.FLUID_HOPPER, world, pos.x, pos.y, pos.z)
|
||||
|
|
|
@ -57,7 +57,8 @@ open class TileEntityFluidHopper(inverted: Boolean): TileEntityHopperBase(invert
|
|||
|
||||
override fun update() {
|
||||
if (!world.isRemote) {
|
||||
// TODO: redstone me
|
||||
if (isPowered()) return
|
||||
|
||||
handlerCooldown--
|
||||
if (handlerCooldown <= 0) {
|
||||
handleFluidHandlers()
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.util.EnumFacing
|
|||
import net.minecraft.util.EnumHand
|
||||
import net.minecraft.util.math.BlockPos
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.items.ItemHandlerHelper
|
||||
import net.shadowfacts.extrahoppers.ExtraHoppers
|
||||
import net.shadowfacts.extrahoppers.block.base.BlockHopperBase
|
||||
import net.shadowfacts.extrahoppers.gui.GUIHandler
|
||||
|
@ -23,6 +24,16 @@ class BlockInvertedHopper: BlockHopperBase<TileEntityInvertedHopper>(true, "hopp
|
|||
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 {
|
||||
player.openGui(ExtraHoppers, GUIHandler.INVERTED_HOPPER, world, pos.x, pos.y, pos.z)
|
||||
return true
|
||||
|
|
|
@ -30,6 +30,8 @@ class TileEntityInvertedHopper: TileEntityHopperBase(), ITickable {
|
|||
|
||||
override fun update() {
|
||||
if (!world.isRemote) {
|
||||
if (isPowered()) return
|
||||
|
||||
cooldown--
|
||||
if (cooldown <= 0) {
|
||||
val pulled = pull()
|
||||
|
|
|
@ -29,7 +29,8 @@ class TileEntityWoodenHopper: TileEntityHopperBase(), ITickable {
|
|||
|
||||
override fun update() {
|
||||
if (!world.isRemote) {
|
||||
// TODO: redstone
|
||||
if (isPowered()) return
|
||||
|
||||
cooldown--
|
||||
if (cooldown <= 0) {
|
||||
val pulled = pull()
|
||||
|
|
|
@ -10,4 +10,5 @@ import net.shadowfacts.extrahoppers.block.fluid.TileEntityFluidHopper
|
|||
class TileEntityWoodenFluidHopper: TileEntityFluidHopper() {
|
||||
|
||||
override val fluidValiator: (FluidStack) -> Boolean = { it.fluid.temperature <= EHConfig.wfhMaxTemperature }
|
||||
|
||||
}
|
Loading…
Reference in New Issue