Jump to content

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


Recommended Posts

Posted

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;
}
}

Posted

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;
}
}

Posted

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.

Posted

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.

Posted

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.

Posted

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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