Solved Is this worth the trouble it would cause?

Discussion in 'Plugin Development' started by Tecno_Wizard, Dec 20, 2014.

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

    Tecno_Wizard

    Evening,
    I am working on a plugin that takes a combination code to unlock chests, but my question is, should I go through the MASSIVE hassle that accompanying for double chests would cause, or should I just restrict it to single chests only?

    Also besides that, I have to be able to verify that a chest is a locked chest when it is interacted with with little to no lagg, and I cannot come up with a good way to do this, for metadata does not persist through a restart with placed items. Any ideas?
    Thanks!
     
  2. Offline

    teej107

    Why not lock double chests as well?
     
  3. Offline

    Tecno_Wizard

    @teej107, because i would also have to check for nearby chests, then double the amount of chests I have to search through to verify if it is a locked chest. If I could find an efficient way to verify the type of chest it is and get its owner I would do it no questions asked.
     
  4. Offline

    teej107

  5. Offline

    Tecno_Wizard

    @teej107
    1) didn't know that was a thing...
    2) still no solution to verifying the type of chest and owner with speed.
     
  6. Offline

    Tecno_Wizard

    Bump- it has been 24 hours.

    Does anyone have any ideas better than this?:
    On restart, reset all of the metadata on every chest in all worlds. I'd check to make sure it wasn't a reload.
     
  7. Offline

    Webbeh

    Metadata isn't kept across reloads/restarts, so you have to come up with something else on your own.

    Otherwise, to have it locked, check the blocks at its north,south,west,east location to see if it is a chest. If it is a chest, check if that one has the "locked" metadata and apply it.

    Make sure you don't re-apply the neighbor chest lookup to the second part of the chest :p

    Code:
    method hasData(chest) {
     return that chest block lock data or null/false if none.
    }
    
    onRightClick {
     data = clicked.hasData()
     if(data==null)
      data = clicked.south.hasData()
     if(data==null)
      data = clicked.north.hasData()
     if(data==null)
      data = clicked.west.hasData()
     if(data==null)
      data = clicked.east.hasData()
     //data now contains null if nothing is found, or the any of the two chests lock data
    }
    
     
  8. Offline

    Rocoty

    Pretty sure that if you get the block state of one half of a double chest, it is the same object as the block state of the other half. Hence, you can probably check if the state is instanceof DoubleChest and cast.
     
  9. Offline

    _Filip

    Metadata is kept over reloads, but not restarts.
     
  10. Offline

    Tecno_Wizard

    @Rocoty @Webbeh, i'll look at the behavior of these later today, thank you!
    I guess I am just reapplying metadata on restart.
     
  11. Offline

    Webbeh

    @_Filip Thanks. But in case of doubt : assume the worst. :p
     
Thread Status:
Not open for further replies.

Share This Page