Get block thunder striked

Discussion in 'Plugin Development' started by xboxhacks, May 8, 2012.

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

    xboxhacks

    Well i made a plugin which makes thunder strike the player when they join(Not hurting them) Is it possible to get the block the thunder strike'd and put out the fire or cancel the fire effect all together?

    It has to come after this code,
    Code:java
    1.  
    2. Location loc = event.getPlayer().getLocation();
    3. loc.getWorld().strikeLightningEffect(loc);
    4.  
     
  2. Offline

    Nitnelave

    Well, you can loop around the player and put out fire in a 5 block radiux, for example
     
  3. Offline

    xboxhacks

    And how would i do that?
    CorrieKay
     
  4. Offline

    CorrieKay

  5. Offline

    xboxhacks

  6. Offline

    JollyGiant16

    xboxhacks
    I came up with

    if(blockId == 352){
    Location location = block.getLocation();
    World world = player.getWorld();
    world.strikeLightning(Location);

    That's when I left click with a bone it strikes, Give me your code and I'll fix it for that to see what I can do
     
  7. Offline

    xboxhacks

    Basically after the If player has permission i have this
    Code:text
    1.  
    2. Location loc = player.getLocation();
    3. loc.getWorld().strikeLightningEffect(loc);
    4.  

    Also player is player = event.getPlayer() in the syntax.
     
  8. Offline

    JollyGiant16

    Dose it work so when you log on it automaticly strikeslightning
     
  9. Offline

    xboxhacks

    actually i did test it on stone and it didn't catch fire it must just be sand that catches alight. I will test on different materials later.

    If you want to help test here is the plugin release
    http://dev.bukkit.org/server-mods/thunderjoinplus/

    Actually is there a way so after the lightningstrike effect it does a 1x1 block radius(Basically block they are standing on) To check for fire then if fire is there then it puts it out or changes fire to air?

    Here is what didn't catch alight.

    Code:
    soulsand
    glowstone
    nether stairs
    nether fence
    glass pane
    iron bars
    chest
    glass
    bookshelfs
    stone stairs
    cobble stairs
    brick stairs
    gate
    piston
    sticky piston
    trap door
    enchant table
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  10. I think the fire is client side. If you log off and on, is the fire still there? If so: There's really fire. If not: It's client side fire.

    If it's server side:
    Code:java
    1. int radius = 10;
    2. radius /= 2;
    3. World world = loc.getWorld();
    4. Block block;
    5. for(int x = loc.getBlockX() - radius; x < loc.getBlockX() + radius; x++)
    6. for(int y = loc.getBlockY() - radius; y < loc.getBlockY() + radius; y++)
    7. for(int z = loc.getBlockZ() - radius; z < loc.getBlockZ() + radius; z++)
    8. {
    9. block = world.getBlockAt(x, y, z);
    10. if(block.getType() == Material.FIRE)
    11. block.setType(Material.AIR);
    12. }

    If it's client side there are things you can do, too (sending faked block/chunk updates to players who are glitched), but I wouldn't as this just bloats the plugin for almost no reason.
     
  11. Offline

    xboxhacks

    I don't think it is completely client side because other players can see that fire when someone joins. But when they logout it disappears. Its confusing if you want to see for your self the plugin is on BukkitDev(Link above somewhere)
     
  12. Just had a look: V10lator had the node ThunderJoin.thunder while Alkoed didn't have it.
    Both players joined the game: V10lator with a lighning stike that setted a wool block on fire. Both players were able to see the fire.
    Now Alkoed left and re-joined the game. At this point he became the chunk like it is at the server and while V10lator still saw the fire (no block/chunk update from the server, so no need to turn the fire off) Alkoed didn't anymore:
    [​IMG]

    Another proof that the fire is client side: It won't spread nor get off (without a block/chunk update)...
     
  13. Offline

    xboxhacks

    ok I will look into a coding a chunk update, If you know how please tell me

    CorrieKay @Nitnelav
     
  14. xboxhacks Something like that should do the trick:
    Code:java
    1. Location loc = player.getLocation(); // The player is the one who striked the lightning
    2. Chunk chunk = loc.getChunk();
    3. List<ChunkCoordIntPair> chunkCoordIntPairQueue;
    4. ChunkCoordIntPair ccip = new ChunkCoordIntPair(chunk.getX(), chunk.getZ());
    5. int threshold = (getServer().getViewDistance() << 4) + 32;
    6. threshold *= threshold;
    7. int px;
    8. int pz;
    9. int cx = chunk.getX() * 16;
    10. int cz = chunk.getZ() * 16;
    11. for(Object o: chunk.world.players)
    12. {
    13. player = (EntityPlayer)o;
    14. loc = player.getBukkitEntity().getLocation();
    15. px = loc.getBlockX() - cx;
    16. pz = loc.getBlockZ() - cz;
    17.  
    18. if((px * px) + (pz * pz) < threshold)
    19. {
    20. chunkCoordIntPairQueue = (List<ChunkCoordIntPair>)player.chunkCoordIntPairQueue;
    21. if(!chunkCoordIntPairQueue.contains(ccip))
    22. chunkCoordIntPairQueue.add(ccip);
    23. }
    24. }

    Credits go to desht and bergerkiller :)

    //EDIT: Changed the example above a bit...
     
Thread Status:
Not open for further replies.

Share This Page