Posted April 29, 201312 yr I'd like to make an item that would act as an egg and spawn a custom mob, but is craftable. Is this possible? If not, how could I make the mob's egg craftable?
April 29, 201312 yr Just change the output of the GameRegistry.addShapedRecipe or GameRegistry.addShapelessRecipe to your egg's id. If I helped, please click the 'Thank you'! .
April 29, 201312 yr Author How would I just use the ID instead of GameRegistry.addRecipe(new ItemStack(Mod.modItem, 1), new Object[] ?
April 29, 201312 yr Author Haven't figured this out yet, I just need an item that can be crafted and, upon right-clicking a block, spawn an entity.
April 30, 201312 yr First make your standard item class and register it and all that in your main mod class, I'm going to assume you know how to add in a custom recipe if not then stop here and go learn about that, because that's easy compared to making your own entity, anyway back to your item class add in this function public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffSet) { if (world.getBlockId(x, y + 1, z) == 0 && (world.getBlockId(x, y, z) == Block.grass.blockID || world.getBlockId(x, y, z) == Block.stone.blockID || world.getBlockId(x, y, z) == Block.dirt.blockID || world.getBlockId(x, y, z) == Block.sand.blockID)) { EntitySkeleton ent = new EntitySkeleton(world); //change to whatever entity you're trying to spawn ent.setLocationAndAngles(x, y + 1, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0.0F); ent.initCreature(); world.spawnEntityInWorld(ent); } return true; } that function will make it when ever they right click, it will spawn a skeleton, though you can change that to whatever, but first it checks if there's air for it to spawn and if you're spawning it on dirt, grass or sand, though you can take that check out if you wish
April 30, 201312 yr That works but it seems to spawn ghosts of the entity... check if worldObj.isRemote is false when you're trying to spawn something. Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
July 24, 201312 yr tihs works but the mob usually gets suffocated because they appear on corners I like helping people because i was also in a same problem and i do not like unfinished work, so a thank you will be enough for the people im helping and a thank you to the people that helped me
July 24, 201312 yr tihs works but the mob usually gets suffocated because they appear on corners Then adjust where it spawns
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.