diff --git a/src/main/java/de/bixilon/minosoft/config/config/game/particles/ParticleConfig.kt b/src/main/java/de/bixilon/minosoft/config/config/game/particles/ParticleConfig.kt
index 4ff101422..fb28766fd 100644
--- a/src/main/java/de/bixilon/minosoft/config/config/game/particles/ParticleConfig.kt
+++ b/src/main/java/de/bixilon/minosoft/config/config/game/particles/ParticleConfig.kt
@@ -16,7 +16,7 @@ package de.bixilon.minosoft.config.config.game.particles
import com.squareup.moshi.Json
data class ParticleConfig(
- var enabled: Boolean = false,
+ var enabled: Boolean = true,
@Json(name = "by_packet") var byPacket: Boolean = true,
var explosions: Boolean = true,
)
diff --git a/src/main/java/de/bixilon/minosoft/data/Directions.kt b/src/main/java/de/bixilon/minosoft/data/Directions.kt
index dfe43b316..f665105b5 100644
--- a/src/main/java/de/bixilon/minosoft/data/Directions.kt
+++ b/src/main/java/de/bixilon/minosoft/data/Directions.kt
@@ -22,7 +22,7 @@ import glm_.vec2.Vec2i
import glm_.vec3.Vec3
import glm_.vec3.Vec3i
-enum class Directions(val directionVector: Vec3i) {
+enum class Directions(val vector: Vec3i) {
DOWN(Vec3i(0, -1, 0)),
UP(Vec3i(0, 1, 0)),
NORTH(Vec3i(0, 0, -1)),
@@ -30,7 +30,7 @@ enum class Directions(val directionVector: Vec3i) {
WEST(Vec3i(-1, 0, 0)),
EAST(Vec3i(1, 0, 0));
- val floatDirectionVector = Vec3(directionVector)
+ val floatDirectionVector = Vec3(vector)
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 {
- 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 {
@@ -89,7 +89,7 @@ enum class Directions(val directionVector: Vec3i) {
}
operator fun get(axis: Axes): Int {
- return directionVector[axis]
+ return vector[axis]
}
diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/AbstractRedstoneGateBlock.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/AbstractRedstoneGateBlock.kt
deleted file mode 100644
index 664d7850c..000000000
--- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/AbstractRedstoneGateBlock.kt
+++ /dev/null
@@ -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)
diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/Block.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/Block.kt
index 5b43e0ad5..59c49cc30 100644
--- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/Block.kt
+++ b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/Block.kt
@@ -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.entites.BlockEntityType
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.registry.RegistryItem
import de.bixilon.minosoft.data.mappings.registry.ResourceLocationDeserializer
diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/RepeaterBlock.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/RepeaterBlock.kt
deleted file mode 100644
index a3085afec..000000000
--- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/RepeaterBlock.kt
+++ /dev/null
@@ -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
- }
-}
diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/ComparatorBlock.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/redstone/ComparatorBlock.kt
similarity index 54%
rename from src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/ComparatorBlock.kt
rename to src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/redstone/ComparatorBlock.kt
index 13d288c0f..8381ca7c8 100644
--- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/ComparatorBlock.kt
+++ b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/redstone/ComparatorBlock.kt
@@ -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 .
+ *
+ * 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.inventory.ItemStack
@@ -12,7 +25,7 @@ import de.bixilon.minosoft.gui.rendering.input.camera.RaycastHit
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
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? {
TODO()
diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/redstone/RedstoneGateBlock.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/redstone/RedstoneGateBlock.kt
new file mode 100644
index 000000000..47fcc0e3d
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/redstone/RedstoneGateBlock.kt
@@ -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 .
+ *
+ * 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)
diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/LeverBlock.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/redstone/RepeaterBlock.kt
similarity index 87%
rename from src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/LeverBlock.kt
rename to src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/redstone/RepeaterBlock.kt
index 38514e221..ceb476c33 100644
--- a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/LeverBlock.kt
+++ b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/redstone/RepeaterBlock.kt
@@ -11,7 +11,7 @@
* 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 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 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? {
TODO()
}
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
}
diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/wall/LeverBlock.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/wall/LeverBlock.kt
new file mode 100644
index 000000000..5d0e36d30
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/wall/LeverBlock.kt
@@ -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 .
+ *
+ * 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
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/wall/WallMountedBlock.kt b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/wall/WallMountedBlock.kt
new file mode 100644
index 000000000..4db6ef574
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/mappings/blocks/types/wall/WallMountedBlock.kt
@@ -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 .
+ *
+ * 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
+ }
+ }
+
+}
diff --git a/src/main/java/de/bixilon/minosoft/data/physics/CollisionDetector.kt b/src/main/java/de/bixilon/minosoft/data/physics/CollisionDetector.kt
index 65a111302..1cde5c11b 100644
--- a/src/main/java/de/bixilon/minosoft/data/physics/CollisionDetector.kt
+++ b/src/main/java/de/bixilon/minosoft/data/physics/CollisionDetector.kt
@@ -27,7 +27,7 @@ class CollisionDetector(val connection: PlayConnection) {
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)
- val blockPositions = (aabb extend deltaPosition extend Directions.DOWN.directionVector).getBlockPositions()
+ val blockPositions = (aabb extend deltaPosition extend Directions.DOWN.vector).getBlockPositions()
val result = VoxelShape()
for (blockPosition in blockPositions) {
val chunk = connection.world[blockPosition.chunkPosition]
diff --git a/src/main/java/de/bixilon/minosoft/data/text/Colors.kt b/src/main/java/de/bixilon/minosoft/data/text/Colors.kt
new file mode 100644
index 000000000..2cda0dba2
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/data/text/Colors.kt
@@ -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 .
+ *
+ * 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)
+}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt
index a43bdeea5..def19190b 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/WorldRenderer.kt
@@ -457,7 +457,7 @@ class WorldRenderer(
}
private operator fun Int.plus(upOrDown: Directions): Int {
- return this + upOrDown.directionVector.y
+ return this + upOrDown.vector.y
}
}
}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt
index 46a2c806b..24677c12e 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/chunk/models/renderable/ElementRenderer.kt
@@ -58,7 +58,7 @@ class ElementRenderer(
if (uvLock) {
for (direction in Directions.VALUES) {
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)
}
}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/DefaultParticleFactory.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/DefaultParticleFactory.kt
index 5c1fdd18d..a6cb1f9ac 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/DefaultParticleFactory.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/DefaultParticleFactory.kt
@@ -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.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.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.lava.LavaParticle
+import de.bixilon.minosoft.gui.rendering.particle.types.render.texture.simple.suspend.DolphinParticle
object DefaultParticleFactory : DefaultFactory>(
ExplosionEmitterParticle,
@@ -28,4 +30,6 @@ object DefaultParticleFactory : DefaultFactory>(
CampfireSmokeParticle.SignalFactory,
LavaParticle,
SmokeParticle,
+ DolphinParticle,
+ DustParticle,
)
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/ParticleRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/ParticleRenderer.kt
index 729c6f296..316a97cf2 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/ParticleRenderer.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/ParticleRenderer.kt
@@ -82,7 +82,6 @@ class ParticleRenderer(
add(particle)
}
-
override fun draw() {
particleShader.use()
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/dust/AbstractDustParticle.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/dust/AbstractDustParticle.kt
new file mode 100644
index 000000000..5a308b6f6
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/dust/AbstractDustParticle.kt
@@ -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 .
+ *
+ * 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
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/dust/DustParticle.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/dust/DustParticle.kt
new file mode 100644
index 000000000..7465c314e
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/dust/DustParticle.kt
@@ -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 .
+ *
+ * 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 {
+ 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)
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/suspend/DolphinParticle.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/suspend/DolphinParticle.kt
new file mode 100644
index 000000000..76fe23457
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/suspend/DolphinParticle.kt
@@ -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 .
+ *
+ * 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 {
+ 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)
+ }
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/suspend/SuspendParticle.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/suspend/SuspendParticle.kt
new file mode 100644
index 000000000..7b7bc5bd4
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/particle/types/render/texture/simple/suspend/SuspendParticle.kt
@@ -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 .
+ *
+ * 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
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/util/VecUtil.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/util/VecUtil.kt
index 56f8f04f3..b144ea8a2 100644
--- a/src/main/java/de/bixilon/minosoft/gui/rendering/util/VecUtil.kt
+++ b/src/main/java/de/bixilon/minosoft/gui/rendering/util/VecUtil.kt
@@ -241,7 +241,7 @@ object VecUtil {
}
infix operator fun Vec3i.plus(direction: Directions?): Vec3i {
- return this + direction?.directionVector
+ return this + direction?.vector
}
infix operator fun Vec3i.plus(input: Vec3): Vec3 {
@@ -253,7 +253,7 @@ object VecUtil {
}
infix operator fun Vec2i.plus(direction: Directions): Vec2i {
- return this + direction.directionVector
+ return this + direction.vector
}
fun Vec3i.getWorldOffset(block: Block): Vec3 {
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/ParticleS2CP.kt b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/ParticleS2CP.kt
index 23b50540a..b0dcb772f 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/ParticleS2CP.kt
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/s2c/play/ParticleS2CP.kt
@@ -53,6 +53,6 @@ class ParticleS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
}
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)" }
}
}