Jump to content

Why my Block doesn't have graphics? [SOLVED]


Enderlook

Recommended Posts

I think I am doing something wrong, but I'm not sure. My block has the black and violet graphic as item and as block.

 

In the folder assets\extracraft\textures\blocks I have sugar_block.png.

In the folder assets\extracraft\models\block I have this sugar_block.json:

{
    "parent": "blocks/cube_all",
    "textures": {
        "all": "extracraft:blocks/sugar_block"
    }
}

In the folder assets\extracraft\blockstates I have this sugar_block.json:

{
    "forge_maker": 1,
    "defaults": {
        "model": "extracraft:sugar_block"
    },
    "variants": {
        "normal": [{"model": "extracraft:models/sugar_block"}],
        "inventory": [{}]
    }
}

And in my code I have:

	@ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block")
	public static final BlockSugar BLOCK_SUGAR = new BlockSugar("sugar_block");	

 

*extracraft is my mod id.

 

Why doesn't it work? What am I doing wrong?

Edited by Enderlook
Link to comment
Share on other sites

1 minute ago, Enderlook said:

And in my code I have:

You should set this to null, the @ObjectHolder annotation injects the instance after registration.

3 minutes ago, Enderlook said:

"normal": [{"model": "extracraft:models/sugar_block"}],

You should'nt have models/ in there

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

3 minutes ago, Animefan8888 said:

You should set this to null, the @ObjectHolder annotation injects the instance after registration.

You should'nt have models/ in there

I'm sorry, but I don't understand you.

Should I do?:

@ObjectHolder(null)
public static final BlockSugar BLOCK_SUGAR = new BlockSugar("sugar_block");

That gives an error.

And, also I should do this?

"normal": [{"model": "extracraft:sugar_block"}],

How Minecraft would know that sugar_block is inside models? Also, it still doesn't work the graphic.

Link to comment
Share on other sites

27 minutes ago, Enderlook said:

I'm sorry, but I don't understand you.

Should I do?:


@ObjectHolder(null)
public static final BlockSugar BLOCK_SUGAR = new BlockSugar("sugar_block");

That gives an error.

No. That is not what he said. He said don't assign a value to the field.

 

	@ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block")
	public static final BlockSugar BLOCK_SUGAR;

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

5 minutes ago, Draco18s said:

No. That is not what he said. He said don't assign a value to the field.

 


	@ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block")
	public static final BlockSugar BLOCK_SUGAR;

But when the value will be assigned? Would Minecraft do that automatically?

Also, if I do that, how later will I be able to register them? I can't make an array with them if they aren't assigned. Also, I couldn't iterate over that array to initialize their models, item version nor I couldn't register them.

Edited by Enderlook
Link to comment
Share on other sites

...yes, that's the whole point of the @ObjectHolder annotation.

37 minutes ago, Enderlook said:

I can't make an array with them if they aren't assigned.

Yes you can. You still need to call new somewhere and you can still use local variables.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

10 hours ago, Draco18s said:

...yes, that's the whole point of the @ObjectHolder annotation.

Yes you can. You still need to call new somewhere and you can still use local variables.

I'm sorry for my lack of knowledge, but I should do this?:

 

	@ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block")
	public static BlockSugar BLOCK_SUGAR;

	public static final CBlockBasic[] BLOCKS_BASIC = new CBlockBasic[] {
		BLOCK_SUGAR
	};
	
	public static void init() {
		BLOCK_SUGAR = new BlockSugar("sugar_block");
	}

In order to do that, I had to remove the "final" of BLOCK_SUGAR, is that okay?

 

By the way, that crashed Minecraft :(:

---- Minecraft Crash Report ----
// I just don't know what went wrong :(

Time: 8/4/18 11:11 AM
Description: Initializing game

java.lang.NullPointerException: Can't use a null-name for the registry, object null.
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:864)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:291)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:285)
	at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:118)
	at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:159)
	at net.enderlook.extracraft.blocks.init.CBlocks.registerBlocks(CBlocks.java:53)
	at net.enderlook.extracraft.proxy.CommonProxy.registerBlocks(CommonProxy.java:56)
    [...]

I'm not sure which is the error because "registry.registerAll" is executed after the init, not before, so it shouldn't be null, right?

Link to comment
Share on other sites

40 minutes ago, Enderlook said:

I'm sorry for my lack of knowledge, but I should do this?:

 

No. Read the docs on the object holders. The field must be final. Don't touch it. Just declare it as null and never put anything into it manually. Forge will do everything for you. Just register new instances of your blocks/items in the registry event like I do here.

