Java Code Examples for org.bukkit.entity.ArmorStand

The following examples show how to use org.bukkit.entity.ArmorStand. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: PGM   Source File: Uncarried.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
protected void placeBanner() {
  if (!this.flag.canDropOn(oldBase)) {
    oldBase.getBlock().setType(Material.SEA_LANTERN, false);
  } else if (Materials.isWater(oldBase.getType())) {
    oldBase.getBlock().setType(Material.ICE, false);
  }

  Materials.placeStanding(this.location, this.flag.getBannerMeta());

  this.labelEntity =
      this.location.getWorld().spawn(this.location.clone().add(0, 1.7, 0), ArmorStand.class);
  this.labelEntity.setVisible(false);
  this.labelEntity.setMarker(true);
  this.labelEntity.setGravity(false);
  this.labelEntity.setRemoveWhenFarAway(false);
  this.labelEntity.setSmall(true);
  this.labelEntity.setArms(false);
  this.labelEntity.setBasePlate(false);
  this.labelEntity.setCustomName(this.flag.getColoredName());
  this.labelEntity.setCustomNameVisible(true);
}
 
Example 2
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void entity(EntityDeathEvent event) {
    if (!useEnhanceProtection) {
        return;
    }
    if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
        return;
    }
    if (!(event.getEntity() instanceof ArmorStand)) {
        return;
    }
    if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) {
        return;
    }
    event.setDroppedExp(0);
    event.getDrops().clear();
}
 
Example 3
@EventHandler(ignoreCancelled = true)
public void canBuild(BlockCanBuildEvent e) {
    if (!plugin.isDisplay()
            || DisplayItem.getNowUsing() != DisplayType.ARMORSTAND
            || e.isBuildable()) {
        return;
    }

    final Collection<Entity> entities =
            e.getBlock().getWorld().getNearbyEntities(e.getBlock().getLocation(), 1.0, 1, 1.0);

    for (final Entity entity : entities) {
        if (!(entity instanceof ArmorStand)
                || !DisplayItem.checkIsGuardItemStack(((ArmorStand) entity).getItemInHand())) {
            continue;
        }

        e.setBuildable(true);
        Util.debugLog(
                "Re-set the allowed build flag here because it found the cause of the display-item blocking it before.");
        return;
    }
}
 
Example 4
public void fixDisplayMovedOld() {
    for (Entity entity : Objects.requireNonNull(this.shop.getLocation().getWorld()).getEntities()) {
        if (!(entity instanceof ArmorStand)) {
            continue;
        }
        ArmorStand eArmorStand = (ArmorStand) entity;
        if (eArmorStand.getUniqueId().equals(Objects.requireNonNull(this.armorStand).getUniqueId())) {
            Util.debugLog(
                    "Fixing moved ArmorStand displayItem "
                            + eArmorStand.getUniqueId()
                            + " at "
                            + eArmorStand.getLocation());
            eArmorStand.teleport(getDisplayLocation());
            return;
        }
    }
}
 
Example 5
@Override
public boolean removeDupe() {
    if (this.armorStand == null) {
        Util.debugLog("Warning: Trying to removeDupe for a null display shop.");
        return false;
    }
    boolean removed = false;
    for (Entity entity : armorStand.getNearbyEntities(1.5, 1.5, 1.5)) {
        if (entity.getType() != EntityType.ARMOR_STAND) {
            continue;
        }
        ArmorStand eArmorStand = (ArmorStand) entity;

        if (!eArmorStand.getUniqueId().equals(this.armorStand.getUniqueId())) {
            if (DisplayItem.checkIsTargetShopDisplay(eArmorStand.getItemInHand(), this.shop)) {
                Util.debugLog("Removing dupes ArmorEntity " + eArmorStand.getUniqueId() + " at " + eArmorStand.getLocation());
                entity.remove();
                removed = true;
            }
        }
    }
    return removed;
}
 
