From 0f5cbab6552dfbd514f3183afd4b855f3d1ccb9d Mon Sep 17 00:00:00 2001 From: Tec Date: Mon, 27 Apr 2020 18:01:15 +0200 Subject: Addmore util --- .../tectech/loader/ConstructableLoader.java | 8 +- .../mechanics/structure/StructureUtility.java | 98 ++++++++++++++++++---- 2 files changed, 88 insertions(+), 18 deletions(-) (limited to 'src/main/java/com') diff --git a/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java b/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java index 537bbf8cca..4e1a2eff75 100644 --- a/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java @@ -11,7 +11,7 @@ import net.minecraft.util.EnumChatFormatting; import static com.github.technus.tectech.mechanics.constructable.IMultiblockInfoContainer.registerMetaClass; import static com.github.technus.tectech.mechanics.structure.StructureUtility.ofBlock; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.ofHintOnly; +import static com.github.technus.tectech.mechanics.structure.StructureUtility.ofHint; import static gregtech.api.GregTech_API.sBlockCasings1; public class ConstructableLoader implements Runnable { @@ -28,9 +28,9 @@ public class ConstructableLoader implements Runnable { {"000","\"\"\"","\"\"\""," ",}, }) .addElement('0', ofBlock(sBlockCasings1,11)) - .addElement('\"', ofHintOnly(3)) - .addElement('!', ofHintOnly(2)) - .addElement(' ', ofHintOnly(1)) + .addElement('\"', ofHint(3)) + .addElement('!', ofHint(2)) + .addElement(' ', ofHint(1)) .build(); private final String[] desc=new String[]{ EnumChatFormatting.AQUA+"Hint Details:", 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 40b1793f93..b1be2071a7 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 @@ -85,7 +85,7 @@ public class StructureUtility { /** * Does not allow Block duplicates (with different meta) */ - public static IStructureElement ofHintFlat(Map blocsMap,Block hintBlock,int hintMeta){ + public static IStructureElement ofBlocksFlatHint(Map blocsMap,Block hintBlock,int hintMeta){ if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){ throw new IllegalArgumentException(); } @@ -106,7 +106,7 @@ public class StructureUtility { /** * Allows block duplicates (with different meta) */ - public static IStructureElement ofHint(Map> blocsMap,Block hintBlock,int hintMeta){ + public static IStructureElement ofBlocksMapHint(Map> blocsMap,Block hintBlock,int hintMeta){ if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){ throw new IllegalArgumentException(); } @@ -129,7 +129,7 @@ public class StructureUtility { }; } - public static IStructureElement ofHint(Block block, int meta,Block hintBlock,int hintMeta){ + public static IStructureElement ofBlockHint(Block block, int meta,Block hintBlock,int hintMeta){ if(block==null || hintBlock==null){ throw new IllegalArgumentException(); } @@ -147,11 +147,11 @@ public class StructureUtility { }; } - public static IStructureElement ofHint(Block block, int meta){ - return ofHint(block, meta,block,meta); + public static IStructureElement ofBlockHint(Block block, int meta){ + return ofBlockHint(block, meta,block,meta); } - public static IStructureElement ofHintOnly(int dots){ + public static IStructureElement ofHint(int dots){ int meta=dots-1; return new IStructureElement() { @Override @@ -167,7 +167,7 @@ public class StructureUtility { }; } - public static IStructureElement ofHintAdder(IBlockAdder iBlockAdder, Block hintBlock, int hintMeta){ + public static IStructureElement ofBlockAdderHint(IBlockAdder iBlockAdder, Block hintBlock, int hintMeta){ if(iBlockAdder==null ||hintBlock==null){ throw new IllegalArgumentException(); } @@ -215,7 +215,7 @@ public class StructureUtility { /** * Allows block duplicates (with different meta) */ - public static IStructureElement ofBlocks(Map> blocsMap,Block hintBlock,int hintMeta){ + public static IStructureElement ofBlocskMap(Map> blocsMap,Block hintBlock,int hintMeta){ if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){ throw new IllegalArgumentException(); } @@ -296,7 +296,6 @@ public class StructureUtility { }; } - public static IStructureElement ofTileAdder(ITileAdder iTileAdder, Block hintBlock, int hintMeta){ if(iTileAdder==null ||hintBlock==null){ throw new IllegalArgumentException(); @@ -316,6 +315,52 @@ public class StructureUtility { }; } + public static IStructureElement ofHatchAdder(IHatchAdder iHatchAdder, Short textureIndex, int dots){ + int meta=dots-1; + if(iHatchAdder==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply(t,(IGregTechTileEntity) tileEntity, textureIndex); + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z) { + TecTech.proxy.hint_particle(world,x,y,z,sHintCasingsTT,meta); + return true; + } + }; + } + + public static IStructureElement ofHatchAdder(IHatchAdder iHatchAdder, Short textureIndex, int dots, Block placeCasing,int placeCasingMeta){ + int meta=dots-1; + if(iHatchAdder==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply(t,(IGregTechTileEntity) tileEntity, textureIndex); + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z) { + TecTech.proxy.hint_particle(world,x,y,z,sHintCasingsTT,meta); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z) { + world.setBlock(x,y,z,placeCasing,placeCasingMeta,2); + return true; + } + }; + } + public static IStructureElement ofHatchAdder(IHatchAdder iHatchAdder, Short textureIndex, Block hintBlock, int hintMeta){ if(iHatchAdder==null ||hintBlock==null){ throw new IllegalArgumentException(); @@ -335,6 +380,31 @@ public class StructureUtility { }; } + public static IStructureElement ofHatchAdder(IHatchAdder iHatchAdder, Short textureIndex, Block hintBlock, int hintMeta, Block placeCasing,int placeCasingMeta){ + if(iHatchAdder==null ||hintBlock==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply(t,(IGregTechTileEntity) tileEntity, textureIndex); + } + + @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; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z) { + world.setBlock(x,y,z,placeCasing,placeCasingMeta,2); + return true; + } + }; + } + public static IStructureElement onElementPass(Consumer onCheckPass, IStructureElement element){ return new IStructureElement() { @Override @@ -381,8 +451,12 @@ public class StructureUtility { }; } + public static IStructureNavigate step(int a,int b, int c){ + return step(new Vec3Impl(a,b,c)); + } + @SuppressWarnings("unchecked") - static IStructureNavigate step(Vec3Impl step){ + public static IStructureNavigate step(Vec3Impl step){ if(step==null || step.get0()<0 || step.get1()<0 || step.get2()<0){ throw new IllegalArgumentException(); } @@ -397,10 +471,6 @@ public class StructureUtility { }); } - static IStructureNavigate step(int a,int b, int c){ - return step(new Vec3Impl(a,b,c)); - } - private static IStructureNavigate stepA(int a,int b, int c){ return new IStructureNavigate() { @Override -- cgit