Jump to content

[1.7.10][SOLVED]Removing Unnecessary Code


Recommended Posts

I recently made a way so that tools can be healed durability using the crafting table with an ingot. I have a lot of tools in my mod so I had to make a shapeless recipe for a ton of tools! I could tell as soon as i got in game the fps had dropped by about 10-30 and seemed to have more lag spikes. Don't call me out so much on the fps stuff my main issue is how to clear up some space. Here is a small piece of code from my CraftHandler class that registers all recipes:


GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.greenPickaxe), new ItemStack(ItemHandler.greenPickaxe, 1, WILDCARD_VALUE), ItemHandler.greenIngot);
	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.greenSpade), new ItemStack(ItemHandler.greenSpade, 1, WILDCARD_VALUE), ItemHandler.greenIngot);
	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.greenAxe), new ItemStack(ItemHandler.greenAxe, 1, WILDCARD_VALUE), ItemHandler.greenIngot);
	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.greenSword), new ItemStack(ItemHandler.greenSword, 1, WILDCARD_VALUE), ItemHandler.greenIngot);

	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.purplePickaxe), new ItemStack(ItemHandler.purplePickaxe, 1, WILDCARD_VALUE), ItemHandler.purpleIngot);
	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.purpleSpade), new ItemStack(ItemHandler.purpleSpade, 1, WILDCARD_VALUE), ItemHandler.purpleIngot);
	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.purpleAxe), new ItemStack(ItemHandler.purpleAxe, 1, WILDCARD_VALUE), ItemHandler.purpleIngot);
	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.purpleSword), new ItemStack(ItemHandler.purpleSword, 1, WILDCARD_VALUE), ItemHandler.purpleIngot);

	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.redPickaxe), new ItemStack(ItemHandler.redPickaxe, 1, WILDCARD_VALUE), ItemHandler.redIngot);
	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.redSpade), new ItemStack(ItemHandler.redSpade, 1, WILDCARD_VALUE), ItemHandler.redIngot);
	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.redAxe), new ItemStack(ItemHandler.redAxe, 1, WILDCARD_VALUE), ItemHandler.redIngot);
	GameRegistry.addShapelessRecipe(new ItemStack(ItemHandler.redSword), new ItemStack(ItemHandler.redSword, 1, WILDCARD_VALUE), ItemHandler.redIngot);


There are many more tools than this also. You can see though that this would take up a lot of memory and make the gaming experience not as good.


Is there anyway that these recipes could be called from one register? For example I have one CustomPickaxe class that I can use to initialize all my pickaxes. Same for the other tools. Is there any way I can have a small piece of code like that, that can do all this work for me instead of me having to type it out.


Don't think the problem is typing it out. The problem is I want the best experience for the player so any FPS I can keep is good.


Here's a piece of code that shows you kind of what I'm trying to do:

GameRegistry.addShapelessRecipe(new ItemStack(tools), new ItemStack(tools, 1, WILDCARD_VALUE), ingots);

You can see I replaced the actual items with tools and ingots. I was going to try and make the other tools be registered through those variables. I may be completely wrong I'm just trying to figure things out.


I'm trying to take a simple piece of code that can register all these other items but in one way instead of 100. I hope I made it clear the issue because it's kind of confusing to understand. If you have any questions please ask! Or answers :P!


Also there may be no solution, I'm not sure. I hope someone will know the answer to this that has been stumping me over the past couple days.





Link to comment
Share on other sites

A friend of mine runs a server with over 240 mods.  It lags like a mofo, but not from the sheer number of recipes, but rather from the sheer, ungodly weight, of how many different blocks and items there are and all the TileEntities spawned in the world (because why run one tech mod when you can run FIFTEEN including ComputerCraft with all of the addons).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.


Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.


DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

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