Jump to content

Recommended Posts

Posted

Hi

 

I'm trying to make "Super Bonemeal" which grows all plants instantly.

I've got it working with vanilla crops, by just setting their age value to 7, but the way I have it right now it doesn't work for modded crops. I also want it to be able to instantly grow trees by hitting the sapling. If anyone knows how to make it compatible with all crops and grow trees, help is very much apprechiated.

 

- Tschipp

Posted

If bonemeal can be used on it grow() should make it skip a step up specified by the plant. You could use a while loop and the while loop should only run if the plant can be affected by bonemeal and if it is not at it's final stage.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

If bonemeal can be used on it grow() should make it skip a step up specified by the plant. You could use a while loop and the while loop should only run if the plant can be affected by bonemeal and if it is not at it's final stage.

Thank you, that seemed to work!

It does sort of work with trees too, but the tree generates invisible and doesn't appear til I relog...

Posted
  package tschipp.creativePlus.items;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.IGrowable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;

public class SuperBonemeal extends Item {



                public SuperBonemeal(String name) {

                               this.setUnlocalizedName(name);
                               this.hasEffect(new ItemStack(CustomItems.superBonemeal));
                               this.setMaxStackSize(1);
                }


                public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {


                               IBlockState iblockstate = worldIn.getBlockState(pos);

                               int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, pos, iblockstate, stack);
                               if (hook != 0) return hook > 0;

                               if (iblockstate.getBlock() instanceof IGrowable)
                               {
                                               IGrowable igrowable = (IGrowable)iblockstate.getBlock();


                                               if (!worldIn.isRemote)
                                               {


                                                               while(iblockstate.getBlock() instanceof IGrowable) {

                                                               igrowable.grow(worldIn, worldIn.rand, pos, worldIn.getBlockState(pos));
                                                              
                                                               }
                                              

                                               }




/*                                           Block block = worldIn.getBlockState(pos).getBlock();

                                               double d0 = itemRand.nextGaussian() * 0.02D;
                                               double d1 = itemRand.nextGaussian() * 0.02D;
                                               double d2 = itemRand.nextGaussian() * 0.02D;
                                               worldIn.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, (double)((float)pos.getX() + itemRand.nextFloat()), (double)pos.getY() + (double)itemRand.nextFloat() * block.getBlockBoundsMaxY(), (double)((float)pos.getZ() + itemRand.nextFloat()), d0, d1, d2, 200);
*/

                               }





                               return false;

                }

}  

Posted

It crashes

  ---- Minecraft Crash Report ----
// Don't be sad, have a hug! <3

Time: 05.08.16 12:41
Description: Unexpected error

java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=stage, clazz=class java.lang.Integer, values=[0, 1]} as it does not exist in BlockState{block=minecraft:log, properties=[axis, variant]}
                at net.minecraft.block.state.BlockState$StateImplementation.getValue(BlockState.java:137)
                at net.minecraft.block.BlockSapling.grow(BlockSapling.java:65)
                at net.minecraft.block.BlockSapling.grow(BlockSapling.java:245)
                at tschipp.creativePlus.items.SuperBonemeal.onItemUse(SuperBonemeal.java:48)
                at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:149)
                at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:438)
                at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1569)
                at net.minecraft.client.Minecraft.runTick(Minecraft.java:2123)
                at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080)
                at net.minecraft.client.Minecraft.run(Minecraft.java:380)
                at net.minecraft.client.main.Main.main(Main.java:116)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:497)
                at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
                at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:497)
                at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
                at GradleStart.main(GradleStart.java:26)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
                at net.minecraft.block.state.BlockState$StateImplementation.getValue(BlockState.java:137)
                at net.minecraft.block.BlockSapling.grow(BlockSapling.java:65)
                at net.minecraft.block.BlockSapling.grow(BlockSapling.java:245)
                at tschipp.creativePlus.items.SuperBonemeal.onItemUse(SuperBonemeal.java:48)
                at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:149)
                at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:438)
                at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1569)

