How to set a block accurate

Discussion in 'Plugin Development' started by Datablock_, Aug 6, 2020.

Thread Status:
Not open for further replies.
  1. I have an issue with the setType method, you have to compare it to a Material, but why is that? Since, for example, why is Material.ACACIA_BOAT an option in setBlock. Is there a way to compare it to a block?

    The reason I have a problem with this is that if I compare it to either grass or grass_block it will always place grass_block. There seems to be no way to place grass

    CODE:
    RayTraceResult ray = player.rayTraceBlocks(distance);
    Location loc = ray.getHitPosition().toLocation(me.getWorld());
    Block block = loc.getBlock();

    //both these 2 lines of code place grass_block, why is that?
    block.setType(Material.matchMaterial("GRASS"));
    block.setType(Material.GRASS);

    If someone knows a fix for this, please let me know.
    Sincerely, Datablock_
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Datablock_ There is no GRASS block as far as I know, that is the item variant.
    What is grass in itself?
    And the boat is an option because it is a Material, also used to create ItemStacks
     
  3. Offline

    KarimAKL

    @timtower I believe they're talking about the grass that you can walk through and which drops seeds when broken.

    @Datablock_ I think it might be TALL_GRASS, i'm not sure though.
     
Thread Status:
Not open for further replies.

Share This Page