-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
persistEnchantedBooksOnly
config option
- Loading branch information
1 parent
a5155ab
commit ba55f9a
Showing
5 changed files
with
38 additions
and
8 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
21 changes: 21 additions & 0 deletions
21
src/main/java/cool/furry/mc/forge/projectexpansion/mixin/EnchantmentProcessorMixin.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,21 @@ | ||
package cool.furry.mc.forge.projectexpansion.mixin; | ||
|
||
import cool.furry.mc.forge.projectexpansion.config.Config; | ||
import moze_intel.projecte.api.ItemInfo; | ||
import moze_intel.projecte.emc.nbt.processor.EnchantmentProcessor; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.item.Items; | ||
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.CallbackInfoReturnable; | ||
|
||
@Mixin(EnchantmentProcessor.class) | ||
public class EnchantmentProcessorMixin { | ||
@Inject(at = @At("HEAD"), method = "getPersistentNBT(Lmoze_intel/projecte/api/ItemInfo;)Lnet/minecraft/nbt/CompoundTag;", cancellable = true, remap = false) | ||
public void getPersistentNBT(ItemInfo info, CallbackInfoReturnable<CompoundTag> cir) { | ||
if(Config.persistEnchantedBooksOnly.get() && info.getItem() != Items.ENCHANTED_BOOK) { | ||
cir.setReturnValue(null); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/cool/furry/mc/forge/projectexpansion/mixin/package-info.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,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package cool.furry.mc.forge.projectexpansion.mixin; | ||
|
||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
import javax.annotation.ParametersAreNonnullByDefault; |
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,19 +1,20 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "cool.furry.mc.forge.projectexpansion.mixin", | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "cool.furry.mc.forge.projectexpansion.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"refmap": "projectexpansion.refmap.json", | ||
"client": [ | ||
"refmap": "projectexpansion.refmap.json", | ||
"client": [ | ||
"DeleteWeebShitMixin", | ||
"EMCFormatterMixin" | ||
], | ||
"mixins": [ | ||
"mixins": [ | ||
"AlchemicalBagMixin", | ||
"EnchantmentMixin", | ||
"EnchantmentProcessorMixin", | ||
"PhilosophersStoneMixin" | ||
], | ||
"injectors": { | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |