Skip to content

Commit

Permalink
Silly silly dumb dumb
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Jul 2, 2024
1 parent e0e4a2e commit fffaa16
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_build=7
loader_version=0.15.11

# Mod Properties
mod_version=1.5.3
mod_version=1.5.4
maven_group=net.mcbrawls
mod_id=blueprint

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ data class Blueprint(
var i = 0
forEach { offset, state ->
world.setBlockState(position.add(offset), state)
i++
progress.set(++i / totalBlocks.toFloat())
}

progress.set(i / totalBlocks.toFloat())
}

PlacedBlueprint(this, position)
Expand Down
36 changes: 36 additions & 0 deletions src/test/kotlin/net/mcbrawls/blueprint/test/BlueprintTest.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
package net.mcbrawls.blueprint.test

import dev.andante.audience.AudienceInitializer.server
import net.fabricmc.api.ModInitializer
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents
import net.mcbrawls.blueprint.BlueprintMod
import net.mcbrawls.blueprint.resource.BlueprintManager
import net.mcbrawls.blueprint.structure.ProgressProvider
import net.minecraft.server.command.CommandManager
import net.minecraft.text.Text
import net.minecraft.util.Identifier
import net.minecraft.util.math.BlockPos

object BlueprintTest : ModInitializer {
private var displayedProgress: ProgressProvider? = null

override fun onInitialize() {
CommandRegistrationCallback.EVENT.register { dispatcher, _, _ ->
dispatcher.register(
CommandManager.literal("blueprint-test")
.executes { context ->
val pos = context.source.position
val blockPos = BlockPos.ofFloored(pos)
val (future, progress) = BlueprintManager[Identifier.of(BlueprintMod.MOD_ID, "test")]!!.placeWithProgress(context.source.world, blockPos)
if (displayedProgress == null) {
displayedProgress = progress
}
future.thenRun {
if (displayedProgress === progress) {
displayedProgress = null
}
}
1
}
)
}
ServerTickEvents.END_SERVER_TICK.register { server ->
server.playerManager.playerList.forEach { player ->
player.actionBar(Text.literal("${displayedProgress?.getProgress()}"))
}
}
}
}
Binary file not shown.

0 comments on commit fffaa16

Please sign in to comment.