diff --git a/build.gradle b/build.gradle index b03f2e2..f03597a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,10 @@ -buildscript { - repositories { - // These repositories are only for Gradle plugins, put any other repositories in the repository block further below - maven { url = 'https://maven.minecraftforge.net' } - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - } -} -// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. plugins { id 'eclipse' id 'maven-publish' + id 'net.minecraftforge.gradle' version '5.1.+' } -apply plugin: 'net.minecraftforge.gradle' - -version = '1.18.2-Forge-1.0.0.2' +version = '1.19-Forge-1.0.0.0' group = 'com.timlee9024.mcgltf.example' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'MCglTF-Example' @@ -38,7 +26,7 @@ minecraft { // // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'official', version: '1.18.2' + mappings channel: 'official', version: '1.19' // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. @@ -77,7 +65,6 @@ minecraft { property 'forge.logging.console.level', 'debug' - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', 'example_mcgltf_usage' mods { @@ -93,19 +80,10 @@ minecraft { gameTestServer { workingDirectory project.file('run') - // Recommended logging data for a userdev environment - // The markers can be added/remove as needed separated by commas. - // "SCAN": For mods scan. - // "REGISTRIES": For firing of registry events. - // "REGISTRYDUMP": For getting the contents of all registries. property 'forge.logging.markers', 'REGISTRIES' - // Recommended logging level for the console - // You can set various levels here. - // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'debug' - // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', 'example_mcgltf_usage' mods { @@ -151,7 +129,7 @@ dependencies { // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.18.2-40.1.14' + minecraft 'net.minecraftforge:forge:1.19-41.0.63' // Real mod deobf dependency examples - these get remapped to your current mappings // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency @@ -164,8 +142,8 @@ dependencies { // For more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html - - implementation fileTree(dir: 'libs', include: '*.jar') + + implementation fileTree(dir: 'libs', include: '*.jar') } // Example for how to get properties into the manifest for reading at runtime. diff --git a/src/main/java/com/timlee9024/mcgltf/example/Example.java b/src/main/java/com/timlee9024/mcgltf/example/Example.java index 6cb9bb8..5f84860 100644 --- a/src/main/java/com/timlee9024/mcgltf/example/Example.java +++ b/src/main/java/com/timlee9024/mcgltf/example/Example.java @@ -31,7 +31,6 @@ import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockBehaviour; @@ -41,10 +40,11 @@ import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.common.ForgeSpawnEggItem; -import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegisterEvent; @Mod("example_mcgltf_usage") public class Example { @@ -57,46 +57,34 @@ public class Example { public static class Server { @SubscribeEvent - public static void onBlockRegistryEvent(final RegistryEvent.Register event) { - EXAMPLE_BLOCK = new ExampleBlock(BlockBehaviour.Properties.of(Material.STONE).strength(0.3F).sound(SoundType.STONE).noOcclusion().isValidSpawn((a, b, c, d) -> false).isRedstoneConductor((a, b, c) -> false).isSuffocating((a, b, c) -> false).isViewBlocking((a, b, c) -> false)); - EXAMPLE_BLOCK.setRegistryName(new ResourceLocation("mcgltf", "example_block")); - event.getRegistry().register(EXAMPLE_BLOCK); - } - - @SubscribeEvent - public static void onBlockEntityTypeRegistryEvent(final RegistryEvent.Register> event) { - EXAMPLE_BLOCK_ENTITY_TYPE = BlockEntityType.Builder.of(ExampleBlockEntity::new, EXAMPLE_BLOCK).build(null); - EXAMPLE_BLOCK_ENTITY_TYPE.setRegistryName(new ResourceLocation("mcgltf", "example_blockentity")); - event.getRegistry().register(EXAMPLE_BLOCK_ENTITY_TYPE); - } - - @SubscribeEvent - public static void onEntityTypeRegistryEvent(final RegistryEvent.Register> event) { - EXAMPLE_ENTITY_TYPE = EntityType.Builder.of(ExampleEntity::new, MobCategory.MISC) - .sized(0.6F, 1.95F) - .clientTrackingRange(10) - .build("mcgltf:example_entity"); - EXAMPLE_ENTITY_TYPE.setRegistryName(new ResourceLocation("mcgltf", "example_entity")); - event.getRegistry().register(EXAMPLE_ENTITY_TYPE); - } - - @SubscribeEvent - public static void onItemRegistryEvent(final RegistryEvent.Register event) { - Item item = new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)); - item.setRegistryName(new ResourceLocation("mcgltf", "example_item")); - event.getRegistry().register(item); + public static void onEvent(RegisterEvent event) { + event.register(ForgeRegistries.Keys.BLOCKS, helper -> { + EXAMPLE_BLOCK = new ExampleBlock(BlockBehaviour.Properties.of(Material.STONE).strength(0.3F).sound(SoundType.STONE).noOcclusion().isValidSpawn((a, b, c, d) -> false).isRedstoneConductor((a, b, c) -> false).isSuffocating((a, b, c) -> false).isViewBlocking((a, b, c) -> false)); + helper.register(new ResourceLocation("mcgltf", "example_block"), EXAMPLE_BLOCK); + }); + + event.register(ForgeRegistries.Keys.BLOCK_ENTITY_TYPES, helper -> { + EXAMPLE_BLOCK_ENTITY_TYPE = BlockEntityType.Builder.of(ExampleBlockEntity::new, EXAMPLE_BLOCK).build(null); + helper.register(new ResourceLocation("mcgltf", "example_blockentity"), EXAMPLE_BLOCK_ENTITY_TYPE); + }); - BlockItem blockItem = new BlockItem(EXAMPLE_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC)); - item.setRegistryName(EXAMPLE_BLOCK.getRegistryName()); - event.getRegistry().register(blockItem); + event.register(ForgeRegistries.Keys.ENTITY_TYPES, helper -> { + EXAMPLE_ENTITY_TYPE = EntityType.Builder.of(ExampleEntity::new, MobCategory.MISC) + .sized(0.6F, 1.95F) + .clientTrackingRange(10) + .build("mcgltf:example_entity"); + helper.register(new ResourceLocation("mcgltf", "example_entity"), EXAMPLE_ENTITY_TYPE); + }); - ForgeSpawnEggItem spawnEggItem = new ForgeSpawnEggItem(() -> EXAMPLE_ENTITY_TYPE, 12422002, 5651507, new Item.Properties().tab(CreativeModeTab.TAB_MISC)); - spawnEggItem.setRegistryName(new ResourceLocation("mcgltf", "example_entity_spawn_egg")); - event.getRegistry().register(spawnEggItem); + event.register(ForgeRegistries.Keys.ITEMS, helper -> { + helper.register(new ResourceLocation("mcgltf", "example_item"), new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + helper.register(new ResourceLocation("mcgltf", "example_block"), new BlockItem(EXAMPLE_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + helper.register(new ResourceLocation("mcgltf", "example_entity_spawn_egg"), new ForgeSpawnEggItem(() -> EXAMPLE_ENTITY_TYPE, 12422002, 5651507, new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + }); } @SubscribeEvent - public static void onEvent(final EntityAttributeCreationEvent event) { + public static void onEvent(EntityAttributeCreationEvent event) { event.put(EXAMPLE_ENTITY_TYPE, ExampleEntity.createAttributes().build()); } } @@ -108,31 +96,25 @@ public static class Client { private static BlockItem blockItem; @SubscribeEvent - public static void onBlockRegistryEvent(final RegistryEvent.Register event) { - EXAMPLE_BLOCK = new ExampleBlock(BlockBehaviour.Properties.of(Material.STONE).strength(0.3F).sound(SoundType.STONE).noOcclusion().isValidSpawn((a, b, c, d) -> false).isRedstoneConductor((a, b, c) -> false).isSuffocating((a, b, c) -> false).isViewBlocking((a, b, c) -> false)); - EXAMPLE_BLOCK.setRegistryName(new ResourceLocation("mcgltf", "example_block")); - event.getRegistry().register(EXAMPLE_BLOCK); - } - - @SubscribeEvent - public static void onBlockEntityTypeRegistryEvent(final RegistryEvent.Register> event) { - EXAMPLE_BLOCK_ENTITY_TYPE = BlockEntityType.Builder.of(ExampleBlockEntity::new, EXAMPLE_BLOCK).build(null); - EXAMPLE_BLOCK_ENTITY_TYPE.setRegistryName(new ResourceLocation("mcgltf", "example_blockentity")); - event.getRegistry().register(EXAMPLE_BLOCK_ENTITY_TYPE); - } - - @SubscribeEvent - public static void onEntityTypeRegistryEvent(final RegistryEvent.Register> event) { - EXAMPLE_ENTITY_TYPE = EntityType.Builder.of(ExampleEntity::new, MobCategory.MISC) - .sized(0.6F, 1.95F) - .clientTrackingRange(10) - .build("mcgltf:example_entity"); - EXAMPLE_ENTITY_TYPE.setRegistryName(new ResourceLocation("mcgltf", "example_entity")); - event.getRegistry().register(EXAMPLE_ENTITY_TYPE); - } - - @SubscribeEvent - public static void onItemRegistryEvent(final RegistryEvent.Register event) { + public static void onEvent(RegisterEvent event) { + event.register(ForgeRegistries.Keys.BLOCKS, helper -> { + EXAMPLE_BLOCK = new ExampleBlock(BlockBehaviour.Properties.of(Material.STONE).strength(0.3F).sound(SoundType.STONE).noOcclusion().isValidSpawn((a, b, c, d) -> false).isRedstoneConductor((a, b, c) -> false).isSuffocating((a, b, c) -> false).isViewBlocking((a, b, c) -> false)); + helper.register(new ResourceLocation("mcgltf", "example_block"), EXAMPLE_BLOCK); + }); + + event.register(ForgeRegistries.Keys.BLOCK_ENTITY_TYPES, helper -> { + EXAMPLE_BLOCK_ENTITY_TYPE = BlockEntityType.Builder.of(ExampleBlockEntity::new, EXAMPLE_BLOCK).build(null); + helper.register(new ResourceLocation("mcgltf", "example_blockentity"), EXAMPLE_BLOCK_ENTITY_TYPE); + }); + + event.register(ForgeRegistries.Keys.ENTITY_TYPES, helper -> { + EXAMPLE_ENTITY_TYPE = EntityType.Builder.of(ExampleEntity::new, MobCategory.MISC) + .sized(0.6F, 1.95F) + .clientTrackingRange(10) + .build("mcgltf:example_entity"); + helper.register(new ResourceLocation("mcgltf", "example_entity"), EXAMPLE_ENTITY_TYPE); + }); + AbstractItemGltfModelReceiver itemModelReceiver = new AbstractItemGltfModelReceiver() { @Override @@ -440,40 +422,36 @@ public BlockEntityWithoutLevelRenderer getItemStackRenderer() { }; - item = new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) { + event.register(ForgeRegistries.Keys.ITEMS, helper -> { + item = new Item(new Item.Properties().tab(CreativeModeTab.TAB_MISC)) { - @Override - public void initializeClient(Consumer consumer) { - consumer.accept(renderProperties); - } - - }; - item.setRegistryName(new ResourceLocation("mcgltf", "example_item")); - event.getRegistry().register(item); - - blockItem = new BlockItem(EXAMPLE_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC)) { + @Override + public void initializeClient(Consumer consumer) { + consumer.accept(renderProperties); + } + + };; + helper.register(new ResourceLocation("mcgltf", "example_item"), item); + blockItem = new BlockItem(EXAMPLE_BLOCK, new Item.Properties().tab(CreativeModeTab.TAB_MISC)) { - @Override - public void initializeClient(Consumer consumer) { - consumer.accept(renderProperties); - } - - }; - blockItem.setRegistryName(EXAMPLE_BLOCK.getRegistryName()); - event.getRegistry().register(blockItem); - - ForgeSpawnEggItem spawnEggItem = new ForgeSpawnEggItem(() -> EXAMPLE_ENTITY_TYPE, 12422002, 5651507, new Item.Properties().tab(CreativeModeTab.TAB_MISC)); - spawnEggItem.setRegistryName(new ResourceLocation("mcgltf", "example_entity_spawn_egg")); - event.getRegistry().register(spawnEggItem); + @Override + public void initializeClient(Consumer consumer) { + consumer.accept(renderProperties); + } + + }; + helper.register(new ResourceLocation("mcgltf", "example_block"), blockItem); + helper.register(new ResourceLocation("mcgltf", "example_entity_spawn_egg"), new ForgeSpawnEggItem(() -> EXAMPLE_ENTITY_TYPE, 12422002, 5651507, new Item.Properties().tab(CreativeModeTab.TAB_MISC))); + }); } @SubscribeEvent - public static void onEvent(final EntityAttributeCreationEvent event) { + public static void onEvent(EntityAttributeCreationEvent event) { event.put(EXAMPLE_ENTITY_TYPE, ExampleEntity.createAttributes().build()); } @SubscribeEvent - public static void onEvent(final EntityRenderersEvent.RegisterRenderers event) { + public static void onEvent(EntityRenderersEvent.RegisterRenderers event) { event.registerBlockEntityRenderer(EXAMPLE_BLOCK_ENTITY_TYPE, (context) -> { ExampleBlockEntityRenderer ber = new ExampleBlockEntityRenderer(); MCglTF.getInstance().addGltfModelReceiver(ber); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index c7cb94e..25bb2b9 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -23,9 +23,9 @@ version="${file.jarVersion}" #mandatory # A display name for the mod displayName="Example MCglTF Usage" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ -updateJSONURL="https://raw.githubusercontent.com/TimLee9024/MCglTF-Example/1.18.2-Forge/updates.json" #optional +updateJSONURL="https://raw.githubusercontent.com/TimLee9024/MCglTF-Example/1.19-Forge/updates.json" #optional # A URL for the "homepage" for this mod, displayed in the mod UI -displayURL="https://github.com/TimLee9024/MCglTF-Example/tree/1.18.2-Forge/" #optional +displayURL="https://github.com/TimLee9024/MCglTF-Example/tree/1.19-Forge/" #optional # A file name (in the root of the mod JAR) containing a logo for display logoFile="examplemod.png" #optional # A text field displayed in the mod UI diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index 0398799..e777f17 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,8 @@ { "pack": { "description": "MCglTF Example resources", - "pack_format": 9 + "pack_format": 9, + "forge:resource_pack_format": 9, + "forge:data_pack_format": 10 } } diff --git a/updates.json b/updates.json index b6adb55..018d129 100644 --- a/updates.json +++ b/updates.json @@ -1,12 +1,10 @@ { "homepage": "https://github.com/TimLee9024/MCglTF-Example/releases", - "1.18.2": { - "1.18.2-Forge-1.0.0.2": "Fix registry name of block item is incorrect on server", - "1.18.2-Forge-1.0.0.1": "Fix depth test sometime not enable on GUI Item", - "1.18.2-Forge-1.0.0.0": "Initial release" + "1.19": { + "1.19-Forge-1.0.0.0": "Initial release" }, "promos": { - "1.18.2-latest": "1.18.2-Forge-1.0.0.2", - "1.18.2-recommended": "1.18.2-Forge-1.0.0.2" + "1.19-latest": "1.19-Forge-1.0.0.0", + "1.19-recommended": "1.19-Forge-1.0.0.0" } } \ No newline at end of file