java.lang.ArrayIndexOutOfBoundsException: 310
at ModLoader.initStats(ModLoader.java:926)
at ModLoader.init(ModLoader.java:910)
at ModLoader.addAllRenderers(ModLoader.java:189)
at ahu.<init>(ahu.java:77)
at ahu.<clinit>(ahu.java:8)
at net.minecraft.client.Minecraft.a(SourceFile:273)
at net.minecraft.client.Minecraft.run(SourceFile:657)
at java.lang.Thread.run(Thread.java:680)
This is the code:
mod_Gardening
package net.minecraft.src;
public class mod_Gardening extends BaseMod{
public static final Block sprinkeler = (new BlockSprinkeler(310, 0)).setHardness(0.5F).setStepSound(Block.soundGravelFootstep).setBlockName("sprinkeler");
public static final Material sprinkelerMat;
static{
sprinkelerMat = new Material(MapColor.dirtColor);
}
public mod_Gardening(){
ModLoader.addName(sprinkeler, "Sprinkeler");
ModLoader.registerBlock(sprinkeler);
ModLoader.addShapelessRecipe(new ItemStack(sprinkeler), new Object[] {Block.dirt});
}
@Override
public String getVersion() {
return "1.2.5";
}
@Override
public void load() {
}
}
BlockSprinkeler
package net.minecraft.src;
import java.util.Random;
public class BlockSprinkeler extends Block
{
protected BlockSprinkeler(int par1, int par2)
{
super(par1, par2, mod_Gardening.sprinkelerMat);
setTickRandomly(true);
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int i)
{
return null;
}
/**
* Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return 2;
}
/**
* Gets if we can place a torch on a block.
*/
private boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4)
{
int i = par1World.getBlockId(par2, par3, par4);
if (i == Block.grass.blockID || i == Block.dirt.blockID)
{
return true;
}
else{
return false;
}
}
/**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
if (par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true))
{
return true;
}
if (par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true))
{
return true;
}
if (par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true))
{
return true;
}
if (par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true))
{
return true;
}
return canPlaceTorchOn(par1World, par2, par3 - 1, par4);
}
/**
* Called when a block is placed using an item. Used often for taking the facing and figuring out how to position
* the item. Args: x, y, z, facing
*/
public void onBlockPlaced(World par1World, int par2, int par3, int par4, int par5)
{
int i = par1World.getBlockMetadata(par2, par3, par4);
if (par5 == 1 && canPlaceTorchOn(par1World, par2, par3 - 1, par4))
{
i = 5;
}
if (par5 == 2 && par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true))
{
i = 4;
}
if (par5 == 3 && par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true))
{
i = 3;
}
if (par5 == 4 && par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true))
{
i = 2;
}
if (par5 == 5 && par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true))
{
i = 1;
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, i);
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.updateTick(par1World, par2, par3, par4, par5Random);
if (par1World.getBlockMetadata(par2, par3, par4) == 0)
{
onBlockAdded(par1World, par2, par3, par4);
}
}
/**
* Called whenever the block is added into the world. Args: world, x, y, z
*/
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
if (par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1);
}
else if (par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2);
}
else if (par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3);
}
else if (par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 4);
}
else if (canPlaceTorchOn(par1World, par2, par3 - 1, par4))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 5);
}
dropTorchIfCantStay(par1World, par2, par3, par4);
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
if (dropTorchIfCantStay(par1World, par2, par3, par4))
{
int i = par1World.getBlockMetadata(par2, par3, par4);
boolean flag = false;
if (!par1World.isBlockNormalCubeDefault(par2 - 1, par3, par4, true) && i == 1)
{
flag = true;
}
if (!par1World.isBlockNormalCubeDefault(par2 + 1, par3, par4, true) && i == 2)
{
flag = true;
}
if (!par1World.isBlockNormalCubeDefault(par2, par3, par4 - 1, true) && i == 3)
{
flag = true;
}
if (!par1World.isBlockNormalCubeDefault(par2, par3, par4 + 1, true) && i == 4)
{
flag = true;
}
if (!canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i == 5)
{
flag = true;
}
if (flag)
{
dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockWithNotify(par2, par3, par4, 0);
}
}
}
/**
* Tests if the block can remain at its current location and will drop as an item if it is unable to stay. Returns
* True if it can stay and False if it drops. Args: world, x, y, z
*/
private boolean dropTorchIfCantStay(World par1World, int par2, int par3, int par4)
{
if (!canPlaceBlockAt(par1World, par2, par3, par4))
{
if (par1World.getBlockId(par2, par3, par4) == blockID)
{
dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockWithNotify(par2, par3, par4, 0);
}
return false;
}
else
{
return true;
}
}
/**
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
* x, y, z, startVec, endVec
*/
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3D par5Vec3D, Vec3D par6Vec3D)
{
int i = par1World.getBlockMetadata(par2, par3, par4) & 7;
float f = 0.15F;
if (i == 1)
{
setBlockBounds(0.0F, 0.2F, 0.5F - f, f * 2.0F, 0.8F, 0.5F + f);
}
else if (i == 2)
{
setBlockBounds(1.0F - f * 2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f);
}
else if (i == 3)
{
setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f * 2.0F);
}
else if (i == 4)
{
setBlockBounds(0.5F - f, 0.2F, 1.0F - f * 2.0F, 0.5F + f, 0.8F, 1.0F);
}
else
{
float f1 = 0.1F;
setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1);
}
return super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3D, par6Vec3D);
}
/**
* A randomly called display update to be able to add particles or other items for display
*/
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
int i = par1World.getBlockMetadata(par2, par3, par4);
double d = (float)par2 + 0.5F;
double d1 = (float)par3 + 0.7F;
double d2 = (float)par4 + 0.5F;
double d3 = 0.2199999988079071D;
double d4 = 0.27000001072883606D;
if (i == 1)
{
par1World.spawnParticle("splash", d - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("splash", d - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
}
else if (i == 2)
{
par1World.spawnParticle("splash", d + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("splash", d + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
}
else if (i == 3)
{
par1World.spawnParticle("splash", d, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("splash", d, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
}
else if (i == 4)
{
par1World.spawnParticle("splash", d, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("splash", d, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
}
else
{
par1World.spawnParticle("splash", d, d1, d2, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("splash", d, d1, d2, 0.0D, 0.0D, 0.0D);
}
}
}
BlockFarmland ( I edited the pre-existing flie )
package net.minecraft.src;
import java.util.Random;
public class BlockFarmland extends Block
{
protected BlockFarmland(int par1)
{
super(par1, Material.ground);
blockIndexInTexture = 87;
setTickRandomly(true);
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.9375F, 1.0F);
setLightOpacity(255);
}
/**
* Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
* cleared to be reused)
*/
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
{
return AxisAlignedBB.getBoundingBoxFromPool(par2 + 0, par3 + 0, par4 + 0, par2 + 1, par3 + 1, par4 + 1);
}
/**
* Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
*/
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
public int getBlockTextureFromSideAndMetadata(int par1, int par2)
{
if (par1 == 1 && par2 > 0)
{
return blockIndexInTexture - 1;
}
if (par1 == 1)
{
return blockIndexInTexture;
}
else
{
return 2;
}
}
/**
* Ticks the block if it's been scheduled
*/
public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
if (isWaterNearby(par1World, par2, par3, par4) || par1World.canLightningStrikeAt(par2, par3 + 1, par4))
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 7);
}
else
{
int i = par1World.getBlockMetadata(par2, par3, par4);
if (i > 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, i - 1);
}
else if (!isCropsNearby(par1World, par2, par3, par4))
{
par1World.setBlockWithNotify(par2, par3, par4, Block.dirt.blockID);
}
}
}
/**
* Block's chance to react to an entity falling on it.
*/
public void onFallenUpon(World par1World, int par2, int par3, int par4, Entity par5Entity, float par6)
{
if (par1World.rand.nextFloat() < par6 - 0.5F)
{
par1World.setBlockWithNotify(par2, par3, par4, Block.dirt.blockID);
}
}
/**
* returns true if there is at least one cropblock nearby (x-1 to x+1, y+1, z-1 to z+1)
*/
private boolean isCropsNearby(World par1World, int par2, int par3, int par4)
{
int i = 0;
for (int j = par2 - i; j <= par2 + i; j++)
{
for (int k = par4 - i; k <= par4 + i; k++)
{
int l = par1World.getBlockId(j, par3 + 1, k);
if (l == Block.crops.blockID || l == Block.melonStem.blockID || l == Block.pumpkinStem.blockID)
{
return true;
}
}
}
return false;
}
/**
* returns true if there's water nearby (x-4 to x+4, y to y+1, k-4 to k+4)
*/
private boolean isWaterNearby(World par1World, int par2, int par3, int par4)
{
for (int i = par2 - 4; i <= par2 + 4; i++)
{
for (int j = par3; j <= par3 + 1; j++)
{
for (int k = par4 - 4; k <= par4 + 4; k++)
{
if (par1World.getBlockMaterial(i, j, k) == Material.water || par1World.getBlockMaterial(i, j, k) == mod_Gardening.sprinkelerMat)
{
return true;
}
}
}
}
return false;
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
*/
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
Material material = par1World.getBlockMaterial(par2, par3 + 1, par4);
if (material.isSolid())
{
par1World.setBlockWithNotify(par2, par3, par4, Block.dirt.blockID);
}
}
/**
* Returns the ID of the items to drop on destruction.
*/
public int idDropped(int par1, Random par2Random, int par3)
{
return Block.dirt.idDropped(0, par2Random, par3);
}
}
Rollback Post to RevisionRollBack
------------------------------
"whatever you do don't die"
"310", block id "310"... if you have looked at any modding tutorials (or even parts of the wiki) the first thing noted when creating a block is DO NOT GO OVER 255. also you'll note that in recent versions of modloader, you no longer need the "public mod_" function, just place all that into your load function. also, your current code will not override the terrain.png to give you a different look for your block.
"310", block id "310"... if you have looked at any modding tutorials (or even parts of the wiki) the first thing noted when creating a block is DO NOT GO OVER 255. also you'll note that in recent versions of modloader, you no longer need the "public mod_" function, just place all that into your load function. also, your current code will not override the terrain.png to give you a different look for your block.
now i have this error
Generated 6/2/12 6:09 PM
Minecraft: Minecraft 1.2.5
OS: Mac OS X (x86_64) version 10.7.4
Java: 1.6.0_31, Apple Inc.
VM: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Apple Inc.
LWJGL: 2.4.2
OpenGL: ATI Radeon X1600 OpenGL Engine version 2.1 ATI-7.0.52, ATI Technologies Inc.
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at net.minecraft.src.ModLoader.addMod(ModLoader.java:287)
at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1279)
at net.minecraft.src.ModLoader.init(ModLoader.java:849)
at net.minecraft.src.ModLoader.addAllRenderers(ModLoader.java:157)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:85)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:12)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:424)
at net.minecraft.client.Minecraft.run(Minecraft.java:786)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NullPointerException
at net.minecraft.src.Block.<init>(Block.java:242)
at net.minecraft.src.Block.<init>(Block.java:267)
at net.minecraft.src.BlockSprinkeler.<init>(BlockSprinkeler.java:9)
at net.minecraft.src.mod_Gardening.<clinit>(mod_Gardening.java:4)
... 15 more
your going to have to add textures, the sooner the better if for no other reason then to test (pick something bright that screams "i need fixing"). also if your not using eclipse i would suggest that. its helpful and can point out things to you that you might not realize
This is the code:
mod_Gardening
"whatever you do don't die"
now i have this error
P.S. I don't have the textures yet
"whatever you do don't die"