Package-level declarations

Types

Link copied to clipboard

Yes, this name sucks as SimulatedPlayerCache already exists, but I don't know a better name :/

Link copied to clipboard
class FallingPlayer(player: LocalPlayer, var x: Double, var y: Double, var z: Double, motionX: Double, motionY: Double, motionZ: Double, yRot: Float)
Link copied to clipboard
class LinearPositionExtrapolation(basePosition: Vec3, velocity: Vec3) : PositionExtrapolation

A utility class which assumes that the subject is moving at a specified speed.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun interface PositionExtrapolation

A utility which predicts the position of something in n ticks.

Link copied to clipboard
object RenderedEntities : Collection<LivingEntity> , EventListener

A readonly Collection containing all LivingEntity instances that meet the shouldBeShown condition.

Link copied to clipboard
class SimulatedArrow(val level: Level, var pos: Vec3, var velocity: Vec3, collideEntities: Boolean = true)
Link copied to clipboard
class SimulatedPlayer(player: Player, var input: SimulatedPlayer.SimulatedPlayerInput, var pos: Vec3, var deltaMovement: Vec3, var boundingBox: AABB, var yRot: Float, var xRot: Float, var isSprinting: Boolean, var fallDistance: Double, jumpTriggerTime: Int, jumping: Boolean, fallFlying: Boolean, var onGround: Boolean, var horizontalCollision: Boolean, verticalCollision: Boolean, wasTouchingWater: Boolean, isSwimming: Boolean, wasUnderwater: Boolean, fluidHeight: Object2DoubleMap<TagKey<Fluid>>, eyeFluidTags: HashSet<TagKey<Fluid>>) : PlayerSimulation
Link copied to clipboard
class SimulatedPlayerCache(simulatedPlayer: SimulatedPlayer)
Link copied to clipboard
data class SimulatedPlayerSnapshot(val pos: Vec3, val fallDistance: Double, val velocity: Vec3, val onGround: Boolean, val clipLedged: Boolean)
Link copied to clipboard
data class StrictInteractionResult(val hand: InteractionHand, val source: StrictInteractionSource, val result: InteractionResult) : Record

Strict means to 1:1 simulate net.minecraft.client.Minecraft.startUseItem logic: Try interact/useItemOn then useItem with each hand (main hand -> offhand).

Link copied to clipboard

If the effective hand (item) is offhand, the packets are doubled (main hand -> offhand).

Properties

Link copied to clipboard
val LocalPlayer.airTicks: Int
Link copied to clipboard
Link copied to clipboard
val LivingEntity.armorItems: Array<ItemStack>
Link copied to clipboard
val Entity.box: AABB
Link copied to clipboard
val LocalPlayer.direction: Float
Link copied to clipboard
val LivingEntity.handItems: Array<ItemStack>
Link copied to clipboard
val LocalPlayer.hasCooldown: Boolean

Check if the attack speed is below 1 tick. If so, we have a cooldown.

Link copied to clipboard
Link copied to clipboard
val LocalPlayer.immuneToMagmaBlocks: Boolean
Link copied to clipboard
val ClientInput.initial: Input
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val Entity.lastPos: Vec3
Link copied to clipboard
val LocalPlayer.lastRotation: Rotation
Link copied to clipboard
var ClientInput.movementForward: Float
Link copied to clipboard
var ClientInput.movementSideways: Float
Link copied to clipboard
val LocalPlayer.moving: Boolean
Link copied to clipboard
val Entity.netherPosition: Vec3
Link copied to clipboard
val LocalPlayer.onGroundTicks: Int
Link copied to clipboard
val Player.ping: Int
Link copied to clipboard
val Entity.rotation: Rotation
Link copied to clipboard
val ClientInput.untransformed: Input
Link copied to clipboard
val LivingEntity.wouldBlockHit: Boolean

Functions

