Jump to content

urbanxx001

Members
  • Posts

    200
  • Joined

  • Last visited

Everything posted by urbanxx001

  1. Title says it all. In my ModItems class, I added the following override (which should be default game behavior tbh): @Override public UseAction getUseAction(ItemStack stack) { UseAction ReturnUseAction; if (stack.getItem().isFood()) { if (stack.hasContainerItem()) { Item stack_container = stack.getContainerItem().getItem(); if (stack_container == Items.BOWL) { ReturnUseAction = UseAction.DRINK;} else { ReturnUseAction = UseAction.EAT;} } else { ReturnUseAction = UseAction.EAT;} } else { ReturnUseAction = UseAction.NONE;} return ReturnUseAction; } For reference, the original is: public UseAction getUseAction(ItemStack stack) { return stack.getItem().isFood() ? UseAction.EAT : UseAction.NONE; } But all foods still return the eating action in-game.
  2. Choonster thank you! That's so much simpler, I had no idea about helper functions. Draco thank you as well, I didn't realize the events were clashing like that. I'll credit you all in the toml file.
  3. Well it's almost done. Even though the code window doesn't throw any errors, the block items don't register in-game. I'll leave it here in case any future modders can resolve it.
  4. Understood. I'll create another array that stores the actual ItemGroups. Think I got this now. Thanks for you and Dracos advice.
  5. Yeah. This would work: public static class RegistryArray { public static void main(DeferredRegister args) { ArrayList<DeferredRegister> block_registries = new ArrayList<DeferredRegister>(); block_registries.add(DECORATIONS); block_registries.add(BUILDING_BLOCKS); } } That's resolved, just need to convert the ith entry: ModBlocks.RegistryArray.get(i) to an ItemGroup name
  6. Sorry I'm using Matlab notation. I just mean some way in Java to get the ith registry from the list of all block registries.The registries in class ModBlocks are: public static final DeferredRegister<Block> DECORATIONS = DeferredRegister.create(ForgeRegistries.BLOCKS, Reference.MOD_ID); public static final RegistryObject<Block> BLOCK_A = DECORATIONS.register("block_a", () -> new Block(Block.Properties.create(WOOD))); public static final DeferredRegister<Block> BUILDING_BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Reference.MOD_ID); public static final RegistryObject<Block> BLOCK_B = BUILDING_BLOCKS.register("block_b", () -> new Block(Block.Properties.create(WOOD)));
  7. What I'm referring to is passing the block registry into the ModBlocks line (Where the registries are already defined in that class), which will be converted to an item_group name. The item registry ITEMS is already defined in ModItems, i.e.: @SubscribeEvent public static void createBlockItems(final RegistryEvent.Register<Item> event) { final IForgeRegistry<Item> registry = event.getRegistry(); registry_size = size of Block registries for i = 1 : registry_size BLOCK_REGISTRY_I = Registry(i) (where registry name is Building Blocks, Decorations, etc); ModBlocks.BLOCK_REGISTRY_I.getEntries().stream().map(RegistryObject::get).forEach(block -> { GROUP = (convert Block Regsitry to ItemGroup name) BLOCK_NAME = (convert block to BLOCK_NAME) final RegistryObject<Item> BLOCK_NAME = ModItems.ITEMS.register(block, () -> new BlockItem(block, new Item.Properties().group(ItemGroup.GROUP))); }); } Sorry I'm using Matlab notation for some of this
  8. I'm aware it doesn't allow blocks in different tabs still, it requires to: Call the names of registries to pass into it (why I was playing with .findRegistry()) Convert that name to an ItemGroup name Convert block to Block_Name Block_Name is a variable now since it's not the actual name of a block (Instead it would be Block_A, Block_B, etc.). Unless there's a simpler way.
  9. Oops yeah line 8 was from me toying to see how .findRegistry works. Wouldn't any enumeration method create a long list though? Is it a performance issue? I suppose it could be simplified to: @SubscribeEvent public static void createBlockItems(final RegistryEvent.Register<Item> event) { final IForgeRegistry<Item> registry = event.getRegistry(); ModBlocks.BLOCK_REGISTRY.getEntries().stream().map(RegistryObject::get).forEach(block -> { final RegistryObject<Item> BLOCK_NAME = ModItems.ITEMS.register(block, () -> new BlockItem(block, new Item.Properties().group(ItemGroup.GROUP))); }); } Where the Item Register is already defined in ModItems. But there would need to be some way to make BLOCK_NAME a dynamic variable, which I don't see happening (or maybe with a hashmap?)
  10. You mean just settle for one tab? (I know one could duplicate the code and manually change the fields that way, but a dynamic solution seems better)
  11. Many tutorials use this nifty event to create block items for a given Deferred Registry: 1 @SubscribeEvent 2 public static void createBlockItems(final RegistryEvent.Register<Item> event) { 3 4 final IForgeRegistry<Item> registry = event.getRegistry(); 5 6 ModBlocks.BLOCK_REGISTRY.getEntries().stream().map(RegistryObject::get).forEach(block -> { 7 8 IForgeRegistry blockRegistry = GameRegistry.findRegistry(Block.class).getRegistrySuperType(); 9 10 final Item.Properties properties = new Item.Properties().group(ItemGroup.GROUP); 11 final BlockItem blockItem = new BlockItem(block, properties); 12 blockItem.setRegistryName(Objects.requireNonNull(block.getRegistryName())); 13 registry.register(blockItem); 14 }); 15 } However this only works when registering all the blocks to a single creative tab. I have an idea for multiple tabs. Naming the registries in class ModBlocks after ItemGroups, surround the inside code in a for-loop to enumerate over them in line 6 (for instance, ModBlocks.DECORATIONS, ModBlocks.BUILDING_BLOCKS, etc.). Then convert the name of each registry into an actual ItemGroup to be passed in line 10. I read that GameRegistry.findRegistry(Block.class) may work for getting a registry name from a global registry, but I'm not sure. Is this idea feasible?
  12. Thank you very much! I realized I also had to delete "new" in front of TileEntityType
  13. Trying to create a tile entity in 1.16 with deferred registry is giving errors. I tried the following: public static final DeferredRegister<TileEntityType<?>> TILE_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, Main.MOD_ID); public static final RegistryObject<TileEntityType<ModChestTileEntity>> MOD_CHEST_TE = TILE_ENTITY_TYPES.register("mod_chest", () -> new TileEntityType.Builder.create(ModChestTileEntity::new, ModBlocks.MOD_CHEST))); Which is recommended by 1.15 tutorials, and is even written as such in the 1.16 source code with builder.create. The top line is fine but the second isn't. The .create isn't recognized, and neither is the ModChestTileEntity::new constructor, even though the class exists. I know that: @ObjectHolder("modname:mod_chest") public static final TileEntityType<ModChestTileEntity> MOD_CHEST_TE; static { MOD_CHEST_TE = null; } Still works, but I'd like to avoid it if possible. Thank you in advance.
  14. Ah ok. Thank you you for your advice, I’ll try starting a new project
  15. Of course BlockList FluidList FoodList ItemList PotionList Actually something to mention is that using @Mod.EventBusSubscriber(modid = Main.MOD_ID) in the main class works, even though I'm not 100%. All the tutorials I've seen use: @Mod.EventBusSubscriber(modid = Main.MOD_ID, bus = Bus.MOD) Which doesn't work in 1.16.
  16. Yes, the files exist in Gradle: net.minecraft:client:extra:1.16.1. I wonder if my main class registry is somehow affecting it: Main Class
  17. Ah no luck, still receive the same errors. Thank you anyway though.
  18. I haven’t tried that method yet, will do it later tonight. Thanks!
  19. I'm modding for version 1.16.1-32.0.75 in Intellij. When creating a world, I receive the error that currently selected datapacks prevented the world from loading. I checked the client run window and found many errors that have vanilla minecraft paths, and none are blocks associated with my mod. Some of these are: java.io.FileNotFoundException: minecraft:advancements/recipes/decorations/orange_stained_glass_pane_from_glass_pane.json java.io.FileNotFoundException: minecraft:loot_tables/blocks/stone_pressure_plate.json java.io.FileNotFoundException: minecraft:recipes/purpur_pillar.json java.io.FileNotFoundException: minecraft:advancements/recipes/decorations/painting.json The actual window is shown in this pastebin. This is only a snippet though, as the amount of errors are too large to paste. I had the errors in an older 1.16 version and figured updating the dependencies would help, but did not. Is this an issue with 1.16 being buggy or my mod? Is there a generally accepted stable version? Thanks for any advice.
  20. Because Forge and CraftTweaker share syntax. I figured it out and it was indeed <tag:minecraft:sapling>. I prefer it over individual JSON files as all the recipes can be stored in one script, which is less daunting for larger modpacks.
  21. The sacred texts! I'm going to be crucified for necro-ing this, but how would one implement "tag": "minecraft:saplings" as a substitute for ore:treeSapling (or another way that includes all modded saplings)? I don't have IDE to refer to, as I'm asking for CraftTweaker rather than mod development.
  22. Alright will do. Their tutorial is pretty cohesive though, I'm sure it's just something on my end.
  23. Here's the mods.toml modLoader="javafml" #mandatory loaderVersion="[28,)" #mandatory (28 is current forge version) modId="modtutorial" #mandatory version="0.1" #mandatory displayName="Mod Tutorial" #mandatory credits="Thanks to Harry Talks for his amazing tutorials" #optional authors="Me" #optional description='''This is my mod description''' [[dependencies.modtutorial]] #optional modId="forge" #mandatory mandatory=true #mandatory versionRange="[28,)" #mandatory ordering="NONE" side="BOTH"
  24. I'm going to tear my hair out. I'm following the tutorial series by Harry Talks on YouTube, and from the second video, my build fails when running both inside Eclipse and using RunClient.bat. At first, I encountered the following error: New Dep: net.minecraftforge:forge:1.14.4-28.2.0_mapped_snapshot_20190719-1.14.3 :compileJava > Resolve dependencies of :compileClasspath Someone recommended changing org.gradle.daemon in gradle.properties to true, and then reimporting the project. This seems to have helped some, however now I receive this error: Execution failed for task ':runClient'. > Process 'command 'C:\Program Files\Java\jdk1.8.0_241\bin\java.exe'' finished with non-zero exit value 1 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings BUILD FAILED in 6s 6 actionable tasks: 2 executed, 4 up-to-date With the following log: [10Mar2020 15:52:11.292] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [java.util.stream.ReferencePipeline$3@3f0062f8, --gameDir, ., --launchTarget, fmluserdevclient, --fml.mcpVersion, 20190829.143755, --fml.mcVersion, 1.14.4, --fml.forgeGroup, net.minecraftforge, --fml.forgeVersion, 28.2.0, --version, MOD_DEV, --assetIndex, 1.14, --assetsDir, C:\Users\Andrew\.gradle\caches\forge_gradle\assets, --username, Dev, --accessToken, ????????, --userProperties, {}] [10Mar2020 15:52:11.300] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 4.1.0+62+5bfa59b starting: java version 1.8.0_241 by Oracle Corporation [10Mar2020 15:52:12.681] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [10Mar2020 15:52:13.883] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: com.electronwill.nightconfig.core.io.ParsingException: Invalid character 'i' after key [This] [10Mar2020 15:52:13.885] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at com.electronwill.nightconfig.toml.TableParser.parseDottedKey(TableParser.java:152) [10Mar2020 15:52:13.886] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at com.electronwill.nightconfig.toml.TableParser.parseNormal(TableParser.java:55) [10Mar2020 15:52:13.887] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:44) [10Mar2020 15:52:13.887] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at com.electronwill.nightconfig.toml.TomlParser.parse(TomlParser.java:37) [10Mar2020 15:52:13.887] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:113) [10Mar2020 15:52:13.887] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:219) [10Mar2020 15:52:13.888] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at com.electronwill.nightconfig.core.io.ConfigParser.parse(ConfigParser.java:202) [10Mar2020 15:52:13.888] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at com.electronwill.nightconfig.core.file.WriteAsyncFileConfig.load(WriteAsyncFileConfig.java:138) [10Mar2020 15:52:13.889] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.moddiscovery.ModFileParser.loadModFile(ModFileParser.java:57) [10Mar2020 15:52:13.889] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.moddiscovery.ModFileParser.readModList(ModFileParser.java:51) [10Mar2020 15:52:13.890] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.moddiscovery.ModFile.identifyMods(ModFile.java:132) [10Mar2020 15:52:13.890] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer.discoverMods(ModDiscoverer.java:116) [10Mar2020 15:52:13.891] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.FMLLoader.beginModScan(FMLLoader.java:208) [10Mar2020 15:52:13.891] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.fml.loading.FMLServiceProvider.runScan(FMLServiceProvider.java:105) [10Mar2020 15:52:13.892] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServiceDecorator.runScan(TransformationServiceDecorator.java:111) [10Mar2020 15:52:13.892] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler.lambda$runScanningTransformationServices$8(TransformationServicesHandler.java:115) [10Mar2020 15:52:13.894] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267) [10Mar2020 15:52:13.895] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1628) [10Mar2020 15:52:13.895] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) [10Mar2020 15:52:13.896] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) [10Mar2020 15:52:13.896] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) [10Mar2020 15:52:13.897] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [10Mar2020 15:52:13.897] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) [10Mar2020 15:52:13.897] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler.runScanningTransformationServices(TransformationServicesHandler.java:116) [10Mar2020 15:52:13.898] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:63) [10Mar2020 15:52:13.898] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.Launcher.run(Launcher.java:75) [10Mar2020 15:52:13.899] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [10Mar2020 15:52:13.899] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) I've tried many solutions from the commenters of that video; ensuring JAVA_HOME is directed to the jdk folder; that I have a jdk of 8 (I have version 8u241); that my modid is filled in correctly and that I don't have unused lines of code in mods.toml; but nothing has helped. The maker of the tutorial suggested to someone else with the 'deprecated' issue to update their forge to a non-beta version (as the video covered a beta at the time), however as far as I know I'm running on a stable 1.14.4. If the error is that I have both Java 8 and Java 11, I'm afraid of uninstalling Java 11 if that's going to harm my computer in some way (although I read that as long as the Java 8 variable is declared first it shouldn't matter). Any help is appreciated.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.