Silk touch settings, loot double drops fix,
This commit is contained in:
parent
7d716fe62b
commit
cffdf696c3
|
@ -85,7 +85,7 @@ public class TreeAnimationDisintegrate extends TreeAnimation {
|
|||
|
||||
if (useCustomParticles)
|
||||
versionAdapter.playFallingParticles(td, treeBlock);
|
||||
treeDefinitionManager.dropTreeLoot(td, treeBlock, p, hst);
|
||||
treeDefinitionManager.dropTreeLoot(td, treeBlock, p, hst, false);
|
||||
TreeAnimationDisintegrate.this.replaceBlock((TreeBlock) treeBlock);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -29,8 +29,8 @@ public class TreeAnimationNone extends TreeAnimation {
|
|||
versionAdapter.playFallingParticles(this.detectedTree.getTreeDefinition(), treeBlock);
|
||||
|
||||
for (ITreeBlock<Block> treeBlock : this.detectedTree.getDetectedTreeBlocks().getAllTreeBlocks()) {
|
||||
treeDefinitionManager.dropTreeLoot(this.detectedTree.getTreeDefinition(), treeBlock, this.player, this.hasSilkTouch);
|
||||
this.replaceBlock((TreeBlock)treeBlock);
|
||||
treeDefinitionManager.dropTreeLoot(this.detectedTree.getTreeDefinition(), treeBlock, this.player, this.hasSilkTouch, false);
|
||||
this.replaceBlock((TreeBlock) treeBlock);
|
||||
}
|
||||
|
||||
whenFinished.run();
|
||||
|
|
|
@ -18,6 +18,8 @@ public class ConfigurationManager extends Manager {
|
|||
LEAVES_REQUIRED_FOR_TREE(SettingType.INT),
|
||||
REALISTIC_TOOL_DAMAGE(SettingType.BOOLEAN),
|
||||
PROTECT_TOOL(SettingType.BOOLEAN),
|
||||
APPLY_SILK_TOUCH(SettingType.BOOLEAN),
|
||||
APPLY_SILK_TOUCH_TOOL_DAMAGE(SettingType.BOOLEAN),
|
||||
ALWAYS_REPLANT_SAPLING(SettingType.BOOLEAN),
|
||||
BREAK_ENTIRE_TREE_BASE(SettingType.BOOLEAN),
|
||||
DESTROY_INITIATED_BLOCK(SettingType.BOOLEAN),
|
||||
|
|
|
@ -155,7 +155,7 @@ public class TreeAnimationManager extends Manager implements Listener, Runnable
|
|||
if (useCustomSound)
|
||||
versionAdapter.playLandingSound(treeBlock);
|
||||
|
||||
treeDefinitionManager.dropTreeLoot(treeDefinition, treeBlock, treeAnimation.getPlayer(), treeAnimation.hasSilkTouch());
|
||||
treeDefinitionManager.dropTreeLoot(treeDefinition, treeBlock, treeAnimation.getPlayer(), treeAnimation.hasSilkTouch(), false);
|
||||
this.ultimateTimber.getSaplingManager().replantSaplingWithChance(treeDefinition, treeBlock);
|
||||
treeAnimation.getFallingTreeBlocks().remove(treeBlock);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public class TreeAnimationManager extends Manager implements Listener, Runnable
|
|||
if (!event.getEntityType().equals(EntityType.FALLING_BLOCK))
|
||||
return;
|
||||
|
||||
FallingBlock fallingBlock = (FallingBlock)event.getEntity();
|
||||
FallingBlock fallingBlock = (FallingBlock) event.getEntity();
|
||||
if (!this.isBlockInAnimation(fallingBlock))
|
||||
return;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public class TreeDefinitionManager extends Manager {
|
|||
private final Random random;
|
||||
private Set<TreeDefinition> treeDefinitions;
|
||||
private Set<IBlockData> globalPlantableSoil;
|
||||
private Set<TreeLoot> globalLogLoot, globalLeafLoot;
|
||||
private Set<TreeLoot> globalLogLoot, globalLeafLoot, globalEntireTreeLoot;
|
||||
private Set<ItemStack> globalRequiredTools;
|
||||
|
||||
public TreeDefinitionManager(UltimateTimber ultimateTimber) {
|
||||
|
@ -36,6 +36,7 @@ public class TreeDefinitionManager extends Manager {
|
|||
this.globalPlantableSoil = new HashSet<>();
|
||||
this.globalLogLoot = new HashSet<>();
|
||||
this.globalLeafLoot = new HashSet<>();
|
||||
this.globalEntireTreeLoot = new HashSet<>();
|
||||
this.globalRequiredTools = new HashSet<>();
|
||||
}
|
||||
|
||||
|
@ -45,6 +46,7 @@ public class TreeDefinitionManager extends Manager {
|
|||
this.globalPlantableSoil.clear();
|
||||
this.globalLogLoot.clear();
|
||||
this.globalLeafLoot.clear();
|
||||
this.globalEntireTreeLoot.clear();
|
||||
this.globalRequiredTools.clear();
|
||||
|
||||
VersionAdapter versionAdapter = this.ultimateTimber.getVersionAdapter();
|
||||
|
@ -123,6 +125,12 @@ public class TreeDefinitionManager extends Manager {
|
|||
for (String lootKey : leafSection.getKeys(false))
|
||||
this.globalLeafLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LEAF, leafSection.getConfigurationSection(lootKey)));
|
||||
|
||||
// Load global entire tree drops
|
||||
ConfigurationSection entireTreeSection = config.getConfigurationSection("global-leaf-loot");
|
||||
if (entireTreeSection != null)
|
||||
for (String lootKey : entireTreeSection.getKeys(false))
|
||||
this.globalEntireTreeLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LEAF, entireTreeSection.getConfigurationSection(lootKey)));
|
||||
|
||||
// Load global tools
|
||||
for (String itemStackString : config.getStringList("global-required-tools"))
|
||||
this.globalRequiredTools.add(versionAdapter.parseItemStackFromString(itemStackString));
|
||||
|
@ -238,8 +246,11 @@ public class TreeDefinitionManager extends Manager {
|
|||
List<TreeLoot> toTry = new ArrayList<>();
|
||||
if (isForEntireTree) {
|
||||
toTry.addAll(treeDefinition.getEntireTreeLoot());
|
||||
toTry.addAll(this.globalEntireTreeLoot);
|
||||
} else {
|
||||
if (hasSilkTouch) {
|
||||
if (ConfigurationManager.Setting.APPLY_SILK_TOUCH.getBoolean() && hasSilkTouch) {
|
||||
if (hookManager.shouldApplyDoubleDropsHooks(player))
|
||||
lootedItems.addAll(versionAdapter.getBlockDrops(treeDefinition, treeBlock));
|
||||
lootedItems.addAll(versionAdapter.getBlockDrops(treeDefinition, treeBlock));
|
||||
} else {
|
||||
switch (treeBlock.getTreeBlockType()) {
|
||||
|
|
|
@ -6,10 +6,12 @@ import com.songoda.ultimatetimber.events.TreeFallEvent;
|
|||
import com.songoda.ultimatetimber.events.TreeFellEvent;
|
||||
import com.songoda.ultimatetimber.misc.OnlyToppleWhile;
|
||||
import com.songoda.ultimatetimber.tree.DetectedTree;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlockSet;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
@ -105,7 +107,7 @@ public class TreeFallManager extends Manager implements Listener {
|
|||
if (!treeDefinitionManager.isToolValidForTreeDefinition(detectedTree.getTreeDefinition(), tool))
|
||||
return;
|
||||
|
||||
int toolDamage = ConfigurationManager.Setting.REALISTIC_TOOL_DAMAGE.getBoolean() ? detectedTree.getDetectedTreeBlocks().getLogBlocks().size() : 1;
|
||||
int toolDamage = this.getToolDamage(detectedTree.getDetectedTreeBlocks(), tool.containsEnchantment(Enchantment.SILK_TOUCH));
|
||||
if (ConfigurationManager.Setting.PROTECT_TOOL.getBoolean() && !versionAdapter.hasEnoughDurability(tool, toolDamage))
|
||||
return;
|
||||
|
||||
|
@ -155,4 +157,15 @@ public class TreeFallManager extends Manager implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
private int getToolDamage(TreeBlockSet<Block> treeBlocks, boolean hasSilkTouch) {
|
||||
if (!ConfigurationManager.Setting.REALISTIC_TOOL_DAMAGE.getBoolean())
|
||||
return 1;
|
||||
|
||||
if (ConfigurationManager.Setting.APPLY_SILK_TOUCH_TOOL_DAMAGE.getBoolean() && hasSilkTouch) {
|
||||
return treeBlocks.size();
|
||||
} else {
|
||||
return treeBlocks.getLogBlocks().size();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,16 @@ realistic-tool-damage: true
|
|||
# Default: false
|
||||
protect-tool: false
|
||||
|
||||
# Use the silk touch enchantment if the tool has it
|
||||
# Logs and leaves will drop their original block 100% of the time
|
||||
# Default: true
|
||||
apply-silk-touch: true
|
||||
|
||||
# Damage the tool extra for each leaf block broken, this is vanilla behavior but can be disabled here
|
||||
# Note: Does nothing if realistic-tool-damage is false
|
||||
# Default: true
|
||||
apply-silk-touch-tool-damage: true
|
||||
|
||||
# Require the entire base of the tree to be broken before it topples
|
||||
# Default: false
|
||||
break-entire-tree-base: false
|
||||
|
|
|
@ -38,6 +38,16 @@ realistic-tool-damage: true
|
|||
# Default: false
|
||||
protect-tool: false
|
||||
|
||||
# Use the silk touch enchantment if the tool has it
|
||||
# Logs and leaves will drop their original block 100% of the time
|
||||
# Default: true
|
||||
apply-silk-touch: true
|
||||
|
||||
# Damage the tool extra for each leaf block broken, this is vanilla behavior but can be disabled here
|
||||
# Note: Does nothing if realistic-tool-damage is false
|
||||
# Default: true
|
||||
apply-silk-touch-tool-damage: true
|
||||
|
||||
# Require the entire base of the tree to be broken before it topples
|
||||
# Default: false
|
||||
break-entire-tree-base: false
|
||||
|
@ -353,7 +363,7 @@ global-log-loot:
|
|||
global-leaf-loot:
|
||||
0:
|
||||
material: GOLDEN_APPLE
|
||||
chance: 0.5
|
||||
chance: 0.1
|
||||
|
||||
# Custom entire tree loot that is available for all tree types
|
||||
# The loot will be dropped only one time for the entire tree
|
||||
|
|
Loading…
Reference in New Issue