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

Hello guys, I'm having a problem, I'm making a block spawn items when it's break, but for some reason the spawnEntityInWorld it does spawn the item on the x y x specified but the items float to the west ending at around 1 or 2 blocks to the West from where they were called.

 

Is there a way to fix this? Does this happen for any reason?

 

I know I could do x+1 or x+2 when I call the item to spawn, but it doesn't look good, I would like them to spawn in place and not move.

 

Thanks in advance for any tip ;)

  • Author

Set their velocity to 0.

 

Thanks diesieben07, but I seem to be having some problems, most likely because I'm not really that good and Modding or even with Java :P lol

 

It works when I do:

 

ItemStack drop0 = new ItemStack(Items.apple,reward,0);

	EntityItem itemDrop = new EntityItem(world, x, y, z, drop0);

	world.spawnEntityInWorld(itemDrop);

 

But when I add:

 

		ItemStack drop0 = new ItemStack(Items.apple,reward,0);

	EntityItem itemDrop = new EntityItem(world, x, y, z, drop0);

	world.spawnEntityInWorld(itemDrop.setVelocity(0F, 0F, 0F));

 

 

I get an error saying:

 

The method spawnEntityInWorld(Entity) in the type World is not applicable for the arguments(void)

 

The code is like this:

 

	public static void init(World world, int x, int y, int z)
{
	//Amount of items
	final int reward = (int) ((Math.random() * +2);
   		   	
	ItemStack drop0 = new ItemStack(Items.apple,reward,0);

	EntityItem itemDrop = new EntityItem(world, x, y, z, drop0);

	world.spawnEntityInWorld(itemDrop.setVelocity(0F, 0F, 0F));

}

 

I know I must be falling into some mistake because I'm not sure what I'm doing :P lol

setVelocity does NOT return EntityItem, its a void method. Learn java.

 

1st setVelocity, then in next line spawn entity.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

setVelocity does NOT return EntityItem, its a void method. Learn java.

 

1st setVelocity, then in next line spawn entity.

 

I tired to learn Java several times, but it's way too confusing for me.

 

I think I see what you mean, I will give a try and see if I get it.

 

PS: I'm trying to learn, but again, Java beats me :P

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.