# Solved How rotate sign ?

Discussion in 'Spigot Plugin Development' started by ProxyBite, Sep 26, 2015.

1. ### ProxyBite

I want rotate sign (Sign block)
Code (Text):

Block block = loc.getBlock();
block.setType(Material.WALL_SIGN);

Because when use this Sign placed in DIRECTION to: SOUTH
and i want rotate sign with Location "YAW"

2. ### Mr.Midnight

One second, I made a plugin that goes thru data values really fast. Let me test it out and get back to you.

Ok :8

4. ### Mr.Midnight

If it is the way I think it is it would be something like:
(Block).setData((Byte you want to use 1 to 15));

5. ### ProxyBite

i want calculate direction with .. loc.getYaw() (float)
or you can giveme example ?

6. ### Mr.Midnight

Hmm if it goes by dataValue perhaps you can make a switch statement?

7. ### Mr.Midnight

Yet again, I am quite a nub.

8. ### Mr.Midnight

So like make a method for example public void setSouth(Block block){
(Set block data here)
}

9. ### TheeNinja

The data value defines it's direction, data value in this case is kind of like yaw.

(Block).setData(4) Will rotate it 4 1/16th rotations around a circle.

• Like x 1
• Agree x 1
10. ### ProxyBite

Code (Text):
public static BlockFace getDirection(Float yaw)
{
yaw = Float.valueOf(yaw.floatValue() / 90.0F);
yaw = Float.valueOf(Math.round(yaw.floatValue()));
if ((yaw.floatValue() == -4.0F) || (yaw.floatValue() == 0.0F) || (yaw.floatValue() == 4.0F)) {
return BlockFace.SOUTH;
}
if ((yaw.floatValue() == -1.0F) || (yaw.floatValue() == 3.0F)) {
return BlockFace.EAST;
}
if ((yaw.floatValue() == -2.0F) || (yaw.floatValue() == 2.0F)) {
return BlockFace.NORTH;  }
if ((yaw.floatValue() == -3.0F) || (yaw.floatValue() == 1.0F)) {
return BlockFace.WEST;
}
return null;
}

Code (Text):
BlockFace bf = getDirection(loc.getYaw());

Now, how set blockface to block?

11. ### Mr.Midnight

getDirection(Byte byte){
//Check if byte = so and so
}

12. ### ProxyBite

but how rotate sign to Direction SOUTH, WEST, EAST, NORTH

13. ### Mr.Midnight

As TheeNinja said "The data value defines it's direction, data value in this case is kind of like yaw.

(Block).setData(4) Will rotate it 4 1/16th rotations around a circle."

Just make methods as you find the direction like setSouth()

• Like x 2

ok i try now

15. ### ProxyBite

Thanks fixed.

• Like x 1