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

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
+ reworked LuVTierEnhancer
+ use of isAir() instead of block.equals(air) in base layer check method

Signed-off-by: bartimaeusnek <[email protected]>
  • Loading branch information
bartimaeusnek committed Jan 16, 2020
1 parent 125b963 commit 583bb0a
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package com.github.bartimaeusnek.bartworks.system.material.GT_Enhancement;

import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader;
import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.AfterLuVTierEnhacement;
import com.github.bartimaeusnek.bartworks.util.BW_Util;
Expand All @@ -41,89 +42,138 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Predicate;

import static gregtech.api.enums.OrePrefixes.*;

@SuppressWarnings("ALL")
public class LuVTierEnhancer implements Runnable {

public void run() {
LuVTierEnhancer.replaceAsslineRecipes();

List<IRecipe> bufferedRecipeList = null;

try {
bufferedRecipeList = (List<IRecipe>) FieldUtils.getDeclaredField(GT_ModHandler.class, "sBufferRecipeList", true).get(null);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
assert bufferedRecipeList != null;

HashSet<ItemStack> LuVMachines = new HashSet<>();
LuVMachines.add(ItemRegistry.cal);
OrePrefixes[] LuVMaterialsGenerated = {dust, ingot, plate, stick, stickLong, rotor, plateDouble, plateDense};
for (ItemList item : ItemList.values()) {
if (item.toString().contains("LuV") && item.hasBeenSet())
LuVMachines.add(item.get(1));
}

Arrays.stream(ItemList.values())
.filter(item -> item.toString().contains("LuV") && item.hasBeenSet())
.forEach(item -> LuVMachines.add(item.get(1)));

if (Loader.isModLoaded("dreamcraft")) {
try {
Class customItemListClass = Class.forName("com.dreammaster.gthandler.CustomItemList");
Method hasnotBeenSet = MethodUtils.getAccessibleMethod(customItemListClass, "hasBeenSet");
Method get = MethodUtils.getAccessibleMethod(customItemListClass, "get", long.class, Object[].class);
for (Enum customItemList : (Enum[]) FieldUtils.getField(customItemListClass, "$VALUES", true).get(null)) {
if (customItemList.toString().contains("LuV") && (boolean) hasnotBeenSet.invoke(customItemList))
LuVMachines.add((ItemStack) get.invoke(customItemList, 1, new Object[0]));
}
} catch (IllegalAccessException | ClassNotFoundException | InvocationTargetException e) {
e.printStackTrace();
}
addDreamcraftItemListItems(LuVMachines);
}
GT_ModHandler.addCraftingRecipe(ItemList.Casing_LuV.get(1), GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_RECIPES, new Object[]{"PPP", "PwP", "PPP", 'P', WerkstoffLoader.LuVTierMaterial.get(plate)});
for (ItemStack stack : LuVMachines) {
for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) {
for (GT_Recipe recipe : map.mRecipeList) {
for (OrePrefixes prefixes : LuVMaterialsGenerated) {
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mOutputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
}
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mOutputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mOutputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
}
}
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidInputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidOutputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
}
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mOutputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidInputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidOutputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
}

GT_ModHandler.addCraftingRecipe(ItemList.Casing_LuV.get(1),
GT_ModHandler.RecipeBits.BUFFERED |
GT_ModHandler.RecipeBits.REVERSIBLE |
GT_ModHandler.RecipeBits.NOT_REMOVABLE |
GT_ModHandler.RecipeBits.DELETE_ALL_OTHER_RECIPES,
new Object[]{
"PPP",
"PwP",
"PPP",
'P', WerkstoffLoader.LuVTierMaterial.get(plate)
});

replaceAllRecipes(LuVMachines,LuVMaterialsGenerated,bufferedRecipeList);

AfterLuVTierEnhacement.run();
}

