Hi, I am very new to modding and I am trying to make an item that spawns an entity, but every time i use it, it spawns 2 entities. one that is normal and has ai and health and everything, and one that is invulnerable and never moves. I have been searching google for an hour and havent found any help. Could you post the piece of code that spawns them normally? An help would be very appreciated.
Also how do you make it spawn on the block you click or at least in front of you?
Without seeing your code I'm guessing you are spawning the item once on the server and a second time on the client. When you use an item the code for onItemRightClick is run on both the server and the client. You need to check and then choose the side you want to you. In your case I suspect you want to only run on the server side.
Example:
/**
* Called whenever this item is equipped and the right mouse button is
* pressed. Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
EntityPlayer par3EntityPlayer) {
if (!par2World.isRemote) {
// Server Side
par2World.spawnEntityInWorld(new EntityCherryBomb(par2World,
par3EntityPlayer).setParams(explosionSize, mobDamage));
}
return par1ItemStack;
}
Also how do you make it spawn on the block you click or at least in front of you?
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumExample:
/** * Called whenever this item is equipped and the right mouse button is * pressed. Args: itemStack, world, entityPlayer */ @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par2World.isRemote) { // Server Side par2World.spawnEntityInWorld(new EntityCherryBomb(par2World, par3EntityPlayer).setParams(explosionSize, mobDamage)); } return par1ItemStack; }