You are not logged in.

IC2 Experimental builds (jenkins):
v2.0/2.1/2.2 / 2.3 / 2.5 / 2.6 (For Minecraft 1.6.4/1.7.2/1.7.10 / 1.8.9 / 1.9.4 / 1.10)
IndustrialCraft² recent version: v1.117! (For Minecraft 1.5.2 → topic)

Dear visitor, welcome to IC² Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

mak326428

Iron Miner

  • "mak326428" is male
  • "mak326428" started this thread

Posts: 639

Location: Totally not Honduras.

  • Send private message

1

Thursday, October 3rd 2013, 11:28am

[Addon for 1.6.2 (and experimental IC2)] Custom UUM Recipes - Because Old Ones Just Don't Cut It!

Adds config for every single IC2 uum recipe. (EU amount, UUM amount, -1 to disable).
Simple as that.

Tested on IC2_experimental build 116.
Should work on any version, if it doesn't, yell at me.

Source


CustomUUMValues.java

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package makmods.customuumvalues;

import ic2.api.recipe.IRecipeInput;
import ic2.api.recipe.RecipeInputItemStack;
import ic2.api.recipe.RecipeOutput;
import ic2.api.recipe.Recipes;

import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.Configuration;

import com.google.common.collect.Maps;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = CustomUUMValuesReference.MOD_ID, name = CustomUUMValuesReference.MOD_NAME, version = CustomUUMValuesReference.VERSION, dependencies = "required-after:IC2@[2.0,)")
public class CustomUUMValues {

	@Instance(CustomUUMValuesReference.MOD_ID)
	public static CustomUUMValues instance;

	public static Configuration config;
	public static Logger logger;

	public static String CONFIG_CATEGORY = "uumvalues";

	@EventHandler
	public void preInit(FMLPreInitializationEvent event) {
		config = new Configuration(event.getSuggestedConfigurationFile());
		logger = event.getModLog();
		logger.log(Level.INFO, "Pre-Initialization...");
		config.load();
	}

	@EventHandler
	public void init(FMLInitializationEvent event) {
		logger.log(Level.INFO, "Initialization...");
	}

	public void clearScannerRecipes() {
		Recipes.Scanner.getRecipes().clear();
	}

	public static final String AMOUNT_EU = "recordedAmountEU";
	public static final String AMOUNT_UU = "recordedAmountUU";

	public static void addScannerRecipe(ItemStack output, int recordedAmountUU,
			int recordedAmountEU) {
		if (output == null)
			return;
		NBTTagCompound metadata = new NBTTagCompound();

		metadata.setInteger(AMOUNT_UU, recordedAmountUU);
		metadata.setInteger(AMOUNT_EU, recordedAmountEU);

		Recipes.Scanner.addRecipe(new RecipeInputItemStack(output), metadata,
				new ItemStack[0]);
	}

	@EventHandler
	public void postInit(FMLPostInitializationEvent event) {
		logger.log(Level.INFO, "Post-Initialization...");
		if (!Loader.isModLoaded("IC2"))
			throw new RuntimeException("IC2 isn't installed.");
		Map<IRecipeInput, RecipeOutput> immutableScannerCopy = Maps
				.newHashMap();
		immutableScannerCopy.putAll(Recipes.Scanner.getRecipes());
		logger.info("Clearing old scanner recipes...");
		clearScannerRecipes();
		for (Entry<IRecipeInput, RecipeOutput> r : immutableScannerCopy
				.entrySet()) {
			try {
				if (r.getKey().getInputs().size() != 1) {
					logger.log(Level.SEVERE, "Recipe is invalid, continuing...");
					continue;
				}
				ItemStack output = r.getKey().getInputs().get(0);
				if (output == null) {
					logger.log(Level.SEVERE, "Recipe is invalid, continuing...");
					continue;
				}
				NBTTagCompound alreadyExisted = r.getValue().metadata;
				int alreadyExistedEU = alreadyExisted.getInteger(AMOUNT_EU);
				int alreadyExistedUU = alreadyExisted.getInteger(AMOUNT_UU);
				String name = output.getUnlocalizedName().replace("item.", "")
						.replace("tile.", "").replace(".name", "");
				int eu = config.get(CONFIG_CATEGORY, name + "Eu",
						alreadyExistedEU).getInt();
				int uu = config.get(CONFIG_CATEGORY, name + "Uu",
						alreadyExistedUU).getInt();
				if (eu > 0 && uu > 0) {
					logger.info(String.format(
							"Re-adding scanner recipe for %s, EU: %d, UU: %d",
							name, eu, uu));
					addScannerRecipe(output.copy(), uu, eu);
				}
			} catch (Throwable t) {
				logger.severe("Exception occured! Whoops!");
				t.printStackTrace();
			}
		}
		config.save();
	}
}

