Skip to content

Commit

Permalink
Getting a number of exceptions in the grow tree event, so wrapping to…
Browse files Browse the repository at this point in the history
… figure out what is going on.
  • Loading branch information
ProgrammerDan committed May 14, 2017
1 parent 701b88b commit b6d94cf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.untamedears</groupId>
<artifactId>RealisticBiomes</artifactId>
<packaging>jar</packaging>
<version>1.3.0</version>
<version>1.3.1</version>
<name>RealisticBiomes</name>
<url>https://github.com/Civcraft/RealisticBiomes</url>

Expand Down
47 changes: 26 additions & 21 deletions src/com/untamedears/realisticbiomes/persist/BlockGrower.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,33 @@ public boolean generateTree(Block block, float growth, TreeType type) {
}
}

StructureGrowDelegate sgd = new StructureGrowDelegate(((CraftWorld) block.getWorld()).getHandle());
if (block.getWorld().generateTree(block.getLocation(), type, sgd)) {

// Call wrapper event.
RealisticBiomes.plugin.getServer().getPluginManager().callEvent(new RealisticBiomesStructureGrowEvent(
block.getLocation(), type, false, null, sgd.getBlocks()));
for (BlockState state : sgd.getBlocks()) {
// Since we're using the delegate, we need to force the update ourselves.
state.update(true, false);
}

// remove affected 2x2 saplings
for (int i = 1; i < states.size(); i++) {
plantManager.removePlant(states.get(i).getBlock());
}
return false;
} else {
RealisticBiomes.doLog(Level.FINER, "generateTree reset data: " + states.size());
for (BlockState state: states) {
state.update(true, false);
try {
StructureGrowDelegate sgd = new StructureGrowDelegate(((CraftWorld) block.getWorld()).getHandle());
if (block.getWorld().generateTree(block.getLocation(), type, sgd)) {

// Call wrapper event.
RealisticBiomes.plugin.getServer().getPluginManager().callEvent(new RealisticBiomesStructureGrowEvent(
block.getLocation(), type, false, null, sgd.getBlocks()));
for (BlockState state : sgd.getBlocks()) {
// Since we're using the delegate, we need to force the update ourselves.
state.update(true, false);
}

// remove affected 2x2 saplings
for (int i = 1; i < states.size(); i++) {
plantManager.removePlant(states.get(i).getBlock());
}
return false;
} else {
RealisticBiomes.doLog(Level.FINER, "generateTree reset data: " + states.size());
for (BlockState state: states) {
state.update(true, false);
}
return true;
}
return true;
} catch (Exception e) {
RealisticBiomes.LOG.log(Level.SEVERE, "generateTree has failed", e);
return false; // we don't know what happened.
}
}

Expand Down

0 comments on commit b6d94cf

Please sign in to comment.