particles: RedstoneTorchBlock

This commit is contained in:
Bixilon 2021-06-12 15:13:01 +02:00 committed by Lukas
parent 325d8ccfe6
commit 6b608738b9
3 changed files with 42 additions and 2 deletions

View File

@ -124,6 +124,7 @@ open class Block(
"BrewingStandBlock" to { resourceLocation, registries, data -> BrewingStandBlock(resourceLocation, registries, data) },
"EnderChestBlock" to { resourceLocation, registries, data -> EnderChestBlock(resourceLocation, registries, data) },
"NetherPortalBlock" to { resourceLocation, registries, data -> NetherPortalBlock(resourceLocation, registries, data) },
"RedstoneTorchBlock" to { resourceLocation, registries, data -> RedstoneTorchBlock(resourceLocation, registries, data) },
)
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): Block {

View File

@ -0,0 +1,39 @@
/*
* Minosoft
* Copyright (C) 2021 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.mappings.blocks.types
import com.google.gson.JsonObject
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.mappings.blocks.BlockState
import de.bixilon.minosoft.data.mappings.blocks.properties.BlockProperties
import de.bixilon.minosoft.data.mappings.versions.Registries
import de.bixilon.minosoft.gui.rendering.util.VecUtil.EMPTY
import de.bixilon.minosoft.gui.rendering.util.VecUtil.of
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import glm_.vec3.Vec3d
import glm_.vec3.Vec3i
import kotlin.random.Random
open class RedstoneTorchBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : TorchBlock(resourceLocation, registries, data) {
override fun randomTick(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, random: Random) {
if (blockState.properties[BlockProperties.LIT] != true) {
return
}
flameParticle?.let { connection.world += it.factory?.build(connection, Vec3d(blockPosition) + Vec3d(0.5, 0.7, 0.5) + (Vec3d.of { random.nextDouble() - 0.5 } * 0.2), Vec3d.EMPTY) }
}
}

View File

@ -26,8 +26,8 @@ import glm_.vec3.Vec3i
import kotlin.random.Random
open class TorchBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : Block(resourceLocation, registries, data) {
private val smokeParticle = registries.particleTypeRegistry[SmokeParticle]
private val flameParticle = registries.particleTypeRegistry[data["flame_particle"] ?: FlameParticle]
protected val smokeParticle = registries.particleTypeRegistry[SmokeParticle]
protected val flameParticle = registries.particleTypeRegistry[data["flame_particle"] ?: FlameParticle]
private fun spawnSmokeParticles(connection: PlayConnection, blockPosition: Vec3i) {