CustomUUMValuesReference.java

package makmods.customuumvalues;

public class CustomUUMValuesReference {

public static final String MOD_NAME = "Custom UUM Values";
public static final String MOD_ID = "CustomUUMValues";
public static final String VERSION = "v1.2";


}

mak326428 has attached the following file:

This post has been edited 2 times, last edit by "mak326428" (Oct 4th 2013, 9:38am)


2

Thursday, October 3rd 2013, 10:39pm

Woot! Now I can cut the iridium values in half to start with and go from there.

Though I do have a question: if a new material that IC2 supports comes along, will the config be updated to reflect such?

3

Thursday, October 3rd 2013, 10:47pm

Is it UNIVERSAL?for both...? :)
IF is, i'll download it :D And make people cry while the realize then getting 1 Iridium need 10x more UU :D HA HA :D

NICE JOB ! :)
public void getForumUserData(Signature signature, User user) { if(user.equalsTo("Cass") && user.isOnline() { Forum.Out.println("signature")})return;}

4

Thursday, October 3rd 2013, 10:51pm

For both SSP, and SMP? If that's your question, then yes it should work for both.

mak326428

Iron Miner

  • "mak326428" is male
  • "mak326428" started this thread

Posts: 639

Location: Totally not Honduras.

  • Send private message

5

Friday, October 4th 2013, 8:59am

Woot! Now I can cut the iridium values in half to start with and go from there.

Though I do have a question: if a new material that IC2 supports comes along, will the config be updated to reflect such?

Yes, it's absolutely dynamic. So, if any mod adds its UUM Recipes before CustomUUMValues' Post-Init phase (which they should), it will be a config option.

@CastielAngelow:
Yes it is. At least it should be.

@Make people cry:
I've already cried when I'd seen the default IC2's Iridium Ore UUM requirement.
That's what encouraged me to create this simple addon.

EDIT:
Yes, it actually works on servers.
I changed Iridium Ore in the config and it worked.

Spoiler Spoiler

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Post-Initialization...
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Clearing old scanner recipes...
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Re-adding scanner recipe for blockOreTin, EU: 15000, UU: 415
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Re-adding scanner recipe for oreIron, EU: 150000, UU: 551
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Re-adding scanner recipe for gravel, EU: 128, UU: 35
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Re-adding scanner recipe for redstone, EU: 4000, UU: 427
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Re-adding scanner recipe for itemDustCoal, EU: 9000, UU: 295
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Re-adding scanner recipe for oreGold, EU: 145000, UU: 5481
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Re-adding scanner recipe for blockOreLead, EU: 230000, UU: 2600
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Re-adding scanner recipe for coal, EU: 8000, UU: 284
2013-10-04 12:32:07 [INFO] [CustomUUMValues] Re-adding scanner recipe for blockOreUran, EU: 200000, UU: 6775
2013-10-04 12:32:08 [INFO] [CustomUUMValues] Re-adding scanner recipe for dyePowder.blue, EU: 35000, UU: 2432
2013-10-04 12:32:08 [INFO] [CustomUUMValues] Re-adding scanner recipe for stone, EU: 1180, UU: 5
2013-10-04 12:32:08 [INFO] [CustomUUMValues] Re-adding scanner recipe for sand, EU: 800, UU: 5
2013-10-04 12:32:08 [INFO] [CustomUUMValues] Re-adding scanner recipe for itemOreIridium, EU: 1000, UU: 1000
2013-10-04 12:32:08 [INFO] [CustomUUMValues] Re-adding scanner recipe for diamond, EU: 560000, UU: 20121
2013-10-04 12:32:08 [INFO] [CustomUUMValues] Re-adding scanner recipe for glass, EU: 1180, UU: 5
2013-10-04 12:32:08 [INFO] [CustomUUMValues] Re-adding scanner recipe for dirt, EU: 128, UU: 30
2013-10-04 12:32:08 [INFO] [CustomUUMValues] Re-adding scanner recipe for blockOreCopper, EU: 12000, UU: 349
2013-10-04 12:32:08 [INFO] [CustomUUMValues] Re-adding scanner recipe for stonebrick, EU: 128, UU: 4


