Get block sign is attached to

Hello! I am trying to get block, which is my wall sign attached to, so I can modify it. I need something like this :

BlockSnapshot block = getSignBlockSomewhere();
Sign sign = (Sign) block.getTileEntity();
BlockSnapshot block2 = sign.getAttachedBlock();

Is there a way to get it?

Also, a way of getting the face, which is sign is rotated to will help me anyway.

Thanks in advance.

SpongeAPI: 7.1.0
Java: 8.1.0
SpongeVanilla: 1.12.2

So this is how I would do it

Location<World> loc;
//check if sign
Direction facing = loc.get(Keys.DIRECTION).get();
Direction opposite = facing.getOpposite();

What do you mean by “the face, which a sign is rotated”?

1 Like

Thanks for reply.
I meant that knowning the opposite face, it would be easier to find the target block.

Knowing the opposite direction, how should I get the block behind the sign?

Location<World> loc = loc.getRelative(direction);

Thanks for help!

I should really spend more time reading docs .

There is a lot the docs will not tell you. The docs will give you a general idea of how to do a lot but it will not give you examples to do everything.

I don’t think the docs tell you about this, they tell you about keys and working with locations.

I would recommend reading the docs all the way through but doing what most people did for bukkit and going on the sponge api github and reading what each and every class does

You can also take a look at the Sponge Javadocs - they give a lot of this information in a better-organized format. https://jd.spongepowered.org