-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NBT Condition and From Recipe Recycling Helpers
- Loading branch information
1 parent
28838e4
commit f23e149
Showing
8 changed files
with
222 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/nomiceu/nomilabs/mixin/gregtech/RecyclingRecipesMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.nomiceu.nomilabs.mixin.gregtech; | ||
|
||
import static com.nomiceu.nomilabs.groovy.LabsVirtualizedRegistries.REPLACE_RECYCLING_MANAGER; | ||
|
||
import net.minecraft.item.ItemStack; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import com.nomiceu.nomilabs.util.ItemMeta; | ||
|
||
import gregtech.api.recipes.RecipeBuilder; | ||
import gregtech.api.recipes.ingredients.GTRecipeItemInput; | ||
import gregtech.loaders.recipe.RecyclingRecipes; | ||
|
||
/** | ||
* This mixin allows us to define custom NBT handling in recycling. | ||
*/ | ||
@Mixin(value = RecyclingRecipes.class, remap = false) | ||
public class RecyclingRecipesMixin { | ||
|
||
@Inject(method = "cleanInputNBT", at = @At("HEAD")) | ||
private static void handleCustomNBT(ItemStack input, RecipeBuilder<?> builder, CallbackInfo ci) { | ||
// Only initiate custom handling if we have nbt conditions | ||
if (REPLACE_RECYCLING_MANAGER.nbtConditions == null || REPLACE_RECYCLING_MANAGER.nbtConditions.isEmpty()) | ||
return; | ||
|
||
var handling = REPLACE_RECYCLING_MANAGER.nbtConditions.get(new ItemMeta(input)); | ||
if (handling == null) return; | ||
|
||
builder.clearInputs(); | ||
builder.inputNBT(new GTRecipeItemInput(input), handling.getLeft(), handling.getRight()); | ||
} | ||
} |
Oops, something went wrong.