Solved Spawning Minecart with Custom Item Block

Discussion in 'Plugin Development' started by Tenetri, May 12, 2013.

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

    Tenetri

    So I have been trying to spawn Minecarts with custom blocks inside of them. I've seen recently that with McEdit, with a Filter that SethBling made. With it I can modify a minecarts metadata and have the minecart have a block in it, instead of TNT or a Chest.

    I've been trying to replicate this with Server Code, but I not sure how to continue, or even if its possible

    I have this so far. The code is running off of the PlayerInteractEvent

    Code:
    Entity ee = event.getPlayer().getWorld().spawnEntity(new Location (event.getPlayer().getWorld(), 0,80,0), EntityType.MINECART_TNT);
                            ee.setMetadata(String, MetadataValue);
     
  2. Offline

    chasechocolate

  3. Offline

    ZeusAllMighty11

    Code:
    EntityMinecartAbstract ema = (EntityMinecartAbstract) ((CraftEntity)cart).getHandle();
    ema.k(Material.GRASS.id());
    ema.l(0);
    
    You will need CraftBukkit

    Inside the k method, you put in the Material ID
    Inside the l method, you put the damage/data value

    :)
     
    microgeek and Tenetri like this.
  4. Offline

    Tenetri

    Thanks so much! I had searched for a while.

    Have a great day!

    Edit: [Set to Solved]
     
    TheGreenGamerHD likes this.
Thread Status:
Not open for further replies.

Share This Page