-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up anti-fly mitigation and patch elytra fireworks
- Loading branch information
Showing
6 changed files
with
55 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.puffy.util | ||
|
||
import net.minecraft.entity.effect.StatusEffect | ||
import net.minecraft.server.network.ServerPlayerEntity | ||
|
||
// https://minecraft.fandom.com/wiki/Levitation | ||
private const val LEVITATION_STATUS_ID = 25 | ||
// Likely, once the player's velocity reaches this threshold it's probably from a tnt jump or mod | ||
private const val FLIGHT_SPEED_THRESHOLD = 5 | ||
|
||
fun ServerPlayerEntity.isAllowedFlight(): Boolean { | ||
// Water internally is implemented as an alternative movement style which isn't walking or | ||
// flight, but a little in between. So this returns true for water to be safe | ||
|
||
return (this.abilities.flying || this.abilities.allowFlying) || | ||
this.isTouchingWater || | ||
this.isSubmergedInWater || | ||
this.isSwimming || | ||
this.isFallFlying || | ||
this.hasStatusEffect(StatusEffect.byRawId(LEVITATION_STATUS_ID)) || | ||
this.velocity.length() >= FLIGHT_SPEED_THRESHOLD || | ||
this.fallDistance > 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.puffy.util | ||
|
||
import net.minecraft.server.network.ServerPlayerEntity | ||
|
||
private const val Y_BIAS = 0.2 | ||
|
||
fun ServerPlayerEntity.isInAir(): Boolean { | ||
val world = this.entityWorld | ||
val boundingBox = this.boundingBox.expand(0.0, Y_BIAS, 0.0) | ||
|
||
val collidingBlocks = world.getBlockCollisions(this, boundingBox) | ||
val collidingEntities = | ||
world.getOtherEntities(this, boundingBox) { entity -> !entity.equals(this) } | ||
|
||
return !collidingBlocks.any() && !collidingEntities.any() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters