From 8e3024edfde8317f4f0073842563c45a3cb41ab6 Mon Sep 17 00:00:00 2001 From: basdxz Date: Mon, 6 Jul 2020 17:23:30 +0100 Subject: Add Plasma Boosting to Tesla Towers --- .../technus/tectech/loader/TecTechConfig.java | 22 +++-- .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 100 +++++++++++++++++---- 2 files changed, 99 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java index 0c2920e585..2cc52e8513 100644 --- a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java @@ -24,12 +24,12 @@ public class TecTechConfig extends ConfigManager { public float TESLA_MULTI_MIN_EFFICIENCY; public float TESLA_MULTI_MAX_EFFICIENCY; public float TESLA_MULTI_OVERDRIVE_LOSS; + public int TESLA_MULTI_SCAN_RANGE; + public boolean TESLA_MULTI_MOLTEN_OUTPUT; public float TESLA_SINGLE_MIN_EFFICIENCY; public float TESLA_SINGLE_MAX_EFFICIENCY; public float TESLA_SINGLE_OVERDRIVE_LOSS; - - /** * This loading phases do not correspond to mod loading phases! */ @@ -47,6 +47,8 @@ public class TecTechConfig extends ConfigManager { TESLA_MULTI_MIN_EFFICIENCY = 0.955F; TESLA_MULTI_MAX_EFFICIENCY = 0.98F; TESLA_MULTI_OVERDRIVE_LOSS = 0.005F; + TESLA_MULTI_SCAN_RANGE = 40; + TESLA_MULTI_MOLTEN_OUTPUT = false; TESLA_SINGLE_MIN_EFFICIENCY = 0.91F; TESLA_SINGLE_MAX_EFFICIENCY = 0.95F; TESLA_SINGLE_OVERDRIVE_LOSS = 0.010F; @@ -78,17 +80,21 @@ public class TecTechConfig extends ConfigManager { "Set to true to disable the block hardness nerf"); DISABLE_MATERIAL_LOADING_FFS = _mainConfig.getBoolean("DisableMaterialLoading", "Debug", DISABLE_MATERIAL_LOADING_FFS, "Set to true to disable gregtech material processing"); - TESLA_MULTI_MIN_EFFICIENCY = _mainConfig.getFloat("teslaMultiMinEfficency", "Features", TESLA_MULTI_MIN_EFFICIENCY, 0, 1, + TESLA_MULTI_MIN_EFFICIENCY = _mainConfig.getFloat("TeslaMultiMinEfficency", "Features", TESLA_MULTI_MIN_EFFICIENCY, 0, 1, "Worst possible power loss per block for the multi block tesla"); - TESLA_MULTI_MAX_EFFICIENCY = _mainConfig.getFloat("teslaMultiMaxEfficency", "Features", TESLA_MULTI_MAX_EFFICIENCY, 0, 1, + TESLA_MULTI_MAX_EFFICIENCY = _mainConfig.getFloat("TeslaMultiMaxEfficency", "Features", TESLA_MULTI_MAX_EFFICIENCY, 0, 1, "Best possible power loss per block for the multi block tesla"); - TESLA_MULTI_OVERDRIVE_LOSS = _mainConfig.getFloat("teslaMultiOverdriveLoss", "Features", TESLA_MULTI_OVERDRIVE_LOSS, 0, 1, + TESLA_MULTI_OVERDRIVE_LOSS = _mainConfig.getFloat("TeslaMultiOverdriveLoss", "Features", TESLA_MULTI_OVERDRIVE_LOSS, 0, 1, "Additional losses for overdrive use on the multi block tesla"); - TESLA_SINGLE_MIN_EFFICIENCY = _mainConfig.getFloat("teslaSingleMinEfficency", "Features", TESLA_SINGLE_MIN_EFFICIENCY, 0, 1, + TESLA_MULTI_SCAN_RANGE = _mainConfig.getInt("TeslaMultiScanRange", "Features", TESLA_MULTI_SCAN_RANGE, 4, 256, + "Determines the scan range constant for multi block tesla"); + TESLA_MULTI_MOLTEN_OUTPUT = _mainConfig.getBoolean("TeslaMultiMoltenOutput", "Features", TESLA_MULTI_MOLTEN_OUTPUT, + "Set to true to get molten outputs when boosting the multi block tesla with plasmas"); + TESLA_SINGLE_MIN_EFFICIENCY = _mainConfig.getFloat("TeslaSingleMinEfficency", "Features", TESLA_SINGLE_MIN_EFFICIENCY, 0, 1, "Worst possible power loss per block for the single block tesla"); - TESLA_SINGLE_MAX_EFFICIENCY = _mainConfig.getFloat("teslaSingleMaxEfficency", "Features", TESLA_SINGLE_MAX_EFFICIENCY, 0, 1, + TESLA_SINGLE_MAX_EFFICIENCY = _mainConfig.getFloat("TeslaSingleMaxEfficency", "Features", TESLA_SINGLE_MAX_EFFICIENCY, 0, 1, "Best possible power loss per block for the single block tesla"); - TESLA_SINGLE_OVERDRIVE_LOSS = _mainConfig.getFloat("teslaSingleOverdriveLoss", "Features", TESLA_SINGLE_OVERDRIVE_LOSS, 0, 1, + TESLA_SINGLE_OVERDRIVE_LOSS = _mainConfig.getFloat("TeslaSingleOverdriveLoss", "Features", TESLA_SINGLE_OVERDRIVE_LOSS, 0, 1, "Additional losses for overdrive use on the single block tesla"); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 89093bdba7..dac8800894 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -23,6 +23,7 @@ import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.util.Vec3Impl; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -33,6 +34,7 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; import java.util.HashMap; @@ -57,20 +59,24 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; - + //TODO Make the setting abstractions static, if they aren't changed at tick time private int mTier = 0; //Determines max voltage and efficiency (MV to LuV) private int maxTier = 6; //Max tier for efficiency calcuation + private int plasmaTier = 0; //0 is None, 1 is Helium or Nitrogen, 2 is Radon + private boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_MOLTEN_OUTPUT; //Default is false + private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs for one second private float energyEfficiency = 1; private float overdriveEfficiency = 1; private float minEfficiency = TecTech.configTecTech.TESLA_MULTI_MIN_EFFICIENCY;//Default is 0.955F - private float maxEfficiency = TecTech.configTecTech.TESLA_MULTI_MAX_EFFICIENCY;//Default is 0.98F; + private float maxEfficiency = TecTech.configTecTech.TESLA_MULTI_MAX_EFFICIENCY;//Default is 0.98F private float overdriveEfficiencyExtra = TecTech.configTecTech.TESLA_MULTI_OVERDRIVE_LOSS;//Default is 0.005F private Map eTeslaMap = new HashMap<>(); //Used to store targets for power transmission private final ArrayList eCapacitorHatches = new ArrayList<>(); //Used to determine count and tier of capacitors present private int scanTime = 0; //Scan timer used for tesla search intervals + private int scanRangeXZ = TecTech.configTecTech.TESLA_MULTI_SCAN_RANGE;//Default is 40 private long energyCapacity = 0; //Total energy storage limited by capacitors private long outputVoltageMax = 0; //Tesla voltage output limited by capacitors @@ -254,11 +260,25 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } private float getRangeMulti(int mTier, int vTier) { + //Helium and Nitrogen Plasmas will double the range + //Radon will quadruple the range + int plasmaBoost; + switch (plasmaTier) { + case 2: + plasmaBoost = 4; + break; + case 1: + plasmaBoost = 2; + break; + default: + plasmaBoost = 1; + } + //Over-tiered coils will add +25% range if (vTier > mTier) { - return 1.25F; + return 1.25F * plasmaBoost; } - return 1F; + return 1F * plasmaBoost; } private void scanForTransmissionTargets(Vec3Impl coordsMin, Vec3Impl coordsMax) { @@ -302,6 +322,46 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock sparkList.add(new ThaumSpark(posTop.get0(), posTop.get1(), posTop.get2(), xR, yR, zR, wID)); } + private void checkPlasmaBoost() { + //If there's fluid in the queue, try to output it + //That way it takes at least a second to 'process' the plasma + if (mOutputFluidsQueue != null) { + mOutputFluids = mOutputFluidsQueue; + mOutputFluidsQueue = null; + } + + for (GT_MetaTileEntity_Hatch_Input fluidHatch : mInputHatches) { + if (fluidHatch.mFluid != null) { + if (fluidHatch.mFluid.isFluidEqual(Materials.Helium.getPlasma(1)) && fluidHatch.mFluid.amount >= 100) { + System.out.print("HELIUM\n"); + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 100; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[]{Materials.Helium.getGas(100)}; + } + plasmaTier = 1; + return; + } else if (fluidHatch.mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) && fluidHatch.mFluid.amount >= 50) { + System.out.print("NITRO\n"); + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 50; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[]{Materials.Nitrogen.getGas(50)}; + } + plasmaTier = 1; + return; + } else if (fluidHatch.mFluid.isFluidEqual(Materials.Radon.getPlasma(1)) && fluidHatch.mFluid.amount >= 50) { + System.out.print("RADON\n"); + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 50; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[]{Materials.Radon.getGas(50)}; + } + plasmaTier = 2; + return; + } + } + } + plasmaTier = 0; + } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_TM_teslaCoil(mName); @@ -340,20 +400,20 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock posTop = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -14, 2)).add(getBaseMetaTileEntity()); //Calculate offsets for scanning - scanPosOffsets[0] = getExtendedFacing().getWorldOffset(new Vec3Impl(40, 0, 43)); - scanPosOffsets[1] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -4, -37)); + scanPosOffsets[0] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, 0, scanRangeXZ + 3)); + scanPosOffsets[1] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -4, -1 * scanRangeXZ + 3)); - scanPosOffsets[2] = getExtendedFacing().getWorldOffset(new Vec3Impl(40, -5, 43)); - scanPosOffsets[3] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -8, -37)); + scanPosOffsets[2] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, -5, scanRangeXZ + 3)); + scanPosOffsets[3] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -8, -1 * scanRangeXZ + 3)); - scanPosOffsets[4] = getExtendedFacing().getWorldOffset(new Vec3Impl(40, -9, 43)); - scanPosOffsets[5] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -12, -37)); + scanPosOffsets[4] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, -9, scanRangeXZ + 3)); + scanPosOffsets[5] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -12, -1 * scanRangeXZ + 3)); - scanPosOffsets[6] = getExtendedFacing().getWorldOffset(new Vec3Impl(40, -13, 43)); - scanPosOffsets[7] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -16, -37)); + scanPosOffsets[6] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, -13, scanRangeXZ + 3)); + scanPosOffsets[7] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -16, -1 * scanRangeXZ + 3)); - scanPosOffsets[8] = getExtendedFacing().getWorldOffset(new Vec3Impl(40, -17, 43)); - scanPosOffsets[9] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -20, -37)); + scanPosOffsets[8] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, -17, scanRangeXZ + 3)); + scanPosOffsets[9] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -20, -1 * scanRangeXZ + 3)); } return true; } @@ -362,6 +422,8 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock @Override public boolean checkRecipe_EM(ItemStack itemStack) { + checkPlasmaBoost(); + if (!histHighSetting.getStatus(false).isOk || !histLowSetting.getStatus(false).isOk || !transferRadiusTowerSetting.getStatus(false).isOk || @@ -825,6 +887,14 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); + } return false; } @@ -841,4 +911,4 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock public String[] getStructureDescription(ItemStack stackSize) { return description; } -} \ No newline at end of file +} -- cgit From 3b388cd947255ccef57215862591228cb4421997 Mon Sep 17 00:00:00 2001 From: basdxz Date: Sat, 11 Jul 2020 13:37:02 +0100 Subject: Plasma range boosting now helps with loss Very generous imo, might need to be scaled back --- .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index dac8800894..5ae1d86895 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -252,10 +252,22 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } private long getEnergyEfficiency(long voltage, int distance, boolean overDriveToggle) { + //Helium and Nitrogen Plasmas will half the effective distance + //Radon will half it again + int effectiveDistance = distance; + switch (plasmaTier) { + case 2: + effectiveDistance = distance / 4; + break; + case 1: + effectiveDistance = distance / 2; + break; + } + if (overDriveToggle) { - return (long) ((voltage * 2) - (voltage * Math.pow(overdriveEfficiency, distance))); + return (long) ((voltage * 2) - (voltage * Math.pow(overdriveEfficiency, effectiveDistance))); } else { - return (long) (voltage * Math.pow(energyEfficiency, distance)); + return (long) (voltage * Math.pow(energyEfficiency, effectiveDistance)); } } @@ -333,7 +345,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock for (GT_MetaTileEntity_Hatch_Input fluidHatch : mInputHatches) { if (fluidHatch.mFluid != null) { if (fluidHatch.mFluid.isFluidEqual(Materials.Helium.getPlasma(1)) && fluidHatch.mFluid.amount >= 100) { - System.out.print("HELIUM\n"); fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 100; if (doFluidOutput) { mOutputFluidsQueue = new FluidStack[]{Materials.Helium.getGas(100)}; @@ -341,7 +352,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock plasmaTier = 1; return; } else if (fluidHatch.mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) && fluidHatch.mFluid.amount >= 50) { - System.out.print("NITRO\n"); fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 50; if (doFluidOutput) { mOutputFluidsQueue = new FluidStack[]{Materials.Nitrogen.getGas(50)}; @@ -349,7 +359,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock plasmaTier = 1; return; } else if (fluidHatch.mFluid.isFluidEqual(Materials.Radon.getPlasma(1)) && fluidHatch.mFluid.amount >= 50) { - System.out.print("RADON\n"); fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 50; if (doFluidOutput) { mOutputFluidsQueue = new FluidStack[]{Materials.Radon.getGas(50)}; @@ -450,6 +459,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock //Calculate Efficiency values energyEfficiency = map(mTier + 1, 1, maxTier, minEfficiency, maxEfficiency); + //OD Eff calc overdriveEfficiency = energyEfficiency - overdriveEfficiencyExtra; energyCapacity = 0; -- cgit From 011cfd255f5324dad9cf53e4efe1b0c455257152 Mon Sep 17 00:00:00 2001 From: basdxz Date: Sat, 11 Jul 2020 13:38:09 +0100 Subject: Expand Tesla tiers We now have ZPM Tier primary coils and LuV and ZPM tier capacitors, props to the madlads at the BigFlex MegaPlex for planning on using it with their fusion reactors --- .../dreamcraft/DreamCraftRecipeLoader.java | 27 +++++++++++++++- .../tectech/loader/recipe/BloodyRecipeLoader.java | 22 +++++++++++++ .../technus/tectech/thing/CustomItemList.java | 2 +- .../tectech/thing/casing/GT_Block_CasingsBA0.java | 35 ++++++++++++++------- .../tectech/thing/casing/GT_Item_CasingsBA0.java | 4 +++ .../tectech/thing/item/TeslaCoilCapacitor.java | 14 ++++++--- .../hatch/GT_MetaTileEntity_Hatch_Capacitor.java | 18 +++++------ .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 10 ++++-- .../iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_6.png | Bin 0 -> 814 bytes .../TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_6.png | Bin 0 -> 838 bytes src/main/resources/assets/tectech/lang/en_US.lang | 3 ++ .../tectech/textures/items/itemCapacitorLuV.png | Bin 0 -> 570 bytes .../tectech/textures/items/itemCapacitorZPM.png | Bin 0 -> 563 bytes 13 files changed, 106 insertions(+), 29 deletions(-) create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_6.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_6.png create mode 100644 src/main/resources/assets/tectech/textures/items/itemCapacitorLuV.png create mode 100644 src/main/resources/assets/tectech/textures/items/itemCapacitorZPM.png diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java index b669165176..748888c5c9 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java @@ -224,7 +224,12 @@ public class DreamCraftRecipeLoader implements Runnable { GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorLuV, 8), getItemContainer("MicaInsulatorFoil").get(28) - }, Materials.Indium.getMolten(144), CustomItemList.tM_TeslaPrimary_5.get(1), 50, 30720); + }, Materials.Indium.getMolten(144), CustomItemList.tM_TeslaPrimary_5.get(1), 200, 30720); + //Tesla Primary Coils T6 + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ + GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.SuperconductorZPM, 8), + getItemContainer("MicaInsulatorFoil").get(32) + }, Materials.Naquadah.getMolten(144), CustomItemList.tM_TeslaPrimary_6.get(1), 200, 122880); //endregion @@ -1599,6 +1604,20 @@ public class DreamCraftRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 24), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 24), }, Materials.Epoxid.getMolten(360), CustomItemList.teslaCapacitor.getWithDamage(1, 4), 320, 7680); + //LuV Tesla Capacitor + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ + GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.HSSG, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 14), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 28), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 28), + }, Materials.Epoxid.getMolten(432), CustomItemList.teslaCapacitor.getWithDamage(1, 5), 320, 30720); + //ZPM Tesla Capacitor + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ + GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Naquadah, 4), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 16), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 32), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 32), + }, Materials.Epoxid.getMolten(504), CustomItemList.teslaCapacitor.getWithDamage(1, 6), 320, 122880); //Tesla Cover GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ CustomItemList.teslaComponent.getWithDamage(4, 0), @@ -1663,6 +1682,12 @@ public class DreamCraftRecipeLoader implements Runnable { //IV Tesla Capacitor GT_Values.RA.addExtractorRecipe(CustomItemList.teslaCapacitor.getWithDamage(1, 4), GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 12), 300, 2); + //LuV Tesla Capacitor + GT_Values.RA.addExtractorRecipe(CustomItemList.teslaCapacitor.getWithDamage(1, 5), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 14), 300, 2); + //ZPM Tesla Capacitor + GT_Values.RA.addExtractorRecipe(CustomItemList.teslaCapacitor.getWithDamage(1, 6), + GT_OreDictUnificator.get(OrePrefixes.itemCasing, Materials.BatteryAlloy, 16), 300, 2); //endregion diff --git a/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java index 70f64d3719..7b8cc14f4d 100644 --- a/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/recipe/BloodyRecipeLoader.java @@ -191,6 +191,7 @@ public class BloodyRecipeLoader implements Runnable { GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"WWW", "WwW", "WWW", 'W', OrePrefixes.wireGt02.get(Materials.Superconductor)}); + //TODO Add Tesla Primary Coils T6 //endregion @@ -1157,6 +1158,21 @@ public class BloodyRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 24), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 24), }, Materials.Epoxid.getMolten(360), CustomItemList.teslaCapacitor.getWithDamage(1, 4), 320, 7680); + //LuV Tesla Capacitor + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ + GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.HSSG, 4), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BatteryAlloy, 14), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 28), + GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 28), + }, Materials.Epoxid.getMolten(432), CustomItemList.teslaCapacitor.getWithDamage(1, 5), 320, 30720); + //ZPM Tesla Capacitor + //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ + // GT_OreDictUnificator.get(OrePrefixes.cableGt01, Materials.Naquadah, 4), + // GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BatteryAlloy, 16), + // GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Aluminium, 32), + // GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 32), + //}, Materials.Epoxid.getMolten(504), CustomItemList.teslaCapacitor.getWithDamage(1, 6), 320, 122880); + //TODO Allow with the coils, useless alone and will only cause trouble //Tesla Cover GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ CustomItemList.teslaComponent.getWithDamage(4, 0), @@ -1221,6 +1237,12 @@ public class BloodyRecipeLoader implements Runnable { //IV Tesla Capacitor GT_Values.RA.addExtractorRecipe(CustomItemList.teslaCapacitor.getWithDamage(1, 4), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BatteryAlloy, 12), 300, 2); + //LuV Tesla Capacitor + GT_Values.RA.addExtractorRecipe(CustomItemList.teslaCapacitor.getWithDamage(1, 5), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BatteryAlloy, 14), 300, 2); + //ZPM Tesla Capacitor + GT_Values.RA.addExtractorRecipe(CustomItemList.teslaCapacitor.getWithDamage(1, 6), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BatteryAlloy, 16), 300, 2); //endregion 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 5265ad25c6..a86695ff4a 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -78,7 +78,7 @@ public enum CustomItemList implements IItemContainer { eM_Containment, eM_Containment_Field, eM_Containment_Advanced, eM_Coil, eM_Teleportation, eM_Dimensional, eM_Ultimate_Containment, eM_Ultimate_Containment_Advanced, eM_Ultimate_Containment_Field, eM_Spacetime, eM_Computer_Casing, eM_Computer_Bus, eM_Computer_Vent, eM_Hollow, eM_Power, debugBlock, - tM_TeslaBase, tM_TeslaToroid, tM_TeslaSecondary, tM_TeslaPrimary_0, tM_TeslaPrimary_1, tM_TeslaPrimary_2, tM_TeslaPrimary_3, tM_TeslaPrimary_4, tM_TeslaPrimary_5, + tM_TeslaBase, tM_TeslaToroid, tM_TeslaSecondary, tM_TeslaPrimary_0, tM_TeslaPrimary_1, tM_TeslaPrimary_2, tM_TeslaPrimary_3, tM_TeslaPrimary_4, tM_TeslaPrimary_5, tM_TeslaPrimary_6, Machine_Multi_Microwave, Machine_Multi_TeslaCoil, Machine_Multi_Transformer, diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java index 6d5bcd2b04..823f9ae26e 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java @@ -23,8 +23,8 @@ import static com.github.technus.tectech.TecTech.tectechTexturePage1; * Created by danie_000 on 03.10.2016. */ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { - public static final byte texturePage=tectechTexturePage1; - public static final short textureOffset = (texturePage << 7)+16;//Start of PAGE 8 (which is the 9th page) (8*128)+16 + public static final byte texturePage = tectechTexturePage1; + public static final short textureOffset = (texturePage << 7) + 16;//Start of PAGE 8 (which is the 9th page) (8*128)+16 private static IIcon[] tM0 = new IIcon[2]; private static IIcon[] tM1 = new IIcon[2]; @@ -35,11 +35,12 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { private static IIcon[] tM6 = new IIcon[2]; private static IIcon tM7; private static IIcon[] tM8 = new IIcon[2]; + private static IIcon[] tM9 = new IIcon[2]; public GT_Block_CasingsBA0() { super(GT_Item_CasingsBA0.class, "gt.blockcasingsBA0", GT_Material_Casings.INSTANCE); for (byte b = 0; b < 16; b = (byte) (b + 1)) { - Textures.BlockIcons.casingTexturePages[texturePage][b+16] = new GT_CopiedBlockTexture(this, 6, b); + Textures.BlockIcons.casingTexturePages[texturePage][b + 16] = new GT_CopiedBlockTexture(this, 6, b); /*IMPORTANT for block recoloring**/ } @@ -49,6 +50,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "EV Superconductor Primary Tesla Windings"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "IV Superconductor Primary Tesla Windings"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "LuV Superconductor Primary Tesla Windings"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "ZPM Superconductor Primary Tesla Windings"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Tesla Base Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Tesla Toroid Casing"); @@ -60,6 +62,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { CustomItemList.tM_TeslaPrimary_3.set(new ItemStack(this, 1, 3)); CustomItemList.tM_TeslaPrimary_4.set(new ItemStack(this, 1, 4)); CustomItemList.tM_TeslaPrimary_5.set(new ItemStack(this, 1, 5)); + CustomItemList.tM_TeslaPrimary_6.set(new ItemStack(this, 1, 9)); CustomItemList.tM_TeslaBase.set(new ItemStack(this, 1, 6)); CustomItemList.tM_TeslaToroid.set(new ItemStack(this, 1, 7)); @@ -80,6 +83,8 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { tM4[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_4"); tM5[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_5"); tM5[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_5"); + tM9[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_6"); + tM9[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_6"); tM6[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_BASE_TOP_BOTTOM"); tM6[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_BASE_SIDES"); @@ -92,7 +97,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { public IIcon getIcon(int aSide, int aMeta) { switch (aMeta) { case 0: - switch (aSide){ + switch (aSide) { case 0: case 1: return tM0[0]; @@ -100,7 +105,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { return tM0[1]; } case 1: - switch (aSide){ + switch (aSide) { case 0: case 1: return tM1[0]; @@ -108,7 +113,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { return tM1[1]; } case 2: - switch (aSide){ + switch (aSide) { case 0: case 1: return tM2[0]; @@ -116,7 +121,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { return tM2[1]; } case 3: - switch (aSide){ + switch (aSide) { case 0: case 1: return tM3[0]; @@ -124,7 +129,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { return tM3[1]; } case 4: - switch (aSide){ + switch (aSide) { case 0: case 1: return tM4[0]; @@ -132,7 +137,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { return tM4[1]; } case 5: - switch (aSide){ + switch (aSide) { case 0: case 1: return tM5[0]; @@ -140,7 +145,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { return tM5[1]; } case 6: - switch (aSide){ + switch (aSide) { case 0: case 1: return tM6[0]; @@ -150,13 +155,21 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { case 7: return tM7; case 8: - switch (aSide){ + switch (aSide) { case 0: case 1: return tM8[0]; default: return tM8[1]; } + case 9: + switch (aSide) { + case 0: + case 1: + return tM9[0]; + default: + return tM9[1]; + } default: return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); } diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsBA0.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsBA0.java index 56fdfd22bb..50630820df 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsBA0.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsBA0.java @@ -45,6 +45,10 @@ public class GT_Item_CasingsBA0 extends GT_Item_Casings_Abstract { aList.add(translateToLocal("gt.blockcasingsBA0.8.desc.0"));//Picks up power from a primary coil aList.add(EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.8.desc.1"));//Who wouldn't want a 32k epoxy multi? break; + case 9://"ZPM Superconductor Primary Tesla Windings" + aList.add(translateToLocal("gt.blockcasingsBA0.0.desc.0") + " " + V[7] + " EU/t");//Handles up to + aList.add(EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.0.desc.1"));//What one man calls God, another calls the laws of physics. + break; default://WTF? aList.add("Damn son where did you get that!?"); aList.add(EnumChatFormatting.BLUE.toString() + "From outer space... I guess..."); diff --git a/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java index 6e7e8c426d..86982e7c09 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java +++ b/src/main/java/com/github/technus/tectech/thing/item/TeslaCoilCapacitor.java @@ -22,7 +22,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; public final class TeslaCoilCapacitor extends Item { public static TeslaCoilCapacitor INSTANCE; - private static IIcon LVicon, MVicon, HVicon, EVicon, IVicon; + private static IIcon LVicon, MVicon, HVicon, EVicon, IVicon, LuVicon, ZPMicon; private TeslaCoilCapacitor() { setHasSubtypes(true); @@ -33,8 +33,8 @@ public final class TeslaCoilCapacitor extends Item { @Override public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { aList.add(CommonValues.BASS_MARK); - if (aStack.getItemDamage() >= 0 && aStack.getItemDamage() <= 4) { - aList.add(translateToLocal("item.tm.teslaCoilCapacitor.desc.0") + " " + V[aStack.getItemDamage() + 1] * 512 + " " + translateToLocal("item.tm.teslaCoilCapacitor.desc.1") +" " + V[aStack.getItemDamage() + 1] + " EU/t");//Stores 16384 EU in a tesla tower at 32 EU/t + if (aStack.getItemDamage() >= 0 && aStack.getItemDamage() <= 6) { + aList.add(translateToLocal("item.tm.teslaCoilCapacitor.desc.0") + " " + V[aStack.getItemDamage() + 1] * 512 + " " + translateToLocal("item.tm.teslaCoilCapacitor.desc.1") + " " + V[aStack.getItemDamage() + 1] + " EU/t");//Stores 16384 EU in a tesla tower at 32 EU/t } else { aList.add(translateToLocal("item.tm.teslaCoilCapacitor.desc.2"));//Yeet this broken item into some spicy water! } @@ -61,6 +61,8 @@ public final class TeslaCoilCapacitor extends Item { HVicon = iconRegister.registerIcon(MODID + ":itemCapacitorHV"); EVicon = iconRegister.registerIcon(MODID + ":itemCapacitorEV"); IVicon = iconRegister.registerIcon(MODID + ":itemCapacitorIV"); + LuVicon = iconRegister.registerIcon(MODID + ":itemCapacitorLuV"); + ZPMicon = iconRegister.registerIcon(MODID + ":itemCapacitorZPM"); } @Override @@ -74,6 +76,10 @@ public final class TeslaCoilCapacitor extends Item { return EVicon; case 4: return IVicon; + case 5: + return LuVicon; + case 6: + return ZPMicon; default: return LVicon; } @@ -81,7 +87,7 @@ public final class TeslaCoilCapacitor extends Item { @Override public void getSubItems(Item aItem, CreativeTabs par2CreativeTabs, List aList) { - for (int i = 0; i <= 4; i++) { + for (int i = 0; i <= 6; i++) { aList.add(new ItemStack(aItem, 1, i)); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java index b4e8f03a74..4e07622c25 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Capacitor.java @@ -38,7 +38,7 @@ public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Capacitor(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 16, ""); - Util.setTier(aTier,this); + Util.setTier(aTier, this); } public GT_MetaTileEntity_Hatch_Capacitor(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -173,11 +173,13 @@ public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch { } public static void run() { - new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID+":item.tm.teslaCoilCapacitor.0", 0, 1, V[1]*512);//LV Capacitor - new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID+":item.tm.teslaCoilCapacitor.1", 1, 1, V[2]*512);//MV Capacitor - new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID+":item.tm.teslaCoilCapacitor.2", 2, 1, V[3]*512);//HV Capacitor - new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID+":item.tm.teslaCoilCapacitor.3", 3, 1, V[4]*512);//EV Capacitor - new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID+":item.tm.teslaCoilCapacitor.4", 4, 1, V[5]*512);//IV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.0", 0, 1, V[1] * 512);//LV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.1", 1, 1, V[2] * 512);//MV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.2", 2, 1, V[3] * 512);//HV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.3", 3, 1, V[4] * 512);//EV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.4", 4, 1, V[5] * 512);//IV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.5", 5, 1, V[6] * 512);//LuV Capacitor + new GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.6", 6, 1, V[7] * 512);//ZPM Capacitor } public static class CapacitorComponent implements Comparable { @@ -206,12 +208,10 @@ public class GT_MetaTileEntity_Hatch_Capacitor extends GT_MetaTileEntity_Hatch { @Override public boolean equals(Object obj) { - if(obj instanceof CapacitorComponent) { + if (obj instanceof CapacitorComponent) { return compareTo((CapacitorComponent) obj) == 0; } return false; } } } - - diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 5ae1d86895..58ea6d322b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -61,7 +61,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private static Textures.BlockIcons.CustomIcon ScreenON; //TODO Make the setting abstractions static, if they aren't changed at tick time private int mTier = 0; //Determines max voltage and efficiency (MV to LuV) - private int maxTier = 6; //Max tier for efficiency calcuation + private int maxTier = 7; //Max tier for efficiency calcuation private int plasmaTier = 0; //0 is None, 1 is Helium or Nitrogen, 2 is Radon private boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_MOLTEN_OUTPUT; //Default is false private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs for one second @@ -110,7 +110,8 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private static final byte[] blockMetaT3 = new byte[]{7, 3, 6, 8}; private static final byte[] blockMetaT4 = new byte[]{7, 4, 6, 8}; private static final byte[] blockMetaT5 = new byte[]{7, 5, 6, 8}; - private static final byte[][] blockMetas = new byte[][]{blockMetaT0, blockMetaT1, blockMetaT2, blockMetaT3, blockMetaT4, blockMetaT5}; + private static final byte[] blockMetaT6 = new byte[]{7, 9, 6, 8}; + private static final byte[][] blockMetas = new byte[][]{blockMetaT0, blockMetaT1, blockMetaT2, blockMetaT3, blockMetaT4, blockMetaT5, blockMetaT6}; private static final IHatchAdder[] addingMethods = adders( GT_MetaTileEntity_TM_teslaCoil::addCapacitorToMachineList, GT_MetaTileEntity_TM_teslaCoil::addFrameToMachineList); @@ -389,6 +390,9 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -1, 1)); mTier = iGregTechTileEntity.getMetaIDOffset(xyzOffsets.get0(), xyzOffsets.get1(), xyzOffsets.get2()); + if (mTier == 9){ + mTier = 6; + } if (structureCheck_EM(shape, blockType, blockMetas[mTier], addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 3, 16, 0) && eCapacitorHatches.size() > 0) { for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) { @@ -914,7 +918,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - Structure.builder(shape, blockType, blockMetas[(stackSize.stackSize - 1) % 6], 3, 16, 0, getBaseMetaTileEntity(), getExtendedFacing(), hintsOnly); + Structure.builder(shape, blockType, blockMetas[(stackSize.stackSize - 1) % 7], 3, 16, 0, getBaseMetaTileEntity(), getExtendedFacing(), hintsOnly); } @Override diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_6.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_6.png new file mode 100644 index 0000000000..833597130b Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_6.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_6.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_6.png new file mode 100644 index 0000000000..de4ce136e7 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_6.png differ diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 3b8bc433ed..dc4af9970b 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -64,6 +64,8 @@ item.tm.teslaCoilCapacitor.1.name=MV Tesla Capacitor item.tm.teslaCoilCapacitor.2.name=HV Tesla Capacitor item.tm.teslaCoilCapacitor.3.name=EV Tesla Capacitor item.tm.teslaCoilCapacitor.4.name=IV Tesla Capacitor +item.tm.teslaCoilCapacitor.5.name=LuV Tesla Capacitor +item.tm.teslaCoilCapacitor.6.name=ZPM Tesla Capacitor item.tm.teslaCoilCapacitor.desc.0=Stores item.tm.teslaCoilCapacitor.desc.1=EU in a tesla tower at item.tm.teslaCoilCapacitor.desc.2=Yeet this broken item into some spicy water! @@ -518,6 +520,7 @@ gt.blockcasingsBA0.2.name=HV Superconductor Primary Tesla Windings gt.blockcasingsBA0.3.name=EV Superconductor Primary Tesla Windings gt.blockcasingsBA0.4.name=IV Superconductor Primary Tesla Windings gt.blockcasingsBA0.5.name=LuV Superconductor Primary Tesla Windings +gt.blockcasingsBA0.9.name=ZPM Superconductor Primary Tesla Windings gt.blockcasingsBA0.0.desc.0=Handles up to gt.blockcasingsBA0.0.desc.1=What one man calls God, another calls the laws of physics. gt.blockcasingsBA0.6.name=Tesla Base Casing diff --git a/src/main/resources/assets/tectech/textures/items/itemCapacitorLuV.png b/src/main/resources/assets/tectech/textures/items/itemCapacitorLuV.png new file mode 100644 index 0000000000..0801e3f0d7 Binary files /dev/null and b/src/main/resources/assets/tectech/textures/items/itemCapacitorLuV.png differ diff --git a/src/main/resources/assets/tectech/textures/items/itemCapacitorZPM.png b/src/main/resources/assets/tectech/textures/items/itemCapacitorZPM.png new file mode 100644 index 0000000000..29b30dc63e Binary files /dev/null and b/src/main/resources/assets/tectech/textures/items/itemCapacitorZPM.png differ -- cgit From 5b9d907a4e098d8b765c13c411ba0ea5225267aa Mon Sep 17 00:00:00 2001 From: basdxz Date: Sat, 11 Jul 2020 13:39:58 +0100 Subject: Bump the version Added Plasma Boosting to Tesla Tower Works with Nitrogen and Helium 100mb Helium per second 50mb Nitrogen per second 50mb Radon per second Helium and Nitrogen boost max range by 2x Radon by 4x The max scan range hasn't been changed, but i pushed it into the config would suggest setting to 64 there if you want more than 40 In addition By default it just voids the plasma There is a config to make it output fluid instead idk im coder not a gayme play balance lad so you should play with it also unsure of the plasma values are low/high please give input Added ZPM Primary Tesla Coils Added LuV Telsa Capacitors Added ZPM Tesla Capacitors All above with recipes Tesla range related losses now halfed when using Nitrogen or Helium and Quartered when using Radon plasma Current bugginess, power sent may or may not be once a second instead of once a tick. Additionally multi amp per source transmission might be messed up The bugginess was due to the capacitor tiering not being configured, EG LuV and IV capacitors working at IV tier. Has since been fixed. --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 3b282b43c2..b377db8b58 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614 -tectech.version=3.8.3 +tectech.version=3.9.0 ic2.version=2.2.790-experimental codechickenlib.version=1.1.3.140 -- cgit From 792d54ffa2fde437a3af9925c7c41399821b2d83 Mon Sep 17 00:00:00 2001 From: basdxz Date: Sat, 11 Jul 2020 13:51:59 +0100 Subject: Patch ZPM Tesla Primaries missing from NEI --- build.properties | 2 +- .../com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.properties b/build.properties index b377db8b58..90269e3abe 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614 -tectech.version=3.9.0 +tectech.version=3.9.1 ic2.version=2.2.790-experimental codechickenlib.version=1.1.3.140 diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java index 823f9ae26e..0d2f710ae9 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsBA0.java @@ -184,7 +184,7 @@ public class GT_Block_CasingsBA0 extends GT_Block_Casings_Abstract { @Override public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { - for (int i = 0; i <= 8; i++) { + for (int i = 0; i <= 9; i++) { aList.add(new ItemStack(aItem, 1, i)); } } -- cgit From d895a4f85ae7edad8884c5ded8c29ff47bbb8de9 Mon Sep 17 00:00:00 2001 From: basdxz Date: Sat, 18 Jul 2020 09:38:35 +0100 Subject: Lots of Tesla Tower work Reworked power loss Fixed Tesla Tower exploding when already powered off Added and reworded some comments Added plasma consumption values to config --- .../technus/tectech/loader/TecTechConfig.java | 65 +++++------ .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 119 ++++++++++----------- .../single/GT_MetaTileEntity_TeslaCoil.java | 64 ++++++----- 3 files changed, 119 insertions(+), 129 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java index 2cc52e8513..030be65f3b 100644 --- a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java @@ -21,14 +21,17 @@ public class TecTechConfig extends ConfigManager { public boolean DISABLE_BLOCK_HARDNESS_NERF; public float TURRET_DAMAGE_FACTOR; public float TURRET_EXPLOSION_FACTOR; - public float TESLA_MULTI_MIN_EFFICIENCY; - public float TESLA_MULTI_MAX_EFFICIENCY; - public float TESLA_MULTI_OVERDRIVE_LOSS; - public int TESLA_MULTI_SCAN_RANGE; - public boolean TESLA_MULTI_MOLTEN_OUTPUT; - public float TESLA_SINGLE_MIN_EFFICIENCY; - public float TESLA_SINGLE_MAX_EFFICIENCY; - public float TESLA_SINGLE_OVERDRIVE_LOSS; + public int TESLA_MULTI_HELIUM_PLASMA_PER_SECOND; + public int TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND; + public int TESLA_MULTI_RADON_PLASMA_PER_SECOND; + public int TESLA_MULTI_LOSS_PER_BLOCK_T0; + public int TESLA_MULTI_LOSS_PER_BLOCK_T1; + public int TESLA_MULTI_LOSS_PER_BLOCK_T2; + public float TESLA_MULTI_OVERDRIVE_LOSS_FACTOR; + public int TESLA_MULTI_SCAN_RANGE;//TODO delete + public boolean TESLA_MULTI_GAS_OUTPUT; + public int TESLA_SINGLE_LOSS_PER_BLOCK; + public float TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR; /** * This loading phases do not correspond to mod loading phases! @@ -44,17 +47,19 @@ public class TecTechConfig extends ConfigManager { DISABLE_MATERIAL_LOADING_FFS = false; TURRET_DAMAGE_FACTOR = 10; TURRET_EXPLOSION_FACTOR = 1; - TESLA_MULTI_MIN_EFFICIENCY = 0.955F; - TESLA_MULTI_MAX_EFFICIENCY = 0.98F; - TESLA_MULTI_OVERDRIVE_LOSS = 0.005F; + TESLA_MULTI_HELIUM_PLASMA_PER_SECOND = 100; + TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND = 50; + TESLA_MULTI_RADON_PLASMA_PER_SECOND = 50; + TESLA_MULTI_LOSS_PER_BLOCK_T0 = 1; + TESLA_MULTI_LOSS_PER_BLOCK_T1 = 1; + TESLA_MULTI_LOSS_PER_BLOCK_T2 = 1; + TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = 0.25F; TESLA_MULTI_SCAN_RANGE = 40; - TESLA_MULTI_MOLTEN_OUTPUT = false; - TESLA_SINGLE_MIN_EFFICIENCY = 0.91F; - TESLA_SINGLE_MAX_EFFICIENCY = 0.95F; - TESLA_SINGLE_OVERDRIVE_LOSS = 0.010F; + TESLA_MULTI_GAS_OUTPUT = false; + TESLA_SINGLE_LOSS_PER_BLOCK = 1; + TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = 0.25F; } - /** * This loading phases do not correspond to mod loading phases! */ @@ -80,22 +85,18 @@ public class TecTechConfig extends ConfigManager { "Set to true to disable the block hardness nerf"); DISABLE_MATERIAL_LOADING_FFS = _mainConfig.getBoolean("DisableMaterialLoading", "Debug", DISABLE_MATERIAL_LOADING_FFS, "Set to true to disable gregtech material processing"); - TESLA_MULTI_MIN_EFFICIENCY = _mainConfig.getFloat("TeslaMultiMinEfficency", "Features", TESLA_MULTI_MIN_EFFICIENCY, 0, 1, - "Worst possible power loss per block for the multi block tesla"); - TESLA_MULTI_MAX_EFFICIENCY = _mainConfig.getFloat("TeslaMultiMaxEfficency", "Features", TESLA_MULTI_MAX_EFFICIENCY, 0, 1, - "Best possible power loss per block for the multi block tesla"); - TESLA_MULTI_OVERDRIVE_LOSS = _mainConfig.getFloat("TeslaMultiOverdriveLoss", "Features", TESLA_MULTI_OVERDRIVE_LOSS, 0, 1, - "Additional losses for overdrive use on the multi block tesla"); - TESLA_MULTI_SCAN_RANGE = _mainConfig.getInt("TeslaMultiScanRange", "Features", TESLA_MULTI_SCAN_RANGE, 4, 256, - "Determines the scan range constant for multi block tesla"); - TESLA_MULTI_MOLTEN_OUTPUT = _mainConfig.getBoolean("TeslaMultiMoltenOutput", "Features", TESLA_MULTI_MOLTEN_OUTPUT, - "Set to true to get molten outputs when boosting the multi block tesla with plasmas"); - TESLA_SINGLE_MIN_EFFICIENCY = _mainConfig.getFloat("TeslaSingleMinEfficency", "Features", TESLA_SINGLE_MIN_EFFICIENCY, 0, 1, - "Worst possible power loss per block for the single block tesla"); - TESLA_SINGLE_MAX_EFFICIENCY = _mainConfig.getFloat("TeslaSingleMaxEfficency", "Features", TESLA_SINGLE_MAX_EFFICIENCY, 0, 1, - "Best possible power loss per block for the single block tesla"); - TESLA_SINGLE_OVERDRIVE_LOSS = _mainConfig.getFloat("TeslaSingleOverdriveLoss", "Features", TESLA_SINGLE_OVERDRIVE_LOSS, 0, 1, - "Additional losses for overdrive use on the single block tesla"); + + TESLA_MULTI_HELIUM_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiHeliumPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_HELIUM_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower helium plasma consumed each second the tesla tower is active"); + TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiNitrogenPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower nitrogen plasma consumed each second the tesla tower is active"); + TESLA_MULTI_RADON_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiRadonPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_RADON_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower radon plasma consumed each second the tesla tower is active"); + TESLA_MULTI_LOSS_PER_BLOCK_T0 = _mainConfig.getInt("TeslaMultiLossPerBlockT0", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T0, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using no plasmas"); + TESLA_MULTI_LOSS_PER_BLOCK_T1 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T1, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using helium or nitrogen plasma"); + TESLA_MULTI_LOSS_PER_BLOCK_T2 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T2, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using radon plasma"); + TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaMultiOverdriveLossFactor", "Balance Tweaks", TESLA_MULTI_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Tower power loss per amp as a factor of the tier voltage"); + TESLA_MULTI_SCAN_RANGE = _mainConfig.getInt("TeslaMultiScanRange", "Balance Tweaks", TESLA_MULTI_SCAN_RANGE, 4, 256, "The horizontal radius scanned by the Tesla Tower"); + TESLA_MULTI_GAS_OUTPUT = _mainConfig.getBoolean("TeslaMultiMoltenOutput", "Balance Tweaks", TESLA_MULTI_GAS_OUTPUT, "Set to true to enable outputting plasmas as gasses from the tesla tower with a 1:1 ratio"); + TESLA_SINGLE_LOSS_PER_BLOCK = _mainConfig.getInt("TeslaSingleLossPerBlock", "Balance Tweaks", TESLA_SINGLE_LOSS_PER_BLOCK, 0, Integer.MAX_VALUE, "Tesla Transceiver power transmission loss per block per amp"); + TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaSingleOverdriveLossFactor", "Balance Tweaks", TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Transceiver power loss per amp as a factor of the tier voltage"); } /** diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 58ea6d322b..09f6d597ad 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -55,42 +55,44 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region variables - private final static HashSet sparkList = new HashSet<>(); - + private static final int heliumUse = TecTech.configTecTech.TESLA_MULTI_HELIUM_PLASMA_PER_SECOND;//Default is 100 + private static final int nitrogenUse = TecTech.configTecTech.TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND;//Default is 50 + private static final int radonUse = TecTech.configTecTech.TESLA_MULTI_RADON_PLASMA_PER_SECOND;//Default is 50 + //Default is {1, 1, 1} + private static final int[] plasmaTierLoss = new int[]{TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T0, + TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T1, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T2}; + private static final float overDriveLoss = TecTech.configTecTech.TESLA_MULTI_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F; + private static final int scanRangeXZ = TecTech.configTecTech.TESLA_MULTI_SCAN_RANGE;//Default is 40 + private static final boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_GAS_OUTPUT; //Default is false + + //Face icons private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; - //TODO Make the setting abstractions static, if they aren't changed at tick time - private int mTier = 0; //Determines max voltage and efficiency (MV to LuV) - private int maxTier = 7; //Max tier for efficiency calcuation - private int plasmaTier = 0; //0 is None, 1 is Helium or Nitrogen, 2 is Radon - private boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_MOLTEN_OUTPUT; //Default is false - private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs for one second - private float energyEfficiency = 1; - private float overdriveEfficiency = 1; - private float minEfficiency = TecTech.configTecTech.TESLA_MULTI_MIN_EFFICIENCY;//Default is 0.955F - private float maxEfficiency = TecTech.configTecTech.TESLA_MULTI_MAX_EFFICIENCY;//Default is 0.98F - private float overdriveEfficiencyExtra = TecTech.configTecTech.TESLA_MULTI_OVERDRIVE_LOSS;//Default is 0.005F + private int mTier = 0; //Determines max voltage (LV to ZPM) + private int plasmaTier = 0; //0 is None, 1 is Helium or Nitrogen, 2 is Radon (Does not match actual plasma tiers) + + private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs, so the tesla takes a second to 'cool' any plasma it would output as a gas - private Map eTeslaMap = new HashMap<>(); //Used to store targets for power transmission - private final ArrayList eCapacitorHatches = new ArrayList<>(); //Used to determine count and tier of capacitors present + private final HashSet sparkList = new HashSet<>(); //Thaumcraft lighting coordinate pairs, so we can send them in bursts and save on lag + private final Map eTeslaMap = new HashMap<>(); //Targets for power transmission //TODO Make this fill more efficently and globally + private final ArrayList eCapacitorHatches = new ArrayList<>(); //Capacitor hatches which determine the max voltage tier and count of amps - private int scanTime = 0; //Scan timer used for tesla search intervals - private int scanRangeXZ = TecTech.configTecTech.TESLA_MULTI_SCAN_RANGE;//Default is 40 + private int scanTime = 0; //Scan timer used for tesla search intervals //TODO Replace with something that fetches from a global map private long energyCapacity = 0; //Total energy storage limited by capacitors private long outputVoltageMax = 0; //Tesla voltage output limited by capacitors private int vTier = -1; //Tesla voltage tier limited by capacitors private long outputCurrentMax = 0; //Tesla current output limited by capacitors - //Prevents unnecessary offset calculation + //Prevents unnecessary offset calculation, saving on lag private byte oldRotation = -1; private byte oldOrientation = -1; //Coordinate Arrays private final Vec3Impl[] scanPosOffsets = new Vec3Impl[10]; - private Vec3Impl posZap = Vec3Impl.NULL_VECTOR;//Power Transfer Origin - public Vec3Impl posTop = Vec3Impl.NULL_VECTOR;//Lightning Origin + private Vec3Impl posZap = Vec3Impl.NULL_VECTOR;//Location of the bottom middle of the tower, used as the power transfer origin + public Vec3Impl posTop = Vec3Impl.NULL_VECTOR;//Location of the center of the sphere on top of the tower, used as theThaumcraft lightning origin //endregion //region structure @@ -252,24 +254,22 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock super(aName); } - private long getEnergyEfficiency(long voltage, int distance, boolean overDriveToggle) { - //Helium and Nitrogen Plasmas will half the effective distance - //Radon will half it again - int effectiveDistance = distance; - switch (plasmaTier) { - case 2: - effectiveDistance = distance / 4; - break; - case 1: - effectiveDistance = distance / 2; - break; - } + private int getPerBlockLoss(){ + return plasmaTierLoss[plasmaTier]; + } + + private long[] getOutputVoltage(long outputVoltage, int distance, boolean overDriveToggle) { + long outputVoltageInjectable; + long outputVoltageConsumption; if (overDriveToggle) { - return (long) ((voltage * 2) - (voltage * Math.pow(overdriveEfficiency, effectiveDistance))); + outputVoltageInjectable = outputVoltage; + outputVoltageConsumption = outputVoltage + (distance * getPerBlockLoss()) + (long) Math.round(overDriveLoss * outputVoltage); } else { - return (long) (voltage * Math.pow(energyEfficiency, effectiveDistance)); + outputVoltageInjectable = outputVoltage - (distance * getPerBlockLoss()); + outputVoltageConsumption = outputVoltage; } + return new long[]{outputVoltageInjectable, outputVoltageConsumption}; } private float getRangeMulti(int mTier, int vTier) { @@ -345,24 +345,24 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock for (GT_MetaTileEntity_Hatch_Input fluidHatch : mInputHatches) { if (fluidHatch.mFluid != null) { - if (fluidHatch.mFluid.isFluidEqual(Materials.Helium.getPlasma(1)) && fluidHatch.mFluid.amount >= 100) { - fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 100; + if (fluidHatch.mFluid.isFluidEqual(Materials.Helium.getPlasma(1)) && fluidHatch.mFluid.amount >= heliumUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - heliumUse; if (doFluidOutput) { - mOutputFluidsQueue = new FluidStack[]{Materials.Helium.getGas(100)}; + mOutputFluidsQueue = new FluidStack[]{Materials.Helium.getGas(heliumUse)}; } plasmaTier = 1; return; - } else if (fluidHatch.mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) && fluidHatch.mFluid.amount >= 50) { - fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 50; + } else if (fluidHatch.mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) && fluidHatch.mFluid.amount >= nitrogenUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - nitrogenUse; if (doFluidOutput) { - mOutputFluidsQueue = new FluidStack[]{Materials.Nitrogen.getGas(50)}; + mOutputFluidsQueue = new FluidStack[]{Materials.Nitrogen.getGas(nitrogenUse)}; } plasmaTier = 1; return; - } else if (fluidHatch.mFluid.isFluidEqual(Materials.Radon.getPlasma(1)) && fluidHatch.mFluid.amount >= 50) { - fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - 50; + } else if (fluidHatch.mFluid.isFluidEqual(Materials.Radon.getPlasma(1)) && fluidHatch.mFluid.amount >= radonUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - radonUse; if (doFluidOutput) { - mOutputFluidsQueue = new FluidStack[]{Materials.Radon.getGas(50)}; + mOutputFluidsQueue = new FluidStack[]{Materials.Radon.getGas(radonUse)}; } plasmaTier = 2; return; @@ -390,9 +390,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -1, 1)); mTier = iGregTechTileEntity.getMetaIDOffset(xyzOffsets.get0(), xyzOffsets.get1(), xyzOffsets.get2()); - if (mTier == 9){ - mTier = 6; - } + if (mTier == 9){mTier = 6;}//Hacky remap because the ZPM coils were added later if (structureCheck_EM(shape, blockType, blockMetas[mTier], addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 3, 16, 0) && eCapacitorHatches.size() > 0) { for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) { @@ -461,11 +459,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } } - //Calculate Efficiency values - energyEfficiency = map(mTier + 1, 1, maxTier, minEfficiency, maxEfficiency); - //OD Eff calc - overdriveEfficiency = energyEfficiency - overdriveEfficiencyExtra; - energyCapacity = 0; outputCurrentMax = 0; @@ -608,6 +601,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock cap.getBaseMetaTileEntity().setActive(false); } + ePowerPass = false; setEUVar(0); energyStoredDisplay.set(0); energyFractionDisplay.set(0); @@ -618,12 +612,10 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock IGregTechTileEntity mte = getBaseMetaTileEntity(); //Hysteresis based ePowerPass setting - long energyMax = maxEUStore() / 2; long energyStored = getEUVar(); + float energyFrac = (float) energyStored / energyCapacity; - float energyFrac = (float) energyStored / energyMax; - - energyCapacityDisplay.set(energyMax); + energyCapacityDisplay.set(energyCapacity); energyStoredDisplay.set(energyStored); energyFractionDisplay.set(energyFrac); @@ -793,15 +785,9 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock IGregTechTileEntity node = Rx.getKey(); IMetaTileEntity nodeInside = node.getMetaTileEntity(); - long outputVoltageInjectable; - long outputVoltageConsumption; - if (overdriveToggle) { - outputVoltageInjectable = outputVoltage; - outputVoltageConsumption = getEnergyEfficiency(outputVoltage, Rx.getValue(), true); - } else { - outputVoltageInjectable = getEnergyEfficiency(outputVoltage, Rx.getValue(), false); - outputVoltageConsumption = outputVoltage; - } + long[] outputVoltageNow = getOutputVoltage(outputVoltage, Rx.getValue(), overdriveToggle); + long outputVoltageInjectable = outputVoltageNow[0]; + long outputVoltageConsumption = outputVoltageNow[1]; if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && Rx.getValue() <= transferRadiusTower) { GT_MetaTileEntity_TM_teslaCoil nodeTesla = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; @@ -865,6 +851,11 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock return energyCapacity * 2; } + @Override + public long getEUVar() { + return getBaseMetaTileEntity().isActive() ? super.getEUVar() : 0; + } + private boolean addCapacitorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null) { return false; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index ed36dec7cb..0f73750d48 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -36,37 +36,32 @@ import static net.minecraft.util.StatCollector.translateToLocalFormatted; public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer { + private final static int perBlockLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_PER_BLOCK;//Default is 1 + private final static float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F + + public Map eTeslaMap = new HashMap<>();//Tesla Map to map them tesla bois! private final static HashSet sparkList = new HashSet<>(); private byte sparkCount = 0; - private int maxTier = 4; //Max tier of transceiver - private int minTier = 0; //Min tier of transceiver - - public Map eTeslaMap = new HashMap<>();//Tesla Map to map them tesla bois! + private final static int maxTier = 4; //Max tier of transceiver + private final static int minTier = 0; //Min tier of transceiver - private int transferRadiusMax = 20; - private int transferRadiusMin = 4; - private int transferRadiusLimitTop = (int) map(mTier + 1, minTier + 1, maxTier + 1, transferRadiusMin, transferRadiusMax); - private int transferRadiusLimitBottom = 1; //Minimum user configurable + private final static int transferRadiusMax = 20; + private final static int transferRadiusMin = 4; + private final int transferRadiusLimitTop = (int) map(mTier + 1, minTier + 1, maxTier + 1, transferRadiusMin, transferRadiusMax); + private final static int transferRadiusLimitBottom = 1; //Minimum user configurable private int transferRadius = transferRadiusLimitTop; //Default transferRadius setting - private int transferRadiusTower = 0; //Radius for transceiver to tower transfers - private int transferRadiusCover = 0; //Radius for transceiver to cover transfers public boolean powerPassToggle = false; //Power Pass for public viewing - private int histSteps = 20; //Hysteresis Resolution + private final static int histSteps = 20; //Hysteresis Resolution private int histSettingLow = 3; //Hysteresis Low Limit private int histSettingHigh = 15; //Hysteresis High Limit - private int histLowLimit = 1; //How low can you configure it? - private int histHighLimit = 19; //How high can you configure it? + private final static int histLowLimit = 1; //How low can you configure it? + private final static int histHighLimit = 19; //How high can you configure it? private float histLow = (float) histSettingLow / histSteps; //Power pass is disabled if power is under this fraction private float histHigh = (float) histSettingHigh / histSteps; //Power pass is enabled if power is over this fraction - private long outputVoltage = V[mTier]; - private float minEfficiency = TecTech.configTecTech.TESLA_SINGLE_MIN_EFFICIENCY;//Default is 0.91F - private float maxEfficiency = TecTech.configTecTech.TESLA_SINGLE_MAX_EFFICIENCY;//Default is 0.95F - private float overdriveEfficiencyExtra = TecTech.configTecTech.TESLA_SINGLE_OVERDRIVE_LOSS;//Default is 0.010F - private float energyEfficiency = map(mTier + 1, minTier + 1, maxTier + 1, minEfficiency, maxEfficiency); - private float overdriveEfficiency = energyEfficiency - overdriveEfficiencyExtra; + private final long outputVoltage = V[mTier]; private boolean overdriveToggle = false; private String clientLocale = "en_US"; @@ -220,12 +215,18 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB sparkList.add(new ThaumSpark(x, y, z, xR, yR, zR, wID)); } - private long getEnergyEfficiency(long voltage, int distance, boolean overDriveToggle) { + private long[] getOutputVoltage(long outputVoltage, int distance, boolean overDriveToggle) { + long outputVoltageInjectable; + long outputVoltageConsumption; + if (overDriveToggle) { - return (long) ((voltage * 2) - (voltage * Math.pow(overdriveEfficiency, distance))); + outputVoltageInjectable = outputVoltage; + outputVoltageConsumption = outputVoltage + (distance * perBlockLoss) + (long) Math.round(overDriveLoss * outputVoltage); } else { - return (long) (voltage * Math.pow(energyEfficiency, distance)); + outputVoltageInjectable = outputVoltage - (distance * perBlockLoss); + outputVoltageConsumption = outputVoltage; } + return new long[]{outputVoltageInjectable, outputVoltageConsumption}; } @Override @@ -251,8 +252,10 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB if (powerPassToggle) { float rangeFrac = (float) ((-0.5 * Math.pow(energyFrac, 2)) + (1.5 * energyFrac)); long outputCurrent = mBatteryCount; - transferRadiusTower = (int) (transferRadius * rangeFrac); - transferRadiusCover = (int) (transferRadiusTower / 1.25); + //Radius for transceiver to tower transfers + int transferRadiusTower = (int) (transferRadius * rangeFrac); + //Radius for transceiver to cover transfers + int transferRadiusCover = (int) (transferRadiusTower / 1.25); //Clean the eTeslaMap for (Map.Entry Rx : eTeslaMap.entrySet()) { @@ -282,15 +285,10 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB IGregTechTileEntity node = Rx.getKey(); IMetaTileEntity nodeInside = node.getMetaTileEntity(); - long outputVoltageInjectable; - long outputVoltageConsumption; - if (overdriveToggle) { - outputVoltageInjectable = outputVoltage; - outputVoltageConsumption = getEnergyEfficiency(outputVoltage, Rx.getValue(), true); - } else { - outputVoltageInjectable = getEnergyEfficiency(outputVoltage, Rx.getValue(), false); - outputVoltageConsumption = outputVoltage; - } + long[] outputVoltageNow = getOutputVoltage(outputVoltage, Rx.getValue(), overdriveToggle); + long outputVoltageInjectable = outputVoltageNow[0]; + long outputVoltageConsumption = outputVoltageNow[1]; + if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && Rx.getValue() <= transferRadiusTower) { GT_MetaTileEntity_TM_teslaCoil nodeTesla = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; if (!nodeTesla.ePowerPass) { -- cgit From f2cbb5c88aff3b3f0f3908601328c53ee652f9dd Mon Sep 17 00:00:00 2001 From: basdxz Date: Sat, 18 Jul 2020 12:35:36 +0100 Subject: Created Global Tesla List --- .../tectech/thing/cover/GT_Cover_TM_TeslaCoil.java | 17 ++++++++++++-- .../cover/GT_Cover_TM_TeslaCoil_Ultimate.java | 2 +- .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 20 +++++++++++++--- .../single/GT_MetaTileEntity_TeslaCoil.java | 27 +++++++++++++++++++++- 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java index 721f730960..8be875ff4f 100644 --- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java @@ -1,16 +1,25 @@ package com.github.technus.tectech.thing.cover; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_TM_teslaCoil.teslaNodeSet; import static ic2.api.info.Info.DMG_ELECTRIC; public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior { public GT_Cover_TM_TeslaCoil() { } + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { + if (aTileEntity.getEUCapacity() > 0) { + teslaNodeSet.add(aTileEntity.getIGregTechTileEntityOffset(0, 0, 0)); + } + return super.doCoverThings(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity, aTimer); + } + public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return "Do not attempt to use screwdriver!"; } @@ -20,9 +29,13 @@ public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior { } public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if(aTileEntity.getStoredEU() > 0 && !GT_Utility.isWearingFullElectroHazmat(aPlayer)){ + if (aTileEntity.getStoredEU() > 0 && !GT_Utility.isWearingFullElectroHazmat(aPlayer)) { aPlayer.attackEntityFrom(DMG_ELECTRIC, 20); } return aCoverVariable; } -} \ No newline at end of file + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 200; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java index db7c751fc6..2b5db1f5c9 100644 --- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java @@ -26,4 +26,4 @@ public class GT_Cover_TM_TeslaCoil_Ultimate extends GT_Cover_TM_TeslaCoil { public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } -} \ No newline at end of file +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 09f6d597ad..7d12302477 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -5,8 +5,8 @@ import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.mechanics.spark.RendererMessage; import com.github.technus.tectech.mechanics.spark.ThaumSpark; -import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; import com.github.technus.tectech.mechanics.structure.Structure; +import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil; import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil_Ultimate; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Capacitor; @@ -47,7 +47,6 @@ import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBloc import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.util.Util.entriesSortedByValues; -import static com.github.technus.tectech.util.Util.map; import static gregtech.api.enums.GT_Values.E; import static java.lang.Math.max; import static java.lang.Math.min; @@ -74,8 +73,9 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs, so the tesla takes a second to 'cool' any plasma it would output as a gas + public static final HashSet teslaNodeSet = new HashSet<>(); //Targets for power transmission //TODO Make this fill more efficently and globally private final HashSet sparkList = new HashSet<>(); //Thaumcraft lighting coordinate pairs, so we can send them in bursts and save on lag - private final Map eTeslaMap = new HashMap<>(); //Targets for power transmission //TODO Make this fill more efficently and globally + private final Map eTeslaMap = new HashMap<>(); //Targets for power transmission private final ArrayList eCapacitorHatches = new ArrayList<>(); //Capacitor hatches which determine the max voltage tier and count of amps private int scanTime = 0; //Scan timer used for tesla search intervals //TODO Replace with something that fetches from a global map @@ -519,6 +519,11 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock @Override public void onRemoval() { super.onRemoval(); + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (aBaseMetaTileEntity.isClientSide()) { + return; + } + teslaNodeSet.remove(aBaseMetaTileEntity); for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(cap)) { cap.getBaseMetaTileEntity().setActive(false); @@ -592,6 +597,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); energyCapacity = aNBT.getLong("eEnergyCapacity"); + teslaNodeSet.add(this.getBaseMetaTileEntity()); } @Override @@ -607,6 +613,14 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock energyFractionDisplay.set(0); } + @Override + public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick_EM(aBaseMetaTileEntity); + if (!aBaseMetaTileEntity.isClientSide()) { + teslaNodeSet.add(aBaseMetaTileEntity); + } + } + @Override public boolean onRunningTick(ItemStack aStack) { IGregTechTileEntity mte = getBaseMetaTileEntity(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index 0f73750d48..47625b999f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -17,6 +17,7 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicBatteryBuffer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.reflect.FieldUtils; @@ -26,6 +27,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_TM_teslaCoil.teslaNodeSet; import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.util.Util.entriesSortedByValues; import static com.github.technus.tectech.util.Util.map; @@ -38,7 +40,7 @@ import static net.minecraft.util.StatCollector.translateToLocalFormatted; public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer { private final static int perBlockLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_PER_BLOCK;//Default is 1 private final static float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F - + public Map eTeslaMap = new HashMap<>();//Tesla Map to map them tesla bois! private final static HashSet sparkList = new HashSet<>(); private byte sparkCount = 0; @@ -229,6 +231,29 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB return new long[]{outputVoltageInjectable, outputVoltageConsumption}; } + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + if (!aBaseMetaTileEntity.isClientSide()) { + teslaNodeSet.add(aBaseMetaTileEntity); + } + } + + @Override + public void onRemoval() { + super.onRemoval(); + IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); + if (!aBaseMetaTileEntity.isClientSide()) { + teslaNodeSet.remove(aBaseMetaTileEntity); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + teslaNodeSet.add(this.getBaseMetaTileEntity()); + } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); -- cgit From 05b7f7d4111926d1eef68c7643c09f0cac5e09c5 Mon Sep 17 00:00:00 2001 From: basdxz Date: Sun, 19 Jul 2020 08:26:15 +0100 Subject: Implement Tesla Global List And then when I do it with lists the way Bart suggested it, I have Tec tell me to rewrite everything using interfaces --- .../technus/tectech/loader/TecTechConfig.java | 3 - .../tectech/thing/cover/GT_Cover_TM_TeslaCoil.java | 1 - .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 310 +++++++++------------ .../single/GT_MetaTileEntity_TeslaCoil.java | 56 ++-- 4 files changed, 145 insertions(+), 225 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java index 030be65f3b..ae9da94b02 100644 --- a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java @@ -28,7 +28,6 @@ public class TecTechConfig extends ConfigManager { public int TESLA_MULTI_LOSS_PER_BLOCK_T1; public int TESLA_MULTI_LOSS_PER_BLOCK_T2; public float TESLA_MULTI_OVERDRIVE_LOSS_FACTOR; - public int TESLA_MULTI_SCAN_RANGE;//TODO delete public boolean TESLA_MULTI_GAS_OUTPUT; public int TESLA_SINGLE_LOSS_PER_BLOCK; public float TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR; @@ -54,7 +53,6 @@ public class TecTechConfig extends ConfigManager { TESLA_MULTI_LOSS_PER_BLOCK_T1 = 1; TESLA_MULTI_LOSS_PER_BLOCK_T2 = 1; TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = 0.25F; - TESLA_MULTI_SCAN_RANGE = 40; TESLA_MULTI_GAS_OUTPUT = false; TESLA_SINGLE_LOSS_PER_BLOCK = 1; TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = 0.25F; @@ -93,7 +91,6 @@ public class TecTechConfig extends ConfigManager { TESLA_MULTI_LOSS_PER_BLOCK_T1 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T1, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using helium or nitrogen plasma"); TESLA_MULTI_LOSS_PER_BLOCK_T2 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T2, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using radon plasma"); TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaMultiOverdriveLossFactor", "Balance Tweaks", TESLA_MULTI_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Tower power loss per amp as a factor of the tier voltage"); - TESLA_MULTI_SCAN_RANGE = _mainConfig.getInt("TeslaMultiScanRange", "Balance Tweaks", TESLA_MULTI_SCAN_RANGE, 4, 256, "The horizontal radius scanned by the Tesla Tower"); TESLA_MULTI_GAS_OUTPUT = _mainConfig.getBoolean("TeslaMultiMoltenOutput", "Balance Tweaks", TESLA_MULTI_GAS_OUTPUT, "Set to true to enable outputting plasmas as gasses from the tesla tower with a 1:1 ratio"); TESLA_SINGLE_LOSS_PER_BLOCK = _mainConfig.getInt("TeslaSingleLossPerBlock", "Balance Tweaks", TESLA_SINGLE_LOSS_PER_BLOCK, 0, Integer.MAX_VALUE, "Tesla Transceiver power transmission loss per block per amp"); TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaSingleOverdriveLossFactor", "Balance Tweaks", TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Transceiver power loss per amp as a factor of the tier voltage"); diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java index 8be875ff4f..6442ba51b6 100644 --- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.thing.cover; import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 7d12302477..eca70ca63f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -48,8 +48,7 @@ import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStat import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.util.Util.entriesSortedByValues; import static gregtech.api.enums.GT_Values.E; -import static java.lang.Math.max; -import static java.lang.Math.min; +import static java.lang.Math.*; import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { @@ -61,7 +60,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private static final int[] plasmaTierLoss = new int[]{TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T0, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T1, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T2}; private static final float overDriveLoss = TecTech.configTecTech.TESLA_MULTI_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F; - private static final int scanRangeXZ = TecTech.configTecTech.TESLA_MULTI_SCAN_RANGE;//Default is 40 private static final boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_GAS_OUTPUT; //Default is false //Face icons @@ -73,12 +71,12 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs, so the tesla takes a second to 'cool' any plasma it would output as a gas - public static final HashSet teslaNodeSet = new HashSet<>(); //Targets for power transmission //TODO Make this fill more efficently and globally + public static final HashSet teslaNodeSet = new HashSet<>(); //Targets for power transmission private final HashSet sparkList = new HashSet<>(); //Thaumcraft lighting coordinate pairs, so we can send them in bursts and save on lag - private final Map eTeslaMap = new HashMap<>(); //Targets for power transmission + private Map teslaNodeMap = new HashMap<>(); //Targets for power transmission private final ArrayList eCapacitorHatches = new ArrayList<>(); //Capacitor hatches which determine the max voltage tier and count of amps - private int scanTime = 0; //Scan timer used for tesla search intervals //TODO Replace with something that fetches from a global map + private int sortTime = 0; //Scan timer used for tesla search intervals private long energyCapacity = 0; //Total energy storage limited by capacitors private long outputVoltageMax = 0; //Tesla voltage output limited by capacitors @@ -88,11 +86,8 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock //Prevents unnecessary offset calculation, saving on lag private byte oldRotation = -1; private byte oldOrientation = -1; - - //Coordinate Arrays - private final Vec3Impl[] scanPosOffsets = new Vec3Impl[10]; - private Vec3Impl posZap = Vec3Impl.NULL_VECTOR;//Location of the bottom middle of the tower, used as the power transfer origin - public Vec3Impl posTop = Vec3Impl.NULL_VECTOR;//Location of the center of the sphere on top of the tower, used as theThaumcraft lightning origin + //Location of the center of the sphere on top of the tower, used as the Thaumcraft lightning and origin + public Vec3Impl posTop = Vec3Impl.NULL_VECTOR; //endregion //region structure @@ -128,8 +123,8 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock //endregion //region parameters - protected Parameters.Group.ParameterIn popogaSetting, histLowSetting, histHighSetting, transferRadiusTowerSetting, transferRadiusTransceiverSetting, transferRadiusCoverUltimateSetting, outputVoltageSetting, outputCurrentSetting, scanTimeMinSetting, overDriveSetting; - protected Parameters.Group.ParameterOut popogaDisplay, transferRadiusTowerDisplay, transferRadiusTransceiverDisplay, transferRadiusCoverUltimateDisplay, outputVoltageDisplay, outputCurrentDisplay, energyCapacityDisplay, energyStoredDisplay, energyFractionDisplay, scanTimeDisplay; + protected Parameters.Group.ParameterIn popogaSetting, histLowSetting, histHighSetting, transferRadiusTowerSetting, transferRadiusTransceiverSetting, transferRadiusCoverUltimateSetting, outputVoltageSetting, outputCurrentSetting, sortTimeMinSetting, overDriveSetting; + protected Parameters.Group.ParameterOut popogaDisplay, transferRadiusTowerDisplay, transferRadiusTransceiverDisplay, transferRadiusCoverUltimateDisplay, outputVoltageDisplay, outputCurrentDisplay, energyCapacityDisplay, energyStoredDisplay, energyFractionDisplay, sortTimeDisplay; private static final INameFunction HYSTERESIS_LOW_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.0");//Hysteresis low setting private static final INameFunction HYSTERESIS_HIGH_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.1");//Hysteresis high setting @@ -294,37 +289,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock return 1F * plasmaBoost; } - private void scanForTransmissionTargets(Vec3Impl coordsMin, Vec3Impl coordsMax) { - //This makes sure the minimums are actually smaller than the maximums - int xMin = min(coordsMin.get0(), coordsMax.get0()); - int yMin = min(coordsMin.get1(), coordsMax.get1()); - int zMin = min(coordsMin.get2(), coordsMax.get2()); - //And vice versa - int xMax = max(coordsMin.get0(), coordsMax.get0()); - int yMax = max(coordsMin.get1(), coordsMax.get1()); - int zMax = max(coordsMin.get2(), coordsMax.get2()); - - for (int xPos = xMin; xPos <= xMax; xPos++) { - for (int yPos = yMin; yPos <= yMax; yPos++) { - for (int zPos = zMin; zPos <= zMax; zPos++) { - if (xPos == 0 && yPos == 0 && zPos == 0) { - continue; - } - IGregTechTileEntity node = getBaseMetaTileEntity().getIGregTechTileEntityOffset(xPos, yPos, zPos); - if (node != null) { - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil || - nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive() || - (node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil)) { - eTeslaMap.put(node, (int) Math.ceil(Math.sqrt(Math.pow(xPos, 2) + Math.pow(yPos, 2) + Math.pow(zPos, 2)))); - } - } - } - } - } - - } - private void thaumLightning(IGregTechTileEntity mte, IGregTechTileEntity node) { byte xR = (byte) (node.getXCoord() - posTop.get0()); byte yR = (byte) (node.getYCoord() - posTop.get1()); @@ -405,26 +369,10 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock oldOrientation = iGregTechTileEntity.getFrontFacing(); //Calculate coordinates of the middle bottom - posZap = getExtendedFacing().getWorldOffset(new Vec3Impl(0, 0, 2)).add(getBaseMetaTileEntity()); + posTop = getExtendedFacing().getWorldOffset(new Vec3Impl(0, 0, 2)).add(getBaseMetaTileEntity()); //Calculate coordinates of the top sphere posTop = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -14, 2)).add(getBaseMetaTileEntity()); - - //Calculate offsets for scanning - scanPosOffsets[0] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, 0, scanRangeXZ + 3)); - scanPosOffsets[1] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -4, -1 * scanRangeXZ + 3)); - - scanPosOffsets[2] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, -5, scanRangeXZ + 3)); - scanPosOffsets[3] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -8, -1 * scanRangeXZ + 3)); - - scanPosOffsets[4] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, -9, scanRangeXZ + 3)); - scanPosOffsets[5] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -12, -1 * scanRangeXZ + 3)); - - scanPosOffsets[6] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, -13, scanRangeXZ + 3)); - scanPosOffsets[7] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -16, -1 * scanRangeXZ + 3)); - - scanPosOffsets[8] = getExtendedFacing().getWorldOffset(new Vec3Impl(scanRangeXZ, -17, scanRangeXZ + 3)); - scanPosOffsets[9] = getExtendedFacing().getWorldOffset(new Vec3Impl(-1 * scanRangeXZ, -20, -1 * scanRangeXZ + 3)); } return true; } @@ -442,7 +390,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock !transferRadiusCoverUltimateSetting.getStatus(false).isOk || !outputVoltageSetting.getStatus(false).isOk || !outputCurrentSetting.getStatus(false).isOk || - !scanTimeMinSetting.getStatus(false).isOk || + !sortTimeMinSetting.getStatus(false).isOk || !overDriveSetting.getStatus(false).isOk ) return false; @@ -558,7 +506,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock popogaSetting = hatch_5.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); popogaSetting = hatch_6.makeInParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); popogaSetting = hatch_6.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); - scanTimeMinSetting = hatch_7.makeInParameter(0, 100, SCAN_TIME_MIN_SETTING_NAME, SCAN_TIME_MIN_STATUS); + sortTimeMinSetting = hatch_7.makeInParameter(0, 100, SCAN_TIME_MIN_SETTING_NAME, SCAN_TIME_MIN_STATUS); popogaSetting = hatch_7.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); overDriveSetting = hatch_8.makeInParameter(0, 0, OVERDRIVE_SETTING_NAME, OVERDRIVE_STATUS); popogaSetting = hatch_8.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); @@ -579,7 +527,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock energyCapacityDisplay = hatch_5.makeOutParameter(1, 0, ENERGY_CAPACITY_DISPLAY_NAME, ENERGY_STATUS); energyStoredDisplay = hatch_6.makeOutParameter(0, 0, ENERGY_STORED_DISPLAY_NAME, ENERGY_STATUS); energyFractionDisplay = hatch_6.makeOutParameter(1, 0, ENERGY_FRACTION_DISPLAY_NAME, ENERGY_STATUS); - scanTimeDisplay = hatch_7.makeOutParameter(0, 0, SCAN_TIME_DISPLAY_NAME, SCAN_TIME_STATUS); + sortTimeDisplay = hatch_7.makeOutParameter(0, 0, SCAN_TIME_DISPLAY_NAME, SCAN_TIME_STATUS); popogaDisplay = hatch_7.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); popogaDisplay = hatch_8.makeOutParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); popogaDisplay = hatch_8.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); @@ -621,120 +569,135 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } } - @Override - public boolean onRunningTick(ItemStack aStack) { - IGregTechTileEntity mte = getBaseMetaTileEntity(); - //Hysteresis based ePowerPass setting - long energyStored = getEUVar(); - float energyFrac = (float) energyStored / energyCapacity; + public static Map generateTeslaNodeMap(IGregTechTileEntity orgin){ + Map generatedNodeMap = new HashMap<>(); + IMetaTileEntity orginInside = orgin.getMetaTileEntity(); + int orginX; + int orginY; + int orginZ; + if (orginInside instanceof GT_MetaTileEntity_TM_teslaCoil) { + GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) orginInside; + orginX = teslaTower.posTop.get0(); + orginY = teslaTower.posTop.get1(); + orginZ = teslaTower.posTop.get2(); + } else { + orginX = orgin.getXCoord(); + orginY = orgin.getYCoord(); + orginZ = orgin.getZCoord(); + } - energyCapacityDisplay.set(energyCapacity); - energyStoredDisplay.set(energyStored); - energyFractionDisplay.set(energyFrac); + for (IGregTechTileEntity node : teslaNodeSet) { + if (node == null) { + //Technically, the Tesla Covers do not remove themselves from the list and this is the code that does + teslaNodeSet.remove(null); + continue; + } else if (node == orgin || orgin.getWorld().provider.dimensionId != node.getWorld().provider.dimensionId) { + //Skip if looking at myself and skip if not in the same dimention + //TODO, INTERDIM? + continue; + } - if (!ePowerPass && energyFrac > histHighSetting.get()) { - ePowerPass = true; - } else if (ePowerPass && energyFrac < histLowSetting.get()) { - ePowerPass = false; + //Makes the target coordinates the center of the sphere of the tower if it has one + IMetaTileEntity nodeInside = node.getMetaTileEntity(); + int targetX; + int targetY; + int targetZ; + if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil) { + GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; + targetX = teslaTower.posTop.get0(); + targetY = teslaTower.posTop.get1(); + targetZ = teslaTower.posTop.get2(); + } else { + targetX = node.getXCoord(); + targetY = node.getYCoord(); + targetZ = node.getZCoord(); + } + + //Find the xyz offsets and calculate the distance between us and the target + int xPosOffset = targetX - orginX; + int yPosOffset = targetY - orginY; + int zPosOffset = targetZ - orginZ; + int distance = (int) ceil(sqrt(pow(xPosOffset, 2) + pow(yPosOffset, 2) + pow(zPosOffset, 2))); + //Thought we need abs here, we don't. An Integer to the power of two is going to be either 0 or positive. + //We also can just put stuff here without further checks, as we always check the next section + generatedNodeMap.put(node, distance); } + return generatedNodeMap; + } + + public static Map cleanTeslaNodeMap(Map nodeMap, IGregTechTileEntity orgin) { + IMetaTileEntity orginInside = orgin.getMetaTileEntity(); + //Assumes that if the orgin is not a Tesla Tower, it mus be a single block. + boolean isMulti = orginInside instanceof GT_MetaTileEntity_TM_teslaCoil; - //Clean the eTeslaMap - for (Map.Entry Rx : eTeslaMap.entrySet()) { + for (Map.Entry Rx : nodeMap.entrySet()) { + //All the checks need to pass or the target gets removed from the transmission list IGregTechTileEntity node = Rx.getKey(); + //Null check if (node != null) { IMetaTileEntity nodeInside = node.getMetaTileEntity(); + //We need this in a try catch, just as a precaution that a chunk had unloaded or a machine was removed try { + //Is it an Active Tesla Tower with at least some energy capacity? + //Singles and Multis can send power here, so we don't check if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive()) { GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; if (teslaTower.maxEUStore() > 0) { continue; } - } else if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil) { + //Is it a Tesla Transceiver with at least one battery? + //Only multis can send power to singles + } else if (isMulti && nodeInside instanceof GT_MetaTileEntity_TeslaCoil) { GT_MetaTileEntity_TeslaCoil teslaTransceiver = (GT_MetaTileEntity_TeslaCoil) nodeInside; if (teslaTransceiver.mBatteryCount > 0) { continue; } - } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil) && node.getEUCapacity() > 0) { + //Is it a tile entity with a Tesla Coil Cover? + //Only single can send power to non-Rich edition covers + //Since Rich edition inherits from regular, we need the final check + } else if (!isMulti && node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil && + node.getEUCapacity() > 0 && !(node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil_Ultimate)) { + continue; + //Is it a tile entity with a Tesla Coil Cover Rich edition? + //Only multis can send power to Rich edition covers + } else if (isMulti && node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil_Ultimate && node.getEUCapacity() > 0) { continue; } - } catch (Exception e) { + } catch (Exception ignored) { } } - eTeslaMap.remove(Rx.getKey()); + nodeMap.remove(Rx.getKey()); } + return nodeMap; + } - //Scan for transmission targets - switch (scanTime) { - case 0: - scanTimeDisplay.updateStatus(); - scanForTransmissionTargets(scanPosOffsets[0], scanPosOffsets[1]); - break; - case 20: - scanTimeDisplay.updateStatus(); - scanForTransmissionTargets(scanPosOffsets[2], scanPosOffsets[3]); - break; - case 40: - scanTimeDisplay.updateStatus(); - scanForTransmissionTargets(scanPosOffsets[4], scanPosOffsets[5]); - break; - case 60: - scanTimeDisplay.updateStatus(); - scanForTransmissionTargets(scanPosOffsets[6], scanPosOffsets[7]); - break; - case 80: - scanTimeDisplay.updateStatus(); - scanForTransmissionTargets(scanPosOffsets[8], scanPosOffsets[9]); - break; - default: - if (scanTime == (int) scanTimeMinSetting.get() - 1) { - scanTime = -1; - for (Map.Entry Rx : eTeslaMap.entrySet()) { - IGregTechTileEntity node = Rx.getKey(); - if (node != null) { - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - try { - if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil) { - GT_MetaTileEntity_TeslaCoil teslaCoil = (GT_MetaTileEntity_TeslaCoil) nodeInside; - - int tX = node.getXCoord(); - int tY = node.getYCoord(); - int tZ = node.getZCoord(); - - int tXN = posZap.get0(); - int tYN = posZap.get1(); - int tZN = posZap.get2(); - - int tOffset = (int) Math.ceil(Math.sqrt(Math.pow(tX - tXN, 2) + Math.pow(tY - tYN, 2) + Math.pow(tZ - tZN, 2))); - teslaCoil.eTeslaMap.put(mte, tOffset); - - for (Map.Entry RRx : eTeslaMap.entrySet()) { - IGregTechTileEntity nodeN = RRx.getKey(); - if (nodeN == node) { - continue; - } - tXN = nodeN.getXCoord(); - tYN = nodeN.getYCoord(); - tZN = nodeN.getZCoord(); - tOffset = (int) Math.ceil(Math.sqrt(Math.pow(tX - tXN, 2) + Math.pow(tY - tYN, 2) + Math.pow(tZ - tZN, 2))); - if (tOffset > 20) { - continue; - } - teslaCoil.eTeslaMap.put(nodeN, tOffset); - } - } - } catch (Exception e) { - eTeslaMap.remove(Rx.getKey()); - } - } - } - } - break; + @Override + public boolean onRunningTick(ItemStack aStack) { + IGregTechTileEntity mte = getBaseMetaTileEntity(); + + //Hysteresis based ePowerPass setting + float energyFrac = (float) getEUVar() / energyCapacity; + + energyCapacityDisplay.set(energyCapacity); + energyStoredDisplay.set(getEUVar()); + energyFractionDisplay.set(energyFrac); + + if (!ePowerPass && energyFrac > histHighSetting.get()) { + ePowerPass = true; + } else if (ePowerPass && energyFrac < histLowSetting.get()) { + ePowerPass = false; } - scanTime++; - scanTimeDisplay.set(scanTime); + //Create the teslaNodeMap + if (sortTime == sortTimeMinSetting.get()) { + sortTime = 0; + sortTimeDisplay.updateStatus(); + teslaNodeMap = generateTeslaNodeMap(mte); + } + sortTime++; + sortTimeDisplay.set(sortTime); //Power Limit Settings long outputVoltage; @@ -756,46 +719,23 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock //Stuff to do if ePowerPass if (ePowerPass) { //Range calculation and display - float rangeFrac = (float) ((-0.5 * Math.pow(energyFrac, 2)) + (1.5 * energyFrac)); - int transferRadiusTower = (int) (transferRadiusTowerSetting.get() * getRangeMulti(mTier, vTier) * rangeFrac); + int transferRadiusTower = (int) (transferRadiusTowerSetting.get() * getRangeMulti(mTier, vTier)); transferRadiusTowerDisplay.set(transferRadiusTower); - int transferRadiusTransceiver = (int) (transferRadiusTransceiverSetting.get() * getRangeMulti(mTier, vTier) * rangeFrac); + int transferRadiusTransceiver = (int) (transferRadiusTransceiverSetting.get() * getRangeMulti(mTier, vTier)); transferRadiusTransceiverDisplay.set(transferRadiusTransceiver); - int transferRadiusCoverUltimate = (int) (transferRadiusCoverUltimateSetting.get() * getRangeMulti(mTier, vTier) * rangeFrac); + int transferRadiusCoverUltimate = (int) (transferRadiusCoverUltimateSetting.get() * getRangeMulti(mTier, vTier)); transferRadiusCoverUltimateDisplay.set(transferRadiusCoverUltimate); - //Clean the eTeslaMap - for (Map.Entry Rx : eTeslaMap.entrySet()) { - IGregTechTileEntity node = Rx.getKey(); - if (node != null) { - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - try { - if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive()) { - GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; - if (teslaTower.maxEUStore() > 0) { - continue; - } - } else if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil) { - GT_MetaTileEntity_TeslaCoil teslaCoil = (GT_MetaTileEntity_TeslaCoil) nodeInside; - if (teslaCoil.getStoredEnergy()[1] > 0) { - continue; - } - } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil) && node.getEUCapacity() > 0) { - continue; - } - } catch (Exception e) { - } - } - eTeslaMap.remove(Rx.getKey()); - } + //Clean the teslaNodeMap + teslaNodeMap = cleanTeslaNodeMap(teslaNodeMap, mte); //Power transfer long sparks = outputCurrent; while (sparks > 0) { boolean overdriveToggle = overDriveSetting.get() > 0; boolean idle = true; - for (Map.Entry Rx : entriesSortedByValues(eTeslaMap)) { - if (energyStored >= (overdriveToggle ? outputVoltage * 2 : outputVoltage)) { + for (Map.Entry Rx : entriesSortedByValues(teslaNodeMap)) { + if (getEUVar() >= (overdriveToggle ? outputVoltage * 2 : outputVoltage)) { IGregTechTileEntity node = Rx.getKey(); IMetaTileEntity nodeInside = node.getMetaTileEntity(); @@ -845,12 +785,12 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } } outputCurrentDisplay.set(outputCurrent - sparks); - if (scanTime % 60 == 0 && !sparkList.isEmpty()) { + if (sortTime % 60 == 0 && !sparkList.isEmpty()) { NetworkDispatcher.INSTANCE.sendToAllAround(new RendererMessage.RendererData(sparkList), mte.getWorld().provider.dimensionId, - mte.getXCoord(), - mte.getYCoord(), - mte.getZCoord(), + posTop.get0(), + posTop.get1(), + posTop.get2(), 256); } sparkList.clear(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index 47625b999f..657bf6b01a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -27,32 +27,25 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_TM_teslaCoil.teslaNodeSet; +import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_TM_teslaCoil.*; import static com.github.technus.tectech.util.CommonValues.V; import static com.github.technus.tectech.util.Util.entriesSortedByValues; -import static com.github.technus.tectech.util.Util.map; import static com.github.technus.tectech.thing.metaTileEntity.Textures.*; import static java.lang.Math.round; import static net.minecraft.util.StatCollector.translateToLocal; import static net.minecraft.util.StatCollector.translateToLocalFormatted; - public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer { private final static int perBlockLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_PER_BLOCK;//Default is 1 private final static float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F - public Map eTeslaMap = new HashMap<>();//Tesla Map to map them tesla bois! + private Map teslaNodeMap = new HashMap<>();//Tesla Map to map them tesla bois! private final static HashSet sparkList = new HashSet<>(); private byte sparkCount = 0; - private final static int maxTier = 4; //Max tier of transceiver - private final static int minTier = 0; //Min tier of transceiver - - private final static int transferRadiusMax = 20; - private final static int transferRadiusMin = 4; - private final int transferRadiusLimitTop = (int) map(mTier + 1, minTier + 1, maxTier + 1, transferRadiusMin, transferRadiusMax); - private final static int transferRadiusLimitBottom = 1; //Minimum user configurable - private int transferRadius = transferRadiusLimitTop; //Default transferRadius setting + private final static int transferRadiusMax = 20; //Maximum user configurable + private final static int transferRadiusMin = 4; //Minimum user configurable + private int transferRadius = 16; //Default transferRadius setting public boolean powerPassToggle = false; //Power Pass for public viewing private final static int histSteps = 20; //Hysteresis Resolution @@ -68,6 +61,9 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB private String clientLocale = "en_US"; + private int sortTime = 0;//Sorting tick counter + private final static int sortTimeMax = 100;//Sorting tick counter limit, so we only sort once every 5 seconds + public GT_MetaTileEntity_TeslaCoil(int aID, String aName, String aNameRegional, int aTier, int aSlotCount) { super(aID, aName, aNameRegional, aTier, "", aSlotCount); Util.setTier(aTier, this); @@ -125,11 +121,11 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB @Override public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { - if (transferRadius > transferRadiusLimitBottom) { + if (transferRadius > transferRadiusMin) { transferRadius--; } } else { - if (transferRadius < 0) { + if (transferRadius < transferRadiusMax) { transferRadius++; } } @@ -171,13 +167,11 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[3][17][]; - for (byte i = -1; i < 16; ++i) { rTextures[0][i + 1] = new ITexture[]{MACHINE_CASINGS_TT[this.mTier][i + 1]}; rTextures[1][i + 1] = new ITexture[]{MACHINE_CASINGS_TT[this.mTier][i + 1], TESLA_TRANSCEIVER_TOP_BA}; rTextures[2][i + 1] = new ITexture[]{MACHINE_CASINGS_TT[this.mTier][i + 1], this.mInventory.length == 16 ? OVERLAYS_ENERGY_OUT_POWER_TT[this.mTier] : (this.mInventory.length > 4 ? OVERLAYS_ENERGY_OUT_MULTI_TT[this.mTier] : OVERLAYS_ENERGY_OUT_TT[this.mTier])}; } - return rTextures; } @@ -273,6 +267,13 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB powerPassToggle = false; } + //Create the teslaNodeMap + if (sortTime == sortTimeMax) { + sortTime = 0; + teslaNodeMap = generateTeslaNodeMap(aBaseMetaTileEntity); + } + sortTime++; + //Stuff to do if ePowerPass if (powerPassToggle) { float rangeFrac = (float) ((-0.5 * Math.pow(energyFrac, 2)) + (1.5 * energyFrac)); @@ -282,30 +283,13 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB //Radius for transceiver to cover transfers int transferRadiusCover = (int) (transferRadiusTower / 1.25); - //Clean the eTeslaMap - for (Map.Entry Rx : eTeslaMap.entrySet()) { - IGregTechTileEntity node = Rx.getKey(); - if (node != null) { - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - try { - if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive()) { - GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; - if (teslaTower.maxEUStore() > 0) { - continue; - } - } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil) && node.getEUCapacity() > 0) { - continue; - } - } catch (Exception e) { - } - } - eTeslaMap.remove(Rx.getKey()); - } + //Clean the teslaNodeMap + teslaNodeMap = cleanTeslaNodeMap(teslaNodeMap, aBaseMetaTileEntity); //Power transfer while (outputCurrent > 0) { boolean idle = true; - for (Map.Entry Rx : entriesSortedByValues(eTeslaMap)) { + for (Map.Entry Rx : entriesSortedByValues(teslaNodeMap)) { if (getEUVar() >= (overdriveToggle ? outputVoltage * 2 : outputVoltage)) { IGregTechTileEntity node = Rx.getKey(); IMetaTileEntity nodeInside = node.getMetaTileEntity(); -- cgit From 209aba66021d742a606e03f5c2691cd5fee92942 Mon Sep 17 00:00:00 2001 From: basdxz Date: Sun, 19 Jul 2020 10:18:09 +0100 Subject: Tweak tesla range and add more config --- .../technus/tectech/loader/TecTechConfig.java | 18 +++++ .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 78 +++++++++++++--------- .../single/GT_MetaTileEntity_TeslaCoil.java | 24 +++---- 3 files changed, 75 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java index ae9da94b02..cc6afd3f00 100644 --- a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java @@ -21,6 +21,11 @@ public class TecTechConfig extends ConfigManager { public boolean DISABLE_BLOCK_HARDNESS_NERF; public float TURRET_DAMAGE_FACTOR; public float TURRET_EXPLOSION_FACTOR; + public int TESLA_MULTI_TOWER_RANGE; + public int TESLA_MULTI_TRANSCEIVER_RANGE; + public int TESLA_MULTI_COVER_RANGE; + public int TESLA_MULTI_PLASMA_RANGE_MULTI_T1; + public int TESLA_MULTI_PLASMA_RANGE_MULTI_T2; public int TESLA_MULTI_HELIUM_PLASMA_PER_SECOND; public int TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND; public int TESLA_MULTI_RADON_PLASMA_PER_SECOND; @@ -29,6 +34,7 @@ public class TecTechConfig extends ConfigManager { public int TESLA_MULTI_LOSS_PER_BLOCK_T2; public float TESLA_MULTI_OVERDRIVE_LOSS_FACTOR; public boolean TESLA_MULTI_GAS_OUTPUT; + public int TESLA_SINGLE_RANGE; public int TESLA_SINGLE_LOSS_PER_BLOCK; public float TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR; @@ -46,6 +52,11 @@ public class TecTechConfig extends ConfigManager { DISABLE_MATERIAL_LOADING_FFS = false; TURRET_DAMAGE_FACTOR = 10; TURRET_EXPLOSION_FACTOR = 1; + TESLA_MULTI_TOWER_RANGE= 32; + TESLA_MULTI_TRANSCEIVER_RANGE= 16; + TESLA_MULTI_COVER_RANGE= 16; + TESLA_MULTI_PLASMA_RANGE_MULTI_T1= 2; + TESLA_MULTI_PLASMA_RANGE_MULTI_T2= 4; TESLA_MULTI_HELIUM_PLASMA_PER_SECOND = 100; TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND = 50; TESLA_MULTI_RADON_PLASMA_PER_SECOND = 50; @@ -54,6 +65,7 @@ public class TecTechConfig extends ConfigManager { TESLA_MULTI_LOSS_PER_BLOCK_T2 = 1; TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = 0.25F; TESLA_MULTI_GAS_OUTPUT = false; + TESLA_SINGLE_RANGE = 20; TESLA_SINGLE_LOSS_PER_BLOCK = 1; TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = 0.25F; } @@ -84,6 +96,11 @@ public class TecTechConfig extends ConfigManager { DISABLE_MATERIAL_LOADING_FFS = _mainConfig.getBoolean("DisableMaterialLoading", "Debug", DISABLE_MATERIAL_LOADING_FFS, "Set to true to disable gregtech material processing"); + TESLA_MULTI_TOWER_RANGE = _mainConfig.getInt("TeslaMultiTowerRange", "Balance Tweaks", TESLA_MULTI_TOWER_RANGE, 0, Integer.MAX_VALUE, "Tesla Tower to Tower max range"); + TESLA_MULTI_TRANSCEIVER_RANGE = _mainConfig.getInt("TeslaMultiTransceiverRange", "Balance Tweaks", TESLA_MULTI_TRANSCEIVER_RANGE, 0, Integer.MAX_VALUE, "Tesla Tower to Transceiver max range"); + TESLA_MULTI_COVER_RANGE = _mainConfig.getInt("TeslaMultiCoverRange", "Balance Tweaks", TESLA_MULTI_COVER_RANGE, 0, Integer.MAX_VALUE, "Tesla Tower to Tesla Coil Rich Edition Cover max range"); + TESLA_MULTI_PLASMA_RANGE_MULTI_T1 = _mainConfig.getInt("TeslaMultiPlasmaRangeMultiT1", "Balance Tweaks", TESLA_MULTI_PLASMA_RANGE_MULTI_T1, 0, Integer.MAX_VALUE, "Tesla Tower T1 Plasmas Range Multiplier"); + TESLA_MULTI_PLASMA_RANGE_MULTI_T2 = _mainConfig.getInt("TeslaMultiPlasmaRangeMultiT2", "Balance Tweaks", TESLA_MULTI_PLASMA_RANGE_MULTI_T2, 0, Integer.MAX_VALUE, "Tesla Tower T2 Plasmas Range Multiplier"); TESLA_MULTI_HELIUM_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiHeliumPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_HELIUM_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower helium plasma consumed each second the tesla tower is active"); TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiNitrogenPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower nitrogen plasma consumed each second the tesla tower is active"); TESLA_MULTI_RADON_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiRadonPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_RADON_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower radon plasma consumed each second the tesla tower is active"); @@ -92,6 +109,7 @@ public class TecTechConfig extends ConfigManager { TESLA_MULTI_LOSS_PER_BLOCK_T2 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T2, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using radon plasma"); TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaMultiOverdriveLossFactor", "Balance Tweaks", TESLA_MULTI_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Tower power loss per amp as a factor of the tier voltage"); TESLA_MULTI_GAS_OUTPUT = _mainConfig.getBoolean("TeslaMultiMoltenOutput", "Balance Tweaks", TESLA_MULTI_GAS_OUTPUT, "Set to true to enable outputting plasmas as gasses from the tesla tower with a 1:1 ratio"); + TESLA_SINGLE_RANGE = _mainConfig.getInt("TeslaSingleRange", "Balance Tweaks", TESLA_SINGLE_RANGE, 0, Integer.MAX_VALUE, "Tesla Transceiver to max range"); TESLA_SINGLE_LOSS_PER_BLOCK = _mainConfig.getInt("TeslaSingleLossPerBlock", "Balance Tweaks", TESLA_SINGLE_LOSS_PER_BLOCK, 0, Integer.MAX_VALUE, "Tesla Transceiver power transmission loss per block per amp"); TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaSingleOverdriveLossFactor", "Balance Tweaks", TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Transceiver power loss per amp as a factor of the tier voltage"); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index eca70ca63f..8ab6be3a50 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -53,6 +53,11 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region variables + private static final int transferRadiusTowerFromConfig = TecTech.configTecTech.TESLA_MULTI_TOWER_RANGE;//Default is 32 + private static final int transferRadiusTransceiverFromConfig = TecTech.configTecTech.TESLA_MULTI_TRANSCEIVER_RANGE;//Default is 16 + private static final int transferRadiusCoverUltimateFromConfig = TecTech.configTecTech.TESLA_MULTI_COVER_RANGE;//Default is 16 + private static final int plasmaRangeMultiT1 = TecTech.configTecTech.TESLA_MULTI_PLASMA_RANGE_MULTI_T1;//Default is 2 + private static final int plasmaRangeMultiT2 = TecTech.configTecTech.TESLA_MULTI_PLASMA_RANGE_MULTI_T2;//Default is 4 private static final int heliumUse = TecTech.configTecTech.TESLA_MULTI_HELIUM_PLASMA_PER_SECOND;//Default is 100 private static final int nitrogenUse = TecTech.configTecTech.TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND;//Default is 50 private static final int radonUse = TecTech.configTecTech.TESLA_MULTI_RADON_PLASMA_PER_SECOND;//Default is 50 @@ -168,17 +173,25 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; if (value < 0) return STATUS_TOO_LOW; - if (value > 40) return STATUS_TOO_HIGH; - if (value < 32) return STATUS_LOW; + if (value > transferRadiusTowerFromConfig) return STATUS_HIGH; + if (value < transferRadiusTowerFromConfig) return STATUS_LOW; return STATUS_OK; }; - private static final IStatusFunction TRANSFER_RADIUS_TRANSCEIVER_OR_COVER_ULTIMATE_STATUS = (base, p) -> { + private static final IStatusFunction TRANSFER_RADIUS_TRANSCEIVER_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; if (value < 0) return STATUS_TOO_LOW; - if (value > 20) return STATUS_TOO_HIGH; - if (value < 16) return STATUS_LOW; + if (value > transferRadiusTransceiverFromConfig) return STATUS_HIGH; + if (value < transferRadiusTransceiverFromConfig) return STATUS_LOW; + return STATUS_OK; + }; private static final IStatusFunction TRANSFER_RADIUS_COVER_ULTIMATE_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return STATUS_WRONG; + value = (int) value; + if (value < 0) return STATUS_TOO_LOW; + if (value > transferRadiusCoverUltimateFromConfig) return STATUS_HIGH; + if (value < transferRadiusCoverUltimateFromConfig) return STATUS_LOW; return STATUS_OK; }; private static final IStatusFunction OUTPUT_VOLTAGE_OR_CURRENT_STATUS = (base, p) -> { @@ -215,7 +228,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; - if (value == 0 || value == 20 || value == 40 || value == 60 || value == 80) return STATUS_HIGH; + if (value == 0) return STATUS_HIGH; return STATUS_LOW; }; private static final IStatusFunction POWER_STATUS = (base, p) -> { @@ -268,15 +281,16 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } private float getRangeMulti(int mTier, int vTier) { + //By Default: //Helium and Nitrogen Plasmas will double the range //Radon will quadruple the range int plasmaBoost; switch (plasmaTier) { case 2: - plasmaBoost = 4; + plasmaBoost = plasmaRangeMultiT2; break; case 1: - plasmaBoost = 2; + plasmaBoost = plasmaRangeMultiT1; break; default: plasmaBoost = 1; @@ -351,7 +365,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock eCapacitorHatches.clear(); Vec3Impl xyzOffsets; - xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -1, 1)); mTier = iGregTechTileEntity.getMetaIDOffset(xyzOffsets.get0(), xyzOffsets.get1(), xyzOffsets.get2()); if (mTier == 9){mTier = 6;}//Hacky remap because the ZPM coils were added later @@ -496,10 +509,10 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock popogaSetting = hatch_0.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); histHighSetting = hatch_1.makeInParameter(0, 0.75, HYSTERESIS_HIGH_SETTING_NAME, HYSTERESIS_HIGH_STATUS); popogaSetting = hatch_1.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); - transferRadiusTowerSetting = hatch_2.makeInParameter(0, 32, TRANSFER_RADIUS_TOWER_SETTING_NAME, TRANSFER_RADIUS_TOWER_STATUS); + transferRadiusTowerSetting = hatch_2.makeInParameter(0, transferRadiusTowerFromConfig, TRANSFER_RADIUS_TOWER_SETTING_NAME, TRANSFER_RADIUS_TOWER_STATUS); popogaSetting = hatch_2.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); - transferRadiusTransceiverSetting = hatch_3.makeInParameter(0, 16, TRANSFER_RADIUS_TRANSCEIVER_SETTING_NAME, TRANSFER_RADIUS_TRANSCEIVER_OR_COVER_ULTIMATE_STATUS); - transferRadiusCoverUltimateSetting = hatch_3.makeInParameter(1, 16, TRANSFER_RADIUS_COVER_ULTIMATE_SETTING_NAME, TRANSFER_RADIUS_TRANSCEIVER_OR_COVER_ULTIMATE_STATUS); + transferRadiusTransceiverSetting = hatch_3.makeInParameter(0, transferRadiusTransceiverFromConfig, TRANSFER_RADIUS_TRANSCEIVER_SETTING_NAME, TRANSFER_RADIUS_TRANSCEIVER_STATUS); + transferRadiusCoverUltimateSetting = hatch_3.makeInParameter(1, transferRadiusCoverUltimateFromConfig, TRANSFER_RADIUS_COVER_ULTIMATE_SETTING_NAME, TRANSFER_RADIUS_COVER_ULTIMATE_STATUS); outputVoltageSetting = hatch_4.makeInParameter(0, -1, OUTPUT_VOLTAGE_SETTING_NAME, OUTPUT_VOLTAGE_OR_CURRENT_STATUS); popogaSetting = hatch_4.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); outputCurrentSetting = hatch_5.makeInParameter(0, -1, OUTPUT_CURRENT_SETTING_NAME, OUTPUT_VOLTAGE_OR_CURRENT_STATUS); @@ -519,8 +532,8 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock popogaDisplay = hatch_1.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); transferRadiusTowerDisplay = hatch_2.makeOutParameter(0, 0, TRANSFER_RADIUS_TOWER_DISPLAY_NAME, TRANSFER_RADIUS_TOWER_STATUS); popogaDisplay = hatch_2.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); - transferRadiusTransceiverDisplay = hatch_3.makeOutParameter(0, 0, TRANSFER_RADIUS_TRANSCEIVER_DISPLAY_NAME, TRANSFER_RADIUS_TRANSCEIVER_OR_COVER_ULTIMATE_STATUS); - transferRadiusCoverUltimateDisplay = hatch_3.makeOutParameter(1, 0, TRANSFER_RADIUS_COVER_ULTIMATE_DISPLAY_NAME, TRANSFER_RADIUS_TRANSCEIVER_OR_COVER_ULTIMATE_STATUS); + transferRadiusTransceiverDisplay = hatch_3.makeOutParameter(0, 0, TRANSFER_RADIUS_TRANSCEIVER_DISPLAY_NAME, TRANSFER_RADIUS_TRANSCEIVER_STATUS); + transferRadiusCoverUltimateDisplay = hatch_3.makeOutParameter(1, 0, TRANSFER_RADIUS_COVER_ULTIMATE_DISPLAY_NAME, TRANSFER_RADIUS_COVER_ULTIMATE_STATUS); outputVoltageDisplay = hatch_4.makeOutParameter(0, 0, OUTPUT_VOLTAGE_DISPLAY_NAME, POWER_STATUS); popogaDisplay = hatch_4.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); outputCurrentDisplay = hatch_5.makeOutParameter(0, 0, OUTPUT_CURRENT_DISPLAY_NAME, POWER_STATUS); @@ -572,19 +585,19 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock public static Map generateTeslaNodeMap(IGregTechTileEntity orgin){ Map generatedNodeMap = new HashMap<>(); - IMetaTileEntity orginInside = orgin.getMetaTileEntity(); - int orginX; - int orginY; - int orginZ; - if (orginInside instanceof GT_MetaTileEntity_TM_teslaCoil) { - GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) orginInside; - orginX = teslaTower.posTop.get0(); - orginY = teslaTower.posTop.get1(); - orginZ = teslaTower.posTop.get2(); + IMetaTileEntity originInside = orgin.getMetaTileEntity(); + int originX; + int originY; + int originZ; + if (originInside instanceof GT_MetaTileEntity_TM_teslaCoil) { + GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) originInside; + originX = teslaTower.posTop.get0(); + originY = teslaTower.posTop.get1(); + originZ = teslaTower.posTop.get2(); } else { - orginX = orgin.getXCoord(); - orginY = orgin.getYCoord(); - orginZ = orgin.getZCoord(); + originX = orgin.getXCoord(); + originY = orgin.getYCoord(); + originZ = orgin.getZCoord(); } for (IGregTechTileEntity node : teslaNodeSet) { @@ -593,7 +606,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock teslaNodeSet.remove(null); continue; } else if (node == orgin || orgin.getWorld().provider.dimensionId != node.getWorld().provider.dimensionId) { - //Skip if looking at myself and skip if not in the same dimention + //Skip if looking at myself and skip if not in the same dimension //TODO, INTERDIM? continue; } @@ -615,9 +628,9 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } //Find the xyz offsets and calculate the distance between us and the target - int xPosOffset = targetX - orginX; - int yPosOffset = targetY - orginY; - int zPosOffset = targetZ - orginZ; + int xPosOffset = targetX - originX; + int yPosOffset = targetY - originY; + int zPosOffset = targetZ - originZ; int distance = (int) ceil(sqrt(pow(xPosOffset, 2) + pow(yPosOffset, 2) + pow(zPosOffset, 2))); //Thought we need abs here, we don't. An Integer to the power of two is going to be either 0 or positive. //We also can just put stuff here without further checks, as we always check the next section @@ -626,7 +639,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock return generatedNodeMap; } - public static Map cleanTeslaNodeMap(Map nodeMap, IGregTechTileEntity orgin) { + public static void cleanTeslaNodeMap(Map nodeMap, IGregTechTileEntity orgin) { IMetaTileEntity orginInside = orgin.getMetaTileEntity(); //Assumes that if the orgin is not a Tesla Tower, it mus be a single block. boolean isMulti = orginInside instanceof GT_MetaTileEntity_TM_teslaCoil; @@ -669,7 +682,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } nodeMap.remove(Rx.getKey()); } - return nodeMap; } @@ -727,7 +739,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock transferRadiusCoverUltimateDisplay.set(transferRadiusCoverUltimate); //Clean the teslaNodeMap - teslaNodeMap = cleanTeslaNodeMap(teslaNodeMap, mte); + cleanTeslaNodeMap(teslaNodeMap, mte); //Power transfer long sparks = outputCurrent; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index 657bf6b01a..fcf85e26c3 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -36,6 +36,7 @@ import static net.minecraft.util.StatCollector.translateToLocal; import static net.minecraft.util.StatCollector.translateToLocalFormatted; public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer { + private final static int transferRadiusMax = TecTech.configTecTech.TESLA_SINGLE_RANGE;//Default is 20 private final static int perBlockLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_PER_BLOCK;//Default is 1 private final static float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F @@ -43,18 +44,17 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB private final static HashSet sparkList = new HashSet<>(); private byte sparkCount = 0; - private final static int transferRadiusMax = 20; //Maximum user configurable - private final static int transferRadiusMin = 4; //Minimum user configurable - private int transferRadius = 16; //Default transferRadius setting + private final static int transferRadiusMin = 4;//Minimum user configurable + private int transferRadius = transferRadiusMax;//Default transferRadius setting - public boolean powerPassToggle = false; //Power Pass for public viewing - private final static int histSteps = 20; //Hysteresis Resolution - private int histSettingLow = 3; //Hysteresis Low Limit - private int histSettingHigh = 15; //Hysteresis High Limit - private final static int histLowLimit = 1; //How low can you configure it? - private final static int histHighLimit = 19; //How high can you configure it? - private float histLow = (float) histSettingLow / histSteps; //Power pass is disabled if power is under this fraction - private float histHigh = (float) histSettingHigh / histSteps; //Power pass is enabled if power is over this fraction + public boolean powerPassToggle = false;//Power Pass for public viewing + private final static int histSteps = 20;//Hysteresis Resolution + private int histSettingLow = 3;//Hysteresis Low Limit + private int histSettingHigh = 15;//Hysteresis High Limit + private final static int histLowLimit = 1;//How low can you configure it? + private final static int histHighLimit = 19;//How high can you configure it? + private float histLow = (float) histSettingLow / histSteps;//Power pass is disabled if power is under this fraction + private float histHigh = (float) histSettingHigh / histSteps;//Power pass is enabled if power is over this fraction private final long outputVoltage = V[mTier]; private boolean overdriveToggle = false; @@ -284,7 +284,7 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB int transferRadiusCover = (int) (transferRadiusTower / 1.25); //Clean the teslaNodeMap - teslaNodeMap = cleanTeslaNodeMap(teslaNodeMap, aBaseMetaTileEntity); + cleanTeslaNodeMap(teslaNodeMap, aBaseMetaTileEntity); //Power transfer while (outputCurrent > 0) { -- cgit From ed1a7521080d545318fccd27b5c4351489db9690 Mon Sep 17 00:00:00 2001 From: basdxz Date: Sun, 19 Jul 2020 12:05:45 +0100 Subject: Refactor TecTechConfig.java --- .../java/com/github/technus/tectech/TecTech.java | 2 +- .../technus/tectech/loader/TecTechConfig.java | 156 ++++++++++++--------- .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 18 +-- .../single/GT_MetaTileEntity_TeslaCoil.java | 2 +- 4 files changed, 100 insertions(+), 78 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 47a3b576b1..809a7e877d 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -78,7 +78,7 @@ public class TecTech { LOGGER.error(Reference.MODID + " could not load its config file. Things are going to be weird!"); } - if (configTecTech.modAdminErrorLogs) { + if (configTecTech.MOD_ADMIN_ERROR_LOGS) { LOGGER.setDebugOutput(DEBUG_MODE); LOGGER.debug("moduleAdminErrorLogs is enabled"); moduleAdminErrorLogs = new IngameErrorLog(); diff --git a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java index cc6afd3f00..66e549ddb1 100644 --- a/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java @@ -9,65 +9,70 @@ public class TecTechConfig extends ConfigManager { super(pConfigBaseDirectory, pModCollectionDirectory, pModID); } - public boolean modAdminErrorLogs; - //final static to allow compiler to remove the debug code when this is false public static boolean DEBUG_MODE = false; + public boolean DISABLE_MATERIAL_LOADING_FFS; + public boolean BOOM_ENABLE; + public boolean DISABLE_BLOCK_HARDNESS_NERF; public boolean EASY_SCAN; public boolean NERF_FUSION; public boolean ENABLE_TURRET_EXPLOSIONS; - public boolean DISABLE_MATERIAL_LOADING_FFS; - public boolean DISABLE_BLOCK_HARDNESS_NERF; public float TURRET_DAMAGE_FACTOR; public float TURRET_EXPLOSION_FACTOR; - public int TESLA_MULTI_TOWER_RANGE; - public int TESLA_MULTI_TRANSCEIVER_RANGE; - public int TESLA_MULTI_COVER_RANGE; - public int TESLA_MULTI_PLASMA_RANGE_MULTI_T1; - public int TESLA_MULTI_PLASMA_RANGE_MULTI_T2; - public int TESLA_MULTI_HELIUM_PLASMA_PER_SECOND; - public int TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND; - public int TESLA_MULTI_RADON_PLASMA_PER_SECOND; + + public boolean MOD_ADMIN_ERROR_LOGS; + + public boolean TESLA_MULTI_GAS_OUTPUT; + public float TESLA_MULTI_LOSS_FACTOR_OVERDRIVE; public int TESLA_MULTI_LOSS_PER_BLOCK_T0; public int TESLA_MULTI_LOSS_PER_BLOCK_T1; public int TESLA_MULTI_LOSS_PER_BLOCK_T2; - public float TESLA_MULTI_OVERDRIVE_LOSS_FACTOR; - public boolean TESLA_MULTI_GAS_OUTPUT; - public int TESLA_SINGLE_RANGE; + public int TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM; + public int TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN; + public int TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON; + public int TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1; + public int TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2; + public int TESLA_MULTI_RANGE_COVER; + public int TESLA_MULTI_RANGE_TOWER; + public int TESLA_MULTI_RANGE_TRANSCEIVER; + public float TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE; public int TESLA_SINGLE_LOSS_PER_BLOCK; - public float TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR; + public int TESLA_SINGLE_RANGE; /** * This loading phases do not correspond to mod loading phases! */ @Override protected void PreInit() { - modAdminErrorLogs = false; - EASY_SCAN = false; + DISABLE_MATERIAL_LOADING_FFS = false; + BOOM_ENABLE = true; - NERF_FUSION = false; DISABLE_BLOCK_HARDNESS_NERF = false; + EASY_SCAN = false; + NERF_FUSION = false; ENABLE_TURRET_EXPLOSIONS = true; - DISABLE_MATERIAL_LOADING_FFS = false; TURRET_DAMAGE_FACTOR = 10; TURRET_EXPLOSION_FACTOR = 1; - TESLA_MULTI_TOWER_RANGE= 32; - TESLA_MULTI_TRANSCEIVER_RANGE= 16; - TESLA_MULTI_COVER_RANGE= 16; - TESLA_MULTI_PLASMA_RANGE_MULTI_T1= 2; - TESLA_MULTI_PLASMA_RANGE_MULTI_T2= 4; - TESLA_MULTI_HELIUM_PLASMA_PER_SECOND = 100; - TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND = 50; - TESLA_MULTI_RADON_PLASMA_PER_SECOND = 50; + + MOD_ADMIN_ERROR_LOGS = false; + + TESLA_MULTI_GAS_OUTPUT = false; + TESLA_MULTI_LOSS_FACTOR_OVERDRIVE = 0.25F; TESLA_MULTI_LOSS_PER_BLOCK_T0 = 1; TESLA_MULTI_LOSS_PER_BLOCK_T1 = 1; TESLA_MULTI_LOSS_PER_BLOCK_T2 = 1; - TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = 0.25F; - TESLA_MULTI_GAS_OUTPUT = false; - TESLA_SINGLE_RANGE = 20; + TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM = 100; + TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN = 50; + TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON = 50; + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1 = 2; + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2 = 4; + TESLA_MULTI_RANGE_COVER = 16; + TESLA_MULTI_RANGE_TOWER = 32; + TESLA_MULTI_RANGE_TRANSCEIVER = 16; + TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE = 0.25F; TESLA_SINGLE_LOSS_PER_BLOCK = 1; - TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = 0.25F; + TESLA_SINGLE_RANGE = 20; } /** @@ -75,43 +80,61 @@ public class TecTechConfig extends ConfigManager { */ @Override protected void Init() { - modAdminErrorLogs = _mainConfig.getBoolean("AdminErrorLog", "Modules", modAdminErrorLogs, - "If set to true, every op/admin will receive all errors occurred during the startup phase as in game message on join"); - DEBUG_MODE = _mainConfig.getBoolean("DebugMode", "Debug", DEBUG_MODE, + DEBUG_MODE = _mainConfig.getBoolean("DebugMode", "debug", DEBUG_MODE, "Enables logging and other purely debug features"); - EASY_SCAN = _mainConfig.getBoolean("EasyScan", "Features", EASY_SCAN, - "Enables tricorder to scan EM i/o hatches directly, too CHEEKY"); - BOOM_ENABLE = _mainConfig.getBoolean("BoomEnable", "Features", BOOM_ENABLE, + DISABLE_MATERIAL_LOADING_FFS = _mainConfig.getBoolean("DisableMaterialLoading", "debug", + DISABLE_MATERIAL_LOADING_FFS, "Set to true to disable gregtech material processing"); + + BOOM_ENABLE = _mainConfig.getBoolean("BoomEnable", "features", BOOM_ENABLE, "Set to false to disable explosions on everything bad that you can do"); - NERF_FUSION = _mainConfig.getBoolean("NerfFusion", "Features", NERF_FUSION, + DISABLE_BLOCK_HARDNESS_NERF = _mainConfig.getBoolean("DisableBlockHardnessNerf", "features", + DISABLE_BLOCK_HARDNESS_NERF, "Set to true to disable the block hardness nerf"); + EASY_SCAN = _mainConfig.getBoolean("EasyScan", "features", EASY_SCAN, + "Enables tricorder to scan EM i/o hatches directly, too CHEEKY"); + NERF_FUSION = _mainConfig.getBoolean("NerfFusion", "features", NERF_FUSION, "Set to true to enable removal of plasmas heavier than Fe and other weird ones"); - ENABLE_TURRET_EXPLOSIONS = _mainConfig.getBoolean("TurretBoomEnable", "Features", ENABLE_TURRET_EXPLOSIONS, - "Set to false to disable explosions caused by EM turrets"); - TURRET_DAMAGE_FACTOR = _mainConfig.getFloat("TurretDamageFactor", "Features", TURRET_DAMAGE_FACTOR, 0, Short.MAX_VALUE, - "Damage is multiplied by this number"); - TURRET_EXPLOSION_FACTOR = _mainConfig.getFloat("TurretExplosionFactor", "Features", TURRET_EXPLOSION_FACTOR, 0, Short.MAX_VALUE, - "Explosion strength is multiplied by this number"); - DISABLE_BLOCK_HARDNESS_NERF = _mainConfig.getBoolean("DisableBlockHardnessNerf", "Features", DISABLE_BLOCK_HARDNESS_NERF, - "Set to true to disable the block hardness nerf"); - DISABLE_MATERIAL_LOADING_FFS = _mainConfig.getBoolean("DisableMaterialLoading", "Debug", DISABLE_MATERIAL_LOADING_FFS, - "Set to true to disable gregtech material processing"); - - TESLA_MULTI_TOWER_RANGE = _mainConfig.getInt("TeslaMultiTowerRange", "Balance Tweaks", TESLA_MULTI_TOWER_RANGE, 0, Integer.MAX_VALUE, "Tesla Tower to Tower max range"); - TESLA_MULTI_TRANSCEIVER_RANGE = _mainConfig.getInt("TeslaMultiTransceiverRange", "Balance Tweaks", TESLA_MULTI_TRANSCEIVER_RANGE, 0, Integer.MAX_VALUE, "Tesla Tower to Transceiver max range"); - TESLA_MULTI_COVER_RANGE = _mainConfig.getInt("TeslaMultiCoverRange", "Balance Tweaks", TESLA_MULTI_COVER_RANGE, 0, Integer.MAX_VALUE, "Tesla Tower to Tesla Coil Rich Edition Cover max range"); - TESLA_MULTI_PLASMA_RANGE_MULTI_T1 = _mainConfig.getInt("TeslaMultiPlasmaRangeMultiT1", "Balance Tweaks", TESLA_MULTI_PLASMA_RANGE_MULTI_T1, 0, Integer.MAX_VALUE, "Tesla Tower T1 Plasmas Range Multiplier"); - TESLA_MULTI_PLASMA_RANGE_MULTI_T2 = _mainConfig.getInt("TeslaMultiPlasmaRangeMultiT2", "Balance Tweaks", TESLA_MULTI_PLASMA_RANGE_MULTI_T2, 0, Integer.MAX_VALUE, "Tesla Tower T2 Plasmas Range Multiplier"); - TESLA_MULTI_HELIUM_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiHeliumPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_HELIUM_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower helium plasma consumed each second the tesla tower is active"); - TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiNitrogenPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower nitrogen plasma consumed each second the tesla tower is active"); - TESLA_MULTI_RADON_PLASMA_PER_SECOND = _mainConfig.getInt("TeslaMultiRadonPlasmaPerSecond", "Balance Tweaks", TESLA_MULTI_RADON_PLASMA_PER_SECOND, 0, Integer.MAX_VALUE, "Tesla Tower radon plasma consumed each second the tesla tower is active"); - TESLA_MULTI_LOSS_PER_BLOCK_T0 = _mainConfig.getInt("TeslaMultiLossPerBlockT0", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T0, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using no plasmas"); - TESLA_MULTI_LOSS_PER_BLOCK_T1 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T1, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using helium or nitrogen plasma"); - TESLA_MULTI_LOSS_PER_BLOCK_T2 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "Balance Tweaks", TESLA_MULTI_LOSS_PER_BLOCK_T2, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using radon plasma"); - TESLA_MULTI_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaMultiOverdriveLossFactor", "Balance Tweaks", TESLA_MULTI_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Tower power loss per amp as a factor of the tier voltage"); - TESLA_MULTI_GAS_OUTPUT = _mainConfig.getBoolean("TeslaMultiMoltenOutput", "Balance Tweaks", TESLA_MULTI_GAS_OUTPUT, "Set to true to enable outputting plasmas as gasses from the tesla tower with a 1:1 ratio"); - TESLA_SINGLE_RANGE = _mainConfig.getInt("TeslaSingleRange", "Balance Tweaks", TESLA_SINGLE_RANGE, 0, Integer.MAX_VALUE, "Tesla Transceiver to max range"); - TESLA_SINGLE_LOSS_PER_BLOCK = _mainConfig.getInt("TeslaSingleLossPerBlock", "Balance Tweaks", TESLA_SINGLE_LOSS_PER_BLOCK, 0, Integer.MAX_VALUE, "Tesla Transceiver power transmission loss per block per amp"); - TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR = _mainConfig.getFloat("TeslaSingleOverdriveLossFactor", "Balance Tweaks", TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR, 0, 1, "Additional Tesla Transceiver power loss per amp as a factor of the tier voltage"); + ENABLE_TURRET_EXPLOSIONS = _mainConfig.getBoolean("TurretBoomEnable", "features", + ENABLE_TURRET_EXPLOSIONS, "Set to false to disable explosions caused by EM turrets"); + TURRET_DAMAGE_FACTOR = _mainConfig.getFloat("TurretDamageFactor", "features", TURRET_DAMAGE_FACTOR, + 0, Short.MAX_VALUE, "Damage is multiplied by this number"); + TURRET_EXPLOSION_FACTOR = _mainConfig.getFloat("TurretExplosionFactor", "features", + TURRET_EXPLOSION_FACTOR, 0, Short.MAX_VALUE, "Explosion strength is multiplied by this number"); + + MOD_ADMIN_ERROR_LOGS = _mainConfig.getBoolean("AdminErrorLog", "modules", MOD_ADMIN_ERROR_LOGS, + "If set to true, every op/admin will receive all errors occurred during the startup phase as in game message on join"); + + TESLA_MULTI_GAS_OUTPUT = _mainConfig.getBoolean("TeslaMultiGasOutput", "tesla_tweaks", + TESLA_MULTI_GAS_OUTPUT, "Set to true to enable outputting plasmas as gasses from the tesla tower with a 1:1 ratio"); + TESLA_MULTI_LOSS_FACTOR_OVERDRIVE = _mainConfig.getFloat("TeslaMultiLossFactorOverdrive", "tesla_tweaks", + TESLA_MULTI_LOSS_FACTOR_OVERDRIVE, 0, 1, "Additional Tesla Tower power loss per amp as a factor of the tier voltage"); + TESLA_MULTI_LOSS_PER_BLOCK_T0 = _mainConfig.getInt("TeslaMultiLossPerBlockT0", "tesla_tweaks", + TESLA_MULTI_LOSS_PER_BLOCK_T0, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using no plasmas"); + TESLA_MULTI_LOSS_PER_BLOCK_T1 = _mainConfig.getInt("TeslaMultiLossPerBlockT1", "tesla_tweaks", + TESLA_MULTI_LOSS_PER_BLOCK_T1, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using helium or nitrogen plasma"); + TESLA_MULTI_LOSS_PER_BLOCK_T2 = _mainConfig.getInt("TeslaMultiLossPerBlockT2", "tesla_tweaks", + TESLA_MULTI_LOSS_PER_BLOCK_T2, 0, Integer.MAX_VALUE, "Tesla Tower power transmission loss per block per amp using radon plasma"); + TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM = _mainConfig.getInt("TeslaMultiPlasmaPerSecondT1Helium", + "tesla_tweaks", TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM, 0, Integer.MAX_VALUE, "Tesla Tower helium plasma consumed each second the tesla tower is active"); + TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN = _mainConfig.getInt("TeslaMultiPlasmaPerSecondT1Nitrogen", + "tesla_tweaks", TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN, 0, Integer.MAX_VALUE, "Tesla Tower nitrogen plasma consumed each second the tesla tower is active"); + TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON = _mainConfig.getInt("TeslaMultiPlasmaPerSecondT2Radon", + "tesla_tweaks", TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON, 0, Integer.MAX_VALUE, "Tesla Tower radon plasma consumed each second the tesla tower is active"); + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1 = _mainConfig.getInt("TeslaMultiRangeCoefficientPlasmaT1", + "tesla_tweaks", TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1, 0, Integer.MAX_VALUE, "Tesla Tower T1 Plasmas Range Multiplier"); + TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2 = _mainConfig.getInt("TeslaMultiRangeCoefficientPlasmaT2", + "tesla_tweaks", TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2, 0, Integer.MAX_VALUE, "Tesla Tower T2 Plasmas Range Multiplier"); + TESLA_MULTI_RANGE_COVER = _mainConfig.getInt("TeslaMultiRangeCover", "tesla_tweaks", + TESLA_MULTI_RANGE_COVER, 0, Integer.MAX_VALUE, "Tesla Tower to Tesla Coil Rich Edition Cover max range"); + TESLA_MULTI_RANGE_TOWER = _mainConfig.getInt("TeslaMultiRangeTower", "tesla_tweaks", + TESLA_MULTI_RANGE_TOWER, 0, Integer.MAX_VALUE, "Tesla Tower to Tower max range"); + TESLA_MULTI_RANGE_TRANSCEIVER = _mainConfig.getInt("TeslaMultiRangeTransceiver", "tesla_tweaks", + TESLA_MULTI_RANGE_TRANSCEIVER, 0, Integer.MAX_VALUE, "Tesla Tower to Transceiver max range"); + TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE = _mainConfig.getFloat("TeslaSingleLossFactorOverdrive", "tesla_tweaks", + TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE, 0, 1, "Additional Tesla Transceiver power loss per amp as a factor of the tier voltage"); + TESLA_SINGLE_LOSS_PER_BLOCK = _mainConfig.getInt("TeslaSingleLossPerBlock", "tesla_tweaks", + TESLA_SINGLE_LOSS_PER_BLOCK, 0, Integer.MAX_VALUE, "Tesla Transceiver power transmission loss per block per amp"); + TESLA_SINGLE_RANGE = _mainConfig.getInt("TeslaSingleRange", "tesla_tweaks", + TESLA_SINGLE_RANGE, 0, Integer.MAX_VALUE, "Tesla Transceiver to max range"); } /** @@ -119,6 +142,5 @@ public class TecTechConfig extends ConfigManager { */ @Override protected void PostInit() { - } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 8ab6be3a50..e63a92d107 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -53,18 +53,18 @@ import static net.minecraft.util.StatCollector.translateToLocal; public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region variables - private static final int transferRadiusTowerFromConfig = TecTech.configTecTech.TESLA_MULTI_TOWER_RANGE;//Default is 32 - private static final int transferRadiusTransceiverFromConfig = TecTech.configTecTech.TESLA_MULTI_TRANSCEIVER_RANGE;//Default is 16 - private static final int transferRadiusCoverUltimateFromConfig = TecTech.configTecTech.TESLA_MULTI_COVER_RANGE;//Default is 16 - private static final int plasmaRangeMultiT1 = TecTech.configTecTech.TESLA_MULTI_PLASMA_RANGE_MULTI_T1;//Default is 2 - private static final int plasmaRangeMultiT2 = TecTech.configTecTech.TESLA_MULTI_PLASMA_RANGE_MULTI_T2;//Default is 4 - private static final int heliumUse = TecTech.configTecTech.TESLA_MULTI_HELIUM_PLASMA_PER_SECOND;//Default is 100 - private static final int nitrogenUse = TecTech.configTecTech.TESLA_MULTI_NITROGEN_PLASMA_PER_SECOND;//Default is 50 - private static final int radonUse = TecTech.configTecTech.TESLA_MULTI_RADON_PLASMA_PER_SECOND;//Default is 50 + private static final int transferRadiusTowerFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TOWER;//Default is 32 + private static final int transferRadiusTransceiverFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TRANSCEIVER;//Default is 16 + private static final int transferRadiusCoverUltimateFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_COVER;//Default is 16 + private static final int plasmaRangeMultiT1 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1;//Default is 2 + private static final int plasmaRangeMultiT2 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2;//Default is 4 + private static final int heliumUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM;//Default is 100 + private static final int nitrogenUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN;//Default is 50 + private static final int radonUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON;//Default is 50 //Default is {1, 1, 1} private static final int[] plasmaTierLoss = new int[]{TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T0, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T1, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T2}; - private static final float overDriveLoss = TecTech.configTecTech.TESLA_MULTI_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F; + private static final float overDriveLoss = TecTech.configTecTech.TESLA_MULTI_LOSS_FACTOR_OVERDRIVE;//Default is 0.25F; private static final boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_GAS_OUTPUT; //Default is false //Face icons diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index fcf85e26c3..8d3696d9ad 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -38,7 +38,7 @@ import static net.minecraft.util.StatCollector.translateToLocalFormatted; public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer { private final static int transferRadiusMax = TecTech.configTecTech.TESLA_SINGLE_RANGE;//Default is 20 private final static int perBlockLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_PER_BLOCK;//Default is 1 - private final static float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_OVERDRIVE_LOSS_FACTOR;//Default is 0.25F + private final static float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE;//Default is 0.25F private Map teslaNodeMap = new HashMap<>();//Tesla Map to map them tesla bois! private final static HashSet sparkList = new HashSet<>(); -- cgit From 9566fb9aa67f3dfc9f2e03252dd005fb0dda1fda Mon Sep 17 00:00:00 2001 From: basdxz Date: Sun, 19 Jul 2020 16:02:05 +0100 Subject: Bump version --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 90269e3abe..ec613edcdf 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614 -tectech.version=3.9.1 +tectech.version=3.10.0 ic2.version=2.2.790-experimental codechickenlib.version=1.1.3.140 -- cgit From 9182db0ff8a7205b012b6a61b26c8550c52fc744 Mon Sep 17 00:00:00 2001 From: basdxz Date: Sun, 19 Jul 2020 16:09:49 +0100 Subject: Added git hash as version appendage https://forgegradle.readthedocs.io/en/latest/cookbook/ --- build.gradle | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c969fb1e47..8701264e0e 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,12 @@ file "build.properties" withReader { ext.config = new ConfigSlurper().parse prop } +def getVersionAppendage() { + def proc = "git rev-parse --short HEAD".execute() + proc.waitFor() + return "DEV." + proc.exitValue() ? "GITBORK" : proc.text.trim() +} + ext.set("minecraftVersion","${config.minecraft.version}-${config.forge.version}-${config.minecraft.version}") import de.undercouch.gradle.tasks.download.Download @@ -51,7 +57,7 @@ sourceSets { } } -version = "${config.minecraft.version}-${config.tectech.version}" +version = "${config.minecraft.version}-${config.tectech.version}-"+getVersionAppendage() group = "com.github.technus" archivesBaseName = "TecTech" -- cgit From adf24c44acf9762f80ccb4d2903b8870d5137ed6 Mon Sep 17 00:00:00 2001 From: basdxz Date: Sun, 19 Jul 2020 16:22:23 +0100 Subject: Flipping this seems to fix it? --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8701264e0e..9689a82607 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ file "build.properties" withReader { def getVersionAppendage() { def proc = "git rev-parse --short HEAD".execute() proc.waitFor() - return "DEV." + proc.exitValue() ? "GITBORK" : proc.text.trim() + return "DEV." + proc.exitValue() ? proc.text.trim() : "GITBORK" } ext.set("minecraftVersion","${config.minecraft.version}-${config.forge.version}-${config.minecraft.version}") -- cgit From 18ec8a9bc25aed92dda52334c4fff5b39f1dc010 Mon Sep 17 00:00:00 2001 From: basdxz Date: Tue, 4 Aug 2020 22:32:50 +0100 Subject: Repackage Tesla code into interfaces and util class Currently bugged, Tesla Towers always drain power from Energy Injectors --- .../tectech/mechanics/spark/ThaumSpark.java | 29 +- .../tectech/mechanics/tesla/ITeslaConnectable.java | 127 ++++++++ .../mechanics/tesla/ITeslaConnectableSimple.java | 22 ++ .../tectech/thing/cover/GT_Cover_TM_TeslaCoil.java | 65 +++- .../cover/GT_Cover_TM_TeslaCoil_Ultimate.java | 10 + .../multi/GT_MetaTileEntity_TM_teslaCoil.java | 357 +++++++-------------- .../single/GT_MetaTileEntity_TeslaCoil.java | 171 +++++----- 7 files changed, 450 insertions(+), 331 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java create mode 100644 src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectableSimple.java diff --git a/src/main/java/com/github/technus/tectech/mechanics/spark/ThaumSpark.java b/src/main/java/com/github/technus/tectech/mechanics/spark/ThaumSpark.java index 604624828c..e31e63f250 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/spark/ThaumSpark.java +++ b/src/main/java/com/github/technus/tectech/mechanics/spark/ThaumSpark.java @@ -1,5 +1,7 @@ package com.github.technus.tectech.mechanics.spark; +import com.github.technus.tectech.util.Vec3Impl; + import java.io.Serializable; import java.util.Objects; @@ -9,22 +11,10 @@ public class ThaumSpark implements Serializable { public int x, y, z, wID; public byte xR, yR, zR; - public ThaumSpark(){ - this.x = 0; - this.z = 0; - this.y = 0; - - this.xR = 0; - this.yR = 0; - this.zR = 0; - - this.wID = 0; - } - public ThaumSpark(int x, int y, int z, byte xR, byte yR, byte zR, int wID) { this.x = x; - this.z = z; this.y = y; + this.z = z; this.xR = xR; this.yR = yR; @@ -33,6 +23,19 @@ public class ThaumSpark implements Serializable { this.wID = wID; } + public ThaumSpark(Vec3Impl origin, Vec3Impl target, int wID) { + this.x = origin.get0(); + this.y = origin.get1(); + this.z = origin.get2(); + + Vec3Impl offset = target.sub(origin); + this.xR = (byte) offset.get0(); + this.yR = (byte) offset.get1(); + this.zR = (byte) offset.get2(); + + this.wID = wID; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java new file mode 100644 index 0000000000..07ecc4bc31 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java @@ -0,0 +1,127 @@ +package com.github.technus.tectech.mechanics.tesla; + +import com.github.technus.tectech.mechanics.spark.ThaumSpark; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import static com.github.technus.tectech.util.Util.entriesSortedByValues; +import static java.lang.Math.sqrt; + +public interface ITeslaConnectable extends ITeslaConnectableSimple { + //Map with all Teslas in the same dimension and the distance to them //TODO Range + Map teslaNodeMap = new HashMap<>(); + //ThaumCraft lighting coordinate pairs, so we can send them in bursts and save on lag + HashSet sparkList = new HashSet<>(); + + //-128 to -1 disables capability + //0 means any source or target + //1 to 127 must match on source and target or source/target must be 0 + byte getTeslaTransmissionCapability(); + + //Transmission Range is typically 16+ in blocks + int getTeslaTransmissionRange(); + boolean isOverdriveEnabled(); + + int getTeslaEnergyLossPerBlock(); + float getTeslaOverdriveLossCoefficient(); + + long getTeslaOutputVoltage(); + long getTeslaOutputCurrent(); + + boolean teslaDrainEnergy(long teslaVoltageDrained); + + class TeslaUtil { + public static final HashSet teslaNodeSet = new HashSet<>();//Targets for power transmission + + public static void generateTeslaNodeMap(ITeslaConnectable origin) { + origin.teslaNodeMap.clear(); + for (ITeslaConnectableSimple target : teslaNodeSet) { + //Sanity checks + if (target == null) { + //The Tesla Covers do not remove themselves from the list and this is the code that does + teslaNodeSet.remove(null); + continue; + } else if (origin.equals(target) || !origin.getTeslaDimension().equals(target.getTeslaDimension())) { + //Skip if looking at myself and skip if not in the same dimension + //TODO, INTERDIM? + continue; + } else if (origin.getTeslaTransmissionCapability() != 0 && origin.getTeslaReceptionCapability() != 0 && + origin.getTeslaTransmissionCapability() != origin.getTeslaReceptionCapability()) { + //Skip if incompatible + continue; + } + + //Range calc + int distance = (int) sqrt(origin.getTeslaPosition().distanceSq(target.getTeslaPosition())); + if (distance > origin.getTeslaTransmissionRange() * target.getTeslaReceptionCoefficient()) { + //Skip if the range is too vast + continue; + } + origin.teslaNodeMap.put(target, distance); + } + } + + public static void cleanTeslaNodeMap(ITeslaConnectable origin) { + //TODO Do we still need this? + for (ITeslaConnectableSimple target : origin.teslaNodeMap.keySet()) { + if (target == null) { + origin.teslaNodeMap.remove(null); + } + } + } + + public static long powerTeslaNodeMap(ITeslaConnectable origin) { + //Teslas can only send OR receive + if (origin.isTeslaReadyToReceive()) { + return 0L;//TODO Negative values to indicate charging? + } + long remainingAmperes = origin.getTeslaOutputCurrent(); + while (remainingAmperes > 0) { + long startingAmperes = remainingAmperes; + for (Map.Entry Rx : entriesSortedByValues(teslaNodeMap)) { + if (origin.getTeslaStoredEnergy() < (origin.isOverdriveEnabled() ? origin.getTeslaOutputVoltage() * 2 : origin.getTeslaOutputVoltage())) { + //Return and end the tick if we're out of energy to send + return origin.getTeslaOutputCurrent() - remainingAmperes; + } + + ITeslaConnectableSimple target = Rx.getKey(); + int distance = Rx.getValue(); + + //Calculate the voltage output + long outputVoltageInjectable; + long outputVoltageConsumption; + + if (origin.isOverdriveEnabled()) { + outputVoltageInjectable = origin.getTeslaOutputVoltage(); + outputVoltageConsumption = origin.getTeslaOutputVoltage() + (distance * origin.getTeslaEnergyLossPerBlock()) + + (long) Math.round(origin.getTeslaOutputVoltage() * origin.getTeslaOverdriveLossCoefficient()); + } else { + outputVoltageInjectable = origin.getTeslaOutputVoltage() - (distance * origin.getTeslaEnergyLossPerBlock()); + outputVoltageConsumption = origin.getTeslaOutputVoltage(); + } + + //Skip the target if the cost is too high + if (origin.getTeslaStoredEnergy() < outputVoltageConsumption) { + continue; + } + + if (target.teslaInjectEnergy(outputVoltageInjectable)) { + origin.teslaDrainEnergy(outputVoltageConsumption); + sparkList.add(new ThaumSpark(origin.getTeslaPosition(), target.getTeslaPosition(), origin.getTeslaDimension())); + remainingAmperes--; + } + if (remainingAmperes == 0) { + return origin.getTeslaOutputCurrent(); + } + } + //End the tick after one iteration with no transmissions + if (remainingAmperes == startingAmperes) { + return origin.getTeslaOutputCurrent() - remainingAmperes; + } + } + return origin.getTeslaOutputCurrent() - remainingAmperes; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectableSimple.java b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectableSimple.java new file mode 100644 index 0000000000..3b56b6968c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectableSimple.java @@ -0,0 +1,22 @@ +package com.github.technus.tectech.mechanics.tesla; + +import com.github.technus.tectech.util.Vec3Impl; + +public interface ITeslaConnectableSimple { + //-128 to -1 disables capability + //0 means any source or target + //1 to 127 must match on source and target or source/target must be 0 + byte getTeslaReceptionCapability(); + + //Reception Coefficient is a range extension, typical is 1 + float getTeslaReceptionCoefficient(); + + boolean isTeslaReadyToReceive(); + + long getTeslaStoredEnergy(); + + boolean teslaInjectEnergy(long teslaVoltageInjected); + + Vec3Impl getTeslaPosition(); + Integer getTeslaDimension(); +} diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java index 6442ba51b6..2efe2f3cbc 100644 --- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java @@ -1,40 +1,95 @@ package com.github.technus.tectech.thing.cover; +import com.github.technus.tectech.mechanics.tesla.ITeslaConnectableSimple; +import com.github.technus.tectech.util.Vec3Impl; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_TM_teslaCoil.teslaNodeSet; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.*; import static ic2.api.info.Info.DMG_ELECTRIC; -public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior { +public class GT_Cover_TM_TeslaCoil extends GT_CoverBehavior implements ITeslaConnectableSimple { + private IGregTechTileEntity IGT; + public GT_Cover_TM_TeslaCoil() { } + @Override public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { - if (aTileEntity.getEUCapacity() > 0) { - teslaNodeSet.add(aTileEntity.getIGregTechTileEntityOffset(0, 0, 0)); + //Only do stuff if we're on top and have power + if (aSide == 1 || aTileEntity.getEUCapacity() > 0) { + //Pull IGT onto the outside, should only execute first tick + if (IGT == null) { + IGT = aTileEntity.getIGregTechTileEntityOffset(0, 0, 0); + } + //Makes sure we're on the list + teslaNodeSet.add(this); } + return super.doCoverThings(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity, aTimer); } + @Override public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return "Do not attempt to use screwdriver!"; + return "Do not attempt to use screwdriver!";//TODO Translation support } + @Override public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } + @Override public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { + //Shock a non-hazmat player if they dare stuff a screwdriver into one of these if (aTileEntity.getStoredEU() > 0 && !GT_Utility.isWearingFullElectroHazmat(aPlayer)) { aPlayer.attackEntityFrom(DMG_ELECTRIC, 20); } return aCoverVariable; } + @Override public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + //It updates once every 200 ticks, so once every 10 seconds return 200; } + + @Override + public byte getTeslaReceptionCapability() { + return 2; + } + + @Override + public float getTeslaReceptionCoefficient() { + return 1; + } + + @Override + public boolean isTeslaReadyToReceive() { + return true; + } + + @Override + public long getTeslaStoredEnergy() { + return IGT.getStoredEU(); + } + + @Override + public Vec3Impl getTeslaPosition() { + return new Vec3Impl(IGT); + } + + @Override + public Integer getTeslaDimension() { + return IGT.getWorld().provider.dimensionId; + } + + @Override + public boolean teslaInjectEnergy(long teslaVoltageInjected) { + //Same as in the microwave transmitters, this does not account for amp limits + return IGT.injectEnergyUnits((byte) 1, teslaVoltageInjected, 1L) > 0L; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java index 2b5db1f5c9..028ac3a4d6 100644 --- a/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java +++ b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil_Ultimate.java @@ -7,23 +7,33 @@ public class GT_Cover_TM_TeslaCoil_Ultimate extends GT_Cover_TM_TeslaCoil { public GT_Cover_TM_TeslaCoil_Ultimate() { } + @Override public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return true; } + @Override public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } + @Override public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { return true; } + @Override public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } + @Override public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { return true; } + + @Override + public byte getTeslaReceptionCapability() { + return 1; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index e63a92d107..729b73044e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -7,8 +7,7 @@ import com.github.technus.tectech.mechanics.spark.RendererMessage; import com.github.technus.tectech.mechanics.spark.ThaumSpark; import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; -import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil; -import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil_Ultimate; +import com.github.technus.tectech.mechanics.tesla.ITeslaConnectable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Capacitor; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_DynamoMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; @@ -18,7 +17,6 @@ import com.github.technus.tectech.thing.metaTileEntity.multi.base.INameFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.IStatusFunction; import com.github.technus.tectech.thing.metaTileEntity.multi.base.Parameters; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; -import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_TeslaCoil; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.util.Vec3Impl; import cpw.mods.fml.relauncher.Side; @@ -37,21 +35,18 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; import static com.github.technus.tectech.mechanics.structure.Structure.adders; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.*; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsBA0; import static com.github.technus.tectech.thing.metaTileEntity.multi.base.LedStatus.*; import static com.github.technus.tectech.util.CommonValues.V; -import static com.github.technus.tectech.util.Util.entriesSortedByValues; import static gregtech.api.enums.GT_Values.E; import static java.lang.Math.*; import static net.minecraft.util.StatCollector.translateToLocal; -public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { +public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable, ITeslaConnectable { //region variables private static final int transferRadiusTowerFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TOWER;//Default is 32 private static final int transferRadiusTransceiverFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TRANSCEIVER;//Default is 16 @@ -76,9 +71,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private FluidStack[] mOutputFluidsQueue; //Used to buffer the fluid outputs, so the tesla takes a second to 'cool' any plasma it would output as a gas - public static final HashSet teslaNodeSet = new HashSet<>(); //Targets for power transmission - private final HashSet sparkList = new HashSet<>(); //Thaumcraft lighting coordinate pairs, so we can send them in bursts and save on lag - private Map teslaNodeMap = new HashMap<>(); //Targets for power transmission private final ArrayList eCapacitorHatches = new ArrayList<>(); //Capacitor hatches which determine the max voltage tier and count of amps private int sortTime = 0; //Scan timer used for tesla search intervals @@ -88,6 +80,10 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock private int vTier = -1; //Tesla voltage tier limited by capacitors private long outputCurrentMax = 0; //Tesla current output limited by capacitors + //outputVoltage and current after settings + private long outputVoltage; + private long outputCurrent; + //Prevents unnecessary offset calculation, saving on lag private byte oldRotation = -1; private byte oldOrientation = -1; @@ -185,7 +181,8 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock if (value > transferRadiusTransceiverFromConfig) return STATUS_HIGH; if (value < transferRadiusTransceiverFromConfig) return STATUS_LOW; return STATUS_OK; - }; private static final IStatusFunction TRANSFER_RADIUS_COVER_ULTIMATE_STATUS = (base, p) -> { + }; + private static final IStatusFunction TRANSFER_RADIUS_COVER_ULTIMATE_STATUS = (base, p) -> { double value = p.get(); if (Double.isNaN(value)) return STATUS_WRONG; value = (int) value; @@ -262,24 +259,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock super(aName); } - private int getPerBlockLoss(){ - return plasmaTierLoss[plasmaTier]; - } - - private long[] getOutputVoltage(long outputVoltage, int distance, boolean overDriveToggle) { - long outputVoltageInjectable; - long outputVoltageConsumption; - - if (overDriveToggle) { - outputVoltageInjectable = outputVoltage; - outputVoltageConsumption = outputVoltage + (distance * getPerBlockLoss()) + (long) Math.round(overDriveLoss * outputVoltage); - } else { - outputVoltageInjectable = outputVoltage - (distance * getPerBlockLoss()); - outputVoltageConsumption = outputVoltage; - } - return new long[]{outputVoltageInjectable, outputVoltageConsumption}; - } - private float getRangeMulti(int mTier, int vTier) { //By Default: //Helium and Nitrogen Plasmas will double the range @@ -303,16 +282,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock return 1F * plasmaBoost; } - private void thaumLightning(IGregTechTileEntity mte, IGregTechTileEntity node) { - byte xR = (byte) (node.getXCoord() - posTop.get0()); - byte yR = (byte) (node.getYCoord() - posTop.get1()); - byte zR = (byte) (node.getZCoord() - posTop.get2()); - - int wID = mte.getWorld().provider.dimensionId; - - sparkList.add(new ThaumSpark(posTop.get0(), posTop.get1(), posTop.get2(), xR, yR, zR, wID)); - } - private void checkPlasmaBoost() { //If there's fluid in the queue, try to output it //That way it takes at least a second to 'process' the plasma @@ -367,7 +336,9 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock Vec3Impl xyzOffsets; xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -1, 1)); mTier = iGregTechTileEntity.getMetaIDOffset(xyzOffsets.get0(), xyzOffsets.get1(), xyzOffsets.get2()); - if (mTier == 9){mTier = 6;}//Hacky remap because the ZPM coils were added later + if (mTier == 9) { + mTier = 6; + }//Hacky remap because the ZPM coils were added later if (structureCheck_EM(shape, blockType, blockMetas[mTier], addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 3, 16, 0) && eCapacitorHatches.size() > 0) { for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) { @@ -480,11 +451,10 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock @Override public void onRemoval() { super.onRemoval(); - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - if (aBaseMetaTileEntity.isClientSide()) { + if (this.getBaseMetaTileEntity().isClientSide()) { return; } - teslaNodeSet.remove(aBaseMetaTileEntity); + teslaNodeSet.remove(this); for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(cap)) { cap.getBaseMetaTileEntity().setActive(false); @@ -558,7 +528,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); energyCapacity = aNBT.getLong("eEnergyCapacity"); - teslaNodeSet.add(this.getBaseMetaTileEntity()); + teslaNodeSet.add(this); } @Override @@ -578,113 +548,10 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) { super.onFirstTick_EM(aBaseMetaTileEntity); if (!aBaseMetaTileEntity.isClientSide()) { - teslaNodeSet.add(aBaseMetaTileEntity); - } - } - - - public static Map generateTeslaNodeMap(IGregTechTileEntity orgin){ - Map generatedNodeMap = new HashMap<>(); - IMetaTileEntity originInside = orgin.getMetaTileEntity(); - int originX; - int originY; - int originZ; - if (originInside instanceof GT_MetaTileEntity_TM_teslaCoil) { - GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) originInside; - originX = teslaTower.posTop.get0(); - originY = teslaTower.posTop.get1(); - originZ = teslaTower.posTop.get2(); - } else { - originX = orgin.getXCoord(); - originY = orgin.getYCoord(); - originZ = orgin.getZCoord(); - } - - for (IGregTechTileEntity node : teslaNodeSet) { - if (node == null) { - //Technically, the Tesla Covers do not remove themselves from the list and this is the code that does - teslaNodeSet.remove(null); - continue; - } else if (node == orgin || orgin.getWorld().provider.dimensionId != node.getWorld().provider.dimensionId) { - //Skip if looking at myself and skip if not in the same dimension - //TODO, INTERDIM? - continue; - } - - //Makes the target coordinates the center of the sphere of the tower if it has one - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - int targetX; - int targetY; - int targetZ; - if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil) { - GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; - targetX = teslaTower.posTop.get0(); - targetY = teslaTower.posTop.get1(); - targetZ = teslaTower.posTop.get2(); - } else { - targetX = node.getXCoord(); - targetY = node.getYCoord(); - targetZ = node.getZCoord(); - } - - //Find the xyz offsets and calculate the distance between us and the target - int xPosOffset = targetX - originX; - int yPosOffset = targetY - originY; - int zPosOffset = targetZ - originZ; - int distance = (int) ceil(sqrt(pow(xPosOffset, 2) + pow(yPosOffset, 2) + pow(zPosOffset, 2))); - //Thought we need abs here, we don't. An Integer to the power of two is going to be either 0 or positive. - //We also can just put stuff here without further checks, as we always check the next section - generatedNodeMap.put(node, distance); - } - return generatedNodeMap; - } - - public static void cleanTeslaNodeMap(Map nodeMap, IGregTechTileEntity orgin) { - IMetaTileEntity orginInside = orgin.getMetaTileEntity(); - //Assumes that if the orgin is not a Tesla Tower, it mus be a single block. - boolean isMulti = orginInside instanceof GT_MetaTileEntity_TM_teslaCoil; - - for (Map.Entry Rx : nodeMap.entrySet()) { - //All the checks need to pass or the target gets removed from the transmission list - IGregTechTileEntity node = Rx.getKey(); - //Null check - if (node != null) { - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - //We need this in a try catch, just as a precaution that a chunk had unloaded or a machine was removed - try { - //Is it an Active Tesla Tower with at least some energy capacity? - //Singles and Multis can send power here, so we don't check - if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && node.isActive()) { - GT_MetaTileEntity_TM_teslaCoil teslaTower = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; - if (teslaTower.maxEUStore() > 0) { - continue; - } - //Is it a Tesla Transceiver with at least one battery? - //Only multis can send power to singles - } else if (isMulti && nodeInside instanceof GT_MetaTileEntity_TeslaCoil) { - GT_MetaTileEntity_TeslaCoil teslaTransceiver = (GT_MetaTileEntity_TeslaCoil) nodeInside; - if (teslaTransceiver.mBatteryCount > 0) { - continue; - } - //Is it a tile entity with a Tesla Coil Cover? - //Only single can send power to non-Rich edition covers - //Since Rich edition inherits from regular, we need the final check - } else if (!isMulti && node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil && - node.getEUCapacity() > 0 && !(node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil_Ultimate)) { - continue; - //Is it a tile entity with a Tesla Coil Cover Rich edition? - //Only multis can send power to Rich edition covers - } else if (isMulti && node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil_Ultimate && node.getEUCapacity() > 0) { - continue; - } - } catch (Exception ignored) { - } - } - nodeMap.remove(Rx.getKey()); + teslaNodeSet.add(this); } } - @Override public boolean onRunningTick(ItemStack aStack) { IGregTechTileEntity mte = getBaseMetaTileEntity(); @@ -706,13 +573,12 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock if (sortTime == sortTimeMinSetting.get()) { sortTime = 0; sortTimeDisplay.updateStatus(); - teslaNodeMap = generateTeslaNodeMap(mte); + generateTeslaNodeMap(this); } sortTime++; sortTimeDisplay.set(sortTime); //Power Limit Settings - long outputVoltage; if (outputVoltageSetting.get() > 0) { outputVoltage = min(outputVoltageMax, (long) outputVoltageSetting.get()); } else { @@ -720,95 +586,34 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } outputVoltageDisplay.set(outputVoltage); - long outputCurrent; if (outputCurrentSetting.get() > 0) { outputCurrent = min(outputCurrentMax, (long) outputCurrentSetting.get()); } else { outputCurrent = outputCurrentMax; } - outputCurrentDisplay.set(0); - - //Stuff to do if ePowerPass - if (ePowerPass) { - //Range calculation and display - int transferRadiusTower = (int) (transferRadiusTowerSetting.get() * getRangeMulti(mTier, vTier)); - transferRadiusTowerDisplay.set(transferRadiusTower); - int transferRadiusTransceiver = (int) (transferRadiusTransceiverSetting.get() * getRangeMulti(mTier, vTier)); - transferRadiusTransceiverDisplay.set(transferRadiusTransceiver); - int transferRadiusCoverUltimate = (int) (transferRadiusCoverUltimateSetting.get() * getRangeMulti(mTier, vTier)); - transferRadiusCoverUltimateDisplay.set(transferRadiusCoverUltimate); - - //Clean the teslaNodeMap - cleanTeslaNodeMap(teslaNodeMap, mte); - - //Power transfer - long sparks = outputCurrent; - while (sparks > 0) { - boolean overdriveToggle = overDriveSetting.get() > 0; - boolean idle = true; - for (Map.Entry Rx : entriesSortedByValues(teslaNodeMap)) { - if (getEUVar() >= (overdriveToggle ? outputVoltage * 2 : outputVoltage)) { - IGregTechTileEntity node = Rx.getKey(); - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - - long[] outputVoltageNow = getOutputVoltage(outputVoltage, Rx.getValue(), overdriveToggle); - long outputVoltageInjectable = outputVoltageNow[0]; - long outputVoltageConsumption = outputVoltageNow[1]; - - if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && Rx.getValue() <= transferRadiusTower) { - GT_MetaTileEntity_TM_teslaCoil nodeTesla = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; - if (!nodeTesla.ePowerPass) { - if (nodeTesla.getEUVar() + outputVoltageInjectable <= (nodeTesla.maxEUStore() / 2)) { - setEUVar(getEUVar() - outputVoltageConsumption); - node.increaseStoredEnergyUnits(outputVoltageConsumption, true); - thaumLightning(mte, node); - sparks--; - idle = false; - } - } - } else if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil && Rx.getValue() <= transferRadiusTransceiver) { - GT_MetaTileEntity_TeslaCoil nodeTesla = (GT_MetaTileEntity_TeslaCoil) nodeInside; - if (!nodeTesla.powerPassToggle) { - if (node.injectEnergyUnits((byte) 6, outputVoltageInjectable, 1L) > 0L) { - setEUVar(getEUVar() - outputVoltageConsumption); - thaumLightning(mte, node); - sparks--; - idle = false; - } - } - } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil_Ultimate) && Rx.getValue() <= transferRadiusCoverUltimate) { - if (node.injectEnergyUnits((byte) 1, outputVoltageInjectable, 1L) > 0L) { - setEUVar(getEUVar() - outputVoltageConsumption); - thaumLightning(mte, node); - sparks--; - idle = false; - } - } - if (sparks == 0) { - break; - } - } else { - idle = true; - break; - } - } - if (idle) { - break; - } - } - outputCurrentDisplay.set(outputCurrent - sparks); - if (sortTime % 60 == 0 && !sparkList.isEmpty()) { - NetworkDispatcher.INSTANCE.sendToAllAround(new RendererMessage.RendererData(sparkList), - mte.getWorld().provider.dimensionId, - posTop.get0(), - posTop.get1(), - posTop.get2(), - 256); - } - sparkList.clear(); - } else { - outputCurrentDisplay.set(0); + + //Range calculation and display + int transferRadiusTower = getTeslaTransmissionRange(); + transferRadiusTowerDisplay.set(transferRadiusTower); + transferRadiusTransceiverDisplay.set(transferRadiusTower * 2); + transferRadiusCoverUltimateDisplay.set(transferRadiusTower); + + //Clean the teslaNodeMap + cleanTeslaNodeMap(this); + + //Power transfer + outputCurrentDisplay.set(powerTeslaNodeMap(this)); + + if (!sparkList.isEmpty()) { + NetworkDispatcher.INSTANCE.sendToAllAround(new RendererMessage.RendererData(sparkList), + mte.getWorld().provider.dimensionId, + posTop.get0(), + posTop.get1(), + posTop.get2(), + 256); } + sparkList.clear(); + return true; } @@ -882,4 +687,88 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock public String[] getStructureDescription(ItemStack stackSize) { return description; } + + @Override + public byte getTeslaReceptionCapability() { + return 0; + } + + @Override + public float getTeslaReceptionCoefficient() { + return 0; + } + + @Override + public byte getTeslaTransmissionCapability() { + return 1; + } + + @Override + public int getTeslaTransmissionRange() { + return (int) (transferRadiusTowerSetting.get() * getRangeMulti(mTier, vTier)); + } + + @Override + public boolean isOverdriveEnabled() { + return overDriveSetting.get() > 0; + } + + @Override + public int getTeslaEnergyLossPerBlock() { + return plasmaTierLoss[plasmaTier]; + } + + @Override + public float getTeslaOverdriveLossCoefficient() { + return overDriveLoss; + } + + @Override + public long getTeslaOutputVoltage() { + return outputVoltage; + } + + @Override + public long getTeslaOutputCurrent() { + return outputCurrent; + } + + @Override + public boolean teslaDrainEnergy(long teslaVoltageDrained) { + if (getEUVar() < teslaVoltageDrained) { + return false; + } + + setEUVar(getEUVar() - teslaVoltageDrained); + return true; + } + + @Override + public boolean isTeslaReadyToReceive() { + return !this.ePowerPass; + } + + @Override + public long getTeslaStoredEnergy() { + return getEUVar(); + } + + @Override + public Vec3Impl getTeslaPosition() { + return posTop; + } + + @Override + public Integer getTeslaDimension() { + return this.getBaseMetaTileEntity().getWorld().provider.dimensionId; + } + + @Override + public boolean teslaInjectEnergy(long teslaVoltageInjected) { + if (this.getEUVar() + teslaVoltageInjected <= (this.maxEUStore() / 2)) { + this.getBaseMetaTileEntity().increaseStoredEnergyUnits(teslaVoltageInjected, true); + return true; + } + return false; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java index 8d3696d9ad..388a253b27 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_TeslaCoil.java @@ -1,14 +1,14 @@ package com.github.technus.tectech.thing.metaTileEntity.single; +import com.github.technus.tectech.mechanics.tesla.ITeslaConnectable; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; import com.github.technus.tectech.loader.NetworkDispatcher; import com.github.technus.tectech.mechanics.spark.RendererMessage; import com.github.technus.tectech.mechanics.spark.ThaumSpark; -import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil; -import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil_Ultimate; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_TM_teslaCoil; +import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.util.Vec3Impl; import eu.usrv.yamcore.auxiliary.PlayerChatHelper; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -23,25 +23,19 @@ import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.reflect.FieldUtils; import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_TM_teslaCoil.*; +import static com.github.technus.tectech.mechanics.tesla.ITeslaConnectable.TeslaUtil.*; import static com.github.technus.tectech.util.CommonValues.V; -import static com.github.technus.tectech.util.Util.entriesSortedByValues; import static com.github.technus.tectech.thing.metaTileEntity.Textures.*; import static java.lang.Math.round; import static net.minecraft.util.StatCollector.translateToLocal; import static net.minecraft.util.StatCollector.translateToLocalFormatted; -public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer { +public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer implements ITeslaConnectable { private final static int transferRadiusMax = TecTech.configTecTech.TESLA_SINGLE_RANGE;//Default is 20 private final static int perBlockLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_PER_BLOCK;//Default is 1 private final static float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE;//Default is 0.25F - private Map teslaNodeMap = new HashMap<>();//Tesla Map to map them tesla bois! - private final static HashSet sparkList = new HashSet<>(); private byte sparkCount = 0; private final static int transferRadiusMin = 4;//Minimum user configurable @@ -229,23 +223,22 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { super.onFirstTick(aBaseMetaTileEntity); if (!aBaseMetaTileEntity.isClientSide()) { - teslaNodeSet.add(aBaseMetaTileEntity); + teslaNodeSet.add(this); } } @Override public void onRemoval() { super.onRemoval(); - IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity(); - if (!aBaseMetaTileEntity.isClientSide()) { - teslaNodeSet.remove(aBaseMetaTileEntity); + if (!this.getBaseMetaTileEntity().isClientSide()) { + teslaNodeSet.remove(this); } } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - teslaNodeSet.add(this.getBaseMetaTileEntity()); + teslaNodeSet.add(this); } @Override @@ -270,72 +263,13 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB //Create the teslaNodeMap if (sortTime == sortTimeMax) { sortTime = 0; - teslaNodeMap = generateTeslaNodeMap(aBaseMetaTileEntity); + generateTeslaNodeMap(this); } sortTime++; - //Stuff to do if ePowerPass - if (powerPassToggle) { - float rangeFrac = (float) ((-0.5 * Math.pow(energyFrac, 2)) + (1.5 * energyFrac)); - long outputCurrent = mBatteryCount; - //Radius for transceiver to tower transfers - int transferRadiusTower = (int) (transferRadius * rangeFrac); - //Radius for transceiver to cover transfers - int transferRadiusCover = (int) (transferRadiusTower / 1.25); - - //Clean the teslaNodeMap - cleanTeslaNodeMap(teslaNodeMap, aBaseMetaTileEntity); - - //Power transfer - while (outputCurrent > 0) { - boolean idle = true; - for (Map.Entry Rx : entriesSortedByValues(teslaNodeMap)) { - if (getEUVar() >= (overdriveToggle ? outputVoltage * 2 : outputVoltage)) { - IGregTechTileEntity node = Rx.getKey(); - IMetaTileEntity nodeInside = node.getMetaTileEntity(); - - long[] outputVoltageNow = getOutputVoltage(outputVoltage, Rx.getValue(), overdriveToggle); - long outputVoltageInjectable = outputVoltageNow[0]; - long outputVoltageConsumption = outputVoltageNow[1]; - - if (nodeInside instanceof GT_MetaTileEntity_TM_teslaCoil && Rx.getValue() <= transferRadiusTower) { - GT_MetaTileEntity_TM_teslaCoil nodeTesla = (GT_MetaTileEntity_TM_teslaCoil) nodeInside; - if (!nodeTesla.ePowerPass) { - if (nodeTesla.getEUVar() + outputVoltageInjectable <= (nodeTesla.maxEUStore() / 2)) { - setEUVar(getEUVar() - outputVoltageConsumption); - node.increaseStoredEnergyUnits(outputVoltageInjectable, true); - thaumLightning(aBaseMetaTileEntity, node); - outputCurrent--; - idle = false; - } - } - } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil) && !(node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil_Ultimate) && Rx.getValue() <= transferRadiusCover) { - if (nodeInside instanceof GT_MetaTileEntity_TeslaCoil){ - GT_MetaTileEntity_TeslaCoil nodeTesla = (GT_MetaTileEntity_TeslaCoil) nodeInside; - if (nodeTesla.powerPassToggle){ - continue; - } - } - if (node.injectEnergyUnits((byte) 1, outputVoltageInjectable, 1L) > 0L) { - setEUVar(getEUVar() - outputVoltageConsumption); - thaumLightning(aBaseMetaTileEntity, node); - outputCurrent--; - idle = false; - } - } - if (outputCurrent == 0) { - break; - } - } else { - idle = true; - break; - } - } - if (idle) { - break; - } - } - } + //Send Power + powerTeslaNodeMap(this); + sparkCount++; if (sparkCount == 60 && !sparkList.isEmpty()) { sparkCount = 0; @@ -364,4 +298,83 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB return true; } + @Override + public byte getTeslaReceptionCapability() { + return 1; + } + + @Override + public float getTeslaReceptionCoefficient() { + return 1; + } + + @Override + public byte getTeslaTransmissionCapability() { + return 2; + } + + @Override + public int getTeslaTransmissionRange() { + return transferRadius; + } + + @Override + public boolean isOverdriveEnabled() { + return overdriveToggle; + } + + @Override + public int getTeslaEnergyLossPerBlock() { + return perBlockLoss; + } + + @Override + public float getTeslaOverdriveLossCoefficient() { + return overDriveLoss; + } + + @Override + public long getTeslaOutputVoltage() { + return outputVoltage; + } + + @Override + public long getTeslaOutputCurrent() { + return mBatteryCount; + } + + @Override + public boolean teslaDrainEnergy(long teslaVoltageDrained) { + if (getEUVar() < teslaVoltageDrained) { + return false; + } + + setEUVar(getEUVar() - teslaVoltageDrained); + return true; + } + + @Override + public boolean isTeslaReadyToReceive() { + return !this.powerPassToggle; + } + + @Override + public long getTeslaStoredEnergy() { + return getEUVar(); + } + + @Override + public Vec3Impl getTeslaPosition() { + return new Vec3Impl(this.getBaseMetaTileEntity()); + } + + @Override + public Integer getTeslaDimension() { + return this.getBaseMetaTileEntity().getWorld().provider.dimensionId; + } + + @Override + public boolean teslaInjectEnergy(long teslaVoltageInjected) { + return this.getBaseMetaTileEntity().injectEnergyUnits((byte) 1, teslaVoltageInjected, 1L) > 0L; + } } -- cgit From 23e8843b01ec3ff95123e6472656c61632c1c598 Mon Sep 17 00:00:00 2001 From: basdxz Date: Wed, 5 Aug 2020 00:14:42 +0100 Subject: Fix Tesla draining energy when disabled --- .../thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 729b73044e..93f6e50c5a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -619,12 +619,15 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock @Override public long maxEUStore() { - return energyCapacity * 2; + //Setting the power here so that the tower looses all it's charge once disabled + //This also stops it from exploding + return getBaseMetaTileEntity().isActive() ? energyCapacity * 2 : 0; } @Override public long getEUVar() { - return getBaseMetaTileEntity().isActive() ? super.getEUVar() : 0; + //Same reason as maxEUStore, set to 1 instead of zero so it doesn't drain constantly + return getBaseMetaTileEntity().isActive() ? super.getEUVar() : 1; } private boolean addCapacitorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { -- cgit From 30097b9cf11fefa9a40eaa19b0fa6d397f42d34d Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Tue, 29 Sep 2020 20:45:58 +0200 Subject: removed unused import (#38) --- .../technus/tectech/mechanics/structure/StructureUtility.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java index 2f6998f028..521b0e7645 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java @@ -217,11 +217,11 @@ public class StructureUtility { /** * Allows block duplicates (with different meta) */ - public static IStructureElementNoPlacement ofBlocksMapHint(Map> blocsMap, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofBlocksMapHint(Map> blocsMap, Block hintBlock, int hintMeta) { if (blocsMap == null || blocsMap.isEmpty() || hintBlock == null) { throw new IllegalArgumentException(); } - for (Set value : blocsMap.values()) { + for (Collection value : blocsMap.values()) { if (value.isEmpty()) { throw new IllegalArgumentException(); } @@ -336,11 +336,11 @@ public class StructureUtility { /** * Allows block duplicates (with different meta) */ - public static IStructureElement ofBlocksMap(Map> blocsMap, Block defaultBlock, int defaultMeta) { + public static IStructureElement ofBlocksMap(Map> blocsMap, Block defaultBlock, int defaultMeta) { if (blocsMap == null || blocsMap.isEmpty() || defaultBlock == null) { throw new IllegalArgumentException(); } - for (Set value : blocsMap.values()) { + for (Collection value : blocsMap.values()) { if (value.isEmpty()) { throw new IllegalArgumentException(); } -- cgit From 9b640643a01ad9835f1baf4ca37cd25c558dfb6f Mon Sep 17 00:00:00 2001 From: Tec Date: Wed, 7 Oct 2020 19:50:28 +0200 Subject: Add getters for translating relative coordinates to world --- .../alignment/enumerable/ExtendedFacing.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java index 2a93bcc540..5949b432df 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java +++ b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java @@ -128,6 +128,7 @@ public enum ExtendedFacing { private static final Map NAME_LOOKUP = stream(VALUES).collect(toMap(ExtendedFacing::getName2, (extendedFacing) -> extendedFacing)); private final ForgeDirection direction; + private final ForgeDirection a,b,c; private final Rotation rotation; private final Flip flip; @@ -206,6 +207,9 @@ public enum ExtendedFacing { default: throw new RuntimeException("More impossible..."); } + this.a=a; + this.b=b; + this.c=c; integerAxisSwap =new IntegerAxisSwap(a,b,c); } @@ -327,4 +331,28 @@ public enum ExtendedFacing { public IntegerAxisSwap getIntegerAxisSwap() { return integerAxisSwap; } + + public ForgeDirection getRelativeLeftInWorld() { + return a; + } + + public ForgeDirection getRelativeRightInWorld() { + return a.getOpposite(); + } + + public ForgeDirection getRelativeDownInWorld() { + return b; + } + + public ForgeDirection getRelativeUpInWorld() { + return b.getOpposite(); + } + + public ForgeDirection getRelativeBackInWorld() { + return c; + } + + public ForgeDirection getRelativeForwardInWorld() { + return c.getOpposite(); + } } -- cgit From 57d8442bdaab404c06bff3abebd4d962d6512b89 Mon Sep 17 00:00:00 2001 From: Tec Date: Wed, 7 Oct 2020 20:11:34 +0200 Subject: Invalidate machine on rotation --- .../multi/base/GT_MetaTileEntity_MultiblockBase_EM.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index 9e508f9e7e..9af6d40df7 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -166,10 +166,11 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } @Override - public void setExtendedFacing(ExtendedFacing alignment) { - if(extendedFacing!=alignment){ - extendedFacing=alignment; + public void setExtendedFacing(ExtendedFacing newExtendedFacing) { + if(extendedFacing!=newExtendedFacing){ + extendedFacing=newExtendedFacing; IGregTechTileEntity base = getBaseMetaTileEntity(); + mMachine = false; if (getBaseMetaTileEntity().isServerSide()) { NetworkDispatcher.INSTANCE.sendToAllAround(new AlignmentMessage.AlignmentData(this), base.getWorld().provider.dimensionId, -- cgit From 4c06bcafc8eda79369777abb2135397e12f1356a Mon Sep 17 00:00:00 2001 From: basdxz Date: Wed, 4 Nov 2020 04:46:38 +0000 Subject: Remove Cofh Core dep Compiles fine without. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9689a82607..d10b7d77df 100644 --- a/build.gradle +++ b/build.gradle @@ -127,7 +127,7 @@ dependencies { compile "micdoodle8.mods:Galacticraft:${config.galacticraft.version}:API" compile "com.mod-buildcraft:buildcraft:${config.buildcraft.version}:dev" //Ivy - compile name: 'CoFHCore', version: config.cofhcore.version, ext: 'jar' + //compile name: 'CoFHCore', version: config.cofhcore.version, ext: 'jar' } task getGregTech(type: Download) { -- cgit From e26a6f058a5e1dcdb4c73b076d9970ec4d731eb7 Mon Sep 17 00:00:00 2001 From: basdxz Date: Wed, 4 Nov 2020 08:32:25 +0000 Subject: Add the COFH Core Dep back as runtime Needed for Thaum stuff --- build.gradle | 14 +++++++++++--- build.properties | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index d10b7d77df..ca8da27742 100644 --- a/build.gradle +++ b/build.gradle @@ -97,10 +97,14 @@ repositories { name "Tterrag maven" url "https://maven.tterrag.com/" } - ivy { //CoFHCore - name 'gtnh_download_source' - artifactPattern "http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]-[revision].[ext]" + maven { + name = "Curse Maven" + url = "https://www.cursemaven.com" } + //ivy { //CoFHCore + // name 'gtnh_download_source' + // artifactPattern "http://downloads.gtnewhorizons.com/Mods_for_Jenkins/[module]-[revision].[ext]" + //} } dependencies { @@ -126,8 +130,12 @@ dependencies { compile "micdoodle8.mods:Galacticraft-Planets:${config.galacticraft.version}:Dev" compile "micdoodle8.mods:Galacticraft:${config.galacticraft.version}:API" compile "com.mod-buildcraft:buildcraft:${config.buildcraft.version}:dev" + + //TODO Re-work the formatting and add documentation + runtime "curse.maven:cofh-core:${config.cofh_core_version}" //Ivy //compile name: 'CoFHCore', version: config.cofhcore.version, ext: 'jar' + } task getGregTech(type: Download) { diff --git a/build.properties b/build.properties index be76171615..d0ee72aeac 100644 --- a/build.properties +++ b/build.properties @@ -8,7 +8,8 @@ codechickencore.version=1.0.7.47 nei.version=1.0.5.120 gregtech.jenkinsbuild=648 gregtech.version=5.09.33.52 -cofhcore.version=[1.7.10]3.1.4-329-dev +#cofhcore.version=[1.7.10]3.1.4-329-dev +cofh_core_version=2388751 yamcore.version=0.5.79 baubles.version=1.0.1.10 thaumcraft.version=4.2.3.5 -- cgit From dac069de4ba59e14833d7c661f4c8ff5722abc84 Mon Sep 17 00:00:00 2001 From: basdxz Date: Wed, 4 Nov 2020 08:32:46 +0000 Subject: Fix disconnect on Tesla Lightning Now properly getting the world from player --- .../technus/tectech/mechanics/spark/RendererMessage.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java b/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java index f2fd17817d..58caed7951 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java +++ b/src/main/java/com/github/technus/tectech/mechanics/spark/RendererMessage.java @@ -5,6 +5,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import eu.usrv.yamcore.network.client.AbstractClientMessageHandler; import io.netty.buffer.ByteBuf; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; @@ -71,12 +72,14 @@ public class RendererMessage implements IMessage { private static void thaumLightning(int tX, int tY, int tZ, int tXN, int tYN, int tZN, int wID) { //This is enough to check for thaum, since it only ever matters for client side effects (Tested not to crash) if (Loader.isModLoaded("Thaumcraft")) { - World world = DimensionManager.getWorld(wID); - FXLightningBolt bolt = new FXLightningBolt(world, tX + 0.5F, tY + 0.5F, tZ + 0.5F, tX + tXN + 0.5F, tY + tYN + 0.5F, tZ + tZN + 0.5F, world.rand.nextLong(), 6, 0.5F, 8); - bolt.defaultFractal(); - bolt.setType(2); - bolt.setWidth(0.125F); - bolt.finalizeBolt(); + World world = Minecraft.getMinecraft().theWorld; + if (world.provider.dimensionId == wID){ + FXLightningBolt bolt = new FXLightningBolt(world, tX + 0.5F, tY + 0.5F, tZ + 0.5F, tX + tXN + 0.5F, tY + tYN + 0.5F, tZ + tZN + 0.5F, world.rand.nextLong(), 6, 0.5F, 8); + bolt.defaultFractal(); + bolt.setType(2); + bolt.setWidth(0.125F); + bolt.finalizeBolt(); + } } } } \ No newline at end of file -- cgit From 8bed7d36a5e0574015395b64e8f9d3d59d3cb9f8 Mon Sep 17 00:00:00 2001 From: basdxz Date: Wed, 4 Nov 2020 09:03:34 +0000 Subject: Fixes ConcurrentModificationException on Tesla Connected Cleaning Now just removes nulls if any --- .../technus/tectech/mechanics/tesla/ITeslaConnectable.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java index 07ecc4bc31..e397c1dc5f 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java +++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java @@ -4,14 +4,14 @@ import com.github.technus.tectech.mechanics.spark.ThaumSpark; import java.util.HashMap; import java.util.HashSet; -import java.util.Map; +import java.util.Objects; import static com.github.technus.tectech.util.Util.entriesSortedByValues; import static java.lang.Math.sqrt; public interface ITeslaConnectable extends ITeslaConnectableSimple { //Map with all Teslas in the same dimension and the distance to them //TODO Range - Map teslaNodeMap = new HashMap<>(); + HashMap teslaNodeMap = new HashMap<>(); //ThaumCraft lighting coordinate pairs, so we can send them in bursts and save on lag HashSet sparkList = new HashSet<>(); @@ -64,12 +64,8 @@ public interface ITeslaConnectable extends ITeslaConnectableSimple { } public static void cleanTeslaNodeMap(ITeslaConnectable origin) { - //TODO Do we still need this? - for (ITeslaConnectableSimple target : origin.teslaNodeMap.keySet()) { - if (target == null) { - origin.teslaNodeMap.remove(null); - } - } + //Wipes all null objects, in practice this is unloaded or improperly removed tesla objects + origin.teslaNodeMap.keySet().removeIf(Objects::isNull); } public static long powerTeslaNodeMap(ITeslaConnectable origin) { @@ -80,7 +76,7 @@ public interface ITeslaConnectable extends ITeslaConnectableSimple { long remainingAmperes = origin.getTeslaOutputCurrent(); while (remainingAmperes > 0) { long startingAmperes = remainingAmperes; - for (Map.Entry Rx : entriesSortedByValues(teslaNodeMap)) { + for (HashMap.Entry Rx : entriesSortedByValues(teslaNodeMap)) { if (origin.getTeslaStoredEnergy() < (origin.isOverdriveEnabled() ? origin.getTeslaOutputVoltage() * 2 : origin.getTeslaOutputVoltage())) { //Return and end the tick if we're out of energy to send return origin.getTeslaOutputCurrent() - remainingAmperes; -- cgit From 5de583bf34003095ff286aa132aa0e005020cab7 Mon Sep 17 00:00:00 2001 From: basdxz Date: Wed, 4 Nov 2020 09:06:13 +0000 Subject: Revert "Merge branch 'master' into BassAddons" This reverts commit 95993fb3d937b8dcfc9c945c18a754ce4ac11f88. --- .../dreamcraft/DreamCraftRecipeLoader.java | 12 +- .../mechanics/structure/IStructureDefinition.java | 146 ++++- .../mechanics/structure/IStructureElement.java | 8 +- .../structure/IStructureElementChain.java | 22 +- .../structure/IStructureElementCheckOnly.java | 6 +- .../structure/IStructureElementDeferred.java | 2 +- .../structure/IStructureElementNoPlacement.java | 4 +- .../mechanics/structure/IStructureNavigate.java | 8 +- .../mechanics/structure/StructureDefinition.java | 50 +- .../structure/StructureIterationType.java | 8 - .../mechanics/structure/StructureUtility.java | 646 ++++++++------------- .../mechanics/structure/adders/IBlockAdder.java | 4 +- .../mechanics/structure/adders/IHatchAdder.java | 6 +- .../mechanics/structure/adders/ITileAdder.java | 4 +- .../java/com/github/technus/tectech/util/Util.java | 1 + 15 files changed, 453 insertions(+), 474 deletions(-) delete mode 100644 src/main/java/com/github/technus/tectech/mechanics/structure/StructureIterationType.java diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java index d58a6e7686..df5c11e67b 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java @@ -933,8 +933,6 @@ public class DreamCraftRecipeLoader implements Runnable { 48000, 64, 200000, 8, new Object[]{ GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.CosmicNeutronium, 1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.CosmicNeutronium, 6L), - ItemList.Gravistar.get(4L), - ItemList.Emitter_UHV.get(4L), new Object[]{OrePrefixes.circuit.get(Materials.Bio), 4L}, GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Neutronium, 64L), @@ -954,9 +952,7 @@ public class DreamCraftRecipeLoader implements Runnable { 96000, 128, 400000, 16, new Object[]{ GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.Infinity, 1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Infinity, 6L), - ItemList.Gravistar.get(8L), - ItemList.Emitter_UEV.get(4L), - new Object[]{OrePrefixes.circuit.get(Materials.Nano), 4}, + new Object[]{OrePrefixes.circuit.get(Materials.Bio), 8L}, GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Tritanium, 64L), @@ -1088,7 +1084,7 @@ public class DreamCraftRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silicone, 64), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Polybenzimidazole, 64) }, new FluidStack[]{ - Materials.SolderingAlloy.getMolten(3744L), + Materials.SolderingAlloy.getMolten(3760L), Materials.Naquadria.getMolten(4032L), new FluidStack(FluidRegistry.getFluid("ic2coolant"), 20000) }, getItemContainer("NanoCircuit").get(1L), 8000, 8000000); @@ -1109,7 +1105,7 @@ public class DreamCraftRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.bolt, Materials.Neutronium, 16), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Lanthanum, 64) }, new FluidStack[]{ - Materials.SolderingAlloy.getMolten(4032L), + Materials.SolderingAlloy.getMolten(3760L), Materials.UUMatter.getFluid(8000L), Materials.Osmium.getMolten(1152L) }, getItemContainer("PikoCircuit").get(1L), 10000, 8000000); @@ -1128,7 +1124,7 @@ public class DreamCraftRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Bedrockium, 8), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Lanthanum, 64) }, new FluidStack[]{ - Materials.SolderingAlloy.getMolten(4608L), + Materials.SolderingAlloy.getMolten(3760L), Materials.UUMatter.getFluid(24000L), Materials.Osmium.getMolten(2304L) }, getItemContainer("QuantumCircuit").get(1L), 20000, 32000000); diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java index ca9712df04..c8488d5cea 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java @@ -1,47 +1,167 @@ package com.github.technus.tectech.mechanics.structure; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import static com.github.technus.tectech.mechanics.structure.StructureIterationType.*; -import static com.github.technus.tectech.mechanics.structure.StructureUtility.iterate; +import java.util.Arrays; -public interface IStructureDefinition { +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; + +public interface IStructureDefinition { /** * Used internally * @param name same name as for other methods here * @return the array of elements to process */ - IStructureElement[] getStructureFor(String name); + IStructureElement[] getStructureFor(String name); - default boolean check(MultiBlock object, String piece, World world, ExtendedFacing extendedFacing, + default boolean check(T object,String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, boolean forceCheckAllBlocks){ return iterate(object, null, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,forceCheckAllBlocks? CHECK_FULLY:CHECK); + basePositionA, basePositionB, basePositionC,false,forceCheckAllBlocks); } - default boolean hints(MultiBlock object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, + default boolean hints(T object, ItemStack trigger,String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC) { return iterate(object, trigger, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,SPAWN_HINTS); + basePositionA, basePositionB, basePositionC,true,null); } - default boolean build(MultiBlock object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, + default boolean build(T object, ItemStack trigger,String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC) { return iterate(object, trigger, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,BUILD_TEMPLATE); + basePositionA, basePositionB, basePositionC,false,null); } - default boolean buildOrHints(MultiBlock object, ItemStack trigger, String piece, World world, ExtendedFacing extendedFacing, + default boolean buildOrHints(T object, ItemStack trigger,String piece, World world, ExtendedFacing extendedFacing, int basePositionX, int basePositionY, int basePositionZ, int basePositionA, int basePositionB, int basePositionC, - boolean hints){ + boolean hintsOnly){ return iterate(object, trigger, getStructureFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, - basePositionA, basePositionB, basePositionC,hints?SPAWN_HINTS:BUILD_TEMPLATE); + basePositionA, basePositionB, basePositionC,hintsOnly,null); + } + + static boolean iterate(T object, ItemStack trigger, IStructureElement[] elements, World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC, + boolean hintsOnly, Boolean checkBlocksIfNotNullForceCheckAllIfTrue){ + if(world.isRemote ^ hintsOnly){ + return false; + } + + //change base position to base offset + basePositionA=-basePositionA; + basePositionB=-basePositionB; + basePositionC=-basePositionC; + + int[] abc = new int[]{basePositionA,basePositionB,basePositionC}; + int[] xyz = new int[3]; + + if(checkBlocksIfNotNullForceCheckAllIfTrue!=null){ + if(checkBlocksIfNotNullForceCheckAllIfTrue){ + for (IStructureElement element : elements) { + if(element.isNavigating()) { + abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); + abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); + abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); + }else { + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + if(!element.check(object, world, xyz[0], xyz[1], xyz[2])){ + if(DEBUG_MODE){ + TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] failed @ "+ + Arrays.toString(xyz)+" "+Arrays.toString(abc)); + } + return false; + } + } else { + if(DEBUG_MODE){ + TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] !blockExists @ "+ + Arrays.toString(xyz)+" "+Arrays.toString(abc)); + } + return false; + } + abc[0]+=1; + } + } + } else { + for (IStructureElement element : elements) { + if(element.isNavigating()) { + abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); + abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); + abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); + }else { + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + if(!element.check(object, world, xyz[0], xyz[1], xyz[2])){ + if(DEBUG_MODE){ + TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] failed @ "+ + Arrays.toString(xyz)+" "+Arrays.toString(abc)); + } + return false; + } + } else { + if(DEBUG_MODE){ + TecTech.LOGGER.info("Multi ["+basePositionX+", "+basePositionY+", "+basePositionZ+"] !blockExists @ "+ + Arrays.toString(xyz)+" "+Arrays.toString(abc)); + } + } + abc[0]+=1; + } + } + } + }else { + if(hintsOnly) { + for (IStructureElement element : elements) { + if(element.isNavigating()) { + abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); + abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); + abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); + }else { + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + element.spawnHint(object, world, xyz[0], xyz[1], xyz[2], trigger); + + abc[0]+=1; + } + } + } else { + for (IStructureElement element : elements) { + if(element.isNavigating()) { + abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); + abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); + abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); + }else { + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + element.placeBlock(object, world, xyz[0], xyz[1], xyz[2], trigger); + } + abc[0]+=1; + } + } + } + } + return true; } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java index 436c7ce203..f946e71f91 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java @@ -6,12 +6,12 @@ import net.minecraft.world.World; /** * Use StructureUtility to instantiate */ -public interface IStructureElement { - boolean check(MultiBlock multiBlock, World world, int x, int y, int z); +public interface IStructureElement { + boolean check(T t,World world,int x,int y,int z); - boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger); + boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger); - boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger); + boolean placeBlock(T t,World world,int x,int y,int z, ItemStack trigger); default int getStepA(){ return 1; diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java index 4c7059dd81..f9593ee1c5 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementChain.java @@ -6,13 +6,13 @@ import net.minecraft.world.World; /** * Use StructureUtility to instantiate */ -public interface IStructureElementChain extends IStructureElement { - IStructureElement[] fallbacks(); +public interface IStructureElementChain extends IStructureElement { + IStructureElement[] fallbacks(); @Override - default boolean check(MultiBlock multiBlock, World world, int x, int y, int z){ - for (IStructureElement fallback : fallbacks()) { - if (fallback.check(multiBlock, world, x, y, z)) { + default boolean check(T t, World world, int x, int y, int z){ + for (IStructureElement fallback : fallbacks()) { + if (fallback.check(t, world, x, y, z)) { return true; } } @@ -20,9 +20,9 @@ public interface IStructureElementChain extends IStructureElement fallback : fallbacks()) { - if (fallback.spawnHint(multiBlock, world, x, y, z, trigger)) { + default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + for (IStructureElement fallback : fallbacks()) { + if (fallback.spawnHint(t, world, x, y, z, trigger)) { return true; } } @@ -30,9 +30,9 @@ public interface IStructureElementChain extends IStructureElement fallback : fallbacks()) { - if (fallback.placeBlock(multiBlock, world, x, y, z, trigger)) { + default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + for (IStructureElement fallback : fallbacks()) { + if (fallback.placeBlock(t, world, x, y, z, trigger)) { return true; } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java index c6492a5ed6..ec15aea53b 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementCheckOnly.java @@ -3,14 +3,14 @@ package com.github.technus.tectech.mechanics.structure; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IStructureElementCheckOnly extends IStructureElement { +public interface IStructureElementCheckOnly extends IStructureElement { @Override - default boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger){ + default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger){ return false; } @Override - default boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger){ + default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger){ return false; } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java index c0e39bb2ad..dbb74312a8 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementDeferred.java @@ -3,5 +3,5 @@ package com.github.technus.tectech.mechanics.structure; /** * Use StructureUtility to instantiate */ -public interface IStructureElementDeferred extends IStructureElement { +public interface IStructureElementDeferred extends IStructureElement { } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java index 12cf2141ae..47e6060878 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementNoPlacement.java @@ -3,9 +3,9 @@ package com.github.technus.tectech.mechanics.structure; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public interface IStructureElementNoPlacement extends IStructureElement { +public interface IStructureElementNoPlacement extends IStructureElement { @Override - default boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger){ + default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger){ return false; } } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java index 8c7c837a94..d3f4134cea 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java @@ -6,19 +6,19 @@ import net.minecraft.world.World; /** * Use StructureUtility to instantiate */ -interface IStructureNavigate extends IStructureElement { +interface IStructureNavigate extends IStructureElement { @Override - default boolean check(MultiBlock multiBlock, World world, int x, int y, int z){ + default boolean check(T t, World world, int x, int y, int z){ return true; } @Override - default boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + default boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { return true; } @Override - default boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + default boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { return true; } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java index f42cbd35d1..9a1e94d98a 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java @@ -7,31 +7,31 @@ import java.util.*; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; -public class StructureDefinition implements IStructureDefinition { - private final Map> elements; +public class StructureDefinition implements IStructureDefinition { + private final Map> elements; private final Map shapes; - private final Map[]> structures; + private final Map[]> structures; - public static Builder builder() { + public static Builder builder() { return new Builder<>(); } private StructureDefinition( - Map> elements, + Map> elements, Map shapes, - Map[]> structures) { + Map[]> structures) { this.elements =elements; this.shapes=shapes; this.structures = structures; } - public static class Builder { + public static class Builder { private static final char A='\uA000'; private static final char B='\uB000'; private static final char C='\uC000'; private char d ='\uD000'; private final Map navigates; - private final Map> elements; + private final Map> elements; private final Map shapes; private Builder() { @@ -40,7 +40,7 @@ public class StructureDefinition implements IStructureDefinition(); } - public Map> getElements() { + public Map> getElements() { return elements; } @@ -57,7 +57,7 @@ public class StructureDefinition implements IStructureDefinition addShapeOldApi(String name, String[][] structurePiece) { + public Builder addShapeOldApi(String name, String[][] structurePiece) { StringBuilder builder = new StringBuilder(); if (structurePiece.length > 0) { for (String[] strings : structurePiece) { @@ -142,7 +142,7 @@ public class StructureDefinition implements IStructureDefinition addShape(String name, String[][] structurePiece) { + public Builder addShape(String name, String[][] structurePiece) { StringBuilder builder = new StringBuilder(); if (structurePiece.length > 0) { for (String[] strings : structurePiece) { @@ -199,13 +199,13 @@ public class StructureDefinition implements IStructureDefinition addElement(Character name, IStructureElement structurePiece) { + public Builder addElement(Character name, IStructureElement structurePiece) { elements.putIfAbsent(name, structurePiece); return this; } - public IStructureDefinition build() { - Map[]> structures = compileStructureMap(); + public IStructureDefinition build() { + Map[]> structures = compileStructureMap(); if(DEBUG_MODE){ return new StructureDefinition<>(new HashMap<>(elements), new HashMap<>(shapes), structures); }else { @@ -214,22 +214,22 @@ public class StructureDefinition implements IStructureDefinition[]> compileElementSetMap() { + private Map[]> compileElementSetMap() { Set missing = new HashSet<>(); shapes.values().stream().map(CharSequence::chars).forEach(intStream -> intStream.forEach(c -> { - IStructureElement iStructureElement = elements.get((char) c); + IStructureElement iStructureElement = elements.get((char) c); if (iStructureElement == null) { missing.add(c); } })); if (missing.isEmpty()) { - Map[]> map = new HashMap<>(); + Map[]> map = new HashMap<>(); shapes.forEach((key, value) -> { Set chars=new HashSet<>(); for (char c : value.toCharArray()) { chars.add(c); } - IStructureElement[] compiled = new IStructureElement[chars.size()]; + IStructureElement[] compiled = new IStructureElement[chars.size()]; int i=0; for (Character aChar : chars) { compiled[i++]=elements.get(aChar); @@ -244,18 +244,18 @@ public class StructureDefinition implements IStructureDefinition[]> compileStructureMap() { + private Map[]> compileStructureMap() { Set mising = new HashSet<>(); shapes.values().stream().map(CharSequence::chars).forEach(intStream -> intStream.forEach(c -> { - IStructureElement iStructureElement = elements.get((char) c); + IStructureElement iStructureElement = elements.get((char) c); if (iStructureElement == null) { mising.add(c); } })); if (mising.isEmpty()) { - Map[]> map = new HashMap<>(); + Map[]> map = new HashMap<>(); shapes.forEach((key, value) -> { - IStructureElement[] compiled = new IStructureElement[value.length()]; + IStructureElement[] compiled = new IStructureElement[value.length()]; for (int i = 0; i < value.length(); i++) { compiled[i] = elements.get(value.charAt(i)); } @@ -269,7 +269,7 @@ public class StructureDefinition implements IStructureDefinition> getElements(){ + public Map> getElements(){ return elements; } @@ -277,12 +277,12 @@ public class StructureDefinition implements IStructureDefinition[]> getStructures() { + public Map[]> getStructures() { return structures; } @Override - public IStructureElement[] getStructureFor(String name) { + public IStructureElement[] getStructureFor(String name) { return structures.get(name); } } \ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureIterationType.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureIterationType.java deleted file mode 100644 index 618c07f970..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureIterationType.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.technus.tectech.mechanics.structure; - -public enum StructureIterationType { - SPAWN_HINTS, //only spawn hint particles - BUILD_TEMPLATE, //only builds template - CHECK, //checks the structure skipping all unloaded chunks (for machines that were validated already) - CHECK_FULLY, //checks the structure failing on unloaded chunks (for machines that are not valid currently) -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java index 87ab275d39..521b0e7645 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java @@ -22,8 +22,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static com.github.technus.tectech.mechanics.structure.StructureIterationType.SPAWN_HINTS; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sHintCasingsTT; import static java.lang.Integer.MIN_VALUE; @@ -39,18 +37,18 @@ public class StructureUtility { @SuppressWarnings("rawtypes") private static final IStructureElement AIR = new IStructureElement() { @Override - public boolean check(Object multiBlock, World world, int x, int y, int z) { + public boolean check(Object t, World world, int x, int y, int z) { return world.getBlock(x, y, z).getMaterial() == Material.air; } @Override - public boolean spawnHint(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 13); return true; } @Override - public boolean placeBlock(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, Blocks.air, 0, 2); return false; } @@ -58,18 +56,18 @@ public class StructureUtility { @SuppressWarnings("rawtypes") private static final IStructureElement NOT_AIR = new IStructureElement() { @Override - public boolean check(Object multiBlock, World world, int x, int y, int z) { + public boolean check(Object t, World world, int x, int y, int z) { return world.getBlock(x, y, z).getMaterial() != Material.air; } @Override - public boolean spawnHint(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 14); return true; } @Override - public boolean placeBlock(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, sHintCasingsTT, 14, 2); return true; } @@ -77,18 +75,18 @@ public class StructureUtility { @SuppressWarnings("rawtypes") private static final IStructureElement ERROR = new IStructureElement() { @Override - public boolean check(Object multiBlock, World world, int x, int y, int z) { + public boolean check(Object t, World world, int x, int y, int z) { return false; } @Override - public boolean spawnHint(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(Object o, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, 15); return true; } @Override - public boolean placeBlock(Object multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(Object o, World world, int x, int y, int z, ItemStack trigger) { return true; } }; @@ -98,12 +96,12 @@ public class StructureUtility { } @SuppressWarnings("unchecked") - public static IStructureElement isAir() { + public static IStructureElement isAir() { return AIR; } @SuppressWarnings("unchecked") - public static IStructureElement notAir() { + public static IStructureElement notAir() { return NOT_AIR; } @@ -112,11 +110,11 @@ public class StructureUtility { * Placement is always handled by this and does nothing. * Makes little to no use it in fallback chain. * - * @param + * @param * @return */ @SuppressWarnings("unchecked") - public static IStructureElement error() { + public static IStructureElement error() { return ERROR; } @@ -126,19 +124,19 @@ public class StructureUtility { * Check always returns: true. * * @param dots - * @param + * @param * @return */ - public static IStructureElementNoPlacement ofHint(int dots) { + public static IStructureElementNoPlacement ofHint(int dots) { int meta = dots - 1; - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, sHintCasingsTT, meta); return false; } @@ -149,18 +147,18 @@ public class StructureUtility { * Check always returns: true. * * @param icons - * @param + * @param * @return */ - public static IStructureElementNoPlacement ofHintDeferred(Supplier icons) { - return new IStructureElementNoPlacement() { + public static IStructureElementNoPlacement ofHintDeferred(Supplier icons) { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, icons.get()); return false; } @@ -172,18 +170,18 @@ public class StructureUtility { * * @param icons * @param RGBa - * @param + * @param * @return */ - public static IStructureElementNoPlacement ofHintDeferred(Supplier icons, short[] RGBa) { - return new IStructureElementNoPlacement() { + public static IStructureElementNoPlacement ofHintDeferred(Supplier icons, short[] RGBa) { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle_tinted(world, x, y, z, icons.get(), RGBa); return false; } @@ -197,19 +195,19 @@ public class StructureUtility { /** * Does not allow Block duplicates (with different meta) */ - public static IStructureElementNoPlacement ofBlocksFlatHint(Map blocsMap, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofBlocksFlatHint(Map blocsMap, Block hintBlock, int hintMeta) { if (blocsMap == null || blocsMap.isEmpty() || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } @@ -228,57 +226,57 @@ public class StructureUtility { throw new IllegalArgumentException(); } } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, Collections.emptySet()).contains(worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static IStructureElementNoPlacement ofBlockHint(Block block, int meta, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofBlockHint(Block block, int meta, Block hintBlock, int hintMeta) { if (block == null || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static IStructureElementNoPlacement ofBlockHint(Block block, int meta) { + public static IStructureElementNoPlacement ofBlockHint(Block block, int meta) { return ofBlockHint(block, meta, block, meta); } - public static IStructureElementNoPlacement ofBlockAdderHint(IBlockAdder iBlockAdder, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofBlockAdderHint(IBlockAdder iBlockAdder, Block hintBlock, int hintMeta) { if (iBlockAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(multiBlock, worldBlock, worldBlock.getDamageValue(world, x, y, z)); + return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } @@ -288,46 +286,46 @@ public class StructureUtility { /** * Does not allow Block duplicates (with different meta) */ - public static IStructureElement ofBlocksFlat(Map blocsMap, Block defaultBlock, int defaultMeta) { + public static IStructureElement ofBlocksFlat(Map blocsMap, Block defaultBlock, int defaultMeta) { if (blocsMap == null || blocsMap.isEmpty() || defaultBlock == null) { throw new IllegalArgumentException(); } if(defaultBlock instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; }else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, MIN_VALUE) == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -348,41 +346,41 @@ public class StructureUtility { } } if(defaultBlock instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, Collections.emptySet()).contains(worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; }else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return blocsMap.getOrDefault(worldBlock, Collections.emptySet()).contains(worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -390,46 +388,46 @@ public class StructureUtility { } } - public static IStructureElement ofBlock(Block block, int meta, Block defaultBlock, int defaultMeta) { + public static IStructureElement ofBlock(Block block, int meta, Block defaultBlock, int defaultMeta) { if (block == null || defaultBlock == null) { throw new IllegalArgumentException(); } if(block instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; } else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); return block == worldBlock && meta == worldBlock.getDamageValue(world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -440,44 +438,44 @@ public class StructureUtility { /** * Same as above but ignores target meta id */ - public static IStructureElement ofBlockAnyMeta(Block block, Block defaultBlock, int defaultMeta) { + public static IStructureElement ofBlockAnyMeta(Block block, Block defaultBlock, int defaultMeta) { if (block == null || defaultBlock == null) { throw new IllegalArgumentException(); } if(block instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return block == world.getBlock(x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; } else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { return block == world.getBlock(x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -485,21 +483,21 @@ public class StructureUtility { } } - public static IStructureElement ofBlock(Block block, int meta) { + public static IStructureElement ofBlock(Block block, int meta) { return ofBlock(block, meta, block, meta); } /** * Same as above but ignores target meta id */ - public static IStructureElement ofBlockAnyMeta(Block block) { + public static IStructureElement ofBlockAnyMeta(Block block) { return ofBlockAnyMeta(block, block, 0); } /** * Same as above but allows to set hint particle render */ - public static IStructureElement ofBlockAnyMeta(Block block,int defaultMeta) { + public static IStructureElement ofBlockAnyMeta(Block block,int defaultMeta) { return ofBlockAnyMeta(block, block, defaultMeta); } @@ -507,46 +505,46 @@ public class StructureUtility { //region adders - public static IStructureElement ofBlockAdder(IBlockAdder iBlockAdder, Block defaultBlock, int defaultMeta) { + public static IStructureElement ofBlockAdder(IBlockAdder iBlockAdder, Block defaultBlock, int defaultMeta) { if (iBlockAdder == null || defaultBlock == null) { throw new IllegalArgumentException(); } if(defaultBlock instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(multiBlock, worldBlock, worldBlock.getDamageValue(world, x, y, z)); + return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } }; }else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { Block worldBlock = world.getBlock(x, y, z); - return iBlockAdder.apply(multiBlock, worldBlock, worldBlock.getDamageValue(world, x, y, z)); + return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z)); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, defaultBlock, defaultMeta, 2); return true; } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, defaultBlock, defaultMeta); return true; } @@ -554,102 +552,102 @@ public class StructureUtility { } } - public static IStructureElement ofBlockAdder(IBlockAdder iBlockAdder, int dots) { + public static IStructureElement ofBlockAdder(IBlockAdder iBlockAdder, int dots) { return ofBlockAdder(iBlockAdder, sHintCasingsTT, dots - 1); } - public static IStructureElementNoPlacement ofTileAdder(ITileAdder iTileAdder, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofTileAdder(ITileAdder iTileAdder, Block hintBlock, int hintMeta) { if (iTileAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && iTileAdder.apply(multiBlock, tileEntity); + return tileEntity instanceof IGregTechTileEntity && iTileAdder.apply(t, tileEntity); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static IStructureElementNoPlacement ofHatchAdder(IHatchAdder iHatchAdder, int textureIndex, int dots) { + public static IStructureElementNoPlacement ofHatchAdder(IHatchAdder iHatchAdder, int textureIndex, int dots) { return ofHatchAdder(iHatchAdder, textureIndex, sHintCasingsTT, dots - 1); } - public static IStructureElementNoPlacement ofHatchAdder(IHatchAdder iHatchAdder, int textureIndex, Block hintBlock, int hintMeta) { + public static IStructureElementNoPlacement ofHatchAdder(IHatchAdder iHatchAdder, int textureIndex, Block hintBlock, int hintMeta) { if (iHatchAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } - return new IStructureElementNoPlacement() { + return new IStructureElementNoPlacement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); - return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply(multiBlock, (IGregTechTileEntity) tileEntity, (short) textureIndex); + return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } }; } - public static IStructureElement ofHatchAdderOptional(IHatchAdder iHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { + public static IStructureElement ofHatchAdderOptional(IHatchAdder iHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { return ofHatchAdderOptional(iHatchAdder, textureIndex, sHintCasingsTT, dots - 1, placeCasing, placeCasingMeta); } - public static IStructureElement ofHatchAdderOptional(IHatchAdder iHatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { + public static IStructureElement ofHatchAdderOptional(IHatchAdder iHatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { if (iHatchAdder == null || hintBlock == null) { throw new IllegalArgumentException(); } if(placeCasing instanceof ICustomBlockSetting){ - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); Block worldBlock = world.getBlock(x, y, z); return (tileEntity instanceof IGregTechTileEntity && - iHatchAdder.apply(multiBlock, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || + iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { ((ICustomBlockSetting) placeCasing).setBlock(world, x, y, z, placeCasingMeta); return true; } }; }else { - return new IStructureElement() { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { + public boolean check(T t, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); Block worldBlock = world.getBlock(x, y, z); return (tileEntity instanceof IGregTechTileEntity && - iHatchAdder.apply(multiBlock, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || + iHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex)) || (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { TecTech.proxy.hint_particle(world, x, y, z, hintBlock, hintMeta); return true; } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { world.setBlock(x, y, z, placeCasing, placeCasingMeta, 2); return true; } @@ -661,48 +659,48 @@ public class StructureUtility { //region side effects - public static IStructureElement onElementPass(Consumer onCheckPass, IStructureElement element) { - return new IStructureElement() { + public static , T> IStructureElement onElementPass(Consumer onCheckPass, B element) { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - boolean check = element.check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + boolean check = element.check(t, world, x, y, z); if (check) { - onCheckPass.accept(multiBlock); + onCheckPass.accept(t); } return check; } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return element.placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return element.placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return element.spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return element.spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElement onElementFail(Consumer onFail, IStructureElement element) { - return new IStructureElement() { + public static , T> IStructureElement onElementFail(Consumer onFail, B element) { + return new IStructureElement() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - boolean check = element.check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + boolean check = element.check(t, world, x, y, z); if (!check) { - onFail.accept(multiBlock); + onFail.accept(t); } return check; } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return element.placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return element.placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return element.spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return element.spawnHint(t, world, x, y, z, trigger); } }; } @@ -714,15 +712,15 @@ public class StructureUtility { * If none does it will finally return false. * * @param elementChain - * @param + * @param * @return */ @SafeVarargs - public static IStructureElementChain ofChain(IStructureElement... elementChain) { + public static IStructureElementChain ofChain(IStructureElement... elementChain) { if (elementChain == null || elementChain.length == 0) { throw new IllegalArgumentException(); } - for (IStructureElement iStructureElement : elementChain) { + for (IStructureElement iStructureElement : elementChain) { if (iStructureElement == null) { throw new IllegalArgumentException(); } @@ -735,317 +733,317 @@ public class StructureUtility { * If none does it will finally return false. * * @param elementChain - * @param + * @param * @return */ @SuppressWarnings("unchecked") - public static IStructureElementChain ofChain(List> elementChain) { + public static IStructureElementChain ofChain(List> elementChain) { return ofChain(elementChain.toArray(new IStructureElement[0])); } //region defer - public static IStructureElementDeferred defer(Supplier> to) { + public static IStructureElementDeferred defer(Supplier> to) { if (to == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return to.get().check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return to.get().check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.get().placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.get().placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.get().spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.get().spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function> to) { + public static IStructureElementDeferred defer(Function> to) { if (to == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return to.apply(multiBlock).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return to.apply(t).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function keyExtractor, Map> map) { + public static IStructureElementDeferred defer(Function keyExtractor, Map> map) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.get(keyExtractor.apply(multiBlock)).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.get(keyExtractor.apply(t)).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock)).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t)).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock)).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t)).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function keyExtractor, Map> map, IStructureElement defaultElem) { + public static IStructureElementDeferred defer(Function keyExtractor, Map> map, IStructureElement defaultElem) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.getOrDefault(keyExtractor.apply(multiBlock), defaultElem).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.getOrDefault(keyExtractor.apply(t), defaultElem).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock), defaultElem).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t), defaultElem).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock), defaultElem).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t), defaultElem).spawnHint(t, world, x, y, z, trigger); } }; } @SafeVarargs - public static IStructureElementDeferred defer(Function keyExtractor, IStructureElement... array) { + public static IStructureElementDeferred defer(Function keyExtractor, IStructureElement... array) { if (keyExtractor == null || array == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return array[keyExtractor.apply(multiBlock)].check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return array[keyExtractor.apply(t)].check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock)].placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t)].placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock)].spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t)].spawnHint(t, world, x, y, z, trigger); } }; } @SuppressWarnings("unchecked") - public static IStructureElementDeferred defer(Function keyExtractor, List> array) { + public static IStructureElementDeferred defer(Function keyExtractor, List> array) { return defer(keyExtractor, array.toArray(new IStructureElement[0])); } - public static IStructureElementDeferred defer(BiFunction> to) { + public static IStructureElementDeferred defer(BiFunction> to) { if (to == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return to.apply(multiBlock, null).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return to.apply(t, null).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock, trigger).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock, trigger).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t, trigger).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(BiFunction keyExtractor, Map> map) { + public static IStructureElementDeferred defer(BiFunction keyExtractor, Map> map) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.get(keyExtractor.apply(multiBlock, null)).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.get(keyExtractor.apply(t, null)).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock, trigger)).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t, trigger)).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock, trigger)).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t, trigger)).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(BiFunction keyExtractor, Map> map, IStructureElement defaultElem) { + public static IStructureElementDeferred defer(BiFunction keyExtractor, Map> map, IStructureElement defaultElem) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.getOrDefault(keyExtractor.apply(multiBlock, null), defaultElem).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.getOrDefault(keyExtractor.apply(t, null), defaultElem).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock, trigger), defaultElem).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock, trigger), defaultElem).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).spawnHint(t, world, x, y, z, trigger); } }; } @SafeVarargs - public static IStructureElementDeferred defer(BiFunction keyExtractor, IStructureElement... array) { + public static IStructureElementDeferred defer(BiFunction keyExtractor, IStructureElement... array) { if (keyExtractor == null || array == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return array[keyExtractor.apply(multiBlock, null)].check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return array[keyExtractor.apply(t, null)].check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock, trigger)].placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t, trigger)].placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock, trigger)].spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t, trigger)].spawnHint(t, world, x, y, z, trigger); } }; } @SuppressWarnings("unchecked") - public static IStructureElementDeferred defer(BiFunction keyExtractor, List> array) { + public static IStructureElementDeferred defer(BiFunction keyExtractor, List> array) { return defer(keyExtractor, array.toArray(new IStructureElement[0])); } - public static IStructureElementDeferred defer(Function> toCheck, BiFunction> to) { + public static IStructureElementDeferred defer(Function> toCheck, BiFunction> to) { if (to == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return toCheck.apply(multiBlock).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return toCheck.apply(t).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock, trigger).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t, trigger).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return to.apply(multiBlock, trigger).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return to.apply(t, trigger).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, Map> map) { + public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, Map> map) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.get(keyExtractorCheck.apply(multiBlock)).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.get(keyExtractorCheck.apply(t)).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock, trigger)).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t, trigger)).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.get(keyExtractor.apply(multiBlock, trigger)).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.get(keyExtractor.apply(t, trigger)).spawnHint(t, world, x, y, z, trigger); } }; } - public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, Map> map, IStructureElement defaultElem) { + public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, Map> map, IStructureElement defaultElem) { if (keyExtractor == null || map == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return map.getOrDefault(keyExtractorCheck.apply(multiBlock), defaultElem).check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return map.getOrDefault(keyExtractorCheck.apply(t), defaultElem).check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock, trigger), defaultElem).placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return map.getOrDefault(keyExtractor.apply(multiBlock, trigger), defaultElem).spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return map.getOrDefault(keyExtractor.apply(t, trigger), defaultElem).spawnHint(t, world, x, y, z, trigger); } }; } @SafeVarargs - public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, IStructureElement... array) { + public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, IStructureElement... array) { if (keyExtractor == null || array == null) { throw new IllegalArgumentException(); } - return new IStructureElementDeferred() { + return new IStructureElementDeferred() { @Override - public boolean check(MultiBlock multiBlock, World world, int x, int y, int z) { - return array[keyExtractorCheck.apply(multiBlock)].check(multiBlock, world, x, y, z); + public boolean check(T t, World world, int x, int y, int z) { + return array[keyExtractorCheck.apply(t)].check(t, world, x, y, z); } @Override - public boolean placeBlock(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock, trigger)].placeBlock(multiBlock, world, x, y, z, trigger); + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t, trigger)].placeBlock(t, world, x, y, z, trigger); } @Override - public boolean spawnHint(MultiBlock multiBlock, World world, int x, int y, int z, ItemStack trigger) { - return array[keyExtractor.apply(multiBlock, trigger)].spawnHint(multiBlock, world, x, y, z, trigger); + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + return array[keyExtractor.apply(t, trigger)].spawnHint(t, world, x, y, z, trigger); } }; } @SuppressWarnings("unchecked") - public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, List> array) { + public static IStructureElementDeferred defer(Function keyExtractorCheck, BiFunction keyExtractor, List> array) { return defer(keyExtractorCheck, keyExtractor, array.toArray(new IStructureElement[0])); } @@ -1057,10 +1055,10 @@ public class StructureUtility { * @param a * @param b * @param c - * @param + * @param * @return */ - public static IStructureNavigate step(int a, int b, int c) { + public static IStructureNavigate step(int a, int b, int c) { return step(new Vec3Impl(a, b, c)); } @@ -1068,11 +1066,11 @@ public class StructureUtility { * Used internally, to generate skips for structure definitions * * @param step - * @param + * @param * @return */ @SuppressWarnings("unchecked") - public static IStructureNavigate step(Vec3Impl step) { + public static IStructureNavigate step(Vec3Impl step) { if (step == null || step.get0() < 0 || step.get1() < 0 || step.get2() < 0) { throw new IllegalArgumentException(); } @@ -1087,8 +1085,8 @@ public class StructureUtility { }); } - private static IStructureNavigate stepA(int a, int b, int c) { - return new IStructureNavigate() { + private static IStructureNavigate stepA(int a, int b, int c) { + return new IStructureNavigate() { @Override public int getStepA() { return a; @@ -1106,8 +1104,8 @@ public class StructureUtility { }; } - private static IStructureNavigate stepB(int a, int b, int c) { - return new IStructureNavigate() { + private static IStructureNavigate stepB(int a, int b, int c) { + return new IStructureNavigate() { @Override public int getStepA() { return a; @@ -1130,8 +1128,8 @@ public class StructureUtility { }; } - private static IStructureNavigate stepC(int a, int b, int c) { - return new IStructureNavigate() { + private static IStructureNavigate stepC(int a, int b, int c) { + return new IStructureNavigate() { @Override public int getStepA() { return a; @@ -1378,134 +1376,6 @@ public class StructureUtility { } } - public static boolean iterate(MultiBlock object, - ItemStack trigger, - IStructureElement[] elements, - World world, - ExtendedFacing extendedFacing, - int basePositionX, int basePositionY, int basePositionZ, - int basePositionA, int basePositionB, int basePositionC, - StructureIterationType iterationType) { - if (world.isRemote ^ (iterationType == SPAWN_HINTS)) { - return false; - } - - //change base position to base offset - basePositionA = -basePositionA; - basePositionB = -basePositionB; - basePositionC = -basePositionC; - - int[] abc = new int[]{basePositionA, basePositionB, basePositionC}; - int[] xyz = new int[3]; - - switch (iterationType) { - case SPAWN_HINTS: { - for (IStructureElement element : elements) { - if (element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - } else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - element.spawnHint(object, world, xyz[0], xyz[1], xyz[2], trigger); - - abc[0] += 1; - } - } - break; - } - case BUILD_TEMPLATE: { - for (IStructureElement element : elements) { - if (element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - } else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - element.placeBlock(object, world, xyz[0], xyz[1], xyz[2], trigger); - } - abc[0] += 1; - } - } - break; - } - case CHECK: { - for (IStructureElement element : elements) { - if (element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - } else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - if (!element.check(object, world, xyz[0], xyz[1], xyz[2])) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] failed @ " + - Arrays.toString(xyz) + " " + Arrays.toString(abc)); - } - return false; - } - } else { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] !blockExists @ " + - Arrays.toString(xyz) + " " + Arrays.toString(abc)); - } - } - abc[0] += 1; - } - break; - } - } - case CHECK_FULLY: { - for (IStructureElement element : elements) { - if (element.isNavigating()) { - abc[0] = (element.resetA() ? basePositionA : abc[0]) + element.getStepA(); - abc[1] = (element.resetB() ? basePositionB : abc[1]) + element.getStepB(); - abc[2] = (element.resetC() ? basePositionC : abc[2]) + element.getStepC(); - } else { - extendedFacing.getWorldOffset(abc, xyz); - xyz[0] += basePositionX; - xyz[1] += basePositionY; - xyz[2] += basePositionZ; - - if (world.blockExists(xyz[0], xyz[1], xyz[2])) { - if (!element.check(object, world, xyz[0], xyz[1], xyz[2])) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] failed @ " + - Arrays.toString(xyz) + " " + Arrays.toString(abc)); - } - return false; - } - } else { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Multi [" + basePositionX + ", " + basePositionY + ", " + basePositionZ + "] !blockExists @ " + - Arrays.toString(xyz) + " " + Arrays.toString(abc)); - } - return false; - } - abc[0] += 1; - } - } - break; - } - default: return false; - } - return true; - } - /** * Transposes shape (swaps B and C axis, can be used to un-transpose transposed shape) * WARNING! Do not use on old api... diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java index 36ebfb3d21..908c4c4aca 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IBlockAdder.java @@ -3,12 +3,12 @@ package com.github.technus.tectech.mechanics.structure.adders; import net.minecraft.block.Block; -public interface IBlockAdder { +public interface IBlockAdder { /** * Callback on block added, needs to check if block is valid (and add it) * @param block block attempted to add * @param meta meta of block attempted to add * @return is structure still valid */ - boolean apply(MultiBlock multiBlock, Block block, int meta); + boolean apply(T t,Block block, Integer meta); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java index 0545a83d9e..a47befc2e8 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/IHatchAdder.java @@ -3,12 +3,12 @@ package com.github.technus.tectech.mechanics.structure.adders; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -public interface IHatchAdder { +public interface IHatchAdder { /** * Callback to add hatch, needs to check if hatch is valid (and add it) * @param iGregTechTileEntity hatch - * @param textureIndex requested texture index, or null if not... + * @param aShort requested texture index, or null if not... * @return managed to add hatch (structure still valid) */ - boolean apply(MultiBlock multiBlock, IGregTechTileEntity iGregTechTileEntity, int textureIndex); + boolean apply(T t,IGregTechTileEntity iGregTechTileEntity, Short aShort); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java index 72d08751b5..cc3c7dbb7a 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/adders/ITileAdder.java @@ -2,11 +2,11 @@ package com.github.technus.tectech.mechanics.structure.adders; import net.minecraft.tileentity.TileEntity; -public interface ITileAdder { +public interface ITileAdder { /** * Callback to add hatch, needs to check if tile is valid (and add it) * @param tileEntity tile * @return managed to add hatch (structure still valid) */ - boolean apply(MultiBlock multiBlock, TileEntity tileEntity); + boolean apply(T t,TileEntity tileEntity); } diff --git a/src/main/java/com/github/technus/tectech/util/Util.java b/src/main/java/com/github/technus/tectech/util/Util.java index 8c693620b6..1843770e3a 100644 --- a/src/main/java/com/github/technus/tectech/util/Util.java +++ b/src/main/java/com/github/technus/tectech/util/Util.java @@ -40,6 +40,7 @@ public final class Util { private Util() { } + @SuppressWarnings("ComparatorMethodParameterNotUsed") public static > SortedSet> entriesSortedByValues(Map map) { SortedSet> sortedEntries = new TreeSet<>( (e1, e2) -> { -- cgit