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.

Can Someone Please Tell Me What I'm Doing Wrong? (1.11 registering entity)

Featured Replies

Posted

I'm not quite certain how to go about this, but here's what I got:

 

Main class:

package exampled.modinfo;

import exampled.modinfo.init.ExampledEntities;
import exampled.modinfo.init.ExampledItems;
import exampled.modinfo.proxy.CommonProxy;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.MOD_VERSION)
public class Exampled
{
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;
@Instance(Reference.MOD_ID)
private static Exampled instance;
private static ResourceLocation rsrcl;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	ModCreativeTabs.load();
	proxy.preInit();
	ExampledItems.init();
	ExampledItems.register();
	ExampledEntities.registerEntities(rsrcl);
	initRecipes();
}
    @EventHandler
    public void init(FMLInitializationEvent event)
    { 
	proxy.registerRenders();
        proxy.registerKeybindings();
        NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
    }	
private static void initRecipes()
{
	GameRegistry.addRecipe(new ItemStack(ExampledItems.SPHERE), new Object[] {" X ",  "X X", " X ", 'X', Item.getItemFromBlock(Blocks.DIRT)});
}
public static Exampled getInstance()
{
	return instance;
}
public static Exampled ResourceLocation()
{
	return rsrcl; <----- only red is located here, having rsrcl underlined. Using auto fix removes the red but crashes on launch.
}
}

 

ModEntities class (no red here) but just in case:

package exampled.modinfo.init;

import exampled.modinfo.Exampled;
import exampled.modinfo.entity.EntitySphere;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityRegistry;

public class ExampledEntities
{
private static int id = 0;

public static void registerEntities(ResourceLocation rsrcl) {
	// TODO Auto-generated method stub
	register( rsrcl, EntitySphere.class, "sphere");
}

private static void register(ResourceLocation rsrcl, Class cls, String name)
{
	EntityRegistry.registerModEntity( rsrcl, cls, name, id++, Exampled.getInstance(), 128, 214, true);
}	
}

  • Author

This is also crashing on start up, but displays no red in combination with modentities class above:

package exampled.modinfo;

import exampled.modinfo.init.ExampledEntities;
import exampled.modinfo.init.ExampledItems;
import exampled.modinfo.proxy.CommonProxy;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.MOD_VERSION)
public class Exampled
{
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;
@Instance(Reference.MOD_ID)
private static Exampled instance;
private static ResourceLocation rsrcl;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	ModCreativeTabs.load();
	proxy.preInit();
	ExampledItems.init();
	ExampledItems.register();
	ExampledEntities.registerEntities(rsrcl);
	initRecipes();
}
    @EventHandler
    public void init(FMLInitializationEvent event)
    { 
	proxy.registerRenders();
        proxy.registerKeybindings();
        NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
    }	
private static void initRecipes()
{
	GameRegistry.addRecipe(new ItemStack(ExampledItems.SPHERE), new Object[] {" X ",  "X X", " X ", 'X', Item.getItemFromBlock(Blocks.DIRT)});
}
public static Exampled getInstance()
{
	return instance;
}
public static ResourceLocation getResourceLocation()
{
	return rsrcl;
}
}

This is your second (third?) post about entity registration. In all of them people have commented that Forge for 1.11 doesn't have proper registration for entities yet.

 

In the latest Forge version, Lex has added a basic draft of it, but that doesn't say it's working already.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

This is your second (third?) post about entity registration. In all of them people have commented that Forge for 1.11 doesn't have proper registration for entities yet.

 

In the latest Forge version, Lex has added a basic draft of it, but that doesn't say it's working already.

 

Changelog:

Build 2149:

LexManos: First draft of Entity Registry re-write.

 

^ I figured this may have changed that, but I guess not?

I apologize.... I'm patient, just didn't know. Jumped the gun a little bit I guess...

 

Ended up with something like this without any errors too... (and it doesn't crash on start up, but entities still invisible when thrown, item model renders with correct stack size and texture though  :) )

 

public class ExampledEntities
{
private static int id = 0;
public static final ExampledEntities INSTANCE = new ExampledEntities();

public static ExampledEntities instance()
    {
        return INSTANCE;
    }

private ExampledEntities()
    {

    }

private static void register(ResourceLocation rsrcl, Class<EntitySphere> cls, String string) {
	// TODO Auto-generated method stub
	register( rsrcl, EntitySphere.class, "sphere");
}

public static void registerModEntities(ResourceLocation rsrcl, Class<? extends Entity> cls, String name, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
    {
        ( instance()).registerModEntities( rsrcl, cls, name, id++, Exampled.getInstance(), 128, 214, true);
    }

public ResourceLocation registerEntities(ResourceLocation rsrcl) {
	// TODO Auto-generated method stub
	return rsrcl;
}
}

 

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.