initial work on combustion

This commit is contained in:
2026-04-12 20:39:46 +02:00
parent ae9a3fd2c7
commit 94e6c505bd
5 changed files with 48 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ object Blocks {
val SCREEN_BLOCK: RegistrySupplier<Block> = BaseBlock.register("screen") { ScreenBlock() }
val CAPACITOR_BLOCK: RegistrySupplier<Block> = BaseBlock.register("capacitor") { CapacitorBlock() }
val SOLARGEN_BLOCK: RegistrySupplier<Block> = BaseBlock.register("solargen") { SolarGeneratorBlock() }
val COMBUSTGEN_BLOCK: RegistrySupplier<Block> = BaseBlock.register("combustgen") { CombustionGeneratorBlock() }
fun registerBlockItems() {
BLOCKS.forEach(Consumer { sup: RegistrySupplier<Block> ->

View File

@@ -15,6 +15,25 @@ class SolarGeneratorBlock : BaseBlock(), EntityBlock {
return SolarGeneratorBlockEntity(BlockEntities.SOLARGEN_ENTITY.get(), blockPos, blockState)
}
override fun <T : BlockEntity> getTicker(
level: Level,
blockState: BlockState,
blockEntityType: BlockEntityType<T>
): BlockEntityTicker<T> {
return object : BlockEntityTicker<T> {
override fun tick(level: Level, blockPos: BlockPos, blockState: BlockState, blockEntity: T) {
if(blockEntity !is SolarGeneratorBlockEntity) return;
blockEntity.giveSolarPower();
}
}
}
}
class CombustionGeneratorBlock : BaseBlock(), EntityBlock {
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
return CombustionGeneratorBlockEntity(BlockEntities.COMBUSTGEN_ENTITY.get(), blockPos, blockState)
}
override fun <T : BlockEntity> getTicker(
level: Level,
blockState: BlockState,