Example 6
@Override
public void safeGuard(@NotNull Entity entity) {
    if (!(entity instanceof ArmorStand)) {
        Util.debugLog(
                "Failed to safeGuard " + entity.getLocation() + ", cause target not a ArmorStand");
        return;
    }
    ArmorStand armorStand = (ArmorStand) entity;
    // Set item protect in the armorstand's hand
    this.guardedIstack = DisplayItem.createGuardItemStack(this.originalItemStack, this.shop);
    armorStand.setHelmet(guardedIstack);
    try {
        armorStand
                .getPersistentDataContainer()
                .set(
                        new NamespacedKey(plugin, "displayMark"),
                        DisplayItemPersistentDataType.INSTANCE,
                        DisplayItem.createShopProtectionFlag(this.originalItemStack, shop));
    } catch (Throwable ignored) {
    }
}
 
Example 7
Source Project: Slimefun4   Source File: HologramProjector.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static ArmorStand getArmorStand(Block projector, boolean createIfNoneExists) {
    String nametag = BlockStorage.getLocationInfo(projector.getLocation(), "text");
    double offset = Double.parseDouble(BlockStorage.getLocationInfo(projector.getLocation(), "offset"));
    Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5);

    for (Entity n : l.getChunk().getEntities()) {
        if (n instanceof ArmorStand && n.getCustomName() != null && n.getCustomName().equals(nametag) && l.distanceSquared(n.getLocation()) < 0.4D) {
            return (ArmorStand) n;
        }
    }

    if (!createIfNoneExists) {
        return null;
    }

    ArmorStand hologram = SimpleHologram.create(l);
    hologram.setCustomName(nametag);
    return hologram;
}
 
Example 8
Source Project: ArmorStandTools   Source File: MainListener.java    License: MIT License 6 votes vote down vote up
private ArmorStand spawnArmorStand(Location l) {
    ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
    as.setHelmet(Config.helmet);
    as.setChestplate(Config.chest);
    as.setLeggings(Config.pants);
    as.setBoots(Config.boots);
    as.getEquipment().setItemInMainHand(Config.itemInHand);
    as.getEquipment().setItemInOffHand(Config.itemInOffHand);
    as.setVisible(Config.isVisible);
    as.setSmall(Config.isSmall);
    as.setArms(Config.hasArms);
    as.setBasePlate(Config.hasBasePlate);
    as.setGravity(Config.hasGravity);
    as.setInvulnerable(Config.invulnerable);
    if(Config.defaultName.length() > 0) {
        as.setCustomName(Config.defaultName);
        as.setCustomNameVisible(true);
    }
    Main.nms.setSlotsDisabled(as, Config.equipmentLock);
    return as;
}
 
Example 9
Source Project: CS-CoreLib   Source File: ArmorStandFactory.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static ArmorStand createSmall(Location l, ItemStack item, EulerAngle arm, float yaw) {
	l.setYaw(yaw);
	ArmorStand armorStand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
	armorStand.getEquipment().setItemInMainHand(item);
	armorStand.setVisible(false);
	armorStand.setSilent(true);
	armorStand.setMarker(true);
	armorStand.setGravity(false);
	armorStand.setSmall(true);
	armorStand.setArms(true);
	armorStand.setRightArmPose(arm);
	armorStand.setBasePlate(false);
	armorStand.setRemoveWhenFarAway(false);
	
	return armorStand;
}
 
Example 10
Source Project: RedProtect   Source File: Compat18.java    License: GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onAttemptInteractAS(PlayerInteractAtEntityEvent e) {

    Entity ent = e.getRightClicked();
    Location l = ent.getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    Player p = e.getPlayer();
    if (r == null) {
        //global flags
        if (ent instanceof ArmorStand) {
            if (!RedProtect.get().config.globalFlagsRoot().worlds.get(l.getWorld().getName()).build) {
                e.setCancelled(true);
                return;
            }
        }
        return;
    }

    if (ent instanceof ArmorStand) {
        if (!r.canBuild(p)) {
            RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantedit");
            e.setCancelled(true);
        }
    }
}
 
Example 11
Source Project: EliteMobs   Source File: HealthDisplay.java    License: GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onHit(EntityDamageEvent event) {

    if (event.isCancelled()) return;

    if (!(event.getEntity() instanceof LivingEntity) || event.getEntity() instanceof ArmorStand) return;

    if (ConfigValues.mobCombatSettingsConfig.getBoolean(MobCombatSettingsConfig.ONLY_SHOW_HEALTH_FOR_ELITE_MOBS)) {
        if (EntityTracker.isEliteMob(event.getEntity()))
            displayHealth((LivingEntity) event.getEntity(), event.getFinalDamage());
        else if (EntityTracker.isSuperMob(event.getEntity()))
            displayHealth((LivingEntity) event.getEntity(), event.getFinalDamage());

    } else
        displayHealth((LivingEntity) event.getEntity(), event.getFinalDamage());

}
 
