diff options
27 files changed, 908 insertions, 572 deletions
diff --git a/build.gradle b/build.gradle index 9689a82607..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' + //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 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/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java index 7ab4a8fab5..d58a6e7686 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 @@ -1623,6 +1628,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), @@ -1687,6 +1706,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/TecTechConfig.java b/src/main/java/com/github/technus/tectech/loader/TecTechConfig.java index 0c2920e585..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,87 +9,132 @@ 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 float TESLA_MULTI_MIN_EFFICIENCY; - public float TESLA_MULTI_MAX_EFFICIENCY; - public float TESLA_MULTI_OVERDRIVE_LOSS; - public float TESLA_SINGLE_MIN_EFFICIENCY; - public float TESLA_SINGLE_MAX_EFFICIENCY; - public float TESLA_SINGLE_OVERDRIVE_LOSS; + 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 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 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_MIN_EFFICIENCY = 0.955F; - TESLA_MULTI_MAX_EFFICIENCY = 0.98F; - TESLA_MULTI_OVERDRIVE_LOSS = 0.005F; - TESLA_SINGLE_MIN_EFFICIENCY = 0.91F; - TESLA_SINGLE_MAX_EFFICIENCY = 0.95F; - TESLA_SINGLE_OVERDRIVE_LOSS = 0.010F; - } + 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_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_RANGE = 20; + } /** * This loading phases do not correspond to mod loading phases! */ @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_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_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"); + 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"); } /** @@ -97,6 +142,5 @@ public class TecTechConfig extends ConfigManager { */ @Override protected void PostInit() { - } } 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/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<String, ExtendedFacing> 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(); + } } 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 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/structure/StructureUtility.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java index 14930952c5..87ab275d39 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 @@ -219,11 +219,11 @@ public class StructureUtility { /** * Allows block duplicates (with different meta) */ - public static <MultiBlock> IStructureElementNoPlacement<MultiBlock> ofBlocksMapHint(Map<Block, Set<Integer>> blocsMap, Block hintBlock, int hintMeta) { + public static <T> IStructureElementNoPlacement<T> ofBlocksMapHint(Map<Block, Collection<Integer>> blocsMap, Block hintBlock, int hintMeta) { if (blocsMap == null || blocsMap.isEmpty() || hintBlock == null) { throw new IllegalArgumentException(); } - for (Set<Integer> value : blocsMap.values()) { + for (Collection<Integer> value : blocsMap.values()) { if (value.isEmpty()) { throw new IllegalArgumentException(); } @@ -338,11 +338,11 @@ public class StructureUtility { /** * Allows block duplicates (with different meta) */ - public static <MultiBlock> IStructureElement<MultiBlock> ofBlocksMap(Map<Block, Set<Integer>> blocsMap, Block defaultBlock, int defaultMeta) { + public static <T> IStructureElement<T> ofBlocksMap(Map<Block, Collection<Integer>> blocsMap, Block defaultBlock, int defaultMeta) { if (blocsMap == null || blocsMap.isEmpty() || defaultBlock == null) { throw new IllegalArgumentException(); } - for (Set<Integer> value : blocsMap.values()) { + for (Collection<Integer> value : blocsMap.values()) { if (value.isEmpty()) { throw new IllegalArgumentException(); } 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..e397c1dc5f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/tesla/ITeslaConnectable.java @@ -0,0 +1,123 @@ +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.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 + HashMap<ITeslaConnectableSimple, Integer> teslaNodeMap = new HashMap<>(); + //ThaumCraft lighting coordinate pairs, so we can send them in bursts and save on lag + HashSet<ThaumSpark> 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<ITeslaConnectableSimple> 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) { + //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) { + //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 (HashMap.Entry<ITeslaConnectableSimple, Integer> 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/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..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 @@ -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(); } @@ -171,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)); } } 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/cover/GT_Cover_TM_TeslaCoil.java b/src/main/java/com/github/technus/tectech/thing/cover/GT_Cover_TM_TeslaCoil.java index 721f730960..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,28 +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.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) { + //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) { - if(aTileEntity.getStoredEU() > 0 && !GT_Utility.isWearingFullElectroHazmat(aPlayer)){ + //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; } -}
\ No newline at end of file + + @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 db7c751fc6..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; } -}
\ No newline at end of file + + @Override + public byte getTeslaReceptionCapability() { + return 1; + } +} 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<GT_MetaTileEntity_Hatch_Capacitor.CapacitorComponent> { @@ -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 89093bdba7..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 @@ -5,10 +5,9 @@ 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.thing.cover.GT_Cover_TM_TeslaCoil; -import com.github.technus.tectech.thing.cover.GT_Cover_TM_TeslaCoil_Ultimate; +import com.github.technus.tectech.mechanics.structure.adders.IHatchAdder; +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,11 +17,11 @@ 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; 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,58 +32,63 @@ 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; -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 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; +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 final static HashSet<ThaumSpark> sparkList = new HashSet<>(); - + 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_LOSS_FACTOR_OVERDRIVE;//Default is 0.25F; + 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; - private int mTier = 0; //Determines max voltage and efficiency (MV to LuV) - private int maxTier = 6; //Max tier for efficiency calcuation + 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 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 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<IGregTechTileEntity, Integer> eTeslaMap = new HashMap<>(); //Used to store targets for power transmission - private final ArrayList<GT_MetaTileEntity_Hatch_Capacitor> eCapacitorHatches = new ArrayList<>(); //Used to determine count and tier of capacitors present + private final ArrayList<GT_MetaTileEntity_Hatch_Capacitor> 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 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 private int vTier = -1; //Tesla voltage tier limited by capacitors private long outputCurrentMax = 0; //Tesla current output limited by capacitors - //Prevents unnecessary offset calculation + //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; - - //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 + //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 @@ -104,7 +108,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<GT_MetaTileEntity_TM_teslaCoil>[] addingMethods = adders( GT_MetaTileEntity_TM_teslaCoil::addCapacitorToMachineList, GT_MetaTileEntity_TM_teslaCoil::addFrameToMachineList); @@ -119,8 +124,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<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_LOW_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.0");//Hysteresis low setting private static final INameFunction<GT_MetaTileEntity_TM_teslaCoil> HYSTERESIS_HIGH_SETTING_NAME = (base, p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.1");//Hysteresis high setting @@ -164,17 +169,26 @@ 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<GT_MetaTileEntity_TM_teslaCoil> 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 > transferRadiusTransceiverFromConfig) return STATUS_HIGH; + if (value < transferRadiusTransceiverFromConfig) return STATUS_LOW; return STATUS_OK; }; - private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> TRANSFER_RADIUS_TRANSCEIVER_OR_COVER_ULTIMATE_STATUS = (base, p) -> { + private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> 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 > 20) return STATUS_TOO_HIGH; - if (value < 16) return STATUS_LOW; + if (value > transferRadiusCoverUltimateFromConfig) return STATUS_HIGH; + if (value < transferRadiusCoverUltimateFromConfig) return STATUS_LOW; return STATUS_OK; }; private static final IStatusFunction<GT_MetaTileEntity_TM_teslaCoil> OUTPUT_VOLTAGE_OR_CURRENT_STATUS = (base, p) -> { @@ -211,7 +225,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<GT_MetaTileEntity_TM_teslaCoil> POWER_STATUS = (base, p) -> { @@ -245,61 +259,64 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock super(aName); } - private long getEnergyEfficiency(long voltage, int distance, boolean overDriveToggle) { - if (overDriveToggle) { - return (long) ((voltage * 2) - (voltage * Math.pow(overdriveEfficiency, distance))); - } else { - return (long) (voltage * Math.pow(energyEfficiency, distance)); + 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 = plasmaRangeMultiT2; + break; + case 1: + plasmaBoost = plasmaRangeMultiT1; + break; + default: + plasmaBoost = 1; } - } - private float getRangeMulti(int mTier, int vTier) { //Over-tiered coils will add +25% range if (vTier > mTier) { - return 1.25F; - } - return 1F; - } - - 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; + return 1.25F * plasmaBoost; + } + return 1F * plasmaBoost; + } + + 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 >= heliumUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - heliumUse; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[]{Materials.Helium.getGas(heliumUse)}; + } + plasmaTier = 1; + return; + } 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(nitrogenUse)}; } - 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)))); - } + plasmaTier = 1; + return; + } 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(radonUse)}; } + plasmaTier = 2; + return; } } } - - } - - 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)); + plasmaTier = 0; } @Override @@ -317,9 +334,11 @@ 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 if (structureCheck_EM(shape, blockType, blockMetas[mTier], addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 3, 16, 0) && eCapacitorHatches.size() > 0) { for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) { @@ -334,26 +353,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(40, 0, 43)); - scanPosOffsets[1] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -4, -37)); - - scanPosOffsets[2] = getExtendedFacing().getWorldOffset(new Vec3Impl(40, -5, 43)); - scanPosOffsets[3] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -8, -37)); - - scanPosOffsets[4] = getExtendedFacing().getWorldOffset(new Vec3Impl(40, -9, 43)); - scanPosOffsets[5] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -12, -37)); - - scanPosOffsets[6] = getExtendedFacing().getWorldOffset(new Vec3Impl(40, -13, 43)); - scanPosOffsets[7] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -16, -37)); - - scanPosOffsets[8] = getExtendedFacing().getWorldOffset(new Vec3Impl(40, -17, 43)); - scanPosOffsets[9] = getExtendedFacing().getWorldOffset(new Vec3Impl(-40, -20, -37)); } return true; } @@ -362,6 +365,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 || @@ -369,7 +374,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; @@ -386,10 +391,6 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } } - //Calculate Efficiency values - energyEfficiency = map(mTier + 1, 1, maxTier, minEfficiency, maxEfficiency); - overdriveEfficiency = energyEfficiency - overdriveEfficiencyExtra; - energyCapacity = 0; outputCurrentMax = 0; @@ -450,6 +451,10 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock @Override public void onRemoval() { super.onRemoval(); + if (this.getBaseMetaTileEntity().isClientSide()) { + return; + } + teslaNodeSet.remove(this); for (GT_MetaTileEntity_Hatch_Capacitor cap : eCapacitorHatches) { if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(cap)) { cap.getBaseMetaTileEntity().setActive(false); @@ -474,17 +479,17 @@ 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); 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); @@ -497,15 +502,15 @@ 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); 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); @@ -523,6 +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); } @Override @@ -532,23 +538,29 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock cap.getBaseMetaTileEntity().setActive(false); } + ePowerPass = false; setEUVar(0); energyStoredDisplay.set(0); energyFractionDisplay.set(0); } @Override + public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick_EM(aBaseMetaTileEntity); + if (!aBaseMetaTileEntity.isClientSide()) { + teslaNodeSet.add(this); + } + } + + @Override public boolean onRunningTick(ItemStack aStack) { IGregTechTileEntity mte = getBaseMetaTileEntity(); //Hysteresis based ePowerPass setting - long energyMax = maxEUStore() / 2; - long energyStored = getEUVar(); + float energyFrac = (float) getEUVar() / energyCapacity; - float energyFrac = (float) energyStored / energyMax; - - energyCapacityDisplay.set(energyMax); - energyStoredDisplay.set(energyStored); + energyCapacityDisplay.set(energyCapacity); + energyStoredDisplay.set(getEUVar()); energyFractionDisplay.set(energyFrac); if (!ePowerPass && energyFrac > histHighSetting.get()) { @@ -557,105 +569,16 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock ePowerPass = false; } - //Clean the eTeslaMap - for (Map.Entry<IGregTechTileEntity, Integer> 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 teslaTransceiver = (GT_MetaTileEntity_TeslaCoil) nodeInside; - if (teslaTransceiver.mBatteryCount > 0) { - continue; - } - } else if ((node.getCoverBehaviorAtSide((byte) 1) instanceof GT_Cover_TM_TeslaCoil) && node.getEUCapacity() > 0) { - continue; - } - } catch (Exception e) { - } - } - eTeslaMap.remove(Rx.getKey()); - } - - //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<IGregTechTileEntity, Integer> 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<IGregTechTileEntity, Integer> 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; + //Create the teslaNodeMap + if (sortTime == sortTimeMinSetting.get()) { + sortTime = 0; + sortTimeDisplay.updateStatus(); + generateTeslaNodeMap(this); } - - scanTime++; - scanTimeDisplay.set(scanTime); + sortTime++; + sortTimeDisplay.set(sortTime); //Power Limit Settings - long outputVoltage; if (outputVoltageSetting.get() > 0) { outputVoltage = min(outputVoltageMax, (long) outputVoltageSetting.get()); } else { @@ -663,130 +586,48 @@ 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 - float rangeFrac = (float) ((-0.5 * Math.pow(energyFrac, 2)) + (1.5 * energyFrac)); - int transferRadiusTower = (int) (transferRadiusTowerSetting.get() * getRangeMulti(mTier, vTier) * rangeFrac); - transferRadiusTowerDisplay.set(transferRadiusTower); - int transferRadiusTransceiver = (int) (transferRadiusTransceiverSetting.get() * getRangeMulti(mTier, vTier) * rangeFrac); - transferRadiusTransceiverDisplay.set(transferRadiusTransceiver); - int transferRadiusCoverUltimate = (int) (transferRadiusCoverUltimateSetting.get() * getRangeMulti(mTier, vTier) * rangeFrac); - transferRadiusCoverUltimateDisplay.set(transferRadiusCoverUltimate); - - //Clean the eTeslaMap - for (Map.Entry<IGregTechTileEntity, Integer> 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()); - } - //Power transfer - long sparks = outputCurrent; - while (sparks > 0) { - boolean overdriveToggle = overDriveSetting.get() > 0; - boolean idle = true; - for (Map.Entry<IGregTechTileEntity, Integer> Rx : entriesSortedByValues(eTeslaMap)) { - if (energyStored >= (overdriveToggle ? outputVoltage * 2 : outputVoltage)) { - 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; - } - - 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 (scanTime % 60 == 0 && !sparkList.isEmpty()) { - NetworkDispatcher.INSTANCE.sendToAllAround(new RendererMessage.RendererData(sparkList), - mte.getWorld().provider.dimensionId, - mte.getXCoord(), - mte.getYCoord(), - mte.getZCoord(), - 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; } @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() { + //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) { @@ -825,6 +666,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; } @@ -834,11 +683,95 @@ 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 public String[] getStructureDescription(ItemStack stackSize) { return description; } -}
\ No newline at end of file + + @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/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, 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..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;
@@ -17,60 +17,47 @@ 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;
import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
+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.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 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
-public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryBuffer {
- private final static HashSet<ThaumSpark> 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<IGregTechTileEntity, Integer> eTeslaMap = new HashMap<>();//Tesla Map to map them tesla bois!
-
- 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 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 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 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 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
+
+ private final long outputVoltage = V[mTier];
private boolean overdriveToggle = false;
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);
@@ -128,11 +115,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++;
}
}
@@ -174,13 +161,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;
}
@@ -220,15 +205,43 @@ 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
+ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
+ super.onFirstTick(aBaseMetaTileEntity);
+ if (!aBaseMetaTileEntity.isClientSide()) {
+ teslaNodeSet.add(this);
}
}
@Override
+ public void onRemoval() {
+ super.onRemoval();
+ if (!this.getBaseMetaTileEntity().isClientSide()) {
+ teslaNodeSet.remove(this);
+ }
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ teslaNodeSet.add(this);
+ }
+
+ @Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
super.onPostTick(aBaseMetaTileEntity, aTick);
if (aBaseMetaTileEntity.isClientSide()) {
@@ -247,88 +260,16 @@ public class GT_MetaTileEntity_TeslaCoil extends GT_MetaTileEntity_BasicBatteryB powerPassToggle = false;
}
- //Stuff to do if ePowerPass
- 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);
-
- //Clean the eTeslaMap
- for (Map.Entry<IGregTechTileEntity, Integer> 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());
- }
-
- //Power transfer
- while (outputCurrent > 0) {
- boolean idle = true;
- for (Map.Entry<IGregTechTileEntity, Integer> Rx : entriesSortedByValues(eTeslaMap)) {
- if (getEUVar() >= (overdriveToggle ? outputVoltage * 2 : outputVoltage)) {
- 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;
- }
- 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;
- }
- }
+ //Create the teslaNodeMap
+ if (sortTime == sortTimeMax) {
+ sortTime = 0;
+ generateTeslaNodeMap(this);
}
+ sortTime++;
+
+ //Send Power
+ powerTeslaNodeMap(this);
+
sparkCount++;
if (sparkCount == 60 && !sparkList.isEmpty()) {
sparkCount = 0;
@@ -357,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;
+ }
}
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 Binary files differnew file mode 100644 index 0000000000..833597130b --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_6.png 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 Binary files differnew file mode 100644 index 0000000000..de4ce136e7 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_6.png 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 Binary files differnew file mode 100644 index 0000000000..0801e3f0d7 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/items/itemCapacitorLuV.png diff --git a/src/main/resources/assets/tectech/textures/items/itemCapacitorZPM.png b/src/main/resources/assets/tectech/textures/items/itemCapacitorZPM.png Binary files differnew file mode 100644 index 0000000000..29b30dc63e --- /dev/null +++ b/src/main/resources/assets/tectech/textures/items/itemCapacitorZPM.png |