Link to comment
Share on other sites

25 minutes ago, V0idWa1k3r said:

No. Read the docs on the object holders. The field must be final. Don't touch it. Just declare it as null and never put anything into it manually. Forge will do everything for you. Just register new instances of your blocks/items in the registry event like I do here.

Ok, I've tried to adapt that example to my code as I could, but I also have "initializeBlockModels" which I haven't found on the example. In addition to that, I noticed that 2 times the array of the blocks were made (to register block and to register their item shape). Why not use just one array?:

@EventBusSubscriber(modid = ExtraCraft.MOD_ID)
public class CBlocks {
	
	@ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block")
	public static final BlockSugar BLOCK_SUGAR = null;
	@ObjectHolder(ExtraCraft.MOD_ID + ":gunpowder_block")
	public static final BlockGunpowder BLOCK_GUNPOWDER = null;
	
	public static CBlockFalling[] BLOCK_FALLING = new CBlockFalling[] { // I've changed from CBlockBasic to CBlockFalling
		new BlockSugar(),
		new BlockGunpowder()
	};	
	
	@SideOnly(Side.CLIENT)
	public static void initializeBlockModels() {
		for (IInitModel block : BLOCK_FALLING) {
			block.initializeModel();
		}
	};
	
	public static void registerBlocks(final RegistryEvent.Register<Block> event) {
		final IForgeRegistry<Block> registry = event.getRegistry();
		registry.registerAll(BLOCK_FALLING);	
	};
	
	public static void registerItemBlocks(final RegistryEvent.Register<Item> event) {
		for (CBlockFalling block : BLOCK_FALLING) {
			block.registerItemBlock(event);
		}
	}
}

Each block has already this two methods inside:

	@Override
	@SideOnly(Side.CLIENT)
	public void initializeModel() {
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory"));		
	};
	
	public void registerItemBlock(final RegistryEvent.Register<Item> event) {
		event.getRegistry().register(new ItemBlock(this).setRegistryName(getRegistryName()));
	}

Note that sadly graphics still doesn't work :(

Link to comment
Share on other sites

Your registry event handler methods aren't annotated with SubscribeEvent so your blocks and items should not even be registered.

 

18 minutes ago, Enderlook said:

public static CBlockFalling[] BLOCK_FALLING = new CBlockFalling[] { // I've changed from CBlockBasic to CBlockFalling

Do not use static initializers. Just initialize your blocks in the registry event.

Link to comment
Share on other sites

1 minute ago, V0idWa1k3r said:

Your registry event handler methods aren't annotated with SubscribeEvent so your blocks and items should not even be registered.

 

Do not use static initializers. Just initialize your blocks in the registry event.

Something like this?:

@EventBusSubscriber(modid = ExtraCraft.MOD_ID)
public class CBlocks {
	
	@ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block")
	public static final BlockSugar BLOCK_SUGAR = null;
	@ObjectHolder(ExtraCraft.MOD_ID + ":gunpowder_block")
	public static final BlockGunpowder BLOCK_GUNPOWDER = null;
	
	@SideOnly(Side.CLIENT)
	public static void initializeBlockModels() {		
		CBlockFalling[] BLOCK_FALLING = new CBlockFalling[] {
			new BlockSugar(),
			new BlockGunpowder()	
		};
		for (IInitModel block : BLOCK_FALLING) {
			block.initializeModel();
		}
	};
	
	@SubscribeEvent
	public static void registerBlocks(final RegistryEvent.Register<Block> event) {
		final IForgeRegistry<Block> registry = event.getRegistry();		
		CBlockFalling[] BLOCK_FALLING = new CBlockFalling[] {
				new BlockSugar(),
				new BlockGunpowder()	
			};
		registry.registerAll(BLOCK_FALLING);	
	};
	
	@SubscribeEvent
	public static void registerItemBlocks(final RegistryEvent.Register<Item> event) {
		CBlockFalling[] BLOCK_FALLING = new CBlockFalling[] {
				new BlockSugar(),
				new BlockGunpowder()	
		};
		for (CBlockFalling block : BLOCK_FALLING) {
			block.registerItemBlock(event);
		}
	}
}

When I write "@SubscribeEvent" the game crash:

 

Initializing game

java.lang.RuntimeException: One of more entry values did not copy to the correct id. Check log for details!
	at net.minecraftforge.registries.ForgeRegistry.sync(ForgeRegistry.java:547)
	at net.minecraftforge.registries.GameData.loadRegistry(GameData.java:494)
	at net.minecraftforge.registries.GameData.freezeData(GameData.java:229)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:753)
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:329)
	at net.minecraft.client.Minecraft.init(Minecraft.java:581)
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)

