Wait, so how do I change an existing block? I can't put it in a mod_* because the class already exists...
Are you attempting to change a vanilla block?
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
To do that you'll need to edit Block.java or the class of the block itself. All blocks as declared as final so therefore you cannot edit them externally.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
I was fooling around with mobs today and I made my mob attack every mob except animals and npcs, but it also attacks other mobs of the same type any way around this besides adding every mob name to the entity task list.
How do I make so when you pick up something you get a achievement?
Using Forge or ModLoader?
With ModLoader there is a method in BaseMod called onItemPickup(Check the BaseMld.java for parameters, I don't remember them exactly). Then inside this overriden method create if statements that check if the itemstack's itemID that is being passed to the onItemPickup hierarchy is equivalent to the itemID of the object of your Item. Then call the instance of entityplayer passed to onItemPickup and call the addStat(YourAchievementObject, 1);
If you are using Forge you can try using the PickupNotifier handler by creating a new class that implements IPickupNotifier and use GameRegistry.registerPickupNotifier(new NameOfYourClassThatImplementsIPickupNotifier); Place the same items as in the ModLoader method above in the method that is forced to be overriden by the implemented interface, except that instead of retrieving the itemID from the itemstack, the method passes the instance of the EntityItem picked up by the player, and so you must retrieve the itemID from the EntityItem.
Sorry if there are any mistakes here, i'm writing this on my phone at work.
Currently been trying to code a custom tree into the game, and I don't know if I'm being stupid or not but I can't seem to find the tutorial on your page for it. .-. Can you please help me out? :/ I have the code and error posted below:
Here's the mod_file:
package net.minecraft.src;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class mod_KHMod extends BaseMod
{
//Paopu Tree, Fruit, and Sapling:
public static final Block PaopuSapling = new BlockPaopuSapling(9986, 15).setHardness(0.0F).setStepSound(Block.soundSandFootstep).setBlockName("Paopu Sapling").setRequiresSelfNotify();
public static final Item PaopuFruit = new ItemFood(9987, 20, 1F, false).setItemName("Paopu Fruit");
public static final Block PaopuLog = new BlockPaopuLog(9988).setHardness(2.0F).setStepSound(Block.soundWoodFootstep).setBlockName("Paopu Log").setRequiresSelfNotify();
public static final Block PaopuLeaves = new BlockPaopuLeaves(9989, 0).setHardness(0.2F).setLightOpacity(1).setStepSound(Block.soundGrassFootstep).setBlockName("Paopu Leaves").setRequiresSelfNotify();
public static int logBottom;
public static int logSide;
public void load()
{
//Paoupu Sapling:
ModLoader.registerBlock(PaopuSapling);
ModLoader.addName(PaopuSapling, "Paopu Sapling");
PaopuSapling.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/items/paopusapling.png");
//Paopu Fruit:
PaopuFruit.iconIndex = ModLoader.addOverride("/gui/items.png", "/paopu.png");
ModLoader.addName(PaopuFruit, "Paopu");
//Paopu Log:
ModLoader.registerBlock(PaopuLog);
ModLoader.addName(PaopuLog, "Paopu Logs");
logBottom = ModLoader.addOverride("/terrain.png", "/items/paopulogbottom.png");
logSide = ModLoader.addOverride("/terrain.png", "/items/paopulogside.png");
//Paopu Leaves:
ModLoader.registerBlock(PaopuLeaves);
ModLoader.addName(PaopuLeaves, "Paopu Leaves");
PaopuLeaves.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/paopuleaves.png");
}
public void generateSurface(World world, Random rand, int chunkX, int chunkZ)
{
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(chunkX, chunkZ);
WorldGenPaopuTree tree = new WorldGenPaopuTree(); //Change this to the World Gens or your tree and make sure that the parameters match if you get errors!
if(biome instanceof BiomeGenDesert)
{
for(int c = 0; c < 3; c++)
{
int Xcoord = chunkX + rand.nextInt(16);
int Zcoord = chunkZ + rand.nextInt(16);
int i = world.getHeightValue(Xcoord, Zcoord);
tree.generate(world, rand, Xcoord, i, Zcoord);
}
}
}
public String getVersion()
{
return "1.4.2";
}
}
and here's the Saplingfile:
package net.minecraft.src;
import java.util.Random;
public class BlockPaopuSapling extends BlockFlower
{
protected BlockPaopuSapling(int i, int j)
{
super(i, j);
float f = 0.4F;
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
}
protected boolean canThisPlantGrowOnThisBlockID(int i)
{
return i == Block.sand.blockID; //Makes this grow on grass.
}
public void updateTick(World world, int i, int j, int k, Random random)
{
if(world.isRemote)
{
return;
}
super.updateTick(world, i, j, k, random);
if(world.getBlockLightValue(i, j + 1, k) >= 9 && random.nextInt(7) == 0)
{
int l = world.getBlockMetadata(i, j, k);
if((l & 8) == 0)
{
world.setBlockMetadataWithNotify(i, j, k, l | 8);
} else
{
growTree(world, i, j, k, random);
}
}
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
j &= 3;
if(j == 1)
{
return blockIndexInTexture; //63
}
if(j == 2)
{
return blockIndexInTexture; //79
} else
{
return blockIndexInTexture;
}
}
public void growTree(World world, int i, int j, int k, Random random)
{
int l = world.getBlockMetadata(i, j, k) & 3;
world.setBlock(i, j, k, 0);
Object obj = null;
obj = new WorldGenPaopuTree();
if(!((WorldGenerator) (obj)).generate(world, random, i, j, k))
{
world.setBlockAndMetadata(i, j, k, blockID, l);
}
}
protected int damageDropped(int i)
{
return i & 3;
}
}
and the Log file:
package net.minecraft.src;
import java.util.Random;
public class BlockPaopuLog extends Block
{
protected BlockPaopuLog(int i)
{
super(i, Material.wood);
}
public int quantityDropped(Random random)
{
return 1;
}
public int idDropped(int i, Random random, int j)
{
return mod_KHMod.PaopuLog.blockID; //Change to your wood block
}
public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l)
{
super.harvestBlock(world, entityplayer, i, j, k, l);
}
public void onBlockRemoval(World world, int i, int j, int k)
{
byte byte0 = 4;
int l = byte0 + 1;
if(world.checkChunksExist(i - l, j - l, k - l, i + l, j + l, k + l))
{
for(int i1 = -byte0; i1 <= byte0; i1++)
{
for(int j1 = -byte0; j1 <= byte0; j1++)
{
for(int k1 = -byte0; k1 <= byte0; k1++)
{
int l1 = world.getBlockId(i + i1, j + j1, k + k1);
if(l1 != mod_KHMod.PaopuLeaves.blockID) //Change to your leaf block.
{
continue;
}
int i2 = world.getBlockMetadata(i + i1, j + j1, k + k1);
if((i2 & 8) == 0)
{
world.setBlockMetadata(i + i1, j + j1, k + k1, i2 | 8);
}
}
}
}
}
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(i == 0)
return mod_KHMod.logBottom;
if(i == 1)
return mod_KHMod.logBottom;
if(i == 2)
return mod_KHMod.logSide;
if(i == 3)
return mod_KHMod.logSide;
if(i == 4)
return mod_KHMod.logSide;
if(i == 5)
return mod_KHMod.logSide;
if(j == 1)
{
return 116;
}
return j != 2 ? 20 : 117;
}
protected int damageDropped(int i)
{
return i;
}
}
and the Leaves file:
package net.minecraft.src;
import java.util.Random;
public class BlockPaopuLeaves extends BlockLeavesBase
{
private int baseIndexInPNG;
int adjacentTreeBlocks[];
protected BlockPaopuLeaves(int i, int j)
{
super(i, j, Material.leaves, false);
setTickRandomly(true);
}
public int getBlockColor()
{
double d = 0.5D;
double d1 = 1.0D;
return 0;
}
public void onBlockRemoval(World world, int i, int j, int k)
{
int l = 1;
int i1 = l + 1;
if(world.checkChunksExist(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1))
{
for(int j1 = -l; j1 <= l; j1++)
{
for(int k1 = -l; k1 <= l; k1++)
{
for(int l1 = -l; l1 <= l; l1++)
{
int i2 = world.getBlockId(i + j1, j + k1, k + l1);
if(i2 == mod_KHMod.PaopuSapling.blockID) //Change to your sapling block.
{
int j2 = world.getBlockMetadata(i + j1, j + k1, k + l1);
world.setBlockMetadata(i + j1, j + k1, k + l1, j2 | 8);
}
}
}
}
}
}
public void updateTick(World world, int i, int j, int k, Random random)
{
if(world.isRemote)
{
return;
}
int l = world.getBlockMetadata(i, j, k);
if((l & 8) != 0 && (l & 4) == 0)
{
byte byte0 = 4;
int i1 = byte0 + 1;
byte byte1 = 32;
int j1 = byte1 * byte1;
int k1 = byte1 / 2;
if(adjacentTreeBlocks == null)
{
adjacentTreeBlocks = new int[byte1 * byte1 * byte1];
}
if(world.checkChunksExist(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1))
{
for(int l1 = -byte0; l1 <= byte0; l1++)
{
for(int k2 = -byte0; k2 <= byte0; k2++)
{
for(int i3 = -byte0; i3 <= byte0; i3++)
{
int k3 = world.getBlockId(i + l1, j + k2, k + i3);
if(k3 == mod_KHMod.PaopuLog.blockID) //Change to your wood block.
{
adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = 0;
continue;
}
if(k3 == mod_KHMod.PaopuLeaves.blockID) //Change to your leaf block.
{
adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2;
} else
{
adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1;
}
}
}
}
for(int i2 = 1; i2 <= 4; i2++)
{
for(int l2 = -byte0; l2 <= byte0; l2++)
{
for(int j3 = -byte0; j3 <= byte0; j3++)
{
for(int l3 = -byte0; l3 <= byte0; l3++)
{
if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] != i2 - 1)
{
continue;
}
if(adjacentTreeBlocks[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2)
{
adjacentTreeBlocks[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2)
{
adjacentTreeBlocks[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2)
{
adjacentTreeBlocks[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2)
{
adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2)
{
adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2)
{
adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2;
}
}
}
}
}
}
int j2 = adjacentTreeBlocks[k1 * j1 + k1 * byte1 + k1];
if(j2 >= 0)
{
world.setBlockMetadata(i, j, k, l & -9);
} else
{
removeLeaves(world, i, j, k);
}
}
}
private void removeLeaves(World world, int i, int j, int k)
{
dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
world.setBlockWithNotify(i, j, k, 0);
}
public int quantityDropped(Random random)
{
return random.nextInt(20) != 0 ? 0 : 1;
}
public int idDropped(int i, Random random, int j)
{
return mod_KHMod.PaopuSapling.blockID; //Makes your leaves drop your type of sapling.
}
public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f, int i1)
{
super.dropBlockAsItemWithChance(world, i, j, k, l, f, i1);
if (!world.isRemote && (l & 3) == 0 && world.rand.nextInt(50) == 0)
{
dropBlockAsItem_do(world, i, j, k, new ItemStack(mod_KHMod.PaopuFruit.shiftedIndex, 1, 0)); //Makes your leaf have a 1/50 chance to drop an apple.
}
}
public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l)
{
if (!world.isRemote && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex)
{
entityplayer.addStat(StatList.mineBlockStatArray[blockID], 1);
dropBlockAsItem_do(world, i, j, k, new ItemStack(Block.leaves.blockID, 1, l & 3));
}
else
{
super.harvestBlock(world, entityplayer, i, j, k, l);
}
}
protected int damageDropped(int i)
{
return i & 3;
}
public boolean isOpaqueCube()
{
return !graphicsLevel;
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if((j & 3) == 1)
{
return blockIndexInTexture;
}else{
return blockIndexInTexture;
}
}
public void setGraphicsLevel(boolean flag)
{
graphicsLevel = flag;
}
public void onEntityWalking(World world, int i, int j, int k, Entity entity)
{
super.onEntityWalking(world, i, j, k, entity);
}
}
and the WorldGen file:
package net.minecraft.src;
import java.util.Random;
public class WorldGenPaopuTree extends WorldGenerator
{
public WorldGenPaopuTree()
{
}
public boolean generate(World world, Random random, int i, int j, int k)
{
int l = random.nextInt(1) + 4;
boolean flag = true;
if(j < 1 || j + l + 1 > 256)
{
return false;
}
for(int i1 = j; i1 <= j + 1 + l; i1++)
{
byte byte0 = 1;
if(i1 == j)
{
byte0 = 0;
}
if(i1 >= (j + 1 + l) - 2)
{
byte0 = 2;
}
for(int i2 = i - byte0; i2 <= i + byte0 && flag; i2++)
{
for(int l2 = k - byte0; l2 <= k + byte0 && flag; l2++)
{
if(i1 >= 0 && i1 < 256)
{
int j3 = world.getBlockId(i2, i1, l2);
if(j3 != 0 && j3 != mod_KHMod.PaopuLeaves.blockID) //Change this to your leaf block.
{
flag = false;
}
} else
{
flag = false;
}
}
}
}
if(!flag)
{
return false;
}
int j1 = world.getBlockId(i, j - 1, k);
if(j1 != Block.sand.blockID && j1 != Block.sand.blockID || j >= 256 - l - 1) //This determines on what blocks your tree can generate.
{
return false;
}
world.setBlock(i, j - 1, k, Block.sand.blockID); //Also determines what block your tree can generate on.
for(int k1 = (j - 3) + l; k1 <= j + l; k1++)
{
int j2 = k1 - (j + l);
int i3 = 1 - j2 / 2;
for(int k3 = i - i3; k3 <= i + i3; k3++)
{
int l3 = k3 - i;
for(int i4 = k - i3; i4 <= k + i3; i4++)
{
int j4 = i4 - k;
if((Math.abs(l3) != i3 || Math.abs(j4) != i3 || random.nextInt(2) != 0 && j2 != 0) && !Block.opaqueCubeLookup[world.getBlockId(k3, k1, i4)])
{
setBlockAndMetadata(world, k3, k1, i4, mod_KHMod.PaopuLeaves.blockID, 0); //Change to your leaf block.
}
}
}
}
for(int l1 = 0; l1 < l; l1++)
{
int k2 = world.getBlockId(i, j + l1, k);
if(k2 == 0 || k2 == mod_KHMod.PaopuLeaves.blockID)
{
setBlockAndMetadata(world, i, j + l1, k, mod_KHMod.PaopuLog.blockID, 0); //Change to your wood block.
}
}
return true;
}
}
and the Error report thing:
--- BEGIN ERROR REPORT 999a3bd2 --------
Generated 11/3/12 3:51 PM
- Minecraft Version: 1.4.2
- Operating System: Windows Vista (x86) version 6.0
- Java Version: 1.7.0_09, Oracle Corporation
- Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
- Memory: 999583744 bytes (953 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
- JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
- AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
- ModLoader: Mods loaded: 1
ModLoader 1.4.2
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.minecraft.src.ModLoader.addMod(ModLoader.java:392)
at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1375)
at net.minecraft.src.ModLoader.init(ModLoader.java:946)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:187)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:91)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:14)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:417)
at net.minecraft.client.Minecraft.run(Minecraft.java:737)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 9986
at net.minecraft.src.Block.<init>(Block.java:278)
at net.minecraft.src.BlockFlower.<init>(BlockFlower.java:9)
at net.minecraft.src.BlockFlower.<init>(BlockFlower.java:19)
at net.minecraft.src.BlockPaopuSapling.<init>(BlockPaopuSapling.java:9)
at net.minecraft.src.mod_KHMod.<clinit>(mod_KHMod.java:15)
... 15 more
--- END ERROR REPORT a45a9b5d ----------
The "9986" that the error says is the id i gave to my sapling, but I can't figure out what I had done wrong. .__. any help would be greatly appreciated, as I have been at this for a while. Dx
Currently been trying to code a custom tree into the game, and I don't know if I'm being stupid or not but I can't seem to find the tutorial on your page for it. .-. Can you please help me out? :/ I have the code and error posted below:
Here's the mod_file:
package net.minecraft.src;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class mod_KHMod extends BaseMod
{
//Paopu Tree, Fruit, and Sapling:
public static final Block PaopuSapling = new BlockPaopuSapling(9986, 15).setHardness(0.0F).setStepSound(Block.soundSandFootstep).setBlockName("Paopu Sapling").setRequiresSelfNotify();
public static final Item PaopuFruit = new ItemFood(9987, 20, 1F, false).setItemName("Paopu Fruit");
public static final Block PaopuLog = new BlockPaopuLog(9988).setHardness(2.0F).setStepSound(Block.soundWoodFootstep).setBlockName("Paopu Log").setRequiresSelfNotify();
public static final Block PaopuLeaves = new BlockPaopuLeaves(9989, 0).setHardness(0.2F).setLightOpacity(1).setStepSound(Block.soundGrassFootstep).setBlockName("Paopu Leaves").setRequiresSelfNotify();
public static int logBottom;
public static int logSide;
public void load()
{
//Paoupu Sapling:
ModLoader.registerBlock(PaopuSapling);
ModLoader.addName(PaopuSapling, "Paopu Sapling");
PaopuSapling.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/items/paopusapling.png");
//Paopu Fruit:
PaopuFruit.iconIndex = ModLoader.addOverride("/gui/items.png", "/paopu.png");
ModLoader.addName(PaopuFruit, "Paopu");
//Paopu Log:
ModLoader.registerBlock(PaopuLog);
ModLoader.addName(PaopuLog, "Paopu Logs");
logBottom = ModLoader.addOverride("/terrain.png", "/items/paopulogbottom.png");
logSide = ModLoader.addOverride("/terrain.png", "/items/paopulogside.png");
//Paopu Leaves:
ModLoader.registerBlock(PaopuLeaves);
ModLoader.addName(PaopuLeaves, "Paopu Leaves");
PaopuLeaves.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/paopuleaves.png");
}
public void generateSurface(World world, Random rand, int chunkX, int chunkZ)
{
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(chunkX, chunkZ);
WorldGenPaopuTree tree = new WorldGenPaopuTree(); //Change this to the World Gens or your tree and make sure that the parameters match if you get errors!
if(biome instanceof BiomeGenDesert)
{
for(int c = 0; c < 3; c++)
{
int Xcoord = chunkX + rand.nextInt(16);
int Zcoord = chunkZ + rand.nextInt(16);
int i = world.getHeightValue(Xcoord, Zcoord);
tree.generate(world, rand, Xcoord, i, Zcoord);
}
}
}
public String getVersion()
{
return "1.4.2";
}
}
and here's the Saplingfile:
package net.minecraft.src;
import java.util.Random;
public class BlockPaopuSapling extends BlockFlower
{
protected BlockPaopuSapling(int i, int j)
{
super(i, j);
float f = 0.4F;
setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
}
protected boolean canThisPlantGrowOnThisBlockID(int i)
{
return i == Block.sand.blockID; //Makes this grow on grass.
}
public void updateTick(World world, int i, int j, int k, Random random)
{
if(world.isRemote)
{
return;
}
super.updateTick(world, i, j, k, random);
if(world.getBlockLightValue(i, j + 1, k) >= 9 && random.nextInt(7) == 0)
{
int l = world.getBlockMetadata(i, j, k);
if((l & 8) == 0)
{
world.setBlockMetadataWithNotify(i, j, k, l | 8);
} else
{
growTree(world, i, j, k, random);
}
}
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
j &= 3;
if(j == 1)
{
return blockIndexInTexture; //63
}
if(j == 2)
{
return blockIndexInTexture; //79
} else
{
return blockIndexInTexture;
}
}
public void growTree(World world, int i, int j, int k, Random random)
{
int l = world.getBlockMetadata(i, j, k) & 3;
world.setBlock(i, j, k, 0);
Object obj = null;
obj = new WorldGenPaopuTree();
if(!((WorldGenerator) (obj)).generate(world, random, i, j, k))
{
world.setBlockAndMetadata(i, j, k, blockID, l);
}
}
protected int damageDropped(int i)
{
return i & 3;
}
}
and the Log file:
package net.minecraft.src;
import java.util.Random;
public class BlockPaopuLog extends Block
{
protected BlockPaopuLog(int i)
{
super(i, Material.wood);
}
public int quantityDropped(Random random)
{
return 1;
}
public int idDropped(int i, Random random, int j)
{
return mod_KHMod.PaopuLog.blockID; //Change to your wood block
}
public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l)
{
super.harvestBlock(world, entityplayer, i, j, k, l);
}
public void onBlockRemoval(World world, int i, int j, int k)
{
byte byte0 = 4;
int l = byte0 + 1;
if(world.checkChunksExist(i - l, j - l, k - l, i + l, j + l, k + l))
{
for(int i1 = -byte0; i1 <= byte0; i1++)
{
for(int j1 = -byte0; j1 <= byte0; j1++)
{
for(int k1 = -byte0; k1 <= byte0; k1++)
{
int l1 = world.getBlockId(i + i1, j + j1, k + k1);
if(l1 != mod_KHMod.PaopuLeaves.blockID) //Change to your leaf block.
{
continue;
}
int i2 = world.getBlockMetadata(i + i1, j + j1, k + k1);
if((i2 & 8) == 0)
{
world.setBlockMetadata(i + i1, j + j1, k + k1, i2 | 8);
}
}
}
}
}
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(i == 0)
return mod_KHMod.logBottom;
if(i == 1)
return mod_KHMod.logBottom;
if(i == 2)
return mod_KHMod.logSide;
if(i == 3)
return mod_KHMod.logSide;
if(i == 4)
return mod_KHMod.logSide;
if(i == 5)
return mod_KHMod.logSide;
if(j == 1)
{
return 116;
}
return j != 2 ? 20 : 117;
}
protected int damageDropped(int i)
{
return i;
}
}
and the Leaves file:
package net.minecraft.src;
import java.util.Random;
public class BlockPaopuLeaves extends BlockLeavesBase
{
private int baseIndexInPNG;
int adjacentTreeBlocks[];
protected BlockPaopuLeaves(int i, int j)
{
super(i, j, Material.leaves, false);
setTickRandomly(true);
}
public int getBlockColor()
{
double d = 0.5D;
double d1 = 1.0D;
return 0;
}
public void onBlockRemoval(World world, int i, int j, int k)
{
int l = 1;
int i1 = l + 1;
if(world.checkChunksExist(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1))
{
for(int j1 = -l; j1 <= l; j1++)
{
for(int k1 = -l; k1 <= l; k1++)
{
for(int l1 = -l; l1 <= l; l1++)
{
int i2 = world.getBlockId(i + j1, j + k1, k + l1);
if(i2 == mod_KHMod.PaopuSapling.blockID) //Change to your sapling block.
{
int j2 = world.getBlockMetadata(i + j1, j + k1, k + l1);
world.setBlockMetadata(i + j1, j + k1, k + l1, j2 | 8);
}
}
}
}
}
}
public void updateTick(World world, int i, int j, int k, Random random)
{
if(world.isRemote)
{
return;
}
int l = world.getBlockMetadata(i, j, k);
if((l & 8) != 0 && (l & 4) == 0)
{
byte byte0 = 4;
int i1 = byte0 + 1;
byte byte1 = 32;
int j1 = byte1 * byte1;
int k1 = byte1 / 2;
if(adjacentTreeBlocks == null)
{
adjacentTreeBlocks = new int[byte1 * byte1 * byte1];
}
if(world.checkChunksExist(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1))
{
for(int l1 = -byte0; l1 <= byte0; l1++)
{
for(int k2 = -byte0; k2 <= byte0; k2++)
{
for(int i3 = -byte0; i3 <= byte0; i3++)
{
int k3 = world.getBlockId(i + l1, j + k2, k + i3);
if(k3 == mod_KHMod.PaopuLog.blockID) //Change to your wood block.
{
adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = 0;
continue;
}
if(k3 == mod_KHMod.PaopuLeaves.blockID) //Change to your leaf block.
{
adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2;
} else
{
adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1;
}
}
}
}
for(int i2 = 1; i2 <= 4; i2++)
{
for(int l2 = -byte0; l2 <= byte0; l2++)
{
for(int j3 = -byte0; j3 <= byte0; j3++)
{
for(int l3 = -byte0; l3 <= byte0; l3++)
{
if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] != i2 - 1)
{
continue;
}
if(adjacentTreeBlocks[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2)
{
adjacentTreeBlocks[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2)
{
adjacentTreeBlocks[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2)
{
adjacentTreeBlocks[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2)
{
adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2)
{
adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2;
}
if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2)
{
adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2;
}
}
}
}
}
}
int j2 = adjacentTreeBlocks[k1 * j1 + k1 * byte1 + k1];
if(j2 >= 0)
{
world.setBlockMetadata(i, j, k, l & -9);
} else
{
removeLeaves(world, i, j, k);
}
}
}
private void removeLeaves(World world, int i, int j, int k)
{
dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0);
world.setBlockWithNotify(i, j, k, 0);
}
public int quantityDropped(Random random)
{
return random.nextInt(20) != 0 ? 0 : 1;
}
public int idDropped(int i, Random random, int j)
{
return mod_KHMod.PaopuSapling.blockID; //Makes your leaves drop your type of sapling.
}
public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f, int i1)
{
super.dropBlockAsItemWithChance(world, i, j, k, l, f, i1);
if (!world.isRemote && (l & 3) == 0 && world.rand.nextInt(50) == 0)
{
dropBlockAsItem_do(world, i, j, k, new ItemStack(mod_KHMod.PaopuFruit.shiftedIndex, 1, 0)); //Makes your leaf have a 1/50 chance to drop an apple.
}
}
public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l)
{
if (!world.isRemote && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex)
{
entityplayer.addStat(StatList.mineBlockStatArray[blockID], 1);
dropBlockAsItem_do(world, i, j, k, new ItemStack(Block.leaves.blockID, 1, l & 3));
}
else
{
super.harvestBlock(world, entityplayer, i, j, k, l);
}
}
protected int damageDropped(int i)
{
return i & 3;
}
public boolean isOpaqueCube()
{
return !graphicsLevel;
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if((j & 3) == 1)
{
return blockIndexInTexture;
}else{
return blockIndexInTexture;
}
}
public void setGraphicsLevel(boolean flag)
{
graphicsLevel = flag;
}
public void onEntityWalking(World world, int i, int j, int k, Entity entity)
{
super.onEntityWalking(world, i, j, k, entity);
}
}
and the WorldGen file:
package net.minecraft.src;
import java.util.Random;
public class WorldGenPaopuTree extends WorldGenerator
{
public WorldGenPaopuTree()
{
}
public boolean generate(World world, Random random, int i, int j, int k)
{
int l = random.nextInt(1) + 4;
boolean flag = true;
if(j < 1 || j + l + 1 > 256)
{
return false;
}
for(int i1 = j; i1 <= j + 1 + l; i1++)
{
byte byte0 = 1;
if(i1 == j)
{
byte0 = 0;
}
if(i1 >= (j + 1 + l) - 2)
{
byte0 = 2;
}
for(int i2 = i - byte0; i2 <= i + byte0 && flag; i2++)
{
for(int l2 = k - byte0; l2 <= k + byte0 && flag; l2++)
{
if(i1 >= 0 && i1 < 256)
{
int j3 = world.getBlockId(i2, i1, l2);
if(j3 != 0 && j3 != mod_KHMod.PaopuLeaves.blockID) //Change this to your leaf block.
{
flag = false;
}
} else
{
flag = false;
}
}
}
}
if(!flag)
{
return false;
}
int j1 = world.getBlockId(i, j - 1, k);
if(j1 != Block.sand.blockID && j1 != Block.sand.blockID || j >= 256 - l - 1) //This determines on what blocks your tree can generate.
{
return false;
}
world.setBlock(i, j - 1, k, Block.sand.blockID); //Also determines what block your tree can generate on.
for(int k1 = (j - 3) + l; k1 <= j + l; k1++)
{
int j2 = k1 - (j + l);
int i3 = 1 - j2 / 2;
for(int k3 = i - i3; k3 <= i + i3; k3++)
{
int l3 = k3 - i;
for(int i4 = k - i3; i4 <= k + i3; i4++)
{
int j4 = i4 - k;
if((Math.abs(l3) != i3 || Math.abs(j4) != i3 || random.nextInt(2) != 0 && j2 != 0) && !Block.opaqueCubeLookup[world.getBlockId(k3, k1, i4)])
{
setBlockAndMetadata(world, k3, k1, i4, mod_KHMod.PaopuLeaves.blockID, 0); //Change to your leaf block.
}
}
}
}
for(int l1 = 0; l1 < l; l1++)
{
int k2 = world.getBlockId(i, j + l1, k);
if(k2 == 0 || k2 == mod_KHMod.PaopuLeaves.blockID)
{
setBlockAndMetadata(world, i, j + l1, k, mod_KHMod.PaopuLog.blockID, 0); //Change to your wood block.
}
}
return true;
}
}
and the Error report thing:
--- BEGIN ERROR REPORT 999a3bd2 --------
Generated 11/3/12 3:51 PM
- Minecraft Version: 1.4.2
- Operating System: Windows Vista (x86) version 6.0
- Java Version: 1.7.0_09, Oracle Corporation
- Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
- Memory: 999583744 bytes (953 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
- JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
- AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
- ModLoader: Mods loaded: 1
ModLoader 1.4.2
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.minecraft.src.ModLoader.addMod(ModLoader.java:392)
at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1375)
at net.minecraft.src.ModLoader.init(ModLoader.java:946)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:187)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:91)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:14)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:417)
at net.minecraft.client.Minecraft.run(Minecraft.java:737)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 9986
at net.minecraft.src.Block.<init>(Block.java:278)
at net.minecraft.src.BlockFlower.<init>(BlockFlower.java:9)
at net.minecraft.src.BlockFlower.<init>(BlockFlower.java:19)
at net.minecraft.src.BlockPaopuSapling.<init>(BlockPaopuSapling.java:9)
at net.minecraft.src.mod_KHMod.<clinit>(mod_KHMod.java:15)
... 15 more
--- END ERROR REPORT a45a9b5d ----------
The "9986" that the error says is the id i gave to my sapling, but I can't figure out what I had done wrong. .__. any help would be greatly appreciated, as I have been at this for a while. Dx
The error shown in your error log is simply saying that your crash is caused by an ArrayIndexOutOfBoundsExcpetion of the value 9986.
Caused by: java.lang.ArrayIndexOutOfBoundsException: 9986
This is caused by the fact that you are attempting to create a Block object with an ID larger than is available for Blocks. BlockID's may only have an ID below 4096, while your Block object creations use values around 9985-9990
This is caue
The error shown in your error log is simply saying that your crash is caused by an ArrayIndexOutOfBoundsExcpetion of the value 9986.
Causedby: java.lang.ArrayIndexOutOfBoundsException:9986 This is caused by the fact that you are attempting to create a Block object with an ID larger than is available for Blocks. BlockID's may only have an ID below 4096, while your Block object creations use values around 9985-9990
This is caue
Hmm I understand, however when changing all the ID's around to lower numbers, I still got an error with the sapling. (Now changed to 3002).
Should I make the ID even lower?
Error:
--- BEGIN ERROR REPORT 574404 --------
Generated 11/4/12 7:11 PM
- Minecraft Version: 1.4.2
- Operating System: Windows Vista (x86) version 6.0
- Java Version: 1.7.0_09, Oracle Corporation
- Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
- Memory: 999584088 bytes (953 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
- JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
- AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
- ModLoader: Mods loaded: 2
ModLoader 1.4.2
mod_KHMod 1.4.2
java.lang.ArrayIndexOutOfBoundsException: 3002
at net.minecraft.src.ModLoader.initStats(ModLoader.java:1004)
at net.minecraft.src.ModLoader.init(ModLoader.java:977)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:187)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:91)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:14)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:417)
at net.minecraft.client.Minecraft.run(Minecraft.java:737)
at java.lang.Thread.run(Unknown Source)
--- END ERROR REPORT 608c9242 ----------
Hmm I understand, however when changing all the ID's around to lower numbers, I still got an error with the sapling. (Now changed to 3002).
Should I make the ID even lower?
Error:
--- BEGIN ERROR REPORT 574404 --------
Generated 11/4/12 7:11 PM
- Minecraft Version: 1.4.2
- Operating System: Windows Vista (x86) version 6.0
- Java Version: 1.7.0_09, Oracle Corporation
- Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
- Memory: 999584088 bytes (953 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
- JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
- AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
- ModLoader: Mods loaded: 2
ModLoader 1.4.2
mod_KHMod 1.4.2
java.lang.ArrayIndexOutOfBoundsException: 3002
at net.minecraft.src.ModLoader.initStats(ModLoader.java:1004)
at net.minecraft.src.ModLoader.init(ModLoader.java:977)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:187)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:91)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:14)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:417)
at net.minecraft.client.Minecraft.run(Minecraft.java:737)
at java.lang.Thread.run(Unknown Source)
--- END ERROR REPORT 608c9242 ----------
Have ID's still not been brought up to 4096? I wouldn't know since I only use Forge, and that has had a 4096 Block ID resolver for a few versions. Try setting the Block ID's below 256
Have ID's still not been brought up to 4096? I wouldn't know since I only use Forge, and that has had a 4096 Block ID resolver for a few versions. Try setting the Block ID's below 256
I had tried it (I'm using ModLoader) and it still had crashed with anything in the thousands, but I did some trial-and-error and found ones that fit, works perfectly now thanks for the help!
Please help, my block mod won't work and I'm not sure why because there is no errors in the code and I think the textures are fine
here are the files
mod_***
package net.minecraft.src;
public class mod_Blackstone extends BaseMod
{
public static final Block Blackstone = new BlockBlackstone(160, 0).setBlockName("Blackstone").setHardness(3F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep);
public static final Block Greenstone = new BlockGreenstone(161, 0).setBlockName("Greenstone").setHardness(3F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep);
public static final Block Bluestone = new BlockBluestone(162, 0).setBlockName("Bluestone").setHardness(3F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep);
public void load()
{
Blackstone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modtextures/blackstone.png");
ModLoader.registerBlock(Blackstone);
ModLoader.addName(Blackstone, "Blackstone");
ModLoader.addRecipe(new ItemStack(Blackstone, 4), new Object [] {"@#@", "#@#", "@#@", Character.valueOf('#'), Block.stone, Character.valueOf('@'), Item.coal});
Greenstone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modtextures/greenstone.png");
ModLoader.registerBlock(Greenstone);
ModLoader.addName(Greenstone, "Greenstone");
ModLoader.addRecipe(new ItemStack(Greenstone, 8), new Object [] {"###", "#@#", "###", Character.valueOf('#'), Block.stone, Character.valueOf('@'), Item.dyePowder, 1, 2});
Bluestone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modtextures/bluestone.png");
ModLoader.registerBlock(Bluestone);
ModLoader.addName(Bluestone, "Bluestone");
ModLoader.addRecipe(new ItemStack(Bluestone, 8), new Object [] {"###", "#@#", "###", Character.valueOf('#'), Block.stone, Character.valueOf('@'), Item.dyePowder, 1, 4});
}
public String getVersion()
{
return "1.4.2";
}
}
BlockBlackstone
package net.minecraft.src;
import java.util.Random;
public class BlockBlackstone extends Block
{
public BlockBlackstone(int par1, int par2)
{
super(par1, par2, Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_Blackstone.Blackstone.blockID;
}
}
BlockGreenstone
package net.minecraft.src;
import java.util.Random;
public class BlockGreenstone extends Block
{
public BlockGreenstone(int par1, int par2)
{
super(par1, par2, Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_Blackstone.Greenstone.blockID;
}
}
BlockBluestone
package net.minecraft.src;
import java.util.Random;
public class BlockBluestone extends Block
{
public BlockBluestone(int par1, int par2)
{
super(par1, par2, Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_Blackstone.Bluestone.blockID;
}
}
Please help, my block mod won't work and I'm not sure why because there is no errors in the code and I think the textures are fine
here are the files
mod_***
package net.minecraft.src;
public class mod_Blackstone extends BaseMod
{
public static final Block Blackstone = new BlockBlackstone(160, 0).setBlockName("Blackstone").setHardness(3F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep);
public static final Block Greenstone = new BlockGreenstone(161, 0).setBlockName("Greenstone").setHardness(3F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep);
public static final Block Bluestone = new BlockBluestone(162, 0).setBlockName("Bluestone").setHardness(3F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep);
public void load()
{
Blackstone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modtextures/blackstone.png");
ModLoader.registerBlock(Blackstone);
ModLoader.addName(Blackstone, "Blackstone");
ModLoader.addRecipe(new ItemStack(Blackstone, 4), new Object [] {"@#@", "#@#", "@#@", Character.valueOf('#'), Block.stone, Character.valueOf('@'), Item.coal});
Greenstone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modtextures/greenstone.png");
ModLoader.registerBlock(Greenstone);
ModLoader.addName(Greenstone, "Greenstone");
ModLoader.addRecipe(new ItemStack(Greenstone, 8), new Object [] {"###", "#@#", "###", Character.valueOf('#'), Block.stone, Character.valueOf('@'), Item.dyePowder, 1, 2});
Bluestone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modtextures/bluestone.png");
ModLoader.registerBlock(Bluestone);
ModLoader.addName(Bluestone, "Bluestone");
ModLoader.addRecipe(new ItemStack(Bluestone, 8), new Object [] {"###", "#@#", "###", Character.valueOf('#'), Block.stone, Character.valueOf('@'), Item.dyePowder, 1, 4});
}
public String getVersion()
{
return "1.4.2";
}
}
BlockBlackstone
package net.minecraft.src;
import java.util.Random;
public class BlockBlackstone extends Block
{
public BlockBlackstone(int par1, int par2)
{
super(par1, par2, Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_Blackstone.Blackstone.blockID;
}
}
BlockGreenstone
package net.minecraft.src;
import java.util.Random;
public class BlockGreenstone extends Block
{
public BlockGreenstone(int par1, int par2)
{
super(par1, par2, Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_Blackstone.Greenstone.blockID;
}
}
BlockBluestone
package net.minecraft.src;
import java.util.Random;
public class BlockBluestone extends Block
{
public BlockBluestone(int par1, int par2)
{
super(par1, par2, Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public int idDropped(int par1, Random par2Random, int par3)
{
return mod_Blackstone.Bluestone.blockID;
}
}
Pleease help
What isn't working about it?
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
Can someone please tell me how to add special AI and abilities to a mob? Like, by giving me a sample of the right code? I can't use MCP because I can't get it t work, so I can't decompile and simply look in the source files. I can't recompile either.
Hello, I have followed your guides and a few others but it seems my mod isn't working, I try to recompile it and it won't let me. please have a look and let me know what I did wrong thank you.
mod_BlockMarble.java
package net.minecraft.src;
public class mod_BlockMarble extends BaseMod
{
public static final Block Marble = new BlockMarble(550, 1)).setHardness(1.5F).setResistance(10.0F).setStepSound(Block.soundStoneFootstep).setBlockName("Marble");
public mod_BlockMarble()
{
ModLoader.registerBlock(Marble);
ModLoader.addName(Marble, "Marble");
Marble.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/CustomTexture/Marble.png");
}
public String getVersion()
{
return "1.4.1";
}
}
BlockMarble.java
package net.minecraft.src;
import java.util.Random;
public class BlockMarble extends Block
{
public BlockMarble(int par1, int par2)
{
super(par1, par2, Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return blockID;
}
}
the issue is, in Eclipse there is a red underline underneath "mod_BlockMarble" in "public class mod_BlockMarble extends BaseMod" part of the mod, then when I try to compile again it says the following
Recompile message:
src\minecraft\net\minecraft\src\mod_BlockMarble.java:3: error: mod_BlockMarble is not abstract and does not override abstract method load() in BaseMod public class mod_BlockMarble extends BaseMod
Hello, I have followed your guides and a few others but it seems my mod isn't working, I try to recompile it and it won't let me. please have a look and let me know what I did wrong thank you.
mod_BlockMarble.java
package net.minecraft.src;
public class mod_BlockMarble extends BaseMod
{
public static final Block Marble = new BlockMarble(550, 1)).setHardness(1.5F).setResistance(10.0F).setStepSound(Block.soundStoneFootstep).setBlockName("Marble");
public mod_BlockMarble()
{
ModLoader.registerBlock(Marble);
ModLoader.addName(Marble, "Marble");
Marble.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/CustomTexture/Marble.png");
}
public String getVersion()
{
return "1.4.1";
}
}
BlockMarble.java
package net.minecraft.src;
import java.util.Random;
public class BlockMarble extends Block
{
public BlockMarble(int par1, int par2)
{
super(par1, par2, Material.rock);
this.setCreativeTab(CreativeTabs.tabBlock);
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return blockID;
}
}
the issue is, in Eclipse there is a red underline underneath "mod_BlockMarble" in "public class mod_BlockMarble extends BaseMod" part of the mod, then when I try to compile again it says the following
Recompile message:
src\minecraft\net\minecraft\src\mod_BlockMarble.java:3: error: mod_BlockMarble is not abstract and does not override abstract method load() in BaseMod public class mod_BlockMarble extends BaseMod
Could someone please help.
If you followed my tutorials and read through them properly, you wouldn't get that error.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
If you followed my tutorials and read through them properly, you wouldn't get that error.
I have Redone the Code to your Guide
mod_Block.java
package net.minecraft.src;
public class mod_Block extends BaseMod
{
public static final Block Marble = new BlockMarble(160, 0).setBlockName("Stone").setHardness(3F).setResistance(4F).setLightValue(1F)
.setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep);
public void load()
{
Marble.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/mods/marble.png");
ModLoader.registerBlock(Marble);
ModLoader.addName(Marble, "Marble");
}
public String getVersion()
{
return "1.4.2";
}
}
BlockMarble.java
package net.minecraft.src;
import java.util.Random;
public class BlockMarble extends Block
{
public BlockMarble(int i, int j)
{
super(i, j, Material.wood);
}
public int idDropped(int i, Random random, int j)
{
return mod_Block.Marble.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}
}
and now my problem is that it says it can not find the image,
here is the directory to were my image is placed: mcp\eclipse\Client\bin\mods\marble.png
Here is the crash error:
---- Minecraft Crash Report ----
// I blame Dinnerbone.
Time: 6/11/12 10:40 AM
Description: Unexpected error
java.lang.RuntimeException: java.lang.Exception: Image not found: /mods/marble.png
at net.minecraft.src.ModLoader.registerAllTextureOverrides(ModLoader.java:1638)
at net.minecraft.src.ModLoader.onTick(ModLoader.java:1194)
at net.minecraft.src.EntityRendererProxy.updateCameraAndRender(EntityRendererProxy.java:21)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:868)
at net.minecraft.client.Minecraft.run(Minecraft.java:764)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.Exception: Image not found: /mods/marble.png
at net.minecraft.src.ModLoader.loadImage(ModLoader.java:1111)
at net.minecraft.src.ModLoader.registerAllTextureOverrides(ModLoader.java:1630)
... 5 more
Relevant Details:
- Minecraft Version: 1.4.2
- Operating System: Windows 7 (amd64) version 6.1
- Java Version: 1.7.0_09, Oracle Corporation
- Java VM Version: Java HotSpot™ 64-Bit Server VM (mixed mode), Oracle Corporation
- Memory: 903735800 bytes (861 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
- JVM Flags: 3 total; -Xincgc -Xms1024M -Xmx1024M
- AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
- ModLoader: Mods loaded: 2
ModLoader 1.4.2
mod_Block 1.4.2
- LWJGL: 2.4.2
- OpenGL: GeForce GTX 560 Ti/PCIe/SSE2 GL version 4.2.0, NVIDIA Corporation
- Is Modded: Very likely
- Type: Client
- Texture Pack: Default
- Profiler Position: N/A (disabled)
- Vec3 Pool Size: ~ERROR~ NullPointerException: null
Are you attempting to change a vanilla block?
together they are powerful beyond imagination."
Precisely.
To do that you'll need to edit Block.java or the class of the block itself. All blocks as declared as final so therefore you cannot edit them externally.
together they are powerful beyond imagination."
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThanks for linking to my Tutorial on the Minecraft Forge wiki
Also, how do I make a mob attack with arrows?
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumUsing Forge or ModLoader?
With ModLoader there is a method in BaseMod called onItemPickup(Check the BaseMld.java for parameters, I don't remember them exactly). Then inside this overriden method create if statements that check if the itemstack's itemID that is being passed to the onItemPickup hierarchy is equivalent to the itemID of the object of your Item. Then call the instance of entityplayer passed to onItemPickup and call the addStat(YourAchievementObject, 1);
If you are using Forge you can try using the PickupNotifier handler by creating a new class that implements IPickupNotifier and use GameRegistry.registerPickupNotifier(new NameOfYourClassThatImplementsIPickupNotifier); Place the same items as in the ModLoader method above in the method that is forced to be overriden by the implemented interface, except that instead of retrieving the itemID from the itemstack, the method passes the instance of the EntityItem picked up by the player, and so you must retrieve the itemID from the EntityItem.
Sorry if there are any mistakes here, i'm writing this on my phone at work.
Here's the mod_file:
package net.minecraft.src; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Random; public class mod_KHMod extends BaseMod { //Paopu Tree, Fruit, and Sapling: public static final Block PaopuSapling = new BlockPaopuSapling(9986, 15).setHardness(0.0F).setStepSound(Block.soundSandFootstep).setBlockName("Paopu Sapling").setRequiresSelfNotify(); public static final Item PaopuFruit = new ItemFood(9987, 20, 1F, false).setItemName("Paopu Fruit"); public static final Block PaopuLog = new BlockPaopuLog(9988).setHardness(2.0F).setStepSound(Block.soundWoodFootstep).setBlockName("Paopu Log").setRequiresSelfNotify(); public static final Block PaopuLeaves = new BlockPaopuLeaves(9989, 0).setHardness(0.2F).setLightOpacity(1).setStepSound(Block.soundGrassFootstep).setBlockName("Paopu Leaves").setRequiresSelfNotify(); public static int logBottom; public static int logSide; public void load() { //Paoupu Sapling: ModLoader.registerBlock(PaopuSapling); ModLoader.addName(PaopuSapling, "Paopu Sapling"); PaopuSapling.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/items/paopusapling.png"); //Paopu Fruit: PaopuFruit.iconIndex = ModLoader.addOverride("/gui/items.png", "/paopu.png"); ModLoader.addName(PaopuFruit, "Paopu"); //Paopu Log: ModLoader.registerBlock(PaopuLog); ModLoader.addName(PaopuLog, "Paopu Logs"); logBottom = ModLoader.addOverride("/terrain.png", "/items/paopulogbottom.png"); logSide = ModLoader.addOverride("/terrain.png", "/items/paopulogside.png"); //Paopu Leaves: ModLoader.registerBlock(PaopuLeaves); ModLoader.addName(PaopuLeaves, "Paopu Leaves"); PaopuLeaves.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/paopuleaves.png"); } public void generateSurface(World world, Random rand, int chunkX, int chunkZ) { BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(chunkX, chunkZ); WorldGenPaopuTree tree = new WorldGenPaopuTree(); //Change this to the World Gens or your tree and make sure that the parameters match if you get errors! if(biome instanceof BiomeGenDesert) { for(int c = 0; c < 3; c++) { int Xcoord = chunkX + rand.nextInt(16); int Zcoord = chunkZ + rand.nextInt(16); int i = world.getHeightValue(Xcoord, Zcoord); tree.generate(world, rand, Xcoord, i, Zcoord); } } } public String getVersion() { return "1.4.2"; } }and here's the Sapling file:
package net.minecraft.src; import java.util.Random; public class BlockPaopuSapling extends BlockFlower { protected BlockPaopuSapling(int i, int j) { super(i, j); float f = 0.4F; setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); } protected boolean canThisPlantGrowOnThisBlockID(int i) { return i == Block.sand.blockID; //Makes this grow on grass. } public void updateTick(World world, int i, int j, int k, Random random) { if(world.isRemote) { return; } super.updateTick(world, i, j, k, random); if(world.getBlockLightValue(i, j + 1, k) >= 9 && random.nextInt(7) == 0) { int l = world.getBlockMetadata(i, j, k); if((l & 8) == 0) { world.setBlockMetadataWithNotify(i, j, k, l | 8); } else { growTree(world, i, j, k, random); } } } public int getBlockTextureFromSideAndMetadata(int i, int j) { j &= 3; if(j == 1) { return blockIndexInTexture; //63 } if(j == 2) { return blockIndexInTexture; //79 } else { return blockIndexInTexture; } } public void growTree(World world, int i, int j, int k, Random random) { int l = world.getBlockMetadata(i, j, k) & 3; world.setBlock(i, j, k, 0); Object obj = null; obj = new WorldGenPaopuTree(); if(!((WorldGenerator) (obj)).generate(world, random, i, j, k)) { world.setBlockAndMetadata(i, j, k, blockID, l); } } protected int damageDropped(int i) { return i & 3; } }and the Log file:
package net.minecraft.src; import java.util.Random; public class BlockPaopuLog extends Block { protected BlockPaopuLog(int i) { super(i, Material.wood); } public int quantityDropped(Random random) { return 1; } public int idDropped(int i, Random random, int j) { return mod_KHMod.PaopuLog.blockID; //Change to your wood block } public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) { super.harvestBlock(world, entityplayer, i, j, k, l); } public void onBlockRemoval(World world, int i, int j, int k) { byte byte0 = 4; int l = byte0 + 1; if(world.checkChunksExist(i - l, j - l, k - l, i + l, j + l, k + l)) { for(int i1 = -byte0; i1 <= byte0; i1++) { for(int j1 = -byte0; j1 <= byte0; j1++) { for(int k1 = -byte0; k1 <= byte0; k1++) { int l1 = world.getBlockId(i + i1, j + j1, k + k1); if(l1 != mod_KHMod.PaopuLeaves.blockID) //Change to your leaf block. { continue; } int i2 = world.getBlockMetadata(i + i1, j + j1, k + k1); if((i2 & 8) == 0) { world.setBlockMetadata(i + i1, j + j1, k + k1, i2 | 8); } } } } } } public int getBlockTextureFromSideAndMetadata(int i, int j) { if(i == 0) return mod_KHMod.logBottom; if(i == 1) return mod_KHMod.logBottom; if(i == 2) return mod_KHMod.logSide; if(i == 3) return mod_KHMod.logSide; if(i == 4) return mod_KHMod.logSide; if(i == 5) return mod_KHMod.logSide; if(j == 1) { return 116; } return j != 2 ? 20 : 117; } protected int damageDropped(int i) { return i; } }and the Leaves file:
package net.minecraft.src; import java.util.Random; public class BlockPaopuLeaves extends BlockLeavesBase { private int baseIndexInPNG; int adjacentTreeBlocks[]; protected BlockPaopuLeaves(int i, int j) { super(i, j, Material.leaves, false); setTickRandomly(true); } public int getBlockColor() { double d = 0.5D; double d1 = 1.0D; return 0; } public void onBlockRemoval(World world, int i, int j, int k) { int l = 1; int i1 = l + 1; if(world.checkChunksExist(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) { for(int j1 = -l; j1 <= l; j1++) { for(int k1 = -l; k1 <= l; k1++) { for(int l1 = -l; l1 <= l; l1++) { int i2 = world.getBlockId(i + j1, j + k1, k + l1); if(i2 == mod_KHMod.PaopuSapling.blockID) //Change to your sapling block. { int j2 = world.getBlockMetadata(i + j1, j + k1, k + l1); world.setBlockMetadata(i + j1, j + k1, k + l1, j2 | 8); } } } } } } public void updateTick(World world, int i, int j, int k, Random random) { if(world.isRemote) { return; } int l = world.getBlockMetadata(i, j, k); if((l & 8) != 0 && (l & 4) == 0) { byte byte0 = 4; int i1 = byte0 + 1; byte byte1 = 32; int j1 = byte1 * byte1; int k1 = byte1 / 2; if(adjacentTreeBlocks == null) { adjacentTreeBlocks = new int[byte1 * byte1 * byte1]; } if(world.checkChunksExist(i - i1, j - i1, k - i1, i + i1, j + i1, k + i1)) { for(int l1 = -byte0; l1 <= byte0; l1++) { for(int k2 = -byte0; k2 <= byte0; k2++) { for(int i3 = -byte0; i3 <= byte0; i3++) { int k3 = world.getBlockId(i + l1, j + k2, k + i3); if(k3 == mod_KHMod.PaopuLog.blockID) //Change to your wood block. { adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = 0; continue; } if(k3 == mod_KHMod.PaopuLeaves.blockID) //Change to your leaf block. { adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -2; } else { adjacentTreeBlocks[(l1 + k1) * j1 + (k2 + k1) * byte1 + (i3 + k1)] = -1; } } } } for(int i2 = 1; i2 <= 4; i2++) { for(int l2 = -byte0; l2 <= byte0; l2++) { for(int j3 = -byte0; j3 <= byte0; j3++) { for(int l3 = -byte0; l3 <= byte0; l3++) { if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] != i2 - 1) { continue; } if(adjacentTreeBlocks[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) { adjacentTreeBlocks[((l2 + k1) - 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2; } if(adjacentTreeBlocks[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] == -2) { adjacentTreeBlocks[(l2 + k1 + 1) * j1 + (j3 + k1) * byte1 + (l3 + k1)] = i2; } if(adjacentTreeBlocks[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] == -2) { adjacentTreeBlocks[(l2 + k1) * j1 + ((j3 + k1) - 1) * byte1 + (l3 + k1)] = i2; } if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] == -2) { adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1 + 1) * byte1 + (l3 + k1)] = i2; } if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] == -2) { adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + ((l3 + k1) - 1)] = i2; } if(adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] == -2) { adjacentTreeBlocks[(l2 + k1) * j1 + (j3 + k1) * byte1 + (l3 + k1 + 1)] = i2; } } } } } } int j2 = adjacentTreeBlocks[k1 * j1 + k1 * byte1 + k1]; if(j2 >= 0) { world.setBlockMetadata(i, j, k, l & -9); } else { removeLeaves(world, i, j, k); } } } private void removeLeaves(World world, int i, int j, int k) { dropBlockAsItem(world, i, j, k, world.getBlockMetadata(i, j, k), 0); world.setBlockWithNotify(i, j, k, 0); } public int quantityDropped(Random random) { return random.nextInt(20) != 0 ? 0 : 1; } public int idDropped(int i, Random random, int j) { return mod_KHMod.PaopuSapling.blockID; //Makes your leaves drop your type of sapling. } public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f, int i1) { super.dropBlockAsItemWithChance(world, i, j, k, l, f, i1); if (!world.isRemote && (l & 3) == 0 && world.rand.nextInt(50) == 0) { dropBlockAsItem_do(world, i, j, k, new ItemStack(mod_KHMod.PaopuFruit.shiftedIndex, 1, 0)); //Makes your leaf have a 1/50 chance to drop an apple. } } public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) { if (!world.isRemote && entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == Item.shears.shiftedIndex) { entityplayer.addStat(StatList.mineBlockStatArray[blockID], 1); dropBlockAsItem_do(world, i, j, k, new ItemStack(Block.leaves.blockID, 1, l & 3)); } else { super.harvestBlock(world, entityplayer, i, j, k, l); } } protected int damageDropped(int i) { return i & 3; } public boolean isOpaqueCube() { return !graphicsLevel; } public int getBlockTextureFromSideAndMetadata(int i, int j) { if((j & 3) == 1) { return blockIndexInTexture; }else{ return blockIndexInTexture; } } public void setGraphicsLevel(boolean flag) { graphicsLevel = flag; } public void onEntityWalking(World world, int i, int j, int k, Entity entity) { super.onEntityWalking(world, i, j, k, entity); } }and the WorldGen file:
package net.minecraft.src; import java.util.Random; public class WorldGenPaopuTree extends WorldGenerator { public WorldGenPaopuTree() { } public boolean generate(World world, Random random, int i, int j, int k) { int l = random.nextInt(1) + 4; boolean flag = true; if(j < 1 || j + l + 1 > 256) { return false; } for(int i1 = j; i1 <= j + 1 + l; i1++) { byte byte0 = 1; if(i1 == j) { byte0 = 0; } if(i1 >= (j + 1 + l) - 2) { byte0 = 2; } for(int i2 = i - byte0; i2 <= i + byte0 && flag; i2++) { for(int l2 = k - byte0; l2 <= k + byte0 && flag; l2++) { if(i1 >= 0 && i1 < 256) { int j3 = world.getBlockId(i2, i1, l2); if(j3 != 0 && j3 != mod_KHMod.PaopuLeaves.blockID) //Change this to your leaf block. { flag = false; } } else { flag = false; } } } } if(!flag) { return false; } int j1 = world.getBlockId(i, j - 1, k); if(j1 != Block.sand.blockID && j1 != Block.sand.blockID || j >= 256 - l - 1) //This determines on what blocks your tree can generate. { return false; } world.setBlock(i, j - 1, k, Block.sand.blockID); //Also determines what block your tree can generate on. for(int k1 = (j - 3) + l; k1 <= j + l; k1++) { int j2 = k1 - (j + l); int i3 = 1 - j2 / 2; for(int k3 = i - i3; k3 <= i + i3; k3++) { int l3 = k3 - i; for(int i4 = k - i3; i4 <= k + i3; i4++) { int j4 = i4 - k; if((Math.abs(l3) != i3 || Math.abs(j4) != i3 || random.nextInt(2) != 0 && j2 != 0) && !Block.opaqueCubeLookup[world.getBlockId(k3, k1, i4)]) { setBlockAndMetadata(world, k3, k1, i4, mod_KHMod.PaopuLeaves.blockID, 0); //Change to your leaf block. } } } } for(int l1 = 0; l1 < l; l1++) { int k2 = world.getBlockId(i, j + l1, k); if(k2 == 0 || k2 == mod_KHMod.PaopuLeaves.blockID) { setBlockAndMetadata(world, i, j + l1, k, mod_KHMod.PaopuLog.blockID, 0); //Change to your wood block. } } return true; } }and the Error report thing:
The "9986" that the error says is the id i gave to my sapling, but I can't figure out what I had done wrong. .__. any help would be greatly appreciated, as I have been at this for a while. Dx
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumThe error shown in your error log is simply saying that your crash is caused by an ArrayIndexOutOfBoundsExcpetion of the value 9986.
Caused by: java.lang.ArrayIndexOutOfBoundsException: 9986
This is caused by the fact that you are attempting to create a Block object with an ID larger than is available for Blocks. BlockID's may only have an ID below 4096, while your Block object creations use values around 9985-9990
This is caue
Hmm I understand, however when changing all the ID's around to lower numbers, I still got an error with the sapling. (Now changed to 3002).
Should I make the ID even lower?
Error:
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumHave ID's still not been brought up to 4096? I wouldn't know since I only use Forge, and that has had a 4096 Block ID resolver for a few versions. Try setting the Block ID's below 256
I had tried it (I'm using ModLoader) and it still had crashed with anything in the thousands, but I did some trial-and-error and found ones that fit, works perfectly now thanks for the help!
here are the files
mod_***
package net.minecraft.src; public class mod_Blackstone extends BaseMod { public static final Block Blackstone = new BlockBlackstone(160, 0).setBlockName("Blackstone").setHardness(3F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep); public static final Block Greenstone = new BlockGreenstone(161, 0).setBlockName("Greenstone").setHardness(3F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep); public static final Block Bluestone = new BlockBluestone(162, 0).setBlockName("Bluestone").setHardness(3F).setResistance(4F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep); public void load() { Blackstone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modtextures/blackstone.png"); ModLoader.registerBlock(Blackstone); ModLoader.addName(Blackstone, "Blackstone"); ModLoader.addRecipe(new ItemStack(Blackstone, 4), new Object [] {"@#@", "#@#", "@#@", Character.valueOf('#'), Block.stone, Character.valueOf('@'), Item.coal}); Greenstone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modtextures/greenstone.png"); ModLoader.registerBlock(Greenstone); ModLoader.addName(Greenstone, "Greenstone"); ModLoader.addRecipe(new ItemStack(Greenstone, 8), new Object [] {"###", "#@#", "###", Character.valueOf('#'), Block.stone, Character.valueOf('@'), Item.dyePowder, 1, 2}); Bluestone.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/modtextures/bluestone.png"); ModLoader.registerBlock(Bluestone); ModLoader.addName(Bluestone, "Bluestone"); ModLoader.addRecipe(new ItemStack(Bluestone, 8), new Object [] {"###", "#@#", "###", Character.valueOf('#'), Block.stone, Character.valueOf('@'), Item.dyePowder, 1, 4}); } public String getVersion() { return "1.4.2"; } }BlockBlackstone
package net.minecraft.src; import java.util.Random; public class BlockBlackstone extends Block { public BlockBlackstone(int par1, int par2) { super(par1, par2, Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); } public int idDropped(int par1, Random par2Random, int par3) { return mod_Blackstone.Blackstone.blockID; } }package net.minecraft.src; import java.util.Random; public class BlockGreenstone extends Block { public BlockGreenstone(int par1, int par2) { super(par1, par2, Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); } public int idDropped(int par1, Random par2Random, int par3) { return mod_Blackstone.Greenstone.blockID; } }package net.minecraft.src; import java.util.Random; public class BlockBluestone extends Block { public BlockBluestone(int par1, int par2) { super(par1, par2, Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); } public int idDropped(int par1, Random par2Random, int par3) { return mod_Blackstone.Bluestone.blockID; } }Pleease help
What isn't working about it?
together they are powerful beyond imagination."
mod_BlockMarble.java
package net.minecraft.src; public class mod_BlockMarble extends BaseMod { public static final Block Marble = new BlockMarble(550, 1)).setHardness(1.5F).setResistance(10.0F).setStepSound(Block.soundStoneFootstep).setBlockName("Marble"); public mod_BlockMarble() { ModLoader.registerBlock(Marble); ModLoader.addName(Marble, "Marble"); Marble.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/CustomTexture/Marble.png"); } public String getVersion() { return "1.4.1"; } }package net.minecraft.src; import java.util.Random; public class BlockMarble extends Block { public BlockMarble(int par1, int par2) { super(par1, par2, Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); } /** * Returns the ID of the items to drop on destruction. */ public int idDropped(int par1, Random par2Random, int par3) { return blockID; } }the issue is, in Eclipse there is a red underline underneath "mod_BlockMarble" in "public class mod_BlockMarble extends BaseMod" part of the mod, then when I try to compile again it says the following
Recompile message:
Could someone please help.
If you followed my tutorials and read through them properly, you wouldn't get that error.
together they are powerful beyond imagination."
I have Redone the Code to your Guide
mod_Block.java
package net.minecraft.src; public class mod_Block extends BaseMod { public static final Block Marble = new BlockMarble(160, 0).setBlockName("Stone").setHardness(3F).setResistance(4F).setLightValue(1F) .setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundStoneFootstep); public void load() { Marble.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/mods/marble.png"); ModLoader.registerBlock(Marble); ModLoader.addName(Marble, "Marble"); } public String getVersion() { return "1.4.2"; } }package net.minecraft.src; import java.util.Random; public class BlockMarble extends Block { public BlockMarble(int i, int j) { super(i, j, Material.wood); } public int idDropped(int i, Random random, int j) { return mod_Block.Marble.blockID; } public int quantityDropped(Random random) { return 1; } }and now my problem is that it says it can not find the image,
here is the directory to were my image is placed:
mcp\eclipse\Client\bin\mods\marble.png
Here is the crash error:
---- Minecraft Crash Report ----
// I blame Dinnerbone.
Time: 6/11/12 10:40 AM
Description: Unexpected error
java.lang.RuntimeException: java.lang.Exception: Image not found: /mods/marble.png
at net.minecraft.src.ModLoader.registerAllTextureOverrides(ModLoader.java:1638)
at net.minecraft.src.ModLoader.onTick(ModLoader.java:1194)
at net.minecraft.src.EntityRendererProxy.updateCameraAndRender(EntityRendererProxy.java:21)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:868)
at net.minecraft.client.Minecraft.run(Minecraft.java:764)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.Exception: Image not found: /mods/marble.png
at net.minecraft.src.ModLoader.loadImage(ModLoader.java:1111)
at net.minecraft.src.ModLoader.registerAllTextureOverrides(ModLoader.java:1630)
... 5 more
Relevant Details:
- Minecraft Version: 1.4.2
- Operating System: Windows 7 (amd64) version 6.1
- Java Version: 1.7.0_09, Oracle Corporation
- Java VM Version: Java HotSpot™ 64-Bit Server VM (mixed mode), Oracle Corporation
- Memory: 903735800 bytes (861 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
- JVM Flags: 3 total; -Xincgc -Xms1024M -Xmx1024M
- AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
- ModLoader: Mods loaded: 2
ModLoader 1.4.2
mod_Block 1.4.2
- LWJGL: 2.4.2
- OpenGL: GeForce GTX 560 Ti/PCIe/SSE2 GL version 4.2.0, NVIDIA Corporation
- Is Modded: Very likely
- Type: Client
- Texture Pack: Default
- Profiler Position: N/A (disabled)
- Vec3 Pool Size: ~ERROR~ NullPointerException: null