Well, I got it to work for me, here is what I did. Instead of using mod_Namehere.BlockNamehere.blockId, I passed in the idBlockNamehere int defined by the properties file (not the blockId, not sure but I couldn't figure out how to use the blockId)
Example of the WorldGenMulberryTrees.java with passing in the idMulberryLeaves:
package net.minecraft.src;
import java.io.*;
import java.util.Map;
import java.util.Random;
import net.minecraft.client.Minecraft;
public class mod_PaperCraft extends BaseMod
{
public static Block cardboardBox;
public static Block present;
public static Block mulberryLeaves;
public static Item brownPaper;
public static Item paperBag;
public static Item dollar;
public static Item cardboard;
public static Item helmetAO;
public static Item chestplateAO;
public static Item legsAO;
public static Item bootsAO;
public static Item mulberryLeaf;
public static Item paperMulberry;
public static Item helmetPM;
public static Item chestplatePM;
public static Item legsPM;
public static Item bootsPM;
public static int idCardboardBox;
public static int idPresent;
public static int idMulberryLeaves;
public static int idBrownPaper;
public static int idPaperBag;
public static int idMoney;
public static int idCardboard;
public static int idHelmetAO;
public static int idChestplateAO;
public static int idLegsAO;
public static int idBootsAO;
public static int idMulberryLeaf;
public static int idPaperMulberry;
public static int idHelmetPM;
public static int idChestplatePM;
public static int idLegsPM;
public static int idBootsPM;
public static int defaultCardboardBox = 158;
public static int defaultPresent = 159;
public static int defaultMulberryLeaves = 157;
public static int defaultBrownPaper = 7100;
public static int defaultPaperBag = 7101;
public static int defaultMoney = 7102;
public static int defaultCardboard = 7103;
public static int defaultHelmetAO = 7104;
public static int defaultChestplateAO = 7105;
public static int defaultLegsAO = 7106;
public static int defaultBootsAO = 7107;
public static int defaultMulberryLeaf = 7108;
public static int defaultPaperMulberry = 7109;
public static int defaultHelmetPM = 7110;
public static int defaultChestplatePM = 7111;
public static int defaultLegsPM = 7112;
public static int defaultBootsPM = 7113;
public String Version()
{
return "0.5";
}
public mod_PaperCraft()
{
PaperCraftProperties papercraftproperties = new PaperCraftProperties();
try
{
File file = new File((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/PaperCraft.properties").toString());
boolean flag = file.createNewFile();
if(flag)
{
FileOutputStream fileoutputstream = new FileOutputStream(file);
papercraftproperties.setProperty("idCardboardBox", Integer.toString(defaultCardboardBox));
papercraftproperties.setProperty("idPresent", Integer.toString(defaultPresent));
papercraftproperties.setProperty("idMulberryLeaves", Integer.toString(defaultMulberryLeaves));
papercraftproperties.setProperty("idBrownPaper", Integer.toString(defaultBrownPaper));
papercraftproperties.setProperty("idPaperBag", Integer.toString(defaultPaperBag));
papercraftproperties.setProperty("idMoney", Integer.toString(defaultMoney));
papercraftproperties.setProperty("idCardboard", Integer.toString(defaultCardboard));
papercraftproperties.setProperty("idMulberryLeaf", Integer.toString(defaultMulberryLeaf));
papercraftproperties.setProperty("idPaperMulberry", Integer.toString(defaultPaperMulberry));
papercraftproperties.setProperty("idHelmetAO", Integer.toString(defaultHelmetAO));
papercraftproperties.setProperty("idChestplateAO", Integer.toString(defaultChestplateAO));
papercraftproperties.setProperty("idLegsAO", Integer.toString(defaultLegsAO));
papercraftproperties.setProperty("idBootsAO", Integer.toString(defaultBootsAO));
papercraftproperties.setProperty("idHelmetPM", Integer.toString(defaultHelmetPM));
papercraftproperties.setProperty("idChestplatePM", Integer.toString(defaultChestplatePM));
papercraftproperties.setProperty("idLegsPM", Integer.toString(defaultLegsPM));
papercraftproperties.setProperty("idBootsPM", Integer.toString(defaultBootsPM));
papercraftproperties.store(fileoutputstream, "In this file you can change the IDs of Blocks and Items.");
fileoutputstream.close();
}
papercraftproperties.load(new FileInputStream((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/PaperCraft.properties").toString()));
idCardboardBox = Integer.parseInt(papercraftproperties.getProperty("idCardboardBox"));
idPresent = Integer.parseInt(papercraftproperties.getProperty("idPresent"));
idMulberryLeaves = Integer.parseInt(papercraftproperties.getProperty("idMulberryLeaves"));
idBrownPaper = Integer.parseInt(papercraftproperties.getProperty("idBrownPaper"));
idPaperBag = Integer.parseInt(papercraftproperties.getProperty("idPaperBag"));
idMoney = Integer.parseInt(papercraftproperties.getProperty("idMoney"));
idCardboard = Integer.parseInt(papercraftproperties.getProperty("idCardboard"));
idMulberryLeaf = Integer.parseInt(papercraftproperties.getProperty("idMulberryLeaf"));
idPaperMulberry = Integer.parseInt(papercraftproperties.getProperty("idPaperMulberry"));
idHelmetAO = Integer.parseInt(papercraftproperties.getProperty("idHelmetAO"));
idChestplateAO = Integer.parseInt(papercraftproperties.getProperty("idChestplateAO"));
idLegsAO = Integer.parseInt(papercraftproperties.getProperty("idLegsAO"));
idBootsAO = Integer.parseInt(papercraftproperties.getProperty("idBootsAO"));
idHelmetPM = Integer.parseInt(papercraftproperties.getProperty("idHelmetAO"));
idChestplatePM = Integer.parseInt(papercraftproperties.getProperty("idChestplateAO"));
idLegsPM = Integer.parseInt(papercraftproperties.getProperty("idLegsPM"));
idBootsPM = Integer.parseInt(papercraftproperties.getProperty("idBootsPM"));
}
catch(IOException ioexception)
{
ioexception.printStackTrace();
}
Block cardboardBox = (new BlockCardboardBox(idCardboardBox, 0)).setHardness(1.0F).setResistance(2.0F).setBlockName("cardboardBox");
Block present = (new BlockPresent(idPresent, 0)).setHardness(1.0F).setResistance(2.0F).setBlockName("present");
Block mulberryLeaves = (new BlockMulberryLeaves(idMulberryLeaves, 0)).setHardness(0.2F).setResistance(1.0F).setBlockName("mulberryLeaves");
Item brownPaper = (new Item(idBrownPaper)).setItemName("brownPaper");
Item paperBag = (new ItemArmor(idPaperBag, 1, ModLoader.AddArmor("PaperBag"), 0)).setItemName("paperBag");
Item dollar = (new Item(idBrownPaper)).setItemName("dollar");
Item cardboard = (new Item(idCardboard)).setItemName("cardboard");
Item helmetAO = (new ItemArmor(idHelmetAO, 1, ModLoader.AddArmor("Awesome-O"), 0)).setItemName("helmetAO");
Item chestplateAO = (new ItemArmor(idChestplateAO, 1, ModLoader.AddArmor("Awesome-O"), 1)).setItemName("chestplateAO");
Item legsAO = (new ItemArmor(idLegsAO, 1, ModLoader.AddArmor("Awesome-O"), 2)).setItemName("legsAO");
Item bootsAO = (new ItemArmor(idBootsAO, 1, ModLoader.AddArmor("Awesome-O"), 3)).setItemName("bootsAO");
Item mulberryLeaf = (new Item(idMulberryLeaf)).setItemName("mulberryLeaf");
Item paperMulberry = (new Item(idPaperMulberry)).setItemName("paperMulberry");
Item helmetPM = (new ItemArmor(idHelmetPM, 1, ModLoader.AddArmor("PaperMulberry"), 0)).setItemName("helmetPM");
Item chestplatePM = (new ItemArmor(idChestplatePM, 1, ModLoader.AddArmor("PaperMulberry"), 1)).setItemName("chestplatePM");
Item legsPM = (new ItemArmor(idLegsPM, 1, ModLoader.AddArmor("PaperMulberry"), 2)).setItemName("legsPM");
Item bootsPM = (new ItemArmor(idBootsPM, 1, ModLoader.AddArmor("PaperMulberry"), 3)).setItemName("bootsPM");
cardboardBox.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Slymask3/PaperCraft/CB_Side.png");
present.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Slymask3/PaperCraft/Present_Side.png");
mulberryLeaves.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Slymask3/PaperCraft/MulberryLeaves.png");
brownPaper.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/BrownPaper.png");
paperBag.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/PaperBag.png");
dollar.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/Money.png");
cardboard.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/Cardboard.png");
helmetAO.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/HelmetAO.png");
chestplateAO.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/ChestplateAO.png");
legsAO.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/LegsAO.png");
bootsAO.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/BootsAO.png");
mulberryLeaf.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/MulberryLeaf.png");
paperMulberry.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/PaperMulberry.png");
helmetPM.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/HelmetPM.png");
chestplatePM.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/ChestplatePM.png");
legsPM.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/LegsPM.png");
bootsPM.iconIndex = ModLoader.addOverride("/gui/items.png", "/Slymask3/PaperCraft/BootsPM.png");
ModLoader.RegisterBlock(cardboardBox);
ModLoader.RegisterBlock(present);
ModLoader.RegisterBlock(mulberryLeaves);
ModLoader.AddName(brownPaper, "Brown Paper");
ModLoader.AddName(paperBag, "Paper Bag");
ModLoader.AddName(dollar, "Money");
ModLoader.AddName(cardboard, "Cardboard");
ModLoader.AddName(cardboardBox, "Cardboard Box");
ModLoader.AddName(helmetAO, "Awesome-O Helmet");
ModLoader.AddName(chestplateAO, "Awesome-O Chestplate");
ModLoader.AddName(legsAO, "Awesome-O Pants");
ModLoader.AddName(bootsAO, "Awesome-O Boots");
ModLoader.AddName(present, "Present");
ModLoader.AddName(mulberryLeaves, "Mulberry Leaves");
ModLoader.AddName(mulberryLeaf, "Mulberry Leaf");
ModLoader.AddName(paperMulberry, "Paper Mulberry");
ModLoader.AddName(helmetPM, "Paper Mulberry Helmet");
ModLoader.AddName(chestplatePM, "Paper Mulberry Chestplate");
ModLoader.AddName(legsPM, "Paper Mulberry Pants");
ModLoader.AddName(bootsPM, "Paper Mulberry Boots");
ModLoader.AddShapelessRecipe(new ItemStack(brownPaper, 1), new Object[] {new ItemStack(Item.dyePowder, 1, 3), new ItemStack(Item.paper, 1, 0)});
ModLoader.AddRecipe(new ItemStack(paperBag, 1), new Object[] {"XXX", "X X", Character.valueOf('X'), brownPaper});
ModLoader.AddShapelessRecipe(new ItemStack(dollar, 1), new Object[] {new ItemStack(Item.dyePowder, 1, 2), new ItemStack(Item.dyePowder, 1, 0), new ItemStack(Item.paper, 1, 0)});
ModLoader.AddRecipe(new ItemStack(paperBag, 1), new Object[] {"XXX", "X X", Character.valueOf('X'), brownPaper});
ModLoader.AddRecipe(new ItemStack(cardboard, 3), new Object[] {"XXX", "YYY", "XXX", Character.valueOf('X'), Item.paper, Character.valueOf('Y'), Block.planks});
ModLoader.AddRecipe(new ItemStack(cardboardBox, 1), new Object[] {"XXX", "X X", "XXX", Character.valueOf('X'), cardboard});
ModLoader.AddRecipe(new ItemStack(helmetAO, 1), new Object[] {"XXX", "X X", Character.valueOf('X'), cardboard});
ModLoader.AddRecipe(new ItemStack(chestplateAO, 1), new Object[] {"X X", "XXX", "XXX", Character.valueOf('X'), cardboard});
ModLoader.AddRecipe(new ItemStack(legsAO, 1), new Object[] {"XXX", "X X", "X X", Character.valueOf('X'), cardboard});
ModLoader.AddRecipe(new ItemStack(bootsAO, 1), new Object[] {"X X", "X X", Character.valueOf('X'), cardboard});
ModLoader.AddRecipe(new ItemStack(present, 1), new Object[] {"XXX", "XYX", "XXX", Character.valueOf('X'), Item.paper, Character.valueOf('Y'), cardboardBox});
ModLoader.AddRecipe(new ItemStack(paperMulberry, 1), new Object[] {"X", Character.valueOf('X'), mulberryLeaf});
ModLoader.AddRecipe(new ItemStack(helmetPM, 1), new Object[] {"XXX", "X X", Character.valueOf('X'), paperMulberry});
ModLoader.AddRecipe(new ItemStack(chestplatePM, 1), new Object[] {"X X", "XXX", "XXX", Character.valueOf('X'), paperMulberry});
ModLoader.AddRecipe(new ItemStack(legsPM, 1), new Object[] {"XXX", "X X", "X X", Character.valueOf('X'), paperMulberry});
ModLoader.AddRecipe(new ItemStack(bootsPM, 1), new Object[] {"X X", "X X", Character.valueOf('X'), paperMulberry});
}
public void GenerateSurface(World world, Random random, int i, int j)
{
BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(i, j);
WorldGenMulberryTrees worldgenmulberrytrees = new WorldGenMulberryTrees(idMulberryLeaves); // pass in 'idMulberryLeaves'
if((biomegenbase instanceof BiomeGenRainforest) || (biomegenbase instanceof BiomeGenForest))
{
int k = i + random.nextInt(16) + 8;
int l = j + random.nextInt(16) + 8;
int i1 = world.getHeightValue(k, l);
worldgenmulberrytrees.func_517_a(1.0D, 1.0D, 1.0D);
worldgenmulberrytrees.generate(world, random, k, i1, l);
}
// This is for generating a new ore, just fyi
for ( int b = 0; b < 8; b++ )
{
int posX = i + random.nextInt(16);
int posY = random.nextInt(30) + 30;
int posZ = j + random.nextInt(16);
(new WorldGenMinable(idBlockNamehere, 7)).generate(world, random, posX, posY, posZ); // Pass in 'idBlockNameHere' instead of using BlockNamehere.blockId
}
}
}
Doing it this way works for me at least. Let me know if it works for you. :smile.gif:
Thank you, I got it to work now, it generated and doesn't crash. :biggrin.gif:
But now, I have got a new problem. :ohmy.gif:
When I break a MulberryLeaves Block, it is supposed to give me a MulberryLeaf 25% of the time.
This worked before the whole propeties file.
Now it gives me a retarded error.
Error:
Mods loaded: 2
ModLoader Beta 1.7.3
net.minecraft.src.mod_PaperCraft 0.5
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem.
If you wish to report this, please copy this entire text and email it to [email protected].
Please include a description of what you did when the error occured.
--- BEGIN ERROR REPORT 81c52406 --------
Generated 02/08/11 12:05 AM
Minecraft: Minecraft Beta 1.7.3
OS: Windows 7 (x86) version 6.1
Java: 1.6.0_26, Sun Microsystems Inc.
VM: Java HotSpot(TM) Client VM (mixed mode), Sun Microsystems Inc.
LWJGL: 2.4.2
OpenGL: GeForce 8200M G/PCI/SSE2 version 3.2.0, NVIDIA Corporation
java.lang.NullPointerException
at net.minecraft.src.BlockMulberryLeaves.idDropped(BlockMulberryLeaves.java:28)
at net.minecraft.src.Block.dropBlockAsItemWithChance(Block.java:312)
at net.minecraft.src.Block.dropBlockAsItem(Block.java:296)
at net.minecraft.src.Block.harvestBlock(Block.java:555)
at net.minecraft.src.PlayerControllerSP.sendBlockRemoved(PlayerControllerSP.java:52)
at net.minecraft.src.PlayerControllerSP.sendBlockRemoving(PlayerControllerSP.java:100)
at net.minecraft.client.Minecraft.sendClickBlockToController(Minecraft.java:775)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1155)
at net.minecraft.client.Minecraft.run(Minecraft.java:480)
at java.lang.Thread.run(Unknown Source)
--- END ERROR REPORT ed3577ac ----------
Thanks to everyone who has helped me! :biggrin.gif:
@static_boy123 That's funny, I used to play Minecraft a lot untill I started modding. The only time I play now is when I record my Let's Play or other videos. :biggrin.gif:
Rollback Post to RevisionRollBack
Instant Blocks Mod - 17 new blocks that generate structures upon right-click. Includes: Farm, Rainbow Skydive, Grinder, Escape Ladder, Water, Lava, Suction, and Statue Blocks.
Thank you, I got it to work now, it generated and doesn't crash. :biggrin.gif:
But now, I have got a new problem. :ohmy.gif:
When I break a MulberryLeaves Block, it is supposed to give me a MulberryLeaf 25% of the time.
This worked before the whole propeties file.
Now it gives me a retarded error.
Error:
Mods loaded: 2
ModLoader Beta 1.7.3
net.minecraft.src.mod_PaperCraft 0.5
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem.
If you wish to report this, please copy this entire text and email it to [email protected].
Please include a description of what you did when the error occured.
--- BEGIN ERROR REPORT 81c52406 --------
Generated 02/08/11 12:05 AM
Minecraft: Minecraft Beta 1.7.3
OS: Windows 7 (x86) version 6.1
Java: 1.6.0_26, Sun Microsystems Inc.
VM: Java HotSpot(TM) Client VM (mixed mode), Sun Microsystems Inc.
LWJGL: 2.4.2
OpenGL: GeForce 8200M G/PCI/SSE2 version 3.2.0, NVIDIA Corporation
java.lang.NullPointerException
at net.minecraft.src.BlockMulberryLeaves.idDropped(BlockMulberryLeaves.java:28)
at net.minecraft.src.Block.dropBlockAsItemWithChance(Block.java:312)
at net.minecraft.src.Block.dropBlockAsItem(Block.java:296)
at net.minecraft.src.Block.harvestBlock(Block.java:555)
at net.minecraft.src.PlayerControllerSP.sendBlockRemoved(PlayerControllerSP.java:52)
at net.minecraft.src.PlayerControllerSP.sendBlockRemoving(PlayerControllerSP.java:100)
at net.minecraft.client.Minecraft.sendClickBlockToController(Minecraft.java:775)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1155)
at net.minecraft.client.Minecraft.run(Minecraft.java:480)
at java.lang.Thread.run(Unknown Source)
--- END ERROR REPORT ed3577ac ----------
Thanks to everyone who has helped me! :biggrin.gif:
@static_boy123 That's funny, I used to play Minecraft a lot untill I started modding. The only time I play now is when I record my Let's Play or other videos. :biggrin.gif:
I ran into that too. It's along the same error as the previous one with generating the trees/ores.
Essentially, you need to reference the Property ID, but on my last test, it still crashed. So what I have been doing is illustrated below:
for(int l = 0; l < 15; l++)
{
int randPosX = chunkX + rand.nextInt(16);
int randPosY = rand.nextInt(100);
int randPosZ = chunkZ + rand.nextInt(16);
(new WorldGenMinable(Block.mobSpawner.blockID, 4)).generate(world, rand, randPosX, randPosY, randPosZ);
}
That's the part where it says to generate the spawner. It is not too common, and with this code it is only generated into stone. I am curious to your code to see what you did to make it sky high and such.
Ahaha I totally skipped over this part of your post. I was still waiting for your reply :happy.gif:;
While i was 'waiting' I put together a little mod that generates Spawners for both Hostile and Friendly Mobs. Hostile Spawners are all underground and generate a 5x5x5 room and hang from the top center. Friendly Spawners just spawn on grass above ground.
Link: Mod: More Spawners
Anyway, here is the basics. Like I said before, I had messed with the dungeon code at one point, so I used that as my starting point again, rather than using WorldGenMinable.
Instead of going through it step by step, here is just an overview of the final code to do the spawning with notes/comments:
package net.minecraft.src;
import java.io.*;
import java.util.Map;
import java.util.Random;
import net.minecraft.client.Minecraft;
public class mod_MoreSpawners extends BaseMod
{
public String Version()
{
return "More Spawners v0.1 - Minecraft 1.7.3 compatible";
}
public mod_MoreSpawners()
{
}
public void GenerateSurface(World world, Random random, int i, int j)
{
for(int a = 0; a < 1; a++) // If you install the mod and view it with xRay, you could see that even with 1, it spawns pretty a decent amount
{
int posX = i + random.nextInt(16);
int posY = random.nextInt(35)+15; // Spawns the Hostile Spawners from levels 15 - 50 (15+35=50)
int posZ = j + random.nextInt(16);
String mobType;
int x = random.nextInt(2); // In fact, I had to limit it a lot because 1 was too much, so now its roughly 0.33
if(x == 0)
{
// Calls my function to make sure the chosen block isn't in water and makes sure it has a solid block beneath it
if(checkBlockSides(world, posX, posY, posZ) != 3 && world.getBlockMaterial(posX, posY-1, posZ).isSolid())
{
// We dont want a Hostile mob spawner visible to the sky, or they burn :smile.gif:
if(!world.canBlockSeeTheSky(posX, posY, posZ))
{
// Makes sure that we are spawning a Hostile mob spawner
if(checkBlockSides(world, posX, posY, posZ) == 4)
{
for(int b = 0; b < 5; b++)
{
// These following lines create the 5x5x5 room by replacing the blocks with air ("0")
world.setBlockWithNotify(posX+2, posY+b, posZ, 0);
world.setBlockWithNotify(posX+2, posY+b, posZ+1, 0);
world.setBlockWithNotify(posX+2, posY+b, posZ-1, 0);
world.setBlockWithNotify(posX+2, posY+b, posZ+2, 0);
world.setBlockWithNotify(posX+2, posY+b, posZ-2, 0);
world.setBlockWithNotify(posX+1, posY+b, posZ, 0);
world.setBlockWithNotify(posX+1, posY+b, posZ+1, 0);
world.setBlockWithNotify(posX+1, posY+b, posZ-1, 0);
world.setBlockWithNotify(posX+1, posY+b, posZ+2, 0);
world.setBlockWithNotify(posX+1, posY+b, posZ-2, 0);
world.setBlockWithNotify(posX, posY+b, posZ, 0);
world.setBlockWithNotify(posX, posY+b, posZ+1, 0);
world.setBlockWithNotify(posX, posY+b, posZ-1, 0);
world.setBlockWithNotify(posX, posY+b, posZ+2, 0);
world.setBlockWithNotify(posX, posY+b, posZ-2, 0);
world.setBlockWithNotify(posX-1, posY+b, posZ, 0);
world.setBlockWithNotify(posX-1, posY+b, posZ+1, 0);
world.setBlockWithNotify(posX-1, posY+b, posZ-1, 0);
world.setBlockWithNotify(posX-1, posY+b, posZ+2, 0);
world.setBlockWithNotify(posX-1, posY+b, posZ-2, 0);
world.setBlockWithNotify(posX-2, posY+b, posZ, 0);
world.setBlockWithNotify(posX-2, posY+b, posZ+1, 0);
world.setBlockWithNotify(posX-2, posY+b, posZ-1, 0);
world.setBlockWithNotify(posX-2, posY+b, posZ+2, 0);
world.setBlockWithNotify(posX-2, posY+b, posZ-2, 0);
}
// Place the Spawner in the specified spot+4 (which puts it on the ceiling instead)
world.setBlockWithNotify(posX, posY+4, posZ, Block.mobSpawner.blockID);
//This grabs the same Spawner and assignes it to a BlockTileEntity so we can manipulate it
TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(posX, posY+4, posZ);
// Picks a random mob for the Spawner
mobType = pickHostileMobSpawner(random);
// Sets the mob for the Spawner
tileentitymobspawner.setMobID(mobType);
}
} else
{
}
}
} else
{
}
}
for(int a = 0; a < 9; a++)
{
// Pretty much the same as before, just modified for Friendly Spawners
int posX = i + random.nextInt(16);
int posY = random.nextInt(45)+60; // Spawnable from levels 60-105
int posZ = j + random.nextInt(16);
String mobType;
// We need to make sure its not in water and its on solid ground
if(checkBlockSides(world, posX, posY, posZ) != 3 && world.getBlockMaterial(posX, posY-1, posZ).isSolid())
{
// Now we make sure its on/around grass and is visible to the sky
if(checkBlockSides(world, posX, posY, posZ) == 2 && world.canBlockSeeTheSky(posX, posY, posZ))
{
// Same as before, except I'm not messing with the posY, and it picks a Friendly mob vs a Hostile mob
world.setBlockWithNotify(posX, posY, posZ, Block.mobSpawner.blockID);
TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(posX, posY, posZ);
mobType = pickFriendlyMobSpawner(random);
tileentitymobspawner.setMobID(mobType);
} else
{
}
}
}
}
// My Custom Function to check surrounding block types. Don't steal it :biggrin.gif: (Not that I really care, it just needs to be optimized better?)
public int checkBlockSides(World world, int posX, int posY, int posZ)
{
if(world.getBlockId(posX-1, posY, posZ) == 9 || world.getBlockId(posX+1, posY, posZ) == 9 || world.getBlockId(posX, posY, posZ-1) == 9 || world.getBlockId(posX, posY, posZ+1) == 9 || world.getBlockId(posX-1, posY-1, posZ) == 9 || world.getBlockId(posX+1, posY-1, posZ) == 9 || world.getBlockId(posX, posY-1, posZ-1) == 9 || world.getBlockId(posX, posY-1, posZ+1) == 9 || world.getBlockId(posX-1, posY-1, posZ-1) == 9 || world.getBlockId(posX-1, posY-1, posZ+1) == 9 || world.getBlockId(posX+1, posY-1, posZ-1) == 9 || world.getBlockId(posX+1, posY-1, posZ+1) == 9 || world.getBlockId(posX-1, posY+1, posZ) == 9 || world.getBlockId(posX+1, posY+1, posZ) == 9 || world.getBlockId(posX, posY+1, posZ-1) == 9 || world.getBlockId(posX, posY+1, posZ+1) == 9 || world.getBlockId(posX-1, posY+1, posZ-1) == 9 || world.getBlockId(posX-1, posY+1, posZ+1) == 9 || world.getBlockId(posX+1, posY+1, posZ-1) == 9 || world.getBlockId(posX+1, posY+1, posZ+1) == 9)
{
return 3; // Doesn't spawn on/in/around water
}
if(world.getBlockId(posX-1, posY-1, posZ) == 2 || world.getBlockId(posX+1, posY-1, posZ) == 2 || world.getBlockId(posX, posY-1, posZ-1) == 2 || world.getBlockId(posX, posY-1, posZ+1) == 2 || world.getBlockId(posX-1, posY-1, posZ-1) == 2 || world.getBlockId(posX-1, posY-1, posZ+1) == 2 || world.getBlockId(posX+1, posY-1, posZ-1) == 2 || world.getBlockId(posX+1, posY-1, posZ+1) == 2)
{
return 2; // This gets an OK for Friendly Spawners // Checks for immediate surrounding Stone
}
if(world.getBlockId(posX-1, posY-1, posZ) == 1 || world.getBlockId(posX+1, posY-1, posZ) == 1 || world.getBlockId(posX, posY-1, posZ-1) == 1 || world.getBlockId(posX, posY-1, posZ+1) == 1 || world.getBlockId(posX-1, posY-1, posZ-1) == 1 || world.getBlockId(posX-1, posY-1, posZ+1) == 1 || world.getBlockId(posX+1, posY-1, posZ-1) == 1 || world.getBlockId(posX+1, posY-1, posZ+1) == 1)
{
return 4; // This gets an OK for Hostile Spawners // Checks for immediate surrounding Grass
} else
{
return 3; // If all else fails, don't create a Spawner. if you removed this as well as another line, the Spawners would spawn EVERYWHERE
}
}
private String pickHostileMobSpawner(Random random)
{
int i = random.nextInt(7);
if(i == 0)
{
return "Skeleton";
}
if(i == 1)
{
return "PigZombie";
}
if(i == 2)
{
return "Creeper";
}
if(i == 3)
{
return "Spider";
} else
{
return "Zombie";
}
}
private String pickFriendlyMobSpawner(Random random)
{
int i = random.nextInt(7);
if(i == 0)
{
return "Wolf";
}
if(i == 1)
{
return "Pig";
}
if(i == 2)
{
return "Cow";
}
if(i == 3)
{
return "Chicken";
} else
{
return "Sheep";
}
}
}
I think I might package this up a bit more and release it as my first published mod. :smile.gif:
I tried it, and now it's giving me another error, when I destroy the block 25% of the time.
Error:
Mods loaded: 2
ModLoader Beta 1.7.3
net.minecraft.src.mod_PaperCraft 0.5
Minecraft has crashed!
----------------------
Minecraft has stopped running because it encountered a problem.
If you wish to report this, please copy this entire text and email it to [email protected].
Please include a description of what you did when the error occured.
--- BEGIN ERROR REPORT 81c52406 --------
Generated 02/08/11 9:04 AM
Minecraft: Minecraft Beta 1.7.3
OS: Windows 7 (x86) version 6.1
Java: 1.6.0_26, Sun Microsystems Inc.
VM: Java HotSpot(TM) Client VM (mixed mode), Sun Microsystems Inc.
LWJGL: 2.4.2
OpenGL: GeForce 8200M G/PCI/SSE2 version 3.2.0, NVIDIA Corporation
java.lang.NullPointerException
at net.minecraft.src.ItemStack.getIconIndex(ItemStack.java:72)
at net.minecraft.src.RenderItem.doRenderItem(RenderItem.java:77)
at net.minecraft.src.RenderItem.doRender(RenderItem.java:255)
at net.minecraft.src.RenderManager.renderEntityWithPosYaw(RenderManager.java:134)
at net.minecraft.src.RenderManager.renderEntity(RenderManager.java:125)
at net.minecraft.src.RenderGlobal.renderEntities(RenderGlobal.java:307)
at net.minecraft.src.EntityRenderer.renderWorld(EntityRenderer.java:567)
at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer.java:430)
at net.minecraft.src.EntityRendererProxy.updateCameraAndRender(EntityRendererProxy.java:23)
at net.minecraft.client.Minecraft.run(Minecraft.java:514)
at java.lang.Thread.run(Unknown Source)
--- END ERROR REPORT e5c54e7f ----------
Rollback Post to RevisionRollBack
Instant Blocks Mod - 17 new blocks that generate structures upon right-click. Includes: Farm, Rainbow Skydive, Grinder, Escape Ladder, Water, Lava, Suction, and Statue Blocks.
I managed to create a working mod. Though, I modified your code (I just want to spawn them randomly, completely randomly so you can be surprised by an arrow in your back) and in the end I got this code:
for(int a = 0; a < 10; a++)
{
int posX = chunkX + rand.nextInt(16);
int posY = rand.nextInt(100);
String mobType;
int x = rand.nextInt(3);
}
}
private String pickHostileMobSpawner(Random rand)
{
int i = rand.nextInt(7);
if(i == 0)
{
return "Skeleton";
}
if(i == 1)
{
return "PigZombie";
}
if(i == 2)
{
return "Creeper";
}
if(i == 3)
{
return "Spider";
} else
{
return "Zombie";
}
}
}
However, when I generate a world, no spawners are created. What did I do wrong?
Thanks in advance!
You can use it as an example, yes. :smile.gif: And with the code you just posted, you aren't *actually* generating anything. See this code:
for(int a = 0; a < 10; a++)
{
int posX = chunkX + rand.nextInt(16);
int posY = rand.nextInt(100);
int posZ = chunkZ + random.nextInt(16); // Assuming you have a chunkZ (You need all three choordinates: X,Y,Z
String mobType;
int x = rand.nextInt(3);
if(x == 0)
{
if(world.getBlockMaterial(posX, posY-1, posZ).isSolid() && !world.canBlockSeeTheSky(posX, posY, posZ)) //So it spawns on solid ground, not in the sky
{
//(new WorldGenMinable(Block.mobSpawner.blockID, 1)).generate(world, rand, posX, posY, posZ); // You *might* be able to use this, instead of world.setBlockWithNotify, but you can't use both.
//world.setBlockWithNotify(posX, posY, posZ, Block.mobSpawner.blockID); // This actually creates the Spawner, use either this line or the one above, they probably do the same thing.
TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getBlockTileEntity(posX, posY, posZ); // This grabs it so we can modify it, to set the mob type
tileentitymobspawner.setMobID(pickHostileMobSpawner(random)); // This calls pickHostileMobSpawner to set the mob type
} else
{
}
}
}
// All this does is return a random String when it is called. It doesn't actually set the Spawners mob type or create the spawner
private String pickHostileMobSpawner(Random rand)
{
int i = rand.nextInt(7);
if(i == 0)
{
return "Skeleton";
}
if(i == 1)
{
return "PigZombie";
}
if(i == 2)
{
return "Creeper";
}
if(i == 3)
{
return "Spider";
} else
{
return "Zombie";
}
}
Hmm, that indeed does look a lot better as my version...
I'll look into it tomorrow since I'm getting an error, but it's late and I have to get up early tomorrow...
Yeah, it's quite a simple one, I've dealed with this before, but I'm tired, I'll look at it myself tomorrow.
(Hopefully my book for learning object orientated Java will arrive soon...)
Goodnight world!
I forget about timezones, its afternoon here :smile.gif:
I'm assuming that you have the "private String pickHostileMobSpawner" inside your GenerateSurface? It needs to be outside of the GenerateSurface function:
public void GenerateSurface(World world, int i, int j, int k)
{
// Blah blah blah
}
private String pickHostileMobSpawner(String s)
{
// More Blah blah blah
}
ModLoader.AddRecipe(new ItemStack(Block.planks, 4), new Object[] {
What do I do if I want to link it to a custom block?
Lets say your mod file is named mod_Awesome.java
To link it to a custom block, you first have to define it in your mod like so:
// Only if you have created a BlockAwesome.java, elsewise you can just use Block
public static Block awesome = new BlockAwesome(123, 0).setHardness(0.7F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("copperOreawesome");
To then use it in a recipe:
//note it is just 'awesome' if used within your mod_Awesome.java file, because that is where it is defined. Otherwise it should be 'mod_Awesome.awesome'
ModLoader.AddRecipe(new ItemStack(awesome, 4), new Object[] {
After finishing the 4 classes I need for a custom tree. I did get some unknown to me, errors. If anyone to tell me how to fix them it would be great! Thanks. Please tell me if any more info needs to be posted.
Error 1:
Desc: The method onEntitywalking(world, int, int, int, Entity)is undefined for the type BlockLeavesBase.
public void onEntityWalking(World world, int i, int j, int k, Entity entity)
{
super.onEntitywalking(world, i, j, k, entity);
}
int adjacentTreeBlocks[];
private int baseIndexInPNG;
}
Error 2:
Desc: il cannot be resolved as a variable.
public void GenerateSurface(World world, Random random, int i, int j)
{
BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(i, j);
WorldGenMagicTrees worldgenmagictrees = new WorldGenMagicTrees();
if((biomegenbase instanceof BiomeGenRainforest) || (biomegenbase instanceof BiomeGenForest))
{
int k = i + random.nextInt(16) + 8;
int l = j + random.nextInt(16) + 8;
worldgenmagictrees.func_517_a(1.0D, 1.0D, 1.0D);
worldgenmagictrees.generate(world, random, k, il, 1);
}
}
To link it to a custom block, you first have to define it in your mod like so:
// Only if you have created a BlockAwesome.java, elsewise you can just use Block
public static Block awesome = new BlockAwesome(123, 0).setHardness(0.7F).setResistance(5F).setStepSound(Block.soundStoneFootstep).setBlockName("copperOreawesome");
To then use it in a recipe:
//note it is just 'awesome' if used within your mod_Awesome.java file, because that is where it is defined. Otherwise it should be 'mod_Awesome.awesome'
ModLoader.AddRecipe(new ItemStack(awesome, 4), new Object[] {
After finishing the 4 classes I need for a custom tree. I did get some unknown to me, errors. If anyone to tell me how to fix them it would be great! Thanks. Please tell me if any more info needs to be posted.
Error 1:
Desc: The method onEntitywalking(world, int, int, int, Entity)is undefined for the type BlockLeavesBase.
public void onEntityWalking(World world, int i, int j, int k, Entity entity)
{
super.onEntitywalking(world, i, j, k, entity);
}
int adjacentTreeBlocks[];
private int baseIndexInPNG;
}
Error 2:
Desc: il cannot be resolved as a variable.
public void GenerateSurface(World world, Random random, int i, int j)
{
BiomeGenBase biomegenbase = world.getWorldChunkManager().getBiomeGenAt(i, j);
WorldGenMagicTrees worldgenmagictrees = new WorldGenMagicTrees();
if((biomegenbase instanceof BiomeGenRainforest) || (biomegenbase instanceof BiomeGenForest))
{
int k = i + random.nextInt(16) + 8;
int l = j + random.nextInt(16) + 8;
worldgenmagictrees.func_517_a(1.0D, 1.0D, 1.0D);
worldgenmagictrees.generate(world, random, k, il, 1);
}
}
Error 1:
You have the second "onEntityWalking" misspelled. You need to capitalize the "W"
Error 2:
On the line:
worldgenmagictrees.generate(world, random, k, il, 1);
It should be:
worldgenmagictrees.generate(world, random, k, l, 1); // "l", not "il"
Error 1:
You have the second "onEntityWalking" misspelled. You need to capitalize the "W"
Error 2:
On the line:
worldgenmagictrees.generate(world, random, k, il, 1);
It should be:
worldgenmagictrees.generate(world, random, k, l, 1); // "l", not "il"
Second one worked! thanks, still having a different error now for the first:
Error 1:
Desc: Entity cannot be resolved to a variable
public void onEntityWalking(World world, int i, int j, int k, Entity entity)
{
super.onEntityWalking(world, i, j, k, Entity);
}
int adjacentTreeBlocks[];
private int baseIndexInPNG;
}
Second one worked! thanks, still having a different error now for the first:
Error 1:
Desc: Entity cannot be resolved to a variable
public void onEntityWalking(World world, int i, int j, int k, Entity entity)
{
super.onEntityWalking(world, i, j, k, Entity);
}
int adjacentTreeBlocks[];
private int baseIndexInPNG;
}
super.onEntityWalking(world, i, j, k, Entity);
should be:
super.onEntityWalking(world, i, j, k, entity); // You capitalized 'entity'
I followed the tree tutorial and every thing went great, except the leaves wouldn't decay and when I logged of and got back on all the trees disappeared,i could only find more in new chunks.
I Did it exactly like strength's example but i changed "namehere" to "MagicTree"
I followed the tree tutorial and every thing went great, except the leaves wouldn't decay and when I logged of and got back on all the trees disappeared,i could only find more in new chunks.
I Did it exactly like strength's example but i changed "namehere" to "MagicTree"
any one know what could have went wrong?
No idea but it sounds like you copied the name of my tree. Anyways I cant even find any of mine. And all the code is done. Where do I edit the spawning rate?
Same I've played less than 3 hours in total scince I started modding. :tongue.gif: Also I will check over the code and try it again tomorrow.
Thank you, I got it to work now, it generated and doesn't crash. :biggrin.gif:
But now, I have got a new problem. :ohmy.gif:
When I break a MulberryLeaves Block, it is supposed to give me a MulberryLeaf 25% of the time.
This worked before the whole propeties file.
Now it gives me a retarded error.
Error:
BlockMulberryLeaves.java
Thanks to everyone who has helped me! :biggrin.gif:
@static_boy123 That's funny, I used to play Minecraft a lot untill I started modding. The only time I play now is when I record my Let's Play or other videos. :biggrin.gif:
Instant Blocks Mod - 17 new blocks that generate structures upon right-click. Includes: Farm, Rainbow Skydive, Grinder, Escape Ladder, Water, Lava, Suction, and Statue Blocks.
I ran into that too. It's along the same error as the previous one with generating the trees/ores.
Essentially, you need to reference the Property ID, but on my last test, it still crashed. So what I have been doing is illustrated below:
Modified BlockMulberryLeaves.java
Ahaha I totally skipped over this part of your post. I was still waiting for your reply :happy.gif:;
While i was 'waiting' I put together a little mod that generates Spawners for both Hostile and Friendly Mobs. Hostile Spawners are all underground and generate a 5x5x5 room and hang from the top center. Friendly Spawners just spawn on grass above ground.
Link:
Mod: More Spawners
Anyway, here is the basics. Like I said before, I had messed with the dungeon code at one point, so I used that as my starting point again, rather than using WorldGenMinable.
Instead of going through it step by step, here is just an overview of the final code to do the spawning with notes/comments:
I think I might package this up a bit more and release it as my first published mod. :smile.gif:
I tried it, and now it's giving me another error, when I destroy the block 25% of the time.
Error:
Instant Blocks Mod - 17 new blocks that generate structures upon right-click. Includes: Farm, Rainbow Skydive, Grinder, Escape Ladder, Water, Lava, Suction, and Statue Blocks.
But i get this error when i try to recompile.
You can use it as an example, yes. :smile.gif: And with the code you just posted, you aren't *actually* generating anything. See this code:
I forget about timezones, its afternoon here :smile.gif:
I'm assuming that you have the "private String pickHostileMobSpawner" inside your GenerateSurface? It needs to be outside of the GenerateSurface function:
What do I do if I want to link it to a custom block?
Lets say your mod file is named mod_Awesome.java
To link it to a custom block, you first have to define it in your mod like so:
To then use it in a recipe:
Error 1:
Desc: The method onEntitywalking(world, int, int, int, Entity)is undefined for the type BlockLeavesBase.
Error 2:
Desc: il cannot be resolved as a variable.
Thankyou so much!
Error 1:
You have the second "onEntityWalking" misspelled. You need to capitalize the "W"
Error 2:
On the line:
worldgenmagictrees.generate(world, random, k, il, 1);
It should be:
worldgenmagictrees.generate(world, random, k, l, 1); // "l", not "il"
Second one worked! thanks, still having a different error now for the first:
Error 1:
Desc: Entity cannot be resolved to a variable
super.onEntityWalking(world, i, j, k, Entity);
should be:
super.onEntityWalking(world, i, j, k, entity); // You capitalized 'entity'
Thanks
Have you done the skin of the armor?
I Did it exactly like strength's example but i changed "namehere" to "MagicTree"
any one know what could have went wrong?
No idea but it sounds like you copied the name of my tree. Anyways I cant even find any of mine. And all the code is done. Where do I edit the spawning rate?
Everyone please go here:
http://www.minecraftforum.net/topic/523134-needcodehelp-a-new-tree/