diff options
43 files changed, 894 insertions, 88 deletions
diff --git a/build.properties b/build.properties index 23cc1df20d..967029ecdf 100644 --- a/build.properties +++ b/build.properties @@ -11,4 +11,4 @@ cofhcore.version=[1.7.10]3.0.3-303-dev cofhlib.cf=2246/918 cofhlib.version=[1.7.10]1.0.3-175-dev -yamcore.version=0.5.70
\ No newline at end of file +yamcore.version=0.5.74
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/CommonValues.java b/src/main/java/com/github/technus/tectech/CommonValues.java index d16b1fd18c..66ce2cde3d 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/CommonValues.java +++ b/src/main/java/com/github/technus/tectech/CommonValues.java @@ -1,4 +1,4 @@ -package com.github.technus.tectech.elementalMatter; +package com.github.technus.tectech; import net.minecraft.util.EnumChatFormatting; diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index ca8f813959..8bfacc056f 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -1,6 +1,7 @@ package com.github.technus.tectech; import gregtech.api.GregTech_API; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; @@ -11,6 +12,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; @@ -41,12 +44,12 @@ public class Util { int horizontalOffset, int verticalOffset, int depthOffset, IGregTechTileEntity aBaseMetaTileEntity, boolean forceCheck) { - //TE Rotation - byte facing = aBaseMetaTileEntity.getFrontFacing(); World world=aBaseMetaTileEntity.getWorld(); if(world.isRemote)return false; + //TE Rotation + byte facing = aBaseMetaTileEntity.getFrontFacing(); - int x, y, z, a, b, c; + int x, y, z, a, b, c, pointer; //a,b,c - relative to block face! //x,y,z - relative to block position on map! //yPos - absolute height of checked block @@ -90,7 +93,7 @@ public class Util { return false; break; default: //check for block (countable) - int pointer = block - '0'; + pointer = block - '0'; //countable air -> net.minecraft.block.BlockAir if (world.getBlock(x, y, z) != blockType[pointer]) { if (TecTech.ModConfig.DEBUG_MODE) @@ -114,6 +117,116 @@ public class Util { return true; } + //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller + //This only checks for REGULAR BLOCKS! + public static boolean StructureCheckerAdvanced( + String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR-1 blocks + Block[] blockType,//use numbers 0-9 for casing types + byte[] blockMeta,//use numbers 0-9 for casing types + Method adder, + String[] addingMethods, + byte[] casingTextures, + Block[] blockTypeFallback,//use numbers 0-9 for casing types + byte[] blockMetaFallback,//use numbers 0-9 for casing types + int horizontalOffset, int verticalOffset, int depthOffset, + IGregTechTileEntity aBaseMetaTileEntity, + boolean forceCheck) { + World world=aBaseMetaTileEntity.getWorld(); + if(world.isRemote)return false; + //TE Rotation + byte facing = aBaseMetaTileEntity.getFrontFacing(); + + IGregTechTileEntity igt; + IMetaTileEntity imt=aBaseMetaTileEntity.getMetaTileEntity(); + + int x, y, z, a, b, c, pointer; + //a,b,c - relative to block face! + //x,y,z - relative to block position on map! + //yPos - absolute height of checked block + + //perform your duties + c = -depthOffset; + for (String[] _structure : structure) {//front to back + b = verticalOffset; + for (String __structure : _structure) {//top to bottom + a = -horizontalOffset; + for (char block : __structure.toCharArray()) {//left to right + if (block > '@') {//characters allow to skip check a-1 skip, b-2 skips etc. + a += block - '@'; + //} else if (block < '+') {//used to mark THINGS + // a++; + } else { + //get x y z from rotation + switch (facing) {//translation + case 4: x = aBaseMetaTileEntity.getXCoord()+c; z = aBaseMetaTileEntity.getZCoord()+a; y = aBaseMetaTileEntity.getYCoord()+b; break; + case 3: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()-c; y = aBaseMetaTileEntity.getYCoord()+b; break; + case 5: x = aBaseMetaTileEntity.getXCoord()-c; z = aBaseMetaTileEntity.getZCoord()-a; y = aBaseMetaTileEntity.getYCoord()+b; break; + case 2: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()+c; y = aBaseMetaTileEntity.getYCoord()+b; break; + //Things get odd if the block faces up or down... + case 1: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()+b; y = aBaseMetaTileEntity.getYCoord()-c; break;//similar to 3 + case 0: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()-b; y = aBaseMetaTileEntity.getYCoord()+c; break;//similar to 2 + default: return false; + } + + //that must be here since in some cases other axis (b,c) controls y + if(y<0 || y>=256) return false; + + //Check block + if (world.blockExists(x,y,z)) {//this actually checks if the chunk is loaded at this pos + switch (block) { + case '-'://must be air + if (world.getBlock(x, y, z).getMaterial() != Material.air) + return false; + break; + case '+'://must not be air + if (world.getBlock(x, y, z).getMaterial() == Material.air) + return false; + break; + default://check for block (countable) + if((pointer = block - '0') >= 0) { + //countable air -> net.minecraft.block.BlockAir + if (world.getBlock(x, y, z) != blockType[pointer]) { + if (TecTech.ModConfig.DEBUG_MODE) + TecTech.Logger.info("Struct-block-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + " " + blockType[pointer].getUnlocalizedName()); + return false; + } + if (world.getBlockMetadata(x, y, z) != blockMeta[pointer]) { + if (TecTech.ModConfig.DEBUG_MODE) + TecTech.Logger.info("Struct-meta-id-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlockMetadata(x, y, z) + " " + blockMeta[pointer]); + return false; + } + }else if((pointer = block - ' ') >= 0){ + igt=aBaseMetaTileEntity.getIGregTechTileEntity(x,y,z); + try { + if(igt==null || !(boolean) adder.invoke(imt,addingMethods[pointer],igt,casingTextures[pointer])){ + if (world.getBlock(x, y, z) != blockTypeFallback[pointer]) { + if (TecTech.ModConfig.DEBUG_MODE) + TecTech.Logger.info("Fallback-struct-block-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + " " + blockTypeFallback[pointer].getUnlocalizedName()); + return false; + } + if (world.getBlockMetadata(x, y, z) != blockMetaFallback[pointer]) { + if (TecTech.ModConfig.DEBUG_MODE) + TecTech.Logger.info("Fallback-Struct-meta-id-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlockMetadata(x, y, z) + " " + blockMetaFallback[pointer]); + return false; + } + } + }catch (InvocationTargetException | IllegalAccessException e){ + if(TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); + return false; + } + } + } + }else if (forceCheck) return false; + a++;//block in horizontal layer + } + } + b--;//horizontal layer + } + c++;//depth + } + return true; + } + public static boolean StructureBuilder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks Block[] blockType,//use numbers 0-9 for casing types byte[] blockMeta,//use numbers 0-9 for casing types @@ -295,11 +408,11 @@ public class Util { int meta=world.getBlockMetadata(x,y,z); if(a==0 && b==0 && c==0){ - line+='#'; + line+='+'; }else if(block.getMaterial()==Material.air){ line+='-'; }else if(block.hasTileEntity(meta)){ - line+='+'; + line+='*'; }else{ ItemStack stack=new ItemStack(block,1,meta); String str="?";//OH YEAH NPEs diff --git a/src/main/java/com/github/technus/tectech/dataFramework/quantumDataPacket.java b/src/main/java/com/github/technus/tectech/dataFramework/quantumDataPacket.java new file mode 100644 index 0000000000..aeb3314d06 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/dataFramework/quantumDataPacket.java @@ -0,0 +1,84 @@ +package com.github.technus.tectech.dataFramework; + +import com.github.technus.tectech.vec3pos; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.TreeSet; + +/** + * Created by Tec on 05.04.2017. + */ +public class quantumDataPacket { + public static byte maxHistory =64; + + public long computation=0; + public TreeSet<vec3pos> trace=new TreeSet<>(); + + public quantumDataPacket(long comp){ + computation=comp; + } + + public quantumDataPacket(vec3pos pos,long computation){ + this.computation=computation; + trace.add(pos); + } + + public quantumDataPacket(quantumDataPacket q,long computation){ + this.computation=computation; + trace.addAll(q.trace); + } + + public quantumDataPacket(quantumDataPacket q){ + this.computation=q.computation; + trace.addAll(q.trace); + } + + public quantumDataPacket(NBTTagCompound nbt){ + computation=nbt.getLong("qComputation"); + for(int i=0;i<nbt.getByte("qHistory");i++){ + trace.add(new vec3pos( + nbt.getInteger("qX"+i), + nbt.getShort("qY"+i), + nbt.getInteger("qZ"+i) + )); + } + } + + public NBTTagCompound toNbt(){ + NBTTagCompound nbt=new NBTTagCompound(); + nbt.setLong("qComputation",computation); + nbt.setByte("qHistory", (byte)trace.size()); + int i=0; + for(vec3pos v:trace){ + nbt.setInteger("qX"+i,v.x); + nbt.setShort("qY"+i,v.y); + nbt.setInteger("qZ"+i,v.z); + i++; + } + return nbt; + } + + public boolean contains(vec3pos v){ + return trace.contains(v); + } + + public boolean check(){ + return trace.size()<=maxHistory; + } + + public quantumDataPacket unifyTraceWith(quantumDataPacket p){ + trace.addAll(p.trace); + return check()?this:null; + } + + public quantumDataPacket unifyPacketWith(quantumDataPacket p){ + computation+=p.computation; + trace.addAll(p.trace); + return check()?this:null; + } + + public long computationIfNotConatined(vec3pos pos){ + if(trace.contains(pos))return 0; + return computation; + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/Machines.java b/src/main/java/com/github/technus/tectech/loader/Machines.java index f6604c9ebd..ff262ba4b7 100644 --- a/src/main/java/com/github/technus/tectech/loader/Machines.java +++ b/src/main/java/com/github/technus/tectech/loader/Machines.java @@ -205,6 +205,7 @@ public class Machines implements Runnable { UncertaintyX_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(15422, "hatch.certain.tier.10", "Uncertainty Resolver X", 10).getStackForm(1L)); dataIn_Hatch.set(new GT_MetaTileEntity_Hatch_InputData(15423, "hatch.datain.tier.08", "Optical Slave Connector", 8).getStackForm(1L)); dataOut_Hatch.set(new GT_MetaTileEntity_Hatch_OutputData(15424, "hatch.dataout.tier.08", "Optical Master Connector", 8).getStackForm(1L)); + rack_Hatch.set(new GT_MetaTileEntity_Hatch_Rack(15425,"hatch.rack.tier.08","Computer Rack",8,"4 Slot Rack").getStackForm(1L)); // =================================================================================================== // Pipes diff --git a/src/main/java/com/github/technus/tectech/loader/Recipes.java b/src/main/java/com/github/technus/tectech/loader/Recipes.java index 8a1a5da6f7..30424076cd 100644 --- a/src/main/java/com/github/technus/tectech/loader/Recipes.java +++ b/src/main/java/com/github/technus/tectech/loader/Recipes.java @@ -2,7 +2,10 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.elementalMatter.classes.cElementalPrimitive; import com.github.technus.tectech.elementalMatter.definitions.*; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Rack; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_computer; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_MultiblockBase_EM; /** * Created by danie_000 on 16.11.2016. @@ -30,6 +33,9 @@ public class Recipes implements Runnable { // Recipe init // =================================================================================================== + GT_MetaTileEntity_MultiblockBase_EM.run(); + GT_MetaTileEntity_Hatch_Rack.run(); + GT_MetaTileEntity_EM_computer.run(); GT_MetaTileEntity_EM_quantizer.run(); } } diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java index 33d4ba406c..d192a4a0ff 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -12,7 +12,7 @@ import static gregtech.api.enums.GT_Values.W; public enum CustomItemList implements IItemContainer { Machine_DebugWriter, - EMpipe,DATApipe, + EMpipe,DATApipe,rack_Hatch, eM_dynamomulti4_UV, eM_dynamomulti16_UV, eM_dynamomulti64_UV, eM_dynamomulti4_UHV, eM_dynamomulti16_UHV, eM_dynamomulti64_UHV, eM_dynamomulti4_UEV, eM_dynamomulti16_UEV, eM_dynamomulti64_UEV, diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugBuilder.java b/src/main/java/com/github/technus/tectech/thing/item/DebugBuilder.java index 87ce3cd921..cb085867e4 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/DebugBuilder.java +++ b/src/main/java/com/github/technus/tectech/thing/item/DebugBuilder.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.item; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.metaTileEntity.constructableTT; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java index 8c04558ed1..cefd90daec 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; import com.github.technus.tectech.elementalMatter.classes.tElementalException; import com.github.technus.tectech.elementalMatter.interfaces.iElementalInstanceContainer; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java index f8b9e46601..f0f2c30088 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.dataFramework.quantumDataPacket; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.machineTT; import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToDataPipe; import gregtech.api.enums.Dyes; @@ -16,7 +17,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; -import static com.github.technus.tectech.elementalMatter.CommonValues.moveAt; +import static com.github.technus.tectech.CommonValues.moveAt; import static gregtech.api.enums.Dyes.MACHINE_METAL; /** @@ -27,9 +28,9 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE private static Textures.BlockIcons.CustomIcon EM_D_ACTIVE; private static Textures.BlockIcons.CustomIcon EM_D_CONN; + public quantumDataPacket q; + public short id = -1; - public int data = 0; - public byte timeout=2; public GT_MetaTileEntity_Hatch_DataConnector(int aID, String aName, String aNameRegional, int aTier, String descr) { super(aID, aName, aNameRegional, aTier, 0, descr); @@ -61,24 +62,26 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setShort("eID", id); - aNBT.setInteger("eDATA",data); + aNBT.setTag("eDATA",q.toNbt()); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); id = aNBT.getShort("eID"); - data=aNBT.getInteger("eDATA"); + q=new quantumDataPacket(aNBT.getCompoundTag("eDATA")); } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { - if (moveAt == aTick % 20) { - if(timeout>0) timeout--; - else data=0; - moveAround(aBaseMetaTileEntity); - getBaseMetaTileEntity().setActive(data>0); + if (moveAt == aTick%20) { + if(q==null){ + getBaseMetaTileEntity().setActive(false); + } else { + getBaseMetaTileEntity().setActive(true); + moveAround(aBaseMetaTileEntity); + } } } } @@ -135,9 +138,13 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE public String[] getInfoData() { if (id > 0) return new String[]{ "ID: "+ EnumChatFormatting.AQUA +id, - "Computation: "+ EnumChatFormatting.AQUA +data + "Computation: "+ EnumChatFormatting.AQUA +(q!=null?q.computation:0), + "PacketHistory: "+EnumChatFormatting.RED +(q!=null?q.trace.size():0), + }; + return new String[]{ + "Computation: "+ EnumChatFormatting.AQUA +(q!=null?q.computation:0), + "PacketHistory: "+EnumChatFormatting.RED +(q!=null?q.trace.size():0), }; - return new String[]{"Computation: "+ EnumChatFormatting.AQUA +data}; } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java index c3a8c38a2f..8a06cbc6bc 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.machineTT; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java index 59e0285423..830d19ebfe 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTi |
