TheDreamSanctuary / Multitool

GNU General Public License v2.0
0 stars 2 forks source link

Associating Tools with Objects (ID and Model) #2

Closed AceDexter closed 9 years ago

AceDexter commented 9 years ago

Question:

How do we associate a tool with a model and identify that tool with an ID?

Example, where do we get the paintbrush model and how do we associate it with an ID and a name with info (i.e. tool tip)?

I'm looking for an abstract explanation just so that I can better understand the process behind creating a new object or material to be used on our server.

To further clarify what I mean by 'model'

I'm talking about the literal three-dimensional object a user will see in-game along with the thumbnail associated with that object located in the items directory and the user's inventory.

Personal Investigation

Using a .png file: After doing my own research, I discoverered that textures are referenced in a .png file.

Question:

Would our "Paint Brush" model then be added to the resource pack and referenced by its ID or material name?

DukeVindzor commented 9 years ago

This is pretty much already one in ToolHandler (registeredTools hashmap holding Material and Tool). It is simply linked to an item in-game. Where Material is an excising class representing materials (which also means items).

By the way, all items of one id will work as a tool. So if slimeball is paintbrush, any slimeball will work as a paintbrush.

AceDexter commented 9 years ago

All right, so that part is taken care of. Could you explain how hashmaps work? Also, how should we decided which items we will associate with our tools for instance in your example of the slimeball?

I found this article on Working with HashMaps. Is that more or less on how we're using them?

DukeVindzor commented 9 years ago

As for which tools should be linked to what item, I think it would be nice to let admins customize that in a config. I think we can go for the default items we are used to from the server which is: Bone (data wrench), golden pickaxe (sledgehammer), slimeball (paint brush), diamond pickaxe (jackhammer) and stone axe (duplicator).

Hashmaps work like a list, but instead of an index you have a key. The key can be any kind of object. You can for example do registeredTools.get(bone), and get a DataWrech object, where bone is a Material Object.

AceDexter commented 9 years ago

@DukeVindzor

I agree that the config file should be used by Admins instead of us defining them in the plugin. Much more user and server friendly. Also, I think we can all agree that the default items we are currently using should be most appropriate going forward. Nice to now have a list ;)