I am using Vanilla Minecraft 1.6.4, so please do not send me Modloader or Forge codes.
---
I've been looking into this for a while, and so far it seems like isOnLader() in the class EntityLivingBase & having your block bounds set to anything under 0.9F lets the block have the capability of climbing. I can't seem to trace anything for isOnLader, or what tells the game when a player is actually on a ladder.
/**
* returns true if this entity is by a ladder, false otherwise
*/
public boolean isOnLadder()
{
int var1 = MathHelper.floor_double(this.posX);
int var2 = MathHelper.floor_double(this.boundingBox.minY);
int var3 = MathHelper.floor_double(this.posZ);
int var4 = this.worldObj.getBlockId(var1, var2, var3);
return var4 == Block.ladder.blockID || var4 == Block.vine.blockID;
}
I've already got most of it all done, just need to know what controls placement of where you climb?
Yeah, @Spirit_Tracks already gave me that one. While I know most people don't use 1.6.4, I am waiting for the next full release of MCP because I've been having too many issues with the names of most of the codes I need in 1.7.2 & 1.8 not being obfuscated, and it's just too confusing for me at the moment.
It's alright, lol, and yeah, I've been doing searches and looking at a lot of the codes to see what controls which part sets tells the game that the player is on a ladder at x,y,z of the block, but I've been getting headaches so it's not really that easy for me. Plus I am close to releasing a different block (the one in my icon currently), so that should be fun. xD
The Meaning of Life, the Universe, and Everything.
Join Date:
4/3/2015
Posts:
54
Member Details
Okay, don't have the 1.6.4 code... but inside of BlockLadder there should be a method that's called isLadder (or something like that)... here's the 1.7.10 version as a pointer.
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
{
return true;
}
Okay, don't have the 1.6.4 code... but inside of BlockLadder there should be a method that's called isLadder (or something like that)... here's the 1.7.10 version as a pointer.
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
{
return true;
}
@Born2Code, did you not see CosmicDan already posted that code, and that code is from Forge? Please at least read a few of the previous comments before posting.
@Sidonious, it may help you to get a copy of Forge simply so you can use your IDE to trace the call hierarchy of the Forge method to find where it was injected into the vanilla code, and then you can search for that vanilla code in your non-Forge version.
It appears that EntityLivingBase#isOnLadder is where Forge added their method, so you'll want to check the call hierarchy of that method (hopefully it is vanilla). You should then see that it is called from EntityLivingBase#moveEntityWithHeading, where, in combination with entity.isCollidedHorizontally, some motionY is added to the entity.
In Eclipse, you can open the call hierarchy for any method / variable using Ctrl-Alt-H or by right-clicking and selecting that option. Doing so, I was able to find the above information in less than one minute, so you can see that IDEs are a very powerful programming aid when used to their full potential.
@Born2Code, did you not see CosmicDan already posted that code, and that code is from Forge? Please at least read a few of the previous comments before posting.
Yes true, and my bad for that... but what is he expecting to do with it in vanilla?
I've made some climbables before. The part most people get wrong is that the bounding box needs to be smaller than 1, 1, 1, but you already figured that part out.
One of my main complaints with the coding style of vanilla is that they compare to exact instances rather than using instanceof. This greatly limits the ease in which you can extend the classes.
In the isOnLadder() code posted at the top of the thread, you can see that it checks whether the block is a ladder or vine instance. So even extending BlockLadder won't help you since the instance of your custom ladder will be different.
I think the isOnLadder() is the right method, but not sure how you're going to hook into it.
---
I've been looking into this for a while, and so far it seems like isOnLader() in the class EntityLivingBase & having your block bounds set to anything under 0.9F lets the block have the capability of climbing. I can't seem to trace anything for isOnLader, or what tells the game when a player is actually on a ladder.
/**
* returns true if this entity is by a ladder, false otherwise
*/
public boolean isOnLadder()
{
int var1 = MathHelper.floor_double(this.posX);
int var2 = MathHelper.floor_double(this.boundingBox.minY);
int var3 = MathHelper.floor_double(this.posZ);
int var4 = this.worldObj.getBlockId(var1, var2, var3);
return var4 == Block.ladder.blockID || var4 == Block.vine.blockID;
}
I've already got most of it all done, just need to know what controls placement of where you climb?
EDIT: That's for 1.7.10, if it's different in 1.6.x then I dunno. Nobody uses 1.6.x anymore.
EDIT2: Ok, apparently that's added by Forge. *Shrug* nevermind, no idea.
http://mcp.ocean-labs.de/download.php?list.2
Obviously the ladder logic wasn't easy or obvious though, hence Forge added the isLadder thing.
Sorry I couldn't help
moreat all. If it were me, I'd do a full text search on the whole code for ladder and explore lol.Okay, don't have the 1.6.4 code... but inside of BlockLadder there should be a method that's called isLadder (or something like that)... here's the 1.7.10 version as a pointer.
public boolean isLadder(IBlockAccess world, int x, int y, int z, EntityLivingBase entity)
{
return true;
}
@Born2Code, did you not see CosmicDan already posted that code, and that code is from Forge? Please at least read a few of the previous comments before posting.
@Sidonious, it may help you to get a copy of Forge simply so you can use your IDE to trace the call hierarchy of the Forge method to find where it was injected into the vanilla code, and then you can search for that vanilla code in your non-Forge version.
It appears that EntityLivingBase#isOnLadder is where Forge added their method, so you'll want to check the call hierarchy of that method (hopefully it is vanilla). You should then see that it is called from EntityLivingBase#moveEntityWithHeading, where, in combination with entity.isCollidedHorizontally, some motionY is added to the entity.
In Eclipse, you can open the call hierarchy for any method / variable using Ctrl-Alt-H or by right-clicking and selecting that option. Doing so, I was able to find the above information in less than one minute, so you can see that IDEs are a very powerful programming aid when used to their full potential.
Yes true, and my bad for that... but what is he expecting to do with it in vanilla?
I've made some climbables before. The part most people get wrong is that the bounding box needs to be smaller than 1, 1, 1, but you already figured that part out.
One of my main complaints with the coding style of vanilla is that they compare to exact instances rather than using instanceof. This greatly limits the ease in which you can extend the classes.
In the isOnLadder() code posted at the top of the thread, you can see that it checks whether the block is a ladder or vine instance. So even extending BlockLadder won't help you since the instance of your custom ladder will be different.
I think the isOnLadder() is the right method, but not sure how you're going to hook into it.