Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

1.17 mod minecraft , block don't work


Sotsuu
 Share

Recommended Posts

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 by Sotsuu
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Gianka1485
Link to comment
Share on other sites

 

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);
    }
}

 

Link to comment
Share on other sites

 

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()));
		});
	}

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Posted (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 :D

And what problems can it lead for creating tools ?

Edited by Sotsuu
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 o.O

And hope you get replies on your thread , I can't help you with that i'm a complete noob as you can see 

Link to comment
Share on other sites

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 by Gianka1485
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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 by Gianka1485
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.