private static void replaceAllRecipes(Collection<ItemStack> LuVMachines, OrePrefixes[] LuVMaterialsGenerated, List<IRecipe> bufferedRecipeList){
LuVTierEnhancer.replaceOsmiridiumInLuVRecipes();
LuVMachines.stream().forEach(stack -> {

Predicate recipeFilter = obj -> obj instanceof GT_Shaped_Recipe && GT_Utility.areStacksEqual(((GT_Shaped_Recipe) obj).getRecipeOutput(), stack, true);

GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.forEach(
recipe -> rewriteAsslineRecipes(stack, LuVMaterialsGenerated, recipe));

GT_Recipe.GT_Recipe_Map.sMappings.forEach(
map -> map.mRecipeList.forEach(
recipe -> rewriteMachineRecipes(stack, LuVMaterialsGenerated, recipe)));

rewriteCraftingRecipes(bufferedRecipeList, LuVMaterialsGenerated, recipeFilter);
}
);
}

private static void addDreamcraftItemListItems(Collection LuVMachines){
try {
Class customItemListClass = Class.forName("com.dreammaster.gthandler.CustomItemList");
Method hasnotBeenSet = MethodUtils.getAccessibleMethod(customItemListClass, "hasBeenSet");
Method get = MethodUtils.getAccessibleMethod(customItemListClass, "get", long.class, Object[].class);
for (Enum customItemList : (Enum[]) FieldUtils.getField(customItemListClass, "$VALUES", true).get(null)) {
if (customItemList.toString().contains("LuV") && (boolean) hasnotBeenSet.invoke(customItemList))
LuVMachines.add((ItemStack) get.invoke(customItemList, 1, new Object[0]));
}
} catch (IllegalAccessException | ClassNotFoundException | InvocationTargetException e) {
e.printStackTrace();
}
}

private static void rewriteCraftingRecipes(List<IRecipe> bufferedRecipeList, OrePrefixes[] LuVMaterialsGenerated, Predicate recipeFilter){
for (OrePrefixes prefixes : LuVMaterialsGenerated) {

Consumer recipeAction = obj -> LuVTierEnhancer.doStacksCointainAndReplace(((GT_Shaped_Recipe) obj).getInput(),
GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true,
WerkstoffLoader.LuVTierMaterial.get(prefixes));

CraftingManager.getInstance().getRecipeList().stream().filter(recipeFilter).forEach(recipeAction);
bufferedRecipeList.stream().filter(recipeFilter).forEach(recipeAction);
}
}