Example 12
Source Project: NyaaUtils   Source File: SitListener.java    License: MIT License 6 votes vote down vote up
@EventHandler
public void onDismount(EntityDismountEvent event) {
    if (event.getDismounted() instanceof ArmorStand) {
        ArmorStand armorStand = (ArmorStand) event.getDismounted();
        if (armorStand.hasMetadata(metadata_key)) {
            for (Entity p : armorStand.getPassengers()) {
                if (p.isValid()) {
                    Location loc = safeLocations.get(p.getUniqueId());
                    safeLocations.remove(p.getUniqueId());
                    new BukkitRunnable() {
                        @Override
                        public void run() {
                            if (p.isValid() && loc != null) {
                                p.teleport(loc);
                            }
                        }
                    }.runTask(plugin);
                }
            }
        }
        armorStand.remove();
    }
}
 
Example 13
Source Project: PGM   Source File: MobsMatchModule.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void checkSpawn(final CreatureSpawnEvent event) {
  if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM
      || event.getEntity() instanceof ArmorStand) {
    return;
  }

  QueryResponse response =
      this.mobsFilter.query(
          new EntitySpawnQuery(event, event.getEntity(), event.getSpawnReason()));
  event.setCancelled(response.isDenied());
}
 
Example 14
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void entity(EntityDamageEvent event) {
    if (!(event.getEntity() instanceof ArmorStand)) {
        return;
    }
    if (DisplayItem.getNowUsing() != DisplayType.ARMORSTAND) {
        return;
    }
    if (!DisplayItem.checkIsGuardItemStack(((ArmorStand) event.getEntity()).getItemInHand())) {
        return;
    }
    event.setCancelled(true);
}
 
Example 15
@Override
public boolean checkIsShopEntity(@NotNull Entity entity) {
    if (!(entity instanceof ArmorStand)) {
        return false;
    }
    return DisplayItem.checkIsGuardItemStack(((ArmorStand) entity).getItemInHand());
}
 
