Developing a plug-in that requires custom items

Discussion in 'Plugin Development' started by Father Of Time, Sep 29, 2011.

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

    Father Of Time

    Good afternoon to all,

    I am new to the plug-in development community, but eager to get my hands dirty. I am an object oriented programmer by trade but the Java language is fairly new to me; however, my experience with C# has proven to be extremely helpful with learning Java.

    I digress; I have been planning out the details of my first Minecraft plug-in that involves inscription, teleportation, portals, resource consumption and location exchanging. This plug-in will be used to allow players to record locations and teleport themselves and other players to recorded locations at the expense of in game resources. The design is to replace our servers current command based travel system with an in game resource based one.

    So, now that you have a brief description of the project onto my questions. I have two questions lingering over my head that will drastically alter how I will approach this project.

    1) Can you create custom artwork for items utilizing only a bukkit plug-ins or will this require a client patch? Will I be able to contain custom items and their graphics all within a single plug-in, or will it require additional alterations to the minecraft client/server.

    2) Can items store data? I know blocks can (for instance, the key of a music block is stored on server shutdown/restart). I would like to make an item that can store a Vector and String (Location and message). I would like to make it possible for players to take their stored locations, transcribe them to a “Rift Rune” and trade them freely so that other players can teleport to your locations.

    I apologize if any of the details I have provided are a bit vague, I can expand upon any details if necessary. This is information I can ultimately discover threw some experimentation, but I thought I would throw a line into the waters here at Bukkit forums to see if anyone is able and willing to lend me their experience.

    Thank you in advance to all who take the time to read this post and share your experience, its greatly appreciated. Have a wonderful afternoon!
     
  2. Offline

    Darkman2412

    :confused: <- This is what I think :p
    1) If you use custom items, you need to change the client too. You can't do that without a client mod (unless you use Spout, but that requires the users to have SpoutCraft)
    2) Items can store data, but not Strings etc. They only support bits like 0x8, 0x1, etc.

    I'm not so pro at custom items, so if I'm wrong, just correct me :)
     
    Father Of Time likes this.
  3. Offline

    Father Of Time

    Firstly, thank you for such a prompt response; I'm ecstatic to see that the community is that lively.

    That's a bummer to hear that custom items require a client mod to utilize. As I stated before I am totally new to plug-in creation so I have a followup questions:
    1) Is a client mod something that I can make the server perform on login to my server, or is it something that the player would have to do to their own client?

    Although I am happy to hear that items can store information, it stinks to hear that it's limited to bits. So I guess the followup questions for this would be:
    1) Is there a difference between items and blocks (say a shovel vs stone) or are they all inherited from a base class that utilizes the stored bit?
    2) can you store as many bits as you want in one item? So if I wanted to store a location I could make a bit for X, a bit for Y and a bit for Z to bypass this limitation. Technically I could store anything with enough bits, but I need to know if there is a limitation on the quantity of bits you can have per item.

    Thank you once more for your time and expertise, its greatly appreciated!
     
  4. Offline

    ZNickq

    You sound like you'll be an awesome developer! :D
    So,no,you can't mod the client on login,you'll need Spout for that,again! (search for it on bukkit)
     
  5. Offline

    Father Of Time

    Why thank you, I hope this turns out to be the case. :p

    Hmm, I had a friend who was talking about spout the other day and now it has been raised twice in one thread… I was doing some very brief research (2 minutes of reading) on spout just this morning and was quickly lost on what exactly it IS. Does it replace the minecraft client, the bukkit plugin, the minecraft server or all of the above? Is it a stand alone, or does it work in coordination with the above systems?

    From what it sounds like spout contains a great deal of features I would like to utilize. Would I still be developing plug-ins for Bukkit, or would the plug-ins be fore spout? I’m sure I'm asking questions that don’t have a quick and easy answer, but any “tid bits” of information you can throw out there about its use would be helpful.

    So what I get from your two post is that custom art/items aren't possible without the players installing a client modification, or without spout; is this assumption correct?
     
  6. Offline

    ZNickq

    Spout is 2 things:
    1.A bukkit plugin,which gives you some more control over stuff,like a listeners from inventory,and it's a little faster than the normal bukkit server
    2.A normal minecraft alternative(sorta) ,which is a lot faster than the normal minecraft,and gives a lot of control over almost everything client-related! For example,you can change texture packs on the fly,etc.

    And yes,custom items aren't possible without spout,or client-side modding!
    The spout new blocks api will be released in 11 days,you have enough time to learn to code! :p
     
  7. Offline

    Don Redhorse

    spoutcraft is an own minecraft client, but will work seamlessly with a normal bukkit / minecraft server, spout is an plugin to bukkit and will work seamlessly with normal mc clients.

    only spoutcraft clients can use client based content of spout servers.. spout servers can have features though which can also be used by non spoutcraft clients.. logblock for example uses some spout apis.
    you can have plugins which will only become "enhanced" if you have spout installed and using the spoutcraft client.. but for the stuff you want you will need a spout plugin and the spoutcraft plugin too.
    yes, benefit of spout is that the spoutcraft client will automatically download the additional stuff it needs to make your runes work...e g. graphics, sound etc...

    you should read it up on dev.bukkit..
     
  8. Offline

    Father Of Time

    This confuses me slightly. Is it a plug-in for bukkit, or does it replace bukkit? I’m just confused on how it “plugs in” to Bukkit, but yet performs faster than the object it has dependency on.

    So if I wanted to utilize this plug-in would I still program a bukkit plug-in like normal and just gain some additional functionality from having spout installed, or do you have to program plug-ins for spout which then ports your plug-in to bukkit?

    I’m sure my questions are confusing, but hopefully you can make some sense of them.

    Fantastic, that was very clear Don Redhorse.

    That is my homework for tonight, sadly I am at work right now so I can only sporadically check this post and brainstorm as I daydream at my desk, but I’ll save the true research for when I get home and can “experiment” as I read.

    So if I understand you correctly, there is a “replacement client” called sproutcraft and then there is a plug-in called spout. The spout plug-in is what gives the server the additional functionality and the spoutcraft is the client that can utilize the additional functionality that the spout plug-in creates. Any player can connect to a server running the spout plug-in, but only players connecting with spoutcraft client will gain from the spout plug-in. Am I close with my assumptions?

    So is spoutcraft a client mod, or is it a stand alone client alternative?

    Thank you Don Redhorse for assisting with getting me going!

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

    McAndze

    Spoutcraft is a mod for clients to "communicate" with Bukkit servers, that have Spout installed. So yeah, pretty much what you said. Just wanted to clear up that it's a mod, not a stand alone client :)
     
  10. Offline

    Father Of Time

    Awesome, you are the best! As I was waiting for a response I decided to go looking for the two items. I realized what was confusing me once I found them:

    Spout: bukkit plug-in
    http://dev.bukkit.org/server-mods/spout/

    Spout craft: Client modification
    http://dev.bukkit.org/client-mods/spoutcraft/#w-how-do-i-get-started

    Before I only found the client modification, not the plug-in, and the verbiage on the client mods website was making little sense to me. Before I thought spout and spoutcraft were the same thing, so when it kept saying "unlock the powers of spoutcraft with spout" I was like.... Huh? How can a mod unlock its own features when used with itself?

    Now that I have an understanding of the two sides of this system, the server plug-in and the client mod its making MUCH more sense. So basically the client mod(spoutcraft) allows the client to communicate with the server via the server plug-in(spout).

    So my basic understanding at this point is that you can manipulate client side stuff from the server by utilizing the communication channel that is created when the client has the spoutcraft mod and the server has the spout plugin, correct? So say for instance... a Skin, skins are client side information, but thanks to the communication channel being created by the spout/spoutcraft plugins/mods we can manipulate a players skin client side with a plug-in server side. Am I in the right ballpark?

    EDIT:
    Oh, back to one of my original questions. The bits that can be stored in items, is there a limit on how many bits that can be stored? Does each item only have one "variable" bit, or can you store any quantity of bits within one item? so for instance
    Bit1 = Coordinate X
    Bit2 = Coordinate Y
    Bit3 = Coordinate Z
    etc.
     
  11. Offline

    cyberdude


    That is correct.


    Spout is two parts.
    1) A serverside bukkit plugin, that first and foremost adds some performance features. And a baseline for plugins to do more than what the Bukkit API provides access for.

    2) A client (named SpoutCraft), which is a modded minecraft client. It is download and go. So players do not need to mod their client. But it is as a standalone client that is already modded. It is however not compatible with most other client mods. The client also features a lot of performance features and the likes. But most important, it allows the server(running Spout plugin) to send "mods" to the client on the fly. Such as HUD changes, texture packs, a lots of other stuff. AFAIK however it is currently not possible with Spout to add new items/blocks/mobs, it will later however.


    You will still be developing plugins for bukkit utilizing the functionality of the Spout framework/API.

    You can setup the server (running Spout) to allow only SpoutCraft clients.

    AFAIK if you want to add custom items/blocks you will need to take a look at ItemCraft, and Client side modding (which you'll probably head to the minecraftforum for more information). However there is a lot of experienced programmers that don't like ItemCraft because of it's nature.

    Edit:
    Was writing this response, and I suddenly got company, so I see I am a bit late on the answer.. ;)..
    However some part of my post have not been mentioned before...
    The Spout page mentions this: "And the future is even better. Spout plans to create a client side plugin system, which will unlock the ability to add custom blocks, mobs, and items to the game"
    So it seems it's not possible as of yet. But will later. If Spout already supported this I'd bet we see a shit load of new plugins utilizing this.
     
  12. Offline

    Afforess

    When someone has questions about Spout, tag me guys! Come on! :p

    Looks like you are looking for Spout. Spout is a bridge between the wide gap between server and client side modding. For the majority of it's features, it requires the Spoutcraft client. However, it will still work for vanilla player's, they will just miss out on the enhancements.

    Minecraft communicates to clients through a series of pre-defined "packets" through the socket network connections. We abuse one of these packets to send a series of pre-defined custom packets that are interpreted by Spoutcraft. One such packet allows setting skins and cloaks.

    Yes, this is already possible with Spout. It's limited, but functional atm. 1.10 will feature a fully fledged custom block and item system that will be compatible with vanilla (i.e vanilla players won't be kicked when they log in - that's the big advantage of this system over vanilla), but they won't see the new textures.

    http://jd.getspout.org/org/getspout...ut.spoutapi.inventory.SpoutCustomBlockDesign)

    http://jd.getspout.org/org/getspout..., org.bukkit.plugin.Plugin, java.lang.String)

    A tiny bit of data sure. Some items already use their data for a specific purposes (item damage, etc), but items that don't use it (say, a dirt block) can have their damage manipulated. Jukebox does this already - you create custom tunes with Spouts audio player and then "burn" them to the jukebox discs, and they will play the tune that has been burned on them and are unique.

    If you need more data than items can store, I suggest using the short value inside an item as a key, and look up the data in a hashmap.

    Anything else I can help answer?
     
    Father Of Time likes this.
  13. Offline

    cyberdude

    Thanks @Afforess
    I was not aware that you had added support for custom blocks, albeit in a limited way. When is 1.10 scheduled planned for release? That would be awesome getting full custom block support! :D..
     
  14. Offline

    Don Redhorse

    did we do so bad? :eek:
    hehe :p
     
  15. Offline

    oyasunadev

    Honestly, you sound like you know what your doing, but trying to pretend you are older than you are. It's not really a big deal. We have mostly young developers, 13, 14, 15, etc, and some very experienced 12 year olds. We don't care if you approach Java from the Bukkit angle, at lease you are learning.
     
  16. Offline

    Afforess

    As soon as we're ready. :p

    Before the end of octoboer. Officially. Development builds much earlier, as early as next week.
     
  17. /cue Afforess bragging about spout.
    Jk, but its still funny :D
     
  18. Offline

    Afforess

    It isn't bragging if it's true. :p

    BTW, we have a lot of cool things going on under the hood, hence the lack of big releases in the last month. We're really going to shake up stuff up soon. :p
     
  19. You win! :D
    *bows to master coder*
     
  20. Offline

    Afforess

    *Pulls tip48 back to his feet.*

    Urgh, don't do that. We've only gone so far because we stand on the shoulders of giants.
     
    tips48 likes this.
  21. Offline

    Father Of Time

    Wow, it seems a wealth of information has been provided since I was last able to visit this post; I apologize for the delayed response, but a baby was born into the family and has had me…. Busy… J

    Ah cool, I was wondering if minecraft handled communication in this way. I’ve had suprizingly little time to dig into the minecraft development kit source code… *sigh*. Out of curiosity, as far as you know can you modify the minecraft server/client to introduce custom packets? I would imagine the communication handlers are somewhere in the development kits coder pack correct?

    This is great to hear. At this point I’ve decided to just reuse existing artwork until I decide what long term approach to take. The plug-in in development has plenty of other work to be done that isn’t being held up by any outstanding concerns.

    Well this just bites it… So it doesn’t even have an “Unused” variable, but rather people just tap into existing variables like HP and “repurpose” them? If this is the case, do you think it would be possible to modify the base item class to introduce a few new variables and rely on the server to serialize these new variables as it does with HP and such, or would it requires a custom serialization process to be created? I am very interested in this question because I am currently trying to decide what is the best method to use for long term data storage, I’m leaning towards MySQL atm.

    Wow, apparently I completely misread this the first time reading your post, this is exactly what I was looking for! In the past with other projects I have utilized a similar principle by assigning unique serial numbers to all world objects then utilizing those serial numbers with a dictionary collection to store additional information on world objects.

    So if this is a possibility in minecraft I guess my question would be what variable within a game item is unique. Would anyone be able/willing to show me a code snippet of how to refer to an objects unique variable? So for example, if we know that the variable ITEM is a game item, what would be the proper way to identify its unique identifier? ITEM.Variables.UniqueSerialNumber (I know this is wrong, just giving you an idea of what I mean by code snippet). I’m excited about this gem, I’ve been looking for this!

    What University is your degree of awesomeness from? ^^

    Not in my eyes, your input was extremely appreciated.

    I will be completely honest; I have no idea who this is directed towards. If you are requesting that I attempt to act older I don’t know what to say. I am almost triple the age of even the oldest group you listen above, so I don’t believe displaying maturity while posting on these forums will be a difficult task for me, but thanks for the advice…

    Thank you to everyone who has taken the time and effort to respond to my questions. The guidance of experienced community members is a commodity worth more than gold to me. I hope that some day I will be able to return the favor.

    Take care.
     
  22. Offline

    Afforess

    Well, to set some things straight, there is no minecraft development kit, or source code. Bukkit, and client mods modify obfuscated, reverse engineered code. Mojang has not made their source public.

    Sure, you could add custom packets, but then you'd need to develop a system for clients to receive those custom packets, etc. It'd be a lot of work for the same exact result that we've got. We have 1 bootstrap packet that contains a much prettier, unobfuscated payload and it works fine.

    It's been a week, and as promised, custom blocks and items are now working in development builds. Official release is still a bit off, but we'd be more than happy to help you get working with development builds.


    You're in luck. So long as it's an item that does not use data values (for example, coal/charcoal DO use data), it's always defaults to 0. So any data value you set can match up to a hash map, and that gives you 2^16 keys to work with. Not a ton, but not super-limited either.

    Items are not unique per-se, so you could have 2 (or more) items with id 3, data 111. There's no real way around that. But keep in mind you are the only code that is going to be setting the data values in the first place, so you can control how unique it is yourself.

    I don't actually have a degree. I'm self-taught.
     
  23. Offline

    Father Of Time

    Understood. As you’ve stated I too am self taught. I’ve programmed mostly in object oriented languages for about 12 years now. Because all of my training is informal my biggest weakness is the proper use of terminology. I have my own names for most things, which makes it difficult when trying to communicate my needs to other programmers. I am currently taking courses at Michigan State University in programming analysis, so hopefully that will help rectify this issue. :p

    Fantastic, I’m happy to hear that your project is making great headway. I think I will have to take you up on that offer some time. When I scrap together enough time I will put a small presentation together on how I would like this plug-in to function, and maybe you can give it a once over and let me know what you feel spout can assist with.

    This just reminded me, is it possible to trigger effects (particle or sound) with just a bukkit plug-in, or would this too require spout?

    Edit: I stumbled across this post while eatting my lunch at work:
    http://forums.bukkit.org/threads/creating-particles-effects.35605/
    Shows a way to display particles. I will be able to answer this myself when I get home and begin testing, but does this function include audio effects?

    Okay, so I want to make sure I understand what you are saying here. Every item in the game has a built in variable named “DataValue”, some items utilize this variable, and some don’t. This DataValue variable defaults to 0 on items that do not utilize the variable and is not a unique identifier by default. I can however use it to store a value that I can make “unique”. So say I used… a dirt block:

    DirtBlock.DataValue = 1
    DirtBlock.DataValue = 2
    DirtBlock.DataValue = 3

    Now these objects aren’t unique in the world because there are three of them; but they are unique to each other because none share the same DataValue. And then by simply creating a hashmap that contains the DataValue as the key I can associate any information I chose by mapping it as the keys value. Am I picking up what you’re laying down?

    Thank you for your continued assistance Afforess, I always appreciate those who take pride in the programming communities they belong to.
     
  24. Offline

    Afforess

    Those effects will trigger sound too, but are limited to just the explosion particles. There is no effect API in spout yet (It's complicated. Particle effects are actually entities, just like mobs and players are...), but you can trigger and alter the background music and play sound effects (either the official mc music or sound effects, or your own custom ogg/wav/midi files).

    Exactly correct.
    No problem. I myself began programming with much help from a similar community, and feel that it's important to share knowledge and help others. It's part of what makes programming great.
     
  25. Offline

    Father Of Time

    I see, although that is better than nothing that is still quite a limitation… I have several questions that relate to this, but I would like to start with the one that will most heavily impact my plug-in.

    My plug-in is a navigation system, and I’m hoping to utilize the purple transparent nether gate block. My questions are 1) is the purple block just that, a normal block? And 2) are the purple flower looking particles that emit out of the nether portal block part of the blocks animation or is that a particle system that is associated with the nether gate? Ultimately I am hoping to be able to generate a 1x1x2 block of purple portal blocks that emit the purple flower particles that automatically delete after 30 seconds. Again, I can explain the function of these blocks in greater detail if needed, but for now I am trying to remain somewhat vague to make the final unveiling somewhat of a surprise. :D

    Excellent, don’t you just love it when things fall in place! ;)

    We come from similar backgrounds. Although I was a web developer before I branched into program design, my first true programming exposure came from an Ultima Online emulator community called RunUO. I ran and developed a customized server for roughly five years before shutting it down due to personal reasons. Many of the methods and tools I use today were taught to me by the community members at RunUO, and it was that amazing community effort that sparked my interest into programming as a career.

    As you said, I truly love that the programming field is one that encourages collaboration. So few industries share ideas and intellectual property for the greater good of the community.
     
  26. Offline

    Afforess

    Yep. It is just a normal block.

    It's technically neither. The purple particles appear anywhere a portal block is, but it's not specifically part of the animation process. But for all meaningful purposes, it's part of the block animation.

    Should be relatively easy to do. The only snag you will hit is that the game will try to remove the portal anytime a block near it is updated (from block placement or removal), but you can prevent the blocks from being removed by cancelling the block physics event. So it's totally do-able.


    Ah cool. I started learning C++ a few years ago for Civilization 4 modding, and then came over here when Civilization 5 was a bust.
     
  27. Offline

    Father Of Time

    Excellent! It sounds like these will be even easier to utilize than I had ever hoped.
    So fantastic to hear. So it sounds like I can pack everything I need into a custom class and just create an instance of it when ever a portal is cast, and have that class instance deletes itself after 30 seconds. So from what you’ve stated it looks like I need to look into overriding the BlockPhysics event in my custom portal class, and to figure out how to trigger an entity location change on block MoveOn or MoveOver.

    Do you have any suggestions as to what distro classes I should look at for similar code for either of the above problems?

    Oh, very cool. Being that I began with C# I’ve been spoiled by the automatic garbage collection. The idea memory management in C++ has kept me dragging my feet on learning the language.

    I am currently making a four player online 3D zombie survival game with XNA which is a .NET framework wrapper. The language lacks the raw power and performance of C++, but its simplicity makes the idea of developing an entire 3D engine with a single developer much more feasible. So far I have been extremely happy with the language and have been pleased with the overall outcome of the project.
     
  28. Offline

    ZNickq

    http://wiki.getspout.org/index.php?title=Custom_Blocks_And_Items_Tutorial
    I'm such a boss :cool: (i made it :p)
     
Thread Status:
Not open for further replies.

Share This Page