Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento authored Jan 14, 2024
2 parents 9657258 + a047279 commit 788582b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/java/world/bentobox/twerk/listeners/TreeGrowListener.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package world.bentobox.twerk.listeners;

import java.util.Arrays;

import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
Expand Down Expand Up @@ -170,6 +171,37 @@ protected void showSparkles(Block b) {
AROUND.stream().map(b::getRelative).map(Block::getLocation).forEach(x -> x.getWorld().playEffect(x, addon.getSettings().getEffectsTwerk(), 0));
}

protected boolean bigTreeSaplings(Block b) {
Material treeType = b.getType();
TreeType type = SAPLING_TO_BIG_TREE_TYPE.get(treeType);
for (List<BlockFace> q : QUADS) {
if (q.stream().map(b::getRelative).allMatch(c -> c.getType().equals(treeType))) {
// All the same sapling type found in this quad
q.stream().map(b::getRelative).forEach(c -> c.setType(Material.AIR));
// Get the tree planting location
Location l = b.getRelative(q.get(0)).getLocation();
if (b.getWorld().generateTree(l, type, new BlockChangeHandler(addon, b.getWorld()))) {
if (addon.getSettings().isEffectsEnabled()) {
showSparkles(b);
}
if (addon.getSettings().isSoundsEnabled()) {
b.getWorld().playSound(b.getLocation(), addon.getSettings().getSoundsGrowingBigTreeSound(),
(float)addon.getSettings().getSoundsGrowingBigTreeVolume(), (float)addon.getSettings().getSoundsGrowingBigTreePitch());
}
return true;
} else {
// Generation failed, reset saplings
q.stream().map(b::getRelative).forEach(c -> c.setType(treeType));
}
}
}
return false;
}

protected void showSparkles(Block b) {
AROUND.stream().map(b::getRelative).map(Block::getLocation).forEach(x -> x.getWorld().playEffect(x, addon.getSettings().getEffectsTwerk(), 0));
}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onTreeBreak(BlockBreakEvent e) {
plantedTrees.keySet().removeIf(e.getBlock()::equals);
Expand Down

0 comments on commit 788582b

Please sign in to comment.