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,

View File

@@ -47,9 +47,14 @@ object BlockEntities {
::CapacitorEntity, mutableSetOf(Blocks.CAPACITOR_BLOCK.get()), BullshitFix()
)
}
val SOLARGEN_ENTITY: RegistrySupplier<BlockEntityType<CapacitorEntity>> = BLOCKENTITIES.register("solargen_entity") {
val SOLARGEN_ENTITY: RegistrySupplier<BlockEntityType<SolarGeneratorBlockEntity>> = BLOCKENTITIES.register("solargen_entity") {
BlockEntityType(
::CapacitorEntity, mutableSetOf(Blocks.SOLARGEN_BLOCK.get()), BullshitFix()
::SolarGeneratorBlockEntity, mutableSetOf(Blocks.SOLARGEN_BLOCK.get()), BullshitFix()
)
}
val COMBUSTGEN_ENTITY: RegistrySupplier<BlockEntityType<CombustionGeneratorBlockEntity>> = BLOCKENTITIES.register("combustgen_entity") {
BlockEntityType(
::CombustionGeneratorBlockEntity, mutableSetOf(Blocks.COMBUSTGEN_BLOCK.get()), BullshitFix()
)
}

View File

@@ -0,0 +1,20 @@
package org.neoflock.neocomputers.entity
import net.minecraft.core.BlockPos
import net.minecraft.world.level.block.entity.BlockEntity
import net.minecraft.world.level.block.entity.BlockEntityType
import net.minecraft.world.level.block.state.BlockState
import org.neoflock.neocomputers.block.NodeBlockEntity
class CombustionGeneratorBlockEntity(blockPos: BlockPos, blockState: BlockState) : BlockEntity(BlockEntities.COMBUSTGEN_ENTITY.get(), blockPos, blockState) {
val energyPerTick: Long = 50
fun giveSolarPower() {
if(level?.isDay == true) {
val below = level?.getBlockEntity(blockPos.below())
if(below is NodeBlockEntity) {
below.node.giveEnergy(energyPerTick)
}
}
}
}

View File

@@ -6,7 +6,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType
import net.minecraft.world.level.block.state.BlockState
import org.neoflock.neocomputers.block.NodeBlockEntity
class SolarGeneratorBlockEntity(entityType: BlockEntityType<*>, blockPos: BlockPos, blockState: BlockState) : BlockEntity(entityType, blockPos, blockState) {
class SolarGeneratorBlockEntity(blockPos: BlockPos, blockState: BlockState) : BlockEntity(BlockEntities.SOLARGEN_ENTITY.get(), blockPos, blockState) {
val energyPerTick: Long = 50
fun giveSolarPower() {