Skip to content

Commit

Permalink
fix crash with demeter modifying getAvailableMoisture() (closes #7)
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Dec 12, 2019
1 parent dff5b91 commit 868e249
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
curseforge_id = 320887
changelog_url = https://github.com/NerdHubMC/Sweed/blob/master/changelog.md
release_type = release
mod_version = 1.1.0-SNAPSHOT
mod_version = 1.1.1-SNAPSHOT

minecraft_version = 1.15
yarn_mappings=1.15+build.2
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/nerdhub/sweed/block/SweedBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,21 @@ protected ItemConvertible getSeedsItem() {
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
SweedConfig config = Sweed.getConfig();
if(random.nextInt(3) != 0) {
if(random.nextDouble() < 0.66D) {
int age = this.getAge(state);
if(age < this.getMaxAge()) {
if(world.getLightLevel(pos, 0) >= 9 && random.nextInt((int) (25.0F / getAvailableMoisture(this, world, pos)) + 1) == 0) {
if(age == this.getMaxAge() - 1 && config.aggressiveSpread && random.nextDouble() < config.spreadChance) {
float moisture = Math.max(getAvailableMoisture(this, world, pos), 1.0F);
if(world.getLightLevel(pos, 0) >= 9 && random.nextInt((int) (25.0F / moisture) + 1) == 0) {
if(age == this.getMaxAge() - 1 && !config.aggressiveSpread && random.nextDouble() < config.spreadChance) {
if(this.spread(world, pos, random) > 0) {
return;
}
}
world.setBlockState(pos, this.withAge(age + 1), 2);
}
}
else {
if(!config.aggressiveSpread && random.nextDouble() < config.spreadChance) {
this.spread(world, pos, random);
}
else if(config.aggressiveSpread && random.nextDouble() < config.spreadChance) {
this.spread(world, pos, random);
}
}
}
Expand Down

0 comments on commit 868e249

Please sign in to comment.