package vgMod.DemonStone ;

import net.minecraft.entity.monster.EntityCreeper ;

import net.minecraft.entity.player.EntityPlayer ;

import net.minecraft.item.Item ;

import net.minecraft.item.ItemStack ;

import net.minecraft.server.MinecraftServer ;

import net.minecraft.world.World ;

public class DemonStaff extends Item {

//empty Entity Variable to be initialized later in the spawnTheMob method

private EntityCreeper creeper ;

// static variable to keep track of how many entities have been spawned

static boolean hasSpawned = false ;

//deceleration and initialization of boolean value to check if mob is dead

boolean isit_dead = false ;

// Constructor for demonstaff

public DemonStaff ( int par1 ) {

super ( par1 ) ;

setUnlocalizedName ( "DemonStaff" ) ;

setTextureName ( "vgdemonstone:DemonStaff" ) ;

// TODO Auto-generated constructor stub

}

// logic for when right click is performed with item

public ItemStack onItemRightClick ( ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer ) {

double x = par3EntityPlayer. posX ;

double y = par3EntityPlayer. posY ;

double z = par3EntityPlayer. posZ ;

// give message if entity is spawned already

if ( par2World. isRemote == false ) {

if ( hasSpawned == true ) {

if ( creeper. isDead == true ) {

hasSpawned = false ;

spawnTheMob ( par3EntityPlayer ) ;

return par1ItemStack ;

}

par3EntityPlayer. addChatMessage ( "can only spawn 1 at a time" ) ;

}

}

// spawn in entity

if ( hasSpawned == false ) {

if ( par2World. isRemote == false ) {

spawnTheMob ( par3EntityPlayer ) ;

}

}

return par1ItemStack ;

}

//method for spawning the entity

void spawnTheMob ( EntityPlayer par3EntityPlayer ) {

double x = par3EntityPlayer. posX ;

double y = par3EntityPlayer. posY ;

double z = par3EntityPlayer. posZ ;

EntityCreeper spawnMob = new EntityCreeper ( par3EntityPlayer. getEntityWorld ( ) ) ;

spawnMob. setPositionAndUpdate ( x + 5 , y + 10 ,z ) ;

par3EntityPlayer. getEntityWorld ( ) . spawnEntityInWorld ( spawnMob ) ;

hasSpawned = true ;

//assigns the spawnmob object to a null object stored in the class scope

creeper = spawnMob ;

}