Efficiently pasting blocks instantly

Discussion in 'Plugin Development' started by Digi, Dec 21, 2011.

Thread Status:
Not open for further replies.
  1. Well, I'm copying and pasting around alot of blocks... in just one code block I have: copying existent blocks to memory, pasting old existent blocks from memory, copying blocks from a new location, pasting previously copied blocks to the new location... also, I'm blocking the BLOCK_PHYSICS event before everything happens and re-enabling it afterwards.
    That works ok for small stuff with a empty server, but the server lags severely as the size slowly increases and it will even more if it's a populated server with other stuff loaded...

    So, is there a special method that I can use to maximize the possible performance ? Note that I don't really want the blocks to react like they've been placed from a human, I want less imprint as possible, it should just visually make it happen.

    EDIT: hmm, actuallly, I never tried that sendChunkUpdate thing, it should fake the blocks on the player without affecting the world and halfs the actions that I do in a code block... but I dunno, if the chunk updates naturally, won't that revert ? Is there a way to "hook"/"listen" to chunks sending themselves to players and allow me to edit them on the way ? :}
     
  2. Offline

    Sleaker

    Spout allows you to deal with Packet data without writing your own packet wrappers/senders. You can listen for the packet and adjust the chunk data in a thread, just like the Ore Obfuscators do.
     
  3. But do I need to persist them to prevent the server from sending the originals ?
     
  4. Offline

    Sleaker

    you'd need to change every packet that sends chunk data that needs to be altered (if you aren't going to actually change the blocks server-side). So however you want to handle that is how you'd need to handle it.

    Knowing what you need to do is the first step in solving your issue. Figure out what, then you can list off what steps you need to take to accomplish the how.
     
  5. Well, basically I store some blocks (shapes of sea ships, air ships, wagons, etc) and then set up points through the world where it should teleport in intervals.

    The packet altering thing would be great for the ghost positioning where I just need a visual info on how the transport would fit... but the part where it actually sits in docks and people board it, I dunno if that will trigger the fly anti-cheat since the server doesn't have blocks there yet the players seem to fly because they are actually walking on blocks they have...

    Tricky...

    Anyway, I'd rather stick to what I have for now, altering the world and saving the previous blocks... so, is there a efficient fast way ? Altering chunk screenshots ? Disabling autosave ? .... I dunno, I'm just guessing here since I really don't know what happens to the server when a block change is sent to it via plugin, and as I said, I want it to have almost zero footprint, as if the blocks were always there.
     
  6. Offline

    Sleaker

    It will trigger every anti-cheat known :p - since the server doesn't have the blocks. the player will also need to walk since the block alterations wont shunt the player to keep them on the vehicle.

    The efficient way would be to add a new complex entity like the enderdragon, and spawn it + setvelocities/directions.
     
  7. The dragon would defeat the purpose of having custom block-based transports.... and I mean instant travel transports, not real time.

    Anyway, I think I'm gonna stare at codes from other plugins that move stuff and maybe I'll find some tricks.
     
  8. Offline

    Trc202

    Check the world edit api? Might be helpful.
     
Thread Status:
Not open for further replies.

Share This Page