org.bukkit.entity.ArmorStand Java Examples

The following examples show how to use org.bukkit.entity.ArmorStand. 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 check out the related API usage on the sidebar.
Example #1
Source File: Uncarried.java    From PGM with 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
Source File: MainListener.java    From ArmorStandTools with 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 #3
Source File: DisplayProtectionListener.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
@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 #4
Source File: DisplayBugFixListener.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
@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 #5
Source File: ArmorStandDisplayItem.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
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 #6
Source File: ArmorStandDisplayItem.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
@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 #7
Source File: ArmorStandDisplayItem.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
@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 #8
Source File: HologramProjector.java    From Slimefun4 with 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 #9
Source File: SitListener.java    From NyaaUtils with 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 #10
Source File: ArmorStandFactory.java    From CS-CoreLib with 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 #11
Source File: HealthDisplay.java    From EliteMobs with 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 File: Compat18.java    From RedProtect with 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 #13
Source File: DisplayArmorstand.java    From AstralEdit with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the pose of
 *
 * @param angle angle
 */
@Override
public void setHeadPose(EulerAngle angle) {
    ((ArmorStand) this.armorStand.getBukkitEntity()).setHeadPose(angle);
    final PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(this.armorStand.getId(), this.armorStand.getDataWatcher(), true);
    this.sendPacket(packet);
}
 
Example #14
Source File: MainListener.java    From ArmorStandTools with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    final Player p = event.getPlayer();
    boolean sameWorld = event.getFrom().getWorld() == event.getTo().getWorld();
    if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) {
        UUID uuid = event.getPlayer().getUniqueId();
        final ArmorStand as = plugin.carryingArmorStand.get(uuid);
        if (as == null || as.isDead()) {
            plugin.carryingArmorStand.remove(p.getUniqueId());
            Utils.actionBarMsg(p, Config.asDropped);
            return;
        }
        if(sameWorld || Config.allowMoveWorld) {
            new BukkitRunnable() {
                @Override
                public void run() {
                    as.teleport(Utils.getLocationFacing(p.getLocation()));
                    Utils.actionBarMsg(p, Config.carrying);
                }
            }.runTaskLater(plugin, 1L);
        } else {
            plugin.returnArmorStand(plugin.carryingArmorStand.get(uuid));
            plugin.carryingArmorStand.remove(uuid);
            if (plugin.savedInventories.containsKey(uuid)) {
                plugin.restoreInventory(p);
            }
        }
    }
    if(Config.deactivateOnWorldChange && !sameWorld && plugin.savedInventories.containsKey(p.getUniqueId())) {
        plugin.restoreInventory(p);
    }
}
 
Example #15
Source File: DisplayArmorstand.java    From AstralEdit with 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 #16
Source File: SitListener.java    From NyaaUtils with MIT License 5 votes vote down vote up
@EventHandler
public void onQuit(PlayerQuitEvent event) {
    Player player = event.getPlayer();
    Entity vehicle = player.getVehicle();
    if (safeLocations.containsKey(player.getUniqueId()) && player.isInsideVehicle() && vehicle instanceof ArmorStand) {
        safeLocations.remove(player.getUniqueId());
        player.leaveVehicle();
        vehicle.remove();
    }
}
 
Example #17
Source File: SimpleHologram.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
public static ArmorStand create(Location l) {
    ArmorStand armorStand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
    armorStand.setVisible(false);
    armorStand.setSilent(true);
    armorStand.setMarker(true);
    armorStand.setGravity(false);
    armorStand.setBasePlate(false);
    armorStand.setCustomNameVisible(true);
    armorStand.setRemoveWhenFarAway(false);
    return armorStand;
}
 
Example #18
Source File: SimpleHologram.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
public static void remove(Block b) {
    Slimefun.runSync(() -> {
        ArmorStand hologram = getArmorStand(b, false);

        if (hologram != null) {
            hologram.remove();
        }
    });
}
 
Example #19
Source File: MobsMatchModule.java    From PGM with 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 #20
Source File: MainListener.java    From ArmorStandTools with MIT License 5 votes vote down vote up
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
    Player p = event.getPlayer();
    if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) {
        ArmorStand as = plugin.carryingArmorStand.get(p.getUniqueId());
        if (as == null || as.isDead()) {
            plugin.carryingArmorStand.remove(p.getUniqueId());
            Utils.actionBarMsg(p, Config.asDropped);
            return;
        }
        as.teleport(Utils.getLocationFacing(event.getTo()));
        Utils.actionBarMsg(p, Config.carrying);
    }
}
 
Example #21
Source File: ArmorStandFactory.java    From CS-CoreLib with GNU General Public License v3.0 5 votes vote down vote up
public static ArmorStand createHidden(Location l) {
	ArmorStand armorStand = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
	armorStand.setVisible(false);
	armorStand.setSilent(true);
	armorStand.setMarker(true);
	armorStand.setGravity(false);
	armorStand.setBasePlate(false);
	armorStand.setCustomNameVisible(true);
	armorStand.setRemoveWhenFarAway(false);
	
	return armorStand;
}
 
Example #22
Source File: DisplayArmorstand.java    From AstralEdit with 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 #23
Source File: DisplayArmorstand.java    From AstralEdit with 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 #24
Source File: DisplayArmorstand.java    From AstralEdit with 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 #25
Source File: DisplayArmorstand.java    From AstralEdit with 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 #26
Source File: DisplayArmorstand.java    From AstralEdit with 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 #27
Source File: HologramProjector.java    From Slimefun4 with 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();
    }
}
 
Example #28
Source File: DisplayArmorstand.java    From AstralEdit with 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 #29
Source File: DisplayArmorstand.java    From AstralEdit with 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 #30
Source File: DisplayArmorstand.java    From AstralEdit with 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);
}