aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorTec <daniel112092@gmail.com>2020-04-26 00:30:34 +0200
committerTec <daniel112092@gmail.com>2020-04-26 00:30:34 +0200
commitf740e2e7665c3a2aecca1ca912755353e875ad4c (patch)
treed2d78a70a8ed1b81375bd9b56786c6599cb336f9 /src/main/java/com
parent5ab4d194f5e46ab71b07eac45b3980b80411864a (diff)
downloadGT5-Unofficial-f740e2e7665c3a2aecca1ca912755353e875ad4c.tar.gz
GT5-Unofficial-f740e2e7665c3a2aecca1ca912755353e875ad4c.tar.bz2
GT5-Unofficial-f740e2e7665c3a2aecca1ca912755353e875ad4c.zip
Add hint only helpers for blocks
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java
index fe7a0d7510..6feb07196d 100644
--- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java
+++ b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java
@@ -76,6 +76,73 @@ public class StructureUtility {
@SuppressWarnings("unchecked")
public static <T> IStructureElement<T> error(){
return ERROR;
+ } /**
+ * Does not allow Block duplicates (with different meta)
+ */
+ public static <T> IStructureElement<T> ofHintFlat(Map<Block, Integer> blocsMap,Block hintBlock,int hintMeta){
+ if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){
+ throw new IllegalArgumentException();
+ }
+ return new IStructureElement<T>() {
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ return blocsMap.getOrDefault(world.getBlock(x, y, z), -1) == world.getBlockMetadata(x, y, z);
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z) {
+ TecTech.proxy.hint_particle(world,x,y,z,hintBlock,hintMeta);
+ return true;
+ }
+ };
+ }
+
+ /**
+ * Allows block duplicates (with different meta)
+ */
+ public static <T> IStructureElement<T> ofHint(Map<Block, Set<Integer>> blocsMap,Block hintBlock,int hintMeta){
+ if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){
+ throw new IllegalArgumentException();
+ }
+ for (Set<Integer> value : blocsMap.values()) {
+ if(value.isEmpty()){
+ throw new IllegalArgumentException();
+ }
+ }
+ return new IStructureElement<T>() {
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ return blocsMap.getOrDefault(world.getBlock(x, y, z), Collections.emptySet()).contains(world.getBlockMetadata(x, y, z));
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z) {
+ TecTech.proxy.hint_particle(world,x,y,z,hintBlock,hintMeta);
+ return true;
+ }
+ };
+ }
+
+ public static <T> IStructureElement<T> ofHint(Block block, int meta,Block hintBlock,int hintMeta){
+ if(block==null || hintBlock==null){
+ throw new IllegalArgumentException();
+ }
+ return new IStructureElement<T>() {
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ return block == world.getBlock(x, y, z) && meta == world.getBlockMetadata(x, y, z);
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z) {
+ TecTech.proxy.hint_particle(world,x,y,z,hintBlock,hintMeta);
+ return true;
+ }
+ };
+ }
+
+ public static <T> IStructureElement<T> ofHint(Block block, int meta){
+ return ofHint(block, meta,block,meta);
}
/**