Link copied to clipboard
fun LivingEntity.blockedByShield(source: DamageSource): Boolean
Link copied to clipboard
fun Entity.boxedDistanceTo(entity: Entity): Double

Allows to calculate the distance between the current entity and entity from the nearest corner of the bounding box

Link copied to clipboard
fun Position.cameraDistance(): Double
Link copied to clipboard
fun Position.cameraDistanceSq(): Double
Link copied to clipboard
fun LocalPlayer.canStep(height: Double = 1.0): Boolean

Check if the player can step up by height blocks.

Link copied to clipboard
inline fun Input.copy(forward: Boolean = this.forward, backward: Boolean = this.backward, left: Boolean = this.left, right: Boolean = this.right, jump: Boolean = this.jump, sneak: Boolean = this.shift, sprint: Boolean = this.sprint): Input
Link copied to clipboard
fun Entity.doesCollideAt(pos: Vec3 = player.position()): Boolean

Check if the entity box collides with any block in the world at the given pos.

Link copied to clipboard
fun Entity.doesNotCollideBelow(until: Double = -64.0): Boolean

Check if the entity collides with anything below his bounding box.

Link copied to clipboard
fun LivingEntity.getActualHealth(fromScoreboard: Boolean = true): Float

Sometimes the server does not publish the actual entity health with its metadata. This function incorporates other sources to get the actual value.

Link copied to clipboard
fun Entity.getBoundingBoxAt(pos: Vec3): AABB
Link copied to clipboard
fun LivingEntity.getDamageFromExplosion(pos: Vec3, power: Float = 6.0f, explosionRange: Float = power * 2f, damageDistance: Float = explosionRange * explosionRange, exclude: Array<BlockPos>? = null, include: BlockPos? = null, maxBlastResistance: Float? = null, entityBoundingBox: AABB? = null): Float

See ExplosionDamageCalculator.getEntityDamageAmount.

Link copied to clipboard
fun LivingEntity.getEffectiveDamage(source: DamageSource, damage: Float, ignoreShield: Boolean = false): Float

Applies armor, enchantments, effects, etc. to the damage and returns the damage that is actually applied. This function is so damn ugly that I turned off code smell analysis for it.

Link copied to clipboard
fun LivingEntity.getExplosionDamageFromEntity(entity: Entity): Float
Link copied to clipboard
fun LivingEntity.getExposureToExplosion(source: Vec3, exclude: Array<BlockPos>?, include: BlockPos?, maxBlastResistance: Float?, entityBoundingBox: AABB?): Float

Basically ServerExplosion.getSeenPercent but this method allows us to exclude blocks using exclude.

Link copied to clipboard
fun LocalPlayer.getFeetBlockPos(): BlockPos
Link copied to clipboard
fun getMovementDirectionOfInput(facingYaw: Float, input: DirectionalInput = DirectionalInput(player.input)): Float
Link copied to clipboard
fun LocalPlayer.getMovementDirectionOfInput(input: DirectionalInput = DirectionalInput(this.input)): Float
Link copied to clipboard
fun LivingEntity.hasHealthScoreboard(): Boolean
Link copied to clipboard
fun interactBlock(hitResult: BlockHitResult, hand: InteractionHand = InteractionHand.MAIN_HAND, swingMode: SwingMode = SwingMode.DO_NOT_HIDE): InteractionResult

Simulated net.minecraft.world.phys.HitResult.Type.BLOCK branch in vanilla No fallback MultiPlayerGameMode.useItem call

Link copied to clipboard
fun interactBlockLikeVanilla(hitResult: BlockHitResult, swingMode: SwingMode = SwingMode.DO_NOT_HIDE, rotation: Rotation = RotationManager.currentRotation ?: player.rotation): StrictInteractionResult?
Link copied to clipboard
fun interactEntity(entity: Entity, hitResult: EntityHitResult = EntityHitResult(entity), hand: InteractionHand = InteractionHand.MAIN_HAND, swingMode: SwingMode = SwingMode.DO_NOT_HIDE): InteractionResult?

