Skip to content

Commit

Permalink
[BumbleLlamaEntity] Fixed #13.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJoeMama committed Mar 21, 2022
1 parent e3ca84f commit 38b26fb
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ public boolean startRiding(Entity entity, boolean force) {
return false;
}

@Override
public boolean startRiding(Entity entity) {
return false;
}

@Override
public boolean canBeControlledByRider() {
return false;
Expand Down Expand Up @@ -98,16 +93,8 @@ public void tick() {
BlockState stateForBoneMeal = this.world.getBlockState(down);

boolean isChosen = this.random.nextInt(384) == 0;

if (isChosen && !this.world.isClient &&
stateForBoneMeal.getBlock() instanceof Fertilizable fertilizable &&
PosUtilities.checkForNoVelocity(this.getVelocity())) {
fertilizable.grow((ServerWorld) this.world, this.random, down, stateForBoneMeal);

((ServerWorld) this.world).spawnParticles(
ParticleTypes.HAPPY_VILLAGER, this.getX(), this.getY(), this.getZ(),
20, 2d, 2d, 2d, 0.0d
);
if (isChosen && world.isClient) {
this.tryGrowPlant(down, stateForBoneMeal);
}
}

Expand Down Expand Up @@ -142,4 +129,18 @@ protected BumbleLlamaEntity getChild() {
return ModEntityTypes.BUMBLE_LLAMA.create(this.world);
}

private void tryGrowPlant(BlockPos down, @NotNull BlockState stateForBoneMeal) {
if (stateForBoneMeal.getBlock() instanceof Fertilizable fertilizable &&
PosUtilities.checkForNoVelocity(this.getVelocity()) &&
fertilizable.isFertilizable(world, down, stateForBoneMeal, world.isClient) &&
fertilizable.canGrow(world, this.getRandom(), down, stateForBoneMeal)) {
fertilizable.grow((ServerWorld) this.world, this.random, down, stateForBoneMeal);

((ServerWorld) this.world).spawnParticles(
ParticleTypes.HAPPY_VILLAGER, this.getX(), this.getY(), this.getZ(),
20, 2d, 2d, 2d, 0.0d
);
}
}

}

0 comments on commit 38b26fb

Please sign in to comment.