making a lantern with a torch

Discussion in 'Plugin Development' started by nitrousspark, Nov 11, 2012.

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

    nitrousspark

    im sure its possible. but i dont know how to do it, i want it so if they switch to a torch in their hand it emits light and then when they put it away the light goes away. how do i do it
     
  2. Offline

    zachoooo

    It is possible, but it requires some intricate knowledge of Bukkit/Minecraft packets
     
  3. Offline

    nitrousspark

    can somebody just write out some code for me to use or something? because i really want to do this.
     
  4. Offline

    zachoooo

    I'm not sure. I'm pretty certain this would require a client/server mod as lighting is calculated client side.

    Perhaps Spout has/will come up with a solution

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

    gomeow

    Try as the player moves, put a torch in their position, y +1. It will seem as though its a handheld torch
     
  6. Offline

    zachoooo

    Just ignore the raining trail of torches behind you :)
     
    gomeow likes this.
  7. Offline

    gomeow

    That could be easily remedied. Just place them, and take them away as you leave. I'm sure there are ways
     
  8. Offline

    zachoooo

    I know, I was just joking
     
  9. Offline

    devilquak

    There's already a plugin that does this, I think it's called TorchLight or something. You can't edit the actual lighting, since it's client-side, so it just sends a block change to each individual client to make the block below them glowstone.
     
  10. Offline

    MYCRAFTisbest

    *EHEM* I kinda already did this. I have an open source so knock yourself out.

    Edit: The plugin was featured on WoopaGaming recently and Curse added it to the Plugin Spotlight for the Curse Network. I am surprised and saddened no one here knew this.

    Plugin: http://dev.bukkit.org/server-mods/rwtc/

    McStats(rank 53): https://mcstats.org/plugin/RWtorchLight
    Curse Spotlight: http://www.curse.com/spotlight/server-mods/minecraft/46924-minecraft-spotlight-rwtorchlight
    WoopaGaming: www.youtube.com/watch?v=TGq3NCjS1f4


    EDIT2: I just relied devilquak was referring to my plugin.:)[torch]
     
  11. Offline

    devilquak

    Yep, I meant your plugin, RWtorchLight.
     
  12. Offline

    Milkywayz

  13. Offline

    nitrousspark

    one last qeustion, i feel like an idot for asking but does every plugin on bukkit have an available source code? and if so, where do i find it.
     
  14. Offline

    zachoooo

    No, but many do. Just google the plugin name and you can sometimes find it. Most of the good large plugins have their source available
     
  15. Offline

    RobotA69

    No, but you can just as easily decompile the .jar
     
  16. Offline

    Icyene

    Code:Java
    1.  
    2. public void forceLightLevel(int x, int y, int z, int level) {
    3. // this was a() in CB 1.2
    4. ((CraftWorld) getWorld()).getHandle().b(EnumSkyBlock.BLOCK, x, y, z, level);
    5. }
    6.  


    Hope that helps. Method is kind of self-explanatory. Credits to desht for it, I just compacted it & put it into context.
     
  17. Offline

    desht

    Thanks.

    You'll probably find you also have to send a block update for the block(s) you're changing (that wasn't necessary in 1.1 and earlier, but that changed in 1.2 - see http://forums.bukkit.org/threads/solved-enumskyblock-block-in-1-2-3-r0-1.63780/. If you're just updating a small number of blocks, the Bukkit.playerSendBlockChange() call should be fine. For mass updates, you might want to use an approach like I discussed in http://forums.bukkit.org/threads/solved-enumskyblock-block-in-1-2-3-r0-1.63780/#post-1010447 to avoid server lag.

    BTW, RWTorchLight uses an alternative pure-Bukkit approach of sending a fake glowstone block change to the player who's holding a torch up. It's a neat approach, and has the advantage of not requiring any NMS trickery. It does however mean that only the player who's holding a torch gets the benefit of the torchlight (suggestion to MYCRAFTisbest - optionally send the fake block change to other nearby players too - it's more work for the server so keep it optional).
     
    Icyene likes this.
  18. Offline

    MYCRAFTisbest

    I actually have that feature in development ATM, but thanks for suggesting it anyway.
     
Thread Status:
Not open for further replies.

Share This Page