EDIT 2:
Added source of the mod in OP.

This post has been edited 5 times, last edit by "mak326428" (Oct 4th 2013, 9:39am)


Chocohead

Drowning in mods.

  • "Chocohead" is male
  • Korea, Democratic People's Republic of United Kingdom

Posts: 5,979

Location: Badly generated chunks.

  • Send private message

6

Friday, October 4th 2013, 4:16pm

Can you add it so you can change the amount of EU for 1 bucket of UU too?
145 Mods isn't too many. 9 types of copper and 8 types of tin aren't too many. 3 types of coffee though?

I know that you believe that you understood what you think I said, but I am not sure you realise that what you read was not what I meant.


---- Minecraft Crash Report ----
// I just don't know what went wrong :(

I see this too much.

luacs1998

ForgeEssentials developer

  • Send private message

7

Friday, October 4th 2013, 4:26pm

Suggestion: Put your source in a zip, maybe even in the main mod distributable.

mak326428

Iron Miner

  • "mak326428" is male
  • "mak326428" started this thread

Posts: 639

Location: Totally not Honduras.

  • Send private message

8

Friday, October 4th 2013, 4:36pm

Can you add it so you can change the amount of EU for 1 bucket of UU too?

Nay, I can't do that in a lag-free fashion. The deal is that Mass Fab (as well as all other IC2 machines) set their BaseMassFabRate for every single MassFab-TileEntity-Instance, but they should've used a STATIC CONSTANT for it.
I could go the route of scan-all-the-tile-entities-every-tick-and-set-rate-for-each-mass-fab, but it would be, like I said, laggy. (mainly because of Reflection)

@luacs1998:
Okay, eventually.

GregoriusT

inactive IC² Dev but still active GT Dev

  • "GregoriusT" is male
  • Germany

Posts: 11,190

Location: Wherever I want to be (most of the time)

  • Send private message

9

Friday, October 4th 2013, 4:50pm

but they should've used a STATIC CONSTANT for it.
You mean like that one, which is already there since a while? "private static final int baseUuCost = 10000000;"
I don't say, your "insert whatever here" is bad, I'm only showing possibilities for making it better.

GregTech Website

Patreon really helps me out, so if you consider funding the development of GT, so I might be able to do it full time, why not?

GregTech 6, the Main Thread, Bug Reports go here too.

I'm also reachable on #gt-dev on irc.esper.net, if you don't want to make a Forum account to contact me, for example. ;)
(I'm there almost every day, but only when I'm at my own computer, and yes you can drop bugs there too)

mak326428

Iron Miner

  • "mak326428" is male
  • "mak326428" started this thread

Posts: 639

Location: Totally not Honduras.

  • Send private message

10

Friday, October 4th 2013, 4:58pm

but they should've used a STATIC CONSTANT for it.
You mean like that one, which is already there since a while? "private static final int baseUuCost = 10000000;"

Oh really?! I decompiled IC2_experimental as of 100 and basevalue there was specified in the constructor.
But, anyways, thanks Greg!

GregoriusT

inactive IC² Dev but still active GT Dev

  • "GregoriusT" is male
  • Germany

Posts: 11,190

Location: Wherever I want to be (most of the time)

  • Send private message

11

Friday, October 4th 2013, 4:59pm

Remember, static final on a basic datatype such as int means also, that even if you use reflection on it you can't change the value, as that value is being set at compile Time.
I don't say, your "insert whatever here" is bad, I'm only showing possibilities for making it better.

GregTech Website

Patreon really helps me out, so if you consider funding the development of GT, so I might be able to do it full time, why not?

GregTech 6, the Main Thread, Bug Reports go here too.

I'm also reachable on #gt-dev on irc.esper.net, if you don't want to make a Forum account to contact me, for example. ;)
(I'm there almost every day, but only when I'm at my own computer, and yes you can drop bugs there too)

mak326428

Iron Miner

  • "mak326428" is male
  • "mak326428" started this thread

Posts: 639

Location: Totally not Honduras.

  • Send private message

12

Friday, October 4th 2013, 5:07pm

Remember, static final on a basic datatype such as int means also, that even if you use reflection on it you can't change the value, as that value is being set at compile Time.

Greg, could you remove "final" keyword from that Variable, please :3?

GregoriusT

inactive IC² Dev but still active GT Dev

  • "GregoriusT" is male
  • Germany

Posts: 11,190

