Posted February 23, 20178 yr Hello, is there a way to change the amount that bonemeal lets the crop grow? I want to make it so it's like the old days that you just need 1 bonemeal per crop... Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 23, 20178 yr Author How do I set the grow level? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 23, 20178 yr Author Where can I find that? Couldn't find ItemBonemeal, forgot it was a dye Edited February 23, 20178 yr by Kokkie Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 23, 20178 yr Author How can I forge it to make it full-grown? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 23, 20178 yr Author Through some hacky nifty ways I managed to come up with this, would it work? @SubscribeEvent public void onCropGrow(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); IBlockState state = event.getBlock(); BlockPos pos = event.getPos(); ItemStack stack = event.getEntityPlayer().getActiveItemStack(); if (state.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) state.getBlock(); if (igrowable.canGrow(world, pos, state, world.isRemote)) { if (!world.isRemote) { igrowable.grow(world, world.rand, pos, state); if (igrowable instanceof BlockCrops) { world.setBlockState(pos, state.withProperty(BlockCrops.AGE, ((BlockCrops)igrowable).getMaxAge())); } stack.shrink(1); } } } } Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 23, 20178 yr Author Wow I had that idea in the beginning but thought Nah that wont work.... @SubscribeEvent public void onCropGrow(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); IBlockState state = event.getBlock(); BlockPos pos = event.getPos(); ItemStack stack = event.getEntityPlayer().getActiveItemStack(); if (state.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) state.getBlock(); if (igrowable.canGrow(world, pos, state, world.isRemote)) { if (!world.isRemote) { igrowable.grow(world, world.rand, pos, state); while (igrowable.canGrow(world, pos, state, world.isRemote)) { igrowable.grow(world, world.rand, pos, state); } stack.shrink(1); } } } } Let's test this out Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr Author Now it 'crashes' the game when I use bonemeal, so when I use it I can't use anything in the game (use hoes on land, open guis from blocks) and then it crashes when I try to go back to the main menu... No crashes in the console Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr It gets stuck in an infinite loop at the while because it is using the same state everytime instead you should get the state from the World field and BlockPos field. 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.
February 26, 20178 yr Author @SubscribeEvent public void onCropGrow(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); IBlockState state = event.getBlock(); BlockPos pos = event.getPos(); ItemStack stack = event.getEntityPlayer().getActiveItemStack(); if (state.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) state.getBlock(); if (igrowable.canGrow(world, pos, state, world.isRemote)) { if (!world.isRemote) { igrowable.grow(world, world.rand, pos, state); while (igrowable.canGrow(world, pos, state, world.isRemote)) { igrowable.grow(world, world.rand, pos, state); igrowable = (IGrowable) world.getBlockState(pos).getBlock(); } stack.shrink(1); } } } } Doesn't work either Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr No your state, not the IGrowable. In the while loop the state you pass into the method needs to be updated so use the worlds state at the BlockPos. 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.
February 26, 20178 yr Author Ah thanks it works, only thing is, it doesn't take away an item... And the tree gets well.. buggy... It isn't rendered until you update the blocks (right-click)... Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr 3 minutes ago, Kokkie said: Ah thanks it works, only thing is, it doesn't take away an item... And the tree gets well.. buggy... It isn't rendered until you update the blocks (right-click)... You will need to mark the block for an update specifically the client. World#markBlockForUpdate (I think that is the name at least it is similar). 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.
February 26, 20178 yr Author Which one? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr I believe the first one and if i am wrong others please correct me. 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.
February 26, 20178 yr Author world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, state, 2); This doesn't work Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr The second state needs to be the one gotten from the world. 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.
February 26, 20178 yr Author @SubscribeEvent public void onCropGrow(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); IBlockState state = event.getBlock(); BlockPos pos = event.getPos(); ItemStack stack = event.getEntityPlayer().getActiveItemStack(); if (state.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) state.getBlock(); if (igrowable.canGrow(world, pos, state, world.isRemote)) { if (!world.isRemote) { while (igrowable.canGrow(world, pos, state, world.isRemote)) { igrowable.grow(world, world.rand, pos, state); state = world.getBlockState(pos); } world.markAndNotifyBlock(pos, world.getChunkFromBlockCoords(pos), state, world.getBlockState(pos), 2); stack.shrink(1); } } } } Nope... Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr Try looking at the Javadoc for the method. 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.
February 26, 20178 yr Author Where can I find the javadoc? And what should I look for? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr Look at the method in the class it belongs to. The comments above the method are known as the javadoc. 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.
February 26, 20178 yr Author Oh that... Ok. Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr Author Also, I get this error in the console [14:16:20] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.entity.player.BonemealEvent@75452f75: java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=stage, clazz=class java.lang.Integer, values=[0, 1]} as it does not exist in BlockStateContainer{block=minecraft:log, properties=[axis, variant]} at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:201) ~[BlockStateContainer$StateImplementation.class:?] at net.minecraft.block.BlockSapling.grow(BlockSapling.java:71) ~[BlockSapling.class:?] at net.minecraft.block.BlockSapling.grow(BlockSapling.java:251) ~[BlockSapling.class:?] at com.Egietje.degeweldigemod.handler.CheeseCommonHandler.onCropGrow(CheeseCommonHandler.java:80) ~[CheeseCommonHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_18_CheeseCommonHandler_onCropGrow_BonemealEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) [EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(ForgeEventFactory.java:355) [ForgeEventFactory.class:?] at net.minecraft.item.ItemDye.applyBonemeal(ItemDye.java:118) [ItemDye.class:?] at net.minecraft.item.ItemDye.onItemUse(ItemDye.java:62) [ItemDye.class:?] at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:812) [ForgeHooks.class:?] at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:179) [ItemStack.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:516) [PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItemOnBlock(NetHandlerPlayServer.java:712) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:68) [CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) [CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) [PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_77] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_77] at net.minecraft.util.Util.runTask(Util.java:26) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_77] [14:16:20] [Server thread/ERROR] [FML]: Index: 1 Listeners: [14:16:20] [Server thread/ERROR] [FML]: 0: NORMAL [14:16:20] [Server thread/ERROR] [FML]: 1: ASM: com.Egietje.degeweldigemod.handler.CheeseCommonHandler@63a5a05a onCropGrow(Lnet/minecraftforge/event/entity/player/BonemealEvent;)V [14:16:20] [Server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=stage, clazz=class java.lang.Integer, values=[0, 1]} as it does not exist in BlockStateContainer{block=minecraft:log, properties=[axis, variant]} at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_77] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_77] at net.minecraft.util.Util.runTask(Util.java:27) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_77] Caused by: java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=stage, clazz=class java.lang.Integer, values=[0, 1]} as it does not exist in BlockStateContainer{block=minecraft:log, properties=[axis, variant]} at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:201) ~[BlockStateContainer$StateImplementation.class:?] at net.minecraft.block.BlockSapling.grow(BlockSapling.java:71) ~[BlockSapling.class:?] at net.minecraft.block.BlockSapling.grow(BlockSapling.java:251) ~[BlockSapling.class:?] at com.Egietje.degeweldigemod.handler.CheeseCommonHandler.onCropGrow(CheeseCommonHandler.java:80) ~[CheeseCommonHandler.class:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_18_CheeseCommonHandler_onCropGrow_BonemealEvent.invoke(.dynamic) ~[?:?] at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?] at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) ~[EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(ForgeEventFactory.java:355) ~[ForgeEventFactory.class:?] at net.minecraft.item.ItemDye.applyBonemeal(ItemDye.java:118) ~[ItemDye.class:?] at net.minecraft.item.ItemDye.onItemUse(ItemDye.java:62) ~[ItemDye.class:?] at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:812) ~[ForgeHooks.class:?] at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:179) ~[ItemStack.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:516) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItemOnBlock(NetHandlerPlayServer.java:712) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:68) ~[CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(CPacketPlayerTryUseItemOnBlock.java:13) ~[CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_77] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_77] at net.minecraft.util.Util.runTask(Util.java:26) ~[Util.class:?] ... 5 more Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 26, 20178 yr Author So... What should the method do? Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 27, 20178 yr Author Bump Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
February 27, 20178 yr Author So.. this? @SubscribeEvent public void onBonemeal(BonemealEvent event) { event.setCanceled(true); World world = event.getWorld(); BlockPos pos = event.getPos(); IBlockState state = world.getBlockState(pos); ItemStack stack = event.getEntityPlayer().getHeldItemMainhand(); if (stack.getItem() != Items.DYE) { stack = event.getEntityPlayer().getHeldItemOffhand(); if (stack.getItem() != Items.DYE) { return; } } if (state.getBlock() instanceof IGrowable) { IGrowable igrowable = (IGrowable) state.getBlock(); if (!world.isRemote) { while (igrowable.canGrow(world, pos, state, world.isRemote)) { igrowable.grow(world, world.rand, pos, state); state = world.getBlockState(pos); if (state.getBlock() instanceof IGrowable) { igrowable = (IGrowable) state.getBlock(); } else { stack.shrink(1); } } } } } Edited February 27, 20178 yr by Kokkie Other solution Classes: 94 Lines of code: 12173 Other files: 206 Github repo: https://github.com/KokkieBeer/DeGeweldigeMod
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.