mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
fix explosion affected blocks
This commit is contained in:
parent
6108344c65
commit
3fed73e640
@ -13,15 +13,16 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.util
|
package de.bixilon.minosoft.gui.rendering.util
|
||||||
|
|
||||||
import de.bixilon.kotlinglm.func.common.ceil
|
|
||||||
import de.bixilon.kotlinglm.func.common.clamp
|
import de.bixilon.kotlinglm.func.common.clamp
|
||||||
import de.bixilon.kotlinglm.func.common.floor
|
|
||||||
import de.bixilon.kotlinglm.vec2.Vec2
|
import de.bixilon.kotlinglm.vec2.Vec2
|
||||||
import de.bixilon.kotlinglm.vec2.Vec2i
|
import de.bixilon.kotlinglm.vec2.Vec2i
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3
|
import de.bixilon.kotlinglm.vec3.Vec3
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3t
|
import de.bixilon.kotlinglm.vec3.Vec3t
|
||||||
|
import de.bixilon.kutil.math.simple.DoubleMath.ceil
|
||||||
|
import de.bixilon.kutil.math.simple.DoubleMath.floor
|
||||||
|
import de.bixilon.kutil.math.simple.FloatMath.floor
|
||||||
import de.bixilon.minosoft.data.Axes
|
import de.bixilon.minosoft.data.Axes
|
||||||
import de.bixilon.minosoft.data.direction.Directions
|
import de.bixilon.minosoft.data.direction.Directions
|
||||||
import de.bixilon.minosoft.data.registries.AABB
|
import de.bixilon.minosoft.data.registries.AABB
|
||||||
@ -261,9 +262,9 @@ object VecUtil {
|
|||||||
fun getDistanceToNextIntegerAxisInDirection(position: Vec3d, direction: Vec3d): Double {
|
fun getDistanceToNextIntegerAxisInDirection(position: Vec3d, direction: Vec3d): Double {
|
||||||
fun getTarget(direction: Vec3d, position: Vec3d, axis: Axes): Int {
|
fun getTarget(direction: Vec3d, position: Vec3d, axis: Axes): Int {
|
||||||
return if (direction[axis] > 0) {
|
return if (direction[axis] > 0) {
|
||||||
position[axis].floor.toInt() + 1
|
position[axis].floor + 1
|
||||||
} else {
|
} else {
|
||||||
position[axis].ceil.toInt() - 1
|
position[axis].ceil - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class ExplosionEvent(
|
|||||||
initiator: EventInitiators,
|
initiator: EventInitiators,
|
||||||
val position: Vec3,
|
val position: Vec3,
|
||||||
val power: Float,
|
val power: Float,
|
||||||
val explodedBlocks: List<Vec3i>,
|
val explodedBlocks: Array<Vec3i>,
|
||||||
val velocity: Vec3,
|
val velocity: Vec3,
|
||||||
) : PlayConnectionEvent(connection) {
|
) : PlayConnectionEvent(connection) {
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ package de.bixilon.minosoft.protocol.packets.s2c.play
|
|||||||
|
|
||||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||||
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
import de.bixilon.kutil.primitive.BooleanUtil.decide
|
||||||
|
import de.bixilon.minosoft.gui.rendering.util.VecUtil.floor
|
||||||
import de.bixilon.minosoft.modding.event.events.ExplosionEvent
|
import de.bixilon.minosoft.modding.event.events.ExplosionEvent
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||||
@ -28,7 +29,7 @@ import de.bixilon.minosoft.util.logging.LogMessageType
|
|||||||
class ExplosionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
class ExplosionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val position = buffer.readVec3f()
|
val position = buffer.readVec3f()
|
||||||
val power = buffer.readFloat()
|
val power = buffer.readFloat()
|
||||||
val explodedBlocks: List<Vec3i> = buffer.readArray((buffer.versionId < V_1_17).decide({ buffer.readInt() }, { buffer.readVarInt() })) { Vec3i(buffer.readByte(), buffer.readByte(), buffer.readByte()) }.toList() // ToDo: Find out version
|
val explodedBlocks: Array<Vec3i> = buffer.readArray((buffer.versionId < V_1_17).decide({ buffer.readInt() }, { buffer.readVarInt() })) { Vec3i(buffer.readByte(), buffer.readByte(), buffer.readByte()) } // ToDo: Find out version
|
||||||
val velocity = buffer.readVec3f()
|
val velocity = buffer.readVec3f()
|
||||||
|
|
||||||
override fun check(connection: PlayConnection) {
|
override fun check(connection: PlayConnection) {
|
||||||
@ -40,8 +41,9 @@ class ExplosionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handle(connection: PlayConnection) {
|
override fun handle(connection: PlayConnection) {
|
||||||
for (record in explodedBlocks) {
|
val offsetPosition = Vec3i(position.floor)
|
||||||
val blockPosition = Vec3i(position) + record
|
for (blockDelta in explodedBlocks) {
|
||||||
|
val blockPosition = offsetPosition + blockDelta
|
||||||
connection.world[blockPosition] = null
|
connection.world[blockPosition] = null
|
||||||
// ToDo: Mass set blocks
|
// ToDo: Mass set blocks
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user