fixed particle not spawning as correct block type

This commit is contained in:
2024-11-15 15:58:27 +01:00
parent 9c0bd44f14
commit 8214038084
3 changed files with 9 additions and 6 deletions
@@ -48,10 +48,8 @@ class Bde_particles : ModInitializer {
onRightClick(player, world as ServerWorld, hand)
})
ServerLifecycleEvents.SERVER_STARTED.register(ServerLifecycleEvents.ServerStarted { server: MinecraftServer ->
server.playerManager.broadcast(Text.of("BDAT - Loaded"), false)
print("BDAT - Loaded")
ServerLifecycleEvents.SERVER_STARTED.register(ServerLifecycleEvents.ServerStarted { _ ->
println("BDE_ParticleSys - Progress bar filled :3")
})
}
}
@@ -24,7 +24,7 @@ class DisplayEntity(val properties: DisplayEntityProperties?) {
val e = BlockDisplayEntity(EntityType.BLOCK_DISPLAY, world)
val nbt = NbtCompound().apply {
putString("Name", properties.blockType)
put("block_state", NbtCompound().apply { putString("Name", properties.blockType) })
put("transformation", NbtCompound().apply {
val offsetList = NbtList().apply {
add(NbtFloat.of(properties.translation.x))
@@ -28,6 +28,8 @@ class Particle(particleParams: ParticleParams) {
var blockDisplay: DisplayEntity? = null
val params = particleParams
var isInit = false
fun init(pos: Vec3d) {
val properties = DisplayEntityProperties(
pos = pos,
@@ -37,11 +39,14 @@ class Particle(particleParams: ParticleParams) {
)
blockDisplay = DisplayEntity(properties)
isInit = true
}
fun spawn(world: ServerWorld) {
blockDisplay?.spawn(world)
if (isInit) { blockDisplay?.spawn(world) }
else { error("Particle is not initialized before being spawned. Please use Particle.init() to initialize it") }
}