-- Affected level --
Details:
                Level name: MpServer
                All players: 1 total; [EntityPlayerSP['Player669'/224, l='MpServer', x=-390.35, y=79.00, z=190.22]]
                Chunk stats: MultiplayerChunkCache: 625, 625
                Level seed: 0
                Level generator: ID 00 - default, ver 1. Features enabled: false
                Level generator options:
                Level spawn location: -255.00,64.00,263.00 - World: (-255,64,263), Chunk: (at 1,4,7 in -16,16; contains blocks -256,0,256 to -241,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
                Level time: 58907 game time, 58907 day time
                Level dimension: 0
                Level storage version: 0x00000 - Unknown?
                Level weather: Rain time: 0 (now: true), thunder time: 0 (now: false)
                Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
                Forced entities: 118 total; [EntityBat['Bat'/0, l='MpServer', x=-445.53, y=24.51, z=120.64], EntitySquid['Squid'/2, l='MpServer', x=-441.50, y=63.00, z=135.50], EntitySquid['Squid'/3, l='MpServer', x=-444.44, y=63.47, z=133.47], EntityChicken['Chicken'/4, l='MpServer', x=-446.78, y=63.59, z=141.47], EntityItem['item.item.egg'/1540, l='MpServer', x=-332.88, y=67.00, z=225.50], EntitySheep['Sheep'/5, l='MpServer', x=-447.47, y=74.00, z=177.19], EntitySheep['Sheep'/6, l='MpServer', x=-444.94, y=66.00, z=205.00], EntityItem['item.item.egg'/7, l='MpServer', x=-441.59, y=67.00, z=207.78], EntityItem['item.item.egg'/8, l='MpServer', x=-434.81, y=67.00, z=203.78], EntityChicken['Chicken'/9, l='MpServer', x=-438.75, y=67.00, z=206.53], EntitySheep['Sheep'/10, l='MpServer', x=-437.97, y=67.00, z=221.84], EntityItem['item.item.egg'/11, l='MpServer', x=-435.97, y=67.00, z=223.84], EntityChicken['Chicken'/12, l='MpServer', x=-436.50, y=67.00, z=224.63], EntityChicken['Chicken'/13, l='MpServer', x=-434.50, y=69.00, z=232.22], EntityItem['item.item.egg'/14, l='MpServer', x=-432.31, y=70.00, z=231.47], EntityChicken['Chicken'/15, l='MpServer', x=-433.50, y=70.00, z=232.63], EntityItem['item.item.egg'/783, l='MpServer', x=-386.47, y=70.00, z=207.59], EntityItem['item.item.egg'/16, l='MpServer', x=-434.13, y=68.00, z=231.44], EntityItem['item.item.dyePowder.black'/17, l='MpServer', x=-446.75, y=38.00, z=248.53], EntityChicken['Chicken'/18, l='MpServer', x=-446.63, y=70.00, z=244.31], EntityChicken['Chicken'/19, l='MpServer', x=-442.38, y=71.00, z=243.59], EntityItem['item.item.egg'/20, l='MpServer', x=-446.16, y=70.00, z=244.56], EntityChicken['Chicken'/21, l='MpServer', x=-441.38, y=69.00, z=241.41], EntityChicken['Chicken'/25, l='MpServer', x=-430.53, y=65.00, z=146.09], EntityChicken['Chicken'/26, l='MpServer', x=-425.50, y=70.97, z=153.53], EntityItem['item.item.egg'/27, l='MpServer', x=-430.94, y=65.00, z=145.72], EntityChicken['Chicken'/28, l='MpServer', x=-430.59, y=69.00, z=188.63], EntityItem['item.item.egg'/29, l='MpServer', x=-422.47, y=71.00, z=217.84], EntityRabbit['Rabbit'/30, l='MpServer', x=-421.56, y=74.00, z=236.94], EntityItem['item.item.egg'/31, l='MpServer', x=-431.69, y=71.00, z=239.09], EntityVillager['Villager'/32, l='MpServer', x=-416.47, y=70.00, z=236.75], EntityVillager['Villager'/33, l='MpServer', x=-416.84, y=69.50, z=251.91], EntityItem['item.item.egg'/38, l='MpServer', x=-409.88, y=69.00, z=141.44], EntityBat['Bat'/39, l='MpServer', x=-418.00, y=28.84, z=144.96], EntityItem['item.item.egg'/40, l='MpServer', x=-415.84, y=71.00, z=156.69], EntityChicken['Chicken'/41, l='MpServer', x=-400.88, y=68.00, z=159.47], EntityChicken['Chicken'/42, l='MpServer', x=-398.66, y=68.00, z=158.66], EntityItem['item.item.egg'/43, l='MpServer', x=-411.50, y=71.00, z=161.53], EntityChicken['Chicken'/44, l='MpServer', x=-408.66, y=71.00, z=162.53], EntityChicken['Chicken'/45, l='MpServer', x=-406.59, y=68.66, z=188.78], EntityItem['item.item.egg'/46, l='MpServer', x=-406.59, y=68.00, z=188.88], EntityChicken['Chicken'/47, l='MpServer', x=-414.34, y=71.00, z=215.47], EntityVillager['Villager'/48, l='MpServer', x=-415.47, y=70.00, z=236.28], EntityVillager['Villager'/49, l='MpServer', x=-416.16, y=70.00, z=238.06], EntityVillager['Villager'/50, l='MpServer', x=-415.28, y=70.00, z=237.16], EntityVillager['Villager'/51, l='MpServer', x=-414.31, y=70.00, z=238.69], EntityVillager['Villager'/52, l='MpServer', x=-414.31, y=70.00, z=237.81], EntityVillager['Villager'/53, l='MpServer', x=-415.19, y=70.00, z=238.69], EntityVillager['Villager'/54, l='MpServer', x=-417.16, y=70.00, z=237.69], EntityVillager['Villager'/55, l='MpServer', x=-414.63, y=69.00, z=251.06], EntitySquid['Squid'/6711, l='MpServer', x=-450.59, y=50.35, z=240.53], EntityVillager['Villager'/56, l='MpServer', x=-415.81, y=69.00, z=251.59], EntityRabbit['Rabbit'/57, l='MpServer', x=-409.25, y=71.00, z=261.28], EntityChicken['Chicken'/64, l='MpServer', x=-387.82, y=78.00, z=189.56], EntityChicken['Chicken'/65, l='MpServer', x=-386.44, y=70.00, z=207.66], EntityBat['Bat'/66, l='MpServer', x=-376.94, y=41.07, z=200.55], EntityItem['item.tile.doublePlant.grass'/67, l='MpServer', x=-389.94, y=71.00, z=238.81], EntityItem['item.tile.doublePlant.grass'/68, l='MpServer', x=-391.38, y=71.00, z=239.66], EntityItem['item.tile.doublePlant.grass'/69, l='MpServer', x=-391.34, y=71.00, z=239.09], EntityItem['item.tile.doublePlant.grass'/70, l='MpServer', x=-390.53, y=71.00, z=239.28], EntityRabbit['Rabbit'/71, l='MpServer', x=-387.81, y=71.00, z=231.22], EntityChicken['Chicken'/72, l='MpServer', x=-398.53, y=71.00, z=238.31], EntityItem['item.item.egg'/73, l='MpServer', x=-397.94, y=71.00, z=238.06], EntityItem['item.tile.doublePlant.grass'/74, l='MpServer', x=-390.50, y=71.00, z=240.06], EntityItem['item.tile.doublePlant.grass'/75, l='MpServer', x=-389.41, y=71.00, z=240.69], EntityVillager['Villager'/76, l='MpServer', x=-401.78, y=71.00, z=257.47], EntityChicken['Chicken'/85, l='MpServer', x=-383.50, y=67.66, z=174.31], EntityItem['item.item.egg'/86, l='MpServer', x=-383.88, y=66.00, z=174.72], EntityBat['Bat'/87, l='MpServer', x=-386.25, y=39.11, z=210.32], EntityChicken['Chicken'/88, l='MpServer', x=-380.47, y=68.69, z=210.13], EntityBat['Bat'/89, l='MpServer', x=-357.27, y=21.06, z=217.89], EntityItem['item.tile.sapling.jungle'/90, l='MpServer', x=-378.59, y=70.00, z=241.25], EntityChicken['Chicken'/96, l='MpServer', x=-362.38, y=70.00, z=136.59], EntityChicken['Chicken'/97, l='MpServer', x=-357.66, y=71.00, z=178.41], EntityItem['item.item.egg'/98, l='MpServer', x=-361.94, y=70.00, z=169.13], EntityChicken['Chicken'/99, l='MpServer', x=-365.69, y=68.59, z=184.00], EntityItem['item.item.egg'/100, l='MpServer', x=-366.47, y=68.00, z=183.47], EntityCow['Cow'/101, l='MpServer', x=-352.88, y=71.00, z=199.84], EntitySheep['Sheep'/102, l='MpServer', x=-352.84, y=71.00, z=204.13], EntityBat['Bat'/107, l='MpServer', x=-347.66, y=21.63, z=122.69], EntityBat['Bat'/108, l='MpServer', x=-348.90, y=19.79, z=131.36], EntityBat['Bat'/109, l='MpServer', x=-344.19, y=25.10, z=164.47], EntityBat['Bat'/110, l='MpServer', x=-343.65, y=24.00, z=168.61], EntityBat['Bat'/111, l='MpServer', x=-337.49, y=24.52, z=177.09], EntityChicken['Chicken'/112, l='MpServer', x=-349.44, y=71.00, z=190.34], EntityBat['Bat'/113, l='MpServer', x=-345.44, y=50.14, z=216.65], EntityBat['Bat'/124, l='MpServer', x=-334.13, y=26.00, z=176.04], EntityChicken['Chicken'/125, l='MpServer', x=-334.97, y=71.00, z=173.94], EntityCow['Cow'/126, l='MpServer', x=-334.47, y=70.00, z=168.53], EntityItem['item.item.egg'/127, l='MpServer', x=-329.13, y=71.00, z=168.50], EntityChicken['Chicken'/128, l='MpServer', x=-323.41, y=71.00, z=170.56], EntityItem['item.item.egg'/129, l='MpServer', x=-331.66, y=72.00, z=185.44], EntityChicken['Chicken'/130, l='MpServer', x=-341.41, y=71.00, z=200.59], EntityChicken['Chicken'/131, l='MpServer', x=-332.16, y=68.68, z=224.72], EntityCow['Cow'/140, l='MpServer', x=-319.16, y=71.00, z=164.03], EntityChicken['Chicken'/143, l='MpServer', x=-314.69, y=64.00, z=259.66], EntityBat['Bat'/154, l='MpServer', x=-310.13, y=23.33, z=194.56], EntityPlayerSP['Player669'/224, l='MpServer', x=-390.35, y=79.00, z=190.22], EntityBat['Bat'/5046, l='MpServer', x=-329.77, y=56.02, z=231.74], EntityChicken['Chicken'/225, l='MpServer', x=-450.38, y=74.00, z=177.69], EntitySheep['Sheep'/226, l='MpServer', x=-459.06, y=67.00, z=209.09], EntityChicken['Chicken'/228, l='MpServer', x=-454.53, y=75.00, z=171.75], EntityChicken['Chicken'/230, l='MpServer', x=-463.47, y=65.00, z=228.38], EntityChicken['Chicken'/231, l='MpServer', x=-461.53, y=68.00, z=218.09], EntityItem['item.item.egg'/232, l='MpServer', x=-451.56, y=66.00, z=214.88], EntitySheep['Sheep'/233, l='MpServer', x=-447.84, y=65.00, z=141.13], EntityItem['item.item.dyePowder.black'/235, l='MpServer', x=-453.59, y=56.00, z=238.28], EntityItem['item.item.dyePowder.black'/236, l='MpServer', x=-451.81, y=56.00, z=238.84], EntityItem['item.item.dyePowder.black'/237, l='MpServer', x=-451.88, y=51.00, z=239.63], EntityItem['item.item.dyePowder.black'/238, l='MpServer', x=-451.13, y=51.00, z=239.41], EntityChicken['Chicken'/239, l='MpServer', x=-450.72, y=63.63, z=138.63], EntityItem['item.item.egg'/240, l='MpServer', x=-450.41, y=63.00, z=137.41], EntityChicken['Chicken'/241, l='MpServer', x=-461.56, y=66.00, z=133.72], EntityChicken['Chicken'/242, l='MpServer', x=-451.63, y=65.00, z=137.69], EntitySheep['Sheep'/243, l='MpServer', x=-460.84, y=66.00, z=143.06], EntityItem['item.item.dyePowder.black'/248, l='MpServer', x=-449.00, y=47.00, z=242.34], EntityItem['item.item.dyePowder.black'/249, l='MpServer', x=-452.78, y=52.00, z=241.22], EntitySheep['Sheep'/250, l='MpServer', x=-458.50, y=68.00, z=117.31]]
                Retry entities: 0 total; []
                Server brand: fml,forge
                Server type: Integrated singleplayer server
Stacktrace:
                at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:383)
                at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2645)
                at net.minecraft.client.Minecraft.run(Minecraft.java:409)
                at net.minecraft.client.main.Main.main(Main.java:116)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:497)
                at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
                at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:497)
                at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
                at GradleStart.main(GradleStart.java:26)

