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.

Featured Replies

Posted

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?

Just change the output of the GameRegistry.addShapedRecipe or GameRegistry.addShapelessRecipe to your egg's id.

If I helped, please click the 'Thank you'!

 

 

 

 

.

  • 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.

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

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.

  • 2 months later...

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 :)

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.

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.