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

Entity data mining #9

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

4everTheOne
Copy link
Contributor

@4everTheOne 4everTheOne commented Sep 1, 2024

This PR adds the ability to automatically mine entity data from the source code. This PR is related with MockBukkit/MockBukkit#1101.

This implementation extracts:

  • Entity eye height
  • Entity height
  • Entity width
  • Entity scale
  • Entity base damage
  • Entity states

jsonObject.add("angry", camelSitting);
}

// TODO: Player - Sneaking, Gliding, Swimming, Sleeping
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic for Player is missing:

  • Sneaking
  • Gliding
  • Swimming
  • Sleeping

Copy link
Collaborator

@Thorinwasher Thorinwasher left a comment

Choose a reason for hiding this comment

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

I will look into sneaking/sleeping/swimming states for the data generation. Here's mostly a question

Comment on lines 29 to 39
BigDecimal normalWidth = BigDecimal.valueOf(mojangEntityType.getWidth());
BigDecimal normalHeight = BigDecimal.valueOf(mojangEntityType.getHeight());
BigDecimal normalEyeHeight = BigDecimal.valueOf(mojangEntityType.getDimensions().eyeHeight());

BigDecimal babyWidth = normalWidth.multiply(scale);
BigDecimal babyHeight = normalHeight.multiply(scale);
BigDecimal babyEyeHeight = BigDecimal.ZERO;
if (BigDecimal.ZERO.compareTo(normalHeight) != 0)
{
babyEyeHeight = babyHeight.multiply(normalEyeHeight).divide(normalHeight, RoundingMode.HALF_UP);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you convert from float to big decimal and then back to double. From my knowledge this should be fine by just converting directly from double, if theres a reason behind this? Floating point precission?

Copy link
Contributor Author

@4everTheOne 4everTheOne Sep 2, 2024

Choose a reason for hiding this comment

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

It's mostly related with the precision in the divisions and multiplication. Because when i attempted to do the maths with the double, the values were off by a significant margin. And when copying the generated files to the mockbukkit project it would replace the correct values with the "bad values".

@4everTheOne 4everTheOne marked this pull request as ready for review December 8, 2024 22:10
@4everTheOne
Copy link
Contributor Author

It's now ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants