Skip to content

Commit

Permalink
Add enchantments to creative inventory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Provismet committed Jun 21, 2024
1 parent fb3d5e3 commit fc7401b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ sourceSets {
}

loom {
accessWidenerPath = file("src/main/resources/additional-armoury.accesswidener")
runs {
// This adds a new gradle task that runs the datagen API: "gradlew runDatagen"
datagen {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ yarn_mappings=1.20.6+build.1
loader_version=0.15.11

# Mod Properties
mod_version=1.0.3
mod_version=1.0.4
maven_group=com.provismet
archives_base_name=additional-armoury
modid=additional-armoury

#Fabric api
fabric_version=0.98.0+1.20.6
combatplus_version=2.0.0-mc1.20.6
combatplus_version=2.0.1-mc1.20.6
lilylib_version=1.1.3-mc1.20.6
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.provismet.AdditionalArmoury.items.DaggerItem;
import com.provismet.AdditionalArmoury.items.MaceItem;

import com.provismet.AdditionalArmoury.utility.AATags;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.component.type.PotionContentsComponent;
import net.minecraft.item.ArmorItem;
Expand All @@ -15,8 +16,11 @@
import net.minecraft.potion.Potion;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.resource.featuretoggle.FeatureSet;

import java.util.Set;

public class AAItemGroups {

public static void register () {
Expand Down Expand Up @@ -56,6 +60,14 @@ public static void register () {
AAItems.DAGGERS.forEach(dagger -> addPotions(content, wrapper, dagger, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS, content.getEnabledFeatures()));
});
});

Set<TagKey<Item>> itemTags = Set.of(AATags.ItemTags.DAGGER_ENCHANTABLE, AATags.ItemTags.MACE_ENCHANTABLE, AATags.ItemTags.BOOMERANG_ENCHANTABLE, AATags.ItemTags.STAFF_ENCHANTABLE);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register(content -> {
content.getContext().lookup().getOptionalWrapper(RegistryKeys.ENCHANTMENT).ifPresent(registryWrapper -> {
ItemGroups.addMaxLevelEnchantedBooks(content, registryWrapper, itemTags, ItemGroup.StackVisibility.PARENT_TAB_ONLY, content.getContext().enabledFeatures());
ItemGroups.addAllLevelEnchantedBooks(content, registryWrapper, itemTags, ItemGroup.StackVisibility.SEARCH_TAB_ONLY, content.getContext().enabledFeatures());
});
});
}

private static void addPotions (ItemGroup.Entries entries, RegistryWrapper<Potion> registryWrapper, Item item, ItemGroup.StackVisibility visibility, FeatureSet enabledFeatures) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/additional-armoury.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessWidener v2 named

accessible method net/minecraft/item/ItemGroups addMaxLevelEnchantedBooks (Lnet/minecraft/item/ItemGroup$Entries;Lnet/minecraft/registry/RegistryWrapper;Ljava/util/Set;Lnet/minecraft/item/ItemGroup$StackVisibility;Lnet/minecraft/resource/featuretoggle/FeatureSet;)V
accessible method net/minecraft/item/ItemGroups addAllLevelEnchantedBooks (Lnet/minecraft/item/ItemGroup$Entries;Lnet/minecraft/registry/RegistryWrapper;Ljava/util/Set;Lnet/minecraft/item/ItemGroup$StackVisibility;Lnet/minecraft/resource/featuretoggle/FeatureSet;)V
1 change: 1 addition & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"mixins": [
"additional-armoury.mixins.json"
],
"accessWidener": "additional-armoury.accesswidener",
"depends": {
"fabricloader": ">=0.15.0",
"minecraft": "~1.20.5",
Expand Down

0 comments on commit fc7401b

Please sign in to comment.