Skip to content
Draft
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cd9565a
Merge branch 'chore/custom-dispatching' into seggan/feature/elektrikity
Seggan Mar 11, 2026
2250a6e
Add base code
Seggan Mar 11, 2026
e9bc467
Simple networks
Seggan Mar 12, 2026
84df04e
Add player input
Seggan Mar 12, 2026
e10c241
Add electric units
Seggan Mar 12, 2026
3cae7d2
Add `WindowSnapshot`
Seggan Mar 17, 2026
8a85e18
Revert "Add `WindowSnapshot`"
Seggan Mar 17, 2026
0f22681
Extract `openWindow`
Seggan Mar 17, 2026
6252a10
Add creative power source and generify number input
Seggan Mar 17, 2026
3db2a07
Add `getAsOrThrow` and fix bugs
Seggan Mar 17, 2026
eaa350d
Start path
Seggan Mar 27, 2026
93fee13
Merge branch 'master' into seggan/feature/elektrikity
Seggan Apr 6, 2026
c2b1fc0
Merge branch 'master' into seggan/feature/elektrikity
Seggan Apr 7, 2026
934f6c4
Slightly broken but ok
Seggan Apr 13, 2026
d29bbe8
Merge branch 'master' into seggan/feature/elektrikity
Seggan Apr 13, 2026
9177b13
Rewrite
Seggan Apr 13, 2026
06fe40b
Start multimeter
Seggan Apr 14, 2026
fb5f8c0
Rewrite node API
Seggan Apr 15, 2026
493d054
Start transformer
Seggan Apr 20, 2026
fc8a086
Rewrite connections
Seggan Apr 21, 2026
97a74a5
Add transformers
Seggan Apr 22, 2026
279b724
Take wires
Seggan Apr 22, 2026
d0acc51
Working capacitors/acceptors
Seggan Apr 22, 2026
647ff75
Don't underfeed
Seggan Apr 23, 2026
5874602
Boiler
Seggan Apr 24, 2026
0423f4d
Steam power go brr
Seggan Apr 27, 2026
080a9ec
Better visibility
Seggan Apr 27, 2026
ed02104
Move
Seggan Apr 27, 2026
0bd9dce
Basic gas turbine multiblock
Seggan Apr 29, 2026
5843f2d
Electricity input/output hatches
Seggan Apr 29, 2026
8ec7b45
Nuke voltage
Seggan Apr 30, 2026
105bfae
Fix multiblock facing
Seggan Apr 30, 2026
8e59d39
Clean up
Seggan Apr 30, 2026
f7047ec
Not like I needed this
Seggan Apr 30, 2026
aa4dca2
Combustion tower
Seggan May 4, 2026
05544bb
Merge branch 'master' into seggan/feature/elektrikity
Seggan May 11, 2026
64fe019
Fix compile
Seggan May 11, 2026
3e6c203
\*read in electroboom's voice* COMBINED CYCLE CLOSED COOLING DIESEL P…
Seggan May 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class PlayerPacketHandler(private val player: ServerPlayer, val handler: PlayerT
if (stack.isEmpty) return stack
val bukkitStack = CraftItemStack.asCraftMirror(stack)
val item = RebarItem.fromStack(bukkitStack) ?: return stack
val prototype = item.schema.getItemStack()
val prototype = item.schema.createNewItem()
prototype.copyDataFrom(bukkitStack) { it != DataComponentTypes.ITEM_NAME && it != DataComponentTypes.LORE }
prototype.editPersistentDataContainer { it.remove(PlayerTranslationHandler.FOOTER_APPENDED) }
prototype.amount = bukkitStack.amount
Expand Down
6 changes: 2 additions & 4 deletions rebar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ dependencies {

paperLibraryApi("xyz.xenondevs.invui:invui:2.0.0-beta.5")
paperLibraryApi("xyz.xenondevs.invui:invui-kotlin:2.0.0-beta.5")
implementation("com.github.Tofaa2.EntityLib:spigot:2.4.11")
implementation("com.github.retrooper:packetevents-spigot:2.11.2")
paperLibraryApi("com.github.Tofaa2.EntityLib:spigot:2.4.11")
paperLibraryApi("com.github.retrooper:packetevents-spigot:2.11.2")
implementation("info.debatty:java-string-similarity:2.0.0")
implementation("org.bstats:bstats-bukkit:2.2.1")
paperLibrary("com.github.ben-manes.caffeine:caffeine:3.2.2")
Expand Down Expand Up @@ -144,8 +144,6 @@ tasks.shadowJar {
exclude("org/intellij/lang/annotations/**")
exclude("org/jetbrains/annotations/**")

relocate("com.github.retrooper.packetevents", "io.github.pylonmc.rebar.packetevents")
relocate("me.tofaa.entitylib", "io.github.pylonmc.rebar.entitylib")
relocate("org.bstats", "io.github.pylonmc.rebar.bstats")

archiveBaseName = "rebar"
Expand Down
172 changes: 90 additions & 82 deletions rebar/src/main/kotlin/io/github/pylonmc/rebar/Rebar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.github.pylonmc.rebar.content.debug.DebugWaxedWeatheredCutCopperStairs
import io.github.pylonmc.rebar.content.fluid.*
import io.github.pylonmc.rebar.content.guide.RebarGuide
import io.github.pylonmc.rebar.culling.BlockCullingEngine
import io.github.pylonmc.rebar.electricity.WireConnectionService
import io.github.pylonmc.rebar.entity.EntityListener
import io.github.pylonmc.rebar.entity.EntityStorage
import io.github.pylonmc.rebar.entity.RebarEntity
Expand All @@ -43,6 +44,7 @@ import io.github.pylonmc.rebar.recipe.RecipeCompletion
import io.github.pylonmc.rebar.recipe.RecipeType
import io.github.pylonmc.rebar.registry.RebarRegistry
import io.github.pylonmc.rebar.resourcepack.armor.ArmorTextureEngine
import io.github.pylonmc.rebar.util.PlayerInput
import io.github.pylonmc.rebar.util.delayTicks
import io.github.pylonmc.rebar.util.mergeGlobalConfig
import io.github.pylonmc.rebar.waila.Waila
Expand All @@ -69,7 +71,7 @@ import org.bukkit.permissions.PermissionDefault
import org.bukkit.plugin.java.JavaPlugin
import xyz.xenondevs.invui.InvUI
import xyz.xenondevs.invui.i18n.Languages
import java.util.Locale
import java.util.*
import kotlin.io.path.*

/**
Expand Down Expand Up @@ -131,6 +133,7 @@ object Rebar : JavaPlugin(), RebarAddon {
pm.registerEvents(RebarTranslator, this)
pm.registerEvents(RebarAddon, this)

@Suppress("UnusedExpression")
RebarMetrics // initialize metrics by referencing it

// Anything that listens for addon registration must be above this line
Expand Down Expand Up @@ -162,93 +165,98 @@ object Rebar : JavaPlugin(), RebarAddon {
pm.registerEvents(RebarTickingEntity, this)
pm.registerEvents(ChunkScope, this)
pm.registerEvents(PlayerScope, this)
pm.registerEvents(RebarElectricBlock, this)
pm.registerEvents(RebarElectricConsumerBlock, this)
pm.registerEvents(RebarElectricProducerBlock, this)
pm.registerEvents(WireConnectionService, this)
pm.registerEvents(PlayerInput, this)

// Rebar Blocks
BlockListener.register(this, pm)
RebarBeacon.register(this, pm)
RebarBell.register(this, pm)
RebarTNT.register(this, pm)
RebarNoteBlock.register(this, pm)
RebarCrafter.register(this, pm)
RebarSponge.register(this, pm)
RebarFurnace.register(this, pm)
RebarCampfire.register(this, pm)
RebarBrewingStand.register(this, pm)
RebarDispenser.register(this, pm)
RebarGrowable.register(this, pm)
RebarCauldron.register(this, pm)
RebarSign.register(this, pm)
RebarVault.register(this, pm)
RebarLeaf.register(this, pm)
RebarTargetBlock.register(this, pm)
RebarComposter.register(this, pm)
RebarShearable.register(this, pm)
RebarLectern.register(this, pm)
RebarPiston.register(this, pm)
RebarEnchantingTable.register(this, pm)
RebarRedstoneBlock.register(this, pm)
RebarInteractBlock.register(this, pm)
RebarSneakBlock.register(this, pm)
RebarJobBlock.register(this, pm)
RebarJumpBlock.register(this, pm)
RebarUnloadBlock.register(this, pm)
RebarFlowerPot.register(this, pm)
RebarVanillaContainerBlock.register(this, pm)
RebarHopper.register(this, pm)
RebarCargoBlock.register(this, pm)
RebarCopperBlock.register(this, pm)
RebarEntityChangedBlock.register(this, pm)
BlockListener.register(this)
RebarBeacon.register(this)
RebarBell.register(this)
RebarTNT.register(this)
RebarNoteBlock.register(this)
RebarCrafter.register(this)
RebarSponge.register(this)
RebarFurnace.register(this)
RebarCampfire.register(this)
RebarBrewingStand.register(this)
RebarDispenser.register(this)
RebarGrowable.register(this)
RebarCauldron.register(this)
RebarSign.register(this)
RebarVault.register(this)
RebarLeaf.register(this)
RebarTargetBlock.register(this)
RebarComposter.register(this)
RebarShearable.register(this)
RebarLectern.register(this)
RebarPiston.register(this)
RebarEnchantingTable.register(this)
RebarRedstoneBlock.register(this)
RebarInteractBlock.register(this)
RebarSneakBlock.register(this)
RebarJobBlock.register(this)
RebarJumpBlock.register(this)
RebarUnloadBlock.register(this)
RebarFlowerPot.register(this)
RebarVanillaContainerBlock.register(this)
RebarHopper.register(this)
RebarCargoBlock.register(this)
RebarCopperBlock.register(this)
RebarEntityChangedBlock.register(this)

// Rebar Items
RebarArrow.register(this, pm)
RebarBlockInteractor.register(this, pm)
RebarBow.register(this, pm)
RebarBrewingStandFuel.register(this, pm)
RebarBucket.register(this, pm)
RebarConsumable.register(this, pm)
RebarDispensable.register(this, pm)
RebarInteractor.register(this, pm)
RebarItemDamageable.register(this, pm)
RebarItemEntityInteractor.register(this, pm)
RebarLingeringPotion.register(this, pm)
RebarSplashPotion.register(this, pm)
RebarTool.register(this, pm)
RebarWeapon.register(this, pm)
VanillaCookingFuel.register(this, pm)
RebarArrow.register(this)
RebarBlockInteractor.register(this)
RebarBow.register(this)
RebarBrewingStandFuel.register(this)
RebarBucket.register(this)
RebarConsumable.register(this)
RebarDispensable.register(this)
RebarInteractor.register(this)
RebarItemDamageable.register(this)
RebarItemEntityInteractor.register(this)
RebarLingeringPotion.register(this)
RebarSplashPotion.register(this)
RebarTool.register(this)
RebarWeapon.register(this)
VanillaCookingFuel.register(this)

// Rebar Entities
EntityListener.register(this, pm)
RebarBat.register(this, pm)
RebarBreedable.register(this, pm)
RebarCombustibleEntity.register(this, pm)
RebarCop.register(this, pm)
RebarCreeper.register(this, pm)
RebarDamageableEntity.register(this, pm)
RebarDeathEntity.register(this, pm)
RebarDragonFireball.register(this, pm)
RebarDyeable.register(this, pm)
RebarEnderDragon.register(this, pm)
RebarEnderman.register(this, pm)
RebarExperienceOrb.register(this, pm)
RebarExplosiveEntity.register(this, pm)
RebarFirework.register(this, pm)
RebarInteractEntity.register(this, pm)
RebarItemEntity.register(this, pm)
RebarLeashable.register(this, pm)
RebarMountableEntity.register(this, pm)
RebarMountingEntity.register(this, pm)
RebarMovingEntity.register(this, pm)
RebarPathingEntity.register(this, pm)
RebarPiglin.register(this, pm)
RebarProjectile.register(this, pm)
RebarResurrectable.register(this, pm)
RebarSlime.register(this, pm)
RebarSpellcaster.register(this, pm)
RebarTameable.register(this, pm)
RebarTurtle.register(this, pm)
RebarVillager.register(this, pm)
RebarWitch.register(this, pm)
RebarZombiePigman.register(this, pm)
EntityListener.register(this)
RebarBat.register(this)
RebarBreedable.register(this)
RebarCombustibleEntity.register(this)
RebarCop.register(this)
RebarCreeper.register(this)
RebarDamageableEntity.register(this)
RebarDeathEntity.register(this)
RebarDragonFireball.register(this)
RebarDyeable.register(this)
RebarEnderDragon.register(this)
RebarEnderman.register(this)
RebarExperienceOrb.register(this)
RebarExplosiveEntity.register(this)
RebarFirework.register(this)
RebarInteractEntity.register(this)
RebarItemEntity.register(this)
RebarLeashable.register(this)
RebarMountableEntity.register(this)
RebarMountingEntity.register(this)
RebarMovingEntity.register(this)
RebarPathingEntity.register(this)
RebarPiglin.register(this)
RebarProjectile.register(this)
RebarResurrectable.register(this)
RebarSlime.register(this)
RebarSpellcaster.register(this)
RebarTameable.register(this)
RebarTurtle.register(this)
RebarVillager.register(this)
RebarWitch.register(this)
RebarZombiePigman.register(this)

Bukkit.getScheduler().runTaskTimer(this, RebarInventoryTicker(), 0, RebarConfig.INVENTORY_TICKER_BASE_RATE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import org.bukkit.event.world.ChunkUnloadEvent
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataContainer
import org.bukkit.persistence.PersistentDataType
import java.util.Collections
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.random.Random
Expand Down Expand Up @@ -181,6 +181,63 @@ object BlockStorage : Listener {
*/
inline fun <reified T> getAs(location: Location): T? = getAs(T::class.java, location)

/**
* Returns the Rebar block (of type [T]) at the given [blockPosition].
*
* @throws IllegalArgumentException if the chunk containing the block is not loaded or the block is not a Rebar block
* @throws ClassCastException if the block is not of the expected class
*/
@JvmStatic
fun <T> getAsOrThrow(clazz: Class<T>, blockPosition: BlockPosition): T {
val block = get(blockPosition) ?: throw IllegalArgumentException("No Rebar block found at $blockPosition")
if (!clazz.isInstance(block)) {
throw ClassCastException("Block at $blockPosition is not of type ${clazz.simpleName}")
}
return clazz.cast(block)
}

/**
* Returns the Rebar block (of type [T]) at the given [block].
*
* @throws IllegalArgumentException if the chunk containing the block is not loaded or the block is not a Rebar block
* @throws ClassCastException if the block is not of the expected class
*/
@JvmStatic
fun <T> getAsOrThrow(clazz: Class<T>, block: Block): T = getAsOrThrow(clazz, block.position)

/**
* Returns the Rebar block (of type [T]) at the given [location].
*
* @throws IllegalArgumentException if the chunk containing the block is not loaded or the block is not a Rebar block
* @throws ClassCastException if the block is not of the expected class
*/
@JvmStatic
fun <T> getAsOrThrow(clazz: Class<T>, location: Location): T = getAsOrThrow(clazz, BlockPosition(location))

/**
* Returns the Rebar block (of type [T]) at the given [blockPosition].
*
* @throws IllegalArgumentException if the chunk containing the block is not loaded or the block is not a Rebar block
* @throws ClassCastException if the block is not of the expected class
*/
inline fun <reified T> getAsOrThrow(blockPosition: BlockPosition): T = getAsOrThrow(T::class.java, blockPosition)

/**
* Returns the Rebar block (of type [T]) at the given [block].
*
* @throws IllegalArgumentException if the chunk containing the block is not loaded or the block is not a Rebar block
* @throws ClassCastException if the block is not of the expected class
*/
inline fun <reified T> getAsOrThrow(block: Block): T = getAsOrThrow(T::class.java, block)

/**
* Returns the Rebar block (of type [T]) at the given [location].
*
* @throws IllegalArgumentException if the chunk containing the block is not loaded or the block is not a Rebar block
* @throws ClassCastException if the block is not of the expected class
*/
inline fun <reified T> getAsOrThrow(location: Location): T = getAsOrThrow(T::class.java, location)

/**
* Returns all the Plyon blocks in the chunk at [chunkPosition].
*
Expand All @@ -193,7 +250,7 @@ object BlockStorage : Listener {
}

/**
* Returns all the Plyon blocks with type [key].
* Returns all the Pylon blocks with type [key].
*/
@JvmStatic
fun getByKey(key: NamespacedKey): Collection<RebarBlock> =
Expand All @@ -205,6 +262,18 @@ object BlockStorage : Listener {
emptySet()
}

/**
* Returns all the Pylon blocks of type [T]
*/
@JvmStatic
fun <T> getByType(clazz: Class<T>) = lockBlockRead { blocks.values.filter { clazz.isInstance(it) }.map { clazz.cast(it)!! } }

/**
* Returns all the Pylon blocks of type [T]
*/
@JvmStatic
inline fun <reified T> getByType() = getByType(T::class.java)

/**
* Returns whether the block at [blockPosition] is a Rebar block.
* Returns false if the chunk at [blockPosition] is not loaded.
Expand Down Expand Up @@ -313,6 +382,7 @@ object BlockStorage : Listener {

RebarBlockPlaceEvent(blockPosition.block, block, context).callEvent()
block.postInitialise()
RebarBlockInitializeEvent(blockPosition.block, block).callEvent()
BlockCullingEngine.insert(block)

return block
Expand Down
Loading
Loading