How to make a block harder to break

Discussion in 'Plugin Development' started by phaed, Aug 24, 2011.

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

    phaed

    For instance, making a dirt block as hard to break as obsidian, is it possible?
     
  2. Offline

    fullwall

    You'd need to change the net.minecraft block.strength value.
     
  3. How exacly can you do that ? :confused:
     
  4. Offline

    oyasunadev

    Well it's client side, so everyone would have to download a Mod that you make. Check out MCP if you really want to continue with this idea...
     
  5. Offline

    Pencil

    easy way is to download craftbukkit source and go into net.minecraft etc and edit block.java BUT without client sided changes ASWELL blocks will be unbreakable! D:
     
  6. You could maybe do a hackish solution and send block change packets to the client to restart the mining process. It wouldn't give a relieable result, though, because of network speed and server lags.
     
  7. Offline

    Pencil

    actually, couldn't we cancel the onPlayerinteract/blockDamageEvent for a few ticks then allow it? :3
     
  8. Whatever you do to make the server delay the breaking of the block, the client won't care. When you hold your left mouse button while facing a block, you will start mining it and break it after the client-set time - and no server can stop that.
     
  9. Offline

    Pencil

    No I mean it like that:

    Player starts hitting a block, the PlayerInteract event gets called, we cancel it for 40 ticks, then don't cancel it anymore. On a lag free server wouldn't that mean that the block wouldn't break because the interact event would be cancelled? It was just a thought, never said that it WILL work...
     
  10. Like I said, cancelling PlayerInteractEvent won't bother the client to break the block. It will still mine it and send the break packet. You might get the server to refuse that and deny the block break, that will send the block back to the player and your procedure starts again ...
     
  11. Offline

    Pencil

    Hm D: True
     
  12. Offline

    Daniel Heppner

    When someone starts breaking a block, the client sends the blockStartBreak packet. When it finishes mining the block, it sends the blockBreak packet. The server calculates how long they should be apart, and if they're too close, the server will ether cancel everything or wait for the time that the block was supposed to break, I'm not sure which.
     
  13. Offline

    Pencil

    Hm! When I get home I should give it a try anyways, we'll see then :D
     
    Daniel Heppner likes this.
  14. Offline

    Daniel Heppner

    I know all this because of my failed attempts at a client-sided insta mine.
     
  15. Offline

    Pencil

    Haha awesome :D I'll be home in an hour and I will be trying this no matter what everyone else says XD After I try it I'll know for sure :)

    Tho I'm glad my idea wasn't so bad after all
     
  16. http://mc.kev009.com/How_to_Write_a_Client#Digging
    Those statements suggest that the server waits until the expected time passed before allowing the client to break more blocks. It could be used for that purpose, but it wouldn't look very pretty and would have no/hardfly any effect on longer mine times like with obsidian.
     
    Daniel Heppner likes this.
  17. Offline

    Afforess

    It is in active development in Spout. It will be all server side. :p

    Expect to see it in the API for 1.1 ;)
     
    phaed, Digi and Pencil like this.
  18. Offline

    Pencil

    <3

    Dude your awesome!
     
  19. Any way that you will reveal how you intend to accopmlish that? I can't think of an only server-side solution that would look pretty (and I'm not only thinking of the cracks on the block).
     
  20. Offline

    Afforess

    Sure. My explanation will assume you are at least somewhat familiar with notchian code.

    Spout will replace all the blocks in Block.byId with a wrapper class that performs the identical function of the previous block.

    https://github.com/SpoutDev/Spout/blob/master/src/org/getspout/spout/block/mcblock/CustomBlock.java

    Then, there will be an API to set the hardness of a block at a location, or the hardness of all the blocks of a type.

    As for the visual half of it, you are correct. Vanilla clients will be unable to calculate the new hardness and will display it visually incorrectly, but will still be affected by. Spoutcraft clients will be sent the updated data and visually display it correctly.
     
Thread Status:
Not open for further replies.

Share This Page