I would like to use Blockbench (a 3d modelling application like blender) to create an entirely new Minecraft weapon.
Then, with java and some API (for example bukkit), I want to have a brand-new weapon.
I do not want to retexture an existing weapon for example the diamond sword.
Would someone kindly give me some pointers? For example, what is not clear for me is how to export it from Blockbench, and how to import it into minecraft.
Is Bukkit the correct API to use? Does know of another API that will better meet my needs. I am not a java beginner.
Making the Custom Models
Background
You can do this absolutely. Since Minecraft version 1.9, Mojang introduced the ability to texture items based on their durability. What so exciting about this is it allows for virtually infinite custom models that don't replace existing ones! Yes, even if you go in survival and damage it so the exact durability you set the custom model at, it will still be seperate. This is because you can set the item to not be damaged, but still have a certain durability value. How sneaky! The only problem is if you're developing for 1.8 (usually for a 1.8-latest server) then you can use any of this.
How this works is, for example, a diamond hoe has a max durability of 1561. This means you can have 1560 different custom models by just using the diamond hoe! It's 1560 and not 1561 because 1561/1561 would be full durability or just a normal diamond hoe.
Create a basic resource pack
So, I'll start with Blockbench. To export your model, it's
File->Export->Export Block/Item Model. That will export it as Json file. When you export the model don't name the itemdiamond_hoeor whatever item you'll be using undermodel id. Name it actually what it's going to be called. I'll show you why in this next step. You could even add a whole 'nother namespace if you wanted, but we'll just stick to theMinecraftnamespace. To export the texture, right click it and pressSave As.We'll make a basic resource pack. Call the resource pack folder whatever you want. Put the Json in
<your resource pack folder>->assets->minecraft->models->item. Put the texture in<your resource pack folder>->assets->minecraft->textures->item. In the resource pack folder you must also have a pack.mcmeta file and a pack.png file. You're most likely already familiar with this.Custom model magic
After you have made a basic resource pack, it's time to create the model for diamond hoe, which will point to your model. This is why you named it the actual item in the previous step. The
diamond_hoe.jsonshould look something like this:The
predicatemodifier is what tells the game when a different model should be shown. This tool can generate the Json for you. The damage value is whatever damage you want it to use over the total durability (e.g. one durability would be 1/1561 which equals 0.000640614990391).After that your layout with just one custom item should look something like this:
Again, there's different ways you could lay it out. You could have your custom stuff in another namespace. This is just how I'm doing it though.
To add multiple items (for example three more items), modify your
diamond_hoe.jsonto look like this:Bukkit/Spigot Plugin
Now, after all that. It's time to use the API. Yes, the Bukkit API is what you need. The Spigot API includes the Bukkit API, so you should be using the Spigot API. If you aren't already using it, change to that. No one uses the Bukkit server itself anymore. I'm assuming you're running a Spigot/Paper server. I will assume you are using the latest version 1.20.4 also.
You sound like you're new to Spigot plugins, so we'll make a plugin from scratch. Here is the basic layout of a Spigot plugin. You should already be familiar with the basic layout of a Java project, but here is what this project should end up looking like:
Use your favorite Java IDE (it better be IntelliJ not Eclipse or anything else) to make a Java project, but if you have IntelliJ just install the
Minecraft Developmentplugin and make a Minecraft project. It creates theplugin.ymland the build scripts for you. You can use whichever build system you want. I like Gradle, but I'll show you what the dependencies should look like for both.Gradle:
Maven:
Now, your main class should look like this:
Notice how it extends
JavaPlugin. That is how it becomes a plugin. TheonEnableandonDisablemethods run every time the server is started or stopped. This line of code in theonEnableassigns our commandGiveitem, to it's executor, theGiveItemclass. It will be the command that gives us our custom item. Create the commands folder if you haven't already. Then, theGiveItemclass. Which will end up looking like this:If you're wondering why we can't just use
give, that would override the game's built-in/givecommand and we don't want to do that. Keep in mind you can get your item any way you like whether it's from a command, minigame, or a gui shop. We just want to get your item. That's why we're starting out with this basic command. That is what is so cool about the Spigot API though. You can build your Minecraft dreams. Almost anything you can imagine.Anyways, your plugin.yml should look like this:
This is what makes your plugin official. It also tells the server any commands that should be created for this plugin.
Time to Test!
Finally, build your plugin (should already be ready in IntelliJ). If you're using something else use
packagecommand for Maven andbuildcommand for Gradle. Put the plugin into your serverpluginfolder. It should be in thetargetfolder for Maven and thebuild/libsfolder for Gradle.Make sure your resource pack is in the right place. Launch Minecraft and enable your resource pack. Then, start up your server and once logged in, run the
giveitemcommand we created with/giveitemand you should have your custom item!Remember, you could make thousands, probably tens of thousands of custom items without replacing existing items. Also starting with version 1.14 they introduced the
custom_model_datamodifier which allows for many many more models. Although who's going to be making that many models!Some of this I originally got from this guide. It's slightly outdated now, but if you know the latest API, it works. Yikes, some of it's incorrect though. Maybe I should fix it...