TristanvO Posted April 9, 2016 Share Posted April 9, 2016 Hey title says my problem here are my files: WorldGenTree.java: http://pastebin.com/ztaUNXAD Log.java: http://pastebin.com/w6MC9T92 Leaf.java: http://pastebin.com/U0itrj7v Sapling.java: http://pastebin.com/KJAmcs60 Main.java http://pastebin.com/ezFaQeAq I hope somebody can help! I've been trying for days. Link to comment Share on other sites More sharing options...
Bektor Posted April 9, 2016 Share Posted April 9, 2016 First, please enable Syntax Highlighting "Java" when posting your code on pastebin. Secondly: Java name conventions: http://www.oracle.com/technetwork/java/codeconventions-135099.html Third: I would suggest to update your mappings in the build.gradle because there are so many func_ methods. To your problem: Object object = p_149878_5_.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true); You are using "WorldGenBigTree" and "WorldGenTrees" in your sapling class instead of your own Tree: "WorldGenMangoTree". That's why the vanilla oak tree is spawning. I hope this helps you. Bektor Developer of Primeval Forest. Link to comment Share on other sites More sharing options...
TristanvO Posted April 9, 2016 Author Share Posted April 9, 2016 First, please enable Syntax Highlighting "Java" when posting your code on pastebin. Secondly: Java name conventions: http://www.oracle.com/technetwork/java/codeconventions-135099.html Third: I would suggest to update your mappings in the build.gradle because there are so many func_ methods. To your problem: Object object = p_149878_5_.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true); You are using "WorldGenBigTree" and "WorldGenTrees" in your sapling class instead of your own Tree: "WorldGenMangoTree". That's why the vanilla oak tree is spawning. I hope this helps you. Bektor Thank you a lot for helping but it didn't solve the problem: I have done this: Object object = p_149878_5_.nextInt(10) == 0 ? new WorldGenMangoTree(mod.mangoLog, mod.mangoLeaf, 0, 0, false, 7, 15, false) : new WorldGenMangoTree(mod.mangoLog, mod.mangoLeaf, 0, 0, false, 7, 15, false); Now when I use bonemeal a few times and when it's supposed to grow, my game crashes. Maybe this causes a problem?: switch (l) { case 0: break; case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; default: break; Thanks again! Link to comment Share on other sites More sharing options...
Bektor Posted April 9, 2016 Share Posted April 9, 2016 Then there are some errors in your code. Could you please upload your code with syntax highlighting for Java. And change this: generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) growVines(World p_76529_1_, int p_76529_2_, int p_76529_3_, int p_76529_4_, int p_76529_5_) colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_) removeLeaves(World p_150126_1_, int p_150126_2_, int p_150126_3_, int p_150126_4_) quantityDropped(Random p_149745_1_) getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_) func_150124_c(World p_150124_1_, int p_150124_2_, int p_150124_3_, int p_150124_4_, int p_150124_5_, int p_150124_6_) {} harvestBlock(World p_149636_1_, EntityPlayer p_149636_2_, int p_149636_3_, int p_149636_4_, int p_149636_5_, int p_149636_6_) damageDropped(int p_149692_1_) etc. to more usefull names. This means also you have to change the parameter names in the method body. (if you are using eclipse there is a function to replace names) Here is an example: generate(World world, Random random, int posX, int posY, int posZ) growVines(World world, int posX, int posY, int posZ, int whatIsThis) colorMultiplier(IBlockAccess blockAccess, int posX, int posY, int posZ) breakBlock(World world, int posX, int posY, int posZ, Block block, int whatIsThis) updateTick(World world, int posX, int posY, int posZ, Random random) randomDisplayTick(World world, int posX, int posY, int posZ, Random random) removeLeaves(World world, int posX, int posY, int posZ) quantityDropped(Random random) getItemDropped(int whatIsThis, Random random, int whatIsThis2) This makes it possible to easily read your code and find the problem and helps everyone who wants to help you alot and helps you also while programming. Then add informations like Minecraft version, Forge version, full crash log (use pastebin for this). Without this it will be really hard or impossible to find your problem. Bektor Developer of Primeval Forest. Link to comment Share on other sites More sharing options...
TristanvO Posted April 9, 2016 Author Share Posted April 9, 2016 First, please enable Syntax Highlighting "Java" when posting your code on pastebin. Secondly: Java name conventions: http://www.oracle.com/technetwork/java/codeconventions-135099.html Third: I would suggest to update your mappings in the build.gradle because there are so many func_ methods. To your problem: Object object = p_149878_5_.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true); You are using "WorldGenBigTree" and "WorldGenTrees" in your sapling class instead of your own Tree: "WorldGenMangoTree". That's why the vanilla oak tree is spawning. I hope this helps you. Bektor I'm using Minecraft version 1.7.10. I'm using Forge 1.7.10-10.13.4.1558-1.7.10-src. I didn't manage to use understandable variables for every function. Sorry for that . It took a while for all the codes but here they are: main.java: http://pastebin.com/FjeENkjs mangoLog.java: http://pastebin.com/zjd6Ev61 mangoLeaf.java: http://pastebin.com/ARN19Mth mangoSapling.java: http://pastebin.com/mzfgFhfY Reference.java: http://pastebin.com/VeAQSjYk WorldGenMangoTree.java: http://pastebin.com/bwdA4wc0 CrashLog: http://pastebin.com/X30TTmPg I hope this makes it clear now and I hope you can help me! Thanks! Link to comment Share on other sites More sharing options...
Bektor Posted April 9, 2016 Share Posted April 9, 2016 So the problem is a java.lang.ClassCastException. Here (WorldGenMangoTree.java:102) you are trying to cast your mangoSapling into a BlockSapling, but this is not possible so the Game is crashing. Your mangoSapling is a sub class from BlockBush because you extend from BlockBush. You can try to change the casting to your mangoSapling, BlockBush or you change the extends. So that mangoSapling becomes a sub class for the super class BlockSapling. That should work. It's ok that you was not able to find everywhere understandable names, it comes with the experience and time and in Minecraft versions like 1.8.9 it's easier, because there it's already mostly done for you. Just a few more tipps: func_149853_b(World world, Random random, int par3, int par4, int par5) --> for this example, even if you know how the method name would be, don't change it if the method is overriden in your class. Second: use over overriden methods this annotation: @Override It gives you an error when the method changes for example with Minecraft 1.8.x. Bektor Developer of Primeval Forest. Link to comment Share on other sites More sharing options...
TristanvO Posted April 9, 2016 Author Share Posted April 9, 2016 So the problem is a java.lang.ClassCastException. Here (WorldGenMangoTree.java:102) you are trying to cast your mangoSapling into a BlockSapling, but this is not possible so the Game is crashing. Your mangoSapling is a sub class from BlockBush because you extend from BlockBush. You can try to change the casting to your mangoSapling, BlockBush or you change the extends. So that mangoSapling becomes a sub class for the super class BlockSapling. That should work. It's ok that you was not able to find everywhere understandable names, it comes with the experience and time and in Minecraft versions like 1.8.9 it's easier, because there it's already mostly done for you. Just a few more tipps: func_149853_b(World world, Random random, int par3, int par4, int par5) --> for this example, even if you know how the method name would be, don't change it if the method is overriden in your class. Second: use over overriden methods this annotation: @Override It gives you an error when the method changes for example with Minecraft 1.8.x. Bektor Thanks a lot! I changed the casting: (BlockSapling) to (IPlantable) and now it works! Right off when the tree spawned, I saw leaves starting to decay while the wood logs were still there? Got a quick solution for that too maybe? Thanks a lot again! Link to comment Share on other sites More sharing options...
TristanvO Posted April 9, 2016 Author Share Posted April 9, 2016 Never mind, I think. I'm going to try to add a "cansustainleaves". I hope this is going to work! Link to comment Share on other sites More sharing options...
TristanvO Posted April 9, 2016 Author Share Posted April 9, 2016 It's working fine! Thanks! I'll close this topic now! Link to comment Share on other sites More sharing options...
Recommended Posts