2019-10-27 01:36:31 +00:00
|
|
|
package net.shadowfacts.phycon.network.block.terminal
|
2021-02-14 02:37:39 +00:00
|
|
|
|
|
|
|
import alexiil.mc.lib.attributes.AttributeList
|
|
|
|
import alexiil.mc.lib.attributes.AttributeProvider
|
|
|
|
import net.minecraft.block.BlockState
|
|
|
|
import net.minecraft.block.Material
|
|
|
|
import net.minecraft.entity.player.PlayerEntity
|
|
|
|
import net.minecraft.util.ActionResult
|
|
|
|
import net.minecraft.util.Hand
|
|
|
|
import net.minecraft.util.Identifier
|
|
|
|
import net.minecraft.util.hit.BlockHitResult
|
|
|
|
import net.minecraft.util.math.BlockPos
|
|
|
|
import net.minecraft.util.math.Direction
|
|
|
|
import net.minecraft.world.BlockView
|
|
|
|
import net.minecraft.world.World
|
2021-02-18 03:29:18 +00:00
|
|
|
import net.minecraft.world.WorldAccess
|
2021-02-14 02:37:39 +00:00
|
|
|
import net.shadowfacts.phycon.PhysicalConnectivity
|
|
|
|
import net.shadowfacts.phycon.api.NetworkComponentBlock
|
|
|
|
import net.shadowfacts.phycon.network.DeviceBlock
|
|
|
|
import java.util.*
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author shadowfacts
|
|
|
|
*/
|
|
|
|
class TerminalBlock: DeviceBlock<TerminalBlockEntity>(Settings.of(Material.METAL)),
|
|
|
|
NetworkComponentBlock,
|
|
|
|
AttributeProvider {
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
val ID = Identifier(PhysicalConnectivity.MODID, "terminal")
|
|
|
|
}
|
|
|
|
|
2021-02-18 03:29:18 +00:00
|
|
|
override fun getNetworkConnectedSides(state: BlockState, world: WorldAccess, pos: BlockPos): Collection<Direction> {
|
2021-02-14 02:37:39 +00:00
|
|
|
return EnumSet.allOf(Direction::class.java)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun createBlockEntity(world: BlockView) = TerminalBlockEntity()
|
|
|
|
|
|
|
|
override fun onUse(state: BlockState, world: World, pos: BlockPos, player: PlayerEntity, hand: Hand, hitResult: BlockHitResult): ActionResult {
|
|
|
|
getBlockEntity(world, pos)!!.onActivate(player)
|
|
|
|
return ActionResult.SUCCESS
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun addAllAttributes(world: World, pos: BlockPos, state: BlockState, to: AttributeList<*>) {
|
|
|
|
to.offer(getBlockEntity(world, pos))
|
|
|
|
}
|
|
|
|
}
|