What is wrong with this code?
It only works for blocks right next, but i want it to work for a above and then right next to it. (like next to the block of air above the main block)
public boolean blockAY(IBlockAccess iblockaccess, int i, int j, int k)
{
int mnm = iblockaccess.getBlockId(i, j, k);
int mnm2 = iblockaccess.getBlockId(i-1, j, k);
int mnm3 = iblockaccess.getBlockId(i+1, j, k);
int mnm4 = iblockaccess.getBlockId(i, j, k-1);
int mnm5 = iblockaccess.getBlockId(i, j, k+1);
int mnm6 = iblockaccess.getBlockId(i, j-1, k);
int mnm7 = iblockaccess.getBlockId(i, j+1, k);
int mnm8 = iblockaccess.getBlockId(i+1, j, k+1);
int mnm9 = iblockaccess.getBlockId(i+1, j, k-1);
int mnm10 = iblockaccess.getBlockId(i-1, j, k+1);
int mnm11 = iblockaccess.getBlockId(i-1, j, k-1);
int mnm12 = iblockaccess.getBlockId(i, j+1, k+1);
int mnm13 = iblockaccess.getBlockId(i, j-1, k+1);
int mnm14 = iblockaccess.getBlockId(i, j+1, k-1);
int mnm15 = iblockaccess.getBlockId(i, j-1, k-1);
if(mnm == Block.dirt.blockID || mnm2 == Block.dirt.blockID || mnm3 == Block.dirt.blockID || mnm4 == Block.dirt.blockID || mnm5 == Block.dirt.blockID || mnm6 == Block.dirt.blockID || mnm7 == Block.dirt.blockID || mnm8 == Block.dirt.blockID || mnm9 == Block.dirt.blockID || mnm10 == Block.dirt.blockID || mnm11 == Block.dirt.blockID || mnm12 == Block.dirt.blockID || mnm13 == Block.dirt.blockID || mnm14 == Block.dirt.blockID|| mnm15 == Block.dirt.blockID)
{
return true;
} else
{
return false;
}
}
O and i know this is a bit messy, i don't know how to make it any better.
What is wrong with this code?
It only works for blocks right next, but i want it to work for a above and then right next to it. (like next to the block of air above the main block)
public boolean blockAY(IBlockAccess iblockaccess, int i, int j, int k)
{
int[] mnm = new int[27];
int i=0;
for(int x=-1;x<2;x++)
{
for(int y=-1;y<2;y++)
{
for(int z=-1;z<2;z++)
{
mnm[i]=iblockaccess.getBlockId(i+x,i+y,i+z);
i++;
}
}
}
for(int j=0;j<mnm.length;j++)
{
if(mnm[j]==Block.dirt.blockID)
{
return true;
}
}
return false;
}
O and i know this is a bit messy, i don't know how to make it any better.
To answer your question, you forgot to do all of the combinations involving x, y, and z (i.e. iblockaccess.getBlockId(x+1,y-1,z+1):wink.gif:
Would you help me out a bit more, I don't really get what you meant (said another way i thought ijk stood for xyz, isn't this true?)
1) Look in my quote, I cleaned up the code a bit and fixed it for you
2)ijk does stand for xyz, what I was saying is that when you looked through the blocks, and did i+1, j-1, etc. you forgot all of the combinations that involved x, y, AND z:
(this has one changed, i)
int mnm3 = iblockaccess.getBlockId(i+1, j, k);
(this has two changed, j and k)
int mnm15 = iblockaccess.getBlockId(i, j-1, k-1);
but none that were like this:
int mnm72 = iblockaccess.getBlockId(i+1, j+1, k-1);
look at my very first quote, I fixed the code inside of there.
I meant that one, It first told me I and J were already declared so i took them out of the header, and since i didn't see k anymore i took that out too, but it still doesn't work.
Maybe you know what's wrong with the header?
I meant that one, It first told me I and J were already declared so i took them out of the header, and since i didn't see k anymore i took that out too, but it still doesn't work.
Maybe you know what's wrong with the header?
oops, I forgot about the parameters.
Change it to this:
public boolean blockAY(IBlockAccess iblockaccess, int i, int j, int k)
{
int[] mnm = new int[27];
int l=0;
for(int x=-1;x<2;x++)
{
for(int y=-1;y<2;y++)
{
for(int z=-1;z<2;z++)
{
mnm[l]=iblockaccess.getBlockId(i+x,i+y,i+z);
l++;
}
}
}
for(int m=0;j<mnm.length;j++)
{
if(mnm[m]==Block.dirt.blockID)
{
return true;
}
}
return false;
}
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then. WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
I think i have to put something between the ()'s of blockAY and x,y,z isn't complete too, is this true?
What method is this code inside of?
Rollback Post to RevisionRollBack
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then. WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then. WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
I'm not sure where you got that method heading from, but onNeighborBlockChange should look like this
public void onNeighborBlockChange(World world, int i, int j, int k, int l)
i and k are x and z, j is k.
I'm not sure what to pass your method for IBlockAccess, but for the 2nd, 3rd, and 4th slot, pass i, j, k.
Perhaps instead of IBlockAccess, you should use a World object, and then just pass in world. World has a getBlockID(i, j, k) method as well.
Edit: Your setBlockWithNotify call should use i, j, k as well (instead of x, y, z)
Ok could you post the complete code, because it still doesn't work at all (dirt and stone are actually something else but i named them this way)
PS i'm not allowed to post anymore now
EDIT: Got it to work(half) because it still doesn't work for the blocks diagonally or (like redstone) diagonally above it, the blocks have to literally touch the main block, if they don't it just doesn't work (so if i'd want to make it change the block 3 block's away, no matter what i code, it doesn't work).
Nested for loops are what you need. Run one loop from -3 to 3 for i, and inside that run another from -3 to 3 for j, and inside that run another from -3 to 3 for k. This method is only viable for short ranges, though, so don't try it if you want the range to be 300 blocks or something ridiculous. Already, that's running 27 checks.
P.S. I'm a believer in not giving people code outright, but letting them structure it themselves. Learning experience, you see.
It only works for blocks right next, but i want it to work for a above and then right next to it. (like next to the block of air above the main block)
O and i know this is a bit messy, i don't know how to make it any better.
To answer your question, you forgot to do all of the combinations involving x, y, and z (i.e. iblockaccess.getBlockId(x+1,y-1,z+1):wink.gif:
Would you help me out a bit more, I don't really get what you meant (said another way i thought ijk stood for xyz, isn't this true?)
1) Look in my quote, I cleaned up the code a bit and fixed it for you
2)ijk does stand for xyz, what I was saying is that when you looked through the blocks, and did i+1, j-1, etc. you forgot all of the combinations that involved x, y, AND z:
(this has one changed, i)
(this has two changed, j and k)
but none that were like this:
Well i tried a lot of things but i can't seem to get it to work, i don't know what's wrong.
look at my very first quote, I fixed the code inside of there.
I meant that one, It first told me I and J were already declared so i took them out of the header, and since i didn't see k anymore i took that out too, but it still doesn't work.
Maybe you know what's wrong with the header?
oops, I forgot about the parameters.
Change it to this:
Might want your for loop to work correctly. Change the 'j's to 'm's.
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then.
WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
I compiles without error's but now i have a problem with another piece of code connected to it
I think i have to put something between the ()'s of blockAY and x,y,z isn't complete too, is this true?
What method is this code inside of?
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then.
WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
public void onNeighborBlockChange(World world, int i, int j, int k, int l, int x, int y, int z)
I'm not sure where you got that method heading from, but onNeighborBlockChange should look like this
i and k are x and z, j is k.
I'm not sure what to pass your method for IBlockAccess, but for the 2nd, 3rd, and 4th slot, pass i, j, k.
Perhaps instead of IBlockAccess, you should use a World object, and then just pass in world. World has a getBlockID(i, j, k) method as well.
Edit: Your setBlockWithNotify call should use i, j, k as well (instead of x, y, z)
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then.
WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
Ok could you post the complete code, because it still doesn't work at all (dirt and stone are actually something else but i named them this way)
PS i'm not allowed to post anymore now
EDIT: Got it to work(half) because it still doesn't work for the blocks diagonally or (like redstone) diagonally above it, the blocks have to literally touch the main block, if they don't it just doesn't work (so if i'd want to make it change the block 3 block's away, no matter what i code, it doesn't work).
P.S. I'm a believer in not giving people code outright, but letting them structure it themselves. Learning experience, you see.