Jump to content

1.7.10 Spawn egg/ Spawn Item is spawning ghost entitys which cause extreme lag


Recommended Posts

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!!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!!

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.