Jump to content

Recommended Posts

Posted (edited)

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
Posted
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.

Posted

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 .

Posted (edited)
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.

Posted

 

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

 

Posted
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

 

Posted (edited)

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
Posted (edited)

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
Posted
	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.

Posted

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.

Posted

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.

Posted

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.

Posted
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!

 

Posted
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.

Posted (edited)
	public static void register(IForgeRegistry<Item> registry) {
		registry.registerAll(ingotCopper);
	}


	public static void registerModels() {
		ingotCopper.registerItemModel();
	}
}

 

if that's what you expect from me I've already put it in another class!

 

Edited by LeChevalierD_Or

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • It is a rendering issue with embeddium/oculus
    • So, I have a minecraft world hosted with essential on forge 1.20.1, there's 149 mods, and the forge version is 47.3.0, and it's been like that for a good 2-3 weeks, and all of a sudden, it stopped loading, and I have 0 clue as to why, and this world means A LOT to me, so if anyone out there is able to help, I would GLADLY appreciate it. here's the link if ya wanna help:   [04Dec2024 22:42:24.552] [Worker-ResourceReload-3/ERROR][net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener/]: Couldn't parse data file slabsexpanded:snow_blockblocktoslab from slabsexpanded:recipes/snow_blockblocktoslab.json com.google.gson.JsonParseException: com.google.gson.stream.MalformedJsonException: Expected name at line 16 column 4 path $.result.item at net.minecraft.util.GsonHelper.m_13780_(GsonHelper.java:526) ~[client-1.20.1-20230612.114412-srg.jar%23490!/:?] at net.minecraft.util.GsonHelper.m_263475_(GsonHelper.java:531) ~[client-1.20.1-20230612.114412-srg.jar%23490!/:?] at net.minecraft.util.GsonHelper.m_13776_(GsonHelper.java:581) ~[client-1.20.1-20230612.114412-srg.jar%23490!/:?] at net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener.m_278771_(SimpleJsonResourceReloadListener.java:41) ~[client-1.20.1-20230612.114412-srg.jar%23490!/:?] at net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener.m_5944_(SimpleJsonResourceReloadListener.java:29) ~[client-1.20.1-20230612.114412-srg.jar%23490!/:?] at net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener.m_5944_(SimpleJsonResourceReloadListener.java:17) ~[client-1.20.1-20230612.114412-srg.jar%23490!/:?] at net.minecraft.server.packs.resources.SimplePreparableReloadListener.m_10786_(SimplePreparableReloadListener.java:11) ~[client-1.20.1-20230612.114412-srg.jar%23490!/:?] at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?] at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1760) ~[?:?] at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?] at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?] at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?] at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?] at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?] Caused by: com.google.gson.stream.MalformedJsonException: Expected name at line 16 column 4 path $.result.item at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1657) ~[gson-2.10.jar%23107!/:?] at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:514) ~[gson-2.10.jar%23107!/:?] at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:422) ~[gson-2.10.jar%23107!/:?] at com.google.gson.internal.bind.TypeAdapters$28.read(TypeAdapters.java:779) ~[gson-2.10.jar%23107!/:?] at com.google.gson.internal.bind.TypeAdapters$28.read(TypeAdapters.java:725) ~[gson-2.10.jar%23107!/:?] at com.google.gson.internal.bind.TypeAdapters$34$1.read(TypeAdapters.java:1007) ~[gson-2.10.jar%23107!/:?] at net.minecraft.util.GsonHelper.m_13780_(GsonHelper.java:524) ~[client-1.20.1-20230612.114412-srg.jar%23490!/:?]
    • Hello! I have been having a problem with Forgematica, Embeddium, Oculus, and create. I wanted to download litematica so I could see which blocks are in my creative mode build, so that I could collect them all in survival. However, litematica is a fabric mod. I found a port called forgematica, which I added (along with it's dependency) to my mods folder. I loaded into a new world, and built a structure. Then, I added a part from the create mod, and the game crashed instantly, with exit code -1. Thanks for any help! Crash Report and mods list: https://pastebin.com/rtzh6LAi
  • Topics

×
×
  • Create New...

Important Information

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