Jump to content

Recommended Posts

Posted

okay I have a OnRightclick method that spawns 5 entitys into the world, the problem is, is that the item spawns 5 ghost entitys as well, here's my code.

package com.OlympiansMod.Item;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

import com.OlympiansMod.entity.EntitySGolem;
import com.OlympiansMod.entity.EntityUndead;

public class UndeadRomanSpawn extends Item{
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){
	if(!player.capabilities.isCreativeMode){
		--itemstack.stackSize;


	}

	EntityUndead undead = new EntityUndead(world);
	undead.setPosition(player.posX, player.posY, player.posZ);
	world.spawnEntityInWorld(undead);




	return itemstack;


}
}

 

 

Im serious don't look at it!!

Posted

Entities should be spawned server-side.

Wrap your spawning with if (!world.isRemote).

 

(I am not sure of stuff below, I am only pointing out what you might run into)

Also: After direct manipulation of ItemStack: "--itemstack.stackSize;" you might have to do player.inventory.detectAndSendChanges() (not sure about method name). You will most certainly NOT have to do this if you would run "--itemstack.stackSize;" on both sides, and spawning entity on server only.

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

Posted

ok I changed it but it still is not working

 

package com.OlympiansMod.Item;

import com.OlympiansMod.entity.EntityUndead;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class DioceltiansSepter extends Item{
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){
	if(player.capabilities.isCreativeMode){

	}	
	if(!world.isRemote);

	for (int i = 0 ; i < 5 ; i++){
	EntityUndead undead = new EntityUndead(world);
	undead.setPosition(player.posX, player.posY, player.posZ);
	world.spawnEntityInWorld(undead);



}
	return itemstack;


}
}


Im serious don't look at it!!

Posted

Isnt there a method that takes x, y, and z parameters? I think its world.spawnEntityInWorld(entity, x, y, z, motionX, motionY, motionZ);

 

I think your problem is that your entity hasn't been spawned before you set its coordinates.

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.