mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 17:07:55 -04:00
lever particles, dolphin and dust particles
This commit is contained in:
parent
462d944031
commit
0160b6c68d
@ -16,7 +16,7 @@ package de.bixilon.minosoft.config.config.game.particles
|
|||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
|
|
||||||
data class ParticleConfig(
|
data class ParticleConfig(
|
||||||
var enabled: Boolean = false,
|
var enabled: Boolean = true,
|
||||||
@Json(name = "by_packet") var byPacket: Boolean = true,
|
@Json(name = "by_packet") var byPacket: Boolean = true,
|
||||||
var explosions: Boolean = true,
|
var explosions: Boolean = true,
|
||||||
)
|
)
|
||||||
|
@ -22,7 +22,7 @@ import glm_.vec2.Vec2i
|
|||||||
import glm_.vec3.Vec3
|
import glm_.vec3.Vec3
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
enum class Directions(val directionVector: Vec3i) {
|
enum class Directions(val vector: Vec3i) {
|
||||||
DOWN(Vec3i(0, -1, 0)),
|
DOWN(Vec3i(0, -1, 0)),
|
||||||
UP(Vec3i(0, 1, 0)),
|
UP(Vec3i(0, 1, 0)),
|
||||||
NORTH(Vec3i(0, 0, -1)),
|
NORTH(Vec3i(0, 0, -1)),
|
||||||
@ -30,7 +30,7 @@ enum class Directions(val directionVector: Vec3i) {
|
|||||||
WEST(Vec3i(-1, 0, 0)),
|
WEST(Vec3i(-1, 0, 0)),
|
||||||
EAST(Vec3i(1, 0, 0));
|
EAST(Vec3i(1, 0, 0));
|
||||||
|
|
||||||
val floatDirectionVector = Vec3(directionVector)
|
val floatDirectionVector = Vec3(vector)
|
||||||
|
|
||||||
val axis: Axes get() = Axes.byDirection(this)
|
val axis: Axes get() = Axes.byDirection(this)
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ enum class Directions(val directionVector: Vec3i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isBlockResolutionBorder(start: Vec3, end: Vec3): Boolean {
|
private fun isBlockResolutionBorder(start: Vec3, end: Vec3): Boolean {
|
||||||
return isCoordinateBorder(directionVector.x, start.x, end.x) || isCoordinateBorder(directionVector.y, start.y, end.y) || isCoordinateBorder(directionVector.z, start.z, end.z)
|
return isCoordinateBorder(vector.x, start.x, end.x) || isCoordinateBorder(vector.y, start.y, end.y) || isCoordinateBorder(vector.z, start.z, end.z)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isCoordinateBorder(directionValue: Int, start: Float, end: Float): Boolean {
|
private fun isCoordinateBorder(directionValue: Int, start: Float, end: Float): Boolean {
|
||||||
@ -89,7 +89,7 @@ enum class Directions(val directionVector: Vec3i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator fun get(axis: Axes): Int {
|
operator fun get(axis: Axes): Int {
|
||||||
return directionVector[axis]
|
return vector[axis]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
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.versions.Registries
|
|
||||||
|
|
||||||
abstract class AbstractRedstoneGateBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : HorizontalFacingBlock(resourceLocation, mappings, data)
|
|
@ -21,6 +21,9 @@ import de.bixilon.minosoft.data.mappings.blocks.BlockUsages
|
|||||||
import de.bixilon.minosoft.data.mappings.blocks.RandomOffsetTypes
|
import de.bixilon.minosoft.data.mappings.blocks.RandomOffsetTypes
|
||||||
import de.bixilon.minosoft.data.mappings.blocks.entites.BlockEntityType
|
import de.bixilon.minosoft.data.mappings.blocks.entites.BlockEntityType
|
||||||
import de.bixilon.minosoft.data.mappings.blocks.properties.BlockProperties
|
import de.bixilon.minosoft.data.mappings.blocks.properties.BlockProperties
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.types.redstone.ComparatorBlock
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.types.redstone.RepeaterBlock
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.types.wall.LeverBlock
|
||||||
import de.bixilon.minosoft.data.mappings.items.Item
|
import de.bixilon.minosoft.data.mappings.items.Item
|
||||||
import de.bixilon.minosoft.data.mappings.registry.RegistryItem
|
import de.bixilon.minosoft.data.mappings.registry.RegistryItem
|
||||||
import de.bixilon.minosoft.data.mappings.registry.ResourceLocationDeserializer
|
import de.bixilon.minosoft.data.mappings.registry.ResourceLocationDeserializer
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package de.bixilon.minosoft.data.mappings.blocks.types
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import de.bixilon.minosoft.data.inventory.ItemStack
|
|
||||||
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
|
||||||
import de.bixilon.minosoft.data.mappings.blocks.BlockState
|
|
||||||
import de.bixilon.minosoft.data.mappings.blocks.BlockUsages
|
|
||||||
import de.bixilon.minosoft.data.mappings.blocks.properties.BlockProperties
|
|
||||||
import de.bixilon.minosoft.data.mappings.versions.Registries
|
|
||||||
import de.bixilon.minosoft.data.player.Hands
|
|
||||||
import de.bixilon.minosoft.gui.rendering.input.camera.RaycastHit
|
|
||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
|
||||||
import glm_.vec3.Vec3i
|
|
||||||
|
|
||||||
open class RepeaterBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : AbstractRedstoneGateBlock(resourceLocation, mappings, data) {
|
|
||||||
|
|
||||||
override fun getPlacementState(connection: PlayConnection, raycastHit: RaycastHit): BlockState? {
|
|
||||||
TODO()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUse(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, raycastHit: RaycastHit, hands: Hands, itemStack: ItemStack?): BlockUsages {
|
|
||||||
connection.world[blockPosition] = blockState.cycle(BlockProperties.REPEATER_DELAY)
|
|
||||||
|
|
||||||
return BlockUsages.SUCCESS
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,17 @@
|
|||||||
package de.bixilon.minosoft.data.mappings.blocks.types
|
/*
|
||||||
|
* 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.redstone
|
||||||
|
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import de.bixilon.minosoft.data.inventory.ItemStack
|
import de.bixilon.minosoft.data.inventory.ItemStack
|
||||||
@ -12,7 +25,7 @@ import de.bixilon.minosoft.gui.rendering.input.camera.RaycastHit
|
|||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
open class ComparatorBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : AbstractRedstoneGateBlock(resourceLocation, mappings, data) {
|
open class ComparatorBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : RedstoneGateBlock(resourceLocation, mappings, data) {
|
||||||
|
|
||||||
override fun getPlacementState(connection: PlayConnection, raycastHit: RaycastHit): BlockState? {
|
override fun getPlacementState(connection: PlayConnection, raycastHit: RaycastHit): BlockState? {
|
||||||
TODO()
|
TODO()
|
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* 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.redstone
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.types.HorizontalFacingBlock
|
||||||
|
import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||||
|
|
||||||
|
abstract class RedstoneGateBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : HorizontalFacingBlock(resourceLocation, mappings, data)
|
@ -11,7 +11,7 @@
|
|||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings.blocks.types
|
package de.bixilon.minosoft.data.mappings.blocks.types.redstone
|
||||||
|
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import de.bixilon.minosoft.data.inventory.ItemStack
|
import de.bixilon.minosoft.data.inventory.ItemStack
|
||||||
@ -25,14 +25,14 @@ import de.bixilon.minosoft.gui.rendering.input.camera.RaycastHit
|
|||||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
import glm_.vec3.Vec3i
|
import glm_.vec3.Vec3i
|
||||||
|
|
||||||
open class LeverBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : Block(resourceLocation, mappings, data) {
|
open class RepeaterBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : RedstoneGateBlock(resourceLocation, mappings, data) {
|
||||||
|
|
||||||
override fun getPlacementState(connection: PlayConnection, raycastHit: RaycastHit): BlockState? {
|
override fun getPlacementState(connection: PlayConnection, raycastHit: RaycastHit): BlockState? {
|
||||||
TODO()
|
TODO()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUse(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, raycastHit: RaycastHit, hands: Hands, itemStack: ItemStack?): BlockUsages {
|
override fun onUse(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, raycastHit: RaycastHit, hands: Hands, itemStack: ItemStack?): BlockUsages {
|
||||||
connection.world[blockPosition] = blockState.cycle(BlockProperties.POWERED)
|
connection.world[blockPosition] = blockState.cycle(BlockProperties.REPEATER_DELAY)
|
||||||
|
|
||||||
return BlockUsages.SUCCESS
|
return BlockUsages.SUCCESS
|
||||||
}
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* 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.wall
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import de.bixilon.minosoft.data.Directions
|
||||||
|
import de.bixilon.minosoft.data.inventory.ItemStack
|
||||||
|
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.BlockState
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.BlockUsages
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.properties.BlockProperties
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.DustParticleData
|
||||||
|
import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||||
|
import de.bixilon.minosoft.data.player.Hands
|
||||||
|
import de.bixilon.minosoft.data.text.Colors
|
||||||
|
import de.bixilon.minosoft.gui.rendering.input.camera.RaycastHit
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.dust.DustParticle
|
||||||
|
import de.bixilon.minosoft.gui.rendering.util.VecUtil.EMPTY
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.KUtil.chance
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
import glm_.vec3.Vec3i
|
||||||
|
import kotlin.random.Random
|
||||||
|
|
||||||
|
open class LeverBlock(resourceLocation: ResourceLocation, registries: Registries, data: JsonObject) : WallMountedBlock(resourceLocation, registries, data) {
|
||||||
|
private val dustParticleType = registries.particleTypeRegistry[DustParticle]
|
||||||
|
|
||||||
|
private fun spawnParticles(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, scale: Float) {
|
||||||
|
dustParticleType ?: return
|
||||||
|
val direction = (blockState.properties[BlockProperties.FACING] as Directions).inverted
|
||||||
|
val mountDirection = getRealFacing(blockState)
|
||||||
|
|
||||||
|
val position = (Vec3(blockPosition) + 0.5f).plus((direction.vector * 0.1f) + (mountDirection.vector * 0.2f))
|
||||||
|
|
||||||
|
connection.world += DustParticle(connection, position, Vec3.EMPTY, DustParticleData(Colors.TRUE_RED, scale, dustParticleType))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun randomTick(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, random: Random) {
|
||||||
|
if (blockState.properties[BlockProperties.POWERED] != true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (random.chance(25)) {
|
||||||
|
spawnParticles(connection, blockState, blockPosition, 0.5f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getPlacementState(connection: PlayConnection, raycastHit: RaycastHit): BlockState? {
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUse(connection: PlayConnection, blockState: BlockState, blockPosition: Vec3i, raycastHit: RaycastHit, hands: Hands, itemStack: ItemStack?): BlockUsages {
|
||||||
|
val nextState = blockState.cycle(BlockProperties.POWERED)
|
||||||
|
connection.world[blockPosition] = nextState
|
||||||
|
spawnParticles(connection, nextState, blockPosition, 1.0f)
|
||||||
|
|
||||||
|
return BlockUsages.SUCCESS
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.wall
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import de.bixilon.minosoft.data.Directions
|
||||||
|
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.BlockState
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.properties.Attachments
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.properties.BlockProperties
|
||||||
|
import de.bixilon.minosoft.data.mappings.blocks.types.Block
|
||||||
|
import de.bixilon.minosoft.data.mappings.versions.Registries
|
||||||
|
|
||||||
|
abstract class WallMountedBlock(resourceLocation: ResourceLocation, mappings: Registries, data: JsonObject) : Block(resourceLocation, mappings, data) {
|
||||||
|
|
||||||
|
fun getRealFacing(blockState: BlockState): Directions {
|
||||||
|
return when (blockState.properties[BlockProperties.FACE]) {
|
||||||
|
Attachments.CEILING -> Directions.DOWN
|
||||||
|
Attachments.FLOOR -> Directions.UP
|
||||||
|
else -> blockState.properties[BlockProperties.FACING] as Directions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -27,7 +27,7 @@ class CollisionDetector(val connection: PlayConnection) {
|
|||||||
|
|
||||||
fun getCollisionsToCheck(deltaPosition: Vec3, aabb: AABB, ignoreUnloadedChunks: Boolean = true): VoxelShape {
|
fun getCollisionsToCheck(deltaPosition: Vec3, aabb: AABB, ignoreUnloadedChunks: Boolean = true): VoxelShape {
|
||||||
// also look at blocks further down to also cover blocks with a higher than normal hitbox (for example fences)
|
// also look at blocks further down to also cover blocks with a higher than normal hitbox (for example fences)
|
||||||
val blockPositions = (aabb extend deltaPosition extend Directions.DOWN.directionVector).getBlockPositions()
|
val blockPositions = (aabb extend deltaPosition extend Directions.DOWN.vector).getBlockPositions()
|
||||||
val result = VoxelShape()
|
val result = VoxelShape()
|
||||||
for (blockPosition in blockPositions) {
|
for (blockPosition in blockPositions) {
|
||||||
val chunk = connection.world[blockPosition.chunkPosition]
|
val chunk = connection.world[blockPosition.chunkPosition]
|
||||||
|
20
src/main/java/de/bixilon/minosoft/data/text/Colors.kt
Normal file
20
src/main/java/de/bixilon/minosoft/data/text/Colors.kt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.text
|
||||||
|
|
||||||
|
object Colors {
|
||||||
|
val TRUE_RED = RGBColor(255, 0, 0)
|
||||||
|
val TRUE_GREEN = RGBColor(0, 255, 0)
|
||||||
|
val TRUE_BLUE = RGBColor(0, 0, 255)
|
||||||
|
}
|
@ -457,7 +457,7 @@ class WorldRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private operator fun Int.plus(upOrDown: Directions): Int {
|
private operator fun Int.plus(upOrDown: Directions): Int {
|
||||||
return this + upOrDown.directionVector.y
|
return this + upOrDown.vector.y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ class ElementRenderer(
|
|||||||
if (uvLock) {
|
if (uvLock) {
|
||||||
for (direction in Directions.VALUES) {
|
for (direction in Directions.VALUES) {
|
||||||
val axis = Axes.byDirection(direction)
|
val axis = Axes.byDirection(direction)
|
||||||
val angle = Axes.choose(axis, rotation) * Axes.choose(axis, direction.directionVector)
|
val angle = Axes.choose(axis, rotation) * Axes.choose(axis, direction.vector)
|
||||||
faces[direction]?.rotate(-angle)
|
faces[direction]?.rotate(-angle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,10 @@ import de.bixilon.minosoft.gui.rendering.particle.types.Particle
|
|||||||
import de.bixilon.minosoft.gui.rendering.particle.types.norender.ExplosionEmitterParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.norender.ExplosionEmitterParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.CampfireSmokeParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.CampfireSmokeParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.ExplosionParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.ExplosionParticle
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.dust.DustParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.fire.SmokeParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.fire.SmokeParticle
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.lava.LavaParticle
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.lava.LavaParticle
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.DolphinParticle
|
||||||
|
|
||||||
object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
|
object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
|
||||||
ExplosionEmitterParticle,
|
ExplosionEmitterParticle,
|
||||||
@ -28,4 +30,6 @@ object DefaultParticleFactory : DefaultFactory<ParticleFactory<out Particle>>(
|
|||||||
CampfireSmokeParticle.SignalFactory,
|
CampfireSmokeParticle.SignalFactory,
|
||||||
LavaParticle,
|
LavaParticle,
|
||||||
SmokeParticle,
|
SmokeParticle,
|
||||||
|
DolphinParticle,
|
||||||
|
DustParticle,
|
||||||
)
|
)
|
||||||
|
@ -82,7 +82,6 @@ class ParticleRenderer(
|
|||||||
add(particle)
|
add(particle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun draw() {
|
override fun draw() {
|
||||||
particleShader.use()
|
particleShader.use()
|
||||||
|
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.gui.rendering.particle.types.render.texture.simple.dust
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.DustParticleData
|
||||||
|
import de.bixilon.minosoft.data.text.RGBColor
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.SimpleTextureParticle
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.MMath
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
|
abstract class AbstractDustParticle(connection: PlayConnection, position: Vec3, velocity: Vec3, data: DustParticleData) : SimpleTextureParticle(connection, position, velocity, data) {
|
||||||
|
|
||||||
|
override var scale: Float
|
||||||
|
get() = super.scale * MMath.clamp(floatAge / maxAge * 32.0f, 0.0f, 1.0f)
|
||||||
|
set(value) {
|
||||||
|
super.scale = value
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.friction = 0.96f
|
||||||
|
this.velocity *= 0.10000000149011612f
|
||||||
|
|
||||||
|
val brightness = random.nextFloat() * 0.4f + 0.6f
|
||||||
|
this.color = RGBColor(
|
||||||
|
red = colorMix(data.color.floatRed, brightness),
|
||||||
|
green = colorMix(data.color.floatGreen, brightness),
|
||||||
|
blue = colorMix(data.color.floatBlue, brightness),
|
||||||
|
)
|
||||||
|
super.scale *= 0.75f * data.scale
|
||||||
|
|
||||||
|
maxAge = ((8.0f / (random.nextFloat() * 0.8f + 0.2f)) * data.scale).coerceAtLeast(1.0f).toInt()
|
||||||
|
|
||||||
|
this.accelerateIfYBlocked = true
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun colorMix(color: Float, brightness: Float): Float {
|
||||||
|
return (random.nextFloat() * 0.2f + 0.8f) * color * brightness
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun realTick() {
|
||||||
|
super.realTick()
|
||||||
|
position += velocity
|
||||||
|
|
||||||
|
velocity *= 0.99f
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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.gui.rendering.particle.types.render.texture.simple.dust
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.DustParticleData
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
|
class DustParticle(connection: PlayConnection, position: Vec3, velocity: Vec3, data: DustParticleData) : AbstractDustParticle(connection, position, velocity, data) {
|
||||||
|
|
||||||
|
companion object : ParticleFactory<DustParticle> {
|
||||||
|
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:dust".asResourceLocation()
|
||||||
|
|
||||||
|
override fun build(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData): DustParticle {
|
||||||
|
return DustParticle(connection, position, velocity, data as DustParticleData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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.gui.rendering.particle.types.render.texture.simple.suspend
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.mappings.ResourceLocation
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
|
||||||
|
import de.bixilon.minosoft.data.text.RGBColor
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.ParticleFactory
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import de.bixilon.minosoft.util.KUtil.asResourceLocation
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
|
class DolphinParticle(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData? = null) : SuspendParticle(connection, position, velocity, data) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
color = RGBColor(0.3f, 0.5f, 1.0f, (1.0f - random.nextFloat() * 0.7f))
|
||||||
|
maxAge /= 2
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object : ParticleFactory<DolphinParticle> {
|
||||||
|
override val RESOURCE_LOCATION: ResourceLocation = "minecraft:dolphin".asResourceLocation()
|
||||||
|
|
||||||
|
override fun build(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData): DolphinParticle {
|
||||||
|
return DolphinParticle(connection, position, velocity, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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.gui.rendering.particle.types.render.texture.simple.suspend
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.mappings.particle.data.ParticleData
|
||||||
|
import de.bixilon.minosoft.data.text.RGBColor.Companion.asGray
|
||||||
|
import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.SimpleTextureParticle
|
||||||
|
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||||
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
|
abstract class SuspendParticle(connection: PlayConnection, position: Vec3, velocity: Vec3, data: ParticleData? = null) : SimpleTextureParticle(connection, position, velocity, data) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.color = (random.nextFloat() * 0.1f + 0.2f).asGray()
|
||||||
|
spacing = Vec3(0.2f)
|
||||||
|
scale *= random.nextFloat() * 0.6f + 0.5f
|
||||||
|
velocity *= 0.019999999552965164f
|
||||||
|
maxAge = (20 / (random.nextFloat() * 0.8f + 0.2f)).toInt()
|
||||||
|
movement = false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun realTick() {
|
||||||
|
super.realTick()
|
||||||
|
position += velocity
|
||||||
|
|
||||||
|
velocity *= 0.99f
|
||||||
|
}
|
||||||
|
}
|
@ -241,7 +241,7 @@ object VecUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
infix operator fun Vec3i.plus(direction: Directions?): Vec3i {
|
infix operator fun Vec3i.plus(direction: Directions?): Vec3i {
|
||||||
return this + direction?.directionVector
|
return this + direction?.vector
|
||||||
}
|
}
|
||||||
|
|
||||||
infix operator fun Vec3i.plus(input: Vec3): Vec3 {
|
infix operator fun Vec3i.plus(input: Vec3): Vec3 {
|
||||||
@ -253,7 +253,7 @@ object VecUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
infix operator fun Vec2i.plus(direction: Directions): Vec2i {
|
infix operator fun Vec2i.plus(direction: Directions): Vec2i {
|
||||||
return this + direction.directionVector
|
return this + direction.vector
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Vec3i.getWorldOffset(block: Block): Vec3 {
|
fun Vec3i.getWorldOffset(block: Block): Vec3 {
|
||||||
|
@ -53,6 +53,6 @@ class ParticleS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun log() {
|
override fun log() {
|
||||||
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "ParticleType (type=$type, longDistance=$longDistance, position=$position, offset=$offset, speed=$speed, count=$count, data=$data)" }
|
Log.log(LogMessageType.NETWORK_PACKETS_IN, level = LogLevels.VERBOSE) { "Particle (type=$type, longDistance=$longDistance, position=$position, offset=$offset, speed=$speed, count=$count, data=$data)" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user