From 855e9a2c154e52af13bdd86e4d6bd092113b934b Mon Sep 17 00:00:00 2001 From: glowredman <35727266+glowredman@users.noreply.github.com> Date: Sun, 26 Nov 2023 00:09:03 +0100 Subject: [PATCH] Adapt to registry overhaul --- gradle.properties | 6 ++--- .../modularmaterials/MM_Commands.java | 18 ++++++------- .../modularmaterials/block/BlockHandler.java | 12 +++++---- .../block/MetaFallingOreBlock.java | 6 ++--- .../modularmaterials/block/MetaOreBlock.java | 6 ++--- .../data/object/MM_OreVein.java | 4 +-- .../modularmaterials/fluid/FluidHandler.java | 27 +++++++++++-------- .../modularmaterials/item/ItemHandler.java | 24 ++++++++--------- .../modularmaterials/util/TagHelper.java | 2 +- .../worldgen/FeatureVeinLayer.java | 5 ++-- 10 files changed, 59 insertions(+), 51 deletions(-) diff --git a/gradle.properties b/gradle.properties index 09c0564..c1137f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,9 +13,9 @@ minecraft_version=1.20.2 # as they do not follow standard versioning conventions. minecraft_version_range=[1.20.2,1.21) # The Neo version must agree with the Minecraft version to get a valid artifact -neo_version=20.2.53-beta +neo_version=20.2.64-beta # The Neo version range can use any version of Neo as bounds or match the loader version range -neo_version_range=[20.2,) +neo_version_range=[20.2.59,) # The loader version range can only use the major version of Neo/FML as bounds loader_version_range=[1,) # The mapping channel to use for mappings. @@ -48,7 +48,7 @@ mod_name=Modular Materials # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=LGPL-3.0 # The mod version. See https://semver.org/ -mod_version=0.14-beta +mod_version=0.14.1-beta # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/glowredman/modularmaterials/MM_Commands.java b/src/main/java/glowredman/modularmaterials/MM_Commands.java index b7b8a1c..0f105ce 100644 --- a/src/main/java/glowredman/modularmaterials/MM_Commands.java +++ b/src/main/java/glowredman/modularmaterials/MM_Commands.java @@ -25,6 +25,8 @@ import net.minecraft.core.Direction; import net.minecraft.core.Holder; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; @@ -46,8 +48,6 @@ import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.neoforge.event.RegisterCommandsEvent; import net.neoforged.neoforge.fluids.FluidType; -import net.neoforged.neoforge.registries.ForgeRegistries; -import net.neoforged.neoforge.registries.ForgeRegistries.Keys; public class MM_Commands { @@ -68,13 +68,13 @@ public void register(RegisterCommandsEvent event) { stack = commandSourceStack.getPlayerOrException().getMainHandItem(); } catch (Exception e) {} - if (stack == null || ForgeRegistries.ITEMS.getKey(stack.getItem()).equals(ForgeRegistries.ITEMS.getKey(Blocks.AIR.asItem()))) { + if (stack == null || BuiltInRegistries.ITEM.getKey(stack.getItem()).equals(BuiltInRegistries.ITEM.getKey(Blocks.AIR.asItem()))) { commandSourceStack.sendFailure(Component.literal("Your main hand is empty!").withStyle(style -> style.withColor(ChatFormatting.RED).withItalic(true))); } else { final Item item = stack.getItem(); - commandSourceStack.sendSuccess(() -> copyable(ForgeRegistries.ITEMS.getKey(item).toString()).withStyle(ChatFormatting.GREEN), false); + commandSourceStack.sendSuccess(() -> copyable(BuiltInRegistries.ITEM.getKey(item).toString()).withStyle(ChatFormatting.GREEN), false); stack.getTags().forEach(rl -> commandSourceStack.sendSuccess(() -> Component.literal(" > ").append(copyable(rl.location().toString())), false)); } return 0; @@ -106,15 +106,15 @@ private static int getInfo(CommandSourceStack commandSourceStack, BlockPos pos) BlockState blockstate = level.getBlockState(pos); Block block = blockstate.getBlock(); - Registry blockRegistry = level.registryAccess().registryOrThrow(Keys.BLOCKS); + Registry blockRegistry = level.registryAccess().registryOrThrow(Registries.BLOCK); ResourceLocation blockRegName = blockRegistry.getKey(block); - List> blockTags = blockRegistry.getHolderOrThrow(ResourceKey.create(Keys.BLOCKS, blockRegName)).tags().toList(); + List> blockTags = blockRegistry.getHolderOrThrow(ResourceKey.create(Registries.BLOCK, blockRegName)).tags().toList(); FluidState fluidstate = level.getFluidState(pos); Fluid fluid = fluidstate.getType(); - Registry fluidRegistry = level.registryAccess().registryOrThrow(Keys.FLUIDS); + Registry fluidRegistry = level.registryAccess().registryOrThrow(Registries.FLUID); ResourceLocation fluidRegName = fluidRegistry.getKey(fluid); - List> fluidTags = fluidRegistry.getHolderOrThrow(ResourceKey.create(Keys.FLUIDS, fluidRegName)).tags().toList(); + List> fluidTags = fluidRegistry.getHolderOrThrow(ResourceKey.create(Registries.FLUID, fluidRegName)).tags().toList(); FluidType fluidType = fluid.getFluidType(); commandSourceStack.sendSuccess(() -> Component.literal("Information for ").withStyle(ChatFormatting.GOLD) @@ -124,7 +124,7 @@ private static int getInfo(CommandSourceStack commandSourceStack, BlockPos pos) .append(Component.literal(":")).withStyle(ChatFormatting.GOLD), false); commandSourceStack.sendSuccess(() -> Component.literal("Biome: ").withStyle(ChatFormatting.BLUE) - .append(copyable(level.registryAccess().registryOrThrow(Keys.BIOMES).getKey(biome.value()).toString())), false); + .append(copyable(level.registryAccess().registryOrThrow(Registries.BIOME).getKey(biome.value()).toString())), false); if(!biomeTags.isEmpty()) commandSourceStack.sendSuccess(() -> Component.literal(" Tags: ").withStyle(ChatFormatting.AQUA), false); biomeTags.forEach(rl -> commandSourceStack.sendSuccess(() -> Component.literal(" > ").append(copyable(rl.location().toString())), false)); diff --git a/src/main/java/glowredman/modularmaterials/block/BlockHandler.java b/src/main/java/glowredman/modularmaterials/block/BlockHandler.java index 0247589..4f1926e 100644 --- a/src/main/java/glowredman/modularmaterials/block/BlockHandler.java +++ b/src/main/java/glowredman/modularmaterials/block/BlockHandler.java @@ -13,6 +13,9 @@ import glowredman.modularmaterials.data.object.sub.Category; import glowredman.modularmaterials.data.object.sub.ColorProperties; import glowredman.modularmaterials.worldgen.FeatureVeinLayer; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; @@ -20,7 +23,6 @@ import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; import net.minecraft.world.level.material.MapColor; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.neoforge.registries.ForgeRegistries; import net.neoforged.neoforge.registries.RegisterEvent; public class BlockHandler { @@ -29,7 +31,7 @@ public class BlockHandler { @SubscribeEvent public void registerBlocks(RegisterEvent event) { - if(!event.getRegistryKey().equals(ForgeRegistries.BLOCKS.getRegistryKey())) { + if(!event.getRegistryKey().equals(Registries.BLOCK)) { return; } @@ -46,7 +48,7 @@ public void registerBlocks(RegisterEvent event) { MM_Material material = eMaterial.getValue(); if((material.enabled && material.enabledTypes.contains(typeName)) || MM_Reference.CONFIG.enableAll) { ResourceLocation regName = new ResourceLocation(MM_Reference.MODID, typeName + "." + materialName); - event.getForgeRegistry().register(regName, new MetaBlock(material, type, materialName, regName)); + Registry.register(BuiltInRegistries.BLOCK, regName, new MetaBlock(material, type, materialName, regName)); } } } @@ -62,9 +64,9 @@ public void registerBlocks(RegisterEvent event) { if(variant.enabled || MM_Reference.CONFIG.enableAll) { ResourceLocation regName = new ResourceLocation(MM_Reference.MODID, "ore." + eVariant.getKey() + "." + materialName); if(variant.falling) { - event.getForgeRegistry().register(regName, new MetaFallingOreBlock(material, variant, materialName, regName)); + Registry.register(BuiltInRegistries.BLOCK, regName, new MetaFallingOreBlock(material, variant, materialName, regName)); } else { - event.getForgeRegistry().register(regName, new MetaOreBlock(material, variant, materialName, regName)); + Registry.register(BuiltInRegistries.BLOCK, regName, new MetaOreBlock(material, variant, materialName, regName)); } } } diff --git a/src/main/java/glowredman/modularmaterials/block/MetaFallingOreBlock.java b/src/main/java/glowredman/modularmaterials/block/MetaFallingOreBlock.java index 09fa255..43e2d3c 100644 --- a/src/main/java/glowredman/modularmaterials/block/MetaFallingOreBlock.java +++ b/src/main/java/glowredman/modularmaterials/block/MetaFallingOreBlock.java @@ -7,6 +7,7 @@ import glowredman.modularmaterials.MM_Reference; import glowredman.modularmaterials.data.object.MM_Material; import glowredman.modularmaterials.data.object.MM_OreVariant; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -14,7 +15,6 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.FallingBlock; -import net.neoforged.neoforge.registries.ForgeRegistries; public class MetaFallingOreBlock extends FallingBlock implements IMetaOre { @@ -23,11 +23,11 @@ public class MetaFallingOreBlock extends FallingBlock implements IMetaOre { private final ResourceLocation registryName; public MetaFallingOreBlock(MM_Material material, MM_OreVariant ore, String uniqueMM_MaterialName, ResourceLocation registryName) { - super(BlockHandler.getOreBlockProperties(material, ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ore.baseBlock)), uniqueMM_MaterialName)); + super(BlockHandler.getOreBlockProperties(material, BuiltInRegistries.BLOCK.get(new ResourceLocation(ore.baseBlock)), uniqueMM_MaterialName)); this.material = material; this.variant = ore; this.registryName = registryName; - MM_Reference.ORES.put(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ore.baseBlock)), uniqueMM_MaterialName, this); + MM_Reference.ORES.put(BuiltInRegistries.BLOCK.get(new ResourceLocation(ore.baseBlock)), uniqueMM_MaterialName, this); } @Override diff --git a/src/main/java/glowredman/modularmaterials/block/MetaOreBlock.java b/src/main/java/glowredman/modularmaterials/block/MetaOreBlock.java index 7f7b5f3..3910d9d 100644 --- a/src/main/java/glowredman/modularmaterials/block/MetaOreBlock.java +++ b/src/main/java/glowredman/modularmaterials/block/MetaOreBlock.java @@ -7,13 +7,13 @@ import glowredman.modularmaterials.MM_Reference; import glowredman.modularmaterials.data.object.MM_Material; import glowredman.modularmaterials.data.object.MM_OreVariant; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.Block; -import net.neoforged.neoforge.registries.ForgeRegistries; public class MetaOreBlock extends Block implements IMetaOre { @@ -22,11 +22,11 @@ public class MetaOreBlock extends Block implements IMetaOre { private final ResourceLocation registryName; public MetaOreBlock(MM_Material material, MM_OreVariant ore, String uniqueMM_MaterialName, ResourceLocation registryName) { - super(BlockHandler.getOreBlockProperties(material, ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ore.baseBlock)), uniqueMM_MaterialName)); + super(BlockHandler.getOreBlockProperties(material, BuiltInRegistries.BLOCK.get(new ResourceLocation(ore.baseBlock)), uniqueMM_MaterialName)); this.material = material; this.variant = ore; this.registryName = registryName; - MM_Reference.ORES.put(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ore.baseBlock)), uniqueMM_MaterialName, this); + MM_Reference.ORES.put(BuiltInRegistries.BLOCK.get(new ResourceLocation(ore.baseBlock)), uniqueMM_MaterialName, this); } @Override diff --git a/src/main/java/glowredman/modularmaterials/data/object/MM_OreVein.java b/src/main/java/glowredman/modularmaterials/data/object/MM_OreVein.java index 4b83a13..a29be80 100644 --- a/src/main/java/glowredman/modularmaterials/data/object/MM_OreVein.java +++ b/src/main/java/glowredman/modularmaterials/data/object/MM_OreVein.java @@ -14,12 +14,12 @@ import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.Holder; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.tags.TagKey; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.neoforged.neoforge.registries.ForgeRegistries.Keys; public class MM_OreVein { @@ -153,7 +153,7 @@ private boolean testDimension(WorldGenLevel world) { private boolean testBiome(WorldGenLevel world, int x, int y, int z) { Holder biomeHolder = world.getBiome(new BlockPos(x + 8, y, z + 8)); Biome biome = biomeHolder.value(); - Registry registry = world.getLevel().registryAccess().registryOrThrow(Keys.BIOMES); + Registry registry = world.getLevel().registryAccess().registryOrThrow(Registries.BIOME); String biomeName = registry.getKey(biome).toString(); if(invertBiomes) { for(TagKey tagKey : biomeHolder.tags().toList()) { diff --git a/src/main/java/glowredman/modularmaterials/fluid/FluidHandler.java b/src/main/java/glowredman/modularmaterials/fluid/FluidHandler.java index 4f03f43..84ea863 100644 --- a/src/main/java/glowredman/modularmaterials/fluid/FluidHandler.java +++ b/src/main/java/glowredman/modularmaterials/fluid/FluidHandler.java @@ -1,6 +1,7 @@ package glowredman.modularmaterials.fluid; import java.util.Map.Entry; +import java.util.function.Supplier; import glowredman.modularmaterials.MM_Reference; import glowredman.modularmaterials.ModularMaterials; @@ -8,20 +9,24 @@ import glowredman.modularmaterials.data.object.MM_Type; import glowredman.modularmaterials.data.object.sub.Category; import glowredman.modularmaterials.item.MetaBucketItem; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; +import net.minecraft.world.level.material.Fluid; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext; import net.neoforged.neoforge.fluids.BaseFlowingFluid; import net.neoforged.neoforge.fluids.FluidType; +import net.neoforged.neoforge.registries.DeferredHolder; import net.neoforged.neoforge.registries.DeferredRegister; -import net.neoforged.neoforge.registries.ForgeRegistries; +import net.neoforged.neoforge.registries.NeoForgeRegistries; import net.neoforged.neoforge.registries.RegisterEvent; -import net.neoforged.neoforge.registries.RegistryObject; public class FluidHandler { - private static final DeferredRegister FLUID_TYPES = DeferredRegister.create(ForgeRegistries.Keys.FLUID_TYPES, MM_Reference.MODID); + private static final DeferredRegister FLUID_TYPES = DeferredRegister.create(NeoForgeRegistries.Keys.FLUID_TYPES, MM_Reference.MODID); public FluidHandler() { @@ -30,7 +35,7 @@ public FluidHandler() { @SubscribeEvent public void registerBlocks(RegisterEvent event) { - if(!event.getRegistryKey().equals(ForgeRegistries.FLUIDS.getRegistryKey())) { + if(!event.getRegistryKey().equals(Registries.FLUID)) { return; } @@ -46,20 +51,20 @@ public void registerBlocks(RegisterEvent event) { String materialName = eMaterial.getKey(); MM_Material material = eMaterial.getValue(); if((material.enabled && material.enabledTypes.contains(typeName)) || MM_Reference.CONFIG.enableAll) { - RegistryObject fluidS = RegistryObject.create(new ResourceLocation(MM_Reference.MODID, typeName + "." + materialName), ForgeRegistries.FLUIDS); - RegistryObject fluidF = RegistryObject.create(new ResourceLocation(MM_Reference.MODID, "flowing_" + typeName + "." + materialName), ForgeRegistries.FLUIDS); - RegistryObject fluidType = FLUID_TYPES.register(typeName + "." + materialName, () -> new MetaFluidType(material, type, typeName)); + DeferredHolder fluidS = DeferredHolder.create(Registries.FLUID, new ResourceLocation(MM_Reference.MODID, typeName + "." + materialName)); + DeferredHolder fluidF = DeferredHolder.create(Registries.FLUID, new ResourceLocation(MM_Reference.MODID, "flowing_" + typeName + "." + materialName)); + Supplier fluidType = FLUID_TYPES.register(typeName + "." + materialName, () -> new MetaFluidType(material, type, typeName)); BaseFlowingFluid.Properties p = new BaseFlowingFluid.Properties(fluidType, fluidS, fluidF); if(MM_Reference.CONFIG.enableBuckets) { ResourceLocation regName = new ResourceLocation(MM_Reference.MODID, "bucket." + fluidS.getId().getPath()); Item bucket = new MetaBucketItem(fluidS, material, regName); p.bucket(() -> bucket); - ForgeRegistries.ITEMS.register(regName, bucket); + Registry.register(BuiltInRegistries.ITEM, regName, bucket); } - - ForgeRegistries.FLUIDS.register(fluidS.getId(), new MetaFluid(material, type, p, fluidS.getId())); - ForgeRegistries.FLUIDS.register(fluidF.getId(), new MetaFlowingFluid(material, type, p, fluidF.getId())); + + Registry.register(BuiltInRegistries.FLUID, fluidS.getId(), new MetaFluid(material, type, p, fluidS.getId())); + Registry.register(BuiltInRegistries.FLUID, fluidF.getId(), new MetaFlowingFluid(material, type, p, fluidF.getId())); //TODO //MetaFluidBlock block = new MetaFluidBlock(fluidS, material, type, materialName); diff --git a/src/main/java/glowredman/modularmaterials/item/ItemHandler.java b/src/main/java/glowredman/modularmaterials/item/ItemHandler.java index fc5dae0..2daa25f 100644 --- a/src/main/java/glowredman/modularmaterials/item/ItemHandler.java +++ b/src/main/java/glowredman/modularmaterials/item/ItemHandler.java @@ -9,6 +9,8 @@ import glowredman.modularmaterials.data.object.MM_Material; import glowredman.modularmaterials.data.object.MM_Type; import glowredman.modularmaterials.data.object.sub.Category; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -20,7 +22,6 @@ import net.minecraft.world.level.block.Blocks; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.neoforge.event.BuildCreativeModeTabContentsEvent; -import net.neoforged.neoforge.registries.ForgeRegistries; import net.neoforged.neoforge.registries.RegisterEvent; public class ItemHandler { @@ -32,7 +33,7 @@ public class ItemHandler { @SubscribeEvent public void registerItems(RegisterEvent event) { - if(!event.getRegistryKey().equals(ForgeRegistries.ITEMS.getRegistryKey())) { + if(!event.getRegistryKey().equals(Registries.ITEM)) { return; } @@ -47,18 +48,18 @@ public void registerItems(RegisterEvent event) { MM_Material material = eMaterial.getValue(); if((material.enabled && material.enabledTypes.contains(typeName)) || MM_Reference.CONFIG.enableAll) { ResourceLocation regName = new ResourceLocation(MM_Reference.MODID, typeName + "." + materialName); - event.getForgeRegistry().register(regName, new MetaItem(material, type, regName)); + Registry.register(BuiltInRegistries.ITEM, regName, new MetaItem(material, type, regName)); } } } } for(MetaBlock block : MM_Reference.BLOCKS) { - event.getForgeRegistry().register(block.registryName, new MetaBlockItem(block)); + Registry.register(BuiltInRegistries.ITEM, block.registryName, new MetaBlockItem(block)); } for(IMetaOre ore : MM_Reference.ORES.values()) { - event.getForgeRegistry().register(ore.getRegistryName(), new MetaOreBlockItem(ore)); + Registry.register(BuiltInRegistries.ITEM, ore.getRegistryName(), new MetaOreBlockItem(ore)); } ModularMaterials.LOGGER.info("Registered {} items. Took {}ms.", MM_Reference.ITEMS.size(), System.currentTimeMillis() - time); @@ -70,16 +71,16 @@ public void populateCreativeTabs(RegisterEvent event) { return; } if(!MM_Reference.BLOCKS.isEmpty()) { - tabBlocks = createCreativeModeTab(event, "blocks", Blocks.IRON_BLOCK); + tabBlocks = createCreativeModeTab("blocks", Blocks.IRON_BLOCK); } if(!MM_Reference.ORES.isEmpty()) { - tabOres = createCreativeModeTab(event, "ores", Blocks.IRON_ORE); + tabOres = createCreativeModeTab("ores", Blocks.IRON_ORE); } if(!MM_Reference.ITEMS.isEmpty()) { - tabItems = createCreativeModeTab(event, "items", Items.IRON_INGOT); + tabItems = createCreativeModeTab("items", Items.IRON_INGOT); } if(!MM_Reference.BUCKETS.isEmpty()) { - tabFluids = createCreativeModeTab(event, "fluids", Items.WATER_BUCKET); + tabFluids = createCreativeModeTab("fluids", Items.WATER_BUCKET); } } @@ -107,10 +108,9 @@ public void populateCreativeTabs(BuildCreativeModeTabContentsEvent event) { } } - private static CreativeModeTab createCreativeModeTab(RegisterEvent event, String name, ItemLike icon) { + private static CreativeModeTab createCreativeModeTab(String name, ItemLike icon) { CreativeModeTab tab = CreativeModeTab.builder().icon(() -> new ItemStack(icon)).title(Component.translatable("itemGroup." + MM_Reference.MODID + "." + name)).build(); - event.register(Registries.CREATIVE_MODE_TAB, new ResourceLocation(MM_Reference.MODID, name), () -> tab); - return tab; + return Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, new ResourceLocation(MM_Reference.MODID, name), tab); } } diff --git a/src/main/java/glowredman/modularmaterials/util/TagHelper.java b/src/main/java/glowredman/modularmaterials/util/TagHelper.java index c2deeb5..3ecc38e 100644 --- a/src/main/java/glowredman/modularmaterials/util/TagHelper.java +++ b/src/main/java/glowredman/modularmaterials/util/TagHelper.java @@ -9,7 +9,7 @@ public class TagHelper { public static boolean hasTag(RegistryAccess registryAccess, T object, TagKey tag) { Registry registry = registryAccess.registryOrThrow(tag.registry()); - return registry.getHolderOrThrow(ResourceKey.create(tag.registry(), registry.getKey(object))).containsTag(tag); + return registry.getHolderOrThrow(ResourceKey.create(tag.registry(), registry.getKey(object))).is(tag); } } diff --git a/src/main/java/glowredman/modularmaterials/worldgen/FeatureVeinLayer.java b/src/main/java/glowredman/modularmaterials/worldgen/FeatureVeinLayer.java index ae4864b..52fec2b 100644 --- a/src/main/java/glowredman/modularmaterials/worldgen/FeatureVeinLayer.java +++ b/src/main/java/glowredman/modularmaterials/worldgen/FeatureVeinLayer.java @@ -8,13 +8,14 @@ import glowredman.modularmaterials.data.object.MM_OreVein; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; -import net.neoforged.neoforge.registries.ForgeRegistries; public class FeatureVeinLayer extends Feature { @@ -36,7 +37,7 @@ public static void calculateTotalWeight() { public FeatureVeinLayer() { super(NoneFeatureConfiguration.CODEC); - ForgeRegistries.FEATURES.register(new ResourceLocation(MM_Reference.MODID, "orevein"), this); + Registry.register(BuiltInRegistries.FEATURE, new ResourceLocation(MM_Reference.MODID, "orevein"), this); } @Override