capacitor debug textures

This commit is contained in:
2026-04-16 18:14:42 +02:00
parent 8dc774e5ab
commit 834a9c7ed8
21 changed files with 123 additions and 15 deletions

View File

@@ -9,6 +9,7 @@ import org.neoflock.neocomputers.gui.buffer.BufferRenderer
import org.neoflock.neocomputers.gui.menu.Menus import org.neoflock.neocomputers.gui.menu.Menus
import org.neoflock.neocomputers.gui.screen.ScreenScreen import org.neoflock.neocomputers.gui.screen.ScreenScreen
import dev.architectury.registry.menu.MenuRegistry import dev.architectury.registry.menu.MenuRegistry
import net.minecraft.client.Minecraft
import org.neoflock.neocomputers.item.Items import org.neoflock.neocomputers.item.Items
import org.neoflock.neocomputers.item.Tabs import org.neoflock.neocomputers.item.Tabs
import org.neoflock.neocomputers.network.Networking import org.neoflock.neocomputers.network.Networking

View File

@@ -26,7 +26,9 @@ object Blocks {
val BLOCKS: DeferredRegister<Block> = DeferredRegister.create(NeoComputers.MODID, Registries.BLOCK) val BLOCKS: DeferredRegister<Block> = DeferredRegister.create(NeoComputers.MODID, Registries.BLOCK)
val SCREEN_BLOCK: RegistrySupplier<Block> = BaseBlock.register("screen") { ScreenBlock() } val SCREEN_BLOCK: RegistrySupplier<Block> = BaseBlock.register("screen") { ScreenBlock() }
val CAPACITOR_BLOCK: RegistrySupplier<Block> = BaseBlock.register("capacitor") { CapacitorBlock() } val CAPACITOR_BLOCK: RegistrySupplier<Block> = BaseBlock.register("capacitor") { CapacitorBlock(1) }
val CAPACITOR_BLOCK2: RegistrySupplier<Block> = BaseBlock.register("capacitor2") { CapacitorBlock(2) }
val CAPACITOR_BLOCK3: RegistrySupplier<Block> = BaseBlock.register("capacitor3") { CapacitorBlock(3) }
val SOLARGEN_BLOCK: RegistrySupplier<Block> = BaseBlock.register("solargen") { SolarGeneratorBlock() } val SOLARGEN_BLOCK: RegistrySupplier<Block> = BaseBlock.register("solargen") { SolarGeneratorBlock() }
val COMBUSTGEN_BLOCK: RegistrySupplier<Block> = BaseBlock.register("combustgen") { CombustionGeneratorBlock() } val COMBUSTGEN_BLOCK: RegistrySupplier<Block> = BaseBlock.register("combustgen") { CombustionGeneratorBlock() }

View File

@@ -7,8 +7,10 @@ import net.minecraft.network.chat.PlayerChatMessage
import net.minecraft.server.level.ServerPlayer import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionResult import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.Item
import net.minecraft.world.level.Level import net.minecraft.world.level.Level
import net.minecraft.world.level.block.entity.BlockEntity 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 net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.BlockHitResult
import org.neoflock.neocomputers.entity.BlockEntities import org.neoflock.neocomputers.entity.BlockEntities
@@ -16,9 +18,8 @@ import org.neoflock.neocomputers.network.Networking
import org.neoflock.neocomputers.network.PowerRole import org.neoflock.neocomputers.network.PowerRole
import kotlin.math.min import kotlin.math.min
class CapacitorEntity(pos: BlockPos, state: BlockState) : NodeBlockEntity(BlockEntities.CAPACITOR_ENTITY.get(), pos, state) { open class CapacitorEntity(val capacity: Long, type: BlockEntityType<*>, pos: BlockPos, state: BlockState) : NodeBlockEntity(type, pos, state) {
var amountStored: Long = 0 var amountStored: Long = 0
val capacity: Long = 20000
override val node = object : Networking.Node() { override val node = object : Networking.Node() {
override fun getPowerRole() = PowerRole.STORAGE override fun getPowerRole() = PowerRole.STORAGE
@@ -38,11 +39,19 @@ class CapacitorEntity(pos: BlockPos, state: BlockState) : NodeBlockEntity(BlockE
} }
} }
class CapacitorBlock : NodeBlock() { class CapacitorEntityTier1(pos: BlockPos, state: BlockState): CapacitorEntity(20000, BlockEntities.CAPACITOR_ENTITY.get(), pos, state)
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity? { class CapacitorEntityTier2(pos: BlockPos, state: BlockState): CapacitorEntity(50000, BlockEntities.CAPACITOR2_ENTITY.get(), pos, state)
val cap = CapacitorEntity(blockPos, blockState) class CapacitorEntityTier3(pos: BlockPos, state: BlockState): CapacitorEntity(100000, BlockEntities.CAPACITOR3_ENTITY.get(), pos, state)
cap.initNetworking()
return cap class CapacitorBlock(val tier: Int) : NodeBlock() {
override fun newBlockEntity(blockPos: BlockPos, blockState: BlockState): BlockEntity {
val cap: CapacitorEntity = when(tier) {
1 -> CapacitorEntityTier1(blockPos, blockState)
2 -> CapacitorEntityTier2(blockPos, blockState)
3 -> CapacitorEntityTier3(blockPos, blockState)
else -> throw UnsupportedOperationException("unsupported tier: $tier")
}
return cap.initNetworking()
} }
override fun useWithoutItem( override fun useWithoutItem(
@@ -54,11 +63,10 @@ class CapacitorBlock : NodeBlock() {
): InteractionResult { ): InteractionResult {
if(!level.isClientSide()) { if(!level.isClientSide()) {
val sp = player as ServerPlayer val sp = player as ServerPlayer
val ent = level.getBlockEntity(blockPos, BlockEntities.CAPACITOR_ENTITY.get()) val ent = level.getBlockEntity(blockPos)
if(ent.isPresent()) { if(ent is CapacitorEntity) {
val cap = ent.get() if(sp.isCrouching) ent.amountStored++
if(sp.isCrouching()) cap.amountStored++ val msg = PlayerChatMessage.system("energy: ${ent.amountStored} / ${ent.capacity} (${ent.computeEdges().size} edges, ${ent.node.getReachable().size} connected)")
val msg = PlayerChatMessage.system("energy: ${cap.amountStored} / ${cap.capacity} (${cap.computeEdges().size} edges, ${cap.node.getReachable().size} connected)")
sp.sendChatMessage(OutgoingChatMessage.create(msg), false, ChatType.bind(ChatType.CHAT, player)) sp.sendChatMessage(OutgoingChatMessage.create(msg), false, ChatType.bind(ChatType.CHAT, player))
} }
} }

View File

@@ -12,6 +12,9 @@ import net.minecraft.world.level.block.entity.BlockEntityType
import org.neoflock.neocomputers.NeoComputers import org.neoflock.neocomputers.NeoComputers
import org.neoflock.neocomputers.block.Blocks import org.neoflock.neocomputers.block.Blocks
import org.neoflock.neocomputers.block.CapacitorEntity import org.neoflock.neocomputers.block.CapacitorEntity
import org.neoflock.neocomputers.block.CapacitorEntityTier1
import org.neoflock.neocomputers.block.CapacitorEntityTier2
import org.neoflock.neocomputers.block.CapacitorEntityTier3
import org.neoflock.neocomputers.network.PowerManager import org.neoflock.neocomputers.network.PowerManager
// complete fucking bullshit btw // complete fucking bullshit btw
@@ -42,9 +45,19 @@ object BlockEntities {
::ScreenEntity, mutableSetOf(Blocks.SCREEN_BLOCK.get()), BullshitFix() ::ScreenEntity, mutableSetOf(Blocks.SCREEN_BLOCK.get()), BullshitFix()
) )
} }
val CAPACITOR_ENTITY: RegistrySupplier<BlockEntityType<CapacitorEntity>> = BLOCKENTITIES.register("capacitor_entity") { val CAPACITOR_ENTITY: RegistrySupplier<BlockEntityType<CapacitorEntityTier1>> = BLOCKENTITIES.register("capacitor_entity") {
BlockEntityType( BlockEntityType(
::CapacitorEntity, mutableSetOf(Blocks.CAPACITOR_BLOCK.get()), BullshitFix() ::CapacitorEntityTier1, mutableSetOf(Blocks.CAPACITOR_BLOCK.get()), BullshitFix()
)
}
val CAPACITOR2_ENTITY: RegistrySupplier<BlockEntityType<CapacitorEntityTier2>> = BLOCKENTITIES.register("capacitor_entity2") {
BlockEntityType(
::CapacitorEntityTier2, mutableSetOf(Blocks.CAPACITOR_BLOCK2.get()), BullshitFix()
)
}
val CAPACITOR3_ENTITY: RegistrySupplier<BlockEntityType<CapacitorEntityTier3>> = BLOCKENTITIES.register("capacitor_entity3") {
BlockEntityType(
::CapacitorEntityTier3, mutableSetOf(Blocks.CAPACITOR_BLOCK3.get()), BullshitFix()
) )
} }
val SOLARGEN_ENTITY: RegistrySupplier<BlockEntityType<SolarGeneratorBlockEntity>> = BLOCKENTITIES.register("solargen_entity") { val SOLARGEN_ENTITY: RegistrySupplier<BlockEntityType<SolarGeneratorBlockEntity>> = BLOCKENTITIES.register("solargen_entity") {
@@ -60,6 +73,8 @@ object BlockEntities {
fun registerPowerBlocks() { fun registerPowerBlocks() {
PowerManager.registerPowerBlockEntity(CAPACITOR_ENTITY.get()) PowerManager.registerPowerBlockEntity(CAPACITOR_ENTITY.get())
PowerManager.registerPowerBlockEntity(CAPACITOR2_ENTITY.get())
PowerManager.registerPowerBlockEntity(CAPACITOR3_ENTITY.get())
PowerManager.registerPowerBlockEntity(SOLARGEN_ENTITY.get()) PowerManager.registerPowerBlockEntity(SOLARGEN_ENTITY.get())
PowerManager.registerPowerBlockEntity(COMBUSTGEN_ENTITY.get()) PowerManager.registerPowerBlockEntity(COMBUSTGEN_ENTITY.get())
} }

View File

@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "neocomputers:block/capacitor"
}
}
}

View File

@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "neocomputers:block/capacitor2"
}
}
}

View File

@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "neocomputers:block/capacitor3"
}
}
}

