The Meaning of Life, the Universe, and Everything.
Location:
worthington
Join Date:
11/3/2010
Posts:
51
Member Details
I checked out all the tutorials, and browsed through about 5 pages of the mod forum, but I couldn't find anything that would help me.
Basically, I'm a novice modder, and for my first mod I was hoping to do something like:
You hit a certain key on the keyboard, and using code you immediately equip the best armor in your inventory.]
Now, code wise I think I know what I'd need to do, but I haven't been able to figure out what commands Minecraft uses to reference inventory/armor (or, specific armor types/inventory slots.)
Can anyone tell me how I'd go about making the above bit of code? I don't need you to tell me exactly how to do the code, but if you could tell me the variable names and the general way I'd go about it, I'd be very thankful.
(Sorry if this question is a bit...Noobish, but I'm just learning java/modding minecraft. I've mostly only programmed in C++ and LUA)
I checked out all the tutorials, and browsed through about 5 pages of the mod forum, but I couldn't find anything that would help me.
Basically, I'm a novice modder, and for my first mod I was hoping to do something like:
You hit a certain key on the keyboard, and using code you immediately equip the best armor in your inventory.]
Now, code wise I think I know what I'd need to do, but I haven't been able to figure out what commands Minecraft uses to reference inventory/armor (or, specific armor types/inventory slots.)
Can anyone tell me how I'd go about making the above bit of code? I don't need you to tell me exactly how to do the code, but if you could tell me the variable names and the general way I'd go about it, I'd be very thankful.
(Sorry if this question is a bit...Noobish, but I'm just learning java/modding minecraft. I've mostly only programmed in C++ and LUA)
Well, the best thing to do right now is wait until MCP comes out. Until then, obtain the data values for the armor slots here.
I am thinking you will do a search for each armor slot starting with diamond, right?
The Meaning of Life, the Universe, and Everything.
Location:
worthington
Join Date:
11/3/2010
Posts:
51
Member Details
I don't know much of Java, but I was planning to do the equivalent of:
1) Check to see if head-armor slot is empty.
if true run search (described below)
if false skip to next slot
2) Repeat above command for each armor slot
SEARCH: Check each inventory slot for [armor-slot] starting with lowest quality (leather/gold) going up to highest (diamond) and equip whichever is the highest armor type you have.
EDIT: That's just a rough idea of what I'd do, obviously the code would have to get more in depth.
The Meaning of Life, the Universe, and Everything.
Location:
worthington
Join Date:
11/3/2010
Posts:
51
Member Details
Quote from r42xer »
Diamond protects you more than chainmail no? Just chainmail has better durability because Notch didn't fully code it.
Also, I would help you, but I am stuck with a mac.
heres some free code. AKA the search function
for (i = 0, i <= 35, i = i + 1) {
getBlocktype.i;
if (blockType = 1){
getArmortype;
if (armortype = 5){
(Equipping code here);
}
}
}
I think.
Thanks a TON. I learn best from reading other's code. But there don't seem to be a lot of in-depth modding tutorials on here...That's a step in the right direction though :tongue.gif: How will I implement it without MCP though?
EDIT: Also, just to make sure I'm understanding the code:
- I'm guessing "getBlocktype.i;" gets the type of item in slot i.
- if "(blockType = 1){" Why do we check if it equals 1? What is 1 supposed to be checking for? (whether or not it's armor?)
- "getArmortype;
if (armortype = 5){" I'm guessing getArmortype checks what kind of armor block i is, but yet again, what is 5 checking for?
Diamond protects you more than chainmail no? Just chainmail has better durability because Notch didn't fully code it.
Also, I would help you, but I am stuck with a mac.
heres some free code. AKA the search function
for (i = 0, i <= 35, i = i + 1) {
getBlocktype.i;
if (blockType = 1){
getArmortype;
if (armortype = 5){
(Equipping code here);
}
}
}
I think.
Thanks a TON. I learn best from reading other's code. But there don't seem to be a lot of in-depth modding tutorials on here...That's a step in the right direction though :tongue.gif: How will I implement it without MCP though?
EDIT: Also, just to make sure I'm understanding the code:
- I'm guessing "getBlocktype.i;" gets the type of item in slot i.
- if "(blockType = 1){" Why do we check if it equals 1? What is 1 supposed to be checking for? (whether or not it's armor?)
- "getArmortype;
if (armortype = 5){" I'm guessing getArmortype checks what kind of armor block i is, but yet again, what is 5 checking for?
I'm not sure if getblocktype.i would check for the blocktype in slot i (it looks for the method getblocktype in class i) and thats a mistake on my part.
Block type, I think would be something from 1-whatever that determines what block type it is (could be datavalues, I am not sure how to do ranges in java)
Armor Type is from 1-5, Leather, Gold, Iron, Chainmail, Diamond. I realiZe I would have to include another "for" loop there.
The Meaning of Life, the Universe, and Everything.
Location:
worthington
Join Date:
11/3/2010
Posts:
51
Member Details
Quote from r42xer »
I'm not sure if getblocktype.i would check for the blocktype in slot i (it looks for the method getblocktype in class i) and thats a mistake on my part.
Block type, I think would be something from 1-whatever that determines what block type it is (could be datavalues, I am not sure how to do ranges in java)
Armor Type is from 1-5, Leather, Gold, Iron, Chainmail, Diamond. I realiZe I would have to include another "for" loop there.
Okay, so would the search loop go something like: (make sure to read this knowing I have almost no knowledge of Java)
(this code is specifically for the head slot)
h = 0
for (i = 0, i <= 35, i += 1 [i]couldn't you just do i +=1 rather then 1 = 1 + 1?[/i]) {
getBlocktype.i;
if (blockType = 1){
getArmortype;
for (a = 1, a <=5, a+=1){
if (armortype = a && a > h){
h = i
}
}
}
}
(Equipping code here.)
Would that work? I've only ever programmed in GML LUA and C++, so I'm not sure.
Basically, I'm a novice modder, and for my first mod I was hoping to do something like:
You hit a certain key on the keyboard, and using code you immediately equip the best armor in your inventory.]
Now, code wise I think I know what I'd need to do, but I haven't been able to figure out what commands Minecraft uses to reference inventory/armor (or, specific armor types/inventory slots.)
Can anyone tell me how I'd go about making the above bit of code? I don't need you to tell me exactly how to do the code, but if you could tell me the variable names and the general way I'd go about it, I'd be very thankful.
(Sorry if this question is a bit...Noobish, but I'm just learning java/modding minecraft. I've mostly only programmed in C++ and LUA)
Well, the best thing to do right now is wait until MCP comes out. Until then, obtain the data values for the armor slots here.
I am thinking you will do a search for each armor slot starting with diamond, right?
1) Check to see if head-armor slot is empty.
if true run search (described below)
if false skip to next slot
2) Repeat above command for each armor slot
SEARCH: Check each inventory slot for [armor-slot] starting with lowest quality (leather/gold) going up to highest (diamond) and equip whichever is the highest armor type you have.
EDIT: That's just a rough idea of what I'd do, obviously the code would have to get more in depth.
Also, I would help you, but I am stuck with a mac.
heres some free code. AKA the search function
I think.
Thanks a TON. I learn best from reading other's code. But there don't seem to be a lot of in-depth modding tutorials on here...That's a step in the right direction though :tongue.gif: How will I implement it without MCP though?
EDIT: Also, just to make sure I'm understanding the code:
- I'm guessing "getBlocktype.i;" gets the type of item in slot i.
- if "(blockType = 1){" Why do we check if it equals 1? What is 1 supposed to be checking for? (whether or not it's armor?)
- "getArmortype;
if (armortype = 5){" I'm guessing getArmortype checks what kind of armor block i is, but yet again, what is 5 checking for?
I'm not sure if getblocktype.i would check for the blocktype in slot i (it looks for the method getblocktype in class i) and thats a mistake on my part.
Block type, I think would be something from 1-whatever that determines what block type it is (could be datavalues, I am not sure how to do ranges in java)
Armor Type is from 1-5, Leather, Gold, Iron, Chainmail, Diamond. I realiZe I would have to include another "for" loop there.
Okay, so would the search loop go something like: (make sure to read this knowing I have almost no knowledge of Java)
(this code is specifically for the head slot)
Would that work? I've only ever programmed in GML LUA and C++, so I'm not sure.