Example 16
Source Project: ArmorStandTools   Source File: NMS.java    License: MIT License 5 votes vote down vote up
void generateCmdBlock(Location l, ArmorStand as) {
    Block b = l.getBlock();
    b.setType(Material.COMMAND_BLOCK);
    CommandBlock cb = (CommandBlock) b.getState();
    cb.setCommand("summon minecraft:armor_stand " + Utils.twoDec(as.getLocation().getX()) + " " + Utils.twoDec(as.getLocation().getY()) + " " + Utils.twoDec(as.getLocation().getZ()) + " "
        + "{"
            + (as.isVisible()                  ? ""                     : "Invisible:1,"                                                  )
            + (as.hasBasePlate()               ? ""                     : "NoBasePlate:1,"                                                )
            + (as.hasGravity()                 ? ""                     : "NoGravity:1,"                                                  )
            + (as.hasArms()                    ? "ShowArms:1,"          : ""                                                              )
            + (as.isSmall()                    ? "Small:1,"             : ""                                                              )
            + (as.isInvulnerable()             ? "Invulnerable:1,"      : ""                                                              )
            + (as.isGlowing()                  ? "Glowing:1,"           : ""                                                              )
            + (getDisabledSlots(as) == 0       ? ""                     : ("DisabledSlots:" + getDisabledSlots(as) + ",")                 )
            + (as.isCustomNameVisible()        ? "CustomNameVisible:1," : ""                                                              )
            + (as.getCustomName() == null      ? ""                     : ("CustomName:\"\\\"" + as.getCustomName() + "\\\"\",")          )
            + (as.getLocation().getYaw() == 0F ? ""                     : ("Rotation:[" + Utils.twoDec(as.getLocation().getYaw()) + "f],"))
            + "ArmorItems:["
                + (as.getBoots()      == null ? "{}," : ("{id:" + as.getBoots().getType().getKey().getKey()      + ",Count:" + as.getBoots().getAmount()      + ",tag:{Damage:" + as.getBoots().getDurability()      + getItemStackTags(as.getBoots())                               + "}},"))
                + (as.getLeggings()   == null ? "{}," : ("{id:" + as.getLeggings().getType().getKey().getKey()   + ",Count:" + as.getLeggings().getAmount()   + ",tag:{Damage:" + as.getLeggings().getDurability()   + getItemStackTags(as.getLeggings())                            + "}},"))
                + (as.getChestplate() == null ? "{}," : ("{id:" + as.getChestplate().getType().getKey().getKey() + ",Count:" + as.getChestplate().getAmount() + ",tag:{Damage:" + as.getChestplate().getDurability() + getItemStackTags(as.getChestplate())                          + "}},"))
                + (as.getHelmet()     == null ? "{}"  : ("{id:" + as.getHelmet().getType().getKey().getKey()     + ",Count:" + as.getHelmet().getAmount()     + ",tag:{Damage:" + as.getHelmet().getDurability()     + getItemStackTags(as.getHelmet()) + skullOwner(as.getHelmet()) + "}}" ))
            + "],"
            + "HandItems:["
                + (as.getEquipment().getItemInMainHand() == null ? "{}," : ("{id:" + as.getEquipment().getItemInMainHand().getType().getKey().getKey() + ",Count:" + as.getEquipment().getItemInMainHand().getAmount() + ",tag:{Damage:" + as.getEquipment().getItemInMainHand().getDurability() + getItemStackTags(as.getEquipment().getItemInMainHand()) + "}},"))
                + (as.getEquipment().getItemInOffHand()  == null ? "{}"  : ("{id:" + as.getEquipment().getItemInOffHand().getType().getKey().getKey()  + ",Count:" + as.getEquipment().getItemInOffHand().getAmount()  + ",tag:{Damage:" + as.getEquipment().getItemInOffHand().getDurability()  + getItemStackTags(as.getEquipment().getItemInOffHand())  + "}}" ))
            + "],"
            + "Pose:{"
                + "Body:["     + Utils.angle(as.getBodyPose().getX())     + "f," + Utils.angle(as.getBodyPose().getY())     + "f," + Utils.angle(as.getBodyPose().getZ())     + "f],"
                + "Head:["     + Utils.angle(as.getHeadPose().getX())     + "f," + Utils.angle(as.getHeadPose().getY())     + "f," + Utils.angle(as.getHeadPose().getZ())     + "f],"
                + "LeftLeg:["  + Utils.angle(as.getLeftLegPose().getX())  + "f," + Utils.angle(as.getLeftLegPose().getY())  + "f," + Utils.angle(as.getLeftLegPose().getZ())  + "f],"
                + "RightLeg:[" + Utils.angle(as.getRightLegPose().getX()) + "f," + Utils.angle(as.getRightLegPose().getY()) + "f," + Utils.angle(as.getRightLegPose().getZ()) + "f],"
                + "LeftArm:["  + Utils.angle(as.getLeftArmPose().getX())  + "f," + Utils.angle(as.getLeftArmPose().getY())  + "f," + Utils.angle(as.getLeftArmPose().getZ())  + "f],"
                + "RightArm:[" + Utils.angle(as.getRightArmPose().getX()) + "f," + Utils.angle(as.getRightArmPose().getY()) + "f," + Utils.angle(as.getRightArmPose().getZ()) + "f]"
            + "}"
        + "}"
    );
    cb.update();
}
 
Example 17
Source Project: UHC   Source File: DeathStandsModule.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
protected Map<EquipmentSlot, ItemStack> getItems(ArmorStand stand) {
    final Map<EquipmentSlot, ItemStack> slots = Maps.newHashMapWithExpectedSize(5);

    slots.put(EquipmentSlot.HAND, stand.getItemInHand());
    slots.put(EquipmentSlot.HEAD, stand.getHelmet());
    slots.put(EquipmentSlot.CHEST, stand.getChestplate());
    slots.put(EquipmentSlot.LEGS, stand.getLeggings());
    slots.put(EquipmentSlot.FEET, stand.getBoots());

    return slots;
}
 
