What event signals a sapling becoming a tree?

Discussion in 'Plugin Development' started by phondeux, Oct 13, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    phondeux

    I've been searching the forums here and the bukkit API but have been unable to find the answer to this; what event signals a sapling becoming a tree?
     
  2. I don't think there is an event for that, you might ask the Bukkit team to add that.
     
  3. Offline

    phondeux

    Okay, to do that I think requires a 'pull request', correct? I've no idea how to do that. I'll dig around for the irc link and try there.
     
  4. Nope, doing a pull request means that you would have coded such a listener on your own and offer it to the Bukkit team to use it. You rather post it as feature in http://leaky.bukkit.org/projects/bukkit/issues
     
    phondeux likes this.
  5. Offline

    phondeux

    I just did that, thanks!

    How would I code it myself? That is, I'd be more than glad to write it as half the plugins I'm using on my own server are self-written. Do I just pull craftbukkit from git? Does it have any special dependencies?
     
  6. Offline

    Sagacious_Zed Bukkit Docs

    You can use maven to your advantage here. It will download all the dependencies.

    If you just clone the repo, it does not have the dependencies.
     
  7. Offline

    phondeux

    Unfortunately I'm terrible with Maven - I tried to get it to work but it's a giant fail-pile.

    I also dug through the bukkit code to see how I'd create the new event and I can't even begin to determine where I'd start. Would tree growth be a world event? The other event types don't seem to qualify.

    I offered to bribe the bukkit team but I think nobody heard me. I'd seriously pay to see this event put in. Is there a place I could post a bounty on the events creation? :D [diamond]
     
  8. Offline

    nicholasntp

    There is a spawn tree type of event. It doesn't have to do with saplings though. It spawns a tree, or a big tree. its in the javadocs for bukkit.
     
  9. Offline

    iffa

    I'll go dive into the source to find where tree "growing" is done.

    (I hate Maven right now, I found a place to call this event)
     
  10. Offline

    phondeux

    I'm dead serious that if someone creates this event and bukkit implements it I'll donate to bukkit and the person whom wrote it.
     
  11. Offline

    iffa

    Yeah I know how to do it but @lukegb 's mojo is having problems.
     
  12. Offline

    Father Of Time

    @phondeux
    God, this issue has been the bane of my existence... Myself and another member here at bukkit forums were searching for this last week, our findings can be found here:

    http://forums.bukkit.org/threads/event-for-giant-mushroom-growth.42221/

    As previously stated, there is absolutely no event for any plant growth (crop/tree/mushrooms). I have two big projects on my table that are high priority for my server, but when I wrap those up I may revisit this post to see if anyone has begun development, and if not lend a hand.

    I do hope you manage to make some progress with this issue as it seems to be a highly requested event. Either way good luck with this request, I'm sure it will ultimately make a lot of people happy. :)

    EDIT: Hmm, This is only a brief brain fart, but for your specific instance I may have thought of a “work around”. There is an event I stumbled across awhile ago that is triggered when a block is generated in the world. This event is unique in that it is only triggered when the server creates a block, not when a player does.

    I would imagine when a sapling grows it takes the sapling block and converts it to a log block (among generating the other logs/leaves). Seeing as the server is generating this block it may trigger the Block generation event.

    If tree growth does trigger this event you could create a listener for it, then check to see if the block from the event is a log, if it’s a log then it’s from a tree growth. You may run into some complications, like when a tree grows it actually generates 5 to 10 logs, so the event will get triggered a bunch per tree growth, but I’m sure there is a workaround for this.

    It’s hard to say if this will help you, if it even works at all; but it may be a work around that will get you going until this event is created. Something is better than nothing!
     
    jblaske likes this.
  13. Offline

    nicholasntp

    Does that help? Or are you trying to make it so if it finds a growth, it stops it?
     
  14. Offline

    nisovin

    He's looking for an event that is called when the server grows a tree, not a way to grow a tree himself.
     
  15. Offline

    nicholasntp

    Ok, gotcha. Yeah, there isn't one yet, for any crop growing. :(
     
  16. Offline

    phondeux

    I assume the event must be more complicated than it seems on the surface as otherwise an event would already exist for it. Or maybe I'm just making a bad assumption.

    As it stands I am officially offering a cash reward for the event to be added. I don't care who does it. If it's a team they'll have to split it. The same reward will be donated to the bukkit team (as a donation to the project).

    [edit] Superficially, I want an event to be triggered when a sapling grows into a tree and I want to be able to cancel that event.
     
  17. Offline

    iffa

    BlockSapling.java, void b, that's all the info a developer will need if (s)he wants to add this event. I'm busy.
     
  18. Offline

    nicholasntp

    Im on it. And forget about the cash. We are all friends here ;)

    EDIT: I actually can't make the event right now. :p
     
  19. Offline

    phondeux

    Okay, fine. I'll still donate to the bukkit team. I spent six hours last weekend digging through the bukkit source trying to figure out how to do this. :(
     
  20. Offline

    nicholasntp

    Wouldn't that interfere with //set log ???

    Thats what I'm doing now. xD. Ill do this later,:eek:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  21. Offline

    Father Of Time

    More than likely, That is what happens when you make last second suggestions during your lunch break at work. :D

    Is this part of the bukkit source or something, because as far as i can see the only thing related to saplings in the bukkit is an enumerator in Marterials.

    http://jd.bukkit.org/doxygen
    Code:
    00014 public enum Material {
    00015     AIR(0),
    00016     STONE(1),
    00017     GRASS(2),
    00018     DIRT(3),
    00019     COBBLESTONE(4),
    00020     WOOD(5),
    00021     SAPLING(6, Tree.class),
    00022     BEDROCK(7),
    00023     WATER(8, MaterialData.class),
    00024     STATIONARY_WATER(9, MaterialData.class),
    00025     LAVA(10, MaterialData.class),
    00026     STATIONARY_LAVA(11, MaterialData.class),
    00027     SAND(12),
    00028     GRAVEL(13),
    00029     GOLD_ORE(14),
    00030     IRON_ORE(15),
    00031     COAL_ORE(16),
    00032     LOG(17, Tree.class),
    00033     LEAVES(18, Tree.class),
    00034     SPONGE(19),
    00035     GLASS(20),
    00036     LAPIS_ORE(21),
    00037     LAPIS_BLOCK(22),
    00038     DISPENSER(23, Dispenser.class),
    00039     SANDSTONE(24),
    00040     NOTE_BLOCK(25),
    00041     BED_BLOCK(26, Bed.class),
    00042     POWERED_RAIL(27, PoweredRail.class),
    00043     DETECTOR_RAIL(28, DetectorRail.class),
    00044     PISTON_STICKY_BASE(29, PistonBaseMaterial.class),
    00045     WEB(30),
    00046     LONG_GRASS(31, LongGrass.class),
    00047     DEAD_BUSH(32),
    00048     PISTON_BASE(33, PistonBaseMaterial.class),
    00049     PISTON_EXTENSION(34, PistonExtensionMaterial.class),
    00050     WOOL(35, Wool.class),
    00051     PISTON_MOVING_PIECE(36),
    00052     YELLOW_FLOWER(37),
    00053     RED_ROSE(38),
    00054     BROWN_MUSHROOM(39),
    00055     RED_MUSHROOM(40),
    00056     GOLD_BLOCK(41),
    00057     IRON_BLOCK(42),
    00058     DOUBLE_STEP(43, Step.class),
    00059     STEP(44, Step.class),
    00060     BRICK(45),
    00061     TNT(46),
    00062     BOOKSHELF(47),
    00063     MOSSY_COBBLESTONE(48),
    00064     OBSIDIAN(49),
    00065     TORCH(50, Torch.class),
    00066     FIRE(51),
    00067     MOB_SPAWNER(52),
    00068     WOOD_STAIRS(53, Stairs.class),
    00069     CHEST(54),
    00070     REDSTONE_WIRE(55, RedstoneWire.class),
    00071     DIAMOND_ORE(56),
    00072     DIAMOND_BLOCK(57),
    00073     WORKBENCH(58),
    00074     CROPS(59, Crops.class),
    00075     SOIL(60, MaterialData.class),
    00076     FURNACE(61, Furnace.class),
    00077     BURNING_FURNACE(62, Furnace.class),
    00078     SIGN_POST(63, 1, Sign.class),
    00079     WOODEN_DOOR(64, Door.class),
    00080     LADDER(65, Ladder.class),
    00081     RAILS(66, Rails.class),
    00082     COBBLESTONE_STAIRS(67, Stairs.class),
    00083     WALL_SIGN(68, 1, Sign.class),
    00084     LEVER(69, Lever.class),
    00085     STONE_PLATE(70, PressurePlate.class),
    00086     IRON_DOOR_BLOCK(71, Door.class),
    00087     WOOD_PLATE(72, PressurePlate.class),
    00088     REDSTONE_ORE(73),
    00089     GLOWING_REDSTONE_ORE(74),
    00090     REDSTONE_TORCH_OFF(75, RedstoneTorch.class),
    00091     REDSTONE_TORCH_ON(76, RedstoneTorch.class),
    00092     STONE_BUTTON(77, Button.class),
    00093     SNOW(78),
    00094     ICE(79),
    00095     SNOW_BLOCK(80),
    00096     CACTUS(81, MaterialData.class),
    00097     CLAY(82),
    00098     SUGAR_CANE_BLOCK(83, MaterialData.class),
    00099     JUKEBOX(84),
    00100     FENCE(85),
    00101     PUMPKIN(86, Pumpkin.class),
    00102     NETHERRACK(87),
    00103     SOUL_SAND(88),
    00104     GLOWSTONE(89),
    00105     PORTAL(90),
    00106     JACK_O_LANTERN(91, Pumpkin.class),
    00107     CAKE_BLOCK(92, 1, Cake.class),
    00108     DIODE_BLOCK_OFF(93, Diode.class),
    00109     DIODE_BLOCK_ON(94, Diode.class),
    00110     LOCKED_CHEST(95),
    00111     TRAP_DOOR(96, TrapDoor.class),
    00112     MONSTER_EGGS(97, MonsterEggs.class),
    00113     SMOOTH_BRICK(98, SmoothBrick.class),
    00114     HUGE_MUSHROOM_1(99),
    00115     HUGE_MUSHROOM_2(100),
    00116     IRON_FENCE(101),
    00117     THIN_GLASS(102),
    00118     MELON_BLOCK(103),
    00119     PUMPKIN_STEM(104),
    00120     MELON_STEM(105),
    00121     VINE(106),
    00122     FENCE_GATE(107),
    00123     BRICK_STAIRS(108),
    00124     SMOOTH_STAIRS(109),
    00125     // ----- Item Separator -----
    00126     IRON_SPADE(256, 1, 250),
    00127     IRON_PICKAXE(257, 1, 250),
    00128     IRON_AXE(258, 1, 250),
    00129     FLINT_AND_STEEL(259, 1, 64),
    00130     APPLE(260),
    00131     BOW(261, 1),
    00132     ARROW(262),
    00133     COAL(263, Coal.class),
    00134     DIAMOND(264),
    00135     IRON_INGOT(265),
    00136     GOLD_INGOT(266),
    00137     IRON_SWORD(267, 1, 250),
    00138     WOOD_SWORD(268, 1, 59),
    00139     WOOD_SPADE(269, 1, 59),
    00140     WOOD_PICKAXE(270, 1, 59),
    00141     WOOD_AXE(271, 1, 59),
    00142     STONE_SWORD(272, 1, 131),
    00143     STONE_SPADE(273, 1, 131),
    00144     STONE_PICKAXE(274, 1, 131),
    00145     STONE_AXE(275, 1, 131),
    00146     DIAMOND_SWORD(276, 1, 1561),
    00147     DIAMOND_SPADE(277, 1, 1561),
    00148     DIAMOND_PICKAXE(278, 1, 1561),
    00149     DIAMOND_AXE(279, 1, 1561),
    00150     STICK(280),
    00151     BOWL(281),
    00152     MUSHROOM_SOUP(282, 1),
    00153     GOLD_SWORD(283, 1, 32),
    00154     GOLD_SPADE(284, 1, 32),
    00155     GOLD_PICKAXE(285, 1, 32),
    00156     GOLD_AXE(286, 1, 32),
    00157     STRING(287),
    00158     FEATHER(288),
    00159     SULPHUR(289),
    00160     WOOD_HOE(290, 1, 59),
    00161     STONE_HOE(291, 1, 131),
    00162     IRON_HOE(292, 1, 250),
    00163     DIAMOND_HOE(293, 1, 1561),
    00164     GOLD_HOE(294, 1, 32),
    00165     SEEDS(295),
    00166     WHEAT(296),
    00167     BREAD(297),
    00168     LEATHER_HELMET(298, 1, 33),
    00169     LEATHER_CHESTPLATE(299, 1, 47),
    00170     LEATHER_LEGGINGS(300, 1, 45),
    00171     LEATHER_BOOTS(301, 1, 39),
    00172     CHAINMAIL_HELMET(302, 1, 66),
    00173     CHAINMAIL_CHESTPLATE(303, 1, 95),
    00174     CHAINMAIL_LEGGINGS(304, 1, 91),
    00175     CHAINMAIL_BOOTS(305, 1, 78),
    00176     IRON_HELMET(306, 1, 135),
    00177     IRON_CHESTPLATE(307, 1, 191),
    00178     IRON_LEGGINGS(308, 1, 183),
    00179     IRON_BOOTS(309, 1, 159),
    00180     DIAMOND_HELMET(310, 1, 271),
    00181     DIAMOND_CHESTPLATE(311, 1, 383),
    00182     DIAMOND_LEGGINGS(312, 1, 367),
    00183     DIAMOND_BOOTS(313, 1, 319),
    00184     GOLD_HELMET(314, 1, 67),
    00185     GOLD_CHESTPLATE(315, 1, 95),
    00186     GOLD_LEGGINGS(316, 1, 91),
    00187     GOLD_BOOTS(317, 1, 79),
    00188     FLINT(318),
    00189     PORK(319),
    00190     GRILLED_PORK(320),
    00191     PAINTING(321),
    00192     GOLDEN_APPLE(322),
    00193     SIGN(323, 1),
    00194     WOOD_DOOR(324, 1),
    00195     BUCKET(325, 1),
    00196     WATER_BUCKET(326, 1),
    00197     LAVA_BUCKET(327, 1),
    00198     MINECART(328, 1),
    00199     SADDLE(329, 1),
    00200     IRON_DOOR(330, 1),
    00201     REDSTONE(331),
    00202     SNOW_BALL(332, 16),
    00203     BOAT(333, 1),
    00204     LEATHER(334),
    00205     MILK_BUCKET(335, 1),
    00206     CLAY_BRICK(336),
    00207     CLAY_BALL(337),
    00208     SUGAR_CANE(338),
    00209     PAPER(339),
    00210     BOOK(340),
    00211     SLIME_BALL(341),
    00212     STORAGE_MINECART(342, 1),
    00213     POWERED_MINECART(343, 1),
    00214     EGG(344, 16),
    00215     COMPASS(345),
    00216     FISHING_ROD(346, 1, 64),
    00217     WATCH(347),
    00218     GLOWSTONE_DUST(348),
    00219     RAW_FISH(349),
    00220     COOKED_FISH(350),
    00221     INK_SACK(351, Dye.class),
    00222     BONE(352),
    00223     SUGAR(353),
    00224     CAKE(354, 1),
    00225     BED(355, 1),
    00226     DIODE(356),
    00227     COOKIE(357),
    00228     MAP(358, 1, MaterialData.class),
    00229     SHEARS(359, 1, 238),
    00230     MELON(360),
    00231     PUMPKIN_SEEDS(361),
    00232     MELON_SEEDS(362),
    00233     RAW_BEEF(363),
    00234     COOKED_BEEF(364),
    00235     RAW_CHICKEN(365),
    00236     COOKED_CHICKEN(366),
    00237     ROTTEN_FLESH(367),
    00238     ENDER_PEARL(368),
    00239     GOLD_RECORD(2256, 1),
    00240     GREEN_RECORD(2257, 1);
    Tree.java is a class of it's own, but as far as I can see there is no sapling.java...

    @original poster...
    I have to admit I am quite interested in the prospect of developing an event listener for bukkit; it would be cool to know that I contributed to the bukkit project in a small way. Locating where the event takes place and programming the event itself shouldn't be too difficult, but I have never worked with bukkits source code before, so in order to get started I would greatly benefit from links to sourcecode, as well as any additional documentation regarding making bukkit source changes.

    This is a blanket request to everyone, if you know anything about modding bukkit itself please share, it will save me a great deal of research, which is nice!
     
  22. Offline

    iffa

    Alright, I'm working on TreeGrowEvent, will be called when some tree is grown from a sapling (naturally or bonemeal), also includes type of tree (possibly)
     
  23. Offline

    thehutch

    May I ask why you would donate the developer to the bukkit team :p
     
  24. Offline

    phondeux

    LOL, I said "_and_ the person" not just "the person". :p
     
  25. Offline

    iffa

    Done, I don't want to include a boolean for bonemeal, so it's just for natural tree growth. I'll make the pull request tomorrow. I want to sleep!
     
  26. Offline

    nicholasntp



    You did it? :O

    Hehe.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  27. Offline

    phondeux

    Thank you from the bottom of my heart!

    I don't think you'd need a boolean for bonemeal - you can just grab the event and see if someone struck the block.
     
  28. Offline

    nicholasntp

    Make sure it gives them back the bonemeal with an error, in your plugin, like, [PLUGIN NAME] You are not allowed to grow trees.

    Iffa, i said I was gonna do it. :( But okay. XD [fire][tnt][fire] TO YOU! lol jk. We're still cool. :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  29. Offline

    Father Of Time

    Welp that saves me some work, kudos. I hope to see this in bukkit soon, but I have a feeling they are going to try to hold onto the "Leet" 1337 build for a bit... :eek:
     
  30. Offline

    phondeux

    It can be rolled into a non-recommended build and we won't lose the 1337 as RB. I don't see a problem ... :D
     
Thread Status:
Not open for further replies.

Share This Page