Jump to content

Help Editing Vanilla Blocks and Items


BLourenco

Recommended Posts

When it comes to adding new block and items, there are plenty of guides and tutorials, but I'm having a really hard time finding out how to properly edit blocks and items from Vanilla Minecraft. I just found how to remove old recipes, because all my searches lead to tutorials for new blocks and items because of keywords.

 

Anyways, here's what I want to do next:

  • Change the icons of Iron tools and armour to something new, since I will be using those for Steel tools and armour.
  • Change old tools and armour to new toolMaterials and armorMaterials (which I have already added)
  • Change old blocks to different harvestLevels (I have added pickaxes with levels 4 and 5)
  • Change Obsidian to drop a certain quantity of items

 

I don't think these should be too difficult to actually code, I'm just having a real hard time searching for this specific information in the ocean of basic tutorials. If anyone can point me in the right direction, that'd be awesome.

 

Thanks!

  • Like 1
Link to comment
Share on other sites

When it comes to adding new block and items, there are plenty of guides and tutorials, but I'm having a really hard time finding out how to properly edit blocks and items from Vanilla Minecraft. I just found how to remove old recipes, because all my searches lead to tutorials for new blocks and items because of keywords.

 

Anyways, here's what I want to do next:

  • Change the icons of Iron tools and armour to something new, since I will be using those for Steel tools and armour.
  • Change old tools and armour to new toolMaterials and armorMaterials (which I have already added)
  • Change old blocks to different harvestLevels (I have added pickaxes with levels 4 and 5)
  • Change Obsidian to drop a certain quantity of items

 

I don't think these should be too difficult to actually code, I'm just having a real hard time searching for this specific information in the ocean of basic tutorials. If anyone can point me in the right direction, that'd be awesome.

 

Thanks!

  • Like 1
Link to comment
Share on other sites

The first two can easily be done without editing base classes (which you should avoid at any cost unless it is 100% necessary.) All you have to do is make new tools and armor extending the vanilla tools and armor, and then change the vanilla recipes to output the new tools and armor.

 

By harvest levels, I'm assuming you mean hardness. You can easily change hardness by using the Block class. It has a list of all the blocks in the game and you can use setHardness() on any of them.

Example:

Block.obsidian.setHardness(25);

25 is half the vanilla hardness of obsidian, so it'll take half the time to harvest it.

 

I'm not 100% sure about changing block drops, but there's probably an event or hook somewhere you can look into. Don't forget to check the source code in Eclipse. The stuff in there is more useful than you may realize. Specifically, look in the package hierarchy net.minecraftforge.event.

width=336 height=83http://img836.imageshack.us/img836/1237/cooltext624963071.png[/img]

I make games, minecraft mods/plugins, and some graphic art.

 

Current Project: LoECraft - An industrial minecraft server with its own modpack and custom launcher.

Link to comment
Share on other sites

The first two can easily be done without editing base classes (which you should avoid at any cost unless it is 100% necessary.) All you have to do is make new tools and armor extending the vanilla tools and armor, and then change the vanilla recipes to output the new tools and armor.

 

By harvest levels, I'm assuming you mean hardness. You can easily change hardness by using the Block class. It has a list of all the blocks in the game and you can use setHardness() on any of them.

Example:

Block.obsidian.setHardness(25);

25 is half the vanilla hardness of obsidian, so it'll take half the time to harvest it.

 

I'm not 100% sure about changing block drops, but there's probably an event or hook somewhere you can look into. Don't forget to check the source code in Eclipse. The stuff in there is more useful than you may realize. Specifically, look in the package hierarchy net.minecraftforge.event.

width=336 height=83http://img836.imageshack.us/img836/1237/cooltext624963071.png[/img]

I make games, minecraft mods/plugins, and some graphic art.

 

Current Project: LoECraft - An industrial minecraft server with its own modpack and custom launcher.

Link to comment
Share on other sites

The first two can easily be done without editing base classes (which you should avoid at any cost unless it is 100% necessary.) All you have to do is make new tools and armor extending the vanilla tools and armor, and then change the vanilla recipes to output the new tools and armor.

Wouldn't that be creating new items? I just want to change the icons for iron armor, tools, and ingots, and change their EnumToolMaterial and EnumArmorMaterial, not create replacements and recreate all the recipes.

 

By harvest levels, I'm assuming you mean hardness. You can easily change hardness by using the Block class. It has a list of all the blocks in the game and you can use setHardness() on any of them.

Example:

Block.obsidian.setHardness(25);

25 is half the vanilla hardness of obsidian, so it'll take half the time to harvest it.

Harvest Level is like what quality tool you need to harvest it. In the code it's set up like this:

0: Wood, Gold

1: Stone

2: Iron

3: Diamond

 

I have made my own materials that use levels 4 and 5. Here's what I made:

0: Wood

1: Stone

2: Bronze, Silver, Gold

3: Iron

4: Steel

5: Diamond, Obsidian

 

So now some blocks need to change their harvest levels so that you can't mine Obsidian with my new Iron.

 

