1.17.x ArmorStand problem

Discussion in 'Spigot Plugin Development' started by MrStreeet, Jun 15, 2021.

  1. I have two problems:

    Context: I'm making a graves plugin, basically when a player dies the plugin makes this construction:

    upload_2021-6-15_19-14-13.png

    1.- I can put armor on the armor stand, I looked in a lot of videos and threads and I didn't found anything.
    How can I stop this from happening?

    upload_2021-6-15_19-15-54.png

    2.- When a player dies, the armorstand (the hologram) it is generated exactly where the player has died and it is not centered in many cases as you can see in the image, how can I solve it?

    upload_2021-6-15_19-21-51.png

    Here's the code:

    Code (Java):
            Location loc3 = new Location(w, z, y, z);
            ArmorStand hologram = (ArmorStand) p.getWorld().spawnEntity(p.getLocation(),
                    EntityType.ARMOR_STAND);
            hologram.setVisible(false);
            hologram.setGravity(false);
            hologram.setBasePlate(false);
            hologram.setCanPickupItems(false);
            hologram.setInvulnerable(true);
            hologram.setCustomNameVisible(true);
            hologram.setHelmet(new ItemStack(Material.AIR));
            hologram.setChestplate(new ItemStack(Material.AIR));
            hologram.setLeggings(new ItemStack(Material.AIR));
            hologram.setBoots(new ItemStack(Material.AIR));
            hologram.setCustomName("§0§kLLL §6§lTUMBA DE §r§4§l" + p.getName() + " §0§kLLL");
    PD: I'm learning please don't be rude with me :D
     
    • Like Like x 1
  2. Hey, you can set the items from the armor stand via the hologram class. You need to cast it frome the entity. Check if the instance first. For Center the the location, try to set x, y, z to the block location and add 0.5d to x, z. The block location you access via Location#getBlockX()
     
  3. I made this and it worked!


    Code (Java):
        @EventHandler
        public void onPlayerInteractAtEntityEvent(PlayerInteractAtEntityEvent event) {
            if(event.getRightClicked() instanceof ArmorStand) {
                event.setCancelled(true);
            }
    Now I need to know how I can make a place entity event for the armor stand
     
    • Like Like x 1
  4. Btw this is veeeeeery bad. Unless you want to disable ALL armor stands
     
    • Funny Funny x 1
  5. Hey, you could do that by checking the entity spawn event and check if the entity is a armor stand. You would not be able to become the player. You could fix that by searching the nearest player who has a armor stand in hand or something like that.
     
  6. Create an empty array of locations and add a new location every time a player dies. Player won't be able to move or kill that armorstand, so you can check the clicked entity's location and if it matches one of the locations in the array you made previously, call your method.
     
  7. Or just use the armorstand‘s UUID :)
     
    • Funny Funny x 1