mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-15 02:15:34 -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!")
|
||||
}
|
||||
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
|
||||
get() = entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_SILENT)
|
||||
|
||||
@EntityMetaDataFunction(name = "Has no gravity")
|
||||
val hasNoGravity: Boolean
|
||||
get() = entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_NO_GRAVITY)
|
||||
@EntityMetaDataFunction(name = "Has gravity")
|
||||
open val hasGravity: Boolean
|
||||
get() = !entityMetaData.sets.getBoolean(EntityMetaDataFields.ENTITY_NO_GRAVITY)
|
||||
|
||||
@get:EntityMetaDataFunction(name = "Pose")
|
||||
val pose: Poses?
|
||||
@ -275,7 +275,7 @@ abstract class Entity(
|
||||
val newVelocity = Vec3(velocity)
|
||||
val oldVelocity = Vec3(velocity)
|
||||
val deltaTime = deltaMillis.toFloat() / 1000.0f
|
||||
if (! hasNoGravity && !isFlying) {
|
||||
if (hasGravity && !isFlying) {
|
||||
newVelocity.y -= ProtocolDefinition.GRAVITY * deltaTime
|
||||
}
|
||||
newVelocity *= 0.25f.pow(deltaTime) // apply
|
||||
|
@ -48,6 +48,14 @@ class PlayerEntity(
|
||||
override val hasCollisions: Boolean
|
||||
get() = gamemode != Gamemodes.SPECTATOR
|
||||
|
||||
override val hasGravity: Boolean
|
||||
get() {
|
||||
if (gamemode == Gamemodes.SPECTATOR) {
|
||||
return false
|
||||
}
|
||||
return super.hasGravity
|
||||
}
|
||||
|
||||
public override val isFlying: Boolean
|
||||
get() = !hasCollisions || gamemode == Gamemodes.CREATIVE
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user