Jump to content

code problem in 1.12


LeChevalierD_Or

Recommended Posts

Hello I have a problem in 1.12 at the line "GameRegistry.register (item);

can you help me here is my code:

 

package com.cubicdeath.blocks;

import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class CubicDeath_Blocks{
	public CubicDeath_Blocks() {
		initItems();
		registerItem(logo);
		registerRender(logo, 0);
	}
	public Item logo;
	public void initItems() {
		logo = new Item().setRegistryName("logo").setUnlocalizedName("logo");
	}
	@SideOnly(Side.CLIENT)
	public void registerItem(Item item) {
		GameRegistry.register(item);
	}
	public void registerRender(Item item, int meta) {
		ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(new ResourceLocation("test", item.getUnlocalizedName().substring(5)), "inventory"));
	}
}
	
	

 

Edited by LeChevalierD_Or
Link to comment
Share on other sites

Quote

1.12

Quote

"GameRegistry.register (item);

You're doing everything wrong. You need to use the Registry events.

http://mcforge.readthedocs.io/en/latest/concepts/registries/#registering-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

Hello,
Thank you for your answer.

here is my code now:

 

 

package com.cubicdeath.blocks;

import net.minecraft.block.Block;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;

public class CubicDeath_Blocks{
	
	
	@SubscribeEvent
	public void registerBlocks(RegistryEvent.Register<Block> event) {
		event.getResult().registerAll(Block1);
	}
}

 

 

Can you now give me the whole code with a block and features so that I can understand better.

Thank you in advance .

Link to comment
Share on other sites

1 hour ago, LeChevalierD_Or said:

 


public class CubicDeath_Blocks{
	@SubscribeEvent
	public void registerBlocks(RegistryEvent.Register<Block> event) {
		event.getResult().registerAll(Block1);
	}
}

 

Your original code had you trying to register an item named logo.

In this code you're trying to register a block named Block1 (which doesn't exist).

Edited by Draco18s

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

 

I send this to some other people too but,

 

In the new 1.12.2 version you need to use the new way of registering with the new RegistryEvent<T> 

 

Try and read the documentation on at mcforge.readthedocs.io/en/latest/concepts/registries/

 

If you arent known with events check out this https://mcforge.readthedocs.io/en/latest/events/intro/

 

I could advice you to check out this repo from Harry'sTechreviews: a youtuber, you can also check out his video on it

https://github.com/HarryTechRevs/MinecraftModding/tree/HarryTechRevs-1.12.2-Tutorials/main/java/harry/mod

 

Link to comment
Share on other sites

Just now, tebreca said:

 

I send this to some other people too but,

 

In the new 1.12.2 version you need to use the new way of registering with the new RegistryEvent<T> 

 

Try and read the documentation on at mcforge.readthedocs.io/en/latest/concepts/registries/

 

If you arent known with events check out this https://mcforge.readthedocs.io/en/latest/events/intro/

 

I could advice you to check out this repo from Harry'sTechreviews: a youtuber, you can also check out his video on it

https://github.com/HarryTechRevs/MinecraftModding/tree/HarryTechRevs-1.12.2-Tutorials/main/java/harry/mod

 

 

1 hour ago, LeChevalierD_Or said:

Hello,
Thank you for your answer.

here is my code now:

 

 


package com.cubicdeath.blocks;

import net.minecraft.block.Block;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;

public class CubicDeath_Blocks{
	
	
	@SubscribeEvent
	public void registerBlocks(RegistryEvent.Register<Block> event) {
		event.getResult().registerAll(Block1);
	}
}

 

 

Can you now give me the whole code with a block and features so that I can understand better.

Thank you in advance .

also you need to register your class as a @EventBusSubscriber

is pretty easy with just the @mod.eventbussubsriber annonation

 

Link to comment
Share on other sites

11 minutes ago, LeChevalierD_Or said:

Unfortunately I do not have any more code I am in total incomprehension = (

 

thats bad though, but i can only help you with sending a website which helps a lot if you understand java good enough,

 

https://shadowfacts.net/tutorials/forge-modding-112/

 

succes with modding, always ask help if you need there will be people around who can help you

 

Link to comment
Share on other sites

Hi, I would like to know if until I get well: xD

 

package com.cubicdeath.blocks;


import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;

@Mod(modid = Main.modId, name = Main.name, version = Main.version)
public class Main {

	public static final String modId = "cubicdeath_block";
	public static final String name = "CubicDeath Block";
	public static final String version = "1.0.0";

	@Mod.Instance(modId)
	public static Main instance;
	
	@SidedProxy(serverSide = "com.cubicdeath.blocks.CommonProxy", clientSide = "com.cubicdeath.blocks.ClientProxy")
	public static CommonProxy proxy;

	@Mod.EventHandler
	public void preInit(FMLPreInitializationEvent event) {
		System.out.println(name + " Et en chargement...");
	}

	@Mod.EventHandler
	public void init(FMLInitializationEvent event) {
		
	}

	@Mod.EventHandler
	public void postInit(FMLPostInitializationEvent event) {
		
	}

	@Mod.EventBusSubscriber
	public static class RegistrationHandler {
	
		@SubscribeEvent
		public static void registerItems(RegistryEvent.Register<Item> event) {
			Main.register(event.getRegistry());
		}
			@SubscribeEvent
			public static void registerItems(ModelRegistryEvent event) {
				Main.registerModels();
				
			}
		}
		
	
	public static void register(IForgeRegistry<Item> registry) {
		
		
	}
	public static void registerModels() {
	
		
	}
}
	


	
	

 

Edited by LeChevalierD_Or
Link to comment
Share on other sites

Hi, there seems to be a problem but I do not know how to help you.
Explanations: When I run the game via eclipse and I go in the CreativeTabs "BuildingsBlocks" I can not find my item CopperIngot = (

Please help me =)

Here is a folder where there are all my classes =)
Thank you in advance ...

error.zip

Edited by LeChevalierD_Or
Link to comment
Share on other sites

	public static void register(IForgeRegistry<Item> registry) {
		//something goes here maybe? I dunno. Maybe something to register my items?
	}

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

Your methods do jack diddly squat.

They are empty.

They need to not be empty.

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

geico-gecko-facepalm.jpg

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

I believe your biggest problem is likely a lack of java knowledge. You really do need to know at least intermediate java/OOP in order to make mods for Minecraft. Otherwise you will struggle a LOT with the simplest of blocks and items, nevermind making anything actually cool/different/exciting.

 

http://www.minecraftforge.net/forum/topic/49497-1112-is-using-registryevent-this-way-ok/

 

This post shows how to register items, blocks, and their models.

 

If someone just writes the code for you and/or gives you the complete answer, you will be right back here stuck again unless you have some programming skills. I'm not trying to be mean, just stating what is true. There are a lot of guys on here that have been here a long time, and you won't get a nice answer out of them if you lack even rudimentary java skills, as this forum is not a place to learn how to program.

Link to comment
Share on other sites

4 hours ago, Ugdhar said:

Je crois que votre plus gros problème est probablement un manque de connaissances Java. Vous avez vraiment besoin de connaître au moins intermédiaire Java / OOP afin de faire des mods pour Minecraft. Sinon, vous aurez beaucoup de mal avec le plus simple des blocs et des objets, sans jamais faire quoi que ce soit de vraiment cool / différent / excitant.

 

http://www.minecraftforge.net/forum/topic/49497-1112-is-using-registryevent-this-way-ok/

 

Ce message montre comment enregistrer des éléments, des blocs et leurs modèles.

 

Si quelqu'un vous écrit simplement le code et / ou vous donne la réponse complète, vous serez à nouveau coincé ici à moins que vous n'ayez des compétences en programmation. Je n'essaie pas d'être méchant, juste en disant ce qui est vrai. Il y a beaucoup de gars ici depuis longtemps et vous n'obtiendrez pas une bonne réponse si vous n'avez même pas de compétences java rudimentaires, car ce forum n'est pas un endroit pour apprendre à programmer.

 

Negative I have a very good knowledge of JAVA but not in forge!

 

Link to comment
Share on other sites

20 hours ago, Draco18s said:

They are empty.

They need to not be empty.

20 hours ago, Draco18s said:

not be empty.

20 hours ago, LeChevalierD_Or said:

So can I delete them?

 

You tell me.

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

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.