[SPIGOT-5512] Allow changing the type of a block while retaining the data of BlockData Created: 12/Jan/20 Updated: 21/Jan/24 Resolved: 21/Jan/24 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | New Feature | Priority: | Minor |
Reporter: | KoekenMeneer | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | BlockData |
Issue Links: |
|
||||||||
Version: | 1.15 | ||||||||
Guidelines Read: | Yes |
Description |
There are several Material's which share the same BlockData class, such as Door, Leaves, Gate, Stairs and Sign. It would be nice if we could switch out the type while retaining all the other data that resides within the BlockData. That is, as long as the new type also uses the same BlockData class. This would allow changing for example a sign material while retaining it's lines and rotation, or changing a door while keeping the hinge and open state the same. This feature request is related to: |
Comments |
Comment by Marvin Rieple [ 21/Jan/24 ] |
This is now possible with the BlockData#copyTo(BlockData) method added in 1.20.4. |
Comment by user-34831 (Inactive) [ 28/Jan/20 ] |
for preserving rotations I use below. It might not be the best way but it works. the text on a sign isn't blockdata though. its block state .
String data = b.getBlockData().getAsString(); b.setBlockData(Bukkit.createBlockData(data.replaceFirst("birch_leaves", "oak_leaves"))); |