Simulated net.minecraft.world.phys.HitResult.Type.ENTITY branch in vanilla No fallback MultiPlayerGameMode.useItem call

Link copied to clipboard
fun interactEntityLikeVanilla(entity: Entity, hitResult: EntityHitResult = EntityHitResult(entity), swingMode: SwingMode = SwingMode.DO_NOT_HIDE, rotation: Rotation = RotationManager.currentRotation ?: player.rotation): StrictInteractionResult?
Link copied to clipboard
fun Entity.interpolateCurrentPosition(tickDelta: Float): Vec3
Link copied to clipboard
fun Entity.interpolateCurrentRotation(tickDelta: Float): Rotation
Link copied to clipboard
fun LocalPlayer.isBurrowed(): Boolean
Link copied to clipboard
fun LocalPlayer.isCloseToEdge(directionalInput: DirectionalInput = DirectionalInput(this.input), distance: Double = 0.1, pos: Vec3 = this.position()): Boolean
Link copied to clipboard
fun LocalPlayer.isInHole(feetBlockPos: BlockPos = getFeetBlockPos()): Boolean
Link copied to clipboard
Link copied to clipboard
fun Entity.lastRenderPos(): Vec3
Link copied to clipboard
fun linePointDistanceSquared(l1: Vec3, l2: Vec3, p: Vec3): Double

Determines the squared distance between the line defined by l1 and l2 the point p

Link copied to clipboard
inline fun ClientInput.set(forward: Boolean = keyPresses.forward, backward: Boolean = keyPresses.backward, left: Boolean = keyPresses.left, right: Boolean = keyPresses.right, jump: Boolean = keyPresses.jump, sneak: Boolean = keyPresses.shift, sprint: Boolean = keyPresses.sprint)
Link copied to clipboard
inline fun LocalPlayer.setDeltaMovement(block: (Vec3) -> Vec3)
Link copied to clipboard
fun InteractionResult.shouldSwingHand(): Boolean
Link copied to clipboard
fun Entity.squareBoxedDistanceTo(entity: Entity, offsetPos: Vec3): Double
Link copied to clipboard
fun Entity.squaredBoxedDistanceTo(entity: Entity): Double
fun Entity.squaredBoxedDistanceTo(otherPos: Vec3): Double
Link copied to clipboard
fun straightLinePointDistanceSquared(s: Vec3, r: Vec3, p: Vec3): Double

Determines the squared distance between the straight light defined by the base vector s and the direction vector r the point p

Link copied to clipboard
fun useItem(hand: InteractionHand, yRot: Float = RotationManager.currentRotation?.yRot ?: player.yRot, xRot: Float = RotationManager.currentRotation?.xRot ?: player.xRot, swingMode: SwingMode = SwingMode.DO_NOT_HIDE): InteractionResult
Link copied to clipboard
fun useItemStrict(yRot: Float = RotationManager.currentRotation?.yRot ?: player.yRot, xRot: Float = RotationManager.currentRotation?.xRot ?: player.xRot, swingMode: SwingMode = SwingMode.DO_NOT_HIDE): StrictInteractionResult?
Link copied to clipboard
fun LocalPlayer.warp(pos: Vec3? = null, onGround: Boolean = false)
Link copied to clipboard
fun Vec3.withStrafe(speed: Double = horizontalDistance(), strength: Double = 1.0, input: DirectionalInput? = DirectionalInput(player.input), yaw: Float = player.getMovementDirectionOfInput(input ?: DirectionalInput(player.input))): Vec3
Link copied to clipboard
fun Player.wouldBeCloseToFallOff(position: Vec3): Boolean
Link copied to clipboard
fun Entity.wouldFallIntoVoid(pos: Vec3, voidLevel: Double = -64.0, safetyExpand: Double = 0.0): Boolean

Check if the entity is likely falling to the void based on the given position and bounding box.