Also it crash if I try:

		Item[] toRegister = new Item[]{
                new ItemBlock(BLOCK_SUGAR).setRegistryName("extracraft:sugar_block"),
                new ItemBlock(BLOCK_GUNPOWDER).setRegistryName("extracraft:gunpowder_block")
		};
		event.getRegistry().registerAll(toRegister);

 

Link to comment
Share on other sites

Now you are registering different instances of the same block thereby ending with multiple entries with the same registry names. ItemBlocks must be constructed from the same block instance you are registering. The items you are registering for your model registry events must be the same instances of ItemBlock you are registering.

 

Edit: Just to clarify - while it is perfectly fine to register different instances of the same block class as long as the registry names are different you are treating different instances as if they were the same object(which they are not) and you must use the same object to register it and obtain the ItemBlock instance(same with the model registration - you must use the registered itemblock objects to register the models with)

Edited by V0idWa1k3r
Link to comment
Share on other sites

ArrayLists are wonderful things.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

3 hours ago, V0idWa1k3r said:

Now you are registering different instances of the same block thereby ending with multiple entries with the same registry names. ItemBlocks must be constructed from the same block instance you are registering. The items you are registering for your model registry events must be the same instances of ItemBlock you are registering.

 

Edit: Just to clarify - while it is perfectly fine to register different instances of the same block class as long as the registry names are different you are treating different instances as if they were the same object(which they are not) and you must use the same object to register it and obtain the ItemBlock instance(same with the model registration - you must use the registered itemblock objects to register the models with)

So... I should do?:

@EventBusSubscriber(modid = ExtraCraft.MOD_ID)
public class CBlocks {
	
	@ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block")
	public static final BlockSugar BLOCK_SUGAR = null;
	@ObjectHolder(ExtraCraft.MOD_ID + ":gunpowder_block")
	public static final BlockGunpowder BLOCK_GUNPOWDER = null;
	
	private static CBlockFalling[] BLOCK_FALLING;
	
	public static void init() {
		BLOCK_FALLING = new CBlockFalling[] {
			new BlockSugar(),
			new BlockGunpowder()	
		};
	}	
	
	@SideOnly(Side.CLIENT)
	public static void initializeBlockModels() {		
		for (IInitModel block : BLOCK_FALLING) {
			block.initializeModel();
		}
	};

	public static void registerBlocks(final RegistryEvent.Register<Block> event) {
		final IForgeRegistry<Block> registry = event.getRegistry();		
		registry.registerAll(BLOCK_FALLING);
	};

	public static void registerItemBlocks(final RegistryEvent.Register<Item> event) {
		for (CBlockFalling block : BLOCK_FALLING) {
			block.registerItemBlock(event);
		}
	}
}

I don't understand :(, Graphics still doesn't work, and if I add "@SubscribeEvent" it crashes.

Link to comment
Share on other sites

47 minutes ago, V0idWa1k3r said:

You obviously need to add SubscribeEvent otherwise you will never get your blocks and items working since they will never get registered. Post your crash report.

 

Adding "@SubscribeEvent" before "registerBlocks" and "registerItemBlocks" produces:

---- Minecraft Crash Report ----
Description: Initializing game
java.lang.RuntimeException: One of more entry values did not copy to the correct id. Check log for details!
	at net.minecraftforge.registries.ForgeRegistry.sync(ForgeRegistry.java:547)
	at net.minecraftforge.registries.GameData.loadRegistry(GameData.java:494)
	at net.minecraftforge.registries.GameData.freezeData(GameData.java:229)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:753)
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:329)
	at net.minecraft.client.Minecraft.init(Minecraft.java:581)
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
	at net.minecraftforge.registries.ForgeRegistry.sync(ForgeRegistry.java:547)
	at net.minecraftforge.registries.GameData.loadRegistry(GameData.java:494)
	at net.minecraftforge.registries.GameData.freezeData(GameData.java:229)
	at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:753)
	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:329)
	at net.minecraft.client.Minecraft.init(Minecraft.java:581)

-- Initialization --
Details:
Stacktrace:
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)

 

Edited by Enderlook
Link to comment
Share on other sites

19 hours ago, V0idWa1k3r said:

You obviously need to add SubscribeEvent otherwise you will never get your blocks and items working since they will never get registered. Post your crash report.

