Sotsuu Posted August 27, 2021 Share Posted August 27, 2021 (edited) Hey , I make a topic because I created a block but when I try to break it with the needed tool , it takes a long time to break and don't drop the block , also the block has no texture, i've been trying to figure out what's wrong but I don't find if someone can help me here's my git repo : https://github.com/Sotsuu/Mod-MC/tree/main/MDG Edited August 27, 2021 by Sotsuu Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 You have to create a "loot table" of the block stored in src / main / resources / data /% modid% / loot_tables / blocks /% block_name%.json with the information you need depending on your needs (such as flowers, plants, etc), normally generator loot tables are used. If you want the block to be broken by a spike, then you create a file called "needs_% material_tool_need% _tool.json" (example: needs_diamond_tool.json, needs_wood_tool.json) and inside you enter the following values: { "replace": false, "values": [ "examplemod:example_ore" ] } For instance. (The file is stored in src / main / resources / data / minecraft / tags / blocks ) And you also need a file that specifies what kind of tool it will use, for example: pickaxe.json (With the same information I gave as an example before.) And it has to be located in src / main / resources / data / minecraft / tags / blocks / mineable. And that's it. Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 (edited) And as for the textures, the information for the block to use a specific texture is saved in a .json file that is stored in src / main / resources / assets /% modid% / blockstates (example: example_ore.json) With the following information: { "variants": { "": { "model": "examplemod:block/example_ore" } } } Just for the blocks. And you need to save another .json file which will recognize the texture in src / main / resources / assets /% modid% / models / blocks (example: example_ore.json) (The information stored varies depending on what you want to use as a texture, whether you need one texture to cover all 6 faces, or just one on the top and a different one on the bottom). And you also need to create another .json file stored in src / main / resources / assets /% modid% / models / items for the block texture when in player inventory. (example: example_ore.json) Generally, you use the following information, but it can also vary: { "parent": "examplemod:block/example_ore" } Edited August 27, 2021 by Gianka1485 Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 After seeing your work, you must also create the properties of the block, but as an item, example: public class ItemInit { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MDG.MOD_ID); public static final RegistryObject<Item> RUBY = ITEMS.register("ruby", () -> new Item(new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS))); public static final RegistryObjet<Item> RUBY_BLOCK = ITEMS.register("ruby_block", () -> new BlockItem((Block) ModBlocks.RUBY_BLOCK.get(), (new Item.Properties()).tab(CreativeModeTab.TAB_BUILDING_BLOCKS)); } And if it still does not appear, create a folder where you save the mod elements, called a block, and inside you put the information of the block. Example: package com.sotsuu.mdg.core.blocks; public class RubyBlock extends Block { public RubyBlock(Properties properties) { super(properties); } } Quote Link to comment Share on other sites More sharing options...
Sotsuu Posted August 27, 2021 Author Share Posted August 27, 2021 Hey , first , thanks for your help and your explanation are very clear, but ModBlocks.RUBY_BLOCK.get() gives me an error Once again , thank you for the help I really appreciate it Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 I think that error is caused by the following line of code in the main class: @SubscribeEvent public static void onRegisterItems(final RegistryEvent.Register<Item> event) { BlockInit.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> { event.getRegistry().register(new BlockItem(block, new Item.Properties().tab(CreativeModeTab.TAB_MISC)) .setRegistryName(block.getRegistryName())); }); } Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 Delete it and leave it like this: @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { LOGGER.info("Hello from Register Item"); } The variable "LOGGER" only serves to guide me, so it is not necessary. Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 But I think this can lead to problems later, such as problems creating tools. Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 By the way, in your case, you have the block registered in BlockInit, and I called it ModBlocks, forgive the confusion. Quote Link to comment Share on other sites More sharing options...
Sotsuu Posted August 27, 2021 Author Share Posted August 27, 2021 (edited) I deleted the old SubscribeEvent and replaced it with the one you sent me , I also changed the ModBlocks by BlockInit and it don't show any errors now , thanks And what problems can it lead for creating tools ? Edited August 27, 2021 by Sotsuu Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 3 minutes ago, Gianka1485 said: By the way, in your case, you have the block registered in BlockInit, and I called it ModBlocks, forgive the confusion. The error. Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 4 minutes ago, Sotsuu said: I deleted the old SubscribeEvent and replaced it with the one you sent me , but ModBlocks still cannot be resolved And what problems can it lead for creating tools ? I just opened a thread about that but no one has replied yet and I really don't know what to do ... haha Quote Link to comment Share on other sites More sharing options...
Sotsuu Posted August 27, 2021 Author Share Posted August 27, 2021 I launched the game , go in the world , but it tells me I can't because there is an error , in the console the errors are : Couldn't read tag list minecraft:needs_iron_tool from minecraft:tags/blocks/needs_iron_tool.json in data pack main com.google.gson.JsonSyntaxException: Missing values, expected to find a JsonArray Couldn't load tag minecraft:mineable/pickaxe as it is missing following references: minecraft:mdg.ruby_block (from main) Missing required tags: ResourceKey[minecraft:root / minecraft:block]:minecraft:mineable/pickaxe so the problem seems to be in pickaxe and needs_iron_tool but they should both be fine And hope you get replies on your thread , I can't help you with that i'm a complete noob as you can see Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 (edited) 16 minutes ago, Sotsuu said: I launched the game , go in the world , but it tells me I can't because there is an error , in the console the errors are : Couldn't read tag list minecraft:needs_iron_tool from minecraft:tags/blocks/needs_iron_tool.json in data pack main com.google.gson.JsonSyntaxException: Missing values, expected to find a JsonArray Couldn't load tag minecraft:mineable/pickaxe as it is missing following references: minecraft:mdg.ruby_block (from main) Missing required tags: ResourceKey[minecraft:root / minecraft:block]:minecraft:mineable/pickaxe so the problem seems to be in pickaxe and needs_iron_tool but they should both be fine And hope you get replies on your thread , I can't help you with that i'm a complete noob as you can see You have to put as a value inside the files, it has to be in your case: mdg:ruby_block That is, your mod id followed by a colon ":" to then put the name of the object or block (Or the id of the item) Edited August 27, 2021 by Gianka1485 Quote Link to comment Share on other sites More sharing options...
Sotsuu Posted August 27, 2021 Author Share Posted August 27, 2021 (edited) Oh , just put "." instead of ":" , that was a mistake so dumb from myself Edited August 27, 2021 by Sotsuu Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 I'm also a very newbie, my programming knowledge is almost nil (or so it was before), I spent a whole month deciphering how variables, classes, int and float values worked, and other things, and after that, now I understand pretty good most of the code, but it was like 2 weeks trying to make an ore appear in the world, hahaha ... The good thing is that I am someone that if you explain with an example he will understand almost immediately, so I It seems good to explain to others, so that they do not go through the same difficulties that I went through ... haha Quote Link to comment Share on other sites More sharing options...
Sotsuu Posted August 27, 2021 Author Share Posted August 27, 2021 Tysm for the help , I'm sure you'll soon be a really good programmer keep up the works you do and never give up , you are a nice person Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 I will do that, thank you very much, by the way, did it work? Quote Link to comment Share on other sites More sharing options...
Sotsuu Posted August 27, 2021 Author Share Posted August 27, 2021 Actually , yes but no , the texture when I place the block is here and I can break hit with the good pickaxe and it'll give me the block , but when I have it in my inventory , the name is block.mdg.ruby_block and it's invisible (But I can place it) Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 (edited) 13 minutes ago, Sotsuu said: Actually , yes but no , the texture when I place the block is here and I can break hit with the good pickaxe and it'll give me the block , but when I have it in my inventory , the name is block.mdg.ruby_block and it's invisible (But I can place it) You must register the name of the object in your lang file, the id of the item and then the translation, example: { "block.examplemod.example_block": "Example block", "item.examplemod.example_item": "Example item", "itemgroup.examplemod": "Example Mod" } These are examples of translating a block, an item and a group of items in creative mode respectively. Lang files are normally named after the language type, for example, for US English it would be en_us.json, for English for England en_uk.json, for Spanish for Spain it would be es_es.json, you can find several examples if you unzip the file from version 1.17.1.jar, in practically the same folder, lang. Edited August 27, 2021 by Gianka1485 Quote Link to comment Share on other sites More sharing options...
Sotsuu Posted August 27, 2021 Author Share Posted August 27, 2021 Everything is good now , thank you again you really helped me I couldn't find what was wrong without you Quote Link to comment Share on other sites More sharing options...
Gianka1485 Posted August 27, 2021 Share Posted August 27, 2021 Hace 20 minutos, Sotsuu dijo: Todo está bien ahora, gracias de nuevo realmente me ayudaste No pude encontrar lo que estaba mal sin ti Me alegro de haberte ayudado. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.