Currently I am brand new to modding, After my first modded block clay (Made it drop 128 :biggrin.gif:) I was impressed with myself, Now I am trying to make an block that will automatically produce an house/farm when put down/clicked.
I've been looking and i've found this code.
public void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
{
// Basic Building
int block = Block.wood.blockID;
int size = 5;
for (int i1 = 0; i1 < size; i1++)
{
for (int j1 = 0; j1 < size; j1++)
{
//Walls
// i == ++ k == 0
world.setBlockWithNotify(i+i1,j+j1,k,block);
// i == ++ k == 4
world.setBlockWithNotify(i+i1,j+j1,k+(size-1),block);
// i == 0 k == ++
world.setBlockWithNotify(i,j+j1,k+i1,block);
// i == 4 k == ++
world.setBlockWithNotify(i+(size-1),j+j1,k+i1,block);
//Roof
world.setBlockWithNotify(i+i1,j+(size-1),k+j1,block);
//Floor
world.setBlockWithNotify(i+i1,j,k+j1,block);
}
}
//Door
world.setBlockWithNotify(i+1,j+2,k,0);
world.setBlockWithNotify(i+1,j+1,k,0);
//Windows
int offset = size % 2 == 0 ? (size / 2) - 1 : (size / 2);
world.setBlockWithNotify(i,j+offset,k+offset,Block.glass.blockID);
world.setBlockWithNotify(i+offset,j+offset,k,Block.glass.blockID);
world.setBlockWithNotify(i+(size-1),j+offset,k+offset,Block.glass.blockID);
world.setBlockWithNotify(i+offset,j+offset,k+(size-1),Block.glass.blockID);
//Utilities
world.setBlockWithNotify(i+1,j+1,k+(size-2),Block.crate.blockID);
world.setBlockWithNotify(i+(size-2),j+1,k+1,Block.workbench.blockID);
world.setBlockWithNotify(i+(size-2),j+1,k+(size-2),Block.stoneOvenIdle.blockID);
}
HOWEVER it gives me this error while trying to recompile and it null's the whole thing and won't even build afterwards.
sources\minecraft\net\minecraft\src\Block.java:477: onBlockClicked(net.minecraft
.src.World,int,int,int,net.minecraft.src.EntityPlayer) is already defined in net
.minecraft.src.Block
public void onBlockClicked(World world, int i, int j, int k, EntityPlayer en
tityplayer)
^
1 error
Currently need an new source so I can freely mod.
Also could you please describe how it build's since it does not make any sense for me atm.
Where it says "public" in your code, switch it to "private". As far as I know, this problem is caused by you trying to define a function that's already defined elsewhere, and switching it to private should fix that.
If that doesn't work, just rename the function to something like "OnBlockClickedmod".
Where it says "public" in your code, switch it to "private". As far as I know, this problem is caused by you trying to define a function that's already defined elsewhere, and switching it to private should fix that.
If that doesn't work, just rename the function to something like "OnBlockClickedmod".
Attempted and did and didn't fix it.
If i rename the it to private i'll get 5 errors.
But if i rename the function to OnblockClickedtest it will compile fine BUT nothing shows up when i place an grass block =/
If i rename the it to private i'll get 5 errors.
But if i rename the function to OnblockClickedtest it will compile fine BUT nothing shows up when i place an grass block =/
Yeah I didn't think the 'private' thing would work, but it was worth a try. Where is "OnBlockClickedtest" being called from? Did you remember to change that too?
If i rename the it to private i'll get 5 errors.
But if i rename the function to OnblockClickedtest it will compile fine BUT nothing shows up when i place an grass block =/
Yeah I didn't think the 'private' thing would work, but it was worth a try. Where is "OnBlockClickedtest" being called from? Did you remember to change that too?
I don't know if its being called.
Currently this is what i got inside block.java
public void onBlockClickedtest(World world, int i, int j, int k, EntityPlayer entityplayer)
{
// Basic Building
int block = Block.grass.blockID;
int size = 5;
for (int i1 = 0; i1 < size; i1++)
{
for (int j1 = 0; j1 < size; j1++)
{
//Walls
// i == ++ k == 0
world.setBlockWithNotify(i+i1,j+j1,k,block);
// i == ++ k == 4
world.setBlockWithNotify(i+i1,j+j1,k+(size-1),block);
// i == 0 k == ++
world.setBlockWithNotify(i,j+j1,k+i1,block);
// i == 4 k == ++
world.setBlockWithNotify(i+(size-1),j+j1,k+i1,block);
//Roof
world.setBlockWithNotify(i+i1,j+(size-1),k+j1,block);
//Floor
world.setBlockWithNotify(i+i1,j,k+j1,block);
}
}
//Door
world.setBlockWithNotify(i+1,j+2,k,0);
world.setBlockWithNotify(i+1,j+1,k,0);
//Windows
int offset = size % 2 == 0 ? (size / 2) - 1 : (size / 2);
world.setBlockWithNotify(i,j+offset,k+offset,Block.glass.blockID);
world.setBlockWithNotify(i+offset,j+offset,k,Block.glass.blockID);
world.setBlockWithNotify(i+(size-1),j+offset,k+offset,Block.glass.blockID);
world.setBlockWithNotify(i+offset,j+offset,k+(size-1),Block.glass.blockID);
//Utilities
world.setBlockWithNotify(i+1,j+1,k+(size-2),Block.crate.blockID);
world.setBlockWithNotify(i+(size-2),j+1,k+1,Block.workbench.blockID);
world.setBlockWithNotify(i+(size-2),j+1,k+(size-2),Block.stoneOvenIdle.blockID);
}
I've been looking and i've found this code.
HOWEVER it gives me this error while trying to recompile and it null's the whole thing and won't even build afterwards.
Currently need an new source so I can freely mod.
Also could you please describe how it build's since it does not make any sense for me atm.
If that doesn't work, just rename the function to something like "OnBlockClickedmod".
Attempted and did and didn't fix it.
If i rename the it to private i'll get 5 errors.
But if i rename the function to OnblockClickedtest it will compile fine BUT nothing shows up when i place an grass block =/
Yeah I didn't think the 'private' thing would work, but it was worth a try. Where is "OnBlockClickedtest" being called from? Did you remember to change that too?
I don't know if its being called.
Currently this is what i got inside block.java
In that code, there isn't a space between "public" and "void", and there should be. Unless you just copypasted it wrong to here and that happened.
Mod Archive