Added fragile blocks.

This commit is contained in:
Brianna 2021-04-05 09:07:03 -05:00
parent 5833234da4
commit c234f202bc
3 changed files with 17 additions and 2 deletions

View File

@ -483,4 +483,11 @@ required-axe:
- 'DURABILITY:3'
- 'DIG_SPEED:5'
# NBT to identify the axe by.
nbt: 'ultimatetimber_axe'
nbt: 'ultimatetimber_axe'
# If a tree lands on these blocks they will be destroyed.
fragile-blocks:
- GLASS
- ICE
- PACKED_ICE
- BLUE_ICE

View File

@ -46,7 +46,8 @@ public class ConfigurationManager extends Manager {
HOOKS_APPLY_EXTRA_DROPS(SettingType.BOOLEAN),
HOOKS_REQUIRE_ABILITY_ACTIVE(SettingType.BOOLEAN),
TREE_ANIMATION_TYPE(SettingType.STRING),
SCATTER_TREE_BLOCKS_ON_GROUND(SettingType.BOOLEAN);
SCATTER_TREE_BLOCKS_ON_GROUND(SettingType.BOOLEAN),
FRAGILE_BLOCKS(SettingType.STRING_LIST);
private SettingType settingType;
private Object value = null;

View File

@ -1,5 +1,6 @@
package com.songoda.ultimatetimber.manager;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.ultimatetimber.UltimateTimber;
import com.songoda.ultimatetimber.animation.TreeAnimation;
import com.songoda.ultimatetimber.animation.TreeAnimationCrumble;
@ -155,6 +156,12 @@ public class TreeAnimationManager extends Manager implements Listener, Runnable
if (useCustomSound)
SoundUtils.playLandingSound(treeBlock);
Block block = treeBlock.getLocation().subtract(0, 1, 0).getBlock();
if (ConfigurationManager.Setting.FRAGILE_BLOCKS.getStringList().contains(block.getType().toString())) {
block.getWorld().dropItemNaturally(block.getLocation(), CompatibleMaterial.getMaterial(block).getItem());
block.breakNaturally();
}
treeDefinitionManager.dropTreeLoot(treeDefinition, treeBlock, treeAnimation.getPlayer(), treeAnimation.hasSilkTouch(), false);
this.plugin.getSaplingManager().replantSaplingWithChance(treeDefinition, treeBlock);
treeAnimation.getFallingTreeBlocks().remove(treeBlock);