Jump to content

Registering entity with new resource location (solved). [1.11]


gurujive

Recommended Posts

I can see the orbs in game, they render differently with summon having different effects. When right clicked they throw off into a random direction. I don't know if I'm doing something wrong here, but I don't necessarily believe I am, I would like to know if I am doing something wrong.

 

package guru.tbe;

import net.minecraft.client.resources.Language;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
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;
import guru.tbe.entity.EntityAetherOrb;
import guru.tbe.entity.EntityAetherOrb2;
import guru.tbe.entity.EntityAirOrb;
import guru.tbe.entity.EntityCreativeOrb;
import guru.tbe.entity.EntityEarthOrb;
import guru.tbe.entity.EntityFireOrb;
import guru.tbe.entity.EntityInvisibleOrb;
import guru.tbe.entity.EntityLeapingFireOrb;
import guru.tbe.entity.EntityNetherOrb;
import guru.tbe.entity.EntityWaterOrb;
import guru.tbe.init.GuruEntities;
import guru.tbe.init.GuruItems;
import guru.tbe.proxy.CommonProxy;

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.MOD_VERSION)
public class Guru
{
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;
@Instance(Reference.MOD_ID)
private static Guru instance;
private static int id = 0;


@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	ModCreativeTabs.load();
	proxy.preInit();
	GuruItems.init();
	GuruItems.register();
	initRecipes();
}
@EventHandler
    public void init(FMLInitializationEvent event)
    { 
	ResourceLocation resourceLocation = new ResourceLocation(Reference.MOD_ID, "aether_orb");
        EntityRegistry.registerModEntity(resourceLocation, EntityAetherOrb.class, resourceLocation.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation1 = new ResourceLocation(Reference.MOD_ID, "aether_orb2");
        EntityRegistry.registerModEntity(resourceLocation1, EntityAetherOrb2.class, resourceLocation1.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation2 = new ResourceLocation(Reference.MOD_ID, "air_orb");
        EntityRegistry.registerModEntity(resourceLocation2, EntityAirOrb.class, resourceLocation2.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation3 = new ResourceLocation(Reference.MOD_ID, "creative_orb");
        EntityRegistry.registerModEntity(resourceLocation2, EntityCreativeOrb.class, resourceLocation3.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation4 = new ResourceLocation(Reference.MOD_ID, "earth_orb");
        EntityRegistry.registerModEntity(resourceLocation2, EntityEarthOrb.class, resourceLocation4.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation5 = new ResourceLocation(Reference.MOD_ID, "fire_orb");
        EntityRegistry.registerModEntity(resourceLocation5, EntityFireOrb.class, resourceLocation5.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation6 = new ResourceLocation(Reference.MOD_ID, "invisible_orb");
        EntityRegistry.registerModEntity(resourceLocation5, EntityInvisibleOrb.class, resourceLocation6.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation7 = new ResourceLocation(Reference.MOD_ID, "leaping_fire_orb");
        EntityRegistry.registerModEntity(resourceLocation5, EntityLeapingFireOrb.class, resourceLocation7.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation8 = new ResourceLocation(Reference.MOD_ID, "nether_orb");
        EntityRegistry.registerModEntity(resourceLocation5, EntityNetherOrb.class, resourceLocation7.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation9 = new ResourceLocation(Reference.MOD_ID, "water_orb");
        EntityRegistry.registerModEntity(resourceLocation5, EntityWaterOrb.class, resourceLocation9.toString(), id++, Guru.instance, 128, 214, true);
	proxy.registerRenders();
        proxy.registerKeybindings();
        NetworkRegistry.INSTANCE.registerGuiHandler(getInstance(), proxy);
    }
public static void initRecipes()
{
	GameRegistry.addRecipe(new ItemStack(GuruItems.AIR_ORB), new Object[] {" X ", "X X", " X ", 'X', Items.FEATHER});
	GameRegistry.addRecipe(new ItemStack(GuruItems.WATER_ORB), new Object[] {" X ",  "X X", " X ", 'X', Items.WATER_BUCKET});
	GameRegistry.addRecipe(new ItemStack(GuruItems.EARTH_ORB), new Object[] {" X ",  "X X", " X ", 'X', Item.getItemFromBlock(Blocks.DIRT)});
	GameRegistry.addRecipe(new ItemStack(GuruItems.FIRE_ORB), new Object[] {" X ",  "X X", " X ", 'X', Items.LAVA_BUCKET});
	GameRegistry.addRecipe(new ItemStack(GuruItems.NETHER_ORB), new Object[] {" X ",  "X X", " X ", 'X', Item.getItemFromBlock(Blocks.OBSIDIAN)});
	GameRegistry.addRecipe(new ItemStack(GuruItems.AETHER_ORB), new Object[] {" X ",  "X X", " X ", 'X', Item.getItemFromBlock(Blocks.GLOWSTONE)});
}
public static Guru getInstance()
{
	return instance;
}
}

Link to comment
Share on other sites

Ok, I saw what I did wrong there and corrected it, now when thrown they go off in a random direction still but show up in the command console:

 

package guru.tbe;

import net.minecraft.client.resources.Language;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
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;
import guru.tbe.entity.EntityAetherOrb;
import guru.tbe.entity.EntityAetherOrb2;
import guru.tbe.entity.EntityAirOrb;
import guru.tbe.entity.EntityCreativeOrb;
import guru.tbe.entity.EntityEarthOrb;
import guru.tbe.entity.EntityFireOrb;
import guru.tbe.entity.EntityInvisibleOrb;
import guru.tbe.entity.EntityLeapingFireOrb;
import guru.tbe.entity.EntityNetherOrb;
import guru.tbe.entity.EntityWaterOrb;
import guru.tbe.init.GuruEntities;
import guru.tbe.init.GuruItems;
import guru.tbe.proxy.CommonProxy;

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.MOD_VERSION)
public class Guru
{
@SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;
@Instance(Reference.MOD_ID)
private static Guru instance;
private static int id = 0;


@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	ModCreativeTabs.load();
	proxy.preInit();
	GuruItems.init();
	GuruItems.register();
	initRecipes();
}
@EventHandler
    public void init(FMLInitializationEvent event)
    { 
	ResourceLocation resourceLocation = new ResourceLocation(Reference.MOD_ID, "aether_orb");
        EntityRegistry.registerModEntity(resourceLocation, EntityAetherOrb.class, resourceLocation.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation1 = new ResourceLocation(Reference.MOD_ID, "aether_orb2");
        EntityRegistry.registerModEntity(resourceLocation1, EntityAetherOrb2.class, resourceLocation1.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation2 = new ResourceLocation(Reference.MOD_ID, "air_orb");
        EntityRegistry.registerModEntity(resourceLocation2, EntityAirOrb.class, resourceLocation2.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation3 = new ResourceLocation(Reference.MOD_ID, "creative_orb");
        EntityRegistry.registerModEntity(resourceLocation3, EntityCreativeOrb.class, resourceLocation3.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation4 = new ResourceLocation(Reference.MOD_ID, "earth_orb");
        EntityRegistry.registerModEntity(resourceLocation4, EntityEarthOrb.class, resourceLocation4.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation5 = new ResourceLocation(Reference.MOD_ID, "fire_orb");
        EntityRegistry.registerModEntity(resourceLocation5, EntityFireOrb.class, resourceLocation5.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation6 = new ResourceLocation(Reference.MOD_ID, "invisible_orb");
        EntityRegistry.registerModEntity(resourceLocation6, EntityInvisibleOrb.class, resourceLocation6.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation7 = new ResourceLocation(Reference.MOD_ID, "leaping_fire_orb");
        EntityRegistry.registerModEntity(resourceLocation7, EntityLeapingFireOrb.class, resourceLocation7.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation8 = new ResourceLocation(Reference.MOD_ID, "nether_orb");
        EntityRegistry.registerModEntity(resourceLocation8, EntityNetherOrb.class, resourceLocation8.toString(), id++, Guru.instance, 128, 214, true);
        ResourceLocation resourceLocation9 = new ResourceLocation(Reference.MOD_ID, "water_orb");
        EntityRegistry.registerModEntity(resourceLocation9, EntityWaterOrb.class, resourceLocation9.toString(), id++, Guru.instance, 128, 214, true);
	proxy.registerRenders();
        proxy.registerKeybindings();
        NetworkRegistry.INSTANCE.registerGuiHandler(getInstance(), proxy);
    }
public static void initRecipes()
{
	GameRegistry.addRecipe(new ItemStack(GuruItems.AIR_ORB), new Object[] {" X ", "X X", " X ", 'X', Items.FEATHER});
	GameRegistry.addRecipe(new ItemStack(GuruItems.WATER_ORB), new Object[] {" X ",  "X X", " X ", 'X', Items.WATER_BUCKET});
	GameRegistry.addRecipe(new ItemStack(GuruItems.EARTH_ORB), new Object[] {" X ",  "X X", " X ", 'X', Item.getItemFromBlock(Blocks.DIRT)});
	GameRegistry.addRecipe(new ItemStack(GuruItems.FIRE_ORB), new Object[] {" X ",  "X X", " X ", 'X', Items.LAVA_BUCKET});
	GameRegistry.addRecipe(new ItemStack(GuruItems.NETHER_ORB), new Object[] {" X ",  "X X", " X ", 'X', Item.getItemFromBlock(Blocks.OBSIDIAN)});
	GameRegistry.addRecipe(new ItemStack(GuruItems.AETHER_ORB), new Object[] {" X ",  "X X", " X ", 'X', Item.getItemFromBlock(Blocks.GLOWSTONE)});
}
public static Guru getInstance()
{
	return instance;
}
}

Link to comment
Share on other sites

try to fix it. use google

 

edit and post logs

 

Absolutely beautiful. Works like a charm. Thank you so much man, I've been at this for 5 days straight pretty much turned my brain into moosh.... Now, I need to look at why and how.

 

edit:

....man, thanks, now I can breathe.

Link to comment
Share on other sites

This is what I needed to know:

 

private static final ResourceLocation entitySphere = new ResourceLocation(Reference.MOD_ID, "EntitySphere");

 

public static void registerEntities() {
	EntityRegistry.registerModEntity(entitySphere, EntitySphere.class, entitySphere.toString(), id++, Exampled.getInstance(), 128, 214, true);
}

 

 

I was so friggin' close.... that rsrcl thing really screwed me up though.

 

{	
static ResourceLocation rscrl = new ResourceLocation(Reference.MOD_ID, "EntitySphere");

public static void registerEntities(ResourceLocation rsrcl) {
	// TODO Auto-generated method stub
	EntityRegistry.registerModEntity(rscrl, EntitySphere.class, rscrl.toString(), 0, Exampled.getInstance(), 128, 214, true);
}
}

 

 

 

5 days - non stop. >.< lmao... laughing at myself now.

Link to comment
Share on other sites

static ResourceLocation rscrl = new ResourceLocation(Reference.MOD_ID, "EntitySphere");

 

public static void registerEntities(ResourceLocation rsrcl)

 

You have two things named "rsrcl" and your code doesn't know which one you want.

Seriously, you're passing an object TO the method, you don't need the static final one.

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.

Link to comment
Share on other sites

but that object was/is null

private static ResourceLocation rsrcl;

 

While true, the point is he doesn't need it.  At all.  Ever.

The fact that he had it was to solve a problem with not knowing how to create resource locations, so he did it there, which was the wrongest place.

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.

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.

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.