mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-21 12:32:29 +00:00
- Added MFR support for 1.6.4
- Improved API for blocks - NBT compound tags with non-identifier keys should now be output properly
This commit is contained in:
1 parent
e644398505
commit
e2b4f50dfc
97 files changed
+5307
-216
No files matched your search
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import minetweaker.util.ArrayUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class BlockPatternOr implements IBlockPattern {
|
||||
private final IBlockPattern[] elements;
|
||||
|
||||
public BlockPatternOr(IBlockPattern[] elements) {
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
public BlockPatternOr(IBlockPattern a, IBlockPattern b) {
|
||||
this.elements = new IBlockPattern[] {a, b};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IBlock> getBlocks() {
|
||||
List<IBlock> blocks = new ArrayList<IBlock>();
|
||||
for (IBlockPattern pattern : elements) {
|
||||
blocks.addAll(pattern.getBlocks());
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(IBlock block) {
|
||||
for (IBlockPattern pattern : elements) {
|
||||
if (pattern.matches(block))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (IBlockPattern pattern : elements) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
result.append(" | ");
|
||||
}
|
||||
|
||||
result.append(pattern.getDisplayName());
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockPattern or(IBlockPattern pattern) {
|
||||
return new BlockPatternOr(ArrayUtil.append(elements, pattern));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user