IllegalArgumentException in BlockState.setData()

Discussion in 'Plugin Development' started by Jim Finnis, Oct 5, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Jim Finnis

    I'm trying to remove deprecated calls to Block.setData(byte d), and I've come across the following problem:
    Code:java
    1. Ladder ladder = new Ladder(Material.LADDER);
    2. ladder.setFacingDirection(BlockFace.NORTH);
    3. for (int y = ladderPos.y; y <= upper.e.miny + 1; y++) {
    4. Block b = w.getBlockAt(ladderPos.x, y, ladderPos.z);
    5. BlockState s = b.getState();
    6. s.setData(ladder);
    7. s.update();
    8. }

    gives the following exception:
    Code:
    Caused by: java.lang.IllegalArgumentException: Provided data is not of type org.bukkit.material.MaterialData, found org.bukkit.material.Ladder
        at org.bukkit.craftbukkit.v1_6_R2.block.CraftBlockState.setData(CraftBlockState.java:72)
        at org.pale.gorm.Building.buildVerticalExit(Building.java:178)
        at org.pale.gorm.Building.addRoomAndBuildExitDown(Building.java:145)
        at org.pale.gorm.Building.placeFloorAt(Building.java:126)
    (it's a plugin which slowly builds a castle on existing terrain, while you watch, by the way).

    Surely, since Ladder implements MaterialData, that shouldn't happen... or am I misunderstanding something?


    Thanks,
    Jim
     
  2. Offline

    stelar7

    ladder.getData is the data, just ladder is the material
     
  3. Offline

    Jim Finnis

    But Ladder.getData() is deprecated.
     
  4. Offline

    Gopaintman

    Doesn't mean that it doesn't work. Deprecated just means that it is going to be gone soon unless otherwise specified.
     
  5. Offline

    Jim Finnis

    I know; but I'm trying to get rid of all the deprecated stuff - that's the point of the exercise, otherwise I wouldn't have used Ladder at all - I'd have just used setType/setData. So my question remains - why is it crashing, and assuming it's something I've done wrong, how do I set a block to a material with extra data (such as Ladder) without using any deprecated methods?
     
Thread Status:
Not open for further replies.

Share This Page