Hey guys, I'm fairly new to mc modding and I was wondering how do I import textures to my custom and existing blocks and items. They are all done but dont have a texture. What I need is how do I assign the textures to the blocks and items, how to import textures and how to register them in generell. Or is there any good tutorial for easily getting into how to import textures?
Can you provide what version of Minecraft you are modding in and, using spoilers and code block, your Block Class? Providing these will help the rest of us to understand your problem.
public class Registration {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, TutorialMod.MOD_ID);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TutorialMod.MOD_ID);
public static void register(){
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
BLOCKS.register(modEventBus);
ITEMS.register(modEventBus);
ModBlocks.register();
ModItems.register();
}
}
This is my main:
@Mod(TutorialMod.MOD_ID)
public class TutorialMod {
public static final String MOD_ID = "tutorial";
private static final Logger LOGGER = LogManager.getLogger();
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) {
LOGGER.info("HELLO from server starting");
}
}
This is my Block class:
public class ModBlocks {
public static final RegistryObject<Block> SILVER_ORE = register("silver_ore", () ->
new Block(AbstractBlock.Properties.create(Material.ROCK).hardnessAndResistance(3, 10).harvestLevel(2).sound(SoundType.STONE)));
public static final RegistryObject<Block> SILVER_BLOCK = register("silver_block", () ->
new Block(AbstractBlock.Properties.create(Material.IRON).hardnessAndResistance(3, 10).sound(SoundType.METAL)));
static void register() {}
public class ModItems {
public static final RegistryObject<Item> SILVER_INGOT = Registration.ITEMS.register("silver_ingot", () ->
new Item(new Item.Properties().group(ItemGroup.MATERIALS)));
static void register(){
}
}
Note: I did not include the imports of the libs because they are a lot and unnecessary anyway for you.
In the blockstates folder you put a .json file with the name of the block record.
name_block.json
{ "variants": {
"": {
"model": "Your_modid:block/name_block"
}
}
}
In the folder "models / block" you put a file with the same name file.json.
name_block.json
{
"parent": "block/cube_all",
"textures":
{
"all": "your_modid:blocks/name_block"
}
}
And finally the texture with the same name File.png in the "textures / blocks" folder.
name_block.png
Remember in the models folder the folder is singular block and in the textures folder it is plural blocks.
I don't understand why your registering your block items the way you are. I do it a bit differently.
public static final RegistryObject<BlockItem> SILVER_BLOCK = ITEMS.register("silver_block",
() -> new BlockItem(ModBlocks.SILVER_BLOCK.get(),
new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)));
Thanks in advance!
Can you provide what version of Minecraft you are modding in and, using spoilers and code block, your Block Class? Providing these will help the rest of us to understand your problem.
Thank you for your reply. I'm currently modding in the Minecraft version 1.16.1. Below you can see the code
This is my main:
This is my Block class:
This is Items:
Note: I did not include the imports of the libs because they are a lot and unnecessary anyway for you.
Have you made the appropriate JSON files?
JSON files look correct.
I don't understand why your registering your block items the way you are. I do it a bit differently.