mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 18:34:56 -04:00
override gravity in entity when in spectator gamemode
This commit is contained in:
parent
02db2d7ba9
commit
aa20dc3441
@ -37,7 +37,7 @@ class MultiAssetsManager(
|
|||||||
throw IllegalArgumentException("Can not add ourself!")
|
throw IllegalArgumentException("Can not add ourself!")
|
||||||
}
|
}
|
||||||
for (namespace in assetsManager.namespaces) {
|
for (namespace in assetsManager.namespaces) {
|
||||||
this.assetsManagers.getOrPut(namespace, { mutableListOf() }).add(assetsManager)
|
this.assetsManagers.getOrPut(namespace) { mutableListOf() }.add(assetsManager)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,9 +136,9 @@ abstract class Entity(
|
|||||||
val isSilent: Boolean
|
val isSilent: Boolean
|
||||||
get() = entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_SILENT)
|
get() = entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_SILENT)
|
||||||
|
|
||||||
@EntityMetaDataFunction(name = "Has no gravity")
|
@EntityMetaDataFunction(name = "Has gravity")
|
||||||
val hasNoGravity: Boolean
|
open val hasGravity: Boolean
|
||||||
get() = entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_NO_GRAVITY)
|
get() = !entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_NO_GRAVITY)
|
||||||
|
|
||||||
@get:EntityMetaDataFunction(name = "Pose")
|
@get:EntityMetaDataFunction(name = "Pose")
|
||||||
val pose: Poses?
|
val pose: Poses?
|
||||||
@ -275,7 +275,7 @@ abstract class Entity(
|
|||||||
val newVelocity = Vec3(velocity)
|
val newVelocity = Vec3(velocity)
|
||||||
val oldVelocity = Vec3(velocity)
|
val oldVelocity = Vec3(velocity)
|
||||||
val deltaTime = deltaMillis.toFloat() / 1000.0f
|
val deltaTime = deltaMillis.toFloat() / 1000.0f
|
||||||
if (! hasNoGravity && !isFlying) {
|
if (hasGravity && !isFlying) {
|
||||||
newVelocity.y -= ProtocolDefinition.GRAVITY * deltaTime
|
newVelocity.y -= ProtocolDefinition.GRAVITY * deltaTime
|
||||||
}
|
}
|
||||||
newVelocity *= 0.25f.pow(deltaTime) // apply
|
newVelocity *= 0.25f.pow(deltaTime) // apply
|
||||||
|
@ -48,6 +48,14 @@ class PlayerEntity(
|
|||||||
override val hasCollisions: Boolean
|
override val hasCollisions: Boolean
|
||||||
get() = gamemode != Gamemodes.SPECTATOR
|
get() = gamemode != Gamemodes.SPECTATOR
|
||||||
|
|
||||||
|
override val hasGravity: Boolean
|
||||||
|
get() {
|
||||||
|
if (gamemode == Gamemodes.SPECTATOR) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return super.hasGravity
|
||||||
|
}
|
||||||
|
|
||||||
public override val isFlying: Boolean
|
public override val isFlying: Boolean
|
||||||
get() = !hasCollisions || gamemode == Gamemodes.CREATIVE
|
get() = !hasCollisions || gamemode == Gamemodes.CREATIVE
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user