Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So, with this new weird 1.12 API, I can't manage to get items to work.

I have been messing around but can't seem to find my problem.

Item Class:

package MoBuildingBlocks.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSword;
import net.minecraftforge.event.RegistryEvent;

public class ItemSaw extends ItemSword {
	public static Item ItemSaw;
	public static void registerItems(RegistryEvent.Register<Item> event) {
        event.getRegistry().register(ItemSaw=new ItemSword(Item.ToolMaterial.IRON).setUnlocalizedName("saw").setRegistryName("mobuildingblocks","saw"));
	}
        public ItemSaw(ToolMaterial material) {
		super(material);
	}
}

Common Proxy:

package MoBuildingBlocks.Proxy;

import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraftforge.event.RegistryEvent;
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 MoBuildingBlocks.Items.ItemSaw;
import MoBuildingBlocks.Registrys.RegistryHandler;

public class CommonProxy {

	public void preInit(FMLPreInitializationEvent event) {
		RegistryHandler.Common();
	}
	public void Init(FMLInitializationEvent event) {
		
	}
	public void postInit(FMLPostInitializationEvent event) {
		
	}
	@SubscribeEvent
    public static void registerItems(RegistryEvent.Register<Item> event, ToolMaterial material) {
        event.getRegistry().register(new ItemSaw(material));
	}
}

Item Registry:

package MoBuildingBlocks.Registrys;

import net.minecraftforge.fml.common.registry.GameRegistry;
import MoBuildingBlocks.Items.ItemSaw;

public class ItemRegistry {
    @GameRegistry.ObjectHolder("mbb:saw")
    public static ItemSaw saw;
}

That's all the classes I have to do with the item, nothing in my main class except the PreInit, Init, and PostInit, and my ClientProxy is the same.

The mod name is Mo' Building Blocks, the mod ID is mbb, the item is called Saw, the texture is in a folder called Items and it is called Saw.

event.getRegistry().register(ItemSaw=new ItemSword(...
event.getRegistry().register(new ItemSaw(...

Wot. Why do you have two different RegistryEvent handlers? Not that either one of them is actually subscribed to the event bus.

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.

  • Author

Oh, lol I just realized that. I saw the subscribe thing when looking through examples but forgot that I registered both of them register it... darp O.o

Edited by Big_Bad_E
Grammer...

  • Author

Still not working...

Item Class:

package MoBuildingBlocks.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSword;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class ItemSaw extends Item {
	public static Item ItemSaw;
	public static void registerItems(RegistryEvent.Register<Item> event) {
        event.getRegistry().register(ItemSaw=new Item().setUnlocalizedName("saw").setRegistryName("mobuildingblocks","saw"));
	}
        public ItemSaw(ToolMaterial material) {
		super();
	}
}

I removed the register thing from my proxy

Item Registry:

package MoBuildingBlocks.Registrys;

import net.minecraftforge.fml.common.registry.GameRegistry;
import MoBuildingBlocks.Items.ItemSaw;

public class ItemRegistry {
    @GameRegistry.ObjectHolder("mbb:saw")
    public static ItemSaw saw;
}

I have no other things related to the item in my other classes, which I may need it in one .-.

Also if anyone knows what to do in my event.getRegistry to put it in a creative tab

If you're using @GameRegistry.ObjectHolder then you don't need to do this: ItemSaw=

The whole point of ObjectHolder annotations is to set the field for you.

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.