-
Notifications
You must be signed in to change notification settings - Fork 92
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
8aadb34
commit b8970fd
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/main/java/dev/latvian/mods/kubejs/core/mixin/TagEmptyConditionMixin.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,29 @@ | ||
package dev.latvian.mods.kubejs.core.mixin; | ||
|
||
import dev.latvian.mods.kubejs.recipe.RecipesKubeEvent; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.item.Item; | ||
import net.neoforged.neoforge.common.conditions.ICondition; | ||
import net.neoforged.neoforge.common.conditions.TagEmptyCondition; | ||
import org.spongepowered.asm.mixin.Final; | ||
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; | ||
|
||
@Mixin(value = TagEmptyCondition.class, remap = false) | ||
public abstract class TagEmptyConditionMixin { | ||
@Shadow | ||
@Final | ||
private TagKey<Item> tag; | ||
|
||
@Inject(method = "test", at = @At("HEAD"), cancellable = true, remap = false) | ||
private void kjs$test(ICondition.IContext ctx, CallbackInfoReturnable<Boolean> cir) { | ||
var lookup = RecipesKubeEvent.TEMP_ITEM_TAG_LOOKUP.getValue(); | ||
|
||
if (lookup != null) { | ||
cir.setReturnValue(lookup.values(tag).isEmpty()); | ||
} | ||
} | ||
} |
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