Advertisement
Guest User

Untitled

a guest
Nov 19th, 2013
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. package vgMod.DemonStone;
  2. import net.minecraft.entity.monster.EntityCreeper;
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.item.Item;
  5. import net.minecraft.item.ItemStack;
  6. import net.minecraft.server.MinecraftServer;
  7. import net.minecraft.world.World;
  8.  
  9. public class DemonStaff extends Item {
  10.    
  11.     //empty Entity Variable to be initialized later in the spawnTheMob method
  12.     private EntityCreeper creeper;
  13.     // static variable to keep track of how many entities have been spawned
  14.     static boolean hasSpawned = false;
  15.     //deceleration and initialization of boolean value to check if mob is dead
  16.     boolean isit_dead = false;
  17.    
  18.     // Constructor for demonstaff
  19.     public DemonStaff(int par1) {
  20.         super(par1);
  21.         setUnlocalizedName("DemonStaff");
  22.         setTextureName("vgdemonstone:DemonStaff");
  23.         // TODO Auto-generated constructor stub
  24.     }
  25.    
  26.     // logic for when right click is performed with item
  27.     public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer){
  28.         double  x = par3EntityPlayer.posX;
  29.         double  y = par3EntityPlayer.posY;
  30.         double  z = par3EntityPlayer.posZ;
  31.        
  32.       // give message if entity is spawned already
  33.        if (par2World.isRemote == false){
  34.            if(hasSpawned ==  true){
  35.                
  36.                if( creeper.isDead == true){
  37.                  hasSpawned = false;
  38.                  spawnTheMob(par3EntityPlayer);
  39.                  return par1ItemStack;
  40.                }
  41.            
  42.             par3EntityPlayer.addChatMessage("can only spawn 1 at a time");
  43.            
  44.            }
  45.        }
  46.        
  47.      // spawn in entity
  48.        if ( hasSpawned == false){
  49.             if (par2World.isRemote == false){
  50.                     spawnTheMob(par3EntityPlayer);
  51.             }
  52.        }
  53.                
  54.        return par1ItemStack;
  55.    
  56.      }
  57.    
  58.     //method for spawning the entity
  59.     void spawnTheMob (EntityPlayer par3EntityPlayer){
  60.         double  x = par3EntityPlayer.posX;
  61.         double  y = par3EntityPlayer.posY;
  62.         double  z = par3EntityPlayer.posZ;
  63.             EntityCreeper spawnMob = new EntityCreeper(par3EntityPlayer.getEntityWorld());
  64.             spawnMob.setPositionAndUpdate(x + 5, y + 10,z);
  65.             par3EntityPlayer.getEntityWorld().spawnEntityInWorld(spawnMob);
  66.             hasSpawned = true;
  67.             //assigns the spawnmob object to a null object stored in the class scope
  68.             creeper = spawnMob;
  69.     }
  70.    
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement