Make a player light up like they are a torch.

Discussion in 'Plugin Development' started by iPhysX, Feb 6, 2012.

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

    iPhysX

    If anyone could help me achieve this effect, i would be grateful.
    I wanted to play a portal effect, but apparently this isn't possible.

    Thanks
    ~Phys.
     
  2. Offline

    nisovin

    This isn't possible either. You could potentially light up the blocks around the player, but you can't light up the player model itself.
     
  3. Offline

    iPhysX

    Yes lighting the blocks is what I want :)
    Sorry for wording myself weirdly.
     
  4. Offline

    nisovin

    Honestly, it's difficult to do, I don't know how, and I'm not even sure if it's possible anymore. If you want to do it, you're probably going to be on your own, sorry.
     
    iPhysX likes this.
  5. Offline

    iPhysX

    Ok, nisovin thanks alot for responding, I'll see if the torchhand guy has anything to say on the subject!
     
  6. Offline

    Rathfon

    I cooked up something for this in a bit of time, but all I've run into is problems here and there. Watch this video, you'll see it works, but you'll notice the glitches:

     
    mushroomhostage likes this.
  7. Offline

    AmoebaMan

    I'd have to spend some time thinking about it, but the only solution that immediately comes to mind is placing a hovering glow-stone block above somebody's head, but that would have numerous problems. I'll have to take a look later.
     
  8. Offline

    Rathfon

    I used SkyBlock. Give that a try.
     
  9. Offline

    iPhysX

    Rathfon , AmoebaMan yeah i tried skyblock, no errors to speak of. But no results either.
     
  10. Offline

    Rathfon

    That's what I used in the video I posted. You need to world.notify(x,y,z) usually to get it to recognize the lighting change. You do that?
     
  11. Offline

    iPhysX

    Rathfon that would probably be why it wasn't working.
    I'll try it when I get home.

    That would be Craftworld correct?
     
  12. Offline

    mushroomhostage

    Something like this?

    Code:
        @EventHandler(priority = EventPriority.NORMAL)
        public void onPlayerMove(PlayerMoveEvent event) {
            Location to = event.getTo();
            World world = to.getWorld();
    
            int x = to.getBlockX();
            int y = to.getBlockY();
            int z = to.getBlockZ();
    
            ((CraftWorld)world).getHandle().a(net.minecraft.server.EnumSkyBlock.SKY, x, y, z);
            ((CraftWorld)world).getHandle().notify(x, y, z);
        }
    
    I'm not seeing any effect from this code. Any ideas what is wrong?
     
  13. Offline

    nil0bject

    not the total effect, but a start?
    add this to EntityPlayer:
    Code:
        public float getEntityBrightness(float f)
        {
            return 1.0F;
        }
     
        public int getEntityBrightnessForRender(float f)
        {
            return 0xf000f0;
        }
     
  14. why do you make a parameter if you don't use it?
     
  15. You could probably try sending a LightingUpdate packet and modify that to suit your needs I suppose. But you'd have to look into it - I've never used it before :p.
     
  16. Offline

    Rathfon

    That's what the notify() does.

    And use the other a method that has the light value as the last.
    End up being more like:
    Code:
     ((CraftWorld)world).getHandle().a(net.minecraft.server.EnumSkyBlock.SKY, x, y, z, #);
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  17. Offline

    mushroomhostage

    If anyone still is trying to do this, I got it working. Use the BLOCK enum field, two meters above the player, and pass the light level:

    Code:
    ((CraftWorld)world).getHandle().a(net.minecraft.server.EnumSkyBlock.BLOCK, x, y+2, z, 15);
    
    Then you need to update the world, not at the location you placed the sky block, but directly below. I couldn't get notify() to have any effect, but getting the block and re-setting its type and data does the trick.

    If anyone wants to see it in action (or see the full source), I added this feature in EnchantMore 0.5.1, activated when you are holding a Sword with the Flame enchantment. I'm finding it is very useful, no annoying need to place torches everywhere.

    It is the same technique used in the older Head Lamp plugin. However, there are a couple problems, especially if you want the light to only be temporary. Head Lamp tries to make the light temporary by removing the sky block when the player moves, but a a video someone posted shows this makes light from torches persist longer than intended. For my plugin I kept the light even when the player moves, so players can create semi-permanent lit paths:

    [​IMG]
     
  18. Offline

    Taco

    I've tried working with light levels before, and I've found that they can persist a bit more than wanted. If you want, you could send them chunk update packets every so often. I'll post some code for it in a second.


    Edit: Here ya go. It's not the most efficient way to do it. It works though. I'm not sure if that will update light levels though. It works for entity/block changes.

    Code:java
    1.  
    2. public void updateBlock(Block block)
    3. {
    4. for(Player p : block.getWorld().getPlayers())
    5. if(p.getLocation().distance(block.getLocation()) < 50)
    6. ((org.bukkit.craftbukkit.entity.CraftPlayer)p).getHandle().netServerHandler.sendPacket(new Packet51MapChunk(block.getX(),block.getY(),block.getZ(), 20, 20, 20, (((CraftWorld) block.getWorld()).getHandle())));
    7. }
    8.  
     
    mushroomhostage likes this.
  19. Offline

    mushroomhostage

    Actually the skyblock method seems to work really well to light up models – this is with an EnumSkyBlock.BLOCK placed 2 m above the player (plane from Flan's mod):

    [​IMG]

    before:

    [​IMG]

    Although I suppose the skyblock counts as a block... but it does work to light up entities.
     
Thread Status:
Not open for further replies.

Share This Page