I can't seem to figure out how I would add more blocks to the 'blocksEffectiveAgainst' array in ItemPickaxe.java without modifying the actualy ItemPickaxe.java. blocksEffectiveAgainst is private, so it cannot be accessed outside of ItemPickaxe either which means I can't just set the variable to what I want.
Check the ModLoader java docs for getPrivateValue().
I'm not quite sure how to use the method setPrivateValue().
The javadocs are rather vague, simply stating:
setPrivateValue
public static <T,E> void setPrivateValue(java.lang.Class<? super T> instanceclass,
T instance,
int fieldindex,
E value)
throws java.lang.IllegalArgumentException,
java.lang.SecurityException,
java.lang.NoSuchFieldException
Used for setting value of private fields.
Type Parameters:
T - Type of instance.
E - Type of value.
Parameters:
instanceclass - Class to use with instance.
instance - Object to get private field from.
fieldindex - Offset of field in class.
value - Value to set.
Throws:
java.lang.IllegalArgumentException - if instance isn't compatible with instanceclass.
java.lang.SecurityException - if the thread is not allowed to access field.
java.lang.NoSuchFieldException - if field does not exist.
If I wanted to change the private Block array blocksEffectiveAgainst in ItemPickaxe.java what arguments would I use?
I don't quite see what would be inputted for 'instance' and 'fieldindex' and I'm not too sure on 'instanceclass' either.
instance class is the full "path" to the class you are dealing with. In you case, it would be:
net.minecraft.src.ItemPickaxe.class
(Note the 'class' at the end.) The instance is the object itself. This is where I start to get lost because there are multiple pickaxes. Item.pickaxeSteel is just one of them.
fieldindex is just what it says. For example:
public class Foo {
int a;
String b;
int c;
}
So a is 0, b is 1, and c is 2. (Or is that 1,2,3?) There is another setPrivateValue() that uses field names, so that's probably easier.
value is - well, I'm sure you figured that one out. Of course, the type is based on the private value you are setting: int, float, etc.
Unfortunately, I've never tried any of this. I only know this is the right direction.
instance class is the full "path" to the class you are dealing with. In you case, it would be:
net.minecraft.src.ItemPickaxe.class
(Note the 'class' at the end.) The instance is the object itself. This is where I start to get lost because there are multiple pickaxes. Item.pickaxeSteel is just one of them.
fieldindex is just what it says. For example:
public class Foo {
int a;
String b;
int c;
}
So a is 0, b is 1, and c is 2. (Or is that 1,2,3?) There is another setPrivateValue() that uses field names, so that's probably easier.
value is - well, I'm sure you figured that one out. Of course, the type is based on the private value you are setting: int, float, etc.
Unfortunately, I've never tried any of this. I only know this is the right direction.
So I would have to change the value for each individual pickaxe?
As I said, you've tapped out my knowledge of this subject. Hopefully, I pointed you in the right direction. Since this is ModLoader stuff, you can't look at Notch's code for examples. You'll have to look at other mods, keep asking, or experiment.
I'm not quite sure how to use the method setPrivateValue().
The javadocs are rather vague, simply stating:
If I wanted to change the private Block array blocksEffectiveAgainst in ItemPickaxe.java what arguments would I use?
I don't quite see what would be inputted for 'instance' and 'fieldindex' and I'm not too sure on 'instanceclass' either.
net.minecraft.src.ItemPickaxe.class
(Note the 'class' at the end.) The instance is the object itself. This is where I start to get lost because there are multiple pickaxes. Item.pickaxeSteel is just one of them.
fieldindex is just what it says. For example:
public class Foo {
int a;
String b;
int c;
}
So a is 0, b is 1, and c is 2. (Or is that 1,2,3?) There is another setPrivateValue() that uses field names, so that's probably easier.
value is - well, I'm sure you figured that one out. Of course, the type is based on the private value you are setting: int, float, etc.
Unfortunately, I've never tried any of this. I only know this is the right direction.
So I would have to change the value for each individual pickaxe?