Example 18
Source Project: helper   Source File: BukkitHologramFactory.java    License: MIT License 5 votes vote down vote up
@Override
public boolean isSpawned() {
    if (!this.spawned) {
        return false;
    }

    for (ArmorStand stand : this.spawnedEntities) {
        if (!stand.isValid()) {
            return false;
        }
    }

    return true;
}
 
Example 19
Source Project: helper   Source File: PacketIndividualHologramFactory.java    License: MIT License 5 votes vote down vote up
private Position getNewLinePosition() {
    if (this.spawnedEntities.isEmpty()) {
        return this.position;
    } else {
        // get the last entry
        ArmorStand last = this.spawnedEntities.get(this.spawnedEntities.size() - 1).getArmorStand();
        return Position.of(last.getLocation()).subtract(0.0d, 0.25d, 0.0d);
    }
}
 
Example 20
Source Project: ArmorStandTools   Source File: Main.java    License: MIT License 5 votes vote down vote up
void returnArmorStand(ArmorStand as) {
    if(as.hasMetadata("startLoc")) {
        for (MetadataValue value : as.getMetadata("startLoc")) {
            if (value.getOwningPlugin() == this) {
                as.teleport((Location) value.value());
                as.removeMetadata("startLoc", this);
                return;
            }
        }
    }
    as.remove();
}
 
Example 21
Source Project: helper   Source File: PacketIndividualHologramFactory.java    License: MIT License 5 votes vote down vote up
@Nullable
@Override
public ArmorStand getArmorStand(int line) {
    if (line >= spawnedEntities.size()) {
        return null;
    }
    return spawnedEntities.get(line).armorStand;
}
 
Example 22
Source Project: UHC   Source File: DeathStandsModule.java    License: MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void on(EntityDamageEvent event) {
    if (event.getEntityType() != EntityType.ARMOR_STAND) return;

    if (!isProtectedArmourStand(event.getEntity())) return;

    // always cancel events, we choose when to break the stand
    event.setCancelled(true);

    final ArmorStand stand = (ArmorStand) event.getEntity();
    final Location loc = stand.getLocation();
    final World world = stand.getWorld();

    // for the first 2 seconds don't allow breaking
    // to avoid accidental breaks after kill
    if (event.getEntity().getTicksLived() < 2 * TICKS_PER_SECOND) {
        world.playEffect(stand.getEyeLocation(), Effect.WITCH_MAGIC, 0);
        return;
    }

    // drop each of it's worn items
    for (final ItemStack stack : Maps.filterValues(getItems(stand), Predicates.not(EMPTY_ITEM)).values()) {
        world.dropItemNaturally(loc, stack);
    }

    // kill the stand now
    stand.remove();
}
 
Example 23
Source Project: ArmorStandTools   Source File: MainListener.java    License: MIT License 5 votes vote down vote up
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if(event.getEntity() instanceof ArmorStand) {
        ArmorStand as = (ArmorStand) event.getEntity();
        if(ArmorStandGUI.isInUse(as) || as.isInvulnerable()) {
            event.setCancelled(true);
        }
    }
}
 
Example 24
Source Project: ProjectAres   Source File: NMSHacks.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
public static void enableArmorSlots(ArmorStand armorStand, boolean enabled) {
    CraftArmorStand craftArmorStand = (CraftArmorStand) armorStand;
    NBTTagCompound nbt = new NBTTagCompound();
    craftArmorStand.getHandle().b(nbt);
    nbt.setInt("DisabledSlots", enabled ? 0 : 0x1f1f00);
    craftArmorStand.getHandle().a(nbt);
}
 
