generated from jaredlll08/MultiLoader-Template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate items on init (should handle things such as containers, etc.)
- Loading branch information
1 parent
c867d17
commit 4baa2fb
Showing
8 changed files
with
131 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
## Changes | ||
- Any Enchanted Books that have no enchantments as a result of this mod will now turn into regular Books. | ||
|
||
## Bugfixes | ||
- [FABRIC] Fixed crash involving platform helper being loaded at the wrong time. | ||
- Fixed setting enchantments operating on an immutable map. | ||
- Caught more edge cases where a disabled enchantment can slip through when playing with the mod serverside. | ||
- Caught more edge cases where a disabled enchantment can be obtained from containers when playing with the mod serverside. | ||
|
||
## Internal | ||
- Moved EnchantmentDisableTag#DISABLED_ENCHANTMENT_TAG field to EnchantmentDisabledTags#DISABLED. | ||
- Moved EnchantmentDisableTag#DISABLED_ENCHANTMENT_TAG field to EnchantmentDisabledTags#DISABLED. | ||
- This was unfortunately a required change to fix Fabric platform helper. |
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
32 changes: 32 additions & 0 deletions
32
...c/src/main/java/dev/greenhouseteam/enchantmentdisabletag/mixin/fabric/ItemStackMixin.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,32 @@ | ||
package dev.greenhouseteam.enchantmentdisabletag.mixin.fabric; | ||
|
||
import dev.greenhouseteam.enchantmentdisabletag.EnchantmentDisableTag; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
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.CallbackInfo; | ||
|
||
@Mixin(ItemStack.class) | ||
public class ItemStackMixin { | ||
@Shadow | ||
@Nullable | ||
private CompoundTag tag; | ||
|
||
@Mutable @Shadow @Final @Deprecated @Nullable | ||
private Item item; | ||
|
||
@Inject(method = "<init>(Lnet/minecraft/nbt/CompoundTag;)V", at = @At(value = "TAIL")) | ||
private void enchantmentdisabletag$verifyEnchantmentTagsFromInit(CompoundTag compoundTag, CallbackInfo ci) { | ||
if (this.tag != null && EnchantmentDisableTag.removeDisabledEnchantments(this.tag) && item == Items.ENCHANTED_BOOK) { | ||
this.item = Items.BOOK; | ||
} | ||
} | ||
} |
29 changes: 15 additions & 14 deletions
29
fabric/src/main/resources/enchantmentdisabletag.fabric.mixins.json
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,16 +1,17 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "dev.greenhouseteam.enchantmentdisabletag.mixin.fabric", | ||
"refmap": "${mod_id}.refmap.json", | ||
"compatibilityLevel": "JAVA_17", | ||
"client": [ | ||
"client.ClientPacketListenerMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
}, | ||
"mixins": [ | ||
"ReloadableServerResourcesMixin" | ||
] | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "dev.greenhouseteam.enchantmentdisabletag.mixin.fabric", | ||
"refmap": "${mod_id}.refmap.json", | ||
"compatibilityLevel": "JAVA_17", | ||
"client": [ | ||
"client.ClientPacketListenerMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
}, | ||
"mixins": [ | ||
"ItemStackMixin", | ||
"ReloadableServerResourcesMixin" | ||
] | ||
} |
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
41 changes: 41 additions & 0 deletions
41
forge/src/main/java/dev/greenhouseteam/enchantmentdisabletag/mixin/forge/ItemStackMixin.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,41 @@ | ||
package dev.greenhouseteam.enchantmentdisabletag.mixin.forge; | ||
|
||
import dev.greenhouseteam.enchantmentdisabletag.EnchantmentDisableTag; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
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.CallbackInfo; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
@Mixin(ItemStack.class) | ||
public class ItemStackMixin { | ||
@Shadow | ||
@Nullable | ||
private CompoundTag tag; | ||
|
||
@Mutable | ||
@Shadow @Final @Deprecated @Nullable | ||
private Item item; | ||
|
||
@Mutable | ||
@Shadow(remap = false) @Final @org.jetbrains.annotations.Nullable | ||
private Holder.@org.jetbrains.annotations.Nullable Reference<Item> delegate; | ||
|
||
@Inject(method = "forgeInit", at = @At(value = "HEAD"), remap = false) | ||
private void enchantmentdisabletag$verifyEnchantmentTagsFromInit(CallbackInfo ci) { | ||
if (this.tag != null && EnchantmentDisableTag.removeDisabledEnchantments(this.tag) && item == Items.ENCHANTED_BOOK) { | ||
this.item = Items.BOOK; | ||
this.delegate = ForgeRegistries.ITEMS.getDelegateOrThrow(Items.BOOK); | ||
} | ||
} | ||
} |
23 changes: 12 additions & 11 deletions
23
forge/src/main/resources/enchantmentdisabletag.forge.mixins.json
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,15 +1,16 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "dev.greenhouseteam.enchantmentdisabletag.mixin", | ||
"refmap": "${mod_id}.refmap.json", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"forge.CreativeModeTabMixin", | ||
"forge.ForgeRegistryMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "dev.greenhouseteam.enchantmentdisabletag.mixin", | ||
"refmap": "${mod_id}.refmap.json", | ||
"compatibilityLevel": "JAVA_17", | ||
"mixins": [ | ||
"forge.CreativeModeTabMixin", | ||
"forge.ForgeRegistryMixin", | ||
"forge.ItemStackMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} | ||
|
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,5 +1,5 @@ | ||
# Project | ||
mod_version=1.0.3 | ||
mod_version=1.1.0 | ||
group=dev.greenhouseteam | ||
|
||
# Common | ||
|