Skip to content

Commit

Permalink
Update to fix config for sounds and trees not generating.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Nov 24, 2024
1 parent 7928712 commit 690ac3c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
23 changes: 17 additions & 6 deletions src/main/java/world/bentobox/twerk/listeners/TreeGrowListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.bukkit.Bukkit;
Expand All @@ -20,6 +21,7 @@
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -32,6 +34,7 @@

import com.google.common.base.Enums;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.util.Util;
Expand Down Expand Up @@ -132,18 +135,16 @@ protected void growTree(Block b) {
}
if (SAPLING_TO_TREE_TYPE.containsKey(t)) {
TreeType type = SAPLING_TO_TREE_TYPE.getOrDefault(b.getType(), TreeType.TREE);
BentoBox.getInstance().logDebug("Setting " + b + " mat " + t + " to air");
b.setType(Material.AIR);

if (b.getWorld().generateTree(b.getLocation(), RAND, type,
bs -> bs.getType() != Material.DIRT
&& (Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld())
|| addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent()))) {
if (b.getWorld().generateTree(b.getLocation(), RAND, type, (Predicate<BlockState>) this::checkPlace)) {
if (addon.getSettings().isEffectsEnabled()) {
showSparkles(b);
}
if (addon.getSettings().isSoundsEnabled()) {
b.getWorld().playSound(b.getLocation(), addon.getSettings().getSoundsGrowingSmallTreeSound(),
(float)addon.getSettings().getSoundsGrowingSmallTreeVolume(), (float)addon.getSettings().getSoundsGrowingSmallTreePitch());
(float) addon.getSettings().getSoundsGrowingSmallTreeVolume(),
(float) addon.getSettings().getSoundsGrowingSmallTreePitch());
}
} else {
// Tree generation failed, so reset block
Expand All @@ -152,6 +153,16 @@ protected void growTree(Block b) {
}
}

private Boolean checkPlace(BlockState bs) {
System.out.println("Not Dirt " + (bs.getType() != Material.DIRT));
System.out.println("Outside range flag set? " + Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld()));
System.out.println("Inside island? " + addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent());
System.out.println("Overall = " + (bs.getType() != Material.DIRT && (Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld())
|| addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent())));
return bs.getType() != Material.DIRT && (Flags.TREES_GROWING_OUTSIDE_RANGE.isSetForWorld(bs.getWorld())
|| addon.getIslands().getProtectedIslandAt(bs.getLocation()).isPresent());
}

protected boolean bigTreeSaplings(Block b) {
Material treeType = b.getType();
TreeType type = SAPLING_TO_BIG_TREE_TYPE.get(treeType);
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TwerkingForTrees configuration file. {$version}
#
#
# How many times the player must twerk before the tree start growing faster.
# If the player has not twerked enough, then the tree will not grow faster.
minimum-twerks: 4
Expand All @@ -17,21 +17,21 @@ sounds:
# Sound that plays when the player twerked enough for the sapling to start growing faster.
# Available sounds are the following:
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
sound: BLOCK_NOTE_BLOCK_BASS
sound: block.note_block.bass
volume: 1.0
pitch: 2.0
growing-small-tree:
# Sound that plays when a small tree (1x1) grows.
# Available sounds are the following:
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
sound: BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT
sound: block.bubble_column.upwards_ambient
volume: 1.0
pitch: 1.0
growing-big-tree:
# Sound that plays when a big tree (2x2) grows.
# Available sounds are the following:
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
sound: BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT
sound: block.bubble_column.upwards_ambient
volume: 1.0
pitch: 1.0
effects:
Expand Down

0 comments on commit 690ac3c

Please sign in to comment.