57 lines
2.0 KiB
Kotlin
57 lines
2.0 KiB
Kotlin
package net.shadowfacts.phycon.block.netinterface
|
|
|
|
import alexiil.mc.lib.attributes.AttributeList
|
|
import alexiil.mc.lib.attributes.AttributeProvider
|
|
import net.minecraft.block.*
|
|
import net.minecraft.entity.LivingEntity
|
|
import net.minecraft.item.ItemStack
|
|
import net.minecraft.util.Identifier
|
|
import net.minecraft.util.math.BlockPos
|
|
import net.minecraft.util.math.Direction
|
|
import net.minecraft.world.BlockView
|
|
import net.minecraft.world.World
|
|
import net.shadowfacts.phycon.PhysicalConnectivity
|
|
import net.shadowfacts.phycon.api.NetworkComponentBlock
|
|
import net.shadowfacts.phycon.block.FaceDeviceBlock
|
|
|
|
/**
|
|
* @author shadowfacts
|
|
*/
|
|
class InterfaceBlock: FaceDeviceBlock<InterfaceBlockEntity>(Settings.of(Material.METAL)),
|
|
NetworkComponentBlock,
|
|
AttributeProvider {
|
|
|
|
companion object {
|
|
val ID = Identifier(PhysicalConnectivity.MODID, "network_interface")
|
|
}
|
|
|
|
override val faceThickness = 2.0
|
|
override val faceShapes = mapOf(
|
|
Direction.DOWN to createCuboidShape(2.0, 0.0, 2.0, 14.0, 2.0, 14.0),
|
|
Direction.UP to createCuboidShape(2.0, 14.0, 2.0, 14.0, 16.0, 14.0),
|
|
Direction.NORTH to createCuboidShape(2.0, 2.0, 0.0, 14.0, 14.0, 2.0),
|
|
Direction.SOUTH to createCuboidShape(2.0, 2.0, 14.0, 14.0, 14.0, 16.0),
|
|
Direction.WEST to createCuboidShape(0.0, 2.0, 2.0, 2.0, 14.0, 14.0),
|
|
Direction.EAST to createCuboidShape(14.0, 2.0, 2.0, 16.0, 14.0, 14.0)
|
|
)
|
|
|
|
override fun createBlockEntity(world: BlockView) = InterfaceBlockEntity()
|
|
|
|
override fun onPlaced(world: World, pos: BlockPos, state: BlockState, placer: LivingEntity?, stack: ItemStack) {
|
|
if (!world.isClient) {
|
|
getBlockEntity(world, pos)!!.updateInventory()
|
|
}
|
|
}
|
|
|
|
override fun neighborUpdate(state: BlockState, world: World, pos: BlockPos, neighborBlock: Block, neighborPos: BlockPos, boolean_1: Boolean) {
|
|
if (!world.isClient) {
|
|
getBlockEntity(world, pos)!!.updateInventory()
|
|
}
|
|
}
|
|
|
|
override fun addAllAttributes(world: World, pos: BlockPos, state: BlockState, to: AttributeList<*>) {
|
|
to.offer(getBlockEntity(world, pos))
|
|
}
|
|
|
|
}
|