Example 25
Source Project: Civs   Source File: AreaTarget.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Set<?> getTargets() {
    int level = getLevel();
    Spell spell = getSpell();
    Set<LivingEntity> returnSet = new HashSet<>();
    if (!(getOrigin() instanceof LivingEntity)) {
        return returnSet;
    }
    LivingEntity player = (LivingEntity) getOrigin();
    ConfigurationSection config = getConfig();
    int range = (int) Math.round(Spell.getLevelAdjustedValue(getConfig().getString("range","15"), level, null, spell));
    int radius = (int) Math.round(Spell.getLevelAdjustedValue(getConfig().getString("radius", "5"), level, null, spell));
    int maxTargets = (int) Math.round(Spell.getLevelAdjustedValue(getConfig().getString("max-targets", "-1"), level, null, spell));
    Collection<Entity> nearbyEntities;
    if (range < 1) {
        nearbyEntities = player.getNearbyEntities(radius, radius, radius);
    } else {
        HashSet<Material> materialHashSet = new HashSet<>();
        Location center = player.getTargetBlock(materialHashSet, range).getLocation();
        center = applyTargetSettings(center);
        ArmorStand removeMe = (ArmorStand) center.getWorld().spawnEntity(center, EntityType.ARMOR_STAND);
        removeMe.setVisible(false);
        nearbyEntities = removeMe.getNearbyEntities(radius, radius, radius);
        removeMe.remove();
    }

    for (Entity target : nearbyEntities) {
        if (maxTargets > 0 && returnSet.size() >= maxTargets) {
            break;
        }

        if (target != player &&
                target instanceof LivingEntity) {

            returnSet.add((LivingEntity) target);
        }
    }
    return returnSet;
}
 
Example 26
Source Project: AstralEdit   Source File: DisplayArmorstand.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the armorstand
 *
 * @param player   player
 * @param location location
 * @param id       id
 * @param data     data
 * @param watchers watchers
 */
public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) {
    super();
    this.watchers = watchers;
    this.player = player;
    this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.armorStand.a(compound);
    this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0);
    this.storedId = id;
    this.storedData = data;

    ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data);
    this.getCraftEntity().setHelmet(stackBuilder.build());
    this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0));

    if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) {
        stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3);
        if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) {
            stackBuilder.setSkin(NMSRegistry.WATER_HEAD);
        } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) {
            stackBuilder.setSkin(NMSRegistry.LAVA_HEAD);
        } else {
            stackBuilder.setSkin(NMSRegistry.NOT_FOUND);
        }
        ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build());
    }
}
 
Example 27
Source Project: AstralEdit   Source File: DisplayArmorstand.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Spawns the armorstand
 */
@Override
public void spawn() {
    final PacketPlayOutSpawnEntityLiving packetSpawn = new PacketPlayOutSpawnEntityLiving(this.armorStand);
    final PacketPlayOutEntityEquipment packetHead =
            new PacketPlayOutEntityEquipment(this.armorStand.getId(), 3, CraftItemStack.asNMSCopy(((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet()));
    this.sendPacket(packetSpawn);
    this.sendPacket(packetHead);
}
 
Example 28
Source Project: AstralEdit   Source File: DisplayArmorstand.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the armorstand
 *
 * @param player   player
 * @param location location
 * @param id       id
 * @param data     data
 * @param watchers watchers
 */
public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) {
    super();
    this.watchers = watchers;
    this.player = player;
    this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.armorStand.a(compound);
    this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0);
    this.storedId = id;
    this.storedData = data;

    ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data);
    this.getCraftEntity().setHelmet(stackBuilder.build());
    this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setGlowing(true);

    if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) {
        stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3);
        if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) {
            stackBuilder.setSkin(NMSRegistry.WATER_HEAD);
        } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) {
            stackBuilder.setSkin(NMSRegistry.LAVA_HEAD);
        } else {
            stackBuilder.setSkin(NMSRegistry.NOT_FOUND);
        }
        ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build());
    }
}
 
Example 29
Source Project: AstralEdit   Source File: DisplayArmorstand.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Spawns the armorstand
 */
@Override
public void spawn() {
    final PacketPlayOutSpawnEntityLiving packetSpawn = new PacketPlayOutSpawnEntityLiving(this.armorStand);
    final PacketPlayOutEntityEquipment packetHead =
            new PacketPlayOutEntityEquipment(this.armorStand.getId(), EnumItemSlot.HEAD, CraftItemStack.asNMSCopy(((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet()));
    this.sendPacket(packetSpawn);
    this.sendPacket(packetHead);
}
 
Example 30
Source Project: Slimefun4   Source File: HologramProjector.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static void remove(Block b) {
    ArmorStand hologram = getArmorStand(b, false);

    if (hologram != null) {
        hologram.remove();
    }
}