What is a "null check"?
when i did this i just got the same errors plus one new:
src\minecraft\net\minecraft\src\mod_Silver.java:21: cannot find symbol
symbol : class Random
location: class net.minecraft.src.mod_Silver
rand=new Random(25);
^
here is my code now:
package net.minecraft.src;
public class mod_Silver extends BaseMod
{
public static final Block SilverOre = new BlockSilverOre(97, 0).setHardness(2.0F).setResistance(5.0F).setBlockName("SilverOre");
public static final Item Silver = new Item(2000).setItemName("Silvr");
public mod_Silver()
{
ModLoader.RegisterBlock(SilverOre);
SilverOre.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Mods/SilverOre.png");
Silver.iconIndex = ModLoader.addOverride("/gui/items.png", "/Mods/Silver.png");
ModLoader.AddName(SilverOre, "Silver Ore");
ModLoader.AddName(Silver, "Silver Ingot");
ModLoader.AddSmelting(SilverOre.blockID, new ItemStack(Silver, 1));
}
public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
{
if(rand==null){
rand=new Random(25);
}
for(int i = 0; i < 11; i++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(30);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(mod_Silver.SilverOre.blockID, 6)).generate(world, rand, randPosX, randPosY, randPosZ);
}
}
public String Version()
{
return "1.7_02";
}
}
null means nothing, it is absolutly nothing, and you can not do stuff with null, for example if rand == null then you can't use rand.somemethod() because null does not have any methods. A null check is when you check to see if smethin is null, meaning empty, blank, nothing, etc... by using if(rand==null) you are checking to see if rand is null, if it is you assign it to new Random(seed) the seed just decides the randomness simmmilar to how the minecraft seed for level generation works. if Random is unknown, that means you need to import it, at the top of your script, right afer the package declaration type:
import java.util.Random;
importing basically makes a reference to another class, meaning you can use all of its functions, importing is not needed for classes that are in the same package, which is why you do not need to import net.minecraft.src.Block; in order to make a class that extends it. but you know there is:
if you were making a class in client and needed to use a class in src you'd need to import it because they are in different packages.
as seeing you do not have Random imported, inside the function declaration:
public void GenerateSurface(World world, Random rand, int chunkX, int chunkZ)
it does not know what Random is, and therefore rand will = null because there's an error, nothing was passed through. import Random it now know what it is and then allows you to use Random.
because you edited the CLIENT and not the SERVER your mod will only work in the SINGLEPLAYER, becuase the server would need to know the new block, meaning modding the SERVER AND the CLIENT, all people that use the server would still need the client mod. Test it in singleplayer to see if you find any of your new block. if not make sure you also added it to the generator in ChunkProviderGenerate.java
because you edited the CLIENT and not the SERVER your mod will only work in the SINGLEPLAYER, becuase the server would need to know the new block, meaning modding the SERVER AND the CLIENT, all people that use the server would still need the client mod. Test it in singleplayer to see if you find any of your new block. if not make sure you also added it to the generator in ChunkProviderGenerate.java
i did it on the client added it to chunk provider and have only look on single player for it
I'm trying to do your tutorial... but you never told us where to save mod_Emeralds.java
save it in the same place as every other java script, the net/minecraft/src folder that they were extracted into, everything goes in there unless modifying something in a different package, in which case it goes in that folder.
Hi, I am developing a mod called Lanterns. I am trying to add support for ModLoader, but I'm having a bit of trouble.
Here's the mod_lanterns:
package net.minecraft.src;
public class mod_lantern extends BaseMod
{
public static final Block lantern = new BlockLantern(97,0).setHardness(0.0F).setResistance(0.0F).setLightValue(1.0F).setBlockName("lantern");
public mod_lantern()
{
ModLoader.RegisterBlock(lantern);
lantern.blockIndexInTexture = ModLoader.addOverride(" /terrain.png", "/force/lantern.png");
ModLoader.AddName(lantern, "Lantern");
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(i == 1)
{
return 1;
}
if(i == 0)
{
return 1;
}
if(j == 1)
{
return 2;
}
if(j == 0)
{
return 2;
}
return j != 2 ? 0 : 2;
}
public String Version()
{
return "1.7.2";
}
}
And here's my BlockLantern:
package net.minecraft.src;
import java.util.Random;
public class BlockLantern extends Block
{
protected BlockLantern(int i, int j)
{
super(i, j, Material.circuits);
setTickOnLoad(true);
setBlockBounds(0.5F - 0.15F, 0.21F, 0.5F - 0.15F, 0.5F + 0.15F, 1.0F, 0.5F + 0.15F);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 16;
}
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
return super.canPlaceBlockAt(world, i, j - 1, k);
}
}
It keeps telling me that there is "No registry for " /terrain.png""
I ahve no idea what to do. Please help.
Rollback Post to RevisionRollBack
"If you wish make an apple pie from scratch, you must first invent the universe." -- Carl Sagan
Hi, I am developing a mod called Lanterns. I am trying to add support for ModLoader, but I'm having a bit of trouble.
Here's the mod_lanterns:
package net.minecraft.src;
public class mod_lantern extends BaseMod
{
public static final Block lantern = new BlockLantern(97,0).setHardness(0.0F).setResistance(0.0F).setLightValue(1.0F).setBlockName("lantern");
public mod_lantern()
{
ModLoader.RegisterBlock(lantern);
lantern.blockIndexInTexture = ModLoader.addOverride(" /terrain.png", "/force/lantern.png");
ModLoader.AddName(lantern, "Lantern");
}
public int getBlockTextureFromSideAndMetadata(int i, int j)
{
if(i == 1)
{
return 1;
}
if(i == 0)
{
return 1;
}
if(j == 1)
{
return 2;
}
if(j == 0)
{
return 2;
}
return j != 2 ? 0 : 2;
}
public String Version()
{
return "1.7.2";
}
}
And here's my BlockLantern:
package net.minecraft.src;
import java.util.Random;
public class BlockLantern extends Block
{
protected BlockLantern(int i, int j)
{
super(i, j, Material.circuits);
setTickOnLoad(true);
setBlockBounds(0.5F - 0.15F, 0.21F, 0.5F - 0.15F, 0.5F + 0.15F, 1.0F, 0.5F + 0.15F);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
{
return null;
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return 16;
}
public boolean canPlaceBlockAt(World world, int i, int j, int k)
{
return super.canPlaceBlockAt(world, i, j - 1, k);
}
}
It keeps telling me that there is "No registry for " /terrain.png""
hey i tried to make a block that makes you jump high but it didn't work, it just acted like a normal block :sad.gif:
heres my BlockTankitejump:
package net.minecraft.src;
import java.util.Random;
public class BlockTankitejump extends Block
{
public BlockTankitejump(int i, int j)
{
super(i, j, Material.rock);
}
public int idDropped(int i, Random random)
{
return mod_Tankite.tankitejump.blockID;
}
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
entity.motionY += 2.0;
}
}
please help :smile.gif:
Rollback Post to RevisionRollBack
I made this map! Please check it out! It's a really awesome map that took me over a year to make! :3
hey i tried to make a block that makes you jump high but it didn't work, it just acted like a normal block :sad.gif:
heres my BlockTankitejump:
package net.minecraft.src;
import java.util.Random;
public class BlockTankitejump extends Block
{
public BlockTankitejump(int i, int j)
{
super(i, j, Material.rock);
}
public int idDropped(int i, Random random)
{
return mod_Tankite.tankitejump.blockID;
}
public void onEntityWalking(World world, int x, int y, int z, Entity entity)
{
entity.motionY += 2.0;
}
}
please help :smile.gif:
Instead of onEntityWalking() try this:
public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity)
{
entity.motionY += 2.0;
}
@Chewy2014
Just wondering...wouldn't it be when the player collides with the side of the block too?
Yes, but I think that's the only way to do it. Unless you did an if statement to see if the player is on the top of the block using metadata... But that's really complicated.
This did not work, I get red lines in eclipse.
Here are the errors:
Description Resource Path Location Type
rand cannot be resolved BlockCabbagePlant.java /Client/src/net/minecraft/src line 80 Java Problem
rand cannot be resolved BlockCabbagePlant.java /Client/src/net/minecraft/src line 86 Java Problem
The method dropItem(int, int) is undefined for the type BlockCabbagePlant BlockCabbagePlant.java /Client/src/net/minecraft/src line 83 Java Problem
The method dropItem(int, int) is undefined for the type BlockCabbagePlant BlockCabbagePlant.java /Client/src/net/minecraft/src line 89 Java Problem
Okay maybe it only works for entities then... [/lol]
Can someone tell me when the new MCP came out did you have to set it up differently than the one before? Because I think you do but I can't find out (because I deleted the old MCP)
Wow, I feel stupid -.-... Anyway, I did that and now there aren't any errors, but it's still drawing the textures for the lantern from the terrain.png... Any ideas?
Rollback Post to RevisionRollBack
"If you wish make an apple pie from scratch, you must first invent the universe." -- Carl Sagan
i did the client and posted the coding above
null means nothing, it is absolutly nothing, and you can not do stuff with null, for example if rand == null then you can't use rand.somemethod() because null does not have any methods. A null check is when you check to see if smethin is null, meaning empty, blank, nothing, etc... by using if(rand==null) you are checking to see if rand is null, if it is you assign it to new Random(seed) the seed just decides the randomness simmmilar to how the minecraft seed for level generation works. if Random is unknown, that means you need to import it, at the top of your script, right afer the package declaration type:
importing basically makes a reference to another class, meaning you can use all of its functions, importing is not needed for classes that are in the same package, which is why you do not need to import net.minecraft.src.Block; in order to make a class that extends it. but you know there is:
net.minecraft.client
net.minecraft.src
net.minecraft.isom
if you were making a class in client and needed to use a class in src you'd need to import it because they are in different packages.
as seeing you do not have Random imported, inside the function declaration:
it does not know what Random is, and therefore rand will = null because there's an error, nothing was passed through. import Random it now know what it is and then allows you to use Random.
so 1 line should fix all those errors.
because you edited the CLIENT and not the SERVER your mod will only work in the SINGLEPLAYER, becuase the server would need to know the new block, meaning modding the SERVER AND the CLIENT, all people that use the server would still need the client mod. Test it in singleplayer to see if you find any of your new block. if not make sure you also added it to the generator in ChunkProviderGenerate.java
i did it on the client added it to chunk provider and have only look on single player for it
Check out my mods at http://www.minecraftforum.net/topic/463113-17-03colorcraft-fencesmodloader/
save it in the same place as every other java script, the net/minecraft/src folder that they were extracted into, everything goes in there unless modifying something in a different package, in which case it goes in that folder.
Here's the mod_lanterns:
And here's my BlockLantern:
It keeps telling me that there is "No registry for " /terrain.png""
I ahve no idea what to do. Please help.
Take out the space before " /terrain.png":
Check out my mods at http://www.minecraftforum.net/topic/463113-17-03colorcraft-fencesmodloader/
heres my BlockTankitejump:
please help :smile.gif:
I made this map! Please check it out! It's a really awesome map that took me over a year to make! :3
I think he means the location of the "/tutorials/emeraldOre.png" path.
Instead of onEntityWalking() try this:
Yes, but I think that's the only way to do it. Unless you did an if statement to see if the player is on the top of the block using metadata... But that's really complicated.
Okay maybe it only works for entities then... [/lol]
I know how to. Check here
Wow, I feel stupid -.-... Anyway, I did that and now there aren't any errors, but it's still drawing the textures for the lantern from the terrain.png... Any ideas?
yeah, that's what i meant. could someone PLEASE tell me. I can't find it.
Check out my mods at http://www.minecraftforum.net/topic/463113-17-03colorcraft-fencesmodloader/
Let me rephrase my question. If i want to add a texture override, do i make the folder in the /temp version of the minecraft folder?
Check out my mods at http://www.minecraftforum.net/topic/463113-17-03colorcraft-fencesmodloader/