From f740e2e7665c3a2aecca1ca912755353e875ad4c Mon Sep 17 00:00:00 2001 From: Tec Date: Sun, 26 Apr 2020 00:30:34 +0200 Subject: Add hint only helpers for blocks --- .../mechanics/structure/StructureUtility.java | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'src/main/java') 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 IStructureElement error(){ return ERROR; + } /** + * Does not allow Block duplicates (with different meta) + */ + public static IStructureElement ofHintFlat(Map blocsMap,Block hintBlock,int hintMeta){ + if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement() { + @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 IStructureElement ofHint(Map> blocsMap,Block hintBlock,int hintMeta){ + if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){ + throw new IllegalArgumentException(); + } + for (Set value : blocsMap.values()) { + if(value.isEmpty()){ + throw new IllegalArgumentException(); + } + } + return new IStructureElement() { + @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 IStructureElement ofHint(Block block, int meta,Block hintBlock,int hintMeta){ + if(block==null || hintBlock==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement() { + @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 IStructureElement ofHint(Block block, int meta){ + return ofHint(block, meta,block,meta); } /** -- cgit