Setting material to a new block - Adding block to Essentials for /give

Discussion in 'Plugin Development' started by tboss, Feb 8, 2012.

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

    tboss

    I just made a new block for my server witch extends net.minecraft.server.Block, so I can craft it, get it in the creative panel, and place it, but I get issues with other plugins witch does getType() on my block witch returns null. I'd like to know how to register a type to my block, knowing that it does not expends CraftBlock but net.minecraft.server.Block.
    And I need to add the item to Essentials so I can use the /give or /item command to get it.
    Thanks in advance !
     
  2. Offline

    thehutch

    Erm this is not how you create a new block :( You have to use Spout which is a server to client API which allows for custom blocks/items/GUI skins/capes/texutres and so on

    For more info go here:
    www.getspout.org
     
  3. This will not work without Spout, but I believe Spout has a very good and easy API.

    Keir
     
  4. Offline

    tboss

    I don't want to use spoutcraft as client because I have my own launcher. How to register my material into Bukkit ?
     
  5. Offline

    mushroomhostage

    I am having the same problem - but on the opposite side. In my plugin I call block.getType(), but if the server owner modded their craftbukkit jar to add a custom block, this returns null, causing an NPE since (I imagine) there is no corresponding block in the Material enum.

    Since I'd like my plugin to be as compatible as possible, I've taken to using block.getTypeId(), returning an int instead of a Material. New ItemStacks can be constructed by type id with no problem, so this is a partial solution. However not all Bukkit APIs accept type ids; I had to forgo a custom crafting recipe because addIngredient() only accepts Material.

    Surely there has to be a better way. How does Spout handle it, do new block types get new Material enum values?
     
  6. Offline

    tboss

    Hey I did not even mod my craftbukkit to add my block ;)
    Can I add my block to the server using spout and then mod manually the client to add my block to the client ?
    If yes, how to add blocks into spout ? How does the api works ?
    If no, how to register a type to my block ?
    How to register my block to craftbukkit ?
     
  7. If you have a custom launcher then it should be pretty easy to put Spout in there. Then instead of using mods on your custom launcher just install spout plugins.

    Also there is a spout Plugin called SpoutBlocks thy allows you to easily add new blocks.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  8. Offline

    tboss

    I don't want to use SpoutBlocks because we can only create very basic blocks and SpoutCraft is very long to be released after new updates.

    Found where I need to add my block : https://github.com/Bukkit/Bukkit/blob/master/src/main/java/org/bukkit/Material.java
    Any way to put it here without modding bukkit ?
    Because every fields are protected :'(

    If no... How do I mod this bukkit class to place it in my plugin's jar ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
Thread Status:
Not open for further replies.

Share This Page