-- System Details --
Details:
                Minecraft Version: 1.8.9
                Operating System: Windows 10 (amd64) version 10.0
                Java Version: 1.8.0_65, Oracle Corporation
                Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
                Memory: 576428784 bytes (549 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
                JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
                IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
                FML: MCP 9.19 Powered by Forge 11.15.1.1875 4 mods loaded, 4 mods active
                States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
                UCHIJAAAA        mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)
                UCHIJAAAA        FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.9-11.15.1.1875.jar)
                UCHIJAAAA        Forge{11.15.1.1875} [Minecraft Forge] (forgeSrc-1.8.9-11.15.1.1875.jar)
                UCHIJAAAA        creativeplus{0.1} [§2Creative §6+] (bin)
                Loaded coremods (and transformers):
                GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 364.72' Renderer: 'GeForce 840M/PCIe/SSE2'
                Launched Version: 1.8.9
                LWJGL: 2.9.4
                OpenGL: GeForce 840M/PCIe/SSE2 GL version 4.5.0 NVIDIA 364.72, NVIDIA Corporation
                GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

                Using VBOs: No
                Is Modded: Definitely; Client brand changed to 'fml,forge'
                Type: Client (map_client.txt)
                Resource Packs:
                Current Language: English (US)
                Profiler Position: N/A (disabled)
                CPU: 8x Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz

 

It seems that it is trying to grow the Log block once more, even though that the Log doesn't implement IGrowable...

May also well be that I just don't understand how while loops work... :o

Posted

Try this while loop (not tested)

while(iblockstate.getBlock() instanceof IGrowable && igrowable.canUseBonemeal(worldIn, new Random(), pos, iblockstate) && igrowable.canGrow(worldIn, pos, iblockstate, worldIn.isRemote)) {

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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