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

Add placement of chorus flower and plant, eating of chorus fruit #582

Merged
merged 3 commits into from Oct 29, 2017

Conversation

Projects
3 participants
@kaenganxt
Member

kaenganxt commented Oct 27, 2017

This pull request implements the chorus plant items/blocks.

  1. Chorus fruit
    The chorus fruit is edible and teleports the player to a random location as described in the Minecraft Wiki. The location check currently doesn't check for the bounding box of the player to be empty, but rather centers the location and checks for two air blocks.

  2. Chorus flower/plant
    Implement placing restrictions and drops for the chorus flower and plant blocks.
    This does not include dropping the plant if certain conditions are met.

for (int i = 0; i < 16; i++) { //16 attempts: +/- 8 blocks in every direction
Location attempt = player.getLocation();
double deltaX = Math.random() * 16 - 8;

This comment has been minimized.

@mastercoms

mastercoms Oct 28, 2017

Member

Use ThreadLocalRandom.current().nextDouble() instead of Math.random()

if (yCoord > world.getHighestBlockYAt(loc)) {
yCoord = world.getHighestBlockYAt(loc) + 1;
}
boolean found = false;

This comment has been minimized.

@mastercoms

mastercoms Oct 28, 2017

Member

What is this loop for? Getting the highest y block should give you a coordinate with enough space for the player, as all blocks above the highest block are air.

This comment has been minimized.

@kaenganxt

kaenganxt Oct 28, 2017

Member

The y coordinate is randomly generated and may be under the ground (or the player eats underground). Vanilla then selects the next possible location lying under the selected target. So the final target is never above the selected random location.

@momothereal momothereal added this to Review in 2017Q4 Oct 28, 2017

@momothereal momothereal merged commit 65bcb98 into GlowstoneMC:master Oct 29, 2017

2 checks passed

ci/circleci Your tests passed on CircleCI!
Details
license/cla Contributor License Agreement is signed.
Details

@momothereal momothereal moved this from Review to Completed in 2017Q4 Oct 29, 2017

@momothereal

This comment has been minimized.

Member

momothereal commented Oct 29, 2017

Thank you for your contribution!

@kaenganxt kaenganxt deleted the kaenganxt:chorus branch Dec 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment