Setting Block MaterialData?

Discussion in 'Plugin Development' started by Milkywayz, Dec 15, 2012.

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

    Milkywayz

    Hey guys, I've been experimenting some Player Skulls and I can't seem to successfully place a Player Skull without physically placing it in game.

    The code Im using:
    Code:
    public void construct() {
            for (Slot b : slots) {
                b.getBlock().setMetadata(
                        "Type",
                        new FixedMetadataValue(Bukkit.getPluginManager().getPlugin(
                                "SkullWalls"), b.getBlock().getTypeId()));
                b.getBlock().setType(Material.SKULL);
                b.getBlock().getState()
                        .setData(new MaterialData(Material.SKULL, (byte) 3));
                b.getBlock().getState().update(true);
                b.removeOccupier();
            }
        }
    Expected Outcome:
    • A Player skull appears
    Actual Outcome:
    • A Skeleton Skull appears
    A Slot is a block within a Wall.
    The ID for a Player Skull is 397:3, when it's a block I think it's 144:3 but I'm not sure.
    I'm using metadata for "logging".
    Removing occupier basically removes the skull owner if there is one.

    I did check the Javadocs and search around, if you could point me in the right direction that would be fantastic. Thanks.
     
  2. Offline

    fireblast709

    Milkywayz bukkit seems to show no difference in skulls
    Code:java
    1. @EventHandler
    2. public void onPlace(BlockPlaceEvent e)
    3. {
    4. Block b = e.getBlock();
    5. e.getPlayer().sendMessage(b.getType().name());
    6. e.getPlayer().sendMessage(""+b.getData());
    7. e.getPlayer().sendMessage(""+b.getState().getData().getData());
    8. e.getPlayer().sendMessage(""+b.getState().getRawData());
    9. }

    This snippet gives me
    Code:
    SKULL
    1
    1
    1
    for each head
     
  3. Offline

    Milkywayz

    It's a real pain in the ass removing the bugs out of my new plugin, it literally took 3 hours to write the plugin and all of today to troubleshoot the issues.
     
  4. Offline

    nisovin

  5. Offline

    fireblast709

    Milkywayz back to scanning how NMS does it :p
    [edit] or that what nisovin said (facedesk)
     
Thread Status:
Not open for further replies.

Share This Page