Advertisement
Mrolcraft

SpawnWither

Mar 10th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. import net.minecraft.server.v1_8_R3.Entity;
  2. import net.minecraft.server.v1_8_R3.NBTTagCompound;
  3. import org.bukkit.Location;
  4. import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
  5. import org.bukkit.entity.EntityType;
  6. import org.bukkit.entity.Wither;
  7.  
  8. public class SpawnWither {
  9.  
  10.     private Wither wither;
  11.     private Location location;
  12.     private String nameWither;
  13.  
  14.     public SpawnWither(Location location, String nameWither){
  15.         this.location = location;
  16.         this.nameWither = nameWither;
  17.         this.wither = (Wither) this.location.getWorld().spawnEntity(this.location, EntityType.WITHER);
  18.         Entity nmsEntity = ((CraftEntity) this.wither).getHandle();
  19.         nmsEntity.setCustomName(this.nameWither);
  20.         nmsEntity.setCustomNameVisible(true);
  21.  
  22.         this.wither.setHealth(15);
  23.  
  24.         NBTTagCompound witherTag = nmsEntity.getNBTTag();
  25.         if(witherTag == null){
  26.             witherTag = new NBTTagCompound();
  27.         }
  28.  
  29.         nmsEntity.c(witherTag);
  30.         witherTag.setInt("NoAI", 1);
  31.         nmsEntity.f(witherTag);
  32.     }
  33.  
  34.     public double getHealth(){
  35.         return wither.getHealth();
  36.     }
  37.  
  38.     public void setHealth(double health){
  39.         wither.setHealth(health);
  40.     }
  41.  
  42.     public Location getLocation(){
  43.         return location;
  44.     }
  45.  
  46.     public String getName(){
  47.         return nameWither;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement