diff options
author | Technus <daniel112092@gmail.com> | 2017-04-06 12:07:51 +0200 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2017-04-06 12:07:51 +0200 |
commit | 0f6ef8576dfd03b17b569be495f7944fd021356b (patch) | |
tree | 1e44e7d44fbf436d9260b7d0fcaecc58ce6db97e | |
parent | 36e581c2a243e4dc0371958f854459325ece9e55 (diff) | |
download | GT5-Unofficial-0f6ef8576dfd03b17b569be495f7944fd021356b.tar.gz GT5-Unofficial-0f6ef8576dfd03b17b569be495f7944fd021356b.tar.bz2 GT5-Unofficial-0f6ef8576dfd03b17b569be495f7944fd021356b.zip |
Some work on data packets, added ComputerRack, some work on switch,junction and computer multiblocks
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/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; 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; @@ -20,7 +20,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; -import static com.github.technus.tectech.elementalMatter.CommonValues.*; +import static com.github.technus.tectech.CommonValues.*; import static gregtech.api.enums.Dyes.MACHINE_METAL; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java index 87fdd24f3f..bfa44a9a74 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_EnergyMulti.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_InputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java index 7e3874279f..e42d6348ac 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java @@ -9,6 +9,8 @@ import gregtech.api.metatileentity.MetaTileEntity; * Created by danie_000 on 27.10.2016. */ public class GT_MetaTileEntity_Hatch_InputData extends GT_MetaTileEntity_Hatch_DataConnector { + public boolean delDelay = true; + public GT_MetaTileEntity_Hatch_InputData(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, "Data Input for Multiblocks"); } @@ -46,4 +48,10 @@ public class GT_MetaTileEntity_Hatch_InputData extends GT_MetaTileEntity_Hatch_D public iConnectsToDataPipe getNext(iConnectsToDataPipe source) { return null; } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + if(delDelay) delDelay =false; + else q=null; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java index 7b0149f910..7b3a8bae26 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.machineTT; import gregtech.api.enums.Dyes; import gregtech.api.enums.Textures; @@ -17,7 +17,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.EnumSkyBlock; -import static com.github.technus.tectech.elementalMatter.CommonValues.disperseAt; +import static com.github.technus.tectech.CommonValues.disperseAt; import static gregtech.api.enums.Dyes.MACHINE_METAL; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java index 4523e94434..5249c78678 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java @@ -51,12 +51,14 @@ public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_ int range=0; while((next=current.getNext(source))!=null && range++<1000){ if(next instanceof GT_MetaTileEntity_Hatch_InputData){ - ((GT_MetaTileEntity_Hatch_InputData) next).timeout=2; - ((GT_MetaTileEntity_Hatch_InputData) next).data=data; + ((GT_MetaTileEntity_Hatch_InputData) next).q=q; + ((GT_MetaTileEntity_Hatch_InputData) next).delDelay =true; + q=null; return; } source=current; current=next; } + q=null; } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java index c1f4471ba7..875329c5f1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.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 com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Param; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Param; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java new file mode 100644 index 0000000000..e606374792 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java @@ -0,0 +1,240 @@ +package com.github.technus.tectech.thing.metaTileEntity.hatch; + +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.thing.machineTT; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.gui.GT_Container_2by2; +import gregtech.api.gui.GT_GUIContainer_2by2; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; + +import java.util.TreeMap; + +import static com.github.technus.tectech.CommonValues.multiCheckAt; + +/** + * Created by Tec on 03.04.2017. + */ +public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implements machineTT { + private static Textures.BlockIcons.CustomIcon EM_R; + private static Textures.BlockIcons.CustomIcon EM_R_ACTIVE; + public int heat=0; + private float overclock=1; + private static TreeMap<String,component> componentBinds=new TreeMap<>(); + + public GT_MetaTileEntity_Hatch_Rack(int aID, String aName, String aNameRegional, int aTier, String descr) { + super(aID, aName, aNameRegional, aTier, 4, descr); + } + + public GT_MetaTileEntity_Hatch_Rack(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("eHeat",heat); + aNBT.setFloat("eOverclock",overclock); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + heat=aNBT.getInteger("eHeat"); + overclock=aNBT.getFloat("eOverclock"); + } + + @Override + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_R_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/EM_RACK_ACTIVE"); + EM_R = new Textures.BlockIcons.CustomIcon("iconsets/EM_RACK"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_R_ACTIVE)}; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(EM_R)}; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Rack(mName,mTier,mDescription,mTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing>=2; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if(aBaseMetaTileEntity.isActive() || heat>0) return false; + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if(aBaseMetaTileEntity.isActive() || heat>0) return false; + return aSide == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Computer Rack"); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + if(aBaseMetaTileEntity.isActive()) + aPlayer.addChatComponentMessage(new ChatComponentText("It is still active...")); + else if(heat>0) + aPlayer.addChatComponentMessage(new ChatComponentText("It is still warm...")); + else + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + + //TODO implement: glitches with OC, random component burning with OC + private int getComputationPower(float overclock,boolean heatProcess){ + float computation=0,heat=0; + for(ItemStack is:mInventory){ + if(is==null || is.stackSize!=1) continue; + component comp=componentBinds.get(is.getUnlocalizedName()); + if(comp==null) continue; + if(heatProcess){ + if(this.heat>comp.maxHeat){ + is.stackSize=0; + continue; + } + if(comp.subZero || this.heat>=0) + heat+=comp.heat>0?comp.heat*overclock*overclock:comp.heat; + } + computation+=comp.computation; + } + if(heatProcess){ + this.heat+=Math.ceil(heat); + } + return (int)Math.ceil(computation*overclock); + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + public int tickComponents(float oc) { + overclock=oc; + if(overclock>10) getBaseMetaTileEntity().setToFire(); + return getComputationPower(overclock,true); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if(aBaseMetaTileEntity.isServerSide()){ + if(aTick%20==multiCheckAt){ + if(heat>0)heat-=Math.max(heat/1000,1); + else if(heat<0)heat-=Math.min(heat/1000,-1); + + if(heat>9000) aBaseMetaTileEntity.setOnFire(); + else if(heat>10000) aBaseMetaTileEntity.setToFire(); + else if(heat<-20000)this.heat=-20000; + } + } + } + + @Override + public void onRemoval() { + if(mInventory!=null && (heat>0 || (getBaseMetaTileEntity()!=null && getBaseMetaTileEntity().isActive()))) + for(int i=0;i<mInventory.length;i++) + mInventory[i]=null; + } + + @Override + public String[] getDescription() { + return new String[]{ + CommonValues.tecMark, + mDescription, + EnumChatFormatting.AQUA + "Holds Computer Components" + }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{ + "Base computation: "+ EnumChatFormatting.AQUA +getComputationPower(1,false), + "After overclocking: "+ EnumChatFormatting.AQUA +getComputationPower(overclock,false), + "Heat Accumulated: "+ EnumChatFormatting.RED + ((heat+99)/100) +EnumChatFormatting.RESET+" %"}; + //heat==0? --> ((heat+9)/10) = 0 + //Heat==1-10? --> 1 + } + + public static void run(){ + new component(ItemList.Circuit_Elite.get(1),4,32,5000,true); + new component(ItemList.Circuit_Advanced.get(1),1,2,2000,true); + new component(ItemList.Circuit_Basic.get(1),2,1,1000,true); + } + + public static class component implements Comparable<component>{ + private final String unlocalizedName; + private final float heat,computation,maxHeat; + private final boolean subZero; + + component(ItemStack is,float heat,float computation,float maxHeat, boolean subZero){ + unlocalizedName=is.getUnlocalizedName(); + this.heat=heat; + this.computation=computation; + this.maxHeat=maxHeat; + this.subZero=subZero; + componentBinds.put(unlocalizedName,this); + } + + @Override + public int compareTo(component o) { + return unlocalizedName.compareTo(o.unlocalizedName); + } + } +} + + diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java index 107d61ef85..9db22ab1a4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.machineTT; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_Container_Uncertainty; import com.github.technus.tectech.thing.metaTileEntity.hatch.gui.GT_GUIContainer_Uncertainty; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java index 74d6400ed3..28fa3dfaf1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java index 70d1f087e1..dc4d4d7eff 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlass; import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; import com.github.technus.tectech.thing.metaTileEntity.constructableTT; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java index a7b0e237e2..de05c46fd8 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlass; import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; import com.github.technus.tectech.thing.metaTileEntity.constructableTT; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java index 897f828b34..187427dfe1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java @@ -2,29 +2,53 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.Util; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.dataFramework.quantumDataPacket; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Rack; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import java.util.ArrayList; + +import static com.github.technus.tectech.thing.casing.GT_Container_CasingsTT.sBlockCasingsTT; +import static gregtech.api.enums.GT_Values.V; + /** * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockBase_EM { - private static final String[][] shape = new String[][]{ - {"",//left to right top - "", - ""},//front - {},//behind front - {} //behind + private final ArrayList<GT_MetaTileEntity_Hatch_Rack> eRacks=new ArrayList<>(); + + private static final String[][] front = new String[][]{ + {" "," ","+ "," ",}, + }; + private static final String[][] terminator = new String[][]{ + {" "," "," "," ",}, }; - private static final Block[] blockType = new Block[]{}; - private static final byte[] blockMeta = new byte[]{}; + private static final String[][] cap = new String[][]{ + {"01","22","22","01",}, + }; + private static final String[][] slice = new String[][]{ + {"01","!2","!2","01",}, + }; + private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT,sBlockCasingsTT}; + private static final byte[] blockMeta = new byte[]{2,0,1}; + private static final String[] addingMethods = new String[]{"addToMachineList","addRackToMachineList"}; + private static final byte[] casingTextures = new byte[]{96,97}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT,sBlockCasingsTT}; + private static final byte[] blockMetaFallback = new byte[]{0,1}; + + private int maxTemp=0; public GT_MetaTileEntity_EM_computer(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -41,17 +65,135 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[97], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[96], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[97]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[96]}; } + //TODO implement uncertainty,unstability @Override - public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + public boolean EM_checkRecipe(ItemStack itemStack) { + eAvailableData=0; + maxTemp=0; + short thingsActive=0; + int rackComputation; + + for (GT_MetaTileEntity_Hatch_Rack r : eRacks) { + if(r.heat>maxTemp)maxTemp=r.heat; + rackComputation= r.tickComponents(eParamsIn[0]); + if(rackComputation>0){ + r.getBaseMetaTileEntity().setActive(true); + eAvailableData+=rackComputation; + thingsActive+=4; + } + } + + for (GT_MetaTileEntity_Hatch_InputData di : eInputData) { + if(di.q!=null) {//ok for power losses + thingsActive++; + } + } + + if(thingsActive>0){ + thingsActive+=eOutputData.size(); + mEUt = -(int) V[8]; + eAmpereFlow = 1 + ((thingsActive + thingsActive) >> 3); + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + return true; + } + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; return false; } @Override + protected long EM_getAvailableData() { + return eAvailableData; + } + + @Override + public void EM_checkParams() { + if(eParamsIn[0]<=0) + eParamsInStatus[0]=PARAM_TOO_LOW; + else if(eParamsIn[0]<1) + eParamsInStatus[0]=PARAM_LOW; + else if(eParamsIn[0]==1) + eParamsInStatus[0]=PARAM_OK; + else if(eParamsIn[0]<=2) + eParamsInStatus[0]=PARAM_HIGH; + else eParamsInStatus[0]=PARAM_TOO_HIGH; + + eParamsOut[0]=eAvailableData; + eParamsOut[10]=maxTemp; + + if(maxTemp<-10000) + eParamsOutStatus[0]=PARAM_TOO_LOW; + else if(maxTemp<0) + eParamsOutStatus[0]=PARAM_LOW; + else if (maxTemp==0) + eParamsOutStatus[0]=PARAM_OK; + else if(maxTemp<=5000) + eParamsOutStatus[0]=PARAM_HIGH; + else eParamsOutStatus[0]=PARAM_TOO_HIGH; + } + + @Override + public void EM_outputFunction() { + if(eOutputData.size()>0) { + quantumDataPacket pack = new quantumDataPacket(position, eAvailableData); + for (GT_MetaTileEntity_Hatch_InputData i : eInputData) { + if(i.q==null)continue; + if(i.q.contains(position)){ + i.q=null; + continue; + } + pack = pack.unifyPacketWith(i.q); + i.q = null; + if (pack == null) return; + } + + pack.computation /= eOutputData.size(); + + for (GT_MetaTileEntity_Hatch_OutputData o : eOutputData) { + o.q=pack; + } + } + } + + @Override + public void onRemoval() { + super.onRemoval(); + for(GT_MetaTileEntity_Hatch_Rack r:eRacks) + r.getBaseMetaTileEntity().setActive(false); + } + + @Override + protected void EM_stopMachine() { + for(GT_MetaTileEntity_Hatch_Rack r:eRacks) + r.getBaseMetaTileEntity().setActive(false); + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + eRacks.clear(); + if(!EM_StructureCheckAdvanced(front,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,0,2,0))return false; + if(!EM_StructureCheckAdvanced(cap,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,0,2,-1))return false; + int i; + for(i=-2;i>-16;i--){ + if(!EM_StructureCheckAdvanced(slice,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,0,2,i))break; + } + if(!EM_StructureCheckAdvanced(cap,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,0,2,++i))return false; + if(!EM_StructureCheckAdvanced(terminator,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,0,2,--i))return false; + return eUncertainHatches.size() == 1; + } + + @Override + protected void EM_extraExplosions() { + for (MetaTileEntity tTileEntity : eRacks) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + + @Override public String[] getDescription() { return new String[]{ CommonValues.tecMark, @@ -59,4 +201,29 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "You need it to process the number above" }; } + + @Override + public boolean isFacingValid(byte aFacing) { + return aFacing>=2; + } + + //NEW METHOD + public final boolean addRackToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Rack) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mMachineBlock = (byte) aBaseCasingIndex; + return eRacks.add((GT_MetaTileEntity_Hatch_Rack) aMetaTileEntity); + } + return false; + } + + public static void run(){ + try { + adderMethodMap.put("addRackToMachineList", GT_MetaTileEntity_EM_computer.class.getMethod("addRackToMachineList", IGregTechTileEntity.class, int.class)); + }catch (NoSuchMethodException e){ + if(TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); + } + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafter.java index 7bdb4ef75b..d073d29bcb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafter.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java index 3dec96b89c..4c158e3a58 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java index 34e02160a1..6e822b663d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlass; import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java index c7e77b4e4d..4ae48e9d62 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java @@ -2,7 +2,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import cofh.api.energy.IEnergyContainerItem; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import ic2.api.item.ElectricItem; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java index 5ad1b54d46..0ecb3b45ec 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlass; import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; @@ -108,9 +108,10 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB if (inIndex < 0 || inIndex > eInputHatches.size()) continue; final int outIndex = (int) (eParamsIn[i + 10]) - 1; GT_MetaTileEntity_Hatch_InputElemental in = eInputHatches.get(inIndex); - if (outIndex == -1) { + if (outIndex == -1) {//param==0 -> null the content cleanHatchContent(in); } else { + if (outIndex < 0 || outIndex > eOutputHatches.size()) continue; GT_MetaTileEntity_Hatch_OutputElemental out = eOutputHatches.get(outIndex); out.getContainerHandler().putUnifyAll(in.getContainerHandler()); in.getContainerHandler().clear(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java index 8f8462fdea..1c4eb68188 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java index 10c985da0b..a7ccd39061 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; 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.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java index fe5a1ea6ed..160d9b2149 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java index 03224f41ee..0d22449db9 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java index 8a3f4f70b8..15b2decea5 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java @@ -1,16 +1,23 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.dataFramework.quantumDataPacket; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; +import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputElemental; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import static com.github.technus.tectech.thing.casing.GT_Container_CasingsTT.sBlockCasingsTT; +import static gregtech.api.enums.GT_Values.V; /** * Created by danie_000 on 17.12.2016. @@ -64,10 +71,69 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas } @Override + public boolean EM_checkRecipe(ItemStack itemStack) { + short thingsActive=0; + for (GT_MetaTileEntity_Hatch_InputData di : eInputData) { + if(di.q!=null) { + thingsActive++; + } + } + + if(thingsActive>0){ + thingsActive+=eOutputData.size(); + mEUt = -(int) V[8]; + eAmpereFlow = 1 + ((thingsActive + thingsActive) >> 3); + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + return true; + } + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + return false; + } + + @Override + public void EM_outputFunction() { + float total=0; + for(int i=0;i<10;i++){//each param pair + if(eParamsIn[i]>0 && eParamsIn[i+10]>=0) + total+=eParamsIn[i];//Total weighted div + } + + total+=total/100F; + + quantumDataPacket pack=new quantumDataPacket(position,0); + for(GT_MetaTileEntity_Hatch_InputData i:eInputData){ + if(i.q==null) continue; + if(i.q.contains(position)){ + i.q=null; + continue; + } + pack = pack.unifyPacketWith(i.q); + i.q = null; + if (pack == null) return; + } + + for (int i = 0; i < 10; i++) { + if(eParamsIn[i]>0) { + final int outIndex = (int) (eParamsIn[i + 10]) - 1; + if (outIndex < 0 || outIndex > eOutputData.size()) continue; + GT_MetaTileEntity_Hatch_OutputData out = eOutputData.get(outIndex); + out.q = new quantumDataPacket(pack, (long) ((pack.computation * eParamsIn[i]) / total)); + } + } + } + + @Override + public void EM_checkParams() { + + } + + @Override public String[] getDescription() { return new String[]{ CommonValues.tecMark, - "User controller computation power routing", + "User controlled computation power routing", EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "Quality of service is a must" }; } 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 ee735ade16..4527269040 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 @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java index ed830449c2..19e0d5aac0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java index cd6f8b5af9..bb427b64dc 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; 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.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; @@ -10,6 +10,7 @@ import com.github.technus.tectech.thing.machineTT; import com.github.technus.tectech.thing.metaTileEntity.hatch.*; import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.gui.GT_GUIContainer_MultiMachineEM; +import com.github.technus.tectech.vec3pos; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -29,10 +30,14 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.ChunkPosition; import net.minecraftforge.fluids.FluidStack; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.TreeMap; import static com.github.technus.tectech.Util.StructureChecker; -import static com.github.technus.tectech.elementalMatter.CommonValues.*; +import static com.github.technus.tectech.Util.StructureCheckerAdvanced; +import static com.github.technus.tectech.CommonValues.*; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.VN; @@ -40,6 +45,9 @@ import static gregtech.api.enums.GT_Values.VN; * Created by danie_000 on 27.10.2016. */ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEntity_MultiBlockBase implements machineTT { + protected final static TreeMap<String,Method> adderMethodMap =new TreeMap<>(); + public static Method adderMethod; + protected cElementalInstanceStackTree[] outputEM = new cElementalInstanceStackTree[0]; public final static ItemStack[] nothingI = new ItemStack[0]; @@ -73,6 +81,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt public long eAmpereFlow = 1; public long eRequiredData = 0; protected long eAvailableData=0; + public final vec3pos position; //init param states in constructor, or implement it in checkrecipe/outputfunction @@ -98,14 +107,33 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt // (Well it can be overflowed if machine didn't finished, soft-hammered/disabled/not enough EU) // Setting available data processing + protected void EM_extraHatchHookInit(){}//For extra types of hatches initiation + protected void EM_extraExplosions(){}//For that extra hatches explosions, and maybe some MOORE EXPLOSIONS + protected void EM_stopMachine(){}//On machine stop + + //Get Available data on data producers should return mAvailableData that is set in check recipe + protected long EM_getAvailableData() { + long result=0; + for(GT_MetaTileEntity_Hatch_InputData in:eInputData) { + if(in.q!=null) result += in.q.computationIfNotConatined(position); + } + return result; + } + //RATHER LEAVE ALONE Section public GT_MetaTileEntity_MultiblockBase_EM(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); + if(getBaseMetaTileEntity()!=null) + position=new vec3pos(getBaseMetaTileEntity()); + else position=null; } public GT_MetaTileEntity_MultiblockBase_EM(String aName) { super(aName); + if(getBaseMetaTileEntity()!=null) + position=new vec3pos(getBaseMetaTileEntity()); + else position=null; } @Override @@ -313,6 +341,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt eParamHatches.clear(); eMufflerHatches.clear(); eDynamoMulti.clear(); + eOutputData.clear(); + eInputData.clear(); mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); @@ -380,6 +410,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt eMaxAmpereFlow = 0; this.setEUVar(0); } + EM_extraHatchHookInit(); } if (mStartUpCheck < 0) {//E @@ -574,13 +605,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return super.getRepairStatus() + ((eCertainStatus == 0) ? 1 : 0) + (this.eParameters ? 1 : 0); } - private long getAvailableData() { - long result=0; - for(GT_MetaTileEntity_Hatch_InputData in:eInputData) - result+=in.data; - return result; - } - @Override public boolean onRunningTick(ItemStack aStack) { if(eRequiredData>eAvailableData) return false; @@ -663,7 +687,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt long euVar = EU * Amperes; if (euVar > getEUVar() || EU > maxEUinputMax || - (euVar - 1) / maxEUinputMin + 1 > eMaxAmpereFlow) { + (euVar - 1) / maxEUinputMin + 1 > eMaxAmpereFlow) {// euVar==0? --> (euVar - 1) / maxEUinputMin + 1 = 1! if (TecTech.ModConfig.DEBUG_MODE) { TecTech.Logger.debug("OMG1 " + euVar + " " + getEUVar() + " " + (euVar > getEUVar())); TecTech.Logger.debug("OMG2 " + EU + " " + maxEUinputMax + " " + (EU > maxEUinputMax)); @@ -733,8 +757,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt getBaseMetaTileEntity().disableWorking(); for(GT_MetaTileEntity_Hatch_OutputData data:eOutputData) { - data.timeout = 0; - data.data = 0; + data.q=null; } float mass = 0; @@ -750,6 +773,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } outputEM = null; + + EM_stopMachine(); } @Override @@ -817,9 +842,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } EM_checkParams(); - eAvailableData=getAvailableData(); - for(GT_MetaTileEntity_Hatch_OutputData data:eOutputData) - if(data.data>0)data.timeout=2; + eAvailableData= EM_getAvailableData(); for (GT_MetaTileEntity_Hatch_Uncertainty uncertainty : eUncertainHatches) eCertainStatus = uncertainty.update(eCertainMode); @@ -867,6 +890,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt for (MetaTileEntity tTileEntity : eDynamoMulti) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); for (MetaTileEntity tTileEntity : eInputData) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); for (MetaTileEntity tTileEntity : eOutputData) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + EM_extraExplosions(); getBaseMetaTileEntity().doExplosion(V[15]); } @@ -1201,6 +1225,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt }; } + @Override public boolean isGivingInformation() { return true; @@ -1208,13 +1233,28 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //can be used to check structures of multi-blocks larger than one chunk, but... //ALL THE HATCHES AND THE CONTROLLER SHOULD BE IN ONE CHUNK OR IN LOADED CHUNKS - public final boolean EM_StructureCheck(String[][] structure,//0-9 casing, +- air no air, a-z ignore - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset){ + public final boolean EM_StructureCheck( + String[][] structure,//0-9 casing, +- air no air, a-z ignore + Block[] blockType,//use numbers 0-9 for casing types + byte[] blockMeta,//use numbers 0-9 for casing types + int horizontalOffset, int verticalOffset, int depthOffset){ return StructureChecker(structure,blockType,blockMeta,horizontalOffset,verticalOffset,depthOffset,getBaseMetaTileEntity(),!mMachine); } + public final boolean EM_StructureCheckAdvanced( + String[][] structure,//0-9 casing, +- air no air, a-z ignore + Block[] blockType,//use numbers 0-9 for casing types + byte[] blockMeta,//use numbers 0-9 for casing types + 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){ + return StructureCheckerAdvanced(structure, blockType, blockMeta, + adderMethod, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, + horizontalOffset, verticalOffset, depthOffset, getBaseMetaTileEntity(), !mMachine); + } + @Override public String[] getDescription() { return new String[]{ @@ -1231,10 +1271,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt hatch_elemental.id = -1; for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) hatch_elemental.id = -1; - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eOutputData) { - hatch_data.timeout=0; - hatch_data.data=0; + for (GT_MetaTileEntity_Hatch_OutputData hatch_data : eOutputData) { hatch_data.id = -1; + hatch_data.q=null; } for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) hatch_data.id = -1; @@ -1254,4 +1293,37 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); } } + + public static void run(){ + try { + adderMethodMap.put("addToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addMufflerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addMufflerToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addInputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addOutputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addEnergyInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addEnergyInputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addDynamoToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addDynamoToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addEnergyIOToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addEnergyIOToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addElementalInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalInputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addElementalOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addElementalOutputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addClassicInputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicInputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addClassicOutputToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicOutputToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addParametrizerToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addParametrizerToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addUncertainToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addUncertainToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addClassicMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); + adderMethodMap.put("addDataConnectorToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addDataConnectorToMachineList", IGregTechTileEntity.class, int.class)); + adderMethod=GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addThing", String.class, IGregTechTileEntity.class, int.class); + }catch (NoSuchMethodException e){ + if(TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); + } + } + + public final boolean addThing(String methodName,IGregTechTileEntity igt,int casing){ + try { + return (boolean) adderMethodMap.get(methodName).invoke(this, igt, casing); + }catch (InvocationTargetException | IllegalAccessException e){ + if(TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); + } + return false; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java index 93b5e3756b..88bb4e409a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.pipe; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.machineTT; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; import gregtech.api.enums.Dyes; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java index 543f25120a..0c3c68d811 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.pipe; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.machineTT; import gregtech.api.enums.Dyes; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java index 99d9c1022d..36e0ff6f66 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.single; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.elementalMatter.CommonValues; +import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_DebugStructureWriter; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_DebugStructureWriter; import gregtech.api.enums.Textures; diff --git a/src/main/java/com/github/technus/tectech/vec3pos.java b/src/main/java/com/github/technus/tectech/vec3pos.java new file mode 100644 index 0000000000..922ce5d66e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/vec3pos.java @@ -0,0 +1,34 @@ +package com.github.technus.tectech; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +/** + * Created by Tec on 05.04.2017. + */ +public class vec3pos implements Comparable<vec3pos> { + public final int x,z; + public final short y; + + public vec3pos(int x,short y, int z){ + this.x=x; + this.y=y; + this.z=z; + } + + public vec3pos(IGregTechTileEntity te){ + this.x=te.getXCoord(); + this.y=te.getYCoord(); + this.z=te.getZCoord(); + } + + @Override + public int compareTo(vec3pos o) { + if(y>o.y) return 1; + if(y<o.y) return -1; + if(x>o.x) return 1; + if(x<o.x) return -1; + if(z>o.z) return 1; + if(z<o.z) return -1; + return 0; + } +} diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_RACK.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_RACK.png Binary files differnew file mode 100644 index 0000000000..86c556706c --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_RACK.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_RACK_ACTIVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_RACK_ACTIVE.png Binary files differnew file mode 100644 index 0000000000..9f016fecbd --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_RACK_ACTIVE.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_RACK_ACTIVE.png.mcmeta b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_RACK_ACTIVE.png.mcmeta new file mode 100644 index 0000000000..97596ba817 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/EM_RACK_ACTIVE.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation":{ + "frametime":2 + } +}
\ No newline at end of file |