Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light updates seem to have no effect #304

Closed
Darker opened this issue Jul 10, 2015 · 12 comments
Closed

Light updates seem to have no effect #304

Darker opened this issue Jul 10, 2015 · 12 comments

Comments

@Darker
Copy link
Contributor

Darker commented Jul 10, 2015

Using BlockFinder plugin I wrote a simple script to find nearby unlit blocks (those that allow mob spawning) and announce the coordinates and type of the darkest one of these. However as I place torches, the bot still announces the same blocks. Something is wrong with block.light. Maybe spigot server isn't sending it correctly?

 //Install block finder
 blockFinderPlugin(bot);
 bot.findBlock({
  point: bot.entity.position,
  matching: function(block) {
    //Ignore 8 and brighter
    if(block.light>7)
      return false;
    //Ignore air
    if(block.type==0)
      return false;
    //Check if there isn't block right above it
    //If there's a block above, the torch can't be placed anyway and monsters can't spawn
    var pos = vec3(block.position);
    pos.y++;

    var obstruction=bot.blockAt(pos);
    if(obstruction!=null && obstruction.type!=0) {
      //console.log(block.position+" is obstructed by "+obstruction.displayName);
      return false;     
    }
    return true;
  },
  maxDistance: 20,
  count: 6,
}, function(err, blocks) {
  if (err) {
    bot.chat('Error trying to find unlit blocks: ' + err);
    _this.setError(1, err);
  }
  else if (blocks.length) {
    //Sort the found blocks from darkest to lightest
    blocks.sort(function(a,b){return a.light-b.light});
    bot.chat('I found an unlit '+blocks[0].displayName+' block at ' + blocks[0].position + ' - It has light of '+blocks[0].light);      
    //return;
  } else {
    bot.chat("I couldn't find any unlit blocks.");
  }
  _this.finished();
});
@rom1504
Copy link
Member

rom1504 commented Jul 11, 2015

Can you try to reproduce this with a vanilla server ? (it's well possible we are not getting the light correctly, I don't think anybody ever used this before)

@Darker
Copy link
Contributor Author

Darker commented Jul 11, 2015

Tried on vanilla, it's the same. Also, nobody really uses vanilla... It almost crashed my computer by it's CPU usage and has broken GUI.

vanilla screenshot

@Darker
Copy link
Contributor Author

Darker commented Jul 11, 2015

Restarting server or reloging has no effect. The light is allways 0.

@roblabla
Copy link
Member

Vanilla is what we used to test node-mc-proto and mineflayer. That's why we always ask to reproduce on vanilla, allows us to see if it's an impl discrepency or just use doing it wrong ^^

@Darker
Copy link
Contributor Author

Darker commented Jul 12, 2015

Ok this is happening both in vanilla and spigot. It also seems that it's not due to block update problem but generally parsing the light value.
Is there anything I can do to hotfix that? I wanted to make a bot that carries light all over certain location.

@rom1504
Copy link
Member

rom1504 commented Jul 21, 2015

This might be related to how light is deserialized ( https://github.com/andrewrk/mineflayer/blob/master/lib/plugins/blocks.js#L63 ), might be worth looking into.

@rom1504
Copy link
Member

rom1504 commented Jul 22, 2015

Ok so I can confirm light is broken, I added an information in chatterbox to check this (with the block command).
I believe the problem is in addColumn (https://github.com/andrewrk/mineflayer/blob/master/lib/plugins/blocks.js#L64) or blockAt (https://github.com/andrewrk/mineflayer/blob/master/lib/plugins/blocks.js#L143) but bitwise operations aren't really my thing. Maybe you can spot something @roblabla ?

@rom1504
Copy link
Member

rom1504 commented Nov 13, 2015

Will be fixed by #334

@rom1504
Copy link
Member

rom1504 commented Jan 7, 2016

reason why : https://github.com/PrismarineJS/mineflayer/blob/master/lib/plugins/blocks.js#L64
lights are half-bytes, not full.

Ways to fix that:

  1. fix it directly
  2. use prismarine-world in mineflayer

I prefer 2 since that's what we will do eventually anyway.

@rom1504
Copy link
Member

rom1504 commented Jan 8, 2017

should be fixed by #465 : needs to be checked

@falazar
Copy link

falazar commented Mar 30, 2017

appears to still not be working in vanilla all the time, sometimes is ok.
will check for light, add three torches, and still say it is dark.

is there an update function I can call force recheck or ?

@rom1504
Copy link
Member

rom1504 commented Mar 31, 2017 via email

@rom1504 rom1504 closed this as completed Jul 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants