diff options
| author | Technus <daniel112092@gmail.com> | 2017-03-23 13:05:22 +0100 |
|---|---|---|
| committer | Technus <daniel112092@gmail.com> | 2017-03-23 13:05:22 +0100 |
| commit | ee592d1f1dd1de2c80a31cd17c847fa69dc2e077 (patch) | |
| tree | 9f5c58ad2d96cbaa7c99c65e8214497e3ef05330 /src | |
| parent | 5cc1821de4c8711eb5021646f66c013eba6e6754 (diff) | |
| download | GT5-Unofficial-ee592d1f1dd1de2c80a31cd17c847fa69dc2e077.tar.gz GT5-Unofficial-ee592d1f1dd1de2c80a31cd17c847fa69dc2e077.tar.bz2 GT5-Unofficial-ee592d1f1dd1de2c80a31cd17c847fa69dc2e077.zip | |
Minor reworks, adding reverse struct checker,
Diffstat (limited to 'src')
35 files changed, 552 insertions, 83 deletions
diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index a2879c16d8..f1be2a0c10 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -2,11 +2,11 @@ package com.github.technus.tectech; import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.auxiliary.TecTechConfig; -import com.github.technus.tectech.loader.GT_CustomLoader; +import com.github.technus.tectech.loader.Main; import com.github.technus.tectech.proxy.CommonProxy; import com.github.technus.tectech.thing.block.QuantumGlass; import com.github.technus.tectech.thing.casing.GT_Container_CasingsTT; -import com.github.technus.tectech.thing.item.debug_container_EM; +import com.github.technus.tectech.thing.item.DebugContainer_EM; import com.github.technus.tectech.thing.machineTT; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; @@ -40,7 +40,7 @@ public class TecTech { public static LogHelper Logger = new LogHelper(Reference.MODID); private static IngameErrorLog Module_AdminErrorLogs = null; - public static GT_CustomLoader GTCustomLoader = null; + public static Main GTCustomLoader = null; public static TecTechConfig ModConfig; public static XSTR Rnd = null; public static CreativeTabs mainTab = null; @@ -78,9 +78,9 @@ public class TecTech { hasCOFH=Loader.isModLoaded(Reference.COFHCORE); QuantumGlass.run(); - debug_container_EM.run(); + DebugContainer_EM.run(); - GTCustomLoader = new GT_CustomLoader(); + GTCustomLoader = new Main(); GTCustomLoader.run(); GTCustomLoader.run2(); @@ -88,7 +88,7 @@ public class TecTech { @SideOnly(Side.CLIENT) @Override public Item getTabIconItem() { - return debug_container_EM.INSTANCE; + return DebugContainer_EM.INSTANCE; } @Override @@ -109,7 +109,7 @@ public class TecTech { public void RegisterThingsInTabs() { QuantumGlass.INSTANCE.setCreativeTab(mainTab); GT_Container_CasingsTT.sBlockCasingsTT.setCreativeTab(mainTab); - debug_container_EM.INSTANCE.setCreativeTab(mainTab); + DebugContainer_EM.INSTANCE.setCreativeTab(mainTab); } /** diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index 05594ce1d5..313106f64b 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -5,10 +5,17 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + /** * Created by Tec on 21.03.2017. */ @@ -40,7 +47,7 @@ public class Util { byte facing = aBaseMetaTileEntity.getFrontFacing(); World world=aBaseMetaTileEntity.getWorld(); - int x, y, z, a, b, c,yPos; + int x, y, z, a, b, c, yPos; //a,b,c - relative to block face! //x,y,z - relative to block position on map! //yPos - absolute height of checked block @@ -66,33 +73,37 @@ public class Util { case 0: x = -a; y = +c; z = -b; break;//similar to 2 default: return false; } - //that must be here since in some cases other axis (a,b,c) controls y + //that must be here since in some cases other axis (b,c) controls y yPos=aBaseMetaTileEntity.getYCoord()+y; if(yPos<0 || yPos>=256) return false; + //Check block - if (forceCheck||world.blockExists(x,y,z)) + if (world.blockExists(x,y,z)) {//this actually checks if the chunk is loaded at this pos switch (block) { case '-'://must be air - if (!aBaseMetaTileEntity.getAirOffset(x, y, z)) return false; + if (getBlockOffset(aBaseMetaTileEntity, x, y, z, world).getMaterial() != Material.air) + return false; break; case '+'://must not be air - if (aBaseMetaTileEntity.getAirOffset(x, y, z)) return false; + if (getBlockOffset(aBaseMetaTileEntity, x, y, z, world).getMaterial() == Material.air) + return false; break; default: {//check for block (countable) int pointer = block - '0'; //countable air -> net.minecraft.block.BlockAir - if (aBaseMetaTileEntity.getBlockOffset(x, y, z) != blockType[pointer]) { + if (getBlockOffset(aBaseMetaTileEntity,x,y,z,world) != blockType[pointer]) { if (TecTech.ModConfig.DEBUG_MODE) - TecTech.Logger.info("Struct-block-error " + x + " " + y + " " + z + "/" + a + " " + c + "/" + aBaseMetaTileEntity.getBlockOffset(x, y, z) + " " + blockType[pointer]); + TecTech.Logger.info("Struct-block-error " + x + " " + y + " " + z + "/" + a + " " + c + "/" + getBlockOffset(aBaseMetaTileEntity,x,y,z,world) + " " + blockType[pointer]); return false; } - if (aBaseMetaTileEntity.getMetaIDOffset(x, y, z) != blockMeta[pointer]) { + if (getMetaIDOffset(aBaseMetaTileEntity,x,y,z,world) != blockMeta[pointer]) { if (TecTech.ModConfig.DEBUG_MODE) - TecTech.Logger.info("Struct-meta-id-error " + x + " " + y + " " + z + "/" + a + " " + c + "/" + aBaseMetaTileEntity.getMetaIDOffset(x, y, z) + " " + blockMeta[pointer]); + TecTech.Logger.info("Struct-meta-id-error " + x + " " + y + " " + z + "/" + a + " " + c + "/" + getMetaIDOffset(aBaseMetaTileEntity,x,y,z,world) + " " + blockMeta[pointer]); return false; } } } + }else if (forceCheck) return false; a++;//block in horizontal layer } } @@ -103,6 +114,141 @@ public class Util { return true; } + public static String[] ReverseStructureCheck(IGregTechTileEntity aBaseMetaTileEntity, + int horizontalOffset, int verticalOffset, int depthOffset, + int horizontalSize, int verticalSize, int depthSize){ + //TE Rotation + byte facing = aBaseMetaTileEntity.getFrontFacing(); + World world=aBaseMetaTileEntity.getWorld(); + + ItemStack[] array=new ItemStack[10]; + + int x, y, z, a, b, c,yPos; + //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 - #1 - count block types + c = -depthOffset; + for (int cz=0;cz<depthSize;cz++) {//front to back + b = verticalOffset; + for (int by=0;by<verticalSize;by++) {//top to bottom + a = -horizontalOffset; + for (int az=0;az<horizontalSize;az++) {//left to right + //get x y z from rotation + switch (facing) {//translation + case 4: x = +c; z = +a; y = +b; break; + case 3: x = +a; z = -c; y = +b; break; + case 5: x = -c; z = -a; y = +b; break; + case 2: x = -a; z = +c; y = +b; break; + //Things get odd if the block faces up or down... + case 1: x = +a; y = -c; z = +b; break;//similar to 3 + case 0: x = -a; y = +c; z = -b; break;//similar to 2 + default: return new String[]{"Invalid facing"}; + } + //that must be here since in some cases other axis (a,b,c) controls y + yPos=aBaseMetaTileEntity.getYCoord()+y; + if(yPos<0 || yPos>=256) return new String[]{"Invalid position"}; + //Check block + Block block=getBlockOffset(aBaseMetaTileEntity,x,y,z,world); + int meta=getMetaIDOffset(aBaseMetaTileEntity,x,y,z,world); + + if(!block.hasTileEntity(meta) && block.getMaterial()!=Material.air) { + boolean err=true; + final ItemStack is=new ItemStack(block, 1, meta); + for(int i=0;i<array.length;i++){ + if(array[i]==null){ + array[i]=is; + err=false; + break; + } else if(is.getItem()==array[i].getItem() && is.getItemDamage()==array[i].getItemDamage()){ + err=false; + break; + } + } + if (err) return new String[]{"Too much different blocks"}; + } + + a++;//block in horizontal layer + } + b--;//horizontal layer + } + c++;//depth + } + + List<String> output=new ArrayList<>(); + + output.add("Block[] MetaID[]"); + output.add(""); + for(ItemStack is:array){ + if(is!=null) output.add(is.getUnlocalizedName()+" "+is.getItemDamage()); + } + output.add(""); + output.add("String[][]"); + //perform your duties - #2 - write strings + c = -depthOffset; + for (int cz=0;cz<depthSize;cz++) {//front to back + b = verticalOffset; + output.add(""); + for (int by=0;by<verticalSize;by++) {//top to bottom + a = -horizontalOffset; + String line=""; + for (int az=0;az<horizontalSize;az++) {//left to right + //get x y z from rotation + switch (facing) {//translation + case 4: x = +c; z = +a; y = +b; break; + case 3: x = +a; z = -c; y = +b; break; + case 5: x = -c; z = -a; y = +b; break; + case 2: x = -a; z = +c; y = +b; break; + //Things get odd if the block faces up or down... + case 1: x = +a; y = -c; z = +b; break;//similar to 3 + case 0: x = -a; y = +c; z = -b; break;//similar to 2 + default: return new String[]{"Invalid facing"}; + } + //that must be here since in some cases other axis (a,b,c) controls y + //yPos=aBaseMetaTileEntity.getYCoord()+y; + //if(yPos<0 || yPos>=256) return new String[]{"Invalid position"}; + //Check block + + Block block=getBlockOffset(aBaseMetaTileEntity,x,y,z,world); + int meta=getMetaIDOffset(aBaseMetaTileEntity,x,y,z,world); + + if(a==0 && b==0 && c==0){ + line+='X'; + }else if(block.getMaterial()==Material.air){ + line+='-'; + }else if(block.hasTileEntity(meta)){ + line+='+'; + }else{ + ItemStack stack=new ItemStack(block,1,meta); + String str="?"; + for(int i=0;i<array.length;i++){ + if(array[i]!=null && stack.getItem()==array[i].getItem() && stack.getItemDamage()==array[i].getItemDamage()) { + str = Integer.toString(i); + break; + } + } + line+=str; + } + + a++;//block in horizontal layer + } + output.add(line); + b--;//horizontal layer + } + c++;//depth + } + return output.toArray(new String[0]); + } + + private static Block getBlockOffset(IGregTechTileEntity a,int x,int y,int z,World w){ + return w.getBlock(a.getXCoord()+x,a.getYCoord()+y,a.getZCoord()+z); + } + + private static int getMetaIDOffset(IGregTechTileEntity a,int x,int y,int z,World w){ + return w.getBlockMetadata(a.getXCoord()+x,a.getYCoord()+y,a.getZCoord()+z); + } + public static boolean isInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] requiredFluidInputs, ItemStack[] requiredInputs, FluidStack[] givenFluidInputs, ItemStack... givenInputs) { if (!GregTech_API.sPostloadFinished) return false; if (requiredFluidInputs.length > 0 && givenFluidInputs == null) return false; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/commonValues.java b/src/main/java/com/github/technus/tectech/elementalMatter/CommonValues.java index c18c543ee5..d16b1fd18c 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/commonValues.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/CommonValues.java @@ -5,7 +5,7 @@ import net.minecraft.util.EnumChatFormatting; /** * Created by danie_000 on 11.01.2017. */ -public final class commonValues { +public final class CommonValues { public final static String tecMark = EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + diff --git a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java b/src/main/java/com/github/technus/tectech/loader/Machines.java index 02cab21bce..64110a69bf 100644 --- a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Machines.java +++ b/src/main/java/com/github/technus/tectech/loader/Machines.java @@ -1,16 +1,18 @@ package com.github.technus.tectech.loader; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.metaTileEntity.hatch.*; import com.github.technus.tectech.thing.metaTileEntity.multi.*; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM; +import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugStructureWriter; import static com.github.technus.tectech.thing.CustomItemList.*; /** * Created by danie_000 on 16.11.2016. */ -public class GT_Loader_Machines implements Runnable { +public class Machines implements Runnable { public void run() { // =================================================================================================== // eM IN @@ -190,6 +192,8 @@ public class GT_Loader_Machines implements Runnable { Machine_Multi_Computer.set(new GT_MetaTileEntity_EM_computer(12172, "multimachine.em.computer", "Quantum Computer").getStackForm(1L)); Machine_Multi_Switch.set(new GT_MetaTileEntity_EM_switch(12173, "multimachine.em.switch", "Network Switch With QoS").getStackForm(1L)); + Machine_DebugWriter.set(new GT_MetaTileEntity_DebugStructureWriter(12179,"debug.tt.writer","Debug Structure Writer",15).getStackForm(1L)); + // =================================================================================================== // Hatches EM // =================================================================================================== diff --git a/src/main/java/com/github/technus/tectech/loader/GT_CustomLoader.java b/src/main/java/com/github/technus/tectech/loader/Main.java index deec6e4306..6a88c06176 100644 --- a/src/main/java/com/github/technus/tectech/loader/GT_CustomLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/Main.java @@ -3,25 +3,25 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.casing.GT_Loader_CasingsTT; -public class GT_CustomLoader { - private GT_Loader_Machines ElementalLoader; +public class Main { + private Machines ElementalLoader; private GT_Loader_CasingsTT ElementalCasing; - private GT_Loader_Recipes ElementalRecipes; + private Recipes ElementalRecipes; - public GT_CustomLoader() { + public Main() { } public void run() { ElementalCasing = new GT_Loader_CasingsTT(); ElementalCasing.run(); TecTech.Logger.info("Casing Init Done"); - ElementalLoader = new GT_Loader_Machines(); + ElementalLoader = new Machines(); ElementalLoader.run(); TecTech.Logger.info("Machine Init Done"); } public void run2() { - ElementalRecipes = new GT_Loader_Recipes(); + ElementalRecipes = new Recipes(); ElementalRecipes.run(); TecTech.Logger.info("Recipe Init Done"); } diff --git a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Recipes.java b/src/main/java/com/github/technus/tectech/loader/Recipes.java index d4c76198d2..8a1a5da6f7 100644 --- a/src/main/java/com/github/technus/tectech/loader/GT_Loader_Recipes.java +++ b/src/main/java/com/github/technus/tectech/loader/Recipes.java @@ -7,7 +7,7 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_E /** * Created by danie_000 on 16.11.2016. */ -public class GT_Loader_Recipes implements Runnable { +public class Recipes implements Runnable { public void run() { // =================================================================================================== // def init 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 a64f219f59..525fcbd7e3 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack; import static gregtech.api.enums.GT_Values.W; public enum CustomItemList implements IItemContainer { + Machine_DebugWriter, EMpipe,DATApipe, eM_dynamomulti4_UV, eM_dynamomulti16_UV, eM_dynamomulti64_UV, eM_dynamomulti4_UHV, eM_dynamomulti16_UHV, eM_dynamomulti64_UHV, diff --git a/src/main/java/com/github/technus/tectech/thing/item/debug_container_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java index 01e55898b5..6af497f3c9 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/debug_container_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java @@ -3,7 +3,7 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; import com.github.technus.tectech.elementalMatter.classes.tElementalException; -import com.github.technus.tectech.elementalMatter.commonValues; +import com.github.technus.tectech.elementalMatter.CommonValues; import com.github.technus.tectech.elementalMatter.interfaces.iElementalInstanceContainer; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -25,10 +25,10 @@ import static com.github.technus.tectech.auxiliary.Reference.MODID; /** * Created by Tec on 15.03.2017. */ -public class debug_container_EM extends Item { - public static debug_container_EM INSTANCE; +public class DebugContainer_EM extends Item { + public static DebugContainer_EM INSTANCE; - debug_container_EM(){ + DebugContainer_EM(){ super(); setMaxStackSize(1); setUnlocalizedName("em.debugContainer"); @@ -70,7 +70,7 @@ public class debug_container_EM extends Item { @Override public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { - aList.add(commonValues.tecMark); + aList.add(CommonValues.tecMark); try { NBTTagCompound tNBT = aStack.getTagCompound(); if (tNBT!=null && tNBT.hasKey("info")) { @@ -83,7 +83,7 @@ public class debug_container_EM extends Item { } public static void run(){ - INSTANCE=new debug_container_EM(); + INSTANCE=new DebugContainer_EM(); GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); } 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 f03e981218..f8b9e46601 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,6 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.elementalMatter.commonValues; +import com.github.technus.tectech.elementalMatter.CommonValues; import com.github.technus.tectech.thing.machineTT; import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToDataPipe; import gregtech.api.enums.Dyes; @@ -16,7 +16,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.elementalMatter.CommonValues.moveAt; import static gregtech.api.enums.Dyes.MACHINE_METAL; /** @@ -143,7 +143,7 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE @Override public String[] getDescription() { return new String[]{ - commonValues.tecMark, + CommonValues.tecMark, mDescription, "High speed fibre optics connector.", EnumChatFormatting.AQUA + "Must be painted to work" 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 d2d2cf0866..c3a8c38a2f 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.elementalMatter.CommonValues; import com.github.technus.tectech.thing.machineTT; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -106,7 +106,7 @@ public class GT_MetaTileEntity_Hatch_DynamoMulti extends GT_MetaTileEntity_Hatch @Override public String[] getDescription() { return new String[]{ - commonValues.tecMark, + CommonValues.tecMark, mDescription //"Amperes Out: "+ EnumChatFormatting.AQUA+Amperes+" A" }; 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 212d14586e..6d3347c182 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java +++ b/ |
