Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
circuitassemblyline balance
Browse files Browse the repository at this point in the history
+ refractor of code

Signed-off-by: bartimaeusnek <[email protected]>
  • Loading branch information
bartimaeusnek committed Jan 18, 2020
1 parent c86f682 commit 8ed92e8
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 54 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
mc_version=1.7.10
majorUpdate=0
minorUpdate=5
buildNumber=8
buildNumber=9
APIVersion=8
ic2.version=2.2.828-experimental
gregtech.version=5.09.32.36
Expand Down
26 changes: 17 additions & 9 deletions src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,35 @@ public void preInit(FMLPreInitializationEvent preinit) {
}
}

if (Loader.isModLoaded("dreamcraft")) {
if (Loader.isModLoaded("dreamcraft"))
ConfigHandler.GTNH = true;
}

ConfigHandler.GTNH = ConfigHandler.ezmode != ConfigHandler.GTNH;

if (ConfigHandler.debugLog) {
try {
new DebugLog(preinit);
} catch (IOException e) {
e.printStackTrace();
}
}

if (ConfigHandler.GTNH)
MainMod.LOGGER.info("GTNH-Detected . . . ACTIVATE HARDMODE.");

if (ConfigHandler.BioLab) {
BioCultureLoader bioCultureLoader = new BioCultureLoader();
bioCultureLoader.run();
}

if (ConfigHandler.newStuff) {
INSTANCE.init();
Werkstoff.init();
GregTech_API.sAfterGTPostload.add(new CircuitPartLoader());
if (FMLCommonHandler.instance().getSide().isClient())
new PrefixTextureLinker();
}

}

@Mod.EventHandler
Expand Down Expand Up @@ -192,16 +196,20 @@ public void postInit(FMLPostInitializationEvent postinit) {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,32 @@

@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);
}

@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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public boolean checkRecipe(ItemStack itemStack) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<>();
Expand Down Expand Up @@ -162,7 +163,7 @@ public static GT_Recipe reBuildRecipe(GT_Recipe original) {
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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,31 @@
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);
});
}
}
57 changes: 53 additions & 4 deletions src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,51 @@ public static void calculateOverclockedNessMulti(@Nonnegative int aEUt, @Nonnega
}
}

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;
Expand Down Expand Up @@ -487,9 +532,10 @@ public static List<Byte> getMetasFromLayer(IGregTechTileEntity aBaseMetaTileEnti
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));
}
}
Expand Down Expand Up @@ -537,7 +583,9 @@ public static byte calculateGlassTier(@Nonnull Block block, @Nonnegative byte me
}

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);
}
Expand All @@ -551,6 +599,7 @@ public static ShapedOreRecipe createGTCraftingRecipe(ItemStack aResult, long aBi
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;
Expand All @@ -575,7 +624,7 @@ else if (!(aRecipe[i] == null || aRecipe[i] instanceof ItemStack || aRecipe[i] i
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++]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
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 {
Expand Down Expand Up @@ -84,8 +81,7 @@ public static void addGasToWorld(int worldID, Pair<ISubTagContainer,Integer> toP

@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){
Expand Down

0 comments on commit 8ed92e8

Please sign in to comment.