Jump to content

spawnEntityInWorld goes WEST


American2050

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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.