mirror of
https://github.com/songoda/UltimateTimber.git
synced 2025-01-23 07:51:26 +01:00
Bug fixing, global soil code
This commit is contained in:
parent
06b570c8c5
commit
f6a22966da
@ -6,9 +6,11 @@ import com.songoda.ultimatetimber.adapter.VersionAdapterType;
|
||||
import com.songoda.ultimatetimber.tree.FallingTreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlockSet;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlockType;
|
||||
import com.songoda.ultimatetimber.utils.Methods;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -20,6 +22,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class CurrentAdapter implements VersionAdapter {
|
||||
|
||||
@ -42,7 +45,9 @@ public class CurrentAdapter implements VersionAdapter {
|
||||
public Collection<ItemStack> getBlockDrops(ITreeBlock treeBlock) {
|
||||
if (treeBlock.getBlock() instanceof Block) {
|
||||
Block block = (Block)treeBlock.getBlock();
|
||||
return block.getDrops(); // TODO: Do this properly
|
||||
Set<ItemStack> drops = new HashSet<>();
|
||||
drops.add(new ItemStack(block.getType()));
|
||||
return drops; // TODO: Do this properly
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
@ -90,12 +95,16 @@ public class CurrentAdapter implements VersionAdapter {
|
||||
|
||||
@Override
|
||||
public void playFallingParticles(TreeBlockSet<Block> treeBlocks) {
|
||||
|
||||
for (ITreeBlock<Block> treeBlock : treeBlocks.getAllTreeBlocks()) {
|
||||
Location location = treeBlock.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||
location.getWorld().spawnParticle(Particle.BLOCK_DUST, location, 10, 0.25, 0.25, 0.25, treeBlock.getBlock().getBlockData());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playLandingParticles(FallingTreeBlock treeBlock) {
|
||||
|
||||
Location location = treeBlock.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||
location.getWorld().spawnParticle(Particle.BLOCK_CRACK, location, 10, 0.25, 0.25, 0.25, treeBlock.getBlock().getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TreeBlock implements ITreeBlock<Block> {
|
||||
|
||||
@ -31,4 +32,17 @@ public class TreeBlock implements ITreeBlock<Block> {
|
||||
return this.treeBlockType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.block, this.treeBlockType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof TreeBlock)) return false;
|
||||
if (o == this) return true;
|
||||
TreeBlock oTreeBlock = (TreeBlock)o;
|
||||
return oTreeBlock.block.equals(this.block) && oTreeBlock.treeBlockType.equals(this.treeBlockType);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,12 +33,11 @@ public abstract class TreeAnimation {
|
||||
/**
|
||||
* Replaces a given block with a new one
|
||||
*
|
||||
* @param treeDefinition The tree definition for the replacement
|
||||
* @param block The block to replace
|
||||
*/
|
||||
protected void replaceBlock(TreeDefinition treeDefinition, Block block) {
|
||||
protected void replaceBlock(Block block) {
|
||||
block.setType(Material.AIR);
|
||||
UltimateTimber.getInstance().getSaplingManager().replantSapling(treeDefinition, block.getLocation());
|
||||
UltimateTimber.getInstance().getSaplingManager().replantSapling(this.detectedTree.getTreeDefinition(), block.getLocation());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package com.songoda.ultimatetimber.animation;
|
||||
|
||||
import com.songoda.ultimatetimber.UltimateTimber;
|
||||
import com.songoda.ultimatetimber.adapter.VersionAdapter;
|
||||
import com.songoda.ultimatetimber.manager.ConfigurationManager;
|
||||
import com.songoda.ultimatetimber.manager.TreeDefinitionManager;
|
||||
import com.songoda.ultimatetimber.tree.DetectedTree;
|
||||
import com.songoda.ultimatetimber.tree.ITreeBlock;
|
||||
import com.songoda.ultimatetimber.tree.TreeBlockSet;
|
||||
@ -15,8 +19,18 @@ public class TreeAnimationNone extends TreeAnimation {
|
||||
|
||||
@Override
|
||||
public void playAnimation(Runnable whenFinished) {
|
||||
for (ITreeBlock<Block> treeBlock : this.detectedTree.getDetectedTreeBlocks().getAllTreeBlocks()) {
|
||||
TreeDefinitionManager treeDefinitionManager = UltimateTimber.getInstance().getTreeDefinitionManager();
|
||||
VersionAdapter versionAdapter = UltimateTimber.getInstance().getVersionAdapter();
|
||||
|
||||
if (ConfigurationManager.Setting.USE_CUSTOM_SOUNDS.getBoolean())
|
||||
versionAdapter.playFallingSound(this.detectedTree.getDetectedTreeBlocks());
|
||||
|
||||
if (ConfigurationManager.Setting.USE_CUSTOM_PARTICLES.getBoolean())
|
||||
versionAdapter.playFallingParticles(this.detectedTree.getDetectedTreeBlocks());
|
||||
|
||||
for (ITreeBlock<Block> treeBlock : this.detectedTree.getDetectedTreeBlocks().getAllTreeBlocks()) {
|
||||
treeDefinitionManager.dropTreeLoot(this.detectedTree.getTreeDefinition(), treeBlock, this.player);
|
||||
this.replaceBlock(treeBlock.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,35 +10,40 @@ import java.util.List;
|
||||
public class ConfigurationManager extends Manager {
|
||||
|
||||
public enum Setting {
|
||||
SERVER_TYPE,
|
||||
DISABLED_WORLDS,
|
||||
MAX_LOGS_PER_CHOP,
|
||||
LEAVES_REQUIRED_FOR_TREE,
|
||||
REALISTIC_TOOL_DAMAGE,
|
||||
PROTECT_TOOL,
|
||||
BREAK_ENTIRE_TREE_BASE,
|
||||
DESTROY_INITIATED_BLOCK,
|
||||
ONLY_DETECT_LOGS_UPWARDS,
|
||||
ONLY_TOPPLE_WHILE_SNEAKING,
|
||||
ALLOW_CREATIVE_MODE,
|
||||
REQUIRE_CHOP_PERMISSION,
|
||||
IGNORE_REQUIRED_TOOLS,
|
||||
REPLANT_SAPLINGS,
|
||||
REPLANT_SAPLINGS_COOLDOWN,
|
||||
FALLING_BLOCKS_REPLANT_SAPLINGS,
|
||||
FALLING_BLOCKS_REPLANT_SAPLINGS_CHANCE,
|
||||
FALLING_BLOCKS_DEAL_DAMAGE,
|
||||
FALLING_BLOCK_DAMAGE,
|
||||
ADD_ITEMS_TO_INVENTORY,
|
||||
USE_CUSTOM_SOUNDS,
|
||||
USE_CUSTOM_PARTICLES,
|
||||
BONUS_LOOT_MULTIPLIER,
|
||||
TREE_ANIMATION_TYPE,
|
||||
SCATTER_TREE_BLOCKS_ON_GROUND,
|
||||
MIX_ALL_TREE_TYPES;
|
||||
SERVER_TYPE(SettingType.STRING),
|
||||
DISABLED_WORLDS(SettingType.STRING_LIST),
|
||||
MAX_LOGS_PER_CHOP(SettingType.INT),
|
||||
LEAVES_REQUIRED_FOR_TREE(SettingType.INT),
|
||||
REALISTIC_TOOL_DAMAGE(SettingType.BOOLEAN),
|
||||
PROTECT_TOOL(SettingType.BOOLEAN),
|
||||
BREAK_ENTIRE_TREE_BASE(SettingType.BOOLEAN),
|
||||
DESTROY_INITIATED_BLOCK(SettingType.BOOLEAN),
|
||||
ONLY_DETECT_LOGS_UPWARDS(SettingType.BOOLEAN),
|
||||
ONLY_TOPPLE_WHILE_SNEAKING(SettingType.BOOLEAN),
|
||||
ALLOW_CREATIVE_MODE(SettingType.BOOLEAN),
|
||||
REQUIRE_CHOP_PERMISSION(SettingType.BOOLEAN),
|
||||
IGNORE_REQUIRED_TOOLS(SettingType.BOOLEAN),
|
||||
REPLANT_SAPLINGS(SettingType.BOOLEAN),
|
||||
REPLANT_SAPLINGS_COOLDOWN(SettingType.INT),
|
||||
FALLING_BLOCKS_REPLANT_SAPLINGS(SettingType.BOOLEAN),
|
||||
FALLING_BLOCKS_REPLANT_SAPLINGS_CHANCE(SettingType.DOUBLE),
|
||||
FALLING_BLOCKS_DEAL_DAMAGE(SettingType.BOOLEAN),
|
||||
FALLING_BLOCK_DAMAGE(SettingType.INT),
|
||||
ADD_ITEMS_TO_INVENTORY(SettingType.BOOLEAN),
|
||||
USE_CUSTOM_SOUNDS(SettingType.BOOLEAN),
|
||||
USE_CUSTOM_PARTICLES(SettingType.BOOLEAN),
|
||||
BONUS_LOOT_MULTIPLIER(SettingType.DOUBLE),
|
||||
TREE_ANIMATION_TYPE(SettingType.STRING),
|
||||
SCATTER_TREE_BLOCKS_ON_GROUND(SettingType.BOOLEAN),
|
||||
MIX_ALL_TREE_TYPES(SettingType.BOOLEAN);
|
||||
|
||||
private SettingType settingType;
|
||||
private Object value = null;
|
||||
|
||||
Setting(SettingType settingType) {
|
||||
this.settingType = settingType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the setting as a boolean
|
||||
*
|
||||
@ -101,8 +106,26 @@ public class ConfigurationManager extends Manager {
|
||||
* Loads the value from the config and caches it if it isn't set yet
|
||||
*/
|
||||
private void loadValue() {
|
||||
if (this.value == null)
|
||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().get(this.getNameAsKey());
|
||||
if (this.value != null)
|
||||
return;
|
||||
|
||||
switch (this.settingType) {
|
||||
case BOOLEAN:
|
||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getBoolean(this.getNameAsKey());
|
||||
break;
|
||||
case INT:
|
||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getInt(this.getNameAsKey());
|
||||
break;
|
||||
case DOUBLE:
|
||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getDouble(this.getNameAsKey());
|
||||
break;
|
||||
case STRING:
|
||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getString(this.getNameAsKey());
|
||||
break;
|
||||
case STRING_LIST:
|
||||
this.value = UltimateTimber.getInstance().getConfigurationManager().getConfig().getStringList(this.getNameAsKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,6 +138,14 @@ public class ConfigurationManager extends Manager {
|
||||
}
|
||||
}
|
||||
|
||||
private enum SettingType {
|
||||
BOOLEAN,
|
||||
INT,
|
||||
DOUBLE,
|
||||
STRING,
|
||||
STRING_LIST
|
||||
}
|
||||
|
||||
private YamlConfiguration configuration;
|
||||
|
||||
public ConfigurationManager(UltimateTimber ultimateTimber) {
|
||||
|
@ -73,13 +73,15 @@ public class SaplingManager extends Manager {
|
||||
* @param location The Location to plant the sapling
|
||||
*/
|
||||
private void internalReplant(TreeDefinition treeDefinition, Location location) {
|
||||
TreeDefinitionManager treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager();
|
||||
|
||||
Block block = location.getBlock();
|
||||
if (!block.getType().equals(Material.AIR))
|
||||
return;
|
||||
|
||||
Block blockBelow = block.getRelative(BlockFace.DOWN);
|
||||
boolean isValidSoil = false;
|
||||
for (IBlockData soilBlockData : treeDefinition.getPlantableSoilBlockData()) {
|
||||
for (IBlockData soilBlockData : treeDefinitionManager.getPlantableSoilBlockData(treeDefinition)) {
|
||||
if (soilBlockData.isSimilar(blockBelow)) {
|
||||
isValidSoil = true;
|
||||
break;
|
||||
|
@ -24,6 +24,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<ItemStack> globalRequiredTools;
|
||||
|
||||
@ -31,6 +32,7 @@ public class TreeDefinitionManager extends Manager {
|
||||
super(ultimateTimber);
|
||||
this.random = new Random();
|
||||
this.treeDefinitions = new HashSet<>();
|
||||
this.globalPlantableSoil = new HashSet<>();
|
||||
this.globalLogLoot = new HashSet<>();
|
||||
this.globalLeafLoot = new HashSet<>();
|
||||
this.globalRequiredTools = new HashSet<>();
|
||||
@ -39,6 +41,7 @@ public class TreeDefinitionManager extends Manager {
|
||||
@Override
|
||||
public void reload() {
|
||||
this.treeDefinitions.clear();
|
||||
this.globalPlantableSoil.clear();
|
||||
this.globalLogLoot.clear();
|
||||
this.globalLeafLoot.clear();
|
||||
this.globalRequiredTools.clear();
|
||||
@ -81,12 +84,14 @@ public class TreeDefinitionManager extends Manager {
|
||||
dropOriginalLeaf = tree.getBoolean("drop-original-leaf");
|
||||
|
||||
ConfigurationSection logLootSection = tree.getConfigurationSection("log-loot");
|
||||
for (String lootKey : logLootSection.getKeys(false))
|
||||
logLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LOG, logLootSection.getConfigurationSection(lootKey)));
|
||||
if (logLootSection != null)
|
||||
for (String lootKey : logLootSection.getKeys(false))
|
||||
logLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LOG, logLootSection.getConfigurationSection(lootKey)));
|
||||
|
||||
ConfigurationSection leafLootSection = tree.getConfigurationSection("leaf-loot");
|
||||
for (String lootKey : leafLootSection.getKeys(false))
|
||||
leafLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LEAF, leafLootSection.getConfigurationSection(lootKey)));
|
||||
if (leafLootSection != null)
|
||||
for (String lootKey : leafLootSection.getKeys(false))
|
||||
leafLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LEAF, leafLootSection.getConfigurationSection(lootKey)));
|
||||
|
||||
for (String itemStackString : tree.getStringList("required-tools"))
|
||||
requiredTools.add(versionAdapter.parseItemStackFromString(itemStackString));
|
||||
@ -94,15 +99,21 @@ public class TreeDefinitionManager extends Manager {
|
||||
this.treeDefinitions.add(new TreeDefinition(key, logBlockData, leafBlockData, saplingBlockData, plantableSoilBlockData, maxLeafDistanceFromLog, detectLeavesDiagonally, dropOriginalLog, dropOriginalLeaf, logLoot, leafLoot, requiredTools));
|
||||
}
|
||||
|
||||
// Load global plantable soil
|
||||
for (String blockDataString : config.getStringList("global-plantable-soil"))
|
||||
this.globalPlantableSoil.add(versionAdapter.parseBlockDataFromString(blockDataString));
|
||||
|
||||
// Load global log drops
|
||||
ConfigurationSection logSection = config.getConfigurationSection("global-log-loot");
|
||||
for (String lootKey : logSection.getKeys(false))
|
||||
this.globalLogLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LOG, logSection.getConfigurationSection(lootKey)));
|
||||
if (logSection != null)
|
||||
for (String lootKey : logSection.getKeys(false))
|
||||
this.globalLogLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LOG, logSection.getConfigurationSection(lootKey)));
|
||||
|
||||
// Load global leaf drops
|
||||
ConfigurationSection leafSection = config.getConfigurationSection("global-leaf-loot");
|
||||
for (String lootKey : leafSection.getKeys(false))
|
||||
this.globalLeafLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LEAF, leafSection.getConfigurationSection(lootKey)));
|
||||
if (leafSection != null)
|
||||
for (String lootKey : leafSection.getKeys(false))
|
||||
this.globalLeafLoot.add(this.getTreeLootEntry(versionAdapter, TreeBlockType.LEAF, leafSection.getConfigurationSection(lootKey)));
|
||||
|
||||
// Load global tools
|
||||
for (String itemStackString : config.getStringList("global-required-tools"))
|
||||
@ -133,8 +144,6 @@ public class TreeDefinitionManager extends Manager {
|
||||
* @return A Set of TreeDefinitions narrowed down
|
||||
*/
|
||||
public Set<TreeDefinition> narrowTreeDefinition(Set<TreeDefinition> possibleTreeDefinitions, Block block, TreeBlockType treeBlockType) {
|
||||
VersionAdapter versionAdapter = this.ultimateTimber.getVersionAdapter();
|
||||
|
||||
Set<TreeDefinition> matchingTreeDefinitions = new HashSet<>();
|
||||
switch (treeBlockType) {
|
||||
case LOG:
|
||||
@ -173,10 +182,10 @@ public class TreeDefinitionManager extends Manager {
|
||||
return true;
|
||||
for (TreeDefinition treeDefinition : this.treeDefinitions)
|
||||
for (ItemStack requiredTool : treeDefinition.getRequiredTools())
|
||||
if (requiredTool.isSimilar(tool))
|
||||
if (requiredTool.getType().equals(tool.getType()))
|
||||
return true;
|
||||
for (ItemStack requiredTool : this.globalRequiredTools)
|
||||
if (requiredTool.isSimilar(tool))
|
||||
if (requiredTool.getType().equals(tool.getType()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -192,10 +201,10 @@ public class TreeDefinitionManager extends Manager {
|
||||
if (ConfigurationManager.Setting.IGNORE_REQUIRED_TOOLS.getBoolean())
|
||||
return true;
|
||||
for (ItemStack requiredTool : treeDefinition.getRequiredTools())
|
||||
if (requiredTool.isSimilar(tool))
|
||||
if (requiredTool.getType().equals(tool.getType()))
|
||||
return true;
|
||||
for (ItemStack requiredTool : this.globalRequiredTools)
|
||||
if (requiredTool.isSimilar(tool))
|
||||
if (requiredTool.getType().equals(tool.getType()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@ -237,7 +246,7 @@ public class TreeDefinitionManager extends Manager {
|
||||
// Roll the dice
|
||||
double bonusLootMultiplier = ConfigurationManager.Setting.BONUS_LOOT_MULTIPLIER.getDouble();
|
||||
for (TreeLoot treeLoot : toTry) {
|
||||
double chance = hasBonusChance ? treeLoot.getChance() * 2 : treeLoot.getChance();
|
||||
double chance = hasBonusChance ? treeLoot.getChance() * bonusLootMultiplier : treeLoot.getChance();
|
||||
if (this.random.nextDouble() > chance / 100)
|
||||
continue;
|
||||
if (treeLoot.hasItem())
|
||||
@ -266,6 +275,19 @@ public class TreeDefinitionManager extends Manager {
|
||||
.replace("%zPos", treeBlock.getLocation().getBlockZ() + ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all possible plantable soil blocks for the given tree definition
|
||||
*
|
||||
* @param treeDefinition The TreeDefinition
|
||||
* @return A Set of IBlockData of plantable soil
|
||||
*/
|
||||
public Set<IBlockData> getPlantableSoilBlockData(TreeDefinition treeDefinition) {
|
||||
Set<IBlockData> plantableSoilBlockData = new HashSet<>();
|
||||
plantableSoilBlockData.addAll(treeDefinition.getPlantableSoilBlockData());
|
||||
plantableSoilBlockData.addAll(this.globalPlantableSoil);
|
||||
return plantableSoilBlockData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a TreeLoot entry from a ConfigurationSection
|
||||
*
|
||||
@ -275,7 +297,8 @@ public class TreeDefinitionManager extends Manager {
|
||||
* @return A TreeLoot entry from the section
|
||||
*/
|
||||
private TreeLoot getTreeLootEntry(VersionAdapter versionAdapter, TreeBlockType treeBlockType, ConfigurationSection configurationSection) {
|
||||
ItemStack item = versionAdapter.parseItemStackFromString(configurationSection.getString("material"));
|
||||
String material = configurationSection.getString("material");
|
||||
ItemStack item = material != null ? versionAdapter.parseItemStackFromString(material) : null;
|
||||
String command = configurationSection.getString("command");
|
||||
double chance = configurationSection.getDouble("chance");
|
||||
return new TreeLoot(treeBlockType, item, command, chance);
|
||||
|
@ -71,6 +71,8 @@ public class TreeDetectionManager extends Manager {
|
||||
* @return A DetectedTree if one was found, otherwise null
|
||||
*/
|
||||
public DetectedTree detectTree(Block initialBlock) {
|
||||
TreeDefinitionManager treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager();
|
||||
|
||||
TreeBlock initialTreeBlock = new TreeBlock(initialBlock, TreeBlockType.LOG);
|
||||
TreeBlockSet<Block> detectedTreeBlocks = new TreeBlockSet<>(initialTreeBlock);
|
||||
Set<TreeDefinition> possibleTreeDefinitions = this.treeDefinitionManager.getTreeDefinitionsForLog(initialBlock);
|
||||
@ -85,7 +87,7 @@ public class TreeDetectionManager extends Manager {
|
||||
while (this.isValidLogType(possibleTreeDefinitions, (targetBlock = targetBlock.getRelative(BlockFace.UP)))) {
|
||||
TreeBlock treeBlock = new TreeBlock(targetBlock, TreeBlockType.LOG);
|
||||
detectedTreeBlocks.add(treeBlock);
|
||||
trunkBlocks.add(initialBlock);
|
||||
trunkBlocks.add(targetBlock);
|
||||
possibleTreeDefinitions.retainAll(this.treeDefinitionManager.narrowTreeDefinition(possibleTreeDefinitions, targetBlock, TreeBlockType.LOG));
|
||||
}
|
||||
|
||||
@ -102,6 +104,7 @@ public class TreeDetectionManager extends Manager {
|
||||
for (ITreeBlock<Block> branchBlock : branchBlocks)
|
||||
this.recursiveLeafSearch(possibleTreeDefinitions, detectedTreeBlocks, branchBlock.getBlock(), 1);
|
||||
|
||||
// Use the first tree definition in the set
|
||||
TreeDefinition actualTreeDefinition = possibleTreeDefinitions.iterator().next();
|
||||
|
||||
// Trees need at least a certain number of leaves
|
||||
@ -119,7 +122,7 @@ public class TreeDetectionManager extends Manager {
|
||||
Block blockBelow = block.getRelative(BlockFace.DOWN);
|
||||
boolean blockBelowIsLog = this.isValidLogType(possibleTreeDefinitions, blockBelow);
|
||||
boolean blockBelowIsSoil = false;
|
||||
for (IBlockData blockData : actualTreeDefinition.getPlantableSoilBlockData()) {
|
||||
for (IBlockData blockData : treeDefinitionManager.getPlantableSoilBlockData(actualTreeDefinition)) {
|
||||
if (blockData.isSimilar(blockBelow)) {
|
||||
blockBelowIsSoil = true;
|
||||
break;
|
||||
@ -135,7 +138,6 @@ public class TreeDetectionManager extends Manager {
|
||||
if (this.destroyBaseLog)
|
||||
detectedTreeBlocks.remove(initialTreeBlock);
|
||||
|
||||
// Use the first tree definition in the set
|
||||
return new DetectedTree(actualTreeDefinition, detectedTreeBlocks);
|
||||
}
|
||||
|
||||
@ -156,7 +158,7 @@ public class TreeDetectionManager extends Manager {
|
||||
TreeBlock treeBlock = new TreeBlock(targetBlock, TreeBlockType.LOG);
|
||||
if (this.isValidLogType(treeDefinitions, targetBlock) && !treeBlocks.contains(treeBlock)) {
|
||||
treeBlocks.add(treeBlock);
|
||||
treeDefinitions.retainAll(this.treeDefinitionManager.narrowTreeDefinition(treeDefinitions, block, TreeBlockType.LOG));
|
||||
treeDefinitions.retainAll(this.treeDefinitionManager.narrowTreeDefinition(treeDefinitions, targetBlock, TreeBlockType.LOG));
|
||||
if (!this.onlyBreakLogsUpwards || targetBlock.getLocation().getBlockY() > startingBlockY)
|
||||
this.recursiveBranchSearch(treeDefinitions, treeBlocks, targetBlock, startingBlockY);
|
||||
}
|
||||
@ -184,7 +186,7 @@ public class TreeDetectionManager extends Manager {
|
||||
if (this.isValidLeafType(treeDefinitions, targetBlock)) {
|
||||
if (!treeBlocks.contains(treeBlock) && !this.doesLeafBorderInvalidLog(treeDefinitions, treeBlocks, targetBlock)) {
|
||||
treeBlocks.add(treeBlock);
|
||||
treeDefinitions.retainAll(this.treeDefinitionManager.narrowTreeDefinition(treeDefinitions, block, TreeBlockType.LEAF));
|
||||
treeDefinitions.retainAll(this.treeDefinitionManager.narrowTreeDefinition(treeDefinitions, targetBlock, TreeBlockType.LEAF));
|
||||
}
|
||||
this.recursiveLeafSearch(treeDefinitions, treeBlocks, targetBlock, distanceFromLog + 1);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ trees:
|
||||
- BIRCH_WOOD
|
||||
- STRIPPED_BIRCH_WOOD
|
||||
leaves:
|
||||
- SPRUCE_BIRCH
|
||||
- BIRCH_LEAVES
|
||||
sapling: BIRCH_SAPLING
|
||||
plantable-soil: []
|
||||
max-leaf-distance-from-log: 4
|
||||
|
Loading…
Reference in New Issue
Block a user