9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 19:49:06 +00:00

Fix tree type size matcher

This commit is contained in:
Daniel Mills
2021-07-30 10:22:50 -04:00
parent b217162cad
commit cd3f9af232
3 changed files with 48 additions and 15 deletions

View File

@@ -36,6 +36,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.block.data.BlockData;
@EqualsAndHashCode()
@@ -214,6 +215,18 @@ public class IrisObjectPlacement {
private transient AtomicCache<TableCache> cache = new AtomicCache<>();
public boolean matches(IrisTreeSize size, TreeType type) {
for(IrisTree i : getTrees())
{
if(i.matches(size, type))
{
return true;
}
}
return false;
}
private static class TableCache {
final transient WeightedRandom<IrisLootTable> global = new WeightedRandom<>();
final transient KMap<Material, WeightedRandom<IrisLootTable>> basic = new KMap<>();

View File

@@ -50,4 +50,29 @@ public class IrisTree {
@Desc("If enabled, overrides trees of any size")
private boolean anySize;
public boolean matches(IrisTreeSize size, TreeType type) {
if(!matchesSize(size))
{
return false;
}
return matchesType(type);
}
private boolean matchesSize(IrisTreeSize size) {
for(IrisTreeSize i : getSizes())
{
if((i.getDepth() == size.getDepth() && i.getWidth() == size.getWidth()) || (i.getDepth() == size.getWidth() && i.getWidth() == size.getDepth()))
{
return true;
}
}
return false;
}
private boolean matchesType(TreeType type) {
return getTreeTypes().contains(type);
}
}