Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched to vanilla values to stop movement from flagging anticheats #112

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Physics (mcData, world) {

const physics = {
gravity: 0.08, // blocks/tick^2 https://minecraft.gamepedia.com/Entity#Motion_of_entities
airdrag: Math.fround(1 - 0.02), // actually (1 - drag)
airdrag: 0.9800000190734863, // actually (1 - drag)
yawSpeed: 3.0,
pitchSpeed: 3.0,
playerSpeed: 0.1,
Expand Down Expand Up @@ -457,6 +457,7 @@ function Physics (mcData, world) {

applyHeading(entity, strafe, forward, acceleration)
moveEntity(entity, world, vel.x, vel.y, vel.z)

vel.y *= inertia
vel.y -= (entity.isInWater ? physics.waterGravity : physics.lavaGravity) * gravityMultiplier
vel.x *= horizontalInertia
Expand Down Expand Up @@ -514,6 +515,7 @@ function Physics (mcData, world) {
if (entity.attributes && entity.attributes[physics.movementSpeedAttribute]) {
// Use server-side player attributes
playerSpeedAttribute = entity.attributes[physics.movementSpeedAttribute]
playerSpeedAttribute.value = 0.1
} else {
// Create an attribute if the player does not have it
playerSpeedAttribute = attribute.createAttributeValue(physics.playerSpeed)
Expand All @@ -533,7 +535,7 @@ function Physics (mcData, world) {
// Calculate what the speed is (0.1 if no modification)
const attributeSpeed = attribute.getAttributeValue(playerSpeedAttribute)
inertia = (blockSlipperiness[blockUnder.type] || physics.defaultSlipperiness) * 0.91
acceleration = attributeSpeed * (0.1627714 / (inertia * inertia * inertia))
acceleration = attributeSpeed * (0.16277136 / (inertia * inertia * inertia))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only actual change in this PR. The other changes have no effect, you can revert them. If there are errors in calculation, they are likely to be caused by 64-bit vs 32-bit float differences, and that's what Math.fround is supposed to fix.

if (acceleration < 0) acceleration = 0 // acceleration should not be negative
} else {
acceleration = physics.airborneAcceleration
Expand Down Expand Up @@ -690,7 +692,7 @@ function Physics (mcData, world) {
vel.y += 0.04
} else if (entity.onGround && entity.jumpTicks === 0) {
const blockBelow = world.getBlock(entity.pos.floored().offset(0, -0.5, 0))
vel.y = Math.fround(0.42) * ((blockBelow && blockBelow.type === honeyblockId) ? physics.honeyblockJumpSpeed : 1)
vel.y = 0.42 * ((blockBelow && blockBelow.type === honeyblockId) ? physics.honeyblockJumpSpeed : 1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (entity.jumpBoost > 0) {
vel.y += 0.1 * entity.jumpBoost
}
Expand Down
Loading