Display guardian beam

I want to make it easier for player to see a specific area. I had the idea to use the beams of guardians or beacons to mark an area. Is there a way to spawn a guardian (just for the client) and make it’s beam point in the sky?

The issue is that the beam render is specific to a Guardian existing and attempting to attack a living entity at the specified location.

Would it be possible to spawn an invisible squid that’s focused by the guardian?

@TypicalDarkness

        Player player = (Player) src;

        int size = 5;

        Living targetTopLeft = (Living) player.getWorld().createEntity(EntityTypes.GUARDIAN, player.getLocation().getPosition().add(size-1, 0, -size)).get();
        targetTopLeft.offer(Keys.AI_ENABLED, false);
        player.getWorld().spawnEntity(targetTopLeft, Cause.of(this));

        Living guardianTopLeft = (Living) player.getWorld().createEntity(EntityTypes.GUARDIAN, player.getLocation().getPosition().add(size, 0, -size)).get();
        guardianTopLeft.offer(Keys.AI_ENABLED, false);
        player.getWorld().spawnEntity(guardianTopLeft, Cause.of(this));

        Living targetTopRight = (Living) player.getWorld().createEntity(EntityTypes.GUARDIAN, player.getLocation().getPosition().add(size, 0, size-1)).get();
        targetTopRight.offer(Keys.AI_ENABLED, false);
        player.getWorld().spawnEntity(targetTopRight, Cause.of(this));

        Living guardianTopRight = (Living) player.getWorld().createEntity(EntityTypes.GUARDIAN, player.getLocation().getPosition().add(size, 0, size)).get();
        guardianTopRight.offer(Keys.AI_ENABLED, false);
        player.getWorld().spawnEntity(guardianTopRight, Cause.of(this));

        Living targetBottomRight = (Living) player.getWorld().createEntity(EntityTypes.GUARDIAN, player.getLocation().getPosition().add(-size+1, 0, size)).get();
        targetBottomRight.offer(Keys.AI_ENABLED, false);
        player.getWorld().spawnEntity(targetBottomRight, Cause.of(this));

        Living guardianBottomRight = (Living) player.getWorld().createEntity(EntityTypes.GUARDIAN, player.getLocation().getPosition().add(-size, 0, size)).get();
        guardianBottomRight.offer(Keys.AI_ENABLED, false);
        player.getWorld().spawnEntity(guardianBottomRight, Cause.of(this));

        Living targetBottomLeft = (Living) player.getWorld().createEntity(EntityTypes.GUARDIAN, player.getLocation().getPosition().add(-size, 0, -size+1)).get();
        targetBottomLeft.offer(Keys.AI_ENABLED, false);
        player.getWorld().spawnEntity(targetBottomLeft, Cause.of(this));

        Living guardianBottomLeft = (Living) player.getWorld().createEntity(EntityTypes.GUARDIAN, player.getLocation().getPosition().add(-size, 0, -size)).get();
        guardianBottomLeft.offer(Keys.AI_ENABLED, false);
        player.getWorld().spawnEntity(guardianBottomLeft, Cause.of(this));

        ((EntityLiving)guardianTopLeft).addPotionEffect((net.minecraft.potion.PotionEffect) PotionEffect.of(PotionEffectTypes.INVISIBILITY, 999999, 999999));
        ((EntityLiving)guardianTopRight).addPotionEffect((net.minecraft.potion.PotionEffect) PotionEffect.of(PotionEffectTypes.INVISIBILITY, 999999, 999999));
        ((EntityLiving)guardianBottomRight).addPotionEffect((net.minecraft.potion.PotionEffect) PotionEffect.of(PotionEffectTypes.INVISIBILITY, 999999, 999999));
        ((EntityLiving)guardianBottomLeft).addPotionEffect((net.minecraft.potion.PotionEffect) PotionEffect.of(PotionEffectTypes.INVISIBILITY, 999999, 999999));
        ((EntityLiving)targetTopRight).addPotionEffect((net.minecraft.potion.PotionEffect) PotionEffect.of(PotionEffectTypes.INVISIBILITY, 999999, 999999));
        ((EntityLiving)targetBottomRight).addPotionEffect((net.minecraft.potion.PotionEffect) PotionEffect.of(PotionEffectTypes.INVISIBILITY, 999999, 999999));
        ((EntityLiving)targetBottomLeft).addPotionEffect((net.minecraft.potion.PotionEffect) PotionEffect.of(PotionEffectTypes.INVISIBILITY, 999999, 999999));
        ((EntityLiving)targetTopLeft).addPotionEffect((net.minecraft.potion.PotionEffect) PotionEffect.of(PotionEffectTypes.INVISIBILITY, 999999, 999999));

        ((Entity)guardianTopLeft).getDataWatcher().updateObject(17, ((Entity)targetTopRight).getEntityId());
        ((Entity)guardianTopRight).getDataWatcher().updateObject(17, ((Entity)targetBottomRight).getEntityId());
        ((Entity)guardianBottomRight).getDataWatcher().updateObject(17, ((Entity)targetBottomLeft).getEntityId());
        ((Entity)guardianBottomLeft).getDataWatcher().updateObject(17, ((Entity)targetTopLeft).getEntityId());

I can’t find the getDataWatcher() method. Which Entity are you using?

That would be the NMS Entity class (net.minecraft.entity.Entity).

How can I use the minecraft classes in my project?

Usually, you shouldn’t. For example, the potion stuff:

((EntityLiving)xxx).addPotionEffect((net.minecraft.potion.PotionEffect) PotionEffect.of(PotionEffectTypes.INVISIBILITY, 999999, 999999))

Can be replaced with:

xxx.offer(Keys.INVISIBLE, true);

But for those cases where you need it (as in the bottom four lines):

  1. Post a request on the SpongeAPI issue tracker to get it added to the API.
  2. Add SpongeForge to your project’s build path.
  3. When you publish your plugin, make sure to specify in your plugin documentation that your plugin requires NMS.

Actually you are wrong, because that would also make the beam not render…
i could do it with the potion key but thats not implemented yet