Jump to content

Custom sapling spawning oak tree instead of custom tree.


TristanvO

Recommended Posts

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

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

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

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

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

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

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Instale el mod en mi servidor y este se queda iniciando por horas, en la consola me habla de algo de permisos y trate de seguir la ruta que me da pero no existe.   [13:05:32 INFO]: CustomNPC Permissions available: [13:05:32 INFO]: customnpcs.edit.blocks [13:05:32 INFO]: customnpcs.edit.villager [13:05:32 INFO]: customnpcs.global.bank [13:05:32 INFO]: customnpcs.global.dialog [13:05:32 INFO]: customnpcs.global.faction [13:05:32 INFO]: customnpcs.global.linked [13:05:32 INFO]: customnpcs.global.naturalspawn [13:05:32 INFO]: customnpcs.global.playerdata [13:05:32 INFO]: customnpcs.global.quest [13:05:32 INFO]: customnpcs.global.recipe [13:05:32 INFO]: customnpcs.global.transport [13:05:32 INFO]: customnpcs.npc.advanced [13:05:32 INFO]: customnpcs.npc.ai [13:05:32 INFO]: customnpcs.npc.clone [13:05:32 INFO]: customnpcs.npc.create [13:05:32 INFO]: customnpcs.npc.delete [13:05:32 INFO]: customnpcs.npc.display [13:05:32 INFO]: customnpcs.npc.freeze [13:05:32 INFO]: customnpcs.npc.gui [13:05:32 INFO]: customnpcs.npc.inventory [13:05:32 INFO]: customnpcs.npc.reset [13:05:32 INFO]: customnpcs.npc.stats [13:05:32 INFO]: customnpcs.scenes [13:05:32 INFO]: customnpcs.soulstone.all [13:05:32 INFO]: customnpcs.spawner.create [13:05:32 INFO]: customnpcs.spawner.mob [13:05:32 INFO]: customnpcs.tool.mounter [13:05:32 INFO]: customnpcs.tool.nbtbook [13:05:32 INFO]: customnpcs.tool.pather [13:05:32 INFO]: customnpcs.tool.scripter
    • I have created a very simple mod that is just supposed to send a message to a player when they join. Upon adding it to a server (that has other mods on it), the following crash message appears: [12:13:01] [main/ERROR] [minecraft/Main]: Failed to start the minecraft server net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [         Epic Mod (epicmod) has failed to load correctly §7java.lang.NoSuchMethodException: net.ed.epicmod.EpicMod.<init>() ]         at net.minecraftforge.fml.ModLoader.waitForTransition(ModLoader.java:243) ~[fmlcore-1.19.2-43.2.14.jar%23548!/:?] {}         at net.minecraftforge.fml.ModLoader.lambda$dispatchAndHandleError$24(ModLoader.java:208) ~[fmlcore-1.19.2-43.2.14.jar%23548!/:?] {}         at java.util.Optional.ifPresent(Optional.java:178) ~[?:?] {re:mixin}         at net.minecraftforge.fml.ModLoader.dispatchAndHandleError(ModLoader.java:208) ~[fmlcore-1.19.2-43.2.14.jar%23548!/:?] {}         at net.minecraftforge.fml.ModLoader.lambda$gatherAndInitializeMods$14(ModLoader.java:185) ~[fmlcore-1.19.2-43.2.14.jar%23548!/:?] {}         at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] {re:mixin,re:computing_frames}         at net.minecraftforge.fml.ModLoader.gatherAndInitializeMods(ModLoader.java:185) ~[fmlcore-1.19.2-43.2.14.jar%23548!/:?] {}         at net.minecraftforge.server.loading.ServerModLoader.load(ServerModLoader.java:32) ~[forge-1.19.2-43.2.14-universal.jar%23552!/:?] {re:classloading}         at net.minecraft.server.Main.main(Main.java:113) ~[server-1.19.2-20220805.130853-srg.jar%23547!/:?] {re:classloading,re:mixin,pl:mixin:A}         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}         at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}         at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}         at net.minecraftforge.fml.loading.targets.CommonServerLaunchHandler.lambda$launchService$0(CommonServerLaunchHandler.java:29) ~[fmlloader-1.19.2-43.2.14.jar%2367!/:?] {}         at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30) [modlauncher-10.0.8.jar%2354!/:?] {}         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-10.0.8.jar%2354!/:?] {}         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-10.0.8.jar%2354!/:?] {}         at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-10.0.8.jar%2354!/:?] {}         at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-10.0.8.jar%2354!/:?] {}         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-10.0.8.jar%2354!/:?] {}         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-10.0.8.jar%2354!/:?] {}         at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141) [bootstraplauncher-1.1.2.jar:?] {} Why could this be? I have tried using the mod on another forge server with only this mod installed and it works there. Is my mod somehow interfering with other mods? MC version is 1.19.2
    • how to make animated doors?, maybe geckolib, but i don't know how to code it?
    • For crash 1, set max-tick-time to -1 in your server.properties Crash 2 shows a conflict or incompatibility between LuckPerms and the mod boh-0.0.6.1-forge-1.20.1_2.jar
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.