Location: Wherever I want to be (most of the time)

  • Send private message

13

Friday, October 4th 2013, 5:13pm

You dont understand. static final means that every mention of that variable is getting replaced by that Data during COMPILING, meaning that even if you change the Constant, nothing will use that changed Constant unless the Code uses reflection to get the Constant, what is never the Case.

Try getting the Version Number of IndustrialCraft without using Reflection from the IC2.class, while you are running a Version different from the one you compiled it with. You will always receive the same Version Number no matter what, unless you use reflection to access the Field.
I don't say, your "insert whatever here" is bad, I'm only showing possibilities for making it better.

GregTech Website

Patreon really helps me out, so if you consider funding the development of GT, so I might be able to do it full time, why not?

GregTech 6, the Main Thread, Bug Reports go here too.

I'm also reachable on #gt-dev on irc.esper.net, if you don't want to make a Forum account to contact me, for example. ;)
(I'm there almost every day, but only when I'm at my own computer, and yes you can drop bugs there too)

mak326428

Iron Miner

  • "mak326428" is male
  • "mak326428" started this thread

Posts: 639

Location: Totally not Honduras.

  • Send private message

14

Friday, October 4th 2013, 5:14pm

You dont understand. static final means that every mention of that variable is getting replaced by that Data during COMPILING, meaning that even if you change the Constant, nothing will use that changed Constant unless the Code uses reflection to get the Constant, what is never the Case.

Try getting the Version Number of IndustrialCraft without using Reflection from the IC2.class, while you are running a Version different from the one you compiled it with. You will always receive the same Version Number no matter what, unless you use reflection to access the Field.

Already got it, always doing stuff before thinking first...

GregoriusT

inactive IC² Dev but still active GT Dev

  • "GregoriusT" is male
  • Germany

Posts: 11,190

Location: Wherever I want to be (most of the time)

  • Send private message

15

Friday, October 4th 2013, 5:15pm

But yes, I will remove the final modifiers from those.
I don't say, your "insert whatever here" is bad, I'm only showing possibilities for making it better.

GregTech Website

Patreon really helps me out, so if you consider funding the development of GT, so I might be able to do it full time, why not?

GregTech 6, the Main Thread, Bug Reports go here too.

I'm also reachable on #gt-dev on irc.esper.net, if you don't want to make a Forum account to contact me, for example. ;)
(I'm there almost every day, but only when I'm at my own computer, and yes you can drop bugs there too)

mak326428

Iron Miner

  • "mak326428" is male
  • "mak326428" started this thread

Posts: 639

Location: Totally not Honduras.

  • Send private message

16

Friday, October 4th 2013, 5:16pm

But yes, I will remove the final modifiers from those.

Yay! Thanks for that.

Chocohead

Drowning in mods.

  • "Chocohead" is male
  • Korea, Democratic People's Republic of United Kingdom

Posts: 5,979

Location: Badly generated chunks.

  • Send private message

17

Friday, October 4th 2013, 7:55pm

Configurable UU cost is happening then? YAY :)
145 Mods isn't too many. 9 types of copper and 8 types of tin aren't too many. 3 types of coffee though?

I know that you believe that you understood what you think I said, but I am not sure you realise that what you read was not what I meant.


---- Minecraft Crash Report ----
// I just don't know what went wrong :(

I see this too much.

mak326428

Iron Miner

  • "mak326428" is male
  • "mak326428" started this thread

Posts: 639

Location: Totally not Honduras.

  • Send private message

18

Saturday, October 5th 2013, 8:58am

Configurable UU cost is happening then? YAY :)

Yes.

Epic Lulz

Copper Miner

  • "Epic Lulz" is male

Posts: 1,498

Location: The land of Hayo

  • Send private message

19

Saturday, October 5th 2013, 9:17am

Can you please add configuration options to add any specified material (i.e. by parsing a config) as UU-replicable?

mak326428

Iron Miner

  • "mak326428" is male
  • "mak326428" started this thread

Posts: 639

Location: Totally not Honduras.

  • Send private message

20

Saturday, October 5th 2013, 10:11am

Can you please add configuration options to add any specified material (i.e. by parsing a config) as UU-replicable?

Probably, yes. Need to look into Forge's Configuration class, and see if I can get all the Key-Value-Pairs from one specific Category, not just requested ones.

Counter:

Hits today: 54,464 | Hits yesterday: 80,423 | Hits record: 152,331 | Hits total: 65,219,155