aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2020-01-07 15:49:37 +0100
committerbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2020-01-07 15:49:37 +0100
commit22ac800273f3774331ca4e817d89233d18819000 (patch)
treea77b8c9258697fd49159a41f596b14f3a5dae740 /src/main/java/com
parent501134f1e1457fb3b5762f12471e1c930ee1fa94 (diff)
downloadGT5-Unofficial-22ac800273f3774331ca4e817d89233d18819000.tar.gz
GT5-Unofficial-22ac800273f3774331ca4e817d89233d18819000.tar.bz2
GT5-Unofficial-22ac800273f3774331ca4e817d89233d18819000.zip
Fixes:
+ Ores not beeing detected by Miners + CircuitImprints not craftable/recipe buildup when server changes Refractored some code Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Former-commit-id: 2f2d7b4977334c7faba8185ecb76229c57b939a3
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java144
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java3
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java8
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java5
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java294
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java98
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java3
7 files changed, 305 insertions, 250 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
index cf0c828cc5..f1ad6e2b2a 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
@@ -120,9 +120,9 @@ public final class MainMod {
if (Loader.isModLoaded("miscutils") && ConfigHandler.GTppLogDisabler) {
try {
- Field loggerField = FieldUtils.getField(Class.forName("gtPlusPlus.api.objects.Logger"),"modLogger",true);
- FieldUtils.removeFinalModifier(loggerField,true);
- loggerField.set(null,(Logger)new STFUGTPPLOG());
+ Field loggerField = FieldUtils.getField(Class.forName("gtPlusPlus.api.objects.Logger"), "modLogger", true);
+ FieldUtils.removeFinalModifier(loggerField, true);
+ loggerField.set(null, (Logger) new STFUGTPPLOG());
} catch (IllegalAccessException | ClassNotFoundException e) {
e.printStackTrace();
}
@@ -180,8 +180,8 @@ public final class MainMod {
NetworkRegistry.INSTANCE.registerGuiHandler(MainMod.instance, MainMod.GH);
if (ConfigHandler.BioLab) {
new GTNHBlocks().run();
- for (Map.Entry<BioVatLogicAdder.BlockMetaPair, Byte>pair : BioVatLogicAdder.BioVatGlass.getGlassMap().entrySet()){
- GT_OreDictUnificator.registerOre("blockGlass"+VN[pair.getValue()],new ItemStack(pair.getKey().getBlock(),1,pair.getKey().getaByte()));
+ for (Map.Entry<BioVatLogicAdder.BlockMetaPair, Byte> pair : BioVatLogicAdder.BioVatGlass.getGlassMap().entrySet()) {
+ GT_OreDictUnificator.registerOre("blockGlass" + VN[pair.getValue()], new ItemStack(pair.getKey().getBlock(), 1, pair.getKey().getaByte()));
}
}
@@ -191,18 +191,18 @@ 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");
+ 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){
+ public void onServerStarting(FMLServerStartingEvent event) {
event.registerServerCommand(new SummonRuin());
event.registerServerCommand(new ChangeConfig());
event.registerServerCommand(new PrintRecipeListToFile());
@@ -212,6 +212,7 @@ public final class MainMod {
public void onServerStarted(FMLServerStartedEvent event) {
MainMod.runOnPlayerJoined(ConfigHandler.classicMode, ConfigHandler.disableExtraGassesForEBF);
}
+
@Mod.EventHandler
public void onModLoadingComplete(FMLLoadCompleteEvent event) {
removeIC2Recipes();
@@ -227,7 +228,6 @@ public final class MainMod {
public static void runOnPlayerJoined(boolean classicMode, boolean extraGasRecipes) {
OreDictHandler.adaptCacheForWorld();
-
CircuitImprintLoader.run();
if (!recipesAdded) {
@@ -246,12 +246,12 @@ public final class MainMod {
private static void fixEnergyRequirements() {
maploop:
- for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings){
- for (GT_Recipe recipe : map.mRecipeList){
+ for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) {
+ for (GT_Recipe recipe : map.mRecipeList) {
if (recipe.mFakeRecipe)
continue maploop;
- for (int i = 0; i < (VN.length-1); i++) {
- if (recipe.mEUt == BW_Util.getTierVoltage(i)){
+ for (int i = 0; i < (VN.length - 1); i++) {
+ if (recipe.mEUt == BW_Util.getTierVoltage(i)) {
recipe.mEUt = BW_Util.getMachineVoltageFromTier(i);
}
}
@@ -293,61 +293,61 @@ public final class MainMod {
MainMod.runMoltenUnificationEnfocement(werkstoff);
MainMod.runUnficationDeleter(werkstoff);
for (String s : oreDictNames)
- for (OrePrefixes prefixes : OrePrefixes.values()) {
- if (OreDictionary.getOres(prefixes + s).size() > 1) {
- for (int j = 0; j < OreDictionary.getOres(prefixes + s).size(); j++) {
- ItemStack toReplace = OreDictionary.getOres(prefixes + s).get(j);
- ItemStack replacement = werkstoff.get(prefixes);
- if (GT_Utility.areStacksEqual(toReplace,replacement) || replacement == null || replacement.getItem() == null)
- continue;
- if (toReplace != null) {
- for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) {
- HashSet<GT_Recipe> toRem = new HashSet<>();
- for (GT_Recipe recipe : map.mRecipeList) {
- boolean removal = map.equals(GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes) || map.equals(GT_Recipe.GT_Recipe_Map.sFluidSolidficationRecipes);
- for (int i = 0; i < recipe.mInputs.length; i++) {
- if (GT_Utility.areStacksEqual(recipe.mInputs[i], toReplace)) {
- if (removal)
- toRem.add(recipe);
- else {
- int amount = recipe.mInputs[i].stackSize;
- recipe.mInputs[i] = replacement.splitStack(amount);
+ for (OrePrefixes prefixes : OrePrefixes.values()) {
+ if (OreDictionary.getOres(prefixes + s).size() > 1) {
+ for (int j = 0; j < OreDictionary.getOres(prefixes + s).size(); j++) {
+ ItemStack toReplace = OreDictionary.getOres(prefixes + s).get(j);
+ ItemStack replacement = werkstoff.get(prefixes);
+ if (GT_Utility.areStacksEqual(toReplace, replacement) || replacement == null || replacement.getItem() == null)
+ continue;
+ if (toReplace != null) {
+ for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) {
+ HashSet<GT_Recipe> toRem = new HashSet<>();
+ for (GT_Recipe recipe : map.mRecipeList) {
+ boolean removal = map.equals(GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes) || map.equals(GT_Recipe.GT_Recipe_Map.sFluidSolidficationRecipes);
+ for (int i = 0; i < recipe.mInputs.length; i++) {
+ if (GT_Utility.areStacksEqual(recipe.mInputs[i], toReplace)) {
+ if (removal)
+ toRem.add(recipe);
+ else {
+ int amount = recipe.mInputs[i].stackSize;
+ recipe.mInputs[i] = replacement.splitStack(amount);
+ }
}
}
- }
- for (int i = 0; i < recipe.mOutputs.length; i++) {
- if (GT_Utility.areStacksEqual(recipe.mOutputs[i], toReplace)) {
- if (removal)
- toRem.add(recipe);
- else {
- int amount = recipe.mOutputs[i].stackSize;
- recipe.mOutputs[i] = replacement.splitStack(amount);
+ for (int i = 0; i < recipe.mOutputs.length; i++) {
+ if (GT_Utility.areStacksEqual(recipe.mOutputs[i], toReplace)) {
+ if (removal)
+ toRem.add(recipe);
+ else {
+ int amount = recipe.mOutputs[i].stackSize;
+ recipe.mOutputs[i] = replacement.splitStack(amount);
+ }
}
}
- }
- if (recipe.mSpecialItems instanceof ItemStack) {
- if (GT_Utility.areStacksEqual((ItemStack) recipe.mSpecialItems, toReplace)) {
- if (removal)
- toRem.add(recipe);
- else {
- int amount = ((ItemStack) recipe.mSpecialItems).stackSize;
- recipe.mSpecialItems = replacement.splitStack(amount);
+ if (recipe.mSpecialItems instanceof ItemStack) {
+ if (GT_Utility.areStacksEqual((ItemStack) recipe.mSpecialItems, toReplace)) {
+ if (removal)
+ toRem.add(recipe);
+ else {
+ int amount = ((ItemStack) recipe.mSpecialItems).stackSize;
+ recipe.mSpecialItems = replacement.splitStack(amount);
+ }
}
}
}
+ map.mRecipeList.removeAll(toRem);
}
- map.mRecipeList.removeAll(toRem);
}
}
}
}
- }
}
}
}
@SuppressWarnings("ALL")
- private static void runMoltenUnificationEnfocement(Werkstoff werkstoff){
+ private static void runMoltenUnificationEnfocement(Werkstoff werkstoff) {
if (werkstoff.getGenerationFeatures().enforceUnification && werkstoff.getGenerationFeatures().hasMolten()) {
try {
FluidContainerRegistry.FluidContainerData data = new FluidContainerRegistry.FluidContainerData(new FluidStack(Objects.requireNonNull(molten.get(werkstoff)), 144), werkstoff.get(cellMolten), Materials.Empty.getCells(1));
@@ -415,26 +415,26 @@ public final class MainMod {
for (OrePrefixes prefixes : OrePrefixes.values())
if ((werkstoff.getGenerationFeatures().toGenerate & Werkstoff.GenerationFeatures.prefixLogic.get(prefixes)) != 0 && ((werkstoff.getGenerationFeatures().blacklist & Werkstoff.GenerationFeatures.prefixLogic.get(prefixes)) == 0)) {
- GT_OreDictUnificator.set(prefixes,werkstoff.getBridgeMaterial(),werkstoff.get(prefixes),true,true);
+ GT_OreDictUnificator.set(prefixes, werkstoff.getBridgeMaterial(), werkstoff.get(prefixes), true, true);
for (ItemStack stack : OreDictionary.getOres(prefixes + werkstoff.getVarName())) {
- GT_OreDictUnificator.addAssociation(prefixes,werkstoff.getBridgeMaterial(),stack,false);
+ GT_OreDictUnificator.addAssociation(prefixes, werkstoff.getBridgeMaterial(), stack, false);
GT_OreDictUnificator.getAssociation(stack).mUnificationTarget = werkstoff.get(prefixes);
}
}
}
- private static ArrayListMultimap<SubTag,GT_Recipe> getRecipesToChange(SubTag... GasTags){
+ private static ArrayListMultimap<SubTag, GT_Recipe> getRecipesToChange(SubTag... GasTags) {
Iterator<GT_Recipe> it = GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.iterator();
- ArrayListMultimap<SubTag,GT_Recipe> toAdd = ArrayListMultimap.create();
+ ArrayListMultimap<SubTag, GT_Recipe> toAdd = ArrayListMultimap.create();
while (it.hasNext()) {
GT_Recipe recipe = it.next();
if (recipe.mFluidInputs != null && recipe.mFluidInputs.length > 0) {
String FluidString = recipe.mFluidInputs[0].getFluid().getName().replaceAll("molten", "").replaceAll("fluid", "");
Materials mat = Materials.get(FluidString.substring(0, 1).toUpperCase() + FluidString.substring(1));
if (mat != Materials._NULL) {
- for (SubTag tag : GasTags){
+ for (SubTag tag : GasTags) {
if (mat.contains(tag)) {
- DebugLog.log("Found EBF Recipe to change, Output:"+ BW_Util.translateGTItemStack(recipe.mOutputs[0]));
+ DebugLog.log("Found EBF Recipe to change, Output:" + BW_Util.translateGTItemStack(recipe.mOutputs[0]));
toAdd.put(tag, recipe);
}
}
@@ -444,10 +444,10 @@ public final class MainMod {
return toAdd;
}
- private static HashSet<ItemStack> getNoGasItems(ArrayListMultimap<SubTag,GT_Recipe> base){
+ private static HashSet<ItemStack> getNoGasItems(ArrayListMultimap<SubTag, GT_Recipe> base) {
Iterator<GT_Recipe> it = GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.iterator();
HashSet<ItemStack> toAdd = new HashSet<>();
- ArrayListMultimap<SubTag,GT_Recipe> repToAdd = ArrayListMultimap.create();
+ ArrayListMultimap<SubTag, GT_Recipe> repToAdd = ArrayListMultimap.create();
while (it.hasNext()) {
GT_Recipe recipe = it.next();
for (SubTag tag : base.keySet())
@@ -457,7 +457,7 @@ public final class MainMod {
for (int i = 0; i < recipe.mInputs.length; i++) {
if ((recipe.mFluidInputs == null || recipe.mFluidInputs.length == 0) && BW_Util.checkStackAndPrefix(recipe.mInputs[i]) && BW_Util.checkStackAndPrefix(baseRe.mInputs[i]) && GT_OreDictUnificator.getAssociation(recipe.mInputs[i]).mMaterial.mMaterial.equals(GT_OreDictUnificator.getAssociation(baseRe.mInputs[i]).mMaterial.mMaterial) && GT_Utility.areStacksEqual(recipe.mOutputs[0], baseRe.mOutputs[0])) {
toAdd.add(recipe.mOutputs[0]);
- repToAdd.put(tag,recipe);
+ repToAdd.put(tag, recipe);
continue recipeLoop;
}
}
@@ -467,7 +467,7 @@ public final class MainMod {
return toAdd;
}
- private static void editRecipes(ArrayListMultimap<SubTag,GT_Recipe> base, HashSet<ItemStack> noGas) {
+ private static void editRecipes(ArrayListMultimap<SubTag, GT_Recipe> base, HashSet<ItemStack> noGas) {
if (GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeFluidNameMap.contains(Objects.requireNonNull(fluids.get(Oganesson)).getName()))
return;
HashSet<GT_Recipe> toAdd = new HashSet<>();
@@ -480,13 +480,13 @@ public final class MainMod {
for (Werkstoff werkstoff : Werkstoff.werkstoffHashMap.values()) {
if (!werkstoff.contains(GasTag))
continue;
- int time = (int) ((double) recipe.mDuration / 200D * (200D + (werkstoff.getStats().getProtons() >= mat.getProtons() ? (double) mat.getProtons() - (double) werkstoff.getStats().getProtons() : (double) mat.getProtons()*2.75D - (double) werkstoff.getStats().getProtons())));
+ int time = (int) ((double) recipe.mDuration / 200D * (200D + (werkstoff.getStats().getProtons() >= mat.getProtons() ? (double) mat.getProtons() - (double) werkstoff.getStats().getProtons() : (double) mat.getProtons() * 2.75D - (double) werkstoff.getStats().getProtons())));
toAdd.add(new BWRecipes.DynamicGTRecipe(false, recipe.mInputs, recipe.mOutputs, recipe.mSpecialItems, recipe.mChances, new FluidStack[]{new FluidStack(Objects.requireNonNull(fluids.get(werkstoff)), recipe.mFluidInputs[0].amount)}, recipe.mFluidOutputs, time, recipe.mEUt, recipe.mSpecialValue));
}
for (Materials materials : Materials.values()) {
if (!materials.contains(GasTag))
continue;
- int time = (int) ((double) recipe.mDuration / 200D * (200D + (materials.getProtons() >= mat.getProtons() ? (double) mat.getProtons() - (double) materials.getProtons() : (double) mat.getProtons()*2.75D - (double) materials.getProtons())));
+ int time = (int) ((double) recipe.mDuration / 200D * (200D + (materials.getProtons() >= mat.getProtons() ? (double) mat.getProtons() - (double) materials.getProtons() : (double) mat.getProtons() * 2.75D - (double) materials.getProtons())));
toAdd.add(new BWRecipes.DynamicGTRecipe(false, recipe.mInputs, recipe.mOutputs, recipe.mSpecialItems, recipe.mChances, new FluidStack[]{materials.getGas(recipe.mFluidInputs[0].amount)}, recipe.mFluidOutputs, time, recipe.mEUt, recipe.mSpecialValue));
}
for (ItemStack is : noGas) {
@@ -510,17 +510,17 @@ public final class MainMod {
GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.removeAll(base.get(GasTag));
}
HashSet<GT_Recipe> duplicates = new HashSet<>();
- for (GT_Recipe recipe : toAdd){
- for (GT_Recipe recipe2 : toAdd){
+ for (GT_Recipe recipe : toAdd) {
+ for (GT_Recipe recipe2 : toAdd) {
if (recipe.mEUt != recipe2.mEUt || recipe.mDuration != recipe2.mDuration || recipe.mSpecialValue != recipe2.mSpecialValue || recipe == recipe2 || recipe.mInputs.length != recipe2.mInputs.length || recipe.mFluidInputs.length != recipe2.mFluidInputs.length)
continue;
boolean isSame = true;
for (int i = 0; i < recipe.mInputs.length; i++) {
- if (!GT_Utility.areStacksEqual(recipe.mInputs[i],recipe2.mInputs[i]))
+ if (!GT_Utility.areStacksEqual(recipe.mInputs[i], recipe2.mInputs[i]))
isSame = false;
}
for (int i = 0; i < recipe.mFluidInputs.length; i++) {
- if (!GT_Utility.areFluidsEqual(recipe.mFluidInputs[i],recipe2.mFluidInputs[i]))
+ if (!GT_Utility.areFluidsEqual(recipe.mFluidInputs[i], recipe2.mFluidInputs[i]))
isSame = false;
}
if (isSame)
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java
index d50511337d..0e2121a0ae 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedBlock_Item.java
@@ -72,9 +72,8 @@ public class BW_MetaGeneratedBlock_Item extends BW_ItemBlocks {
}
BW_MetaGenerated_Block_TE tTileEntity = (BW_MetaGenerated_Block_TE) aWorld.getTileEntity(aX, aY, aZ);
tTileEntity.mMetaData = tDamage;
- } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3)) {
+ } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3))
return false;
- }
if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) {
this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack);
this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage);
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java
index 1b3a645e5c..154efe029a 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java
@@ -48,12 +48,11 @@ public abstract class BW_MetaGenerated_Blocks extends BW_TileEntityContainer {
this.setResistance(5.0F);
this.setBlockTextureName("stone");
this.setCreativeTab(metaTab);
- for (Werkstoff w : Werkstoff.werkstoffHashSet)
- doRegistrationStuff(w);
+ Werkstoff.werkstoffHashSet.forEach(this::doRegistrationStuff);
}
@SideOnly(Side.CLIENT)
- public final BW_MetaGenerated_Block_TE getProperTileEntityForRendering(){
+ public final BW_MetaGenerated_Block_TE getProperTileEntityForRendering() {
return (BW_MetaGenerated_Block_TE) createNewTileEntity(null,0);
}
@@ -69,9 +68,8 @@ public abstract class BW_MetaGenerated_Blocks extends BW_TileEntityContainer {
}
public int getRenderType() {
- if (BW_Renderer_Block_Ores.INSTANCE == null) {
+ if (BW_Renderer_Block_Ores.INSTANCE == null)
return super.getRenderType();
- }
return BW_Renderer_Block_Ores.INSTANCE.mRenderID;
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java
index dc4bc47673..7cea9d0588 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java
@@ -45,12 +45,13 @@ public class BW_MetaGenerated_Ores extends BW_MetaGenerated_Blocks {
super(p_i45386_1_, tileEntity, blockName);
}
- protected void doRegistrationStuff(Werkstoff w){
+ protected void doRegistrationStuff(Werkstoff w) {
if (w != null) {
if ((w.getGenerationFeatures().toGenerate & 0b1000) == 0 || ((w.getGenerationFeatures().blacklist & 0b1000) != 0))
return;
GT_ModHandler.addValuableOre(this, w.getmID(), 1);
GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + w.getmID() + ".name", w.getDefaultName() + OrePrefixes.ore.mLocalizedMaterialPost);
+
}
}
@@ -113,7 +114,7 @@ public class BW_MetaGenerated_Ores extends BW_MetaGenerated_Blocks {
}
@SuppressWarnings("unused")
- private boolean checkForAir(IBlockAccess aWorld, int aX, int aY, int aZ){
+ private boolean checkForAir(IBlockAccess aWorld, int aX, int aY, int aZ) {
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
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 361648f276..4ffade4528 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
@@ -46,111 +46,73 @@ import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import java.util.HashSet;
-import java.util.Iterator;
public class CircuitImprintLoader {
- public static final ArrayListMultimap<NBTTagCompound,GT_Recipe> recipeTagMap = ArrayListMultimap.create();
-
- static final HashBiMap<CircuitData,ItemStack> bwCircuitTagMap = HashBiMap.create(20);
public static short reverseIDs = Short.MAX_VALUE-1;
- public static HashBiMap<Short, ItemList> circuitIIconRefs = HashBiMap.create(20);
-
-// /**
-// * stack is assumed valid
-// **/
-// private static NBTTagCompound getUniqueIdentifierFromStack(ItemStack stack){
-// NBTTagCompound tagCompound = new NBTTagCompound();
-// tagCompound.setString("Name", stack.getUnlocalizedName());
-// tagCompound.setString("ODName", OreDictionary.getOreName(OreDictionary.getOreID(stack)));
-// tagCompound.setShort("Damage", (short)stack.getItemDamage());
-//
-// return tagCompound;
-// }
-//
-// private static ItemStack getStackFromUniqueIdentifier(NBTTagCompound tagCompound){
-// return OreDictionary.getOres(tagCompound.getString("ODName")).stream().filter(
-// e ->
-// e.getItemDamage() == tagCompound.getShort("Damage")
-// && e.getUnlocalizedName().equals(tagCompound.getString("Name"))
-//
-// ).findFirst().orElse(null);
-// }
-
- public static NBTTagCompound getTagFromStack(ItemStack stack){
- if (GT_Utility.isStackValid(stack))
- return stack.copy().splitStack(1).writeToNBT(new NBTTagCompound());
- return new NBTTagCompound();
- }
- public static ItemStack getStackFromTag(NBTTagCompound tagCompound){
- return ItemStack.loadItemStackFromNBT(tagCompound);
- }
+ public static final ArrayListMultimap<NBTTagCompound,GT_Recipe> recipeTagMap = ArrayListMultimap.create();
+ public static final HashBiMap<Short, ItemList> circuitIIconRefs = HashBiMap.create(20);
+ public static final HashSet<ItemStack> blacklistSet = new HashSet<>();
+ static final HashBiMap<CircuitData,ItemStack> bwCircuitTagMap = HashBiMap.create(20);
+ private static final HashSet<IRecipe> recipeWorldCache = new HashSet<>();
+ private static final HashSet<GT_Recipe> gtrecipeWorldCache = new HashSet<>();
public static void run() {
- boolean newServer = false;
- if (BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).mRecipeList.size() > 0){
- BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).mRecipeList.clear();
- recipeTagMap.clear();
- newServer = true;
- }
-
- Iterator<GT_Recipe> it = GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.iterator();
- GT_Recipe circuitRecipe;
-
HashSet<GT_Recipe> toRem = new HashSet<>();
HashSet<GT_Recipe> toAdd = new HashSet<>();
- while (it.hasNext()) {
- circuitRecipe = it.next();
-
- ItemStack[] outputs = circuitRecipe.mOutputs;
-
- if (outputs.length < 1)
- continue;
-
- int[] oreIDS = OreDictionary.getOreIDs(outputs[0]);
-
- if (oreIDS.length < 1)
- continue;
-
- String name = OreDictionary.getOreName(oreIDS[0]);
-
- if (name.contains("Circuit") || name.contains("circuit")) {
-
- CircuitImprintLoader.recipeTagMap.put(CircuitImprintLoader.getTagFromStack(outputs[0]), circuitRecipe.copy());
+ boolean newServer = checkAndDeleteCALRecipes();
+ GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.forEach(e -> CircuitImprintLoader.handleCircuitRecipeRebuilding(e, toRem, toAdd));
+ exchangeRecipesInList(toRem,toAdd,newServer);
+ makeCircuitImprintRecipes(newServer);
+ }
- if (circuitRecipe.mFluidInputs[0].isFluidEqual(Materials.SolderingAlloy.getMolten(0))) {
+ private static void handleCircuitRecipeRebuilding(GT_Recipe circuitRecipe, HashSet<GT_Recipe> toRem, HashSet<GT_Recipe> toAdd) {
+ ItemStack[] outputs = circuitRecipe.mOutputs;
+ String name = getTypeFromOreDict(outputs);
- GT_Recipe newRecipe = CircuitImprintLoader.reBuildRecipe(circuitRecipe);
+ if (name.contains("Circuit") || name.contains("circuit")) {
- if (newRecipe != null)
- BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).addRecipe(newRecipe);
+ CircuitImprintLoader.recipeTagMap.put(CircuitImprintLoader.getTagFromStack(outputs[0]), circuitRecipe.copy());
- if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) {
- toRem.add(circuitRecipe);
- toAdd.add(CircuitImprintLoader.makeMoreExpensive(circuitRecipe));
- }
+ if (circuitRecipe.mFluidInputs[0].isFluidEqual(Materials.SolderingAlloy.getMolten(0))) {
+ GT_Recipe newRecipe = CircuitImprintLoader.reBuildRecipe(circuitRecipe);
+ if (newRecipe != null)
+ BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).addRecipe(newRecipe);
+ addCutoffRecipeToSets(toRem,toAdd,circuitRecipe);
+ } else {
+ if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier))
+ toRem.add(circuitRecipe);
+ }
+ }
+ }
- } else {
+ private static String getTypeFromOreDict(ItemStack[] outputs) {
+ int[] oreIDS = OreDictionary.getOreIDs(outputs[0]);
- if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier))
- toRem.add(circuitRecipe);
+ if (oreIDS.length < 1)
+ return "";
- }
- }
- }
+ return OreDictionary.getOreName(oreIDS[0]);
+ }
+ private static void exchangeRecipesInList(HashSet<GT_Recipe> toRem, HashSet<GT_Recipe> toAdd, boolean newServer) {
if (!newServer) {
GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.addAll(toAdd);
GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.removeAll(toRem);
}
+ }
- makeCircuitImprintRecipes();
+ private static void addCutoffRecipeToSets(HashSet<GT_Recipe> toRem, HashSet<GT_Recipe> toAdd, GT_Recipe circuitRecipe) {
+ if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) {
+ toRem.add(circuitRecipe);
+ toAdd.add(CircuitImprintLoader.makeMoreExpensive(circuitRecipe));
+ }
}
@SuppressWarnings("deprecation")
- public static GT_Recipe makeMoreExpensive(GT_Recipe original){
+ public static GT_Recipe makeMoreExpensive(GT_Recipe original) {
GT_Recipe newRecipe = original.copy();
for (ItemStack is : newRecipe.mInputs){
int[] oreIDs = OreDictionary.getOreIDs(is);
@@ -165,51 +127,71 @@ public class CircuitImprintLoader {
return newRecipe;
}
- @SuppressWarnings("deprecation")
- public static GT_Recipe reBuildRecipe(GT_Recipe original){
- ItemStack out = original.copy().getOutput(0);
- out.stackSize *= 16;
- ItemStack[] in = new ItemStack[6];
- BiMap<ItemList, Short> inversed = CircuitImprintLoader.circuitIIconRefs.inverse();
- for (int i = 0; i < 6; i++) {
- try {
- for (ItemList il : inversed.keySet()){
- if (GT_Utility.areStacksEqual(il.get(1), original.mInputs[i])) {
- in[i] = BW_Meta_Items.getNEWCIRCUITS().getStack(inversed.get(il), original.mInputs[i].stackSize);
- }
+ public static GT_Recipe reBuildRecipe(GT_Recipe original) {
+ ItemStack[] in = new ItemStack[6];
+ BiMap<ItemList, Short> inversed = CircuitImprintLoader.circuitIIconRefs.inverse();
+
+ for (int i = 0; i < 6; i++) {
+ try {
+ replaceCircuits(inversed,original,in,i);
+ replaceComponents(in,original,i);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ break;
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ }
+ }
- }
- if (original.mInputs[i] != null && in[i] == null){
- if (BW_Util.checkStackAndPrefix(original.mInputs[i]) && GT_OreDictUnificator.getAssociation(original.mInputs[i]).mPrefix == OrePrefixes.wireGt01){
- in[i] = GT_OreDictUnificator.get(OrePrefixes.wireGt16,GT_OreDictUnificator.getAssociation(original.mInputs[i]).mMaterial.mMaterial,original.mInputs[i].stackSize);
- }
- else if (BW_Util.checkStackAndPrefix(original.mInputs[i]) && GT_OreDictUnificator.getAssociation(original.mInputs[i]).mPrefix == OrePrefixes.wireFine){
- in[i] = GT_OreDictUnificator.get(OrePrefixes.wireGt04,GT_OreDictUnificator.getAssociation(original.mInputs[i]).mMaterial.mMaterial,original.mInputs[i].stackSize);
- }
- else {
- in[i] = original.mInputs[i].copy();
- in[i].stackSize *= 16;
- if (in[i].stackSize > in[i].getItem().getItemStackLimit() || in[i].stackSize > in[i].getMaxStackSize())
- in[i].stackSize = in[i].getMaxStackSize();
- }
-// if (in[i].stackSize > 64)
-// return null;
- }
- } catch (ArrayIndexOutOfBoundsException e){
- break;
- } catch (NullPointerException e){
- e.printStackTrace();
- }
+ if (CircuitImprintLoader.checkForBlacklistedComponents(in)) {
+ return null;
}
- if (CircuitImprintLoader.checkForBlacklistedComponents(in)){
- 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);
+ }
+
+ private static ItemStack getOutputMultiplied(GT_Recipe original){
+ ItemStack out = original.copy().getOutput(0);
+ out.stackSize *= 16;
+ return out;
+ }
+
+ private static void replaceCircuits(BiMap<ItemList, Short> inversed, GT_Recipe original, ItemStack[] in, int index){
+ for (ItemList il : inversed.keySet()) {
+ if (GT_Utility.areStacksEqual(il.get(1), original.mInputs[index])) {
+ in[index] = BW_Meta_Items.getNEWCIRCUITS().getStack(inversed.get(il), original.mInputs[index].stackSize);
+ }
}
- return new BWRecipes.DynamicGTRecipe(false,in,new ItemStack[]{out},BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(CircuitImprintLoader.getTagFromStack(original.mOutputs[0]),0,0),null, original.mFluidInputs,null,original.mDuration * 16,original.mEUt,0);
}
- public static final HashSet<ItemStack> blacklistSet = new HashSet<>();
+ @SuppressWarnings("deprecation")
+ private static void replaceComponents(ItemStack[] in, GT_Recipe original, int index) throws ArrayIndexOutOfBoundsException {
+ if (original.mInputs[index] != null && in[index] == null) {
+ //big wires
+ if (BW_Util.checkStackAndPrefix(original.mInputs[index]) && GT_OreDictUnificator.getAssociation(original.mInputs[index]).mPrefix == OrePrefixes.wireGt01) {
+ in[index] = GT_OreDictUnificator.get(OrePrefixes.wireGt16, GT_OreDictUnificator.getAssociation(original.mInputs[index]).mMaterial.mMaterial, original.mInputs[index].stackSize);
+ //fine wires
+ } else if (BW_Util.checkStackAndPrefix(original.mInputs[index]) && GT_OreDictUnificator.getAssociation(original.mInputs[index]).mPrefix == OrePrefixes.wireFine) {
+ in[index] = GT_OreDictUnificator.get(OrePrefixes.wireGt04, GT_OreDictUnificator.getAssociation(original.mInputs[index]).mMaterial.mMaterial, original.mInputs[index].stackSize);
+ //other components