-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b120e1
commit c2b7bb5
Showing
4 changed files
with
38 additions
and
22 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
31 changes: 14 additions & 17 deletions
31
src/main/java/io/wispforest/owo/mixin/recipe_remainders/RecipeMixin.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 |
---|---|---|
@@ -1,36 +1,33 @@ | ||
package io.wispforest.owo.mixin.recipe_remainders; | ||
|
||
import io.wispforest.owo.util.RecipeRemainderStorage; | ||
import io.wispforest.owo.util.pond.MixinHooks; | ||
import net.minecraft.inventory.Inventory; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.recipe.Recipe; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.collection.DefaultedList; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
@Mixin(Recipe.class) | ||
public interface RecipeMixin<C extends Inventory> { | ||
@Inject(method = "getRemainder", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD) | ||
private void addRecipeSpecificRemainders(C inventory, CallbackInfoReturnable<DefaultedList<ItemStack>> cir, DefaultedList<ItemStack> remainders) { | ||
Identifier id = MixinHooks.RECIPE_ID.get(); | ||
if (id == null) return; | ||
|
||
// TODO: make work | ||
if (!RecipeRemainderStorage.has(id)) return; | ||
|
||
// @Shadow | ||
// Identifier getId(); | ||
// | ||
// @Inject(method = "getRemainder", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD) | ||
// private void addRecipeSpecificRemainders(C inventory, CallbackInfoReturnable<DefaultedList<ItemStack>> cir, DefaultedList<ItemStack> remainders) { | ||
// if (!RecipeRemainderStorage.has(this.getId())) return; | ||
// | ||
// var owoRemainders = RecipeRemainderStorage.get(this.getId()); | ||
// for (int i = 0; i < remainders.size(); ++i) { | ||
// var item = inventory.getStack(i).getItem(); | ||
// if (!owoRemainders.containsKey(item)) continue; | ||
// | ||
// remainders.set(i, owoRemainders.get(item).copy()); | ||
// } | ||
// } | ||
var owoRemainders = RecipeRemainderStorage.get(id); | ||
for (int i = 0; i < remainders.size(); ++i) { | ||
var item = inventory.getStack(i).getItem(); | ||
if (!owoRemainders.containsKey(item)) continue; | ||
|
||
remainders.set(i, owoRemainders.get(item).copy()); | ||
} | ||
} | ||
} |
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,7 @@ | ||
package io.wispforest.owo.util.pond; | ||
|
||
import net.minecraft.util.Identifier; | ||
|
||
public class MixinHooks { | ||
public static final ThreadLocal<Identifier> RECIPE_ID = new ThreadLocal<>(); | ||
} |