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.sound.BlockSoundGroup 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( Settings.of(Material.METAL) .strength(1.5f) .sounds(BlockSoundGroup.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(pos: BlockPos, state: BlockState) = InterfaceBlockEntity(pos, state) 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)) } }