aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorTec <daniel112092@gmail.com>2020-04-26 08:25:24 +0200
committerTec <daniel112092@gmail.com>2020-04-26 08:25:24 +0200
commit0c35badc49defc7bd7f76f763aa0a86bd9e7be64 (patch)
tree87365680a77ad65bcb5e6c95fa6fbbef2552d5a7 /src/main/java/com
parent93bca910f733b60d8151e4e619b27a1e585811ed (diff)
downloadGT5-Unofficial-0c35badc49defc7bd7f76f763aa0a86bd9e7be64.tar.gz
GT5-Unofficial-0c35badc49defc7bd7f76f763aa0a86bd9e7be64.tar.bz2
GT5-Unofficial-0c35badc49defc7bd7f76f763aa0a86bd9e7be64.zip
Add helper method for on check pass
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java47
-rw-r--r--src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java6
2 files changed, 50 insertions, 3 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 3d13ca86e2..e0e94a00eb 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
@@ -12,6 +12,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.*;
+import java.util.function.Consumer;
import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sHintCasingsTT;
@@ -76,7 +77,9 @@ 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){
@@ -145,6 +148,24 @@ public class StructureUtility {
return ofHint(block, meta,block,meta);
}
+ public static <T> IStructureElement<T> ofHintAdder(IBlockAdder<T> iBlockAdder,Block hintBlock,int hintMeta){
+ if(iBlockAdder==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 iBlockAdder.apply(t,world.getBlock(x, y, z), 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;
+ }
+ };
+ }
+
/**
* Does not allow Block duplicates (with different meta)
*/
@@ -256,6 +277,7 @@ public class StructureUtility {
};
}
+
public static <T> IStructureElement<T> ofTileAdder(ITileAdder<T> iTileAdder,Block hintBlock,int hintMeta){
if(iTileAdder==null ||hintBlock==null){
throw new IllegalArgumentException();
@@ -294,6 +316,29 @@ public class StructureUtility {
};
}
+ public static <T> IStructureElement<T> onCheckPass(Consumer<T> onCheckPass, IStructureElement<T> element){
+ return new IStructureElement<T>() {
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ boolean check = element.check(t, world, x, y, z);
+ if(check){
+ onCheckPass.accept(t);
+ }
+ return check;
+ }
+
+ @Override
+ public boolean placeBlock(T t, World world, int x, int y, int z) {
+ return element.placeBlock(t, world, x, y, z);
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z) {
+ return element.spawnHint(t, world, x, y, z);
+ }
+ };
+ }
+
@SuppressWarnings("unchecked")
public static <T> IStructureNavigate<T> step(Vec3Impl step){
if(step==null || step.get0()<0 || step.get1()<0 || step.get2()<0){
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java
index 1381c1b0f7..b65fcda229 100644
--- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java
+++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java
@@ -47,9 +47,10 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo
.addElement('0', ofBlock(sBlockCasings1,15))
.addElement('1', ofElementChain(
ofHatchAdder(GT_MetaTileEntity_EM_transformer::addEnergyIOToMachineList,textureOffset,sHintCasingsTT,0),
- ofBlock(sBlockCasingsTT,0)
+ onCheckPass(t->t.casingCount++,ofBlock(sBlockCasingsTT,0))
))
.build();
+ private int casingCount=0;
@Override
public IStructureDefinition<GT_MetaTileEntity_EM_transformer> getStructure_EM() {
@@ -86,7 +87,8 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo
@Override
public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) {
- return structureCheck_EM("main", 1, 1, 0);
+ casingCount=0;
+ return structureCheck_EM("main", 1, 1, 0) && casingCount>=5;
}
@Override