Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

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

 

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

 

  • Author

Hey , first , thanks for your help and your explanation are very clear, but ModBlocks.RUBY_BLOCK.get() gives me an error 1321670725_Capturedcran2021-08-27044225.thumb.png.3b5c24b010e2b55d49fde7307559d0db.png

Once again , thank you for the help I really appreciate it

 

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

 

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.

By the way, in your case, you have the block registered in BlockInit, and I called it ModBlocks, forgive the confusion.

  • Author

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

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.

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

  • Author

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 

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

  • Author

Oh , just put "." instead of ":" , that was a mistake so dumb from myself

 

 

 

Edited by Sotsuu

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

  • Author

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

 

  • Author

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)

 

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

  • Author

Everything is good now , thank you again you really helped me I couldn't find what was wrong without you

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.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.