Jump to content

Recommended Posts

Posted

Hello,

I have recently tried to get back into modding after the 1.12 update.  I have looked at the documentation and it seems to show a new way to register items.  I have followed it's instructions to the best of my ability but it still doesn't work.  Can anyone tell me what im doing wrong?

Spoiler

package com.drok.progressiveg;

import com.drok.progressiveg.common.items.ItemAK47;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Mod.EventBusSubscriber
public class Register {

	public static Item ak47 = new ItemAK47();
	
	@SubscribeEvent
    public void registerItems(RegistryEvent.Register<Item> event) {
		GunMod.log("Registering Items");
		
        event.getRegistry().registerAll(
        			ak47
        		);
        
        GunMod.log("Registered Items");
    }
    
    @SubscribeEvent
    public void registerBlocks(RegistryEvent.Register<Block> event) {
        event.getRegistry().registerAll(
        		
        		);
    }
	
}

 


package com.drok.progressiveg;

import com.drok.progressiveg.common.items.*;

import net.minecraft.block.*;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.*;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.*;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@Mod(useMetadata = true, modid = "progressiveg")
public class GunMod
{
    
    public static final CreativeTabs TAB = new CreativeTabs(CreativeTabs.getNextID(), "guns")
    {
        @SideOnly(Side.CLIENT)
        public ItemStack getTabIconItem()
        {
            return new ItemStack(Register.ak47);
        }
    };
    
    
    public static void log(String msg) {
    	System.out.println("[Progressive Guns]" + msg);
    	
    }
    
    @EventHandler
    public void preinit(FMLPreInitializationEvent event)
    {
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    }
    
    @EventHandler
    public void postinit(FMLPostInitializationEvent event)
    {
    }
    
    
    
}

 

 

Posted
9 minutes ago, drok0920 said:

@SubscribeEvent

public void registerItems(RegistryEvent.Register<Item> event) {

GunMod.log("Registering Items");

event.getRegistry().registerAll( ak47 );

GunMod.log("Registered Items");

}

 

@SubscribeEvent

public void registerBlocks(RegistryEvent.Register<Block> event) {

event.getRegistry().registerAll( );

}

These methods need to be static.

  • Like 1

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Posted
1 minute ago, Dylem said:

I don't say that you need to do the same, but I really like @Choonster way of handling items

here is his file on github : github.com

Yes i plan on making it more organized like the example you provided.  I just wanted to get it to register first.

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.