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.
- Loading branch information
1 parent
8f4557d
commit 142c4f9
Showing
15 changed files
with
182 additions
and
64 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 +1,11 @@ | ||
- Allowed creative mode tab code to reload on the server. | ||
## Changes | ||
- Any Enchanted Books that have no enchantments as a result of this mod will now turn into regular Books. | ||
|
||
## Bugfixes | ||
- Caught more edge cases where a disabled enchantment can be obtained from containers when playing with the mod serverside. | ||
- Fixed /enchant and the enchanting table not functioning. | ||
- Fixed items stacking incorrectly when moved to different inventories. | ||
|
||
## Internal | ||
- Moved EnchantmentDisableTag#DISABLED_ENCHANTMENT_TAG field to EnchantmentDisabledTags#DISABLED. | ||
- This was done to match the 1.20.1 version. |
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
9 changes: 9 additions & 0 deletions
9
common/src/main/java/dev/greenhouseteam/enchantmentdisabletag/EnchantmentDisableTags.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,9 @@ | ||
package dev.greenhouseteam.enchantmentdisabletag; | ||
|
||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.item.enchantment.Enchantment; | ||
|
||
public class EnchantmentDisableTags { | ||
public static final TagKey<Enchantment> DISABLED = TagKey.create(Registries.ENCHANTMENT, EnchantmentDisableTag.asResource("disabled")); | ||
} |
16 changes: 16 additions & 0 deletions
16
.../main/java/dev/greenhouseteam/enchantmentdisabletag/mixin/AbstractContainerMenuMixin.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,16 @@ | ||
package dev.greenhouseteam.enchantmentdisabletag.mixin; | ||
|
||
import dev.greenhouseteam.enchantmentdisabletag.EnchantmentDisableTag; | ||
import net.minecraft.world.inventory.AbstractContainerMenu; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
|
||
@Mixin(AbstractContainerMenu.class) | ||
public class AbstractContainerMenuMixin { | ||
@ModifyVariable(method = "setCarried", at = @At("HEAD"), argsOnly = true) | ||
private ItemStack enchantmentdisabletag$removeFromCarried(ItemStack stack) { | ||
return EnchantmentDisableTag.removeDisabledEnchantments(stack); | ||
} | ||
} |
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
60 changes: 60 additions & 0 deletions
60
common/src/main/java/dev/greenhouseteam/enchantmentdisabletag/mixin/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,60 @@ | ||
package dev.greenhouseteam.enchantmentdisabletag.mixin; | ||
|
||
import dev.greenhouseteam.enchantmentdisabletag.EnchantmentDisableTag; | ||
import net.minecraft.core.component.DataComponentMap; | ||
import net.minecraft.core.component.DataComponentPatch; | ||
import net.minecraft.core.component.PatchedDataComponentMap; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.level.ItemLike; | ||
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 abstract class ItemStackMixin { | ||
@Mutable | ||
@Shadow @Final @Deprecated @Nullable | ||
private Item item; | ||
|
||
@Shadow public abstract boolean is(Item item); | ||
|
||
@Mutable | ||
@Shadow @Final private PatchedDataComponentMap components; | ||
|
||
@Inject(method = "<init>(Lnet/minecraft/world/level/ItemLike;ILnet/minecraft/core/component/PatchedDataComponentMap;)V", at = @At("TAIL")) | ||
private void enchantmentdisabletag$unenchantBookIfDisabledInit(ItemLike item, int count, PatchedDataComponentMap map, CallbackInfo ci) { | ||
if (EnchantmentDisableTag.shouldSetToBookAndResetState() && this.is(Items.ENCHANTED_BOOK)) { | ||
this.item = Items.BOOK; | ||
var components = new PatchedDataComponentMap(item.asItem().components()); | ||
components.applyPatch(map.asPatch()); | ||
this.components = components; | ||
} | ||
} | ||
|
||
@Inject(method = "applyComponentsAndValidate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;validateStrict(Lnet/minecraft/world/item/ItemStack;)Lcom/mojang/serialization/DataResult;")) | ||
private void enchantmentdisabletag$unenchantBookIfAllDisabledAndValidate(DataComponentPatch patch, CallbackInfo ci) { | ||
if (EnchantmentDisableTag.shouldSetToBookAndResetState() && this.is(Items.ENCHANTED_BOOK)) { | ||
this.item = Items.BOOK; | ||
var components = new PatchedDataComponentMap(item.components()); | ||
components.applyPatch(this.components.asPatch()); | ||
this.components = components; | ||
} | ||
} | ||
|
||
@Inject(method = "applyComponents(Lnet/minecraft/core/component/DataComponentPatch;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/Item;verifyComponentsAfterLoad(Lnet/minecraft/world/item/ItemStack;)V")) | ||
private void enchantmentdisabletag$unenchantBookIfAllDisabled(DataComponentPatch patch, CallbackInfo ci) { | ||
if (EnchantmentDisableTag.shouldSetToBookAndResetState() && this.is(Items.ENCHANTED_BOOK)) { | ||
this.item = Items.BOOK; | ||
var components = new PatchedDataComponentMap(item.components()); | ||
components.applyPatch(this.components.asPatch()); | ||
this.components = components; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.