Filled Projectile Block Damage

Discussion in 'Plugin Requests' started by AlwaysAllstar, Feb 16, 2020.

  1. Offline

    AlwaysAllstar

    Plugin category: Addon

    Minecraft version: 1.14

    Suggested name: ShotBlockDamage

    What I want: I'm using Crackshot for my server to have many guns. They shoot snowballs and eggs. I thought it would be very cool whenever the bullet (snowball/egg) or an explosion (fireball/tnt) hits a block, it gets damaged/cracked a little like when you mine it. It never breaks though. Note: Explosions should have a radius of damaged blocks. I found a plugin similar but unfortunately it doesn't work. Here is an example config I have in mind:

    #Whether the projectile is enabled or not
    Projectiles:
    Egg: true/false
    Snowball: true/false
    Arrow: true/false
    Explosions: true/false

    #Time in seconds it takes for block to go back to normal
    Regeneration: <Time>

    #How damaging should projectiles be? A low number being a slightly cracking a little more per hit/A big number being cracking the entire block in one hit
    Damage: <Damage>

    I apologize if I missed anything. You can change it to whatever may be easier as long as the projectiles and explosions crack the block(s) it hits/explodes near and heals back to normal after some time.

    Ideas for commands: No commands needed.

    Ideas for permissions: No permissions needed.

    When I'd like it by: As soon as possible. :)
     
  2. Online

    Xp10d3

  3. Offline

    AlwaysAllstar

    That's a shame, thank you for your help. :)
     
    Xp10d3 likes this.
  4. Online

    Xp10d3

    Np. But if you want maybe leave the forum unfilled? I don't know enough about entities in plugin development to give a solid, "No, this is impossible."
     
    AlwaysAllstar likes this.
  5. Offline

    AlwaysAllstar

    Bump if anyone knows how they might be able to do this. :)
     
  6. Offline

    developerjose

    I believe it is possible to do this by using the ProjectileHit event and BlockExplode/EntityExplode events.
    You can crack blocks using packets, specifically with Packet55BlockBreakAnimation/PacketPlayOutBlockBreakAnimation. It seems a few other people have attempted to do this in the past, as I have seen several forums posts on different websites talking about programming something similar.

    Edit: Please try this testing version (https://github.com/DeveloperJose/Java-Minecraft-ProjectileBlockDamage/releases/tag/v1.0_MC1.14) and let me know what you think about it :) I spent around 5 hours working on it, it seems to work fine for me.
     
    Last edited: Feb 25, 2020
    KarimAKL likes this.
  7. Offline

    AlwaysAllstar

    Thank you so much @developerjose ! It's really cool haha. A few things:
    1) The blocks don't seem to heal until around 20 seconds has passed (I had it set to 10 in my config). I noticed in the config too that you mentioned it should be healed within 15 seconds client wise. So.. that's kind of strange. It's not a big deal for my purposes I just thought I should mention it. Maybe its my server being weird too I'm not sure. Either way its not a big deal.
    2) When you hit a block more than once it doesn't increase the crack. I want it to, for example, set damage to a low number in the config (like 2). Then I can throw one snowball it'll do 2 damage, if I throw another one it'll do another 2 damage so the crack increases with each hit (the amount it increases depends on the damage in the config). So basically whatever I set the damage in the config is how much it gets damaged each time its hit. If I set it to 1 it'll take 9 snowballs/eggs/arrows to crack it all the way, or if I set it to 9 it'll only take one.
    3) Somewhat adding onto two, whenever I hit a block more than once rather than spreading the crack it just either darkens or lightens the color of the crack. Here's what I mean:

    One snowball hit looks like this (Set on 5 damage):
    https://gyazo.com/ef21873a2a5a27dbd91f53a2767a2abd
    3 Hits:
    https://gyazo.com/08d6de8f4058955bb63e5bbabbd48dd5
    5 Hits:
    https://gyazo.com/76b9e1e34b5c055589a8f527eb627d69
    7 Hits:
    https://gyazo.com/7b3002b4253083afff8792f306b24c2b

    EDIT: Can you use decimals for the explosion radius? I have x y and z set to 1 and it still seems a bit too big.

    I'm sorry for loading this all onto you after you spent so much time on it, it really is working great for the most part. These are the only things I noticed. Thank you again! :)
     
  8. Offline

    developerjose

    1) That's probably because I'm not too strict with the timing of that in the code. Being a little lenient with the timing allows the server performance to not be so heavily impacted.

    2) Ah I see, so that's what you wanted it to do. I just did the very basics of cracking, I don't keep track of each block's damage or anything. To add what you requested it shouldn't be too difficult but I don't have time at the moment. Perhaps I could get it done over the weekend or next week.

    3) I don't know what you are talking about. I didn't implement anything for hitting a block more than once. I am always just sending the same breaking packets. If the crack is changing the color, it's probably client-side.

    4) For the TNT blast radius, I am actually not taking the center of the explosion and checking around it. That would be time consuming, as there are a lot of blocks to check. I'm actually just taking every single block adjacent to the blocks which will be exploding. I'll modify the config a bit with the comments and names as well as add a few more options for you to play around so you can have it be to your desire.

    However, I cannot do so at the time. It was mostly a quick experiment I did, so it wasn't meant to be a final version or anything.
     
  9. Offline

    AlwaysAllstar

    @developerjose let me know if you ever add anything else or make modifications. Thank you again. :)
     

Share This Page