Setting wet sponge

Discussion in 'Spigot Plugin Development' started by TheDiamondWorm, May 25, 2015.

  1. I am trying to get the wet sponge material, then set wet sponge to the block type in blockplaceevent:

    Code (Java):
     Material material = Material.getMaterial("19:1".split(":")[0]);
    e.getBlock().setType(material);
    However, this causes an error. I know the event is fine, as when I try to set the block to stone or something, it works.
     
  2. I think you want something like this:
    Code (Text):
     Material material = Material.getMaterial(Integer.parseInt("19:1".split(":")[0]));
    e.getBlock().setType(material);
    getMaterial(String) is when you're getting an item by its name like Material.getMaterial("stone"), but it looks like you are trying to get it by its id, so you would use Material.getMaterial(Integer)
    Also, I'm not sure if you know this, but to make it a wet sponge, you would need to use the method setData()
     
    • Like Like x 1
    • Agree Agree x 1
  3. As far as I can tell you would do something like
    Code (Text):

    b.setType(Material.SPONGE);
    b.setData((byte)2);
     
    Accept that the "2" wold be the value after 19, so in this case, the "2 " should be a 1
     
    • Like Like x 1
    • Winner Winner x 1
  4. setData() takes a short

    b.setData((short) 2);
     
  5. Sir, I have to disagree. When I used it I got the error "Cannot cast from int to short"