No, I had to find that out in a separate thread. All these tutorials either leave something out or word something oddly :\
Don't take this the wrong way, but this tutorial is rather clear about it. It's the last paragraph in the first spoiler, Getting Set-Up.
This is very easy to set up. When it asks you to select a workspace, select the 'eclipse' folder in your MCP directory. It will now set everything up automatically. To get to the src files from the game in Eclipse, on the left, click 'Client', 'src', 'net.minecraft.src'.
Well I've run into another issue which I can't seem to pin point. I've added the tools into the mod and it's crashing my game somewhere. It's not showing any errors with the coding in Eclipse. Only after I recompile and start client.
I LIED. I think I need to stop trying to help for a while
Or maybe I didn't? Check if changing null in String getVersion to your MC jar version does anything.
It still gave me the same error code :/ I don't even know how that got changed to null in the first place o.o
Hmm...well, it definitely has something to do with nullity. Because that's the error that's being thrown.
Check somewhere in your public void load area. My next guess would be your recipes. For example, some are "%", where it should be " % ". To represent blank spaces. Try that.
Well I'm not seeing anything that seems out of the ordinary. I tried starting the client again and noticed it will say "Overriding /gui/items.png with /crystalpickaxe.png @ 38. 80 left" and then pause for a couple seconds. Then it will crash. Could that have something to do with it?
Hmm...perhaps. Do you have a crystalpickaxe.png in that directory? Is it the same spelling/case?
However, I doubt it. I would think it would throw a missing texture error. But it can't hurt to check.
I checked for that a few times actually. I even tried renaming the crystalpickaxe.png to crystalpick.png and did the recompile, but it still gave me errors. I'm starting to think that eclipse is just lazy and isn't telling me something.
I see. Well, from the error code, all I can gather is that something is null when it shouldn't be.
I believe in load() (as that's what the error code is pointing to in the second line). But aside from that?
Beats me, I can't see anything that would really throw that.
I checked for that a few times actually. I even tried renaming the crystalpickaxe.png to crystalpick.png and did the recompile, but it still gave me errors. I'm starting to think that eclipse is just lazy and isn't telling me something.
It's probably the JVM being fickle. I added a try|catch clause, it might work now.
If I misplaced some of the brackets just put a try{} around all the stuff in your load() method and then a catch (NullPointerException e) {} on the closing try{} bracket. This doesn't break anything, it basically just tells the JVM "I know an exception is occurring and I'm trying to fix it."
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
It seems this has given me the same error message too. It's completely beyond me as to what might be causing this error.
And yes But these tools are proving rather difficult xD After I get the basics down I'm going to shoot for harder things like dropping dyeable glowing powders as redstone line. Possibly a crystal golem
Wow...you're really lucking out.
Your Java's giving you problems, and I feel bad for you, son.
I got 99 problems, but a NullPointerException ain't one.
Haha but seriously though, hopefully it can get fixed. :/
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
Thanks for the great tutorials! They've made beginning my Minecraft modding much, much easier! :-)
Maybe someone can point me in the right direction on a couple of questions. I'm trying to create a simple mod that generates two more types of ore. I've succeeded in getting the ores to generate in the world and drop the appropriate stuff when mined, but I'd like to add some more specific spawning rules to each ore type. One needs to spawn very close to lava, and the other needs to appear almost exclusively in caverns.
For the close-to-lava-block, I suppose I could drop the maximum height of the spawn down to around the bottom of the map, but I'd like the ore to appear everywhere lava is (including the rare-ish surface pools). As for the cavern ore, I know there must be a way of hooking into the cavern generation script, but I haven't had any success with it yet.
Thanks in advance for any help anyone might provide me with.
Hello! Your tutorials have helped explain alot to me! Thankyou!
... But I've been having trouble modding something for a prodject I've been working on lately... :/
You see, I've been working on an "Advance Block Structure" (i don't know what else to call it), where when you put a certain type of block into a certain structure, it turns into a type of special crafting table or furnace (for example: the Better Than Wolves mod's Kilm where you use brick blocks and a habachi along with a ballow to get it to work so you can put clay blocks inside it)
My idea was to be able to take "Melted Metals" and put them into "Molds" so they come out as certain items i can use further in the crafting for my mod... I was thinking to put three modded blocks in a row to make an advanced structure "Mold Stand" but i have no idea how to accoplish this... Help? D:
There is not one. I have fixed the coding but there is still the same issue; the stairs look like an ordinary block. Here is the updated coding:
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class BlockGlass_Stairs extends Block
{
public static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}};
public boolean field_72156_cr = false;
private int field_72160_cs = 0;
protected BlockGlass_Stairs(int i, int j)
{
super(i, j, Material.glass);
this.setLightOpacity(0);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public void setBlockBoundsBaseOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
if (this.field_72156_cr)
{
this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2));
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
public boolean isOpaqueCube()
{
return false;
}
public boolean randerAsNormalBlock()
{
return false;
}
public int genRenderType()
{
return 10;
}
public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
float var10 = 0.0f;
float var11 = 0.5f;
float var12 = 0.5f;
float var13 = 1.0f;
if ((var8 & 4) != 0)
{
var10 = 0.5f;
var11 = 1.0f;
var12 = 0.0f;
var13 = 0.5f;
}
this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
if (var9 == 0)
{
this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 1)
{
this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 2)
{
this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 3)
{
this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4;
if (var6 == 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7);
}
if (var6 == 1)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7);
}
if (var6 == 2)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7);
}
if (var6 == 3)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7);
}
}
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D)
{
int var9 = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4);
}
}
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
{
MovingObjectPosition[] var7 = new MovingObjectPosition[8];
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
boolean var10 = (var8 & 4) == 4;
int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)];
this.field_72156_cr = true;
int var14;
int var15;
int var16;
for (int var12 = 0; var12 < 8; ++var12)
{
this.field_72160_cs = var12;
int[] var13 = var11;
var14 = var11.length;
for (var15 = 0; var15 < var14; ++var15)
{
var16 = var13[var15];
if (var16 == var12)
{
;
}
}
var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
int[] var21 = var11;
int var24 = var11.length;
for (var14 = 0; var14 < var24; ++var14)
{
var15 = var21[var14];
var7[var15] = null;
}
MovingObjectPosition var23 = null;
double var22 = 0.0D;
MovingObjectPosition[] var25 = var7;
var16 = var7.length;
for (int var17 = 0; var17 < var16; ++var17)
{
MovingObjectPosition var18 = var25[var17];
if (var18 != null)
{
double var19 = var18.hitVec.squareDistanceTo(par6Vec3);
if (var19 > var22)
{
var23 = var18;
var22 = var19;
}
}
}
return var23;
}
}
Post your class with the mod_ prefix.
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'm trying to run a simple mod I wrote that adds one or two items and blocks, but am getting this error message when minecraft crashes. Any idea what's going on?
Mods loaded: 2
ModLoader 1.2.5
mod_RubyItem 1.2.5
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem.
--- BEGIN ERROR REPORT d30a7825 --------
Generated 9/6/12 11:59 AM
Minecraft: Minecraft 1.2.5
OS: Windows 7 (x86) version 6.1
Java: 1.6.0_31, Sun Microsystems Inc.
VM: Java HotSpot(TM) Client VM (mixed mode), Sun Microsystems Inc.
LWJGL: 2.4.2
OpenGL: AMD Radeon HD 6500M/5600/5700 Series version 4.2.11733 Compatibility Profile Context, ATI Technologies Inc.
java.lang.RuntimeException: java.lang.Exception: Image not found: /image.png
at net.minecraft.src.ModLoader.registerAllTextureOverrides(ModLoader.java:1451)
at net.minecraft.src.ModLoader.onTick(ModLoader.java:1104)
at net.minecraft.src.EntityRendererProxy.updateCameraAndRender(EntityRendererProxy.java:21)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:922)
at net.minecraft.client.Minecraft.run(Minecraft.java:801)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.Exception: Image not found: /image.png
at net.minecraft.src.ModLoader.loadImage(ModLoader.java:1024)
at net.minecraft.src.ModLoader.registerAllTextureOverrides(ModLoader.java:1443)
... 5 more
--- END ERROR REPORT 7fdf8e18 ----------
On a side note, I can't get the addRecipe to work correctly either. I have it written like this, but Eclipse is telling me that there is an error in the code.
package net.minecraft.src;
public class mod_Glasscraft extends BaseMod
{
public static final Block Glass_Stairs = new BlockGlass_Stairs (137, 0).setBlockName("Glass Stairs").setHardness(0.3F).setResistance(1.5F).setLightValue(0F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundGlassFootstep);
public static final Item Glass_Shard = new ItemGlass_Shard (960).setItemName("Glass Shard");
public static final Block Glass_Shard_Pile = new BlockGlass_Shard_Pile (138, 0).setBlockName("Glass Shard Pile"). setHardness(0.3F).setResistance(1.5F).setLightValue(0F).setCreativeTab(CreativeTabs.tabMisc).setStepSound(Block.soundGlassFootstep);
public void load()
{
Glass_Stairs.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Glass.png");
ModLoader.registerBlock(Glass_Stairs);
ModLoader.addName(Glass_Stairs, "Glass Stairs");
ModLoader.addRecipe(new ItemStack(Glass_Stairs, 4), new Object [] {"# ", "## ", "###", Character.valueOf('#'), Block.glass});
ModLoader.addRecipe(new ItemStack(Glass_Stairs, 4), new Object [] {" #", " ##", "###", Character.valueOf('#'), Block.glass});
Glass_Shard.iconIndex = ModLoader.addOverride("/gui/items.png", "/GlassShard.png");
ModLoader.addName(Glass_Shard, "Glass Shard");
Glass_Shard_Pile.blockIndexInTexture = ModLoader.addOverride("/gui/items.png", "/GlassShardPile.png");
ModLoader.addRecipe(new ItemStack(Glass_Shard_Pile, 1), new Object [] {" ", "## ", "## ", Character.valueOf('#'), Glass_Shard});
ModLoader.addRecipe(new ItemStack(Glass_Shard_Pile, 1), new Object [] {"## ", "## ", " ", Character.valueOf('#'), Glass_Shard});
ModLoader.addRecipe(new ItemStack(Glass_Shard_Pile, 1), new Object [] {" ##", " ##", " ", Character.valueOf('#'), Glass_Shard});
ModLoader.addRecipe(new ItemStack(Glass_Shard_Pile, 1), new Object [] {" ", " ##", " ##", Character.valueOf('#'), Glass_Shard});
}
public String getVersion()
{
return "1.3.2";
}
}
BlockGlass_Stairs:
package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class BlockGlass_Stairs extends Block
{
public static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}};
public boolean field_72156_cr = false;
private int field_72160_cs = 0;
protected BlockGlass_Stairs(int i, int j)
{
super(i, j, Material.glass);
this.setLightOpacity(0);
this.setCreativeTab(CreativeTabs.tabBlock);
}
public void setBlockBoundsBaseOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
if (this.field_72156_cr)
{
this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2));
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
public boolean isOpaqueCube()
{
return false;
}
public boolean randerAsNormalBlock()
{
return false;
}
public int genRenderType()
{
return 10;
}
public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
{
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
float var10 = 0.0f;
float var11 = 0.5f;
float var12 = 0.5f;
float var13 = 1.0f;
if ((var8 & 4) != 0)
{
var10 = 0.5f;
var11 = 1.0f;
var12 = 0.0f;
var13 = 0.5f;
}
this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
if (var9 == 0)
{
this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 1)
{
this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 2)
{
this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
else if (var9 == 3)
{
this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F);
super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4;
if (var6 == 0)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7);
}
if (var6 == 1)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7);
}
if (var6 == 2)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7);
}
if (var6 == 3)
{
par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7);
}
}
public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8)
{
if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D)
{
int var9 = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4);
}
}
public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)
{
MovingObjectPosition[] var7 = new MovingObjectPosition[8];
int var8 = par1World.getBlockMetadata(par2, par3, par4);
int var9 = var8 & 3;
boolean var10 = (var8 & 4) == 4;
int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)];
this.field_72156_cr = true;
int var14;
int var15;
int var16;
for (int var12 = 0; var12 < 8; ++var12)
{
this.field_72160_cs = var12;
int[] var13 = var11;
var14 = var11.length;
for (var15 = 0; var15 < var14; ++var15)
{
var16 = var13[var15];
if (var16 == var12)
{
;
}
}
var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);
}
int[] var21 = var11;
int var24 = var11.length;
for (var14 = 0; var14 < var24; ++var14)
{
var15 = var21[var14];
var7[var15] = null;
}
MovingObjectPosition var23 = null;
double var22 = 0.0D;
MovingObjectPosition[] var25 = var7;
var16 = var7.length;
for (int var17 = 0; var17 < var16; ++var17)
{
MovingObjectPosition var18 = var25[var17];
if (var18 != null)
{
double var19 = var18.hitVec.squareDistanceTo(par6Vec3);
if (var19 > var22)
{
var23 = var18;
var22 = var19;
}
}
}
return var23;
}
}
Found the issue, these two methods in the block class are spelt incorrectly.
public boolean randerAsNormalBlock()
{
return false;
}
public int genRenderType()
{
return 10;
}
They should be:
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 10;
}
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
okay. This actually did something. It let the game load and everything, but the crystal ore wasn't in the creative inventory anymore. The crystal powder was in the materials tab, but its icon was a leather helmet and it didn't have a name.
XYZ is an integer representing the "strength" of the pickaxe:
0 wood
1 gold
2 stone
3 iron
4 diamond
Don't know if there is an another way without base class editing
Actually no, gold and wood share the same tool material id. 0 - wood, 0- gold, 1- stone, 2- iron, 3- diamond.
There is a way to do it without editing a baseclass, but it requires Forge.
Rollback Post to RevisionRollBack
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
I cant get Items to appear in my minecraft game Here is my code
Mod_DracoCraft
package net.minecraft.src;
import java.util.Random;
public class Mod_DracoCraft extends BaseMod
{
public static final Item FireGem = new Item(2000).setItemName("FireGem").setCreativeTab(CreativeTabs.tabMisc);
public void load()
{
FireGem.iconIndex = ModLoader.addOverride("/gui/items.png", "/FireGem.png");
}
public String getVersion() {
return "3.14159265";
}
}
ItemFireGem
package net.minecraft.src;
import java.util.Random;
public class ItemFireGem extends Item
{
public ItemFireGem(int i)
{
super(i);
maxStackSize = 64;
this.setCreativeTab(CreativeTabs.tabMisc);
}
public String Version()
{
return "3.14159265";
}
}
I receive errors at setCreativeTab saying that the method is undefined for the type Item help please
Rollback Post to RevisionRollBack
Experienced Coder!
To post a comment, please login or register a new account.
Any way to do it without modifying .class files?
NOTE: Nvm, figured it out me-self :3 lol
Nice work TechGuy, lookin forward to seeing the rest of the GUI tut.
Don't take this the wrong way, but this tutorial is rather clear about it. It's the last paragraph in the first spoiler, Getting Set-Up.
I LIED. I think I need to stop trying to help for a while
Or maybe I didn't? Check if changing null in String getVersion to your MC jar version does anything.
Hmm...well, it definitely has something to do with nullity. Because that's the error that's being thrown.
Check somewhere in your public void load area. My next guess would be your recipes. For example, some are "%", where it should be " % ". To represent blank spaces. Try that.
Hmm...perhaps. Do you have a crystalpickaxe.png in that directory? Is it the same spelling/case?
However, I doubt it. I would think it would throw a missing texture error. But it can't hurt to check.
I see. Well, from the error code, all I can gather is that something is null when it shouldn't be.
I believe in load() (as that's what the error code is pointing to in the second line). But aside from that?
Beats me, I can't see anything that would really throw that.
-
View User Profile
-
View Posts
-
Send Message
Retired StaffIt's probably the JVM being fickle. I added a try|catch clause, it might work now.
public void load() { try { //Tools Texture CrystalPickAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/crystalpickaxe.png"); CrystalAxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/crystalaxe.png"); CrystalShovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/crystalshovel.png"); CrystalSword.iconIndex = ModLoader.addOverride("/gui/items.png", "/crystalsword.png"); CrystalHoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/crystalhoe.png"); //Items and Blocks texture CrystalPowder.iconIndex = ModLoader.addOverride("/gui/items.png", "/crystalpowder.png"); CrystalFragment.iconIndex = ModLoader.addOverride("/gui/items.png", "/crystalfragment.png"); CrystalOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/crystalore.png"); //Tools Names ModLoader.addName(CrystalPickAxe, "Crystal Pickaxe"); ModLoader.addName(CrystalAxe, "Crystal Axe"); ModLoader.addName(CrystalShovel, "Crystal Shovel"); ModLoader.addName(CrystalSword, "Crystal Sword"); ModLoader.addName(CrystalHoe, "Crystal Hoe"); //Items and Blocks ModLoader.addName(CrystalPowder, "Crystal Powder"); ModLoader.addShapelessRecipe(new ItemStack(CrystalPowder, 4), new Object [] {CrystalFragment}); ModLoader.registerBlock(CrystalOre); ModLoader.addName(CrystalOre, "Crystal Ore"); ModLoader.addName(CrystalFragment, "Crystal Fragment"); //Tools Recipes ModLoader.addRecipe(new ItemStack(CrystalPickAxe, 1), new Object [] {"###", " % ", " % ", '#', Item.CrystalFragment, '%', Item.stick}); ModLoader.addRecipe(new ItemStack(CrystalAxe, 1), new Object [] {"##", "#%", " %", '#', Item.CrystalFragment, '%', Item.stick}); ModLoader.addRecipe(new ItemStack(CrystalShovel, 1), new Object [] {"#", "%", "%", '#', Item.CrystalFragment, '%', Item.stick}); ModLoader.addRecipe(new ItemStack(CrystalSword, 1), new Object [] {"#", "#", "%", '#', Item.CrystalFragment, '%', Item.stick}); ModLoader.addRecipe(new ItemStack(CrystalHoe, 1), new Object [] {"##", " %", " %", '#', Item.CrystalFragment, '%', Item.stick}); } catch (NullPointerException e) { } }If I misplaced some of the brackets just put a try{} around all the stuff in your load() method and then a catch (NullPointerException e) {} on the closing try{} bracket. This doesn't break anything, it basically just tells the JVM "I know an exception is occurring and I'm trying to fix it."
Also, I see you're adding tools. Whoop!
Wow...you're really lucking out.
Your Java's giving you problems, and I feel bad for you, son.
I got 99 problems, but a NullPointerException ain't one.
Haha but seriously though, hopefully it can get fixed. :/
-
View User Profile
-
View Posts
-
Send Message
Retired StaffThat's odd... a try|catch should work. Works for me. Maybe instead of NullPointerException e put
} catch (Exception e) { }And that catches any exception that occurs.
Did you overwrite the load method?
NullPointers seem to be the one exception that Java's like "let them figure it out. I'll give them a line number."
Maybe someone can point me in the right direction on a couple of questions. I'm trying to create a simple mod that generates two more types of ore. I've succeeded in getting the ores to generate in the world and drop the appropriate stuff when mined, but I'd like to add some more specific spawning rules to each ore type. One needs to spawn very close to lava, and the other needs to appear almost exclusively in caverns.
For the close-to-lava-block, I suppose I could drop the maximum height of the spawn down to around the bottom of the map, but I'd like the ore to appear everywhere lava is (including the rare-ish surface pools). As for the cavern ore, I know there must be a way of hooking into the cavern generation script, but I haven't had any success with it yet.
Thanks in advance for any help anyone might provide me with.
... But I've been having trouble modding something for a prodject I've been working on lately... :/
You see, I've been working on an "Advance Block Structure" (i don't know what else to call it), where when you put a certain type of block into a certain structure, it turns into a type of special crafting table or furnace (for example: the Better Than Wolves mod's Kilm where you use brick blocks and a habachi along with a ballow to get it to work so you can put clay blocks inside it)
My idea was to be able to take "Melted Metals" and put them into "Molds" so they come out as certain items i can use further in the crafting for my mod... I was thinking to put three modded blocks in a row to make an advanced structure "Mold Stand" but i have no idea how to accoplish this... Help? D:
There is not one. I have fixed the coding but there is still the same issue; the stairs look like an ordinary block. Here is the updated coding:
package net.minecraft.src; import java.util.List; import java.util.Random; public class BlockGlass_Stairs extends Block { public static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}}; public boolean field_72156_cr = false; private int field_72160_cs = 0; protected BlockGlass_Stairs(int i, int j) { super(i, j, Material.glass); this.setLightOpacity(0); this.setCreativeTab(CreativeTabs.tabBlock); } public void setBlockBoundsBaseOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { if (this.field_72156_cr) { this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2)); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } } public boolean isOpaqueCube() { return false; } public boolean randerAsNormalBlock() { return false; } public int genRenderType() { return 10; } public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = var8 & 3; float var10 = 0.0f; float var11 = 0.5f; float var12 = 0.5f; float var13 = 1.0f; if ((var8 & 4) != 0) { var10 = 0.5f; var11 = 1.0f; var12 = 0.0f; var13 = 0.5f; } this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); if (var9 == 0) { this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 1) { this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 2) { this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 3) { this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) { int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4; if (var6 == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7); } if (var6 == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7); } if (var6 == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7); } if (var6 == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7); } } public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8) { if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D) { int var9 = par1World.getBlockMetadata(par2, par3, par4); par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4); } } public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) { MovingObjectPosition[] var7 = new MovingObjectPosition[8]; int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = var8 & 3; boolean var10 = (var8 & 4) == 4; int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)]; this.field_72156_cr = true; int var14; int var15; int var16; for (int var12 = 0; var12 < 8; ++var12) { this.field_72160_cs = var12; int[] var13 = var11; var14 = var11.length; for (var15 = 0; var15 < var14; ++var15) { var16 = var13[var15]; if (var16 == var12) { ; } } var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3); } int[] var21 = var11; int var24 = var11.length; for (var14 = 0; var14 < var24; ++var14) { var15 = var21[var14]; var7[var15] = null; } MovingObjectPosition var23 = null; double var22 = 0.0D; MovingObjectPosition[] var25 = var7; var16 = var7.length; for (int var17 = 0; var17 < var16; ++var17) { MovingObjectPosition var18 = var25[var17]; if (var18 != null) { double var19 = var18.hitVec.squareDistanceTo(par6Vec3); if (var19 > var22) { var23 = var18; var22 = var19; } } } return var23; } }Post your class with the mod_ prefix.
together they are powerful beyond imagination."
I'm so sorry, I confused this with another tutorial
On a side note, I can't get the addRecipe to work correctly either. I have it written like this, but Eclipse is telling me that there is an error in the code.
ModLoader.addRecipe(new ItemStack(Pick, 1, new Object [] {"###", " @ ", " @ ", '#', Item.Ruby, '@', Item.stick}));Ok here is both:
mod_Glasscraft:
package net.minecraft.src; public class mod_Glasscraft extends BaseMod { public static final Block Glass_Stairs = new BlockGlass_Stairs (137, 0).setBlockName("Glass Stairs").setHardness(0.3F).setResistance(1.5F).setLightValue(0F).setCreativeTab(CreativeTabs.tabBlock).setStepSound(Block.soundGlassFootstep); public static final Item Glass_Shard = new ItemGlass_Shard (960).setItemName("Glass Shard"); public static final Block Glass_Shard_Pile = new BlockGlass_Shard_Pile (138, 0).setBlockName("Glass Shard Pile"). setHardness(0.3F).setResistance(1.5F).setLightValue(0F).setCreativeTab(CreativeTabs.tabMisc).setStepSound(Block.soundGlassFootstep); public void load() { Glass_Stairs.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Glass.png"); ModLoader.registerBlock(Glass_Stairs); ModLoader.addName(Glass_Stairs, "Glass Stairs"); ModLoader.addRecipe(new ItemStack(Glass_Stairs, 4), new Object [] {"# ", "## ", "###", Character.valueOf('#'), Block.glass}); ModLoader.addRecipe(new ItemStack(Glass_Stairs, 4), new Object [] {" #", " ##", "###", Character.valueOf('#'), Block.glass}); Glass_Shard.iconIndex = ModLoader.addOverride("/gui/items.png", "/GlassShard.png"); ModLoader.addName(Glass_Shard, "Glass Shard"); Glass_Shard_Pile.blockIndexInTexture = ModLoader.addOverride("/gui/items.png", "/GlassShardPile.png"); ModLoader.addRecipe(new ItemStack(Glass_Shard_Pile, 1), new Object [] {" ", "## ", "## ", Character.valueOf('#'), Glass_Shard}); ModLoader.addRecipe(new ItemStack(Glass_Shard_Pile, 1), new Object [] {"## ", "## ", " ", Character.valueOf('#'), Glass_Shard}); ModLoader.addRecipe(new ItemStack(Glass_Shard_Pile, 1), new Object [] {" ##", " ##", " ", Character.valueOf('#'), Glass_Shard}); ModLoader.addRecipe(new ItemStack(Glass_Shard_Pile, 1), new Object [] {" ", " ##", " ##", Character.valueOf('#'), Glass_Shard}); } public String getVersion() { return "1.3.2"; } }BlockGlass_Stairs:
package net.minecraft.src; import java.util.List; import java.util.Random; public class BlockGlass_Stairs extends Block { public static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}}; public boolean field_72156_cr = false; private int field_72160_cs = 0; protected BlockGlass_Stairs(int i, int j) { super(i, j, Material.glass); this.setLightOpacity(0); this.setCreativeTab(CreativeTabs.tabBlock); } public void setBlockBoundsBaseOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { if (this.field_72156_cr) { this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2)); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } } public boolean isOpaqueCube() { return false; } public boolean randerAsNormalBlock() { return false; } public int genRenderType() { return 10; } public void addCollidingBlockToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = var8 & 3; float var10 = 0.0f; float var11 = 0.5f; float var12 = 0.5f; float var13 = 1.0f; if ((var8 & 4) != 0) { var10 = 0.5f; var11 = 1.0f; var12 = 0.0f; var13 = 0.5f; } this.setBlockBounds(0.0F, var10, 0.0F, 1.0F, var11, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); if (var9 == 0) { this.setBlockBounds(0.5F, var12, 0.0F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 1) { this.setBlockBounds(0.0F, var12, 0.0F, 0.5F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 2) { this.setBlockBounds(0.0F, var12, 0.5F, 1.0F, var13, 1.0F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } else if (var9 == 3) { this.setBlockBounds(0.0F, var12, 0.0F, 1.0F, var13, 0.5F); super.addCollidingBlockToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); } this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) { int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; int var7 = par1World.getBlockMetadata(par2, par3, par4) & 4; if (var6 == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | var7); } if (var6 == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | var7); } if (var6 == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | var7); } if (var6 == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | var7); } } public void updateBlockMetadata(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8) { if (par5 == 0 || par5 != 1 && (double)par7 > 0.5D) { int var9 = par1World.getBlockMetadata(par2, par3, par4); par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 4); } } public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3) { MovingObjectPosition[] var7 = new MovingObjectPosition[8]; int var8 = par1World.getBlockMetadata(par2, par3, par4); int var9 = var8 & 3; boolean var10 = (var8 & 4) == 4; int[] var11 = field_72159_a[var9 + (var10 ? 4 : 0)]; this.field_72156_cr = true; int var14; int var15; int var16; for (int var12 = 0; var12 < 8; ++var12) { this.field_72160_cs = var12; int[] var13 = var11; var14 = var11.length; for (var15 = 0; var15 < var14; ++var15) { var16 = var13[var15]; if (var16 == var12) { ; } } var7[var12] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3); } int[] var21 = var11; int var24 = var11.length; for (var14 = 0; var14 < var24; ++var14) { var15 = var21[var14]; var7[var15] = null; } MovingObjectPosition var23 = null; double var22 = 0.0D; MovingObjectPosition[] var25 = var7; var16 = var7.length; for (int var17 = 0; var17 < var16; ++var17) { MovingObjectPosition var18 = var25[var17]; if (var18 != null) { double var19 = var18.hitVec.squareDistanceTo(par6Vec3); if (var19 > var22) { var23 = var18; var22 = var19; } } } return var23; } }Found the issue, these two methods in the block class are spelt incorrectly.
public boolean randerAsNormalBlock() { return false; } public int genRenderType() { return 10; }They should be:
public boolean renderAsNormalBlock() { return false; } public int getRenderType() { return 10; }together they are powerful beyond imagination."
-
View User Profile
-
View Posts
-
Send Message
Retired StaffIn your crystal ore block file, did you put
In the constructor?
Actually no, gold and wood share the same tool material id. 0 - wood, 0- gold, 1- stone, 2- iron, 3- diamond.
There is a way to do it without editing a baseclass, but it requires Forge.
Here is my code
Mod_DracoCraft
package net.minecraft.src; import java.util.Random; public class Mod_DracoCraft extends BaseMod { public static final Item FireGem = new Item(2000).setItemName("FireGem").setCreativeTab(CreativeTabs.tabMisc); public void load() { FireGem.iconIndex = ModLoader.addOverride("/gui/items.png", "/FireGem.png"); } public String getVersion() { return "3.14159265"; } }ItemFireGem
package net.minecraft.src; import java.util.Random; public class ItemFireGem extends Item { public ItemFireGem(int i) { super(i); maxStackSize = 64; this.setCreativeTab(CreativeTabs.tabMisc); } public String Version() { return "3.14159265"; } }I receive errors at setCreativeTab saying that the method is undefined for the type Item
help please