2021-02-28 18:48:39 +00:00
|
|
|
package net.shadowfacts.phycon.block.netinterface
|
2021-02-14 02:37:39 +00:00
|
|
|
|
|
|
|
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
|
2021-02-28 23:56:04 +00:00
|
|
|
import net.minecraft.sound.BlockSoundGroup
|
2021-02-14 02:37:39 +00:00
|
|
|
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
|
2021-02-28 18:48:39 +00:00
|
|
|
import net.shadowfacts.phycon.block.FaceDeviceBlock
|
2021-02-14 02:37:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author shadowfacts
|
|
|
|
*/
|
2021-02-28 23:56:04 +00:00
|
|
|
class InterfaceBlock: FaceDeviceBlock<InterfaceBlockEntity>(
|
|
|
|
Settings.of(Material.METAL)
|
|
|
|
.strength(1.5f)
|
|
|
|
.sounds(BlockSoundGroup.METAL)
|
|
|
|
),
|
2021-02-14 02:37:39 +00:00
|
|
|
NetworkComponentBlock,
|
|
|
|
AttributeProvider {
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
val ID = Identifier(PhysicalConnectivity.MODID, "network_interface")
|
|
|
|
}
|
|
|
|
|
2021-02-21 20:35:20 +00:00
|
|
|
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)
|
|
|
|
)
|
2021-02-14 02:37:39 +00:00
|
|
|
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|