package net.shadowfacts.phycon.block import net.minecraft.block.Block import net.minecraft.block.BlockEntityProvider import net.minecraft.block.BlockState import net.minecraft.block.entity.BlockEntity import net.minecraft.block.entity.BlockEntityTicker import net.minecraft.block.entity.BlockEntityType import net.minecraft.util.math.BlockPos import net.minecraft.world.BlockView import net.minecraft.world.World /** * @author shadowfacts */ abstract class BlockWithEntity(settings: Settings): Block(settings), BlockEntityProvider { abstract override fun createBlockEntity(pos: BlockPos, state: BlockState): T? fun getBlockEntity(world: BlockView, pos: BlockPos): T? { val entity = world.getBlockEntity(pos) return if (entity != null) { entity as? T } else { null } } }