1.14.4 can't figure out how to put blocks in endermen's hand

Discussion in 'Spigot Plugin Development' started by kamalyaka, Mar 24, 2020.

  1. i can't figure out how to use the setCarriedBlock(); thingie. any help?
    here is my code:
    Code (Java):
    if (e.getEntityType() == EntityType.ENDERMAN) {
                Enderman enderman = (Enderman) e.getEntity();
    (this is in the Listeners class that registers)
  2. Also detail what does not work
  3. i saw that but it don't understand that so i came here to ask.
  4. Please be more specific, what you didnt understand?
  5. i only used itemstack to give entities items. now this is something else
  6. this is even more confusing. it is not your fault. thanks for the help but i give up on my idea
  7. As said above,but a bit confusing
    Code (Text):
    void setCarriedMaterial(@NotNull
                            @NotNull MaterialData material)
    That method simply asks for a materialdata,just fill it with what block you want
    Code (Text):
  8. How is it confusing? Get the server instance and then just create a new BlockData instance like this:
    Code (Java):
    BlockData blockData = ServerInstance.createBlockData(itemStack.getType());
    Note that before you do that you should verify that the item stack type is really a block in case it comes from a user input (ItemStack#isBlock)
    Code (Java):
  9. The method asks for materialdata yet ur telling him to create blockdata
  10. No it doesn't, there are two methods, one deprecated (which you recommend) and the proper one. Also your suggestion is even wrong since Material is not MaterialData so the code would be setCarriedMaterial(new MaterialData(Material.DIRT)); (the deprecated way) the proper one is the one i explained above.
  11. You are both suggesting a deprecated method (prone to be removed) and also the wrong way of "using" MaterialData as it not just as Material.ENUM
  12. Yeah noticed that in a fresh project,forgot i was just using a custom method for it
  13. java it does not seem to understand what ServerInstace is
  14. Code (Text):
    If it's in a different class from the main,you need to grab the instance of it,then you can acces getServer()

    Also this might work,without needing any instance
    Code (Text):
  15. fuck i am stupid
  16. i did not read the full message dexuby, sorry
  17. IT WORKS. Bruh thanks!
  18. How am i suggesting a deprecated method? Maybe you should try to read and understand the messages you are replying to.
  19. Set the post to solved(click edit title in the top left corner)