Skip to content

Commit

Permalink
bring back disassembling crafting recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
Taskeren committed May 6, 2024
1 parent 411cec8 commit 8259610
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .idea/inspectionProfiles/GTNN_Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ReverseShapedRecipe(ItemStack output, Object[] aRecipe) {
public static void runReverseRecipes() {
for (ReverseShapedRecipe x : reverseRecipes) {
Optional<GT_Recipe> recipeOptional = GT_Utility.reverseShapedRecipe(x.aResult, x.aRecipe);
ReverseShapelessRecipe.registerRecipe(recipeOptional.orElse(null));
ReverseShapelessRecipe.registerReversedCraftingRecipe(recipeOptional.orElse(null));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package cn.taskeren.gtnn.mod.gt5u.recipe;

import cn.taskeren.gtnn.mod.gt5u.util.DisassemblerRecipeMapBackend;
import cn.taskeren.gtnn.mod.gt5u.util.NNRecipe;
import cn.taskeren.gtnn.mod.gt5u.util.DisassemblerRecipeHelper;
import cn.taskeren.gtnn.mod.gt5u.util.DisassemblerRecipes;
import gregtech.api.enums.GT_Values;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.LinkedList;
Expand All @@ -28,22 +30,35 @@ public ReverseShapelessRecipe(ItemStack output, Object[] aRecipe) {
}

public static void runReverseRecipes() {
for (ReverseShapelessRecipe x : reverseRecipes) {
for(ReverseShapelessRecipe x : reverseRecipes) {
Optional<GT_Recipe> recipeOptional = GT_Utility.reverseShapelessRecipe(x.aResult, x.aRecipe);
registerRecipe(recipeOptional.orElse(null));
registerReversedCraftingRecipe(recipeOptional.orElse(null));
}
}

public static void registerRecipe(GT_Recipe recipe) {
if (recipe == null) return;
ItemStack[] replacement = new ItemStack[recipe.mOutputs.length];
DisassemblerRecipeMapBackend.handleRecipeTransformation(
recipe.mOutputs,
replacement,
Collections.singleton(recipe.mOutputs));
/**
* Register a reversed recipe.
* <p>
* This function handles both Shaped and Shapeless Recipes.
* <p>
* Note: the param itself should have been reversed once, DON'T reverse it again!
*
* @param revRecipe the REVERSED recipe.
*/
public static void registerReversedCraftingRecipe(@Nullable GT_Recipe revRecipe) {
if(revRecipe == null) return;

recipe.mOutputs = replacement;
NNRecipe.Disassembler.getTheCraftingTableReversedRecipeMap().add(recipe);
GT_Values.RA.stdBuilder()
.itemInputs(revRecipe.mInputs)
.itemOutputs(
DisassemblerRecipeHelper.handleRecipeTransformation(
revRecipe.mOutputs,
Collections.singleton(revRecipe.mOutputs)
)
)
.duration(300)
.eut(30)
.addTo(DisassemblerRecipes.DISASSEMBLER_RECIPES);
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package cn.taskeren.gtnn.mod.gt5u.tile;

import cn.taskeren.gtnn.GTNN;
import cn.taskeren.gtnn.mod.gt5u.util.DisassemblerRecipes;
import gregtech.api.enums.SoundResource;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_GT_Recipe;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

import java.util.ArrayList;
import java.util.List;

public class TileEntityDisassembler extends GT_MetaTileEntity_BasicMachine_GT_Recipe {
Expand Down Expand Up @@ -33,4 +37,11 @@ public void addAdditionalTooltipInformation(ItemStack stack, List<String> toolti
tooltip.add("§cPresented by GTNH-NO-NERF!");
}

@Override
public ArrayList<String> getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) {
// TODO: REMOVE
getBaseMetaTileEntity().increaseStoredEnergyUnits(10_000_000, true);
GTNN.logger.info("Currently stored Energy: %d", getBaseMetaTileEntity().getStoredEU());
return super.getSpecialDebugInfo(aBaseMetaTileEntity, aPlayer, aLogLevel, aList);
}
}
Loading

0 comments on commit 8259610

Please sign in to comment.