private static void rewriteMachineRecipes(ItemStack stack, OrePrefixes[] LuVMaterialsGenerated, GT_Recipe recipe){
for (OrePrefixes prefixes : LuVMaterialsGenerated) {
for (Object obj : CraftingManager.getInstance().getRecipeList()) {
if (!(obj instanceof GT_Shaped_Recipe))
continue;
if (GT_Utility.areStacksEqual(((GT_Shaped_Recipe) obj).getRecipeOutput(), stack, true)) {
LuVTierEnhancer.doStacksCointainAndReplace(((GT_Shaped_Recipe) obj).getInput(), GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
}
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mOutputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
}
for (Object obj : bufferedRecipeList) {
if (!(obj instanceof GT_Shaped_Recipe))
continue;
if (GT_Utility.areStacksEqual(((GT_Shaped_Recipe) obj).getRecipeOutput(), stack, true)) {
LuVTierEnhancer.doStacksCointainAndReplace(((GT_Shaped_Recipe) obj).getInput(), GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
}
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mOutputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mOutputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
}
}
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidInputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidOutputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
}
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mOutputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidInputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidOutputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
}
}
private static void rewriteAsslineRecipes(ItemStack stack, OrePrefixes[] LuVMaterialsGenerated, GT_Recipe.GT_Recipe_AssemblyLine recipe){
for (OrePrefixes prefixes : LuVMaterialsGenerated) {
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
LuVTierEnhancer.doStacksCointainAndReplace(new Object[]{recipe.mOutput}, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
}
if (LuVTierEnhancer.doStacksCointainAndReplace(new Object[]{recipe.mOutput}, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
LuVTierEnhancer.doStacksCointainAndReplace(new Object[]{recipe.mOutput}, GT_OreDictUnificator.get(prefixes, Materials.Chrome, 1), true, WerkstoffLoader.LuVTierMaterial.get(prefixes));
}
}
if (LuVTierEnhancer.doStacksCointainAndReplace(recipe.mInputs, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidInputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
}
if (LuVTierEnhancer.doStacksCointainAndReplace(new Object[]{recipe.mOutput}, stack, false)) {
LuVTierEnhancer.doStacksCointainAndReplace(recipe.mFluidInputs, Materials.Chrome.getMolten(1), true, WerkstoffLoader.LuVTierMaterial.getMolten(1).getFluid());
}
new AfterLuVTierEnhacement().run();
}

private static void replaceAsslineRecipes(){
private static void replaceOsmiridiumInLuVRecipes(){
for (GT_Recipe.GT_Recipe_AssemblyLine recipe_assemblyLine : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes){
if (recipe_assemblyLine.mEUt > 6000)
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
import static gregtech.api.enums.OrePrefixes.dust;
import static gregtech.api.enums.OrePrefixes.dustSmall;

public class AfterLuVTierEnhacement implements Runnable {
public class AfterLuVTierEnhacement {

private AfterLuVTierEnhacement(){};

public static void run() {

@Override
public void run() {
GT_Values.RA.addCentrifugeRecipe(BW_NonMeta_MaterialItems.Depleted_Tiberium_1.get(1), null,null,WerkstoffLoader.Xenon.getFluidOrGas(1),
WerkstoffLoader.Zirconium.get(dust),
WerkstoffLoader.Zirconium.get(dust),
Expand All @@ -44,6 +46,7 @@ public void run() {
GT_OreDictUnificator.get(dust, Materials.TungstenSteel, 8L),
GT_OreDictUnificator.get(dust, Materials.Platinum, 1L),
new int[]{10_000,5_000,5_000,2_500,10_000,10_000},250,2000);

GT_Values.RA.addCentrifugeRecipe(BW_NonMeta_MaterialItems.Depleted_Tiberium_2.get(1), null,null,WerkstoffLoader.Xenon.getFluidOrGas(2),
WerkstoffLoader.Zirconium.get(dust,2),
WerkstoffLoader.Zirconium.get(dust,2),
Expand All @@ -52,6 +55,7 @@ public void run() {
GT_OreDictUnificator.get(dust, Materials.TungstenSteel, 18L),
GT_OreDictUnificator.get(dust, Materials.Platinum, 2L),
new int[]{10_000,5_000,5_000,2_500,10_000,10_000},500,2000);

GT_Values.RA.addCentrifugeRecipe(BW_NonMeta_MaterialItems.Depleted_Tiberium_4.get(1), null,null,WerkstoffLoader.Xenon.getFluidOrGas(4),
WerkstoffLoader.Zirconium.get(dust,4),
WerkstoffLoader.Zirconium.get(dust,4),
Expand All @@ -60,6 +64,7 @@ public void run() {
GT_OreDictUnificator.get(dust, Materials.TungstenSteel, 38L),
GT_OreDictUnificator.get(dust, Materials.Platinum, 4L),
new int[]{10_000,5_000,5_000,2_500,10_000,10_000},1000,2000);

GT_Values.RA.addCentrifugeRecipe(BW_NonMeta_MaterialItems.Depleted_TheCoreCell.get(1), null,null,null,
ItemList.Depleted_Naquadah_4.get(8),
WerkstoffLoader.Zirconium.get(dust,64),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int r
continue;
boolean b = Math.abs(x) < radius && Math.abs(z) != radius;
if (insideCheck && b) {
if (!aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(inside) && (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) != dmginside || dmginside > (-1))) {
if (! (inside.equals(Blocks.air) ? aBaseMetaTileEntity.getAir(xDir + x, y, zDir + z) : aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(inside) ) && (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) != dmginside || dmginside > (-1))) {
if (!(allowHatches && (
((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addDynamoToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), aBaseCasingIndex) ||
((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addEnergyInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), aBaseCasingIndex) ||
Expand Down

0 comments on commit 583bb0a

Please sign in to comment.