View File

@@ -0,0 +1,12 @@
{
"parent": "minecraft:block/cube",
"textures": {
"up": "neocomputers:block/capacitor_top",
"down": "neocomputers:block/capacitor_bottom",
"north": "neocomputers:block/capacitor_side",
"south": "neocomputers:block/capacitor_side",
"east": "neocomputers:block/capacitor_side",
"west": "neocomputers:block/capacitor_side",
"particle": "neocomputers:block/capacitor_top"
}
}

View File

@@ -0,0 +1,12 @@
{
"parent": "minecraft:block/cube",
"textures": {
"up": "neocomputers:block/capacitor2_top",
"down": "neocomputers:block/capacitor_bottom",
"north": "neocomputers:block/capacitor2_side",
"south": "neocomputers:block/capacitor2_side",
"east": "neocomputers:block/capacitor2_side",
"west": "neocomputers:block/capacitor2_side",
"particle": "neocomputers:block/capacitor2_top"
}
}

View File

@@ -0,0 +1,12 @@
{
"parent": "minecraft:block/cube",
"textures": {
"up": "neocomputers:block/capacitor3_top",
"down": "neocomputers:block/capacitor_bottom",
"north": "neocomputers:block/capacitor3_side",
"south": "neocomputers:block/capacitor3_side",
"east": "neocomputers:block/capacitor3_side",
"west": "neocomputers:block/capacitor3_side",
"particle": "neocomputers:block/capacitor3_top"
}
}

View File

@@ -0,0 +1,3 @@
{
"parent": "neocomputers:block/capacitor"
}

View File

@@ -0,0 +1,3 @@
{
"parent": "neocomputers:block/capacitor2"
}

View File

@@ -0,0 +1,3 @@
{
"parent": "neocomputers:block/capacitor3"
}

View File

@@ -0,0 +1,16 @@
{
power: {
// amount of energy the different capacitor tiers can store
capacitors: [20000, 50000, 100000],
// how much energy combustion generators make per tick
combustionGeneration: 50,
// the energy capacity of the combustion generator
combustionMaxPower: 50000,
// how much energy solar generators make per tick
solarGeneration: 50,
// the energy capacity of the solar generator
solarMaxPower: 10000,
},
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B