(Warning: I'm not very good at coding, so I'm sorry if what I am about to say makes no sense or is really easy to fix, once again I have just started coding)
I've recently decided to start trying out coding, and so far everything has been alright except for this one thing:
I coded a new block using MCP and eclipse, it is similar to a grass block so of course i had to write in a bit of extra code to get it to have different png images for each side of the block. After that was done i ran the game and my block appears in the creative mode blocks tab and I place it on the ground. the problem is one of the bottom of the block is purple, which most likely means it couldn't find the png image I set for it.
I've checked the code a lot of times and I see nothing blatantly wrong with it, and its been bothering me because I literally don't know how to fix it, so I decided to post it here so you guys could help me :s
The code:
package net.minecraft.src;
public class mod_test extends BaseMod
{
public static final Block terrapreta = new Blockterra(160, 0).setBlockName("terra preta").setHardness(4F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundGrassFootstep);
public static int terraBottom = ModLoader.addOverride("/terrain.png", "/Test/image22.png");
public static int terraTop = ModLoader.addOverride("/terrain.png", "/Test/image1.png");
public static int terraSides = ModLoader.addOverride("/terrain.png", "/Test/image3.png");
public void load()
package net.minecraft.src;
import java.util.Random;
public class Blockterra extends Block
{
public Blockterra(int i, int j)
{
super(i, j, Material.ground);
}
public int quantityDropped(Random random)
{
return 1;
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
return getBlockTextureFromSide(i);
}
public int getBlockTextureFromSide(int i)
{
if (i == 0)
{
return mod_test.terraBottom;
}
if (i == 1)
{
return mod_test.terraTop;
}
else
{
return mod_test.terraSides;
}
}
}
package net.minecraft.src;
public class mod_test extends BaseMod
{
public static final Block terrapreta = new Blockterra(160, 0).setBlockName("terra preta").setHardness(4F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundGrassFootstep);
public static int terraBottom = ModLoader.addOverride("/terrain.png", "/Test/image22.png");
public static int terraTop = ModLoader.addOverride("/terrain.png", "/Test/image1.png");
public static int terraSides = ModLoader.addOverride("/terrain.png", "/Test/image3.png");
public void load()
See the part I've highlighted? You've used ModLoader.addOverride twice on the same file. You should only ever run that method once per file because each subsequent time changes the number for that image. That's why your terraBottom int doesn't give the right image.
See the part I've highlighted? You've used ModLoader.addOverride twice on the same file. You should only ever run that method once per file because each subsequent time changes the number for that image. That's why your terraBottom int doesn't give the right image.
To fix this, change the line in red to say:
terrapreta.blockIndexInTexture = terraBottom;
thanks :), i left that in when i first made the block because at the time it only had 1 texture image, so i decided to leave it in for fear it would crash my game if i took it out.
I've recently decided to start trying out coding, and so far everything has been alright except for this one thing:
I coded a new block using MCP and eclipse, it is similar to a grass block so of course i had to write in a bit of extra code to get it to have different png images for each side of the block. After that was done i ran the game and my block appears in the creative mode blocks tab and I place it on the ground. the problem is one of the bottom of the block is purple, which most likely means it couldn't find the png image I set for it.
I've checked the code a lot of times and I see nothing blatantly wrong with it, and its been bothering me because I literally don't know how to fix it, so I decided to post it here so you guys could help me :s
The code:
package net.minecraft.src;
public class mod_test extends BaseMod
{
public static final Block terrapreta = new Blockterra(160, 0).setBlockName("terra preta").setHardness(4F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundGrassFootstep);
public static int terraBottom = ModLoader.addOverride("/terrain.png", "/Test/image22.png");
public static int terraTop = ModLoader.addOverride("/terrain.png", "/Test/image1.png");
public static int terraSides = ModLoader.addOverride("/terrain.png", "/Test/image3.png");
public void load()
{
terrapreta.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Test/image22.png");
ModLoader.registerBlock(terrapreta);
ModLoader.addName(terrapreta, "Terra Preta");
ModLoader.addRecipe(new ItemStack(terrapreta, 1), new Object [] {"#", Character.valueOf('#'), Block.dirt});
}
public String getVersion()
{
return "1.4.5";
}
}
and the second one:
package net.minecraft.src;
import java.util.Random;
public class Blockterra extends Block
{
public Blockterra(int i, int j)
{
super(i, j, Material.ground);
}
public int quantityDropped(Random random)
{
return 1;
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
return getBlockTextureFromSide(i);
}
public int getBlockTextureFromSide(int i)
{
if (i == 0)
{
return mod_test.terraBottom;
}
if (i == 1)
{
return mod_test.terraTop;
}
else
{
return mod_test.terraSides;
}
}
}
See the part I've highlighted? You've used ModLoader.addOverride twice on the same file. You should only ever run that method once per file because each subsequent time changes the number for that image. That's why your terraBottom int doesn't give the right image.
To fix this, change the line in red to say:
thanks :), i left that in when i first made the block because at the time it only had 1 texture image, so i decided to leave it in for fear it would crash my game if i took it out.