fix: add the enchantment books back to the tools tab for 1.21

This commit is contained in:
TheClashFruit 2024-07-14 17:23:33 +02:00
parent 5068e3ed19
commit 04b0ba8ae0
Signed by: TheClashFruit
GPG key ID: 09BB24C34C2F3204
4 changed files with 27 additions and 16 deletions

View file

@ -1,4 +0,0 @@
### New
* Added Tuff Blocks for 1.21+
### Fixes

3
changelogs/2.0.0.md Normal file
View file

@ -0,0 +1,3 @@
### Fixes
* Added the tuff blocks
* Enchantment books are back in the tools tab.

View file

@ -3,5 +3,5 @@ org.gradle.jvmargs=-Xmx2G
mod.name=Cluttered Creative
mod.id=cc
mod.version=2.0.0-rc.2
mod.version=2.0.0
mod.group=me.theclashfruit

View file

@ -1,12 +1,18 @@
package me.theclashfruit.cc.mixin;
import net.minecraft.block.Blocks;
import net.minecraft.client.gui.screen.ingame.EnchantmentScreen;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentLevelBasedValue;
import net.minecraft.enchantment.EnchantmentLevelEntry;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.enchantment.effect.EnchantmentEffectEntry;
import net.minecraft.enchantment.effect.EnchantmentValueEffect;
import net.minecraft.entity.Entity;
import net.minecraft.item.*;
import net.minecraft.potion.Potions;
import net.minecraft.predicate.item.EnchantmentPredicate;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
@ -23,6 +29,7 @@ import org.spongepowered.asm.mixin.gen.Invoker;
//#if MC >= 1.20.6
import net.minecraft.util.Identifier;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import net.minecraft.component.type.PotionContentsComponent;
//#else
//$$ import net.minecraft.enchantment.EnchantmentTarget;
@ -31,6 +38,7 @@ import net.minecraft.component.type.PotionContentsComponent;
import java.util.EnumSet;
import java.util.Set;
import java.util.stream.IntStream;
import static me.theclashfruit.cc.ClutteredCreative.LOGGER;
import static net.minecraft.item.ItemGroups.*;
@ -405,12 +413,6 @@ public class ItemGroupsMixin {
content.add(Items.STONE_BRICK_STAIRS);
content.add(Items.MUD_BRICK_STAIRS);
//#if MC >= 1.21
content.add(Items.TUFF_BRICK_STAIRS);
content.add(Items.POLISHED_TUFF_STAIRS);
content.add(Items.TUFF_STAIRS);
//#endif
content.add(Items.MYCELIUM);
content.add(Items.NETHER_BRICKS);
content.add(Items.CRACKED_NETHER_BRICKS);
@ -565,6 +567,12 @@ public class ItemGroupsMixin {
content.add(Items.DEEPSLATE_BRICK_STAIRS);
content.add(Items.DEEPSLATE_TILE_STAIRS);
//#if MC >= 1.21
content.add(Items.TUFF_BRICK_STAIRS);
content.add(Items.POLISHED_TUFF_STAIRS);
content.add(Items.TUFF_STAIRS);
//#endif
content.add(Items.POLISHED_GRANITE_SLAB);
content.add(Items.SMOOTH_RED_SANDSTONE_SLAB);
content.add(Items.MOSSY_STONE_BRICK_SLAB);
@ -1553,12 +1561,16 @@ public class ItemGroupsMixin {
content.add(Items.SHEARS);
//#if MC >= 1.21
LOGGER.info("WHY TF 1.21 HAS TO FUCK SHIT UP? HOW DO I MAKE AN ENCHANTED BOOK???????????????");
displayContext.lookup().getOptionalWrapper(RegistryKeys.ENCHANTMENT).ifPresent((impl) -> {
LOGGER.info(impl.getRegistryKey().getValue().getPath());
displayContext.lookup().getOptionalWrapper(RegistryKeys.ENCHANTMENT).ifPresent(impl -> {
content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(impl.getOrThrow(Enchantments.EFFICIENCY), 5)));
content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(impl.getOrThrow(Enchantments.SILK_TOUCH), 1)));
content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(impl.getOrThrow(Enchantments.UNBREAKING), 3)));
content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(impl.getOrThrow(Enchantments.FORTUNE), 3)));
content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(impl.getOrThrow(Enchantments.LUCK_OF_THE_SEA), 3)));
content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(impl.getOrThrow(Enchantments.LURE), 3)));
content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(impl.getOrThrow(Enchantments.MENDING), 1)));
content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(impl.getOrThrow(Enchantments.VANISHING_CURSE), 1)));
});
//#else
//$$ content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.EFFICIENCY, 5)));
//$$ content.add(EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(Enchantments.SILK_TOUCH, 1)));