Furthermore the crash report, I've noted that when Minecraft doesn't crash (because I don't use "@SubscribeEvent")  I get this error in the log: https://pastebin.com/Pfj7PR6b
In line 15 it says:

[11:36:00] [main/ERROR] [FML]: Exception loading model for variant extracraft:sugar_block#normal for blockstate "extracraft:sugar_block"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model extracraft:sugar_block#normal with loader VariantLoader.INSTANCE, skipping

And in line 39:

Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?]
    at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1182) ~[ModelLoader$VariantLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]

But I don't know what means that or how to fix it.

Link to comment
Share on other sites

24 minutes ago, Enderlook said:

Furthermore the crash report, I've noted that when Minecraft doesn't crash (because I don't use "@SubscribeEvent")  I get this error in the log: https://pastebin.com/Pfj7PR6b

Are you registering your blocks in some other method then? You are not annotating the method meaning that the event doesn't fire but the blocks are still being registered meaning that you are registering them somewhere else and you haven't shown that. That would also be the reason for the error that gets thrown when you do annotate the method. You however haven't shown any code that registers the blocks somewhere else.

 

As for the model loading errors:

Caused by: java.lang.RuntimeException: Encountered an exception when loading model definition of 'extracraft:gunpowder_block' from: 'extracraft:blockstates/gunpowder_block.json' in resourcepack: 'FMLFileResourcePack:ExtraCraft Mod'

Caused by: com.google.gson.JsonSyntaxException: Missing model, expected to find a string

You need to post your blockstates file for the gunpowder_block. Looks like it's missing a model pointer.

Edited by V0idWa1k3r
Link to comment
Share on other sites

5 minutes ago, V0idWa1k3r said:

Are you registering your blocks in some other method then? You are not annotating the method meaning that the event doesn't fire but the blocks are still being registered meaning that you are registering them somewhere else and you haven't shown that. That would also be the reason for the error that gets thrown when you do annotate the method. You however haven't shown any code that registers the blocks somewhere else.

 

As for the model loading errors:


Caused by: java.lang.RuntimeException: Encountered an exception when loading model definition of 'extracraft:gunpowder_block' from: 'extracraft:blockstates/gunpowder_block.json' in resourcepack: 'FMLFileResourcePack:ExtraCraft Mod'

Caused by: com.google.gson.JsonSyntaxException: Missing model, expected to find a string

You need to post your blockstates file for the gunpowder_block. Looks like it's missing a model pointer.

ModBlocks.java

@EventBusSubscriber(modid = ExtraCraft.MOD_ID)
public class ModBlocks {
	
	@ObjectHolder(ExtraCraft.MOD_ID + ":sugar_block")
	public static final BlockSugar BLOCK_SUGAR = null;
	@ObjectHolder(ExtraCraft.MOD_ID + ":gunpowder_block")
	public static final BlockGunpowder BLOCK_GUNPOWDER = null;
	
	private static CBlockFalling[] BLOCK_FALLING;
	
	public static void init() {
		BLOCK_FALLING = new CBlockFalling[] {
			new BlockSugar(),
			new BlockGunpowder()	
		};
	}
	
	
	@SideOnly(Side.CLIENT)
	public static void initializeBlockModels() {		
		for (IInitModel block : BLOCK_FALLING) {
			block.initializeModel();
		}
	};

	public static void registerBlocks(final RegistryEvent.Register<Block> event) {
		final IForgeRegistry<Block> registry = event.getRegistry();		
		registry.registerAll(BLOCK_FALLING);
	};
	
	public static void registerItemBlocks(final RegistryEvent.Register<Item> event) {
		for (CBlockFalling block : BLOCK_FALLING) {
			block.registerItemBlock(event);
		}
	}
}

 

In my main file ("Extracraftj.java"):

@Mod(modid = ExtraCraft.MOD_ID, name = ExtraCraft.NAME, version = ExtraCraft.VERSION)
// [...]
	@Mod.EventHandler
	public void preInitializationEvent(FMLPreInitializationEvent event) {
		logger = event.getModLog();
		proxy.preInitializationEvent(event);
		ModBlocks.init();
	}
// [...]

In "CommonProxy.java":

@Mod.EventBusSubscriber(modid = ExtraCraft.MOD_ID)
// [...]
	@SubscribeEvent
	public static void registerItems(final RegistryEvent.Register<Item> event) {		
		ModItems.registerItems(event);
		ModBlocks.registerItemBlocks(event);
	}
	
	@SubscribeEvent
	public static void registerBlocks(final RegistryEvent.Register<Block> event) {
		ModBlocks.registerBlocks(event);
	}
// [...]

In "ClientProxy.java":

@Mod.EventBusSubscriber(modid = ExtraCraft.MOD_ID, value = Side.CLIENT)
// [...]
	@SubscribeEvent
	public static void registerModels(ModelRegistryEvent event) {		
		ModItems.initializeItemsModels();
		ModBlocks.initializeBlockModels();
	}
// [...]

In "assets/extracraft/blockstates/gunpowder_block.json" (I've the same for sugar_block):

{
    "forge_maker": 1,
    "defaults": {
        "model": "extracraft:gunpowder_block"
    },
    "variants": {
        "normal": [{}],
        "inventory": [{}]
    }
}

In "assets/extracraft/blocksates/gunpowder_block.json" (I've the same for sugar_block);

{
    "parent": "blocks/cube_all",
    "textures": {
        "all": "extracraft:blocks/gunpowder_block"
    }
}

In "assets/extracraft/textures/blocks" I've "gunpowder_block.png" and "sugar_block.png"

Link to comment
Share on other sites

8 minutes ago, Enderlook said:

@Mod.EventBusSubscriber(modid = ExtraCraft.MOD_ID)

// [...] @SubscribeEvent
public static void registerItems(final RegistryEvent.Register<Item> event)
{
   
ModItems.registerItems(event); ModBlocks.registerItemBlocks(event);
}
@SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event)
{
   
ModBlocks.registerBlocks(event);
}
// [...]

Well here is the answer. You were already registering your blocks somewhere else and thus putting the subscribeevent caused the blocks to be registered twice. You should just have the ModBlocks be a registration handler, not pass the event from somewhere else to ModBlocks. Think about it - your ModBlocks.registerBlocks already registeres blocks and takes the event as the argument. It doesn't do anything else so why not have it as the handler? Why handle the event somewhere else just to call 1 method? 

Also Code-style issue #1.

 

14 minutes ago, Enderlook said:

In "assets/extracraft/blockstates/gunpowder_block.json" (I've the same for sugar_block):

13 minutes ago, Enderlook said:

forge_maker

Did you mean forge_marker? Currently because of this typo the blockstates is loaded as a vanilla blockstates file and that one expects the model property to be passed in the variant.

  • Thanks 1
Link to comment
Share on other sites

24 minutes ago, V0idWa1k3r said:

Well here is the answer. You were already registering your blocks somewhere else and thus putting the subscribeevent caused the blocks to be registered twice. You should just have the ModBlocks be a registration handler, not pass the event from somewhere else to ModBlocks. Think about it - your ModBlocks.registerBlocks already registeres blocks and takes the event as the argument. It doesn't do anything else so why not have it as the handler? Why handle the event somewhere else just to call 1 method? 

Also Code-style issue #1.

 

Did you mean forge_marker? Currently because of this typo the blockstates is loaded as a vanilla blockstates file and that one expects the model property to be passed in the variant.

I've fixed the typo. New error log :(:

[12:48:31] [main/ERROR] [FML]: Could not load vanilla model parent 'minecraft:blocks/cube_all' for 'net.minecraft.client.renderer.block.model.ModelBlock@649ded12
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model minecraft:blocks/cube_all with loader VanillaLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModelOrLogError(ModelLoaderRegistry.java:203) [ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader$VanillaModelWrapper.getTextures(ModelLoader.java:395) [ModelLoader$VanillaModelWrapper.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:163) [ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.<init>(ModelLoader.java:667) [ModelLoader$WeightedRandomModel.class:?]
	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1183) [ModelLoader$VariantLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) [ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:237) [ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) [ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:225) [ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:152) [ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: java.io.FileNotFoundException: minecraft:models/blocks/cube_all.json
	at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:69) ~[FallbackResourceManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:65) ~[SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.access$1600(ModelLoader.java:117) ~[ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:870) ~[ModelLoader$VanillaLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
	... 27 more

Should I rework my registring code right now or can I do that later? I would prefer first fix my 2 blocks and later rework that, I would prefer not to make new problems on the existing ones. Or it's necessary to fix my bug?

Edited by Enderlook
Link to comment
Share on other sites

5 minutes ago, V0idWa1k3r said:

 

Models are stored in the block and item folders respectively. There is no blocks folder.

Oh my god! It works!!!, I can't believe that all my problems were being typos. I'm sorry. THANK YOU VERY MUCH!!!

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

Announcements



×
×
  • Create New...

Important Information

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