From a98760f350d0162b7f7fa578cbe073582cdc4237 Mon Sep 17 00:00:00 2001 From: TheClashFruit Date: Sat, 13 Jul 2024 15:49:33 +0200 Subject: [PATCH] feat: finish multi version except 1.20.5 --- build.gradle.kts | 18 ++- changelogs/2.0.0-rc.1.md | 12 ++ changelogs/2.0.0.md | 6 - gradle.properties | 2 +- root.gradle.kts | 39 ++---- settings.gradle.kts | 16 +-- .../cc/mixin/ItemGroupsInterfaceMixin.java | 40 +++++- .../cc/mixin/ItemGroupsMixin.java | 130 ++++++++++++++---- versions/mainProject | 2 +- 9 files changed, 188 insertions(+), 77 deletions(-) create mode 100644 changelogs/2.0.0-rc.1.md delete mode 100644 changelogs/2.0.0.md diff --git a/build.gradle.kts b/build.gradle.kts index 00090f7..5580086 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ -import dev.deftu.gradle.utils.ModLoader +import dev.deftu.gradle.utils.* import dev.deftu.gradle.tools.minecraft.CurseRelation import dev.deftu.gradle.tools.minecraft.CurseRelationType @@ -32,6 +32,22 @@ loom { accessWidenerPath = file("../../src/main/resources/cc.accesswidener") } +java { + base.archivesName.set(modData.id) + + tasks { + if (isLoomPresent()) { + named("remapJar") { + archiveBaseName.set(modData.id) + } + } else { + named("jar") { + archiveBaseName.set(modData.id) + } + } + } +} + /* minecraft { accessTransformer = file("../../src/main/resources/META-INF/accesstransformer.cfg") diff --git a/changelogs/2.0.0-rc.1.md b/changelogs/2.0.0-rc.1.md new file mode 100644 index 0000000..18c64da --- /dev/null +++ b/changelogs/2.0.0-rc.1.md @@ -0,0 +1,12 @@ +The mod has been revived from the dead! + +### New + +* 1.21 Support + * !! Enchantment books are missing from the tools tab. + +### Fixes +1. Added Missing Items + * Pottery Sherds + * Smithing Templates +2. Fixed The Brewing Tab Icon \ No newline at end of file diff --git a/changelogs/2.0.0.md b/changelogs/2.0.0.md deleted file mode 100644 index 0386104..0000000 --- a/changelogs/2.0.0.md +++ /dev/null @@ -1,6 +0,0 @@ -The mod has been revived from the dead! - -* Added Missing Items - * Pottery Sherds - * Smithing Templates -* Fixed The Brewing Tab Icon \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7552ec7..cbe881c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,5 +3,5 @@ org.gradle.jvmargs=-Xmx2G mod.name=Cluttered Creative mod.id=cc -mod.version=2.0.0 +mod.version=2.0.0-rc.1 mod.group=me.theclashfruit \ No newline at end of file diff --git a/root.gradle.kts b/root.gradle.kts index 1cfcf28..6d68642 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -3,36 +3,21 @@ plugins { } preprocess { - //val neoforge_1_21 = createNode("1.21-neoforge", 1210, "srg") - //val fabric_1_21 = createNode("1.21-fabric", 1210, "yarn") - - //val neoforge_1_20_5 = createNode("1.20.5-neoforge", 1205, "srg") + val fabric_1_21 = createNode("1.21-fabric", 1210, "yarn") + val fabric_1_20_6 = createNode("1.20.6-fabric", 1206, "yarn") val fabric_1_20_5 = createNode("1.20.5-fabric", 1205, "yarn") - - //val forge_1_20_3 = createNode("1.20.3-forge", 1203, "srg") - //val neoforge_1_20_3 = createNode("1.20.3-neoforge", 1203, "srg") + val fabric_1_20_4 = createNode("1.20.4-fabric", 1204, "yarn") val fabric_1_20_3 = createNode("1.20.3-fabric", 1203, "yarn") - - //val forge_1_20_2 = createNode("1.20.2-forge", 1202, "srg") - //val neoforge_1_20_2 = createNode("1.20.2-neoforge", 1202, "srg") val fabric_1_20_2 = createNode("1.20.2-fabric", 1202, "yarn") + val fabric_1_20_1 = createNode("1.20.1-fabric", 1201, "yarn") + val fabric_1_20 = createNode("1.20-fabric", 1200, "yarn") - // val forge_1_20 = createNode("1.20-forge", 1200, "srg") - val fabric_1_20 = createNode("1.20-fabric", 1200, "yarn") - - //fabric_1_21.link(neoforge_1_21) - //fabric_1_21.link(fabric_1_20_3) - - //fabric_1_20_5.link(neoforge_1_20_5) - fabric_1_20_5.link(fabric_1_20_3) - - //forge_1_20_3.link(fabric_1_20_3) - //neoforge_1_20_3.link(fabric_1_20_3) + fabric_1_21.link(fabric_1_20_6) + //fabric_1_20_6.link(fabric_1_20_5) + fabric_1_20_6.link(fabric_1_20_4) + //fabric_1_20_5.link(fabric_1_20_4) + fabric_1_20_4.link(fabric_1_20_3) fabric_1_20_3.link(fabric_1_20_2) - - //forge_1_20_2.link(fabric_1_20_2) //file("versions/forge.txt") - //neoforge_1_20_2.link(fabric_1_20_2) - fabric_1_20_2.link(fabric_1_20) - - // forge_1_20.link(fabric_1_20) + fabric_1_20_2.link(fabric_1_20_1) + fabric_1_20_1.link(fabric_1_20) } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index cddd846..b34edd9 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -27,22 +27,14 @@ rootProject.name = projectName rootProject.buildFileName = "root.gradle.kts" listOf( - // "1.20-forge", "1.20-fabric", - - //"1.20.2-forge", - //"1.20.2-neoforge", + "1.20.1-fabric", "1.20.2-fabric", - - //"1.20.3-forge", - //"1.20.3-neoforge", "1.20.3-fabric", - - //"1.20.5-neoforge", + "1.20.4-fabric", //"1.20.5-fabric", - - //"1.21-neoforge", - //"1.21-fabric" + "1.20.6-fabric", + "1.21-fabric", ).forEach { version -> include(":$version") project(":$version").apply { diff --git a/src/main/java/me/theclashfruit/cc/mixin/ItemGroupsInterfaceMixin.java b/src/main/java/me/theclashfruit/cc/mixin/ItemGroupsInterfaceMixin.java index 24a18ca..33f397e 100644 --- a/src/main/java/me/theclashfruit/cc/mixin/ItemGroupsInterfaceMixin.java +++ b/src/main/java/me/theclashfruit/cc/mixin/ItemGroupsInterfaceMixin.java @@ -1,7 +1,6 @@ package me.theclashfruit.cc.mixin; import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentTarget; import net.minecraft.item.Instrument; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; @@ -12,6 +11,12 @@ import net.minecraft.registry.tag.TagKey; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +//#if MC >= 1.20.6 +import net.minecraft.resource.featuretoggle.FeatureSet; +//#elseif MC < 1.20.5 +//$$ import net.minecraft.enchantment.EnchantmentTarget; +//#endif + import java.util.Set; @Mixin(ItemGroups.class) @@ -21,13 +26,42 @@ public interface ItemGroupsInterfaceMixin { throw new AssertionError(); } + //#if MC >= 1.20.6 @Invoker("addPotions") - static void invokeAddPotions(ItemGroup.Entries entries, RegistryWrapper registryWrapper, Item item, ItemGroup.StackVisibility visibility) { + static void invokeAddPotions(ItemGroup.Entries entries, RegistryWrapper registryWrapper, Item item, ItemGroup.StackVisibility stackVisibility, FeatureSet featureSet) { throw new AssertionError(); } + //#elseif MC >= 1.20.5 + //$$ @Invoker("addPotions") + //$$ static void invokeAddPotions(ItemGroup.Entries entries, RegistryWrapper registryWrapper, Item item, ItemGroup.StackVisibility visibility) { + //$$ throw new AssertionError(); + //$$ } + //#else + //$$ @Invoker("addPotions") + //$$ static void invokeAddPotions(ItemGroup.Entries entries, RegistryWrapper registryWrapper, Item item, ItemGroup.StackVisibility visibility) { + //$$ throw new AssertionError(); + //$$ } + //#endif + //#if MC >= 1.21 @Invoker("addMaxLevelEnchantedBooks") - static void invokeAddMaxLevelEnchantedBooks(ItemGroup.Entries entries, RegistryWrapper registryWrapper, Set enchantmentTargets, ItemGroup.StackVisibility visibility) { + static void invokeAddMaxLevelEnchantedBooks(ItemGroup.Entries entries, RegistryWrapper registryWrapper, ItemGroup.StackVisibility visibility) { throw new AssertionError(); } + //#elseif MC >= 1.20.6 + //$$ @Invoker("addMaxLevelEnchantedBooks") + //$$ static void invokeAddMaxLevelEnchantedBooks(ItemGroup.Entries entries, RegistryWrapper registryWrapper, Set> set, ItemGroup.StackVisibility stackVisibility, FeatureSet featureSet) { + //$$ throw new AssertionError(); + //$$ } + //#elseif MC >= 1.20.5 + //$$ @Invoker("addMaxLevelEnchantedBooks") + //$$ static void invokeAddMaxLevelEnchantedBooks(ItemGroup.Entries entries, RegistryWrapper registryWrapper, Set> enchantmentTargets, ItemGroup.StackVisibility visibility) { + //$$ throw new AssertionError(); + //$$ } + //#else + //$$ @Invoker("addMaxLevelEnchantedBooks") + //$$ static void invokeAddMaxLevelEnchantedBooks(ItemGroup.Entries entries, RegistryWrapper registryWrapper, Set enchantmentTargets, ItemGroup.StackVisibility visibility) { + //$$ throw new AssertionError(); + //$$ } + //#endif } diff --git a/src/main/java/me/theclashfruit/cc/mixin/ItemGroupsMixin.java b/src/main/java/me/theclashfruit/cc/mixin/ItemGroupsMixin.java index f7f0a8f..12fb6cf 100644 --- a/src/main/java/me/theclashfruit/cc/mixin/ItemGroupsMixin.java +++ b/src/main/java/me/theclashfruit/cc/mixin/ItemGroupsMixin.java @@ -2,20 +2,28 @@ package me.theclashfruit.cc.mixin; import net.minecraft.block.Blocks; import net.minecraft.enchantment.EnchantmentLevelEntry; -import net.minecraft.enchantment.EnchantmentTarget; import net.minecraft.enchantment.Enchantments; import net.minecraft.item.*; -import net.minecraft.potion.PotionUtil; import net.minecraft.potion.Potions; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.InstrumentTags; +import net.minecraft.registry.tag.ItemTags; +import net.minecraft.registry.tag.TagKey; import net.minecraft.text.Text; import net.minecraft.village.raid.Raid; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.gen.Invoker; +//#if MC >= 1.20.6 +import net.minecraft.util.Identifier; +import net.minecraft.component.type.PotionContentsComponent; +//#else +//$$ import net.minecraft.enchantment.EnchantmentTarget; +//$$ import net.minecraft.potion.PotionUtil; +//#endif + import java.util.EnumSet; import java.util.Set; @@ -56,12 +64,25 @@ public class ItemGroupsMixin { .type(ItemGroup.Type.HOTBAR) .build(); + //#if MC >= 1.21 + @Unique + private static final Identifier INVENTORY_TAB_TEXTURE_ID = ItemGroup.getTabTextureId("inventory"); + @Unique + private static final Identifier ITEM_SEARCH_TAB_TEXTURE_ID = ItemGroup.getTabTextureId("item_search"); + //#endif + @Unique private static final ItemGroup inventoryGroup = ItemGroup .create(ItemGroup.Row.BOTTOM, 6) .displayName(Text.translatable("itemGroup.inventory")) .icon(() -> new ItemStack(Blocks.CHEST)) - .texture("inventory.png") + .texture( + //#if MC >= 1.21 + INVENTORY_TAB_TEXTURE_ID + //#else + //$$ "inventory.png" + //#endif + ) .noRenderedName() .special() .type(ItemGroup.Type.INVENTORY) @@ -89,7 +110,13 @@ public class ItemGroupsMixin { content.addAll(itemGroupSet); }) - .texture("item_search.png") + .texture( + //#if MC >= 1.21 + ITEM_SEARCH_TAB_TEXTURE_ID + //#else + //$$ "item_search.png" + //#endif + ) .special() .type(ItemGroup.Type.SEARCH) .build(); @@ -900,7 +927,12 @@ public class ItemGroupsMixin { content.add(Items.GREEN_BANNER); content.add(Items.RED_BANNER); content.add(Items.BLACK_BANNER); - content.add(Raid.getOminousBanner()); + + //#if MC >= 1.20.6 + content.add(Raid.getOminousBanner(displayContext.lookup().getWrapperOrThrow(RegistryKeys.BANNER_PATTERN))); + //#else + //$$ content.add(Raid.getOminousBanner()); + //#endif content.add(Items.END_CRYSTAL); @@ -1130,7 +1162,12 @@ public class ItemGroupsMixin { content.add(Items.BEACON); content.add(Items.TURTLE_EGG); content.add(Items.CONDUIT); - content.add(Items.SCUTE); + + //#if MC >= 1.20 + content.add(Items.TURTLE_SCUTE); + //#else + //$$ content.add(Items.SCUTE); + //#endif content.add(Items.COAL); content.add(Items.CHARCOAL); @@ -1487,14 +1524,18 @@ public class ItemGroupsMixin { content.add(Items.SPYGLASS); content.add(Items.SHEARS); - content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.EFFICIENCY, 5))); - content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.SILK_TOUCH, 1))); - content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.UNBREAKING, 3))); - content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.FORTUNE, 3))); - content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.LUCK_OF_THE_SEA, 3))); - content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.LURE, 3))); - content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.MENDING, 1))); - content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.VANISHING_CURSE, 1))); + //#if MC >= 1.20.6 + LOGGER.info("WHY TF 1.20.6 HAS TO FUCK SHIT UP? HOW DO I MAKE AN ENCHANTED BOOK???????????????"); + //#else + //$$ content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.EFFICIENCY, 5))); + //$$content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.SILK_TOUCH, 1))); + //$$content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.UNBREAKING, 3))); + //$$content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.FORTUNE, 3))); + //$$content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.LUCK_OF_THE_SEA, 3))); + //$$content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.LURE, 3))); + //$$content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.MENDING, 1))); + //$$content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.VANISHING_CURSE, 1))); + //#endif content.add(Items.LEAD); content.add(Items.NAME_TAG); @@ -1552,14 +1593,33 @@ public class ItemGroupsMixin { content.add(Items.NETHERITE_LEGGINGS); content.add(Items.NETHERITE_BOOTS); - EnumSet set = EnumSet.allOf(EnchantmentTarget.class); - - displayContext.lookup().getOptionalWrapper(RegistryKeys.ENCHANTMENT).ifPresent(wrapper -> { - ItemGroupsInterfaceMixin.invokeAddMaxLevelEnchantedBooks(content, wrapper, set, ItemGroup.StackVisibility.PARENT_TAB_ONLY); + //#if MC >= 1.21 + displayContext.lookup().getOptionalWrapper(RegistryKeys.ENCHANTMENT).ifPresent((impl) -> { + ItemGroupsInterfaceMixin.invokeAddMaxLevelEnchantedBooks(content, impl, ItemGroup.StackVisibility.PARENT_TAB_ONLY); }); + //#elseif MC >= 1.20.6 + //$$ Set> set = Set.of(ItemTags.FOOT_ARMOR_ENCHANTABLE, ItemTags.LEG_ARMOR_ENCHANTABLE, ItemTags.CHEST_ARMOR_ENCHANTABLE, ItemTags.HEAD_ARMOR_ENCHANTABLE, ItemTags.ARMOR_ENCHANTABLE, ItemTags.SWORD_ENCHANTABLE, ItemTags.SHARP_WEAPON_ENCHANTABLE, ItemTags.MACE_ENCHANTABLE, ItemTags.FIRE_ASPECT_ENCHANTABLE, ItemTags.WEAPON_ENCHANTABLE, ItemTags.MINING_ENCHANTABLE, ItemTags.MINING_LOOT_ENCHANTABLE, ItemTags.FISHING_ENCHANTABLE, ItemTags.TRIDENT_ENCHANTABLE, ItemTags.DURABILITY_ENCHANTABLE, ItemTags.BOW_ENCHANTABLE, ItemTags.EQUIPPABLE_ENCHANTABLE, ItemTags.CROSSBOW_ENCHANTABLE, ItemTags.VANISHING_ENCHANTABLE); + //$$ + //$$ displayContext.lookup().getOptionalWrapper(RegistryKeys.ENCHANTMENT).ifPresent((impl) -> { + //$$ ItemGroupsInterfaceMixin.invokeAddMaxLevelEnchantedBooks(content, impl, set, ItemGroup.StackVisibility.PARENT_TAB_ONLY, displayContext.comp_1251()); + //$$ }); + //#else + //$$ EnumSet set = EnumSet.allOf(EnchantmentTarget.class); + //$$ + //$$ displayContext.lookup().getOptionalWrapper(RegistryKeys.ENCHANTMENT).ifPresent(wrapper -> { + //$$ ItemGroupsInterfaceMixin.invokeAddMaxLevelEnchantedBooks(content, wrapper, set, ItemGroup.StackVisibility.PARENT_TAB_ONLY); + //$$ }); + //#endif content.add(Items.SPECTRAL_ARROW); - displayContext.lookup().getOptionalWrapper(RegistryKeys.POTION).ifPresent(wrapper -> ItemGroupsInterfaceMixin.invokeAddPotions(content, wrapper, Items.TIPPED_ARROW, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS)); + + //#if MC >= 1.20.6 + displayContext.lookup().getOptionalWrapper(RegistryKeys.POTION).ifPresent((impl) -> { + ItemGroupsInterfaceMixin.invokeAddPotions(content, impl, Items.TIPPED_ARROW, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS, displayContext.comp_1251()); + }); + //#else + //$$ displayContext.lookup().getOptionalWrapper(RegistryKeys.POTION).ifPresent(wrapper -> ItemGroupsInterfaceMixin.invokeAddPotions(content, wrapper, Items.TIPPED_ARROW, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS)); + //#endif content.add(Items.SHIELD); content.add(Items.TOTEM_OF_UNDYING); @@ -1596,13 +1656,24 @@ public class ItemGroupsMixin { .create(ItemGroup.Row.BOTTOM, 4) .type(ItemGroup.Type.CATEGORY) .displayName(Text.translatable("itemGroup.brewing")) - .icon(() -> PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER)) - .entries((displayContext, content) -> { + .icon(() -> + //#if MC >= 1.20.6 + PotionContentsComponent.createStack(Items.POTION, Potions.WATER) + //#else + //$$ PotionUtil.setPotion(new ItemStack(Items.POTION), Potions.WATER) + //#endif + ).entries((displayContext, content) -> { content.add(Items.GHAST_TEAR); - displayContext.lookup().getOptionalWrapper(RegistryKeys.POTION).ifPresent(wrapper -> { - ItemGroupsInterfaceMixin.invokeAddPotions(content, wrapper, Items.POTION, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + //#if MC >= 1.20.6 + displayContext.lookup().getOptionalWrapper(RegistryKeys.POTION).ifPresent((impl) -> { + ItemGroupsInterfaceMixin.invokeAddPotions(content, impl, Items.POTION, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS, displayContext.comp_1251()); }); + //#else + //$$ displayContext.lookup().getOptionalWrapper(RegistryKeys.POTION).ifPresent(wrapper -> { + //$$ ItemGroupsInterfaceMixin.invokeAddPotions(content, wrapper, Items.POTION, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + //$$ }); + //#endif content.add(Items.GLASS_BOTTLE); content.add(Items.FERMENTED_SPIDER_EYE); @@ -1615,10 +1686,17 @@ public class ItemGroupsMixin { content.add(Items.RABBIT_FOOT); content.add(Items.DRAGON_BREATH); - displayContext.lookup().getOptionalWrapper(RegistryKeys.POTION).ifPresent(wrapper -> { - ItemGroupsInterfaceMixin.invokeAddPotions(content, wrapper, Items.SPLASH_POTION, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); - ItemGroupsInterfaceMixin.invokeAddPotions(content, wrapper, Items.LINGERING_POTION, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + //#if MC >= 1.20.6 + displayContext.lookup().getOptionalWrapper(RegistryKeys.POTION).ifPresent((impl) -> { + ItemGroupsInterfaceMixin.invokeAddPotions(content, impl, Items.SPLASH_POTION, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS, displayContext.comp_1251()); + ItemGroupsInterfaceMixin.invokeAddPotions(content, impl, Items.LINGERING_POTION, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS, displayContext.comp_1251()); }); + //#else + //$$ displayContext.lookup().getOptionalWrapper(RegistryKeys.POTION).ifPresent(wrapper -> { + //$$ ItemGroupsInterfaceMixin.invokeAddPotions(content, wrapper, Items.SPLASH_POTION, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + //$$ ItemGroupsInterfaceMixin.invokeAddPotions(content, wrapper, Items.LINGERING_POTION, ItemGroup.StackVisibility.PARENT_AND_SEARCH_TABS); + //$$ }); + //#endif content.add(Items.PHANTOM_MEMBRANE); }) diff --git a/versions/mainProject b/versions/mainProject index 8a82347..dfdd511 100644 --- a/versions/mainProject +++ b/versions/mainProject @@ -1 +1 @@ -1.20.3-fabric \ No newline at end of file +1.21-fabric \ No newline at end of file