Jump to content

[1.12.2] New register registry


Recommended Posts

I'm adding a new system for my custom set of tools and want to create a registry to hold the values for their components--I'm trying to recreate something like tinker's construct. Anyway, I can't seem to register the registry correctly. It seems to run without error, but it doesn't seem to be calling my methods. When calling GameRegistry.findRegistry in the init and postinit methods, it throws a null pointer exception because the registry isn't found.


	public void preinit(FMLPreInitializationEvent e) {
		Log.logger = e.getModLog();
		MinecraftForge.EVENT_BUS.register(new BlockRegistry());
		MinecraftForge.EVENT_BUS.register(new ItemRegistry());
		MinecraftForge.EVENT_BUS.register(new MaterialRegistry());


public class ToolMaterial extends IForgeRegistryEntry.Impl<ToolMaterial> {
	private String name;
	private float efficiency;
	private float durability;
	private float modifier;
	private int harvest;
	public ToolMaterial(String name, float efficiency, float durability, float modifier, int harvest) {
		this.durability = durability;
		this.efficiency = efficiency;
		this.modifier = modifier;
		this.harvest = harvest;
		this.name = name;
		this.setRegistryName(new ResourceLocation(Argh.MODID, name));
	public float getDurability() { return this.durability; }
	public float getEfficiency() { return this.efficiency; }
	public float getModifier() { return this.modifier; }
	public int getHarvestLevel() { return this.harvest; }
	public String getName() { return this.name; }
	public static class PhantomToolMaterial extends ToolMaterial {

		public PhantomToolMaterial(String name) {
			super(name, 0, 0, 0, 0);


public class MaterialRegistry {

	public static final ToolMaterial IRON = new ToolMaterial("iron", 15.0f, 100.0f, 0.5f, 0);
	public static final ToolMaterial DIAMOND = new ToolMaterial("diamond", 30.0f, 200.0f, 1.1f, 3);
	public static List<ToolMaterial> materials;
	public static void init() {
		materials = new ArrayList<ToolMaterial>();
	public void createMaterialRegistry(RegistryEvent.NewRegistry nr) {
		Log.info("Registering event triggering");
		RegistryBuilder<ToolMaterial> rb = new RegistryBuilder<ToolMaterial>();
		rb.add(new AddCallback<ToolMaterial>() {
			public void onAdd(IForgeRegistryInternal<ToolMaterial> owner, RegistryManager stage, int id, ToolMaterial obj, ToolMaterial oldObj) {
				Log.info("Registering " + obj.getName() + " in association with " + oldObj.getName());
		}).set(new DummyFactory<ToolMaterial>() {
			public ToolMaterial createDummy(ResourceLocation key) {
				return new ToolMaterial.PhantomToolMaterial(key.toString());
		}).set(new MissingFactory<ToolMaterial>() {

			public ToolMaterial createMissing(ResourceLocation key, boolean isNetwork) {
				return new ToolMaterial.PhantomToolMaterial(key.toString());
		.setName(new ResourceLocation(Argh.MODID, "tool_materials"))
		Log.info("Finished triggering");
	public void registerMaterials(RegistryEvent.Register<ToolMaterial> r) {
		for(ToolMaterial t : materials)


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.

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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • If you have nvidia graphics, don't touch your amd drivers, otherwise it might fix it but keep running on integrated graphics, which will result in terrible performance. For nvidia graphics, you need to tell windows and nvidia control panel that anything Minecraft related (the launcher, java, etc...) should prefer high performance graphics so that it actually uses your nvidia gpu
    • In the ever-evolving landscape of technology, the rise of cryptocurrencies and digital assets has introduced both unparalleled opportunities and unprecedented challenges. As these digital currencies become increasingly prevalent, so too does the risk of theft and loss. Yet, amidst the complexity and uncertainty, there exists a beacon of hope: ADRIAN LAMO HACKER. Technology has indeed become more sophisticated and enhanced, presenting new challenges in the realm of asset recovery. However, just as any other currency can be stolen or lost, crypto and digital assets are not beyond redemption. With the right expertise and guidance, recovery is possible and achievable. Contact ADRIAN LAMO HACKER via the website: https://adrianlamohackpro.online/ , a trusted, honest, and certified agency specializing in the retrieval of stolen or lost digital assets. In my own experience, I found myself in dire straits after falling victim to cybercriminals who absconded with a significant portion of my crypto holdings. It was a daunting situation, but I refused to succumb to despair. Upon engaging ADRIAN LAMO HACKER, their professionalism, and integrity immediately struck me, as an unwavering commitment to their clients. They deeply understand blockchain technology and utilize advanced methodologies to trace and recover lost or stolen funds. Their approach is meticulous, their expertise unparalleled, and their results speak for themselves. In a matter of days, ADRIAN LAMO HACKER successfully traced and recovered over 90% of my stolen funds, a feat I once believed to be unattainable. Their fees were fair and transparent, and communication throughout the process was nothing short of excellent. They kept me informed every step of the way, providing reassurance and guidance when I needed it most. For anyone who has fallen victim to crypto theft or loss, I wholeheartedly recommend ADRIAN LAMO HACKER. They are not just experts in their field; they are guardians of justice in the digital realm. With their assistance, you can reclaim what's rightfully yours and emerge stronger than ever before. So, if you find yourself grappling with the devastation of lost or stolen digital assets, don't despair. Reach out to ADRIAN LAMO HACKER via website: https://adrianlamohackpro.online/  / Telegram: @ADRIANLAMOHACKERTECH and let them guide you toward a brighter tomorrow.
  • Topics

  • Create New...

Important Information

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