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:
@@ -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<>();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user