I'm not 100% sure about changing block drops, but there's probably an event or hook somewhere you can look into. Don't forget to check the source code in Eclipse. The stuff in there is more useful than you may realize. Specifically, look in the package hierarchy net.minecraftforge.event.

 

Thanks, that's what I'll do. I'm sure most of the stuff is relatively simple, it's just knowing the right keywords (like hook and reflection).

 

Thanks, again.

 

Link to comment
Share on other sites

The first two can easily be done without editing base classes (which you should avoid at any cost unless it is 100% necessary.) All you have to do is make new tools and armor extending the vanilla tools and armor, and then change the vanilla recipes to output the new tools and armor.

Wouldn't that be creating new items? I just want to change the icons for iron armor, tools, and ingots, and change their EnumToolMaterial and EnumArmorMaterial, not create replacements and recreate all the recipes.

 

By harvest levels, I'm assuming you mean hardness. You can easily change hardness by using the Block class. It has a list of all the blocks in the game and you can use setHardness() on any of them.

Example:

Block.obsidian.setHardness(25);

25 is half the vanilla hardness of obsidian, so it'll take half the time to harvest it.

Harvest Level is like what quality tool you need to harvest it. In the code it's set up like this:

0: Wood, Gold

1: Stone

2: Iron

3: Diamond

 

I have made my own materials that use levels 4 and 5. Here's what I made:

0: Wood

1: Stone

2: Bronze, Silver, Gold

3: Iron

4: Steel

5: Diamond, Obsidian

 

So now some blocks need to change their harvest levels so that you can't mine Obsidian with my new Iron.

 

I'm not 100% sure about changing block drops, but there's probably an event or hook somewhere you can look into. Don't forget to check the source code in Eclipse. The stuff in there is more useful than you may realize. Specifically, look in the package hierarchy net.minecraftforge.event.

 

Thanks, that's what I'll do. I'm sure most of the stuff is relatively simple, it's just knowing the right keywords (like hook and reflection).

 

Thanks, again.

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...

I just found how to remove old recipes

 

what's the code for that?

 

 

Edit: nvm, i got it

 

A nifty method for removing vanilla recipes.

 

 

 

 

import net.minecraft.item.crafting.CraftingManager;

 

public static void RemoveRecipe(ItemStack resultItem)

{

ItemStack recipeResult = null;

ArrayList recipes = (ArrayList) CraftingManager.getInstance().getRecipeList();

for (int scan = 0; scan < recipes.size(); scan++)

{

IRecipe tmpRecipe = (IRecipe) recipes.get(scan);

recipeResult = tmpRecipe.getRecipeOutput();

if (recipeResult != null) {

if (recipeResult.itemID == resultItem.itemID && recipeResult.getItemDamage() == resultItem.getItemDamage())

{

System.out.println("Removed Recipe: " + recipes.get(scan) + " -> " + recipeResult);

recipes.remove(scan);

scan--; //list is shifted after remove! Adjust index, so next time we will check this value again.

}

}

}

}

 

// Then call the method e.g. like this:

RemoveRecipe(new ItemStack(Item.bed));  // It's gonna be a looong night ;)

 

 

 

 

Oh you solved it. Ok. Well then this might be an alternate way of doing it :)

Link to comment
Share on other sites

What I would like to know is how to override vanilla GUI's? Or at least remove the block/item completely and then make my own.

 

My problem is that I want to att heat to furnaces. Sure I can remove the recipe for it, but it will still spawn in villages. So I need to replace it's GUI.

 

Any tips anyone?

Link to comment
Share on other sites

I don't think that anything you mentioned is possible without bytecode modifications.

 

Hmm yeah that's what I hear people say most of the time. But it's always "I think..." or "I'm not sure but...", and so on. So I still have hopes that there is an easier way through Forge. And it should, since the two fundamental things you do if you wanna mod minecraft are 1. Adding stuff  2. Modifying vanilla stuff.

 

The most important to me is modifying vanilla stuff (coremodding), since just adding new stuff don't make that much of a difference to gameplay. Food is easily retained though wheat/potatoes and cattle (which is all too simple, in my opinion, so no new food is worth adding). Armor is capped with diamond material, so you can't make anything stronger (except for more durability). Dig straight down below Y:18 and search around for diamonds for a while and you have the best tools and armor the game can offer. So in order to make new tools worth the harvestLevel of diamonds must be increased.

 

Well, I guess you get my point. Sorry for yabbing, got carried away there :)

 

Thanks for the tip! I think the time has come to finally grab the bull by the horns and get into this bytecoding stuff. Feels like it's gonna be a huge time consumer (for me at least).

 

Btw, found something interesting here: https://github.com/MC-Adventure/Torch-Burnout/tree/master/tb_common/com/jjtcomkid/tb

