From b410c1cba1311addfcd52c7bc80b020f1a529699 Mon Sep 17 00:00:00 2001 From: Technus Date: Sun, 9 Apr 2017 12:52:34 +0200 Subject: Computers coded, some reworks. --- .../com/github/technus/tectech/CommonValues.java | 2 +- .../java/com/github/technus/tectech/TecTech.java | 25 +-- .../tectech/dataFramework/quantumDataPacket.java | 12 +- .../technus/tectech/loader/CasingLoader.java | 13 ++ .../technus/tectech/loader/MachineLoader.java | 222 +++++++++++++++++++++ .../github/technus/tectech/loader/Machines.java | 222 --------------------- .../com/github/technus/tectech/loader/Main.java | 28 --- .../github/technus/tectech/loader/MainLoader.java | 43 ++++ .../technus/tectech/loader/RecipeLoader.java | 41 ++++ .../com/github/technus/tectech/loader/Recipes.java | 41 ---- .../technus/tectech/loader/ThingsLoader.java | 23 +++ .../tectech/thing/casing/GT_Loader_CasingsTT.java | 10 - .../GT_MetaTileEntity_Hatch_DataConnector.java | 6 +- .../hatch/GT_MetaTileEntity_Hatch_OutputData.java | 5 +- .../hatch/GT_MetaTileEntity_Hatch_Rack.java | 57 +++--- .../hatch/GT_MetaTileEntity_Hatch_Uncertainty.java | 113 +++++------ .../hatch/gui/GT_Container_Rack.java | 65 ++++++ .../hatch/gui/GT_GUIContainer_Rack.java | 28 +++ .../hatch/gui/GT_GUIContainer_Uncertainty.java | 2 +- .../multi/GT_MetaTileEntity_EM_computer.java | 86 ++++---- .../multi/GT_MetaTileEntity_EM_switch.java | 56 +++--- .../multi/GT_MetaTileEntity_MultiblockBase_EM.java | 24 +-- 22 files changed, 616 insertions(+), 508 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/loader/CasingLoader.java create mode 100644 src/main/java/com/github/technus/tectech/loader/MachineLoader.java delete mode 100644 src/main/java/com/github/technus/tectech/loader/Machines.java delete mode 100644 src/main/java/com/github/technus/tectech/loader/Main.java create mode 100644 src/main/java/com/github/technus/tectech/loader/MainLoader.java create mode 100644 src/main/java/com/github/technus/tectech/loader/RecipeLoader.java delete mode 100644 src/main/java/com/github/technus/tectech/loader/Recipes.java create mode 100644 src/main/java/com/github/technus/tectech/loader/ThingsLoader.java delete mode 100644 src/main/java/com/github/technus/tectech/thing/casing/GT_Loader_CasingsTT.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Rack.java create mode 100644 src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Rack.java (limited to 'src/main/java/com') diff --git a/src/main/java/com/github/technus/tectech/CommonValues.java b/src/main/java/com/github/technus/tectech/CommonValues.java index 66ce2cde3d..7293c351d2 100644 --- a/src/main/java/com/github/technus/tectech/CommonValues.java +++ b/src/main/java/com/github/technus/tectech/CommonValues.java @@ -10,7 +10,7 @@ public final class CommonValues { EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.BLUE + ": Elemental Matter"; - public final static byte decayAt = 0;// hatches compute dacays + public final static byte decayAt = 0;// hatches compute decays public final static byte multiPurge1At = 2;// multiblocks clean their hatches 1 public final static byte moveAt = 4;// move stuff around public final static byte recipeAt = 6;// move stuff around diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index a903ca21dd..0e6088832c 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -2,7 +2,7 @@ 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.Main; +import com.github.technus.tectech.loader.MainLoader; 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; @@ -46,7 +46,7 @@ public class TecTech { public static LogHelper Logger = new LogHelper(Reference.MODID); private static IngameErrorLog Module_AdminErrorLogs = null; - public static Main GTCustomLoader = null; + public static MainLoader GTCustomLoader = null; public static TecTechConfig ModConfig; public static XSTR Rnd = null; public static CreativeTabs mainTab = null; @@ -84,13 +84,9 @@ public class TecTech { public void PostLoad(FMLPostInitializationEvent PostEvent) { hasCOFH=Loader.isModLoaded(Reference.COFHCORE); - QuantumGlass.run(); - DebugContainer_EM.run(); - DebugBuilder.run(); - - GTCustomLoader = new Main(); - GTCustomLoader.run(); - GTCustomLoader.run2(); + GTCustomLoader = new MainLoader(); + GTCustomLoader.things(); + GTCustomLoader.recipes(); mainTab = new CreativeTabs("TecTech") { @SideOnly(Side.CLIENT) @@ -110,7 +106,7 @@ public class TecTech { } }; - RegisterThingsInTabs(); + GTCustomLoader.registerThingsInTabs(); if (Loader.isModLoaded("dreamcraft")) ;//TODO init recipes for GTNH version else ;//TODO init recipes for NON-GTNH version @@ -119,18 +115,11 @@ public class TecTech { @EventHandler public void serverLoad(FMLServerStartingEvent pEvent) { if(!oneTimeFix) { - if (ModConfig.NERF_FUSION) FixBrokenFusionRecipes(); oneTimeFix=true; + if (ModConfig.NERF_FUSION) FixBrokenFusionRecipes(); } } - private void RegisterThingsInTabs() { - QuantumGlass.INSTANCE.setCreativeTab(mainTab); - GT_Container_CasingsTT.sBlockCasingsTT.setCreativeTab(mainTab); - DebugContainer_EM.INSTANCE.setCreativeTab(mainTab); - DebugBuilder.INSTANCE.setCreativeTab(mainTab); - } - private void FixBrokenFusionRecipes(){ HashMap binds=new HashMap<>(); for(Materials m:Materials.values()){ diff --git a/src/main/java/com/github/technus/tectech/dataFramework/quantumDataPacket.java b/src/main/java/com/github/technus/tectech/dataFramework/quantumDataPacket.java index aeb3314d06..7b14a8535e 100644 --- a/src/main/java/com/github/technus/tectech/dataFramework/quantumDataPacket.java +++ b/src/main/java/com/github/technus/tectech/dataFramework/quantumDataPacket.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.dataFramework; import com.github.technus.tectech.vec3pos; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.nbt.NBTTagCompound; import java.util.TreeSet; @@ -14,10 +15,6 @@ public class quantumDataPacket { public long computation=0; public TreeSet trace=new TreeSet<>(); - public quantumDataPacket(long comp){ - computation=comp; - } - public quantumDataPacket(vec3pos pos,long computation){ this.computation=computation; trace.add(pos); @@ -28,11 +25,6 @@ public class quantumDataPacket { 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 componentBinds=new TreeMap<>(); public GT_MetaTileEntity_Hatch_Rack(int aID, String aName, String aNameRegional, int aTier, String descr) { @@ -45,14 +48,16 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setInteger("eHeat",heat); - aNBT.setFloat("eOverclock",overclock); + aNBT.setFloat("eOverClock", overClock); + aNBT.setFloat("eOverVolt", overVolt); } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); heat=aNBT.getInteger("eHeat"); - overclock=aNBT.getFloat("eOverclock"); + overClock =aNBT.getFloat("eOverClock"); + overVolt =aNBT.getFloat("eOverVolt"); } @Override @@ -111,12 +116,12 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); + return new GT_Container_Rack(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Computer Rack"); + return new GT_GUIContainer_Rack(aPlayerInventory, aBaseMetaTileEntity, "Computer Rack"); } @Override @@ -132,26 +137,29 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem } //TODO implement: glitches with OC, random component burning with OC - private int getComputationPower(float overclock,boolean heatProcess){ + private int getComputationPower(float overclock, float overvolt, boolean tickingComponents){ float computation=0,heat=0; - for(ItemStack is:mInventory){ - if(is==null || is.stackSize!=1) continue; - component comp=componentBinds.get(is.getUnlocalizedName()); + for(int i=0;icomp.maxHeat){ - is.stackSize=0; + if(tickingComponents) { + if (this.heat > comp.maxHeat) { + mInventory[i] = null; continue; - } - if(comp.subZero || this.heat>=0) - heat+=comp.heat>0?comp.heat*overclock*overclock:comp.heat; + } else if (comp.subZero || this.heat > 0) + heat += comp.heat > 0 ? comp.heat * overclock * overclock * overvolt: comp.heat; + //=MAX(0;MIN(MIN($B4;1*C$3+C$3-0,25);1+RAND()+(C$3-1)-($B4-1)/2)) + if(overvolt*10f>7f+TecTech.Rnd.nextFloat()) + computation+=comp.computation*Math.max(0,Math.min(Math.min(overclock,overvolt+overvolt-0.25),1+TecTech.Rnd.nextFloat()+(overvolt-1)-(overclock-1)/2)); + }else{ + computation+=comp.computation*overclock; } - computation+=comp.computation; } - if(heatProcess){ + if(tickingComponents) { this.heat+=Math.ceil(heat); } - return (int)Math.ceil(computation*overclock); + return (int)Math.floor(computation); } @Override @@ -159,10 +167,10 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem return 1; } - public int tickComponents(float oc) { - overclock=oc; - if(overclock>10) getBaseMetaTileEntity().setToFire(); - return getComputationPower(overclock,true); + public int tickComponents(float oc,float ov) { + if(oc>3+TecTech.Rnd.nextFloat() || ov>2+TecTech.Rnd.nextFloat()) getBaseMetaTileEntity().setToFire(); + overClock =oc; overVolt =ov; + return getComputationPower(overClock, overVolt,true); } @Override @@ -203,8 +211,8 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem @Override public String[] getInfoData() { return new String[]{ - "Base computation: "+ EnumChatFormatting.AQUA +getComputationPower(1,false), - "After overclocking: "+ EnumChatFormatting.AQUA +getComputationPower(overclock,false), + "Base computation: "+ EnumChatFormatting.AQUA +getComputationPower(1,0,false), + "After overclocking: "+ EnumChatFormatting.AQUA +getComputationPower(overClock,0,false), "Heat Accumulated: "+ EnumChatFormatting.RED + ((heat+99)/100) +EnumChatFormatting.RESET+" %"}; //heat==0? --> ((heat+9)/10) = 0 //Heat==1-10? --> 1 @@ -228,6 +236,7 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem this.maxHeat=maxHeat; this.subZero=subZero; componentBinds.put(unlocalizedName,this); + if(TecTech.ModConfig.DEBUG_MODE) TecTech.Logger.info("Component registered: "+unlocalizedName); } @Override 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 9db22ab1a4..042b2cf49d 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 @@ -26,9 +26,8 @@ import net.minecraftforge.fluids.FluidStack; public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch implements machineTT { private static Textures.BlockIcons.CustomIcon ScreenON; private static Textures.BlockIcons.CustomIcon ScreenOFF; - private static float errorMargin = 0.05f; public short[] matrix = new short[]{500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500}; - public byte selection = -1, mode = 0, status = -128; + public byte selection = -1, mode = 0, status = -128;//all 8 bits set public GT_MetaTileEntity_Hatch_Uncertainty(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, "Feeling certain, or not?"); @@ -71,10 +70,15 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide() && (aTick & 15) == 0) { - shift(); - compute(); - if (mode == 0) aBaseMetaTileEntity.setActive(false); - else aBaseMetaTileEntity.setActive(true); + if (mode == 0) { + aBaseMetaTileEntity.setActive(false); + status=-128; + } + else { + aBaseMetaTileEntity.setActive(true); + shift(); + compute(); + } } } @@ -172,17 +176,12 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch }; } - private float massOffset(int sideLenY, int sideLenX, short... masses) { - int mass = 0; - int massI = 0, massJ = 0; - for (int i = 0; i < sideLenY; i++) { - for (int j = 0; j < sideLenY * sideLenX; j += sideLenY) { - mass += masses[i + j]; - massI += ((float) i - ((float) sideLenY / 2f) + .5f) * masses[i + j]; - massJ += ((float) (j / sideLenY) - ((float) sideLenX / 2f) + .5f) * masses[i + j]; - } + private boolean balanceCheck(int sideLenY, short... masses) { + float inequality = 0; + for (int i = 0; i < masses.length>>1; i++) { + inequality += Math.abs(masses[i]-masses[masses.length-i-1]); } - return ((Math.abs(massI / (float) mass) / (float) sideLenY) + (Math.abs(massJ / (float) mass)) / (float) sideLenX); + return inequality < (masses.length<<7); } public void regenerate() { @@ -194,92 +193,80 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch int result = 0; switch (mode) { case 1://ooo oxo ooo - result = (massOffset(4, 4, matrix) < errorMargin) ? 0 : 1; + result = balanceCheck(4, matrix) ? 0 : 1; break; case 2://ooo xox ooo - result += (massOffset(4, 2, + result += balanceCheck(4, matrix[0], matrix[4], matrix[1], matrix[5], matrix[2], matrix[6], - matrix[3], matrix[7]) < errorMargin) ? 0 : 1; - result += (massOffset(4, 2, + matrix[3], matrix[7]) ? 0 : 1; + result += balanceCheck(4, matrix[8], matrix[12], matrix[9], matrix[13], matrix[10], matrix[14], - matrix[11], matrix[15]) < errorMargin) ? 0 : 2; + matrix[11], matrix[15]) ? 0 : 2; break; case 3://oxo xox oxo - result += (massOffset(2, 4, + result += balanceCheck(2, matrix[0], matrix[4], matrix[8], matrix[12], - matrix[1], matrix[5], matrix[9], matrix[13]) < errorMargin) ? 0 : 1; - result += (massOffset(4, 2, + matrix[1], matrix[5], matrix[9], matrix[13]) ? 0 : 1; + result += balanceCheck(4, matrix[0], matrix[4], matrix[1], matrix[5], matrix[2], matrix[6], - matrix[3], matrix[7]) < errorMargin) ? 0 : 2; - result += (massOffset(4, 2, + matrix[3], matrix[7]) ? 0 : 2; + result += balanceCheck(4, matrix[8], matrix[12], matrix[9], matrix[13], matrix[10], matrix[14], - matrix[11], matrix[15]) < errorMargin) ? 0 : 4; - result += (massOffset(2, 4, + matrix[11], matrix[15]) ? 0 : 4; + result += balanceCheck(2, matrix[2], matrix[6], matrix[10], matrix[14], - matrix[3], matrix[7], matrix[11], matrix[15]) < errorMargin) ? 0 : 8; + matrix[3], matrix[7], matrix[11], matrix[15]) ? 0 : 8; brea