[Solved,Spout Problem] different custom block textures

Discussion in 'Plugin Development' started by Jogy34, Nov 8, 2011.

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

    Jogy34

    I am making a plugin for one of my friends servers and it in I am adding some crop like blocks where as they grow when you plant the seeds in soil. I am however having a problem when trying to replace the block above the soil with the new crop. I have gotten it to the point where I can identify the different items from flint by using the data values of the items but when I try this with the new blocks, when placed, they have the same data value as glass or stone ( it's 0). How would I make it so that one of these blocks is automatically placed?

    EDIT:
    I now need to know how to change the top texture of a custom block and make it different block.
     
  2. Offline

    Afforess

    You're making the job harder than it needs to be. You can easily get and set the custom block at a location.

    To get a Spoutblock, cast any old block. They are a subclass of blocks, and if Spout is on the server, all blocks are spout blocks.

    e.g

    Block b = event.getBlock();
    SpoutBlock s = (SpoutBlock)b;

    http://jd.getspout.org/latest/org/g...k(org.getspout.spoutapi.material.CustomBlock)
    http://jd.getspout.org/latest/org/getspout/spoutapi/block/SpoutBlock.html#getCustomBlock()

    You can also check for the custom material in item stacks easier too. Create a SpoutItemStack ( a subclass of Bukkit' item stack), and use getMaterial() to see if the material is an instance of your custom item.

    http://jd.getspout.org/latest/org/g...poutItemStack(org.bukkit.inventory.ItemStack)
     
  3. Offline

    Jogy34

    @Afforess That makes my life easier by A LOT with the items but now the only thing i don't understand how to do is how to make it automatically place a block. With the bukkit method
    Code:
    block.setType()
    it needs a Material and if i use
    Code:
    block.setTypeId(NewSpoutBlock.getCustomId)
    it gives me either stone or glass. Is there some spout method that can help me out with this, am I going about this wrong, or can this just not be done yet?
     
  4. Offline

    Afforess

    If you want to set a custom block, you need to use ((SpoutBlock)block).setCustomBlock(NewSpoutBlock);

    The reason is that we don't use the block id or metadata to determine if it is a Spout block. We actually have a custom storage system that tracks them, and that's how you access and set them.
     
  5. Offline

    Jogy34

    @Afforess Thanks for the help however I have a few more questions that don't currently apply to what I'm doing but I still want to know.
    1. Is it possible to make a custom GUI like a different workbench where it is possible to put blocks in it and have something happen?
    2. Is it possible to make a block with a different top texture than the sides?
    3. Is it possible to make custom inventory items/blocks look like something other than flint/glass/stone to make it easier for players without the spout client to recognize that those blocks/items are custom items?
     
  6. Offline

    ZNickq

    1. yes
    2. yes
    3. not right now :p
     
  7. Offline

    Jogy34

    @ZNickq How do I do the second one where I have a different top texture than the sides?

    @Afforess can you help me with this?

    @Afforess I have been looking through the spout javadocs and I have a few question about SubTexture and Texture Classes.
    1. If I understand it right it allows you to change one or more of the sides of a block to a different texture. Is that correct?
    2. Why are there 12 texture id's in the Texture class for the SubTextures?
    3. How would I go about changing the top of a block?
    4. What are the X/Y locations for in the SubTexture class constructor?

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

    Jogy34

    @Afforess are there any tutorials on how to use quads because I have seen some really cool things done by @Samkio using them
     
  9. Offline

    Afforess

    tips48 likes this.
  10. Offline

    Jogy34

    @ZNickq, @olloth Can either of you guys help me out here?

    @ZNickq, @olloth, @Samkio I'm really hoping one of you can help me out soon:)

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

    Afforess

    Skyrim happened. :/
     
    r3Fuze, tips48, Kohle and 1 other person like this.
  12. Offline

    Jogy34

    O ya I forgot about that. I don't have enough money to get it yet though:'(
     
  13. Offline

    olloth

    1. Correct, but you have to replace the entire BlockDesign if you want to change an existing block.

    2. The 12 texture id's in the Texture class is purely an example of how it works. I can see now that it lost it's formatting, it was supposed to look like this:
    [0, 1, 2, 3,
    4, 5, 6, 7,
    8, 9, 10, 11]

    As an example of where in an image the texture ID's would be associated.

    3. If you want to change the texture of a vanilla MC block, or a design with a 'top' to a custom block, you will have to assign it a (new) BlockDesign, a GenericCubeBlockDesign is the simplest if you want a cube. That has an array of TextureId args such as {bottom, face, face, face, face, top}

    4. The SubTexture class is not actually made to be constructed by people however I leave things public because otherwise you get SOMEONE who wanted to do something weird with it. The Texture class generates all the SubTextures you'll need from the start, and then you simply ask it for a textureId.
     
  14. Offline

    Jogy34

    I'm slightly unclear as to what a TextureID is composed of. Is it just the URL of the texture?
     
  15. Offline

    Samkio

    @Jogy34
    Code:
    TreeTextureFile = new Texture(this,"http://dl.dropbox.com/u/19653570/Trees.png", 256, 256, 16);
    Code:
    public BaseLog(MoarStuph p, String name, int[] id) {
    super(p, name, new GenericCubeBlockDesign(p, p.TreeTextureFile,id));
    }

    Code:
    public class AshLog extends BaseLog {
    private static int[] ids = {20,4,4,4,4,20};
    public AshLog(MoarStuph p) {
    super(p, "Ash Log",ids);
    Hopefully it is explained in code.
    The id is the location of the 16x16 square on the texture file.
    So 0 is the top left most square. 1 is the one to the right of it and so on.
    However i can also use int arrays.
    The int arrays work just like normal ids. But you define an id for each side of the block.


    From the javadocs:

    Code:
    GenericCubeBlockDesign(org.bukkit.plugin.Plugin plugin, Texture texture, int textureId)
              Creates a basic cube custom block model with only one texture
    GenericCubeBlockDesign(org.bukkit.plugin.Plugin plugin, Texture texture, int[] textureId)
              Creates a basic cube custom block model
    textureId[6] - Array of faces, give Id's for SubTexture locations Array is laid out as follows {bottom, face, face, face, face, top}
     
  16. Offline

    Jogy34

    @Samkio that cleared it up a lot for me. Thanks:D

    @Samkio I have 2 more things to ask about.
    1. Can you teach me how to make dynamic blocks?
    2. Can I help you with developing LevelCraft MoarStuff?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
    Samkio likes this.
  17. Offline

    ZNickq

    LevelCraft is dead, @tips48 is supposed to be working on RPGLevels...
     
  18. Offline

    Jogy34

    Whoops I didn't mean LevelCraft I meant MoarStuph.:oops:
     
  19. /me ducks

    @Samkio check skype please!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 21, 2016
    Samkio likes this.
  20. Offline

    Samkio

    @tips48
    I am always on Skype. Just Ninja. :p
     
    tips48 likes this.
  21. Offline

    Jogy34

    @Samkio So can you teach me how to make dynamic blocks?

    @Samkio Can that also work with custom Item textures?

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

    ZNickq

    Item's are 2d...
    And "dynamic blocks" (i assume you mean custom shapes) are done using Quads, it's complicated stuff :p
     
  23. Offline

    Jogy34

    @ZNickq What I meant for the items was making a texture with multiple subTextures like for the blocks but with items. And yes I do mean custom shapes and I do know that it is complicated however I still want to learn.
     
  24. Offline

    ZNickq

    for items, wouldn't really make sense, since the entire item is in 1 png (because it's 2d) for blocks, get on the spout irc, and they'll help you ^^
     
  25. Offline

    Jogy34

    @ZNickq It would just be easier If I could have one file for a bunch of items rather than have 20 files.
     
  26. Offline

    ZNickq

    ooh, so like an items.png? they're working on that! :p
     
  27. Offline

    Jogy34

    ya.

    @Samkio Can you please teach me ,through spout, how to make custom shaped blocks?

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

    Jogy34

  29. Offline

    Samkio

    @Jogy34
    I was going to do a tutorial on it but no.
    I am not going to teach you. Use sources and learn how other people have done it.
    There are 2+ designs on the MoarStuph repos on github you can look at.
     
  30. Offline

    Jogy34

    @Samkio As far as I know you are the only one who does this in plugins however I never though to look on github for your code so I should be able to figure it out from that so thanks
     
    acuddlyheadcrab and Samkio like this.
Thread Status:
Not open for further replies.

Share This Page