diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2020-01-18 12:05:36 +0100 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2020-01-18 12:05:36 +0100 |
commit | 0c1d0d82bc3700e063a51a90c8d4d88b5c81a074 (patch) | |
tree | a43916c31076be648c975cb04ca88a5178919ad2 /src/main/java/com | |
parent | 7e26501c38ca45b8b6fd6782ab495cfce67871c7 (diff) | |
download | GT5-Unofficial-0c1d0d82bc3700e063a51a90c8d4d88b5c81a074.tar.gz GT5-Unofficial-0c1d0d82bc3700e063a51a90c8d4d88b5c81a074.tar.bz2 GT5-Unofficial-0c1d0d82bc3700e063a51a90c8d4d88b5c81a074.zip |
circuitassemblyline balance
+ refractor of code
Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>
Former-commit-id: 4d1bbb965e7e264597c44766f508033151d955ab
Diffstat (limited to 'src/main/java/com')
8 files changed, 117 insertions, 53 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index 9cb1dffbaf..0bc0a806a4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -129,10 +129,11 @@ public final class MainMod { } } - if (Loader.isModLoaded("dreamcraft")) { + if (Loader.isModLoaded("dreamcraft")) ConfigHandler.GTNH = true; - } + ConfigHandler.GTNH = ConfigHandler.ezmode != ConfigHandler.GTNH; + if (ConfigHandler.debugLog) { try { new DebugLog(preinit); @@ -140,6 +141,7 @@ public final class MainMod { e.printStackTrace(); } } + if (ConfigHandler.GTNH) MainMod.LOGGER.info("GTNH-Detected . . . ACTIVATE HARDMODE."); @@ -147,6 +149,7 @@ public final class MainMod { BioCultureLoader bioCultureLoader = new BioCultureLoader(); bioCultureLoader.run(); } + if (ConfigHandler.newStuff) { INSTANCE.init(); Werkstoff.init(); @@ -154,6 +157,7 @@ public final class MainMod { if (FMLCommonHandler.instance().getSide().isClient()) new PrefixTextureLinker(); } + } @Mod.EventHandler @@ -192,16 +196,20 @@ public final class MainMod { new ThreadedLoader().run(); else INSTANCE.run(); - GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.electricimplosioncompressor", "Electric Implosions?"); - GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.electricimplosioncompressor.desc", "Basically a giant Hammer that presses Stuff - No more TNT!"); - GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.dehp", "Heat from below!"); - GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.dehp.desc", "Get ALL the thermal energy!"); - GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.circuitassemblyline", "Cheaper Circuits?"); - GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.circuitassemblyline.desc", "Well, yes, but actually no..."); - GT_LanguageManager.addStringLocalization("metaitem.01.tooltip.nqgen", "Can be used as Enriched Naquadah Fuel Substitute"); + localiseAchievements(); } } + private static void localiseAchievements(){ + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.electricimplosioncompressor", "Electric Implosions?"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.electricimplosioncompressor.desc", "Basically a giant Hammer that presses Stuff - No more TNT!"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.dehp", "Heat from below!"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.dehp.desc", "Get ALL the thermal energy!"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.circuitassemblyline", "Cheaper Circuits?"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.circuitassemblyline.desc", "Well, yes, but actually no..."); + GT_LanguageManager.addStringLocalization("metaitem.01.tooltip.nqgen", "Can be used as Enriched Naquadah Fuel Substitute"); + } + @Mod.EventHandler public void onServerStarting(FMLServerStartingEvent event) { event.registerServerCommand(new SummonRuin()); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/textures/PrefixTextureLinker.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/textures/PrefixTextureLinker.java index 4294e1c89c..af08a21524 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/textures/PrefixTextureLinker.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/textures/PrefixTextureLinker.java @@ -35,7 +35,7 @@ import java.util.HashMap; @SideOnly(Side.CLIENT) public class PrefixTextureLinker implements Runnable { - public static HashMap<OrePrefixes,HashMap<TextureSet, Textures.ItemIcons.CustomIcon>> texMap = new HashMap<>(); + public static HashMap<OrePrefixes, HashMap<TextureSet, Textures.ItemIcons.CustomIcon>> texMap = new HashMap<>(); { GregTech_API.sBeforeGTLoad.add(this); @@ -43,21 +43,24 @@ public class PrefixTextureLinker implements Runnable { @Override public void run() { - - for (OrePrefixes prefixes : OrePrefixes.values()) { - if (prefixes == OrePrefixes.rod) - continue; - HashMap<TextureSet, Textures.ItemIcons.CustomIcon> curr = new HashMap<>(); - if (prefixes.mTextureIndex == -1 && Werkstoff.GenerationFeatures.prefixLogic.get(prefixes) != 0) { - Arrays.stream(TextureSet.class.getFields()).filter(field -> field.getName().contains("SET")).forEach(SET -> { - try { - curr.put((TextureSet) SET.get(null), new Textures.ItemIcons.CustomIcon("materialicons/" + SET.getName().substring(4) + "/" + prefixes)); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } + Arrays.stream(OrePrefixes.values()) + .filter(prefixes -> prefixes != OrePrefixes.rod + && prefixes.mTextureIndex == -1 && Werkstoff.GenerationFeatures.prefixLogic.get(prefixes) != 0) + .forEach(prefixes -> { + HashMap<TextureSet, Textures.ItemIcons.CustomIcon> curr = new HashMap<>(); + Arrays.stream(TextureSet.class.getFields()) + .filter(field -> field.getName().contains("SET")) + .forEach(SET -> { + try { + curr.put((TextureSet) SET.get(null), + new Textures.ItemIcons.CustomIcon( + "materialicons/" + SET.getName().substring(4) + "/" + prefixes) + ); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + }); + texMap.put(prefixes, curr); }); - texMap.put(prefixes, curr); - } - } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java index 6d664ed7cd..af096236aa 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java @@ -121,7 +121,7 @@ public class GT_TileEntity_CircuitAssemblyLine extends GT_MetaTileEntity_MultiBl return false; if (this.bufferedRecipe != null && this.bufferedRecipe.isRecipeInputEqual(true,false, BW_Util.getFluidsFromInputHatches(this), BW_Util.getItemsFromInputBusses(this))) { - BW_Util.calculateOverclockedNessMulti(this.bufferedRecipe.mEUt,this.bufferedRecipe.mDuration,1,this.getMaxInputVoltage(),this); + BW_Util.calculateOverclockedNessMultiPefectOC(this.bufferedRecipe.mEUt,this.bufferedRecipe.mDuration,1,this.getMaxInputVoltage(),this); if (this.mEUt > 0) this.mEUt = -this.mEUt; this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java index a7823ed112..81fa72717f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -60,6 +60,7 @@ public class CircuitImprintLoader { private static final HashSet<GT_Recipe> ORIGINAL_CAL_RECIPES = new HashSet<>(); private static final HashSet<GT_Recipe> MODIFIED_CAL_RECIPES = new HashSet<>(); + @SuppressWarnings("unused") public static void run() { HashSet<GT_Recipe> toRem = new HashSet<>(); HashSet<GT_Recipe> toAdd = new HashSet<>(); @@ -162,7 +163,7 @@ public class CircuitImprintLoader { return null; } - return new BWRecipes.DynamicGTRecipe(false, in, new ItemStack[]{getOutputMultiplied(original)}, BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(CircuitImprintLoader.getTagFromStack(original.mOutputs[0]), 0, 0), null, original.mFluidInputs, null, original.mDuration * 16, original.mEUt, 0); + return new BWRecipes.DynamicGTRecipe(false, in, new ItemStack[]{getOutputMultiplied(original)}, BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(CircuitImprintLoader.getTagFromStack(original.mOutputs[0]), 0, 0), null, original.mFluidInputs, null, original.mDuration * 12, original.mEUt, 0); } private static ItemStack getOutputMultiplied(GT_Recipe original){ diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java index c5295eab6e..ff080eab82 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java @@ -26,26 +26,31 @@ import com.github.bartimaeusnek.bartworks.util.BW_Util; import gregtech.api.util.GT_Recipe; import java.util.HashSet; +import java.util.Objects; import java.util.Set; public class DownTierLoader implements Runnable { + @Override public void run() { - for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) { - if (map == GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes || map == GT_Recipe.GT_Recipe_Map.sReplicatorFakeRecipes || map == GT_Recipe.GT_Recipe_Map.sMassFabFakeRecipes || map == GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes || map == GT_Recipe.GT_Recipe_Map.sFusionRecipes || map == GT_Recipe.GT_Recipe_Map.sRockBreakerFakeRecipes) - return; - Set<GT_Recipe> newRecipes = new HashSet<>(); - Set<GT_Recipe> toRem = new HashSet<>(); - for (GT_Recipe recipe : map.mRecipeList) { - if (recipe == null) - continue; - if (recipe.mEUt > 128) { - toRem.add(recipe); - newRecipes.add(BW_Util.copyAndSetTierToNewRecipe(recipe, (byte) 2)); - } - } - map.mRecipeList.removeAll(toRem); - map.mRecipeList.addAll(newRecipes); - } + GT_Recipe.GT_Recipe_Map.sMappings.stream().filter(map -> + !(map == GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes + || map == GT_Recipe.GT_Recipe_Map.sReplicatorFakeRecipes + || map == GT_Recipe.GT_Recipe_Map.sMassFabFakeRecipes + || map == GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes + || map == GT_Recipe.GT_Recipe_Map.sFusionRecipes + || map == GT_Recipe.GT_Recipe_Map.sRockBreakerFakeRecipes)) + .forEach(map -> { + Set<GT_Recipe> newRecipes = new HashSet<>(); + Set<GT_Recipe> toRem = new HashSet<>(); + map.mRecipeList.stream() + .filter(recipe -> Objects.nonNull(recipe) && recipe.mEUt > 128) + .forEach(recipe -> { + toRem.add(recipe); + newRecipes.add(BW_Util.copyAndSetTierToNewRecipe(recipe, (byte) 2)); + }); + map.mRecipeList.removeAll(toRem); + map.mRecipeList.addAll(newRecipes); + }); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java index 02351a3f77..24194ff563 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -349,6 +349,51 @@ public class BW_Util { } } + public static void calculateOverclockedNessMultiPefectOC(@Nonnegative int aEUt, @Nonnegative int aDuration, @Nonnegative int mAmperage, @Nonnegative long maxInputVoltage, GT_MetaTileEntity_MultiBlockBase base){ + byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage)); + if (mTier == 0) { + //Long time calculation + long xMaxProgresstime = ((long) aDuration) << 1; + if (xMaxProgresstime > Integer.MAX_VALUE - 1) { + //make impossible if too long + base.mEUt = Integer.MAX_VALUE - 1; + base.mMaxProgresstime = Integer.MAX_VALUE - 1; + } else { + base.mEUt = aEUt >> 2; + base.mMaxProgresstime = (int) xMaxProgresstime; + } + } else { + long xEUt = aEUt; + //Isnt too low EUt check? + long tempEUt = Math.max(xEUt, V[1]); + + base.mMaxProgresstime = aDuration; + + while (tempEUt <= V[mTier - 1] * mAmperage) { + tempEUt <<= 1;//this actually controls overclocking + base.mMaxProgresstime >>= 1;//this is effect of overclocking + xEUt = base.mMaxProgresstime <= 0 ? xEUt >> 1 : xEUt << 1;//U know, if the time is less than 1 tick make the machine use less power + } + + while (xEUt > maxInputVoltage) { + //downclock one notch until we are good again, we have overshot. + xEUt >>= 1; + base.mMaxProgresstime <<= 1; + } + if (xEUt > Integer.MAX_VALUE - 1) { + base.mEUt = Integer.MAX_VALUE - 1; + base.mMaxProgresstime = Integer.MAX_VALUE - 1; + } else { + base.mEUt = (int) xEUt; + if (base.mEUt == 0) + base.mEUt = 1; + if (base.mMaxProgresstime <= 0) + base.mMaxProgresstime = 1;//set time to 1 tick + } + } + } + + public static long getnominalVoltage(GT_MetaTileEntity_MultiBlockBase base) { long rVoltage = 0L; long rAmperage = 0L; @@ -487,9 +532,10 @@ public class BW_Util { continue; if (controllerLayer && (xDir + x == 0 && zDir + z == 0)) continue; - if (insideCheck && (Math.abs(x) < radius && Math.abs(z) != radius)) + final boolean inside = Math.abs(x) < radius && Math.abs(z) != radius; + if (insideCheck && inside) ret.add(aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)); - if (!(Math.abs(x) < radius && Math.abs(z) != radius)) { + if (!inside) { ret.add(aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)); } } @@ -537,7 +583,9 @@ public class BW_Util { } private static Field sBufferedRecipeList; - public static List<IRecipe> getGTBufferedRecipeList() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{ + + @SuppressWarnings("unchecked") + public static List<IRecipe> getGTBufferedRecipeList() throws SecurityException, IllegalArgumentException, IllegalAccessException{ if (sBufferedRecipeList == null) { sBufferedRecipeList = FieldUtils.getDeclaredField(GT_ModHandler.class,"sBufferRecipeList",true); } @@ -551,6 +599,7 @@ public class BW_Util { return createGTCraftingRecipe(aResult, new Enchantment[0], new int[0], (aBitMask & GT_ModHandler.RecipeBits.MIRRORED) != 0L, (aBitMask & GT_ModHandler.RecipeBits.BUFFERED) != 0L, (aBitMask & GT_ModHandler.RecipeBits.KEEPNBT) != 0L, (aBitMask & GT_ModHandler.RecipeBits.DISMANTLEABLE) != 0L, (aBitMask & GT_ModHandler.RecipeBits.NOT_REMOVABLE) == 0L, (aBitMask & GT_ModHandler.RecipeBits.REVERSIBLE) != 0L, (aBitMask & GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_RECIPES) != 0L, (aBitMask & GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_RECIPES_IF_SAME_NBT) != 0L, (aBitMask & GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_SHAPED_RECIPES) != 0L, (aBitMask & GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_NATIVE_RECIPES) != 0L, (aBitMask & GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS) == 0L, (aBitMask & GT_ModHandler.RecipeBits.ONLY_ADD_IF_THERE_IS_ANOTHER_RECIPE_FOR_IT) != 0L, (aBitMask & GT_ModHandler.RecipeBits.ONLY_ADD_IF_RESULT_IS_NOT_NULL) != 0L, aRecipe); } + @SuppressWarnings({"rawtypes","unchecked"}) public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, Enchantment[] aEnchantmentsAdded, int[] aEnchantmentLevelsAdded, boolean aMirrored, boolean aBuffered, boolean aKeepNBT, boolean aDismantleable, boolean aRemovable, boolean aReversible, boolean aRemoveAllOthersWithSameOutput, boolean aRemoveAllOthersWithSameOutputIfTheyHaveSameNBT, boolean aRemoveAllOtherShapedsWithSameOutput, boolean aRemoveAllOtherNativeRecipes, boolean aCheckForCollisions, boolean aOnlyAddIfThereIsAnyRecipeOutputtingThis, boolean aOnlyAddIfResultIsNotNull, Object[] aRecipe) { aResult = GT_OreDictUnificator.get(true, aResult); if (aOnlyAddIfResultIsNotNull && aResult == null) return null; @@ -575,7 +624,7 @@ public class BW_Util { throw new IllegalArgumentException(); } - ArrayList<Object> tRecipeList = new ArrayList<Object>(Arrays.asList(aRecipe)); + ArrayList<Object> tRecipeList = new ArrayList<>(Arrays.asList(aRecipe)); while (aRecipe[idx] instanceof String) { StringBuilder s = new StringBuilder((String) aRecipe[idx++]); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java index 38074acc7b..5c6993d2eb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java @@ -24,6 +24,8 @@ package com.github.bartimaeusnek.bartworks.util; public class ChatColorHelper { + private ChatColorHelper() {} + public static final String BLACK = (char) 167 + "0"; public static final String DARKBLUE = (char) 167 + "1"; public static final String DARKGREEN = (char) 167 + "2"; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java index 83238c5f07..c881e09317 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java @@ -34,10 +34,7 @@ import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; import micdoodle8.mods.galacticraft.api.galaxies.GalaxyRegistry; import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; +import java.util.*; @SuppressWarnings("unused") public final class BWAtmosphereManager { @@ -84,8 +81,7 @@ public final class BWAtmosphereManager { @SafeVarargs public static void addGasToWorld(int worldID, Pair<ISubTagContainer,Integer>... toPut){ - for (Pair<ISubTagContainer,Integer> toadd : toPut) - BWAtmosphereManager.gasConcentration.put(worldID,toadd); + Arrays.stream(toPut).forEach(toadd -> BWAtmosphereManager.gasConcentration.put(worldID, toadd)); } private static boolean addGCGasToWorld(int worldID, IAtmosphericGas gas, int aNumber, int aMaxNumber){ |