He is using a "OverrideHandler", but left out the code for it  >:(  made me VERY disappointed! I would give my left leg to get a glimpse of that code!

Link to comment
Share on other sites

You are not "2. Modifying vanilla stuff". You are removing them, since they are hardcoded in vanilla but you want to make it your own code.

Unless you know the entire Minecraft code (and most of Forge too) you shouldn't do that. You wouldn't know the consequences of such a modification.

Coding wise, it is stupid to change/remove things when they don't belong to you. (I am aware reflection exists, but its primary goal isn't to remove private things)

Would you remove part of Forge if you didn't like them ?

Link to comment
Share on other sites

You are not "2. Modifying vanilla stuff". You are removing them, since they are hardcoded in vanilla but you want to make it your own code.

Unless you know the entire Minecraft code (and most of Forge too) you shouldn't do that. You wouldn't know the consequences of such a modification.

Coding wise, it is stupid to change/remove things when they don't belong to you. (I am aware reflection exists, but its primary goal isn't to remove private things)

Would you remove part of Forge if you didn't like them ?

 

Well if you're gonna get technical on me... sure I'm "removing stuff"... since we want to avoid changing the vanilla code directly, to "modify stuff" in it we can  remove and replace. A fine example is "Block.blocksList[ x ]=null; Block.blocksList[ x ]=Block.myBlock;" Remove and replace my friend, now we have made a MODIFICATION so to speak. So instead of criticizing and saying stupid this, stupid that. Try to be a little more constructive and see the big picture in what I'm saying/asking instead of marking single lines or words. I understand that you mean well, and want to warn me of messing with stuff I don't fully grasp.

 

Hey, I like coding, I'm not an ace in any way. But I like to experiment, see what happens, see if it's possible, see what I can do. And if the program crashes, so be it, then I revert and try something else. So if I see an opportunity to improve something, I'll do it! And that includes Forge (to answer your question), if I see a way to improve it I would.

 

Pheew... this was a waste of time.... please, no more talk of this. I am aware that a program can crash or bug out with bad code. I learned that a looong time ago  :) ... actually I would say that is the first thing you learn about coding. Then you learn to fix the bugs. And when it works, you get your rush. That's why we love programming, problem solving!

 

So anyway, no handy way of overriding e.g. the furnace GUI anyone?

 

Link to comment
Share on other sites

Actually I mentioned it above. It was the "Block.blocksList[ x ]=null; Block.blocksList[ x ]=Block.myBlock;" part. I have simply replaced the furnace block in the blocksList with my own furnace. I had to go find a village with a blacksmith to ensure that the furnaces were replaced. Seems bulletproof so far. It's even gone from the creative block/item index (well of course it is when the object is completely removed).

 

So we'll see from here how this turns out.

 

Off topic, I made my own biome (using the standard Forge GameRegistry-method). As usual when it comes to me, it's not enough. Do you know of a way to generate the custom blocks (forming the ground) futher down than just the top 3 layers?

Link to comment
Share on other sites

  • 2 months later...

You are not "2. Modifying vanilla stuff". You are removing them, since they are hardcoded in vanilla but you want to make it your own code.

Unless you know the entire Minecraft code (and most of Forge too) you shouldn't do that. You wouldn't know the consequences of such a modification.

Coding wise, it is stupid to change/remove things when they don't belong to you. (I am aware reflection exists, but its primary goal isn't to remove private things)

Would you remove part of Forge if you didn't like them ?

 

Well if you're gonna get technical on me... sure I'm "removing stuff"... since we want to avoid changing the vanilla code directly, to "modify stuff" in it we can  remove and replace. A fine example is "Block.blocksList[ x ]=null; Block.blocksList[ x ]=Block.myBlock;" Remove and replace my friend, now we have made a MODIFICATION so to speak. So instead of criticizing and saying stupid this, stupid that. Try to be a little more constructive and see the big picture in what I'm saying/asking instead of marking single lines or words. I understand that you mean well, and want to warn me of messing with stuff I don't fully grasp.

 

Hey, I like coding, I'm not an ace in any way. But I like to experiment, see what happens, see if it's possible, see what I can do. And if the program crashes, so be it, then I revert and try something else. So if I see an opportunity to improve something, I'll do it! And that includes Forge (to answer your question), if I see a way to improve it I would.

 

Pheew... this was a waste of time.... please, no more talk of this. I am aware that a program can crash or bug out with bad code. I learned that a looong time ago  :) ... actually I would say that is the first thing you learn about coding. Then you learn to fix the bugs. And when it works, you get your rush. That's why we love programming, problem solving!

 

So anyway, no handy way of overriding e.g. the furnace GUI anyone?

 

Thank you for posting this question. I had found that I needed Block.blocklist[x] = this.myblock, but no where did it tell me anything about the Block.blocklist[x] = null. After finding this post I was able to make my custom sand, which acts exactly like normal sand, replace the vanilla sand. The only difference is that now the sand doesn't drop its self it drops my custom item.

 

Again thank you so much. Now on the my other issue that seems unsolvable. That is making a custom sapling grow my custom huge tree. In theory it should work the same as a jungle sapling, but it doesn't seem to be working.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.