diff --git a/build.gradle b/build.gradle index 4cdeb41..5b75f14 100644 --- a/build.gradle +++ b/build.gradle @@ -1,53 +1,57 @@ plugins { id 'java' id 'eclipse' - id 'net.minecraftforge.gradle' version '[6.0.16,6.2)' + id 'net.neoforged.moddev' version '2.0.141' id 'me.hypherionmc.cursegradle' version '2.+' } -archivesBaseName = "${mod_name}-${minecraft_version}" +archivesBaseName = "${mod_name}-${minecraft_version}-neoforge" version = mod_version -java.toolchain.languageVersion = JavaLanguageVersion.of(17) +java.toolchain.languageVersion = JavaLanguageVersion.of(21) javadoc.options.addStringOption('Xdoclint:none', '-quiet') println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + ' (' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) -minecraft { - mappings channel: 'official', version: minecraft_version - accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') +neoForge { + version = neo_version + accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg') runs { - configureEach { - workingDirectory project.file('run') - } - client { - taskName "${project.name}Client" + client() + gameDirectory = project.file('run') + systemProperty 'neoforge.enabledGameTestNamespaces', mod_id } server { - taskName "${project.name}Server" + server() + gameDirectory = project.file('run') + programArgument '--nogui' + systemProperty 'neoforge.enabledGameTestNamespaces', mod_id } gameTestServer { - taskName "${project.name}GameTest" - property 'forge.enabledGameTestNamespaces', mod_id + type = "gameTestServer" + gameDirectory = project.file('run') + systemProperty 'neoforge.enabledGameTestNamespaces', mod_id } data { - workingDirectory project.file('run-data') - taskName "${project.name}Data" - args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') + data() + gameDirectory = project.file('run-data') + programArguments.addAll '--mod', mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() + } + } + + mods { + "${mod_id}" { + sourceSet(sourceSets.main) } } } sourceSets.main.resources { srcDir 'src/generated/resources' } -dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" -} - tasks.named('jar', Jar).configure { manifest { attributes([ @@ -70,9 +74,9 @@ tasks.named('processResources', ProcessResources).configure { from sourceSets.main.resources - filesMatching(['META-INF/mods.toml']) { - expand project.properties - } + filesMatching(['META-INF/neoforge.mods.toml']) { + expand project.properties + } } tasks.withType(JavaCompile).configureEach { @@ -86,16 +90,15 @@ curseforge { changelog = file('changelog.txt').canRead() ? file('changelog.txt').text : '' changelogType = 'text' releaseType = 'release' - addGameVersion 'Forge' - forge_compatible_minecraft_versions.split(",").each { + addGameVersion 'NeoForge' + neoforge_compatible_minecraft_versions.split(",").each { addGameVersion(it) } mainArtifact(jar) { - displayName = "${minecraft_version}-${mod_version} Universal" + displayName = "${minecraft_version}-${mod_version} NeoForge" } } options { javaVersionAutoDetect = false - forgeGradleIntegration = false } } diff --git a/gradle.properties b/gradle.properties index f13c1e5..acc88f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,16 @@ # WorldHandler mod_id = worldhandler mod_name = WorldHandler -mod_version = 3.5.1 -minecraft_version = 1.20.4 +mod_version = 3.5.2-neoforge +minecraft_version = 1.21.1 group = exopandora.worldhandler main_class = exopandora.worldhandler.Main author = Exopandora -# Forge -forge_version = 49.0.3 -forge_compatible_minecraft_versions = 1.20.3,1.20.4 +# NeoForge +neo_version = 21.1.225 +loader_version_range = [4,) +neoforge_compatible_minecraft_versions = 1.21.1 # Publishing curse_project_id = 228970 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 309b4e1..9bf7bd3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index 63367e0..0f2b9d9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,14 +2,14 @@ pluginManagement { repositories { gradlePluginPortal() maven { - name = 'MinecraftForge' - url = 'https://maven.minecraftforge.net/' + name = 'NeoForge' + url = 'https://maven.neoforged.net/releases' } } } plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' + id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0' } rootProject.name = 'WorldHandler' diff --git a/src/main/java/exopandora/worldhandler/WorldHandler.java b/src/main/java/exopandora/worldhandler/WorldHandler.java index f767458..fe391ea 100644 --- a/src/main/java/exopandora/worldhandler/WorldHandler.java +++ b/src/main/java/exopandora/worldhandler/WorldHandler.java @@ -7,29 +7,24 @@ import org.apache.logging.log4j.Logger; import exopandora.worldhandler.config.Config; import exopandora.worldhandler.event.ClientEventHandler; -import exopandora.worldhandler.event.KeyHandler; -import exopandora.worldhandler.gui.category.Category; -import exopandora.worldhandler.gui.content.Content; -import exopandora.worldhandler.usercontent.UsercontentLoader; -import exopandora.worldhandler.util.AdvancementHelper; -import exopandora.worldhandler.util.CommandHelper; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.client.event.RegisterClientCommandsEvent; -import net.minecraftforge.client.event.RegisterClientReloadListenersEvent; -import net.minecraftforge.client.event.RegisterKeyMappingsEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.DistExecutor; -import net.minecraftforge.fml.DistExecutor.SafeRunnable; -import net.minecraftforge.fml.IExtensionPoint.DisplayTest; -import net.minecraftforge.fml.ModLoadingContext; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig.Type; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.fml.loading.FMLPaths; +import exopandora.worldhandler.event.KeyHandler; +import exopandora.worldhandler.gui.category.Category; +import exopandora.worldhandler.gui.content.Content; +import exopandora.worldhandler.usercontent.UsercontentLoader; +import exopandora.worldhandler.util.CommandHelper; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.ModContainer; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.config.ModConfig.Type; +import net.neoforged.neoforge.client.event.RegisterClientCommandsEvent; +import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.fml.loading.FMLEnvironment; +import net.neoforged.fml.loading.FMLPaths; @Mod(Main.MODID) public class WorldHandler @@ -37,44 +32,36 @@ public class WorldHandler public static final Logger LOGGER = LogManager.getLogger(); public static final Path USERCONTENT_PATH = FMLPaths.CONFIGDIR.get().resolve(Main.MODID).resolve("usercontent"); - public WorldHandler() - { - IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - ModLoadingContext modLoadingContext = ModLoadingContext.get(); - DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> new SafeRunnable() - { - @Override - public void run() - { - Config.setupDirectories(WorldHandler.USERCONTENT_PATH); - modLoadingContext.registerConfig(Type.CLIENT, Config.CLIENT_SPEC, Main.MODID + "/" + Main.MODID + ".toml"); - UsercontentLoader.load(WorldHandler.USERCONTENT_PATH); - modEventBus.addListener(WorldHandler.this::registerKeyMappingsEvent); - modEventBus.addListener(WorldHandler.this::registerClientReloadListeners); - modEventBus.addListener(Content::createRegistry); - modEventBus.addListener(Category::createRegistry); - modEventBus.addListener(Content::register); - modEventBus.addListener(Category::register); - } - }); - modLoadingContext.registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> "ANY", (remote, isServer) -> true)); - modEventBus.addListener(this::clientSetup); - modEventBus.addListener(this::commonSetup); - } + public WorldHandler(IEventBus modEventBus, ModContainer modContainer) + { + if(Dist.CLIENT.equals(FMLEnvironment.dist)) + { + Config.setupDirectories(WorldHandler.USERCONTENT_PATH); + modContainer.registerConfig(Type.CLIENT, Config.CLIENT_SPEC, Main.MODID + "/" + Main.MODID + ".toml"); + UsercontentLoader.load(WorldHandler.USERCONTENT_PATH); + modEventBus.addListener(WorldHandler.this::registerKeyMappingsEvent); + modEventBus.addListener(Content::createRegistry); + modEventBus.addListener(Category::createRegistry); + modEventBus.addListener(Content::register); + modEventBus.addListener(Category::register); + } + modEventBus.addListener(this::clientSetup); + modEventBus.addListener(this::commonSetup); + } + + @SubscribeEvent + public void clientSetup(FMLClientSetupEvent event) + { + NeoForge.EVENT_BUS.addListener(KeyHandler::keyInputEvent); + NeoForge.EVENT_BUS.addListener(ClientEventHandler::renderLevelStageEvent); + NeoForge.EVENT_BUS.addListener(ClientEventHandler::clientTickEvent); + } @SubscribeEvent - public void clientSetup(FMLClientSetupEvent event) - { - MinecraftForge.EVENT_BUS.addListener(KeyHandler::keyInputEvent); - MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::renderLevelStageEvent); - MinecraftForge.EVENT_BUS.addListener(ClientEventHandler::clientTickEvent); - } - - @SubscribeEvent - public void commonSetup(FMLCommonSetupEvent event) - { - MinecraftForge.EVENT_BUS.addListener(this::registerCommands); - } + public void commonSetup(FMLCommonSetupEvent event) + { + NeoForge.EVENT_BUS.addListener(this::registerCommands); + } @SubscribeEvent public void registerKeyMappingsEvent(RegisterKeyMappingsEvent event) @@ -85,14 +72,8 @@ public class WorldHandler } @SubscribeEvent - public void registerCommands(RegisterClientCommandsEvent event) - { - CommandHelper.registerCommands(event.getDispatcher(), event.getBuildContext()); - } - - @SubscribeEvent - public void registerClientReloadListeners(RegisterClientReloadListenersEvent event) - { - event.registerReloadListener(AdvancementHelper.getInstance()); - } -} \ No newline at end of file + public void registerCommands(RegisterClientCommandsEvent event) + { + CommandHelper.registerCommands(event.getDispatcher(), event.getBuildContext()); + } +} diff --git a/src/main/java/exopandora/worldhandler/builder/argument/Arguments.java b/src/main/java/exopandora/worldhandler/builder/argument/Arguments.java index 69bb9ef..913eaf3 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/Arguments.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/Arguments.java @@ -1,6 +1,7 @@ package exopandora.worldhandler.builder.argument; import java.util.function.Function; +import java.util.Locale; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -15,7 +16,7 @@ import exopandora.worldhandler.builder.argument.PrimitiveArgument.Operation; import exopandora.worldhandler.builder.argument.PrimitiveArgument.Relation; import exopandora.worldhandler.builder.argument.PrimitiveArgument.Type; import exopandora.worldhandler.util.EnumHelper; -import net.minecraft.Util; +import exopandora.worldhandler.util.RegistryHelper; import net.minecraft.advancements.critereon.MinMaxBounds; import net.minecraft.commands.ParserUtils; import net.minecraft.commands.arguments.EntityAnchorArgument.Anchor; @@ -160,7 +161,7 @@ public class Arguments public static PrimitiveArgument resourceLocation() { - return PrimitiveArgument.builder(string -> string.isEmpty() ? null : new ResourceLocation(string)).build(); + return PrimitiveArgument.builder(string -> string.isEmpty() ? null : ResourceLocation.parse(string)).build(); } public static ItemArgument item() @@ -262,8 +263,8 @@ public class Arguments public static PrimitiveArgument anchor() { - return PrimitiveArgument.builder(string -> EnumHelper.find(string, Anchor.values(), anchor -> anchor.name)) - .serializer(anchor -> anchor.name) + return PrimitiveArgument.builder(Anchor::getByName) + .serializer(anchor -> anchor.name().toLowerCase(Locale.ROOT)) .build(); } @@ -292,13 +293,13 @@ public class Arguments { try { - return Component.Serializer.fromJson(string); + return Component.Serializer.fromJson(string, RegistryHelper.registryAccess()); } catch(Exception e) { return Component.literal(string); } - }).serializer(Component.Serializer::toJson).build(); + }).serializer(component -> Component.Serializer.toJson(component, RegistryHelper.registryAccess())).build(); } public static PrimitiveArgument relation() @@ -355,14 +356,14 @@ public class Arguments { try { - return ParserUtils.parseJson(new StringReader(string), Style.Serializer.CODEC); + return ParserUtils.parseJson(RegistryHelper.registryAccess(), new StringReader(string), Style.Serializer.CODEC); } catch(Exception e) { return null; } }) - .serializer(style -> GSON.toJson(Util.getOrThrow(Style.Serializer.CODEC.encodeStart(JsonOps.INSTANCE, style), JsonParseException::new))) + .serializer(style -> GSON.toJson(Style.Serializer.CODEC.encodeStart(JsonOps.INSTANCE, style).getOrThrow(JsonParseException::new))) .build(); } } diff --git a/src/main/java/exopandora/worldhandler/builder/argument/BlockPredicateArgument.java b/src/main/java/exopandora/worldhandler/builder/argument/BlockPredicateArgument.java index 69dd815..177c14b 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/BlockPredicateArgument.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/BlockPredicateArgument.java @@ -16,7 +16,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.Property; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class BlockPredicateArgument extends TagArgument { @@ -38,7 +38,7 @@ public class BlockPredicateArgument extends TagArgument { if(state != null) { - this.resource = ForgeRegistries.BLOCKS.getKey(state.getBlock()); + this.resource = BuiltInRegistries.BLOCK.getKey(state.getBlock()); this.properties = propertiesToString(state.getValues()); } else diff --git a/src/main/java/exopandora/worldhandler/builder/argument/BlockStateArgument.java b/src/main/java/exopandora/worldhandler/builder/argument/BlockStateArgument.java index 051dd09..8fead4d 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/BlockStateArgument.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/BlockStateArgument.java @@ -9,7 +9,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class BlockStateArgument extends TagArgument { @@ -24,7 +24,7 @@ public class BlockStateArgument extends TagArgument { if(block != null) { - this.set(ForgeRegistries.BLOCKS.getValue(block)); + this.set(BuiltInRegistries.BLOCK.get(block)); } else { @@ -104,7 +104,7 @@ public class BlockStateArgument extends TagArgument StringBuilder builder = new StringBuilder(this.state.toString()); String block = this.state.getBlock().toString(); - builder.replace(0, block.length(), ForgeRegistries.BLOCKS.getKey(this.state.getBlock()).toString()); + builder.replace(0, block.length(), BuiltInRegistries.BLOCK.getKey(this.state.getBlock()).toString()); String nbt = super.serialize(); if(nbt != null && this.state.hasBlockEntity()) diff --git a/src/main/java/exopandora/worldhandler/builder/argument/EffectArgument.java b/src/main/java/exopandora/worldhandler/builder/argument/EffectArgument.java index 33c0d92..7d4d5d6 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/EffectArgument.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/EffectArgument.java @@ -5,7 +5,7 @@ import javax.annotation.Nullable; import exopandora.worldhandler.util.ResourceHelper; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffect; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class EffectArgument implements IDeserializableArgument { @@ -25,7 +25,7 @@ public class EffectArgument implements IDeserializableArgument { if(effect != null) { - this.set(ForgeRegistries.MOB_EFFECTS.getValue(effect)); + this.set(BuiltInRegistries.MOB_EFFECT.get(effect)); } else { @@ -54,7 +54,7 @@ public class EffectArgument implements IDeserializableArgument return null; } - return ForgeRegistries.MOB_EFFECTS.getKey(this.effect).toString(); + return BuiltInRegistries.MOB_EFFECT.getKey(this.effect).toString(); } @Override diff --git a/src/main/java/exopandora/worldhandler/builder/argument/EnchantmentArgument.java b/src/main/java/exopandora/worldhandler/builder/argument/EnchantmentArgument.java index d220c43..3d2846f 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/EnchantmentArgument.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/EnchantmentArgument.java @@ -2,10 +2,10 @@ package exopandora.worldhandler.builder.argument; import javax.annotation.Nullable; +import exopandora.worldhandler.util.RegistryHelper; import exopandora.worldhandler.util.ResourceHelper; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraftforge.registries.ForgeRegistries; public class EnchantmentArgument implements IDeserializableArgument { @@ -25,7 +25,7 @@ public class EnchantmentArgument implements IDeserializableArgument { if(enchantment != null) { - this.set(ForgeRegistries.ENCHANTMENTS.getValue(enchantment)); + this.set(RegistryHelper.getEnchantment(enchantment)); } else { @@ -54,7 +54,7 @@ public class EnchantmentArgument implements IDeserializableArgument return null; } - return ForgeRegistries.ENCHANTMENTS.getKey(this.enchantment).toString(); + return RegistryHelper.getEnchantmentKey(this.enchantment).toString(); } @Override diff --git a/src/main/java/exopandora/worldhandler/builder/argument/EntitySummonArgument.java b/src/main/java/exopandora/worldhandler/builder/argument/EntitySummonArgument.java index 6a563b2..d9c49a1 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/EntitySummonArgument.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/EntitySummonArgument.java @@ -10,38 +10,38 @@ import exopandora.worldhandler.util.ResourceHelper; import net.minecraft.Util; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class EntitySummonArgument implements IDeserializableArgument { private static final Map ALIASES = Util.make(new HashMap(), map -> { - map.put("RedCow", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.MOOSHROOM)); - map.put("ChickenJockey", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.CHICKEN)); - map.put("Pigman", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.PIGLIN)); - map.put("ZombiePig", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.PIGLIN)); - map.put("ZombiePigman", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.PIGLIN)); - map.put("Dog", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.WOLF)); - map.put("Dragon", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.ENDER_DRAGON)); - map.put("SnowMan", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.SNOW_GOLEM)); - map.put("LavaCube", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.MAGMA_CUBE)); - map.put("MagmaSlime", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.MAGMA_CUBE)); - map.put("LavaSlime", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.MAGMA_CUBE)); - map.put("SpiderJockey", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.SPIDER)); - map.put("VillagerGolem", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.IRON_GOLEM)); - map.put("Ozelot", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.OCELOT)); - map.put("Kitty", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.CAT)); - map.put("Kitten", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.CAT)); - map.put("TESTIFICATE", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.VILLAGER)); - map.put("Octopus", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.SQUID)); - map.put("GlowingOctopus", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.SQUID)); - map.put("Exwife", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.GHAST)); - map.put("CommandMinecart", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.COMMAND_BLOCK_MINECART)); - map.put("Wizard", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.EVOKER)); - map.put("Johnny", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.VINDICATOR)); - map.put("BabyZombie", ForgeRegistries.ENTITY_TYPES.getKey(EntityType.ZOMBIE)); + map.put("RedCow", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.MOOSHROOM)); + map.put("ChickenJockey", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.CHICKEN)); + map.put("Pigman", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.PIGLIN)); + map.put("ZombiePig", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.PIGLIN)); + map.put("ZombiePigman", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.PIGLIN)); + map.put("Dog", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.WOLF)); + map.put("Dragon", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.ENDER_DRAGON)); + map.put("SnowMan", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.SNOW_GOLEM)); + map.put("LavaCube", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.MAGMA_CUBE)); + map.put("MagmaSlime", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.MAGMA_CUBE)); + map.put("LavaSlime", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.MAGMA_CUBE)); + map.put("SpiderJockey", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.SPIDER)); + map.put("VillagerGolem", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.IRON_GOLEM)); + map.put("Ozelot", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.OCELOT)); + map.put("Kitty", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.CAT)); + map.put("Kitten", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.CAT)); + map.put("TESTIFICATE", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.VILLAGER)); + map.put("Octopus", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.SQUID)); + map.put("GlowingOctopus", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.SQUID)); + map.put("Exwife", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.GHAST)); + map.put("CommandMinecart", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.COMMAND_BLOCK_MINECART)); + map.put("Wizard", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.EVOKER)); + map.put("Johnny", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.VINDICATOR)); + map.put("BabyZombie", BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.ZOMBIE)); - ForgeRegistries.VILLAGER_PROFESSIONS.getEntries().stream().forEach(profession -> map.put(profession.getKey().location().getPath(), profession.getKey().location())); + BuiltInRegistries.VILLAGER_PROFESSION.entrySet().stream().forEach(profession -> map.put(profession.getKey().location().getPath(), profession.getKey().location())); }); private EntityType entity; @@ -67,10 +67,10 @@ public class EntitySummonArgument implements IDeserializableArgument { if(entity != null) { - EntityType type = ForgeRegistries.ENTITY_TYPES.getValue(entity); - ResourceLocation location = ForgeRegistries.ENTITY_TYPES.getKey(type); + EntityType type = BuiltInRegistries.ENTITY_TYPE.get(entity); + ResourceLocation location = BuiltInRegistries.ENTITY_TYPE.getKey(type); - if(!ForgeRegistries.ENTITY_TYPES.getDefaultKey().equals(location) || location.equals(entity)) + if(!BuiltInRegistries.ENTITY_TYPE.getDefaultKey().equals(location) || location.equals(entity)) { this.set(type); } @@ -124,7 +124,7 @@ public class EntitySummonArgument implements IDeserializableArgument return null; } - return ForgeRegistries.ENTITY_TYPES.getKey(this.entity).toString(); + return BuiltInRegistries.ENTITY_TYPE.getKey(this.entity).toString(); } @Override diff --git a/src/main/java/exopandora/worldhandler/builder/argument/ItemArgument.java b/src/main/java/exopandora/worldhandler/builder/argument/ItemArgument.java index ba73504..c5dcb20 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/ItemArgument.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/ItemArgument.java @@ -7,7 +7,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import exopandora.worldhandler.util.ItemPredicateParser; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ItemArgument extends TagArgument { @@ -27,7 +27,7 @@ public class ItemArgument extends TagArgument { if(item != null) { - this.set(ForgeRegistries.ITEMS.getValue(item)); + this.set(BuiltInRegistries.ITEM.get(item)); } else { @@ -85,10 +85,10 @@ public class ItemArgument extends TagArgument if(tag != null) { - return ForgeRegistries.ITEMS.getKey(this.item).toString() + tag; + return BuiltInRegistries.ITEM.getKey(this.item).toString() + tag; } - return ForgeRegistries.ITEMS.getKey(this.item).toString(); + return BuiltInRegistries.ITEM.getKey(this.item).toString(); } @Override diff --git a/src/main/java/exopandora/worldhandler/builder/argument/ItemPredicateArgument.java b/src/main/java/exopandora/worldhandler/builder/argument/ItemPredicateArgument.java index 4b9fbf7..d52604b 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/ItemPredicateArgument.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/ItemPredicateArgument.java @@ -7,7 +7,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import exopandora.worldhandler.util.ItemPredicateParser; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ItemPredicateArgument extends TagArgument { @@ -28,7 +28,7 @@ public class ItemPredicateArgument extends TagArgument { if(item != null) { - this.resource = ForgeRegistries.ITEMS.getKey(item); + this.resource = BuiltInRegistries.ITEM.getKey(item); } else { diff --git a/src/main/java/exopandora/worldhandler/builder/argument/tag/AbstractAttributeTag.java b/src/main/java/exopandora/worldhandler/builder/argument/tag/AbstractAttributeTag.java index e1c035e..d99bf02 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/tag/AbstractAttributeTag.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/tag/AbstractAttributeTag.java @@ -8,11 +8,11 @@ import java.util.stream.Collectors; import net.minecraft.client.resources.language.I18n; import net.minecraft.world.entity.ai.attributes.Attribute; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public abstract class AbstractAttributeTag implements ITagProvider { - public static final List ATTRIBUTES = ForgeRegistries.ATTRIBUTES.getValues().stream() + public static final List ATTRIBUTES = BuiltInRegistries.ATTRIBUTE.stream().toList().stream() .filter(attribute -> !attribute.getDescriptionId().equals(I18n.get(attribute.getDescriptionId()))) .collect(Collectors.toList()); diff --git a/src/main/java/exopandora/worldhandler/builder/argument/tag/AbstractEffectTag.java b/src/main/java/exopandora/worldhandler/builder/argument/tag/AbstractEffectTag.java index 8030936..be32dff 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/tag/AbstractEffectTag.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/tag/AbstractEffectTag.java @@ -12,7 +12,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; import net.minecraft.world.effect.MobEffect; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public abstract class AbstractEffectTag implements ITagProvider { @@ -33,7 +33,7 @@ public abstract class AbstractEffectTag implements ITagProvider CompoundTag compound = new CompoundTag(); int ticks = instance.toTicks(); - compound.putString("id", ForgeRegistries.MOB_EFFECTS.getKey(entry.getKey()).toString()); + compound.putString("id", BuiltInRegistries.MOB_EFFECT.getKey(entry.getKey()).toString()); compound.putByte("amplifier", (byte) (instance.getAmplifier() - 1)); compound.putInt("duration", ticks > 0 ? ticks : 1000000); compound.putBoolean("ambient", instance.isAmbient()); diff --git a/src/main/java/exopandora/worldhandler/builder/argument/tag/AttributeModifiersTag.java b/src/main/java/exopandora/worldhandler/builder/argument/tag/AttributeModifiersTag.java index 0aefbe8..fbc9aef 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/tag/AttributeModifiersTag.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/tag/AttributeModifiersTag.java @@ -9,7 +9,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; import net.minecraft.world.entity.ai.attributes.Attribute; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class AttributeModifiersTag extends AbstractAttributeTag { @@ -24,7 +24,7 @@ public class AttributeModifiersTag extends AbstractAttributeTag if(entry.getValue() != 0) { CompoundTag attribute = new CompoundTag(); - String id = ForgeRegistries.ATTRIBUTES.getKey(entry.getKey()).toString(); + String id = BuiltInRegistries.ATTRIBUTE.getKey(entry.getKey()).toString(); attribute.putString("AttributeName", id); attribute.putDouble("Amount", entry.getValue() / 100); diff --git a/src/main/java/exopandora/worldhandler/builder/argument/tag/AttributesTag.java b/src/main/java/exopandora/worldhandler/builder/argument/tag/AttributesTag.java index 3ed042b..0968e18 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/tag/AttributesTag.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/tag/AttributesTag.java @@ -8,7 +8,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; import net.minecraft.world.entity.ai.attributes.Attribute; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class AttributesTag extends AbstractAttributeTag { @@ -23,7 +23,7 @@ public class AttributesTag extends AbstractAttributeTag if(entry.getValue() != 0) { CompoundTag attribute = new CompoundTag(); - String id = ForgeRegistries.ATTRIBUTES.getKey(entry.getKey()).toString(); + String id = BuiltInRegistries.ATTRIBUTE.getKey(entry.getKey()).toString(); attribute.putString("Name", id); attribute.putDouble("Base", entry.getValue() / 100); diff --git a/src/main/java/exopandora/worldhandler/builder/argument/tag/DisplayTag.java b/src/main/java/exopandora/worldhandler/builder/argument/tag/DisplayTag.java index 7041fc2..120e787 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/tag/DisplayTag.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/tag/DisplayTag.java @@ -1,5 +1,6 @@ package exopandora.worldhandler.builder.argument.tag; +import exopandora.worldhandler.util.TextUtils; import exopandora.worldhandler.util.UserStylableComponent; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -19,7 +20,7 @@ public class DisplayTag implements ITagProvider if(this.name.getText() != null && !this.name.getText().isEmpty()) { - display.putString("Name", Component.Serializer.toJson(this.name)); + display.putString("Name", TextUtils.toJson(this.name)); } ListTag lore = new ListTag(); @@ -28,7 +29,7 @@ public class DisplayTag implements ITagProvider { if(this.lore[x] != null && !this.lore[x].getString().isEmpty()) { - lore.add(StringTag.valueOf(Component.Serializer.toJson(this.lore[x]))); + lore.add(StringTag.valueOf(TextUtils.toJson(this.lore[x]))); } } diff --git a/src/main/java/exopandora/worldhandler/builder/argument/tag/EnchantmentsTag.java b/src/main/java/exopandora/worldhandler/builder/argument/tag/EnchantmentsTag.java index ba1558c..c4e60a0 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/tag/EnchantmentsTag.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/tag/EnchantmentsTag.java @@ -7,11 +7,11 @@ import java.util.Set; import javax.annotation.Nullable; +import exopandora.worldhandler.util.RegistryHelper; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraftforge.registries.ForgeRegistries; public class EnchantmentsTag implements ITagProvider { @@ -29,7 +29,7 @@ public class EnchantmentsTag implements ITagProvider { CompoundTag enchantment = new CompoundTag(); - enchantment.putString("id", ForgeRegistries.ENCHANTMENTS.getKey(entry.getKey()).toString()); + enchantment.putString("id", RegistryHelper.getEnchantmentKey(entry.getKey()).toString()); enchantment.putShort("lvl", entry.getValue()); enchantments.add(enchantment); diff --git a/src/main/java/exopandora/worldhandler/builder/argument/tag/EntityTag.java b/src/main/java/exopandora/worldhandler/builder/argument/tag/EntityTag.java index 3b1c9d5..40d062b 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/tag/EntityTag.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/tag/EntityTag.java @@ -11,6 +11,7 @@ import javax.annotation.Nullable; import com.mojang.brigadier.exceptions.CommandSyntaxException; import exopandora.worldhandler.util.NBTHelper; +import exopandora.worldhandler.util.TextUtils; import exopandora.worldhandler.util.UserStylableComponent; import net.minecraft.nbt.ByteTag; import net.minecraft.nbt.CompoundTag; @@ -405,7 +406,7 @@ public class EntityTag implements ITagProvider if(this.customName.getText() != null && !this.customName.getText().isEmpty()) { - NBTHelper.append(nbt, "CustomName", StringTag.valueOf(Component.Serializer.toJson(this.customName))); + NBTHelper.append(nbt, "CustomName", StringTag.valueOf(TextUtils.toJson(this.customName))); } NBTHelper.append(nbt, this.potion); diff --git a/src/main/java/exopandora/worldhandler/builder/argument/tag/SidedSignTextTag.java b/src/main/java/exopandora/worldhandler/builder/argument/tag/SidedSignTextTag.java index 49fed27..2cd0fb2 100644 --- a/src/main/java/exopandora/worldhandler/builder/argument/tag/SidedSignTextTag.java +++ b/src/main/java/exopandora/worldhandler/builder/argument/tag/SidedSignTextTag.java @@ -4,6 +4,7 @@ import java.util.Arrays; import javax.annotation.Nonnull; +import exopandora.worldhandler.util.TextUtils; import exopandora.worldhandler.util.UserStylableComponent; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -36,7 +37,7 @@ public class SidedSignTextTag implements ITagProvider for(UserStylableComponent text : this.lines) { - messages.add(StringTag.valueOf(Component.Serializer.toJson(text))); + messages.add(StringTag.valueOf(TextUtils.toJson(text))); } CompoundTag tag = new CompoundTag(); diff --git a/src/main/java/exopandora/worldhandler/command/CommandWH.java b/src/main/java/exopandora/worldhandler/command/CommandWH.java index 540202d..e8a4017 100644 --- a/src/main/java/exopandora/worldhandler/command/CommandWH.java +++ b/src/main/java/exopandora/worldhandler/command/CommandWH.java @@ -22,7 +22,7 @@ import net.minecraft.commands.arguments.blocks.BlockPredicateArgument; import net.minecraft.commands.arguments.blocks.BlockStateArgument; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class CommandWH { @@ -58,7 +58,7 @@ public class CommandWH { BlockHelper.pos1().set(BlockHelper.getFocusedBlockPos()); BlockPos pos = BlockHelper.pos1(); - ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos)); + ResourceLocation block = BuiltInRegistries.BLOCK.getKey(BlockHelper.getBlock(pos)); CommandHelper.sendFeedback(source, "Set first position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")"); return 1; } @@ -67,7 +67,7 @@ public class CommandWH { BlockHelper.pos2().set(BlockHelper.getFocusedBlockPos()); BlockPos pos = BlockHelper.pos2(); - ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos)); + ResourceLocation block = BuiltInRegistries.BLOCK.getKey(BlockHelper.getBlock(pos)); CommandHelper.sendFeedback(source, "Set second position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")"); return 1; } diff --git a/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java b/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java index 140c483..f7033d3 100644 --- a/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java +++ b/src/main/java/exopandora/worldhandler/command/CommandWorldHandler.java @@ -17,8 +17,8 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.LevelSettings; import net.minecraft.world.level.storage.PrimaryLevelData; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.VersionChecker; +import net.neoforged.fml.ModList; +import net.neoforged.fml.VersionChecker; public class CommandWorldHandler { diff --git a/src/main/java/exopandora/worldhandler/config/Config.java b/src/main/java/exopandora/worldhandler/config/Config.java index 2b6097d..019c68c 100644 --- a/src/main/java/exopandora/worldhandler/config/Config.java +++ b/src/main/java/exopandora/worldhandler/config/Config.java @@ -7,16 +7,16 @@ import java.util.List; import org.apache.commons.lang3.tuple.Pair; -import net.minecraftforge.common.ForgeConfigSpec; +import net.neoforged.neoforge.common.ModConfigSpec; public class Config { - public static final ForgeConfigSpec CLIENT_SPEC; + public static final ModConfigSpec CLIENT_SPEC; public static final ClientConfig CLIENT; static { - Pair pair = new ForgeConfigSpec.Builder().configure(ClientConfig::new); + Pair pair = new ModConfigSpec.Builder().configure(ClientConfig::new); CLIENT_SPEC = pair.getRight(); CLIENT = pair.getLeft(); } @@ -28,7 +28,7 @@ public class Config private final ConfigCategorySkin skin; private final ConfigCategorySliders sliders; - public ClientConfig(ForgeConfigSpec.Builder builder) + public ClientConfig(ModConfigSpec.Builder builder) { this.settings = new ConfigCategorySettings(builder); this.butcher = new ConfigCategoryButcher(builder); @@ -77,7 +77,7 @@ public class Config return Config.CLIENT.getSliders(); } - protected static void set(ForgeConfigSpec.ConfigValue configValue, T value) + protected static void set(ModConfigSpec.ConfigValue configValue, T value) { if(configValue != null && value != null && (!value.equals(configValue.get()) || configValue.get() instanceof List)) { diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java b/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java index 1ce22c6..cf01118 100644 --- a/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java +++ b/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java @@ -7,15 +7,15 @@ import java.util.stream.Collectors; import com.google.common.base.Predicates; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; -import net.minecraftforge.registries.ForgeRegistries; +import net.neoforged.neoforge.common.ModConfigSpec; +import net.neoforged.neoforge.common.ModConfigSpec.ConfigValue; +import net.minecraft.core.registries.BuiltInRegistries; public class ConfigCategoryButcher { private final ConfigValue> entities; - public ConfigCategoryButcher(ForgeConfigSpec.Builder builder) + public ConfigCategoryButcher(ModConfigSpec.Builder builder) { builder.push("butcher"); @@ -63,7 +63,7 @@ public class ConfigCategoryButcher { if(string != null) { - return ForgeRegistries.ENTITY_TYPES.containsKey(ResourceLocation.tryParse(string.toString())); + return BuiltInRegistries.ENTITY_TYPE.containsKey(ResourceLocation.tryParse(string.toString())); } return false; diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java b/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java index 7d5898c..7127046 100644 --- a/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java +++ b/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java @@ -1,10 +1,10 @@ package exopandora.worldhandler.config; import exopandora.worldhandler.util.BlockPlacingMode; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; -import net.minecraftforge.common.ForgeConfigSpec.IntValue; +import net.neoforged.neoforge.common.ModConfigSpec; +import net.neoforged.neoforge.common.ModConfigSpec.BooleanValue; +import net.neoforged.neoforge.common.ModConfigSpec.ConfigValue; +import net.neoforged.neoforge.common.ModConfigSpec.IntValue; public class ConfigCategorySettings { @@ -23,7 +23,7 @@ public class ConfigCategorySettings private final IntValue midnight; private final ConfigValue blockPlacingMode; - public ConfigCategorySettings(ForgeConfigSpec.Builder builder) + public ConfigCategorySettings(ModConfigSpec.Builder builder) { builder.push("settings"); diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java b/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java index 6d986c1..4bcb721 100644 --- a/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java +++ b/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java @@ -1,9 +1,9 @@ package exopandora.worldhandler.config; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; -import net.minecraftforge.common.ForgeConfigSpec.IntValue; +import net.neoforged.neoforge.common.ModConfigSpec; +import net.neoforged.neoforge.common.ModConfigSpec.BooleanValue; +import net.neoforged.neoforge.common.ModConfigSpec.ConfigValue; +import net.neoforged.neoforge.common.ModConfigSpec.IntValue; public class ConfigCategorySkin { @@ -21,7 +21,7 @@ public class ConfigCategorySkin private final BooleanValue sharpEdges; private final BooleanValue drawBackground; - public ConfigCategorySkin(ForgeConfigSpec.Builder builder) + public ConfigCategorySkin(ModConfigSpec.Builder builder) { builder.push("skin"); diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java b/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java index a23ee68..a16beaa 100644 --- a/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java +++ b/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java @@ -1,7 +1,7 @@ package exopandora.worldhandler.config; -import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; +import net.neoforged.neoforge.common.ModConfigSpec; +import net.neoforged.neoforge.common.ModConfigSpec.DoubleValue; public class ConfigCategorySliders { @@ -15,7 +15,7 @@ public class ConfigCategorySliders private final DoubleValue maxPlayerPoints; private final DoubleValue maxTriggerValue; - public ConfigCategorySliders(ForgeConfigSpec.Builder builder) + public ConfigCategorySliders(ModConfigSpec.Builder builder) { builder.push("sliders"); diff --git a/src/main/java/exopandora/worldhandler/event/ClientEventHandler.java b/src/main/java/exopandora/worldhandler/event/ClientEventHandler.java index 006769e..2a14a60 100644 --- a/src/main/java/exopandora/worldhandler/event/ClientEventHandler.java +++ b/src/main/java/exopandora/worldhandler/event/ClientEventHandler.java @@ -13,10 +13,9 @@ import net.minecraft.client.renderer.MultiBufferSource.BufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.client.event.RenderLevelStageEvent; -import net.minecraftforge.event.TickEvent; -import net.minecraftforge.event.TickEvent.ClientTickEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.neoforged.neoforge.client.event.RenderLevelStageEvent; +import net.neoforged.neoforge.client.event.ClientTickEvent; +import net.neoforged.bus.api.SubscribeEvent; public class ClientEventHandler { @@ -59,9 +58,9 @@ public class ClientEventHandler } @SubscribeEvent - public static void clientTickEvent(ClientTickEvent event) + public static void clientTickEvent(ClientTickEvent.Pre event) { - if(TickEvent.Phase.START.equals(event.phase) && ClientEventHandler.openGui) + if(ClientEventHandler.openGui) { ClientEventHandler.openGui = false; ActionHelper.displayGui(); diff --git a/src/main/java/exopandora/worldhandler/event/KeyHandler.java b/src/main/java/exopandora/worldhandler/event/KeyHandler.java index a5dbb51..559f173 100644 --- a/src/main/java/exopandora/worldhandler/event/KeyHandler.java +++ b/src/main/java/exopandora/worldhandler/event/KeyHandler.java @@ -6,8 +6,8 @@ import exopandora.worldhandler.util.ActionHelper; import exopandora.worldhandler.util.BlockHelper; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; -import net.minecraftforge.client.event.InputEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.neoforged.neoforge.client.event.InputEvent; +import net.neoforged.bus.api.SubscribeEvent; public class KeyHandler { diff --git a/src/main/java/exopandora/worldhandler/gui/category/Categories.java b/src/main/java/exopandora/worldhandler/gui/category/Categories.java index e131db8..8e2bc15 100644 --- a/src/main/java/exopandora/worldhandler/gui/category/Categories.java +++ b/src/main/java/exopandora/worldhandler/gui/category/Categories.java @@ -15,7 +15,7 @@ public class Categories public static Category getRegisteredCategory(String name) { - Category category = Category.REGISTRY.getValue(new ResourceLocation(Main.MODID, name)); + Category category = Category.REGISTRY.get(ResourceLocation.fromNamespaceAndPath(Main.MODID, name)); if(category == null) { @@ -27,6 +27,6 @@ public class Categories public static boolean isRegistered(String name) { - return Category.REGISTRY.containsKey(new ResourceLocation(Main.MODID, name)); + return Category.REGISTRY.containsKey(ResourceLocation.fromNamespaceAndPath(Main.MODID, name)); } } diff --git a/src/main/java/exopandora/worldhandler/gui/category/Category.java b/src/main/java/exopandora/worldhandler/gui/category/Category.java index 6a5c5cf..4898257 100644 --- a/src/main/java/exopandora/worldhandler/gui/category/Category.java +++ b/src/main/java/exopandora/worldhandler/gui/category/Category.java @@ -15,21 +15,20 @@ import exopandora.worldhandler.Main; import exopandora.worldhandler.gui.content.Content; import exopandora.worldhandler.usercontent.UsercontentConfig; import exopandora.worldhandler.usercontent.UsercontentLoader; -import exopandora.worldhandler.usercontent.model.JsonTab; -import exopandora.worldhandler.util.RegistryHelper; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.NewRegistryEvent; -import net.minecraftforge.registries.RegisterEvent; -import net.minecraftforge.registries.RegistryBuilder; +import exopandora.worldhandler.usercontent.model.JsonTab; +import exopandora.worldhandler.util.RegistryHelper; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.neoforge.registries.NewRegistryEvent; +import net.neoforged.neoforge.registries.RegisterEvent; +import net.neoforged.neoforge.registries.RegistryBuilder; public class Category { - public static IForgeRegistry REGISTRY; - public static final ResourceKey> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(Main.MODID, "category")); + public static Registry REGISTRY; + public static final ResourceKey> REGISTRY_KEY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(Main.MODID, "category")); public static final Map> DEFAULT_CATEGORIES = new CategoriesBuilder() .add("main", "main", "containers", "multiplayer") .add("entities", "summon", "butcher") @@ -65,7 +64,7 @@ public class Category public Category add(int index, String key) { - return this.add(index, new ResourceLocation(Main.MODID, key)); + return this.add(index, ResourceLocation.fromNamespaceAndPath(Main.MODID, key)); } public List getContents() @@ -81,16 +80,13 @@ public class Category @Nullable public Content getContent(int index) { - return Content.REGISTRY.getValue(this.contents.get(index)); + return Content.REGISTRY.get(this.contents.get(index)); } - @SubscribeEvent - public static void createRegistry(NewRegistryEvent event) - { - event.create(new RegistryBuilder() - .setName(REGISTRY_KEY.location()) - .disableSaving() - .disableSync(), registry -> REGISTRY = registry); + @SubscribeEvent + public static void createRegistry(NewRegistryEvent event) + { + REGISTRY = event.create(new RegistryBuilder(REGISTRY_KEY).sync(false)); } @SubscribeEvent @@ -102,8 +98,8 @@ public class Category { RegistryHelper.register(event, REGISTRY_KEY, entry.getKey(), () -> { - var keys = entry.getValue().stream() - .map(key -> new ResourceLocation(Main.MODID, key)) + var keys = entry.getValue().stream() + .map(key -> ResourceLocation.fromNamespaceAndPath(Main.MODID, key)) .collect(Collectors.toList()); return new Category(keys); }); @@ -125,7 +121,7 @@ public class Category { if(!Categories.isRegistered(tab.getCategory())) { - RegistryHelper.register(event, REGISTRY_KEY, tab.getCategory(), () -> new Category(new ResourceLocation(Main.MODID, id))); + RegistryHelper.register(event, REGISTRY_KEY, tab.getCategory(), () -> new Category(ResourceLocation.fromNamespaceAndPath(Main.MODID, id))); } else { diff --git a/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandler.java b/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandler.java index 6c7f1cc..5bb43e7 100644 --- a/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandler.java +++ b/src/main/java/exopandora/worldhandler/gui/container/impl/GuiWorldHandler.java @@ -42,7 +42,7 @@ public class GuiWorldHandler extends Container widgets.add(new WidgetCommandSyntax()); widgets.add(new WidgetShortcuts()); }); - private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation("textures/gui/demo_background.png"); + private static final ResourceLocation BACKGROUND_TEXTURE = ResourceLocation.parse("textures/gui/demo_background.png"); private final Content content; diff --git a/src/main/java/exopandora/worldhandler/gui/content/Content.java b/src/main/java/exopandora/worldhandler/gui/content/Content.java index 50df5ce..25539df 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/Content.java +++ b/src/main/java/exopandora/worldhandler/gui/content/Content.java @@ -35,28 +35,24 @@ import exopandora.worldhandler.gui.content.impl.ContentUsercontent; import exopandora.worldhandler.gui.content.impl.ContentWorldInfo; import exopandora.worldhandler.usercontent.UsercontentLoader; import exopandora.worldhandler.util.RegistryHelper; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.NewRegistryEvent; -import net.minecraftforge.registries.RegisterEvent; -import net.minecraftforge.registries.RegistryBuilder; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.neoforge.registries.NewRegistryEvent; +import net.neoforged.neoforge.registries.RegisterEvent; +import net.neoforged.neoforge.registries.RegistryBuilder; public abstract class Content implements IContent { - public static IForgeRegistry REGISTRY; - public static final ResourceKey> REGISTRY_KEY = ResourceKey.createRegistryKey(new ResourceLocation(Main.MODID, "content")); + public static Registry REGISTRY; + public static final ResourceKey> REGISTRY_KEY = ResourceKey.createRegistryKey(ResourceLocation.fromNamespaceAndPath(Main.MODID, "content")); - @SubscribeEvent - public static void createRegistry(NewRegistryEvent event) - { - event.create(new RegistryBuilder() - .setName(REGISTRY_KEY.location()) - .disableSaving() - .disableSync(), registry -> REGISTRY = registry); - } + @SubscribeEvent + public static void createRegistry(NewRegistryEvent event) + { + REGISTRY = event.create(new RegistryBuilder(REGISTRY_KEY).sync(false)); + } @SubscribeEvent public static void register(RegisterEvent event) diff --git a/src/main/java/exopandora/worldhandler/gui/content/Contents.java b/src/main/java/exopandora/worldhandler/gui/content/Contents.java index a197ab2..dda881e 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/Contents.java +++ b/src/main/java/exopandora/worldhandler/gui/content/Contents.java @@ -46,7 +46,7 @@ public class Contents public static Content getRegisteredContent(String name) { - Content content = Content.REGISTRY.getValue(new ResourceLocation(Main.MODID, name)); + Content content = Content.REGISTRY.get(ResourceLocation.fromNamespaceAndPath(Main.MODID, name)); if(content == null) { @@ -58,6 +58,6 @@ public class Contents public static boolean isRegistered(String name) { - return Content.REGISTRY.containsKey(new ResourceLocation(Main.MODID, name)); + return Content.REGISTRY.containsKey(ResourceLocation.fromNamespaceAndPath(Main.MODID, name)); } } \ No newline at end of file diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcher.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcher.java index 2d04f62..225e339 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcher.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcher.java @@ -26,7 +26,7 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ContentButcher extends Content { @@ -102,7 +102,7 @@ public class ContentButcher extends Content container.addRenderableWidget(slaughter = new GuiButtonBase(x + 58, y + 48, 114, 20, Component.translatable("gui.worldhandler.butcher.slaughter"), () -> { - Collection> entities = Config.getButcher().getEntities().stream().map(ForgeRegistries.ENTITY_TYPES::getValue).filter(Predicates.notNull()).collect(Collectors.toList()); + Collection> entities = Config.getButcher().getEntities().stream().map(BuiltInRegistries.ENTITY_TYPE::get).filter(Predicates.notNull()).collect(Collectors.toList()); ContentButcher.slaughter(container.getPlayer(), entities, Integer.parseInt(this.radius)); })); slaughter.active = enabled && !Config.getButcher().getEntities().isEmpty(); @@ -132,7 +132,7 @@ public class ContentButcher extends Content { KillCommandBuilder kill = new KillCommandBuilder(); kill.targets().setSelectorType(SelectorTypes.ALL_ENTITIES); - kill.targets().setType(ForgeRegistries.ENTITY_TYPES.getKey(entity)); + kill.targets().setType(BuiltInRegistries.ENTITY_TYPE.getKey(entity)); kill.targets().setDistanceMax(radius); CommandHelper.sendCommand(username, kill, KillCommandBuilder.Label.KILL_TARGETS); } diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcherPresets.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcherPresets.java index a301483..7023f40 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcherPresets.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcherPresets.java @@ -9,7 +9,7 @@ import exopandora.worldhandler.util.ActionHelper; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ContentButcherPresets extends ContentChild { @@ -42,22 +42,22 @@ public class ContentButcherPresets extends ContentChild container.addRenderableWidget(new GuiButtonBase(x + 58, y, 114, 20, Component.translatable("gui.worldhandler.butcher.presets.passive_mobs"), () -> { - ContentButcher.slaughter(container.getPlayer(), ForgeRegistries.ENTITY_TYPES.getValues().stream().filter(entity -> !MobCategory.MONSTER.equals(entity.getCategory()) && !MobCategory.MISC.equals(entity.getCategory())).collect(Collectors.toList()), this.radius); + ContentButcher.slaughter(container.getPlayer(), BuiltInRegistries.ENTITY_TYPE.stream().toList().stream().filter(entity -> !MobCategory.MONSTER.equals(entity.getCategory()) && !MobCategory.MISC.equals(entity.getCategory())).collect(Collectors.toList()), this.radius); ActionHelper.open(this.getParentContent()); })); container.addRenderableWidget(new GuiButtonBase(x + 58, y + 24, 114, 20, Component.translatable("gui.worldhandler.butcher.presets.hostile_mobs"), () -> { - ContentButcher.slaughter(container.getPlayer(), ForgeRegistries.ENTITY_TYPES.getValues().stream().filter(entity -> MobCategory.MONSTER.equals(entity.getCategory())).collect(Collectors.toList()), this.radius); + ContentButcher.slaughter(container.getPlayer(), BuiltInRegistries.ENTITY_TYPE.stream().toList().stream().filter(entity -> MobCategory.MONSTER.equals(entity.getCategory())).collect(Collectors.toList()), this.radius); ActionHelper.open(this.getParentContent()); })); container.addRenderableWidget(new GuiButtonBase(x + 58, y + 48, 114, 20, Component.translatable("gui.worldhandler.butcher.presets.players"), () -> { - ContentButcher.slaughter(container.getPlayer(), ForgeRegistries.ENTITY_TYPES.getValues().stream().filter(entity -> EntityType.PLAYER.equals(entity)).collect(Collectors.toList()), this.radius); + ContentButcher.slaughter(container.getPlayer(), BuiltInRegistries.ENTITY_TYPE.stream().toList().stream().filter(entity -> EntityType.PLAYER.equals(entity)).collect(Collectors.toList()), this.radius); ActionHelper.open(this.getParentContent()); })); container.addRenderableWidget(new GuiButtonBase(x + 58, y + 72, 114, 20, Component.translatable("gui.worldhandler.butcher.presets.entities"), () -> { - ContentButcher.slaughter(container.getPlayer(), ForgeRegistries.ENTITY_TYPES.getValues().stream().filter(entity -> MobCategory.MISC.equals(entity.getCategory()) && !EntityType.PLAYER.equals(entity)).collect(Collectors.toList()), this.radius); + ContentButcher.slaughter(container.getPlayer(), BuiltInRegistries.ENTITY_TYPE.stream().toList().stream().filter(entity -> MobCategory.MISC.equals(entity.getCategory()) && !EntityType.PLAYER.equals(entity)).collect(Collectors.toList()), this.radius); ActionHelper.open(this.getParentContent()); })); } diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcherSettings.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcherSettings.java index b1c719d..0f432a2 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcherSettings.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentButcherSettings.java @@ -15,7 +15,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ContentButcherSettings extends ContentChild { @@ -24,7 +24,7 @@ public class ContentButcherSettings extends ContentChild @Override public void initGui(Container container, int x, int y) { - List> list = ForgeRegistries.ENTITY_TYPES.getValues().stream().filter(EntityType::canSummon).collect(Collectors.toList()); + List> list = BuiltInRegistries.ENTITY_TYPE.stream().toList().stream().filter(EntityType::canSummon).collect(Collectors.toList()); MenuPageList> entities = new MenuPageList>(x, y, list, 114, 20, 3, container, new ILogicPageList>() { @@ -37,13 +37,13 @@ public class ContentButcherSettings extends ContentChild @Override public MutableComponent toTooltip(EntityType item) { - return Component.literal(ForgeRegistries.ENTITY_TYPES.getKey(item).toString()); + return Component.literal(BuiltInRegistries.ENTITY_TYPE.getKey(item).toString()); } @Override public void onClick(EntityType item) { - ContentButcherSettings.this.entity = ForgeRegistries.ENTITY_TYPES.getKey(item); + ContentButcherSettings.this.entity = BuiltInRegistries.ENTITY_TYPE.getKey(item); container.initButtons(); } diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentChangeWorld.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentChangeWorld.java index d695058..41a5c50 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentChangeWorld.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentChangeWorld.java @@ -11,12 +11,13 @@ import exopandora.worldhandler.util.IConnection.DedicatedConnection; import exopandora.worldhandler.util.IConnection.IntegratedConnection; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.ConnectScreen; -import net.minecraft.client.gui.screens.GenericDirtMessageScreen; +import net.minecraft.client.gui.screens.GenericMessageScreen; import net.minecraft.client.gui.screens.TitleScreen; import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen; import net.minecraft.client.gui.screens.multiplayer.SafetyScreen; import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen; import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.TransferState; import net.minecraft.client.multiplayer.resolver.ServerAddress; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; @@ -62,7 +63,7 @@ public class ContentChangeWorld extends ContentChild if(isIntegrated) { String folder = minecraft.getSingleplayerServer().storageSource.getLevelId(); - minecraft.disconnect(new GenericDirtMessageScreen(Component.translatable("menu.savingLevel"))); + minecraft.disconnect(new GenericMessageScreen(Component.translatable("menu.savingLevel"))); return new IntegratedConnection(folder); } else @@ -86,7 +87,7 @@ public class ContentChangeWorld extends ContentChild } else if(connection instanceof IntegratedConnection integrated) { - Minecraft.getInstance().createWorldOpenFlows().checkForBackupAndLoad(integrated.getFolder(), () -> + Minecraft.getInstance().createWorldOpenFlows().openWorld(integrated.getFolder(), () -> { Minecraft.getInstance().setScreen(new TitleScreen()); }); @@ -95,7 +96,7 @@ public class ContentChangeWorld extends ContentChild else if(connection instanceof DedicatedConnection dedicated) { ServerData data = dedicated.getData(); - ConnectScreen.startConnecting(new TitleScreen(), Minecraft.getInstance(), ServerAddress.parseString(data.ip), data, false); + ConnectScreen.startConnecting(new TitleScreen(), Minecraft.getInstance(), ServerAddress.parseString(data.ip), data, false, (TransferState) null); } } diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCommandStack.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCommandStack.java index a58274f..47583b7 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCommandStack.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCommandStack.java @@ -30,7 +30,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.block.Blocks; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ContentCommandStack extends ContentChild { @@ -59,14 +59,14 @@ public class ContentCommandStack extends ContentChild this.activatorRail.setBlockState(Blocks.ACTIVATOR_RAIL.defaultBlockState()); this.builderCommandStack.nbt().addTagProvider(this.activatorRail); - EntityTag redstoneBlock = new EntityTag(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.FALLING_BLOCK)); + EntityTag redstoneBlock = new EntityTag(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.FALLING_BLOCK)); redstoneBlock.setTime(1); redstoneBlock.setBlockState(Blocks.REDSTONE_BLOCK.defaultBlockState()); this.activatorRail.addPassenger(redstoneBlock); this.addCommand(0); - EntityTag blockRemover = new EntityTag(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.COMMAND_BLOCK_MINECART)); + EntityTag blockRemover = new EntityTag(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.COMMAND_BLOCK_MINECART)); SetBlockCommandBuilder builder = new SetBlockCommandBuilder(); builder.pos().setX(new Coordinate.Ints(Coordinate.Type.RELATIVE)); builder.pos().setY(new Coordinate.Ints(-2, Coordinate.Type.RELATIVE)); @@ -87,10 +87,10 @@ public class ContentCommandStack extends ContentChild blockRemover.setCommand(builder.toCommand(SetBlockCommandBuilder.Label.DESTROY, false)); this.activatorRail.addPassenger(blockRemover); - EntityTag entityRemover = new EntityTag(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.COMMAND_BLOCK_MINECART)); + EntityTag entityRemover = new EntityTag(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.COMMAND_BLOCK_MINECART)); KillCommandBuilder kill = new KillCommandBuilder(); kill.targets().setSelectorType(SelectorTypes.ALL_ENTITIES); - kill.targets().setType(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.COMMAND_BLOCK_MINECART)); + kill.targets().setType(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.COMMAND_BLOCK_MINECART)); kill.targets().setDistanceMax(1.0D); entityRemover.setCommand(kill.toCommand(KillCommandBuilder.Label.KILL_TARGETS, false)); this.activatorRail.addPassenger(entityRemover); @@ -246,7 +246,7 @@ public class ContentCommandStack extends ContentChild private void addCommand(int index) { - this.activatorRail.addPassenger(index + HEAD_LENGTH, new EntityTag(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.COMMAND_BLOCK_MINECART))); + this.activatorRail.addPassenger(index + HEAD_LENGTH, new EntityTag(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.COMMAND_BLOCK_MINECART))); } private void removeCommand(int index) diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCustomItem.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCustomItem.java index da57904..59d6d81 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCustomItem.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentCustomItem.java @@ -24,14 +24,15 @@ import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList; import exopandora.worldhandler.gui.widget.menu.impl.MenuColorField; import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList; import exopandora.worldhandler.util.ActionHandler; -import exopandora.worldhandler.util.ActionHelper; -import exopandora.worldhandler.util.CommandHelper; -import exopandora.worldhandler.util.TextUtils; +import exopandora.worldhandler.util.ActionHelper; +import exopandora.worldhandler.util.CommandHelper; +import exopandora.worldhandler.util.RegistryHelper; +import exopandora.worldhandler.util.TextUtils; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import net.minecraft.world.entity.ai.attributes.Attribute; -import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.world.entity.ai.attributes.Attribute; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.core.registries.BuiltInRegistries; public class ContentCustomItem extends Content { @@ -131,18 +132,18 @@ public class ContentCustomItem extends Content } else if(Page.ENCHANT.equals(this.page)) { - MenuPageList enchantments = new MenuPageList(x + 118, y, new ArrayList(ForgeRegistries.ENCHANTMENTS.getValues()), 114, 20, 3, container, new ILogicPageList() + MenuPageList enchantments = new MenuPageList(x + 118, y, new ArrayList(RegistryHelper.enchantmentValues()), 114, 20, 3, container, new ILogicPageList() { @Override public MutableComponent translate(Enchantment item) { - return Component.translatable(item.getDescriptionId()); + return RegistryHelper.getEnchantmentDescription(item).copy(); } @Override public MutableComponent toTooltip(Enchantment item) { - return Component.literal(ForgeRegistries.ENCHANTMENTS.getKey(item).toString()); + return Component.literal(RegistryHelper.getEnchantmentKey(item).toString()); } @Override @@ -154,7 +155,7 @@ public class ContentCustomItem extends Content @Override public GuiButtonBase onRegister(int x, int y, int width, int height, MutableComponent text, Enchantment item, ActionHandler actionHandler) { - return new GuiSlider(x, y, width, height, 0, Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderSimple(ForgeRegistries.ENCHANTMENTS.getKey(item).toString(), text, value -> + return new GuiSlider(x, y, width, height, 0, Config.getSliders().getMaxItemEnchantment(), 0, container, new LogicSliderSimple(RegistryHelper.getEnchantmentKey(item).toString(), text, value -> { ContentCustomItem.this.enchantments.set(item, value.shortValue()); })); @@ -187,7 +188,7 @@ public class ContentCustomItem extends Content @Override public MutableComponent toTooltip(Attribute attribute) { - return Component.literal(ForgeRegistries.ATTRIBUTES.getKey(attribute).toString()); + return Component.literal(BuiltInRegistries.ATTRIBUTE.getKey(attribute).toString()); } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEnchantment.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEnchantment.java index c674281..af8b9fe 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEnchantment.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentEnchantment.java @@ -14,13 +14,13 @@ import exopandora.worldhandler.gui.widget.button.GuiSlider; import exopandora.worldhandler.gui.widget.button.LogicSliderSimple; import exopandora.worldhandler.gui.widget.menu.impl.ILogicPageList; import exopandora.worldhandler.gui.widget.menu.impl.MenuPageList; -import exopandora.worldhandler.util.ActionHandler; -import exopandora.worldhandler.util.ActionHelper; -import exopandora.worldhandler.util.CommandHelper; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraftforge.registries.ForgeRegistries; +import exopandora.worldhandler.util.ActionHandler; +import exopandora.worldhandler.util.ActionHelper; +import exopandora.worldhandler.util.CommandHelper; +import exopandora.worldhandler.util.RegistryHelper; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.item.enchantment.Enchantment; public class ContentEnchantment extends Content { @@ -36,18 +36,18 @@ public class ContentEnchantment extends Content @Override public void initGui(Container container, int x, int y) { - MenuPageList enchantments = new MenuPageList(x, y, new ArrayList(ForgeRegistries.ENCHANTMENTS.getValues()), 114, 20, 3, container, new ILogicPageList() + MenuPageList enchantments = new MenuPageList(x, y, new ArrayList(RegistryHelper.enchantmentValues()), 114, 20, 3, container, new ILogicPageList() { @Override public MutableComponent translate(Enchantment enchantment) { - return Component.translatable(enchantment.getDescriptionId()); + return RegistryHelper.getEnchantmentDescription(enchantment).copy(); } @Override public MutableComponent toTooltip(Enchantment enchantment) { - return Component.literal(ForgeRegistries.ENCHANTMENTS.getKey(enchantment).toString()); + return Component.literal(RegistryHelper.getEnchantmentKey(enchantment).toString()); } @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentLocate.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentLocate.java index 0547d61..1d38653 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentLocate.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentLocate.java @@ -28,7 +28,7 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ContentLocate extends Content { @@ -114,7 +114,7 @@ public class ContentLocate extends Content .thenAccept(structures -> this.structures.set(structures.getList().stream() .map(Suggestion::getText) .filter(suggestion -> !suggestion.startsWith("#")) - .map(ResourceLocation::new) + .map(ResourceLocation::parse) .collect(Collectors.toList()))) .thenRun(container::init); } @@ -158,7 +158,7 @@ public class ContentLocate extends Content } else if(Page.POI.equals(this.page)) { - List pois = new ArrayList(ForgeRegistries.POI_TYPES.getKeys()); + List pois = new ArrayList(BuiltInRegistries.POINT_OF_INTEREST_TYPE.keySet()); MenuPageList list = new MenuPageList(x + 118, y, pois, 114, 20, 3, container, new ILogicPageList() { @Override diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentNoteEditor.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentNoteEditor.java index 1b5c2b6..b0bcdb4 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentNoteEditor.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentNoteEditor.java @@ -37,7 +37,7 @@ import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; public class ContentNoteEditor extends Content { - private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png"); + private static final ResourceLocation NOTE = ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/misc/note.png"); private final SetBlockCommandBuilder builderNoteEditor = new SetBlockCommandBuilder(); private final CommandPreview preview = new CommandPreview(this.builderNoteEditor, SetBlockCommandBuilder.Label.REPLACE); @@ -66,7 +66,7 @@ public class ContentNoteEditor extends Content if(this.isActive) { BlockPos pos = this.builderNoteEditor.pos().getBlockPos(); - SoundEvent sound = getSoundEvent(pos).getSoundEvent().get(); + SoundEvent sound = getSoundEvent(pos).getSoundEvent().value(); container.addRenderableWidget(new GuiButtonPiano(x - 3 + 15, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.g"), sound, 0.53F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 1))); container.addRenderableWidget(new GuiButtonPiano(x - 3 + 15 * 2, y, 14, 92, Component.translatable("gui.worldhandler.blocks.note_block_editor.a"), sound, 0.6F, Type.NORMAL, () -> this.setNote(container.getPlayer(), 3))); diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java index 0de129a..f030766 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java @@ -24,7 +24,7 @@ import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ContentPotions extends ContentChild { @@ -72,7 +72,7 @@ public class ContentPotions extends ContentChild @Override public void initGui(Container container, int x, int y) { - MenuPageList potions = new MenuPageList(x, y, new ArrayList(ForgeRegistries.MOB_EFFECTS.getValues()), 114, 20, 3, container, new ILogicPageList() + MenuPageList potions = new MenuPageList(x, y, new ArrayList(BuiltInRegistries.MOB_EFFECT.stream().toList()), 114, 20, 3, container, new ILogicPageList() { @Override public MutableComponent translate(MobEffect effect) @@ -83,7 +83,7 @@ public class ContentPotions extends ContentChild @Override public MutableComponent toTooltip(MobEffect effect) { - return Component.literal(ForgeRegistries.MOB_EFFECTS.getKey(effect).toString()); + return Component.literal(BuiltInRegistries.MOB_EFFECT.getKey(effect).toString()); } @Override @@ -163,7 +163,7 @@ public class ContentPotions extends ContentChild tag.setShowParticles(!tag.doShowParticles()); container.init(); })); - container.addRenderableWidget(new GuiSlider(x + 118, y, 114, 20, 1, Config.getSliders().getMaxPotionAmplifier(), 1, container, new LogicSliderSimple("amplifier" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potions.effect.amplifier"), value -> + container.addRenderableWidget(new GuiSlider(x + 118, y, 114, 20, 1, Config.getSliders().getMaxPotionAmplifier(), 1, container, new LogicSliderSimple("amplifier" + BuiltInRegistries.MOB_EFFECT.getKey(effect), Component.translatable("gui.worldhandler.potions.effect.amplifier"), value -> { this.builderPotion.amplifier().set((byte) (value.byteValue() - 1)); tag.setAmplifier(value.byteValue()); @@ -174,17 +174,17 @@ public class ContentPotions extends ContentChild MobEffect effect = this.builderPotion.effect().getEffect(); EffectInstance tag = this.effects.getOrCreate(effect); - container.addRenderableWidget(new GuiSlider(x + 118, y, 114, 20, 0, 59, 0, container, new LogicSliderSimple("s" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potion.time.seconds"), value -> + container.addRenderableWidget(new GuiSlider(x + 118, y, 114, 20, 0, 59, 0, container, new LogicSliderSimple("s" + BuiltInRegistries.MOB_EFFECT.getKey(effect), Component.translatable("gui.worldhandler.potion.time.seconds"), value -> { tag.setSeconds(value.intValue()); this.builderPotion.seconds().set(tag.toSeconds()); }))); - container.addRenderableWidget(new GuiSlider(x + 118, y + 24, 114, 20, 0, 59, 0, container, new LogicSliderSimple("m" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potion.time.minutes"), value -> + container.addRenderableWidget(new GuiSlider(x + 118, y + 24, 114, 20, 0, 59, 0, container, new LogicSliderSimple("m" + BuiltInRegistries.MOB_EFFECT.getKey(effect), Component.translatable("gui.worldhandler.potion.time.minutes"), value -> { tag.setMinutes(value.intValue()); this.builderPotion.seconds().set(tag.toSeconds()); }))); - container.addRenderableWidget(new GuiSlider(x + 118, y + 48, 114, 20, 0, 99, 0, container, new LogicSliderSimple("h" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potion.time.hours"), value -> + container.addRenderableWidget(new GuiSlider(x + 118, y + 48, 114, 20, 0, 99, 0, container, new LogicSliderSimple("h" + BuiltInRegistries.MOB_EFFECT.getKey(effect), Component.translatable("gui.worldhandler.potion.time.hours"), value -> { tag.setHours(value.intValue()); this.builderPotion.seconds().set(tag.toSeconds()); diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardObjectives.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardObjectives.java index 45bb458..1b6e8e4 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardObjectives.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentScoreboardObjectives.java @@ -25,8 +25,8 @@ import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; import net.minecraft.stats.StatType; import net.minecraft.stats.Stats; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.IForgeRegistry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.Registry; public class ContentScoreboardObjectives extends ContentScoreboard { @@ -63,7 +63,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard if(resource != null) { - StatType type = ForgeRegistries.STAT_TYPES.getValue(resource); + StatType type = BuiltInRegistries.STAT_TYPE.get(resource); if(type != null) { @@ -144,9 +144,9 @@ public class ContentScoreboardObjectives extends ContentScoreboard @Nullable private boolean isRegistryItem(ResourceLocation resource) { - IForgeRegistry[] registries = new IForgeRegistry[] {ForgeRegistries.BLOCKS, ForgeRegistries.ITEMS, ForgeRegistries.ENTITY_TYPES}; + Registry[] registries = new Registry[] {BuiltInRegistries.BLOCK, BuiltInRegistries.ITEM, BuiltInRegistries.ENTITY_TYPE}; - for(IForgeRegistry registry : registries) + for(Registry registry : registries) { if(registry.containsKey(resource)) { @@ -154,7 +154,7 @@ public class ContentScoreboardObjectives extends ContentScoreboard } } - return ForgeRegistries.STAT_TYPES.containsKey(resource); + return BuiltInRegistries.STAT_TYPE.containsKey(resource); } }); diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java index 8ed4a80..5a77ce9 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java @@ -57,11 +57,11 @@ import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ContentSummon extends Content { - private static final ResourceLocation BEACON_LOCATION = new ResourceLocation("textures/gui/container/beacon.png"); + private static final ResourceLocation BEACON_LOCATION = ResourceLocation.parse("textures/gui/container/beacon.png"); private static final Item[] HELMETS = { Items.AIR, @@ -246,7 +246,7 @@ public class ContentSummon extends Content @Override public MutableComponent toTooltip(Attribute attribute) { - return Component.literal(ForgeRegistries.ATTRIBUTES.getKey(attribute).toString()); + return Component.literal(BuiltInRegistries.ATTRIBUTE.getKey(attribute).toString()); } @Override @@ -345,7 +345,7 @@ public class ContentSummon extends Content for(ResourceLocation location : this.sortedEffects()) { - MobEffect effect = ForgeRegistries.MOB_EFFECTS.getValue(location); + MobEffect effect = BuiltInRegistries.MOB_EFFECT.get(location); if(effect.equals(MobEffects.HARM) || effect.equals(MobEffects.HEAL)) { @@ -357,7 +357,7 @@ public class ContentSummon extends Content button1.active = false; } - if(this.potionPage == ForgeRegistries.MOB_EFFECTS.getKeys().size() - 3) + if(this.potionPage == BuiltInRegistries.MOB_EFFECT.keySet().size() - 3) { button2.active = false; } @@ -366,11 +366,11 @@ public class ContentSummon extends Content { EffectInstance tag = this.effects.getOrCreate(effect); - container.addRenderableWidget(new GuiSlider(x + 118, y, 114, 20, 0, Config.getSliders().getMaxSummonPotionAmplifier(), 0, container, new LogicSliderSimple("amplifier" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable(effect.getDescriptionId()), value -> + container.addRenderableWidget(new GuiSlider(x + 118, y, 114, 20, 0, Config.getSliders().getMaxSummonPotionAmplifier(), 0, container, new LogicSliderSimple("amplifier" + BuiltInRegistries.MOB_EFFECT.getKey(effect), Component.translatable(effect.getDescriptionId()), value -> { tag.setAmplifier(value.byteValue()); }))); - container.addRenderableWidget(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxSummonPotionMinutes(), 0, container, new LogicSliderSimple("duration" + ForgeRegistries.MOB_EFFECTS.getKey(effect), Component.translatable("gui.worldhandler.potion.time.minutes"), value -> + container.addRenderableWidget(new GuiSlider(x + 118, y + 24, 114, 20, 0, Config.getSliders().getMaxSummonPotionMinutes(), 0, container, new LogicSliderSimple("duration" + BuiltInRegistries.MOB_EFFECT.getKey(effect), Component.translatable("gui.worldhandler.potion.time.minutes"), value -> { tag.setMinutes(value.intValue()); }))); @@ -449,12 +449,12 @@ public class ContentSummon extends Content } else if(EntityType.VILLAGER.equals(entity)) { - for(VillagerProfession profession : ForgeRegistries.VILLAGER_PROFESSIONS) + for(VillagerProfession profession : BuiltInRegistries.VILLAGER_PROFESSION) { if(StringUtils.equalsIgnoreCase(this.mob, profession.toString())) { CompoundTag villagerData = new CompoundTag(); - villagerData.putString("profession", ForgeRegistries.VILLAGER_PROFESSIONS.getKey(profession).toString()); + villagerData.putString("profession", BuiltInRegistries.VILLAGER_PROFESSION.getKey(profession).toString()); this.mutable.setKey("VillagerData"); this.mutable.setTag(villagerData); @@ -473,7 +473,7 @@ public class ContentSummon extends Content else if(EntityType.CHICKEN.equals(entity) && StringUtils.containsIgnoreCase(this.mob, "Jockey") && !this.entity.hasPassengers()) { ListTag list = new ListTag(); - EntityTag zombie = new EntityTag(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.ZOMBIE)); + EntityTag zombie = new EntityTag(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.ZOMBIE)); zombie.setIsBaby(true); list.add(zombie.value()); @@ -484,7 +484,7 @@ public class ContentSummon extends Content else if(EntityType.SPIDER.equals(entity) && StringUtils.containsIgnoreCase(this.mob, "Jockey") && !this.entity.hasPassengers()) { ListTag list = new ListTag(); - EntityTag skeleton = new EntityTag(ForgeRegistries.ENTITY_TYPES.getKey(EntityType.SKELETON)); + EntityTag skeleton = new EntityTag(BuiltInRegistries.ENTITY_TYPE.getKey(EntityType.SKELETON)); skeleton.setHandItem(0, Items.BOW); list.add(skeleton.value()); @@ -503,7 +503,7 @@ public class ContentSummon extends Content { if(Page.POTIONS.equals(this.page)) { - guiGraphics.drawString(Minecraft.getInstance().font, (this.potionPage + 1) + "/" + (ForgeRegistries.MOB_EFFECTS.getKeys().size() - 2), x + 118, y - 11, Config.getSkin().getHeadlineColor(), false); + guiGraphics.drawString(Minecraft.getInstance().font, (this.potionPage + 1) + "/" + (BuiltInRegistries.MOB_EFFECT.keySet().size() - 2), x + 118, y - 11, Config.getSkin().getHeadlineColor(), false); } else if(Page.EQUIPMENT.equals(this.page)) { @@ -529,8 +529,8 @@ public class ContentSummon extends Content private List sortedEffects() { - return ForgeRegistries.MOB_EFFECTS.getKeys().stream() - .sorted((a, b) -> I18n.get(ForgeRegistries.MOB_EFFECTS.getValue(a).getDescriptionId()).compareTo(I18n.get(ForgeRegistries.MOB_EFFECTS.getValue(b).getDescriptionId()))) + return BuiltInRegistries.MOB_EFFECT.keySet().stream() + .sorted((a, b) -> I18n.get(BuiltInRegistries.MOB_EFFECT.get(a).getDescriptionId()).compareTo(I18n.get(BuiltInRegistries.MOB_EFFECT.get(b).getDescriptionId()))) .collect(Collectors.toList()); } diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentWorldInfo.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentWorldInfo.java index df12143..89f3492 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentWorldInfo.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentWorldInfo.java @@ -39,13 +39,13 @@ public class ContentWorldInfo extends Content IntegratedServer server = Minecraft.getInstance().getSingleplayerServer(); this.posXField = new GuiHintTextField(x + 118, y + 12, 114, 20); - this.posXField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " X: " + ContentWorldInfo.format(level, object -> object.getLevelData().getXSpawn())); + this.posXField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " X: " + ContentWorldInfo.format(level, object -> object.getLevelData().getSpawnPos().getX())); this.posYField = new GuiHintTextField(x + 118, y + 36, 114, 20); - this.posYField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Y: " + ContentWorldInfo.format(level, object -> object.getLevelData().getYSpawn())); + this.posYField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Y: " + ContentWorldInfo.format(level, object -> object.getLevelData().getSpawnPos().getY())); this.posZField = new GuiHintTextField(x + 118, y + 60, 114, 20); - this.posZField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Z: " + ContentWorldInfo.format(level, object -> object.getLevelData().getZSpawn())); + this.posZField.setValue(I18n.get("gui.worldhandler.world_info.start.spawn") + " Z: " + ContentWorldInfo.format(level, object -> object.getLevelData().getSpawnPos().getZ())); this.worldField = new GuiHintTextField(x + 118, y + 12, 114, 20); this.worldField.setValue(I18n.get("gui.worldhandler.world_info.world.name") + ": " + ContentWorldInfo.format(server, object -> object.getWorldData().getLevelName())); diff --git a/src/main/java/exopandora/worldhandler/gui/widget/WidgetTabRenderer.java b/src/main/java/exopandora/worldhandler/gui/widget/WidgetTabRenderer.java index 933b3bf..20f2f94 100644 --- a/src/main/java/exopandora/worldhandler/gui/widget/WidgetTabRenderer.java +++ b/src/main/java/exopandora/worldhandler/gui/widget/WidgetTabRenderer.java @@ -20,7 +20,7 @@ import net.minecraft.util.Mth; public class WidgetTabRenderer implements IContainerWidget { - private static final ResourceLocation TAB_TEXTURE = new ResourceLocation("textures/gui/demo_background.png"); + private static final ResourceLocation TAB_TEXTURE = ResourceLocation.parse("textures/gui/demo_background.png"); private static final int SPACING = 2; private static final int WEDGE_HEIGHT = 10; diff --git a/src/main/java/exopandora/worldhandler/gui/widget/button/GuiButtonBase.java b/src/main/java/exopandora/worldhandler/gui/widget/button/GuiButtonBase.java index fef7afe..cc524ac 100644 --- a/src/main/java/exopandora/worldhandler/gui/widget/button/GuiButtonBase.java +++ b/src/main/java/exopandora/worldhandler/gui/widget/button/GuiButtonBase.java @@ -19,9 +19,9 @@ public class GuiButtonBase extends AbstractButton { protected static final WidgetSprites VANILLA_BUTTON_SPRITES = new WidgetSprites ( - new ResourceLocation(Main.MODID, "textures/skins/vanilla/button.png"), - new ResourceLocation(Main.MODID, "textures/skins/vanilla/button_disabled.png"), - new ResourceLocation(Main.MODID, "textures/skins/vanilla/button_highlighted.png") + ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/skins/vanilla/button.png"), + ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/skins/vanilla/button_disabled.png"), + ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/skins/vanilla/button_highlighted.png") ); private final ActionHandler actionHandler; diff --git a/src/main/java/exopandora/worldhandler/gui/widget/button/GuiButtonPiano.java b/src/main/java/exopandora/worldhandler/gui/widget/button/GuiButtonPiano.java index 6a4ff5b..72c453b 100644 --- a/src/main/java/exopandora/worldhandler/gui/widget/button/GuiButtonPiano.java +++ b/src/main/java/exopandora/worldhandler/gui/widget/button/GuiButtonPiano.java @@ -16,7 +16,7 @@ import net.minecraft.sounds.SoundEvent; public class GuiButtonPiano extends GuiButtonBase { - private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png"); + private static final ResourceLocation NOTE = ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/misc/note.png"); private final Type type; private final SoundEvent sound; private final float pitch; diff --git a/src/main/java/exopandora/worldhandler/gui/widget/button/GuiSlider.java b/src/main/java/exopandora/worldhandler/gui/widget/button/GuiSlider.java index 66cb761..f461574 100644 --- a/src/main/java/exopandora/worldhandler/gui/widget/button/GuiSlider.java +++ b/src/main/java/exopandora/worldhandler/gui/widget/button/GuiSlider.java @@ -17,9 +17,9 @@ import net.minecraft.resources.ResourceLocation; public class GuiSlider extends GuiButtonBase { - private static final ResourceLocation SLIDER_SPRITE = new ResourceLocation("widget/slider"); - private static final ResourceLocation SLIDER_HANDLE_SPRITE = new ResourceLocation("widget/slider_handle"); - private static final ResourceLocation SLIDER_HANDLE_HIGHLIGHTED_SPRITE = new ResourceLocation("widget/slider_handle_highlighted"); + private static final ResourceLocation SLIDER_SPRITE = ResourceLocation.parse("widget/slider"); + private static final ResourceLocation SLIDER_HANDLE_SPRITE = ResourceLocation.parse("widget/slider_handle"); + private static final ResourceLocation SLIDER_HANDLE_HIGHLIGHTED_SPRITE = ResourceLocation.parse("widget/slider_handle_highlighted"); private final Persistence persistence; private final ILogicSlider logic; private final Container container; diff --git a/src/main/java/exopandora/worldhandler/gui/widget/button/LogicSliderAttribute.java b/src/main/java/exopandora/worldhandler/gui/widget/button/LogicSliderAttribute.java index 8b04f33..f6a1d35 100644 --- a/src/main/java/exopandora/worldhandler/gui/widget/button/LogicSliderAttribute.java +++ b/src/main/java/exopandora/worldhandler/gui/widget/button/LogicSliderAttribute.java @@ -5,13 +5,13 @@ import java.util.function.Consumer; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.entity.ai.attributes.Attribute; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class LogicSliderAttribute extends LogicSliderSimple { public LogicSliderAttribute(Attribute attribute, MutableComponent text, Consumer listener) { - super(ForgeRegistries.ATTRIBUTES.getKey(attribute).toString(), text, listener); + super(BuiltInRegistries.ATTRIBUTE.getKey(attribute).toString(), text, listener); } @Override diff --git a/src/main/java/exopandora/worldhandler/usercontent/UsercontentLoader.java b/src/main/java/exopandora/worldhandler/usercontent/UsercontentLoader.java index ec4e795..27e84e5 100644 --- a/src/main/java/exopandora/worldhandler/usercontent/UsercontentLoader.java +++ b/src/main/java/exopandora/worldhandler/usercontent/UsercontentLoader.java @@ -171,7 +171,7 @@ public class UsercontentLoader private static boolean isValidPathName(Path path) { String name = path.getFileName().toString(); - boolean valid = ResourceLocation.isValidResourceLocation(name); + boolean valid = ResourceLocation.tryParse(name) != null; if(!valid) { diff --git a/src/main/java/exopandora/worldhandler/usercontent/factory/WidgetFactory.java b/src/main/java/exopandora/worldhandler/usercontent/factory/WidgetFactory.java index bcbaff4..eb26345 100644 --- a/src/main/java/exopandora/worldhandler/usercontent/factory/WidgetFactory.java +++ b/src/main/java/exopandora/worldhandler/usercontent/factory/WidgetFactory.java @@ -21,7 +21,7 @@ import exopandora.worldhandler.usercontent.model.JsonWidget; import exopandora.worldhandler.util.TextUtils; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class WidgetFactory extends AbstractWidgetFactory { @@ -54,7 +54,7 @@ public class WidgetFactory extends AbstractWidgetFactory widget.getLayout().getY() + y, widget.getLayout().getWidth(), widget.getLayout().getHeight(), - ForgeRegistries.ITEMS.getValue(new ResourceLocation(widget.getAttributes().getItem())), + BuiltInRegistries.ITEM.get(ResourceLocation.parse(widget.getAttributes().getItem())), this.getActionHandlerFactory().createActionHandler(content, widget.getAction(), container::getPlayer) ); } diff --git a/src/main/java/exopandora/worldhandler/util/AdvancementHelper.java b/src/main/java/exopandora/worldhandler/util/AdvancementHelper.java index a9596f8..874fed2 100644 --- a/src/main/java/exopandora/worldhandler/util/AdvancementHelper.java +++ b/src/main/java/exopandora/worldhandler/util/AdvancementHelper.java @@ -1,48 +1,30 @@ package exopandora.worldhandler.util; import java.util.Collection; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; +import java.util.Collections; import java.util.stream.Collectors; import net.minecraft.advancements.AdvancementHolder; +import net.minecraft.advancements.AdvancementNode; import net.minecraft.client.Minecraft; -import net.minecraft.server.ServerAdvancementManager; -import net.minecraft.server.packs.PackResources; -import net.minecraft.server.packs.PackType; -import net.minecraft.server.packs.repository.Pack; -import net.minecraft.server.packs.resources.PreparableReloadListener; -import net.minecraft.server.packs.resources.ReloadableResourceManager; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.util.Unit; -import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraft.world.level.storage.loot.LootDataManager; -import net.minecraftforge.common.crafting.conditions.ICondition.IContext; +import net.minecraft.client.multiplayer.ClientPacketListener; -public class AdvancementHelper implements PreparableReloadListener +public class AdvancementHelper { private static final AdvancementHelper INSTANCE = new AdvancementHelper(); - private final ServerAdvancementManager manager = new ServerAdvancementManager(new LootDataManager(), IContext.EMPTY); - - @Override - public CompletableFuture reload(PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) - { - return CompletableFuture.supplyAsync(() -> - { - ReloadableResourceManager serverResourceManager = new ReloadableResourceManager(PackType.SERVER_DATA); - serverResourceManager.registerReloadListener(this.manager); - return serverResourceManager; - }).thenCompose(stage::wait).thenAcceptAsync(serverResourceManager -> - { - List list = Minecraft.getInstance().getResourcePackRepository().getSelectedPacks().stream().map(Pack::open).collect(Collectors.toList()); - serverResourceManager.createReload(backgroundExecutor, gameExecutor, CompletableFuture.completedFuture(Unit.INSTANCE), list); - }); - } public Collection getAdvancements() { - return this.manager.getAllAdvancements(); + ClientPacketListener connection = Minecraft.getInstance().getConnection(); + + if(connection == null) + { + return Collections.emptyList(); + } + + return connection.getAdvancements().getTree().nodes().stream() + .map(AdvancementNode::holder) + .collect(Collectors.toList()); } public static AdvancementHelper getInstance() diff --git a/src/main/java/exopandora/worldhandler/util/BlockPredicateParser.java b/src/main/java/exopandora/worldhandler/util/BlockPredicateParser.java index 2cca58b..69d32df 100644 --- a/src/main/java/exopandora/worldhandler/util/BlockPredicateParser.java +++ b/src/main/java/exopandora/worldhandler/util/BlockPredicateParser.java @@ -15,14 +15,14 @@ import net.minecraft.nbt.TagParser; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class BlockPredicateParser { - private static final ResourceLocation AIR_RESOURCE_LOCATION = ForgeRegistries.BLOCKS.getKey(Blocks.AIR); + private static final ResourceLocation AIR_RESOURCE_LOCATION = BuiltInRegistries.BLOCK.getKey(Blocks.AIR); private final StringReader reader; private final Map vagueProperties = Maps.newHashMap(); - private ResourceLocation block = new ResourceLocation(""); + private ResourceLocation block = null; @Nullable private CompoundTag nbt; private boolean isTag; @@ -157,7 +157,7 @@ public class BlockPredicateParser public Optional getBlock() { - Block block = ForgeRegistries.BLOCKS.getValue(this.block); + Block block = BuiltInRegistries.BLOCK.get(this.block); if(Blocks.AIR.equals(block) && !AIR_RESOURCE_LOCATION.equals(this.block)) { diff --git a/src/main/java/exopandora/worldhandler/util/ItemPredicateParser.java b/src/main/java/exopandora/worldhandler/util/ItemPredicateParser.java index 6c108d3..e8c65ce 100644 --- a/src/main/java/exopandora/worldhandler/util/ItemPredicateParser.java +++ b/src/main/java/exopandora/worldhandler/util/ItemPredicateParser.java @@ -5,20 +5,23 @@ import java.util.Optional; import javax.annotation.Nullable; import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.commands.arguments.item.ItemParser; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.TagParser; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ItemPredicateParser { + private static final SimpleCommandExceptionType ERROR_NO_TAGS_ALLOWED = new SimpleCommandExceptionType(Component.translatable("argument.item.tag.disallowed")); private final StringReader reader; - private ResourceLocation item = new ResourceLocation(""); + private ResourceLocation item = null; @Nullable private CompoundTag nbt; private boolean isTag; @@ -39,7 +42,7 @@ public class ItemPredicateParser { if(!allowTags) { - throw ItemParser.ERROR_NO_TAGS_ALLOWED.createWithContext(this.reader); + throw ERROR_NO_TAGS_ALLOWED.createWithContext(this.reader); } this.readTag(); @@ -74,7 +77,7 @@ public class ItemPredicateParser public Optional getItem() { - Item item = ForgeRegistries.ITEMS.getValue(this.item); + Item item = BuiltInRegistries.ITEM.get(this.item); if(Items.AIR.equals(item)) { diff --git a/src/main/java/exopandora/worldhandler/util/NBTHelper.java b/src/main/java/exopandora/worldhandler/util/NBTHelper.java index b657b92..db526be 100644 --- a/src/main/java/exopandora/worldhandler/util/NBTHelper.java +++ b/src/main/java/exopandora/worldhandler/util/NBTHelper.java @@ -15,7 +15,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class NBTHelper { @@ -62,7 +62,7 @@ public class NBTHelper for(Item item : itemArray) { CompoundTag compound = new CompoundTag(); - compound.putString("id", ForgeRegistries.ITEMS.getKey(item).toString()); + compound.putString("id", BuiltInRegistries.ITEM.getKey(item).toString()); compound.putInt("Count", 1); list.add(compound); } diff --git a/src/main/java/exopandora/worldhandler/util/RegistryHelper.java b/src/main/java/exopandora/worldhandler/util/RegistryHelper.java index 458563a..95ade6f 100644 --- a/src/main/java/exopandora/worldhandler/util/RegistryHelper.java +++ b/src/main/java/exopandora/worldhandler/util/RegistryHelper.java @@ -1,17 +1,63 @@ package exopandora.worldhandler.util; +import java.util.Collection; import java.util.function.Supplier; import exopandora.worldhandler.Main; +import net.minecraft.client.Minecraft; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.registries.RegisterEvent; +import net.minecraft.world.item.enchantment.Enchantment; +import net.neoforged.neoforge.registries.RegisterEvent; public class RegistryHelper { public static void register(RegisterEvent event, ResourceKey> key, String location, Supplier valueSupplier) { - event.register(key, new ResourceLocation(Main.MODID, location), valueSupplier); + event.register(key, RegistryHelper.location(location), valueSupplier); + } + + public static ResourceLocation location(String location) + { + return ResourceLocation.fromNamespaceAndPath(Main.MODID, location); + } + + public static RegistryAccess registryAccess() + { + if(Minecraft.getInstance().level != null) + { + return Minecraft.getInstance().level.registryAccess(); + } + + return RegistryAccess.EMPTY; + } + + public static Registry enchantments() + { + return RegistryHelper.registryAccess().registryOrThrow(Registries.ENCHANTMENT); + } + + public static Collection enchantmentValues() + { + return RegistryHelper.enchantments().stream().toList(); + } + + public static Enchantment getEnchantment(ResourceLocation location) + { + return RegistryHelper.enchantments().get(location); + } + + public static ResourceLocation getEnchantmentKey(Enchantment enchantment) + { + return RegistryHelper.enchantments().getKey(enchantment); + } + + public static Component getEnchantmentDescription(Enchantment enchantment) + { + return enchantment.description(); } } diff --git a/src/main/java/exopandora/worldhandler/util/ResourceHelper.java b/src/main/java/exopandora/worldhandler/util/ResourceHelper.java index b20c0f4..3fc8877 100644 --- a/src/main/java/exopandora/worldhandler/util/ResourceHelper.java +++ b/src/main/java/exopandora/worldhandler/util/ResourceHelper.java @@ -5,7 +5,7 @@ import javax.annotation.Nullable; import exopandora.worldhandler.Main; import exopandora.worldhandler.config.Config; import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.registries.IForgeRegistry; +import net.minecraft.core.Registry; public class ResourceHelper { @@ -20,13 +20,13 @@ public class ResourceHelper return null; } - public static boolean isRegistered(ResourceLocation resource, IForgeRegistry registry) + public static boolean isRegistered(ResourceLocation resource, Registry registry) { return resource != null && registry != null && registry.containsKey(resource); } @Nullable - public static ResourceLocation assertRegistered(ResourceLocation resource, IForgeRegistry registry) + public static ResourceLocation assertRegistered(ResourceLocation resource, Registry registry) { if(resource != null && ResourceHelper.isRegistered(resource, registry)) { @@ -38,6 +38,6 @@ public class ResourceHelper public static ResourceLocation iconTexture() { - return new ResourceLocation(Main.MODID, "textures/icons/icons_" + Config.getSkin().getIconSize().name() + ".png"); + return ResourceLocation.fromNamespaceAndPath(Main.MODID, "textures/icons/icons_" + Config.getSkin().getIconSize().name() + ".png"); } } diff --git a/src/main/java/exopandora/worldhandler/util/ScoreboardHelper.java b/src/main/java/exopandora/worldhandler/util/ScoreboardHelper.java index d660e71..8ac05d0 100644 --- a/src/main/java/exopandora/worldhandler/util/ScoreboardHelper.java +++ b/src/main/java/exopandora/worldhandler/util/ScoreboardHelper.java @@ -14,7 +14,7 @@ import net.minecraft.stats.Stats; import net.minecraft.world.scores.Team.CollisionRule; import net.minecraft.world.scores.Team.Visibility; import net.minecraft.world.scores.criteria.ObjectiveCriteria; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.core.registries.BuiltInRegistries; public class ScoreboardHelper { @@ -44,7 +44,7 @@ public class ScoreboardHelper this.objectives.merge("minecraft", (parent, child) -> parent + "." + child); - for(StatType type : ForgeRegistries.STAT_TYPES) + for(StatType type : BuiltInRegistries.STAT_TYPE) { if(!type.equals(Stats.CUSTOM)) { @@ -55,7 +55,7 @@ public class ScoreboardHelper entries.add(new Node(this.buildKey(key))); } - this.objectives.addNode(this.buildKey(ForgeRegistries.STAT_TYPES.getKey(type)), entries); + this.objectives.addNode(this.buildKey(BuiltInRegistries.STAT_TYPE.getKey(type)), entries); } } diff --git a/src/main/java/exopandora/worldhandler/util/TextUtils.java b/src/main/java/exopandora/worldhandler/util/TextUtils.java index c94aaee..0bd60ec 100644 --- a/src/main/java/exopandora/worldhandler/util/TextUtils.java +++ b/src/main/java/exopandora/worldhandler/util/TextUtils.java @@ -13,6 +13,11 @@ public class TextUtils public static final MutableComponent ARROW_LEFT_BOLD = Component.literal("<").withStyle(ChatFormatting.BOLD); public static final MutableComponent ARROW_RIGHT_BOLD = Component.literal(">").withStyle(ChatFormatting.BOLD); + public static String toJson(Component component) + { + return Component.Serializer.toJson(component, RegistryHelper.registryAccess()); + } + public static MutableComponent stripText(MutableComponent string, int maxWidth, Font font) { return TextUtils.stripText(string, Component.empty(), maxWidth, font); diff --git a/src/main/java/exopandora/worldhandler/util/TranslationHelper.java b/src/main/java/exopandora/worldhandler/util/TranslationHelper.java index 6e3dc2a..90802e1 100644 --- a/src/main/java/exopandora/worldhandler/util/TranslationHelper.java +++ b/src/main/java/exopandora/worldhandler/util/TranslationHelper.java @@ -10,32 +10,29 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Item; -import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.level.block.Block; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.IForgeRegistry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.Registry; public class TranslationHelper { - private static final Map, Function> FORGE = new HashMap, Function>(); + private static final Map, Function> FORGE = new HashMap, Function>(); static { - registerRegistry(ForgeRegistries.BLOCKS, Block::getDescriptionId); - registerRegistry(ForgeRegistries.ITEMS, Item::getDescriptionId); - registerRegistry(ForgeRegistries.MOB_EFFECTS, MobEffect::getDescriptionId); - registerRegistry(ForgeRegistries.BIOMES, biome -> ForgeRegistries.BIOMES.getKey(biome).toLanguageKey("biome")); - registerRegistry(ForgeRegistries.ENCHANTMENTS, Enchantment::getDescriptionId); - registerRegistry(ForgeRegistries.ENTITY_TYPES, EntityType::getDescriptionId); - registerRegistry(ForgeRegistries.STAT_TYPES, stat -> "stat." + stat.toString().replace(':', '.')); - registerRegistry(ForgeRegistries.VILLAGER_PROFESSIONS, profession -> + registerRegistry(BuiltInRegistries.BLOCK, Block::getDescriptionId); + registerRegistry(BuiltInRegistries.ITEM, Item::getDescriptionId); + registerRegistry(BuiltInRegistries.MOB_EFFECT, MobEffect::getDescriptionId); + registerRegistry(BuiltInRegistries.ENTITY_TYPE, EntityType::getDescriptionId); + registerRegistry(BuiltInRegistries.STAT_TYPE, stat -> "stat." + stat.toString().replace(':', '.')); + registerRegistry(BuiltInRegistries.VILLAGER_PROFESSION, profession -> { - ResourceLocation profName = ForgeRegistries.VILLAGER_PROFESSIONS.getKey(profession); + ResourceLocation profName = BuiltInRegistries.VILLAGER_PROFESSION.getKey(profession); return EntityType.VILLAGER.getDescriptionId() + '.' + (!"minecraft".equals(profName.getNamespace()) ? profName.getNamespace() + '.' : "") + profName.getPath(); }); } - private static void registerRegistry(IForgeRegistry registry, Function mapper) + private static void registerRegistry(Registry registry, Function mapper) { FORGE.put(registry, mapper); } @@ -44,11 +41,16 @@ public class TranslationHelper @SuppressWarnings("unchecked") public static String translate(ResourceLocation resource) { - for(IForgeRegistry registry : FORGE.keySet()) + if(RegistryHelper.getEnchantment(resource) != null) + { + return RegistryHelper.getEnchantmentDescription(RegistryHelper.getEnchantment(resource)).getString(); + } + + for(Registry registry : FORGE.keySet()) { if(registry.containsKey(resource)) { - return ((Function) FORGE.get(registry)).apply((T) registry.getValue(resource)); + return ((Function) FORGE.get(registry)).apply((T) registry.get(resource)); } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 33f612b..8272b8b 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,11 +1,11 @@ -public net.minecraft.commands.arguments.blocks.BlockInput f_114664_ # tag -public net.minecraft.server.MinecraftServer f_129744_ # storageSource -public net.minecraft.client.gui.screens.OptionsScreen m_96244_(Lnet/minecraft/server/packs/repository/PackRepository;)V # updatePackList -public net.minecraft.commands.arguments.EntityAnchorArgument$Anchor f_90367_ # name -public net.minecraft.commands.arguments.coordinates.LocalCoordinates m_119908_(Lcom/mojang/brigadier/StringReader;I)D # readDouble -public net.minecraft.advancements.critereon.MinMaxBounds$Doubles (Ljava/util/Optional;Ljava/util/Optional;)V # constructor -public net.minecraft.advancements.critereon.MinMaxBounds$Ints (Ljava/util/Optional;Ljava/util/Optional;)V # constructor -public net.minecraft.network.chat.MutableComponent (Lnet/minecraft/network/chat/ComponentContents;Ljava/util/List;Lnet/minecraft/network/chat/Style;)V # constructor -public net.minecraft.commands.arguments.item.ItemParser f_120991_ # ERROR_NO_TAGS_ALLOWED -public net.minecraft.world.level.storage.PrimaryLevelData f_78443_ # settings -public net.minecraft.client.gui.components.AbstractWidget m_280138_(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/gui/Font;Lnet/minecraft/network/chat/Component;IIIII)V # renderScrollingString +public net.minecraft.commands.arguments.blocks.BlockInput tag +public net.minecraft.server.MinecraftServer storageSource +public net.minecraft.client.gui.screens.OptionsScreen updatePackList(Lnet/minecraft/server/packs/repository/PackRepository;)V +public net.minecraft.commands.arguments.EntityAnchorArgument$Anchor name +public net.minecraft.commands.arguments.coordinates.LocalCoordinates readDouble(Lcom/mojang/brigadier/StringReader;I)D +public net.minecraft.advancements.critereon.MinMaxBounds$Doubles (Ljava/util/Optional;Ljava/util/Optional;)V +public net.minecraft.advancements.critereon.MinMaxBounds$Ints (Ljava/util/Optional;Ljava/util/Optional;)V +public net.minecraft.network.chat.MutableComponent (Lnet/minecraft/network/chat/ComponentContents;Ljava/util/List;Lnet/minecraft/network/chat/Style;)V +public net.minecraft.commands.arguments.item.ItemParser ERROR_NO_TAGS_ALLOWED +public net.minecraft.world.level.storage.PrimaryLevelData settings +public net.minecraft.client.gui.components.AbstractWidget renderScrollingString(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/gui/Font;Lnet/minecraft/network/chat/Component;IIIII)V diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/neoforge.mods.toml similarity index 75% rename from src/main/resources/META-INF/mods.toml rename to src/main/resources/META-INF/neoforge.mods.toml index 696f8a3..4051c64 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[49,)" +loaderVersion="${loader_version_range}" updateJSONURL="https://raw.githubusercontent.com/Exopandora/worldhandler/master/version.json" issueTrackerURL="https://github.com/Exopandora/WorldHandler/issues" displayURL="https://minecraft.curseforge.com/projects/world-handler-command-gui" @@ -11,13 +11,20 @@ license="GPL v3.0" [[mods]] modId="worldhandler" - version="1.20.4-${version}" + version="1.21.1-${version}" displayName="World Handler" description="The World Handler provides a simple and easy to use graphical user interface for commands. It lets you create powerful and complex sub-commands alongside NBT-structures within seconds." [[dependencies.worldhandler]] modId="minecraft" - mandatory=true - versionRange="[1.20.3,)" + type="required" + versionRange="[1.21.1,1.21.2)" + ordering="NONE" + side="BOTH" + +[[dependencies.worldhandler]] + modId="neoforge" + type="required" + versionRange="[21.1.225,)" ordering="NONE" side="BOTH"