Block Physics Event

Discussion in 'Plugin Development' started by Faelsel, May 28, 2012.

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

    Faelsel

    How to know the start of this event?

    For example...
    World generation -> call physics each block placed
    BreakEvent/Place Event -> physics...

    and so on...
    How to know which of them is the first event calling phyisics?


    If is not possible, what event in world generation is the one placing blocks/calling physics, and how to fix removing physics on world creation? (I've to create my world generator? i hope not xD)

    Sorry for bad english =)

    up

    please =(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  2. https://github.com/Bukkit/CraftBukkit/blob/master/src/main/java/net/minecraft/server/World.java#L501 tells us that you can set suppressPhysics to true to suppress all physics. This would look something like this:
    Code:java
    1. World world = getSomeWorld();
    2. net.minecraft.server.World notchWorld = ((CraftWorld)world).getHandle();
    3. boolean oldState = notchWorld.suppressPhysics;
    4. notchWorld.suppressPhysics = true;
    5. //Do stuff here...
    6. notchWorld.suppressPhysics = oldState;

    But without knowing what exactly you want to do I think nobody is able to really help you.
     
    Faelsel likes this.
  3. Offline

    Faelsel

    result in an error:
    CraftWorld cannot be resolved to a type
     
  4. Cause you are leaving the bukkit API. CraftWorld is a CraftBukkit, net.minecraft.server.World is a notch class. To fix this kick the bukkit.jar out of your build path and put the craftbukkit.jar in instead. Then you should be able to import and use this classes. :)
     
  5. Offline

    Faelsel

    uhm?
    i used to place craftbukkit 1.2.5 R2.0.jar in java build path..... there is other thing to use instead of this one?
     
  6. Faelsel: There is craftbukkit and bukkit. Bukkit is the API you normally use to develop plugins while craftbukkit is the server software implementing the API. So remove the API from your build path and add in the server software which contains all the classes you need (notch code + craftbukkit changes + bukkit API). After that import CraftWorld like any other class.
     
  7. Offline

    ZachBora

    V10lator I always use the craftbukkit :eek: , does that cause me to miss anything?
     
  8. Offline

    Faelsel

    But i am already using it as import...
    [​IMG]
    How to import server software so? this is the JAR the batch file use as executable for server...
     
  9. Offline

    ZachBora

    That should be enough. When you click CraftWorld it doesn't give you the option to import it?
    It should be
    import org.bukkit.craftbukkit.CraftWorld;

    I use it in this code, maybe you can check for differences :
    https://github.com/ZachBora/CloneMe...dcretornica/cloneme/ScheduledBlockChange.java
     
  10. No. CraftBukkit implements Bukkit. Else our plugins wouldn't run at it. ;)
     
  11. Offline

    ZachBora

    So I guess it's only a problem if someone makes another server mod that implements Bukkit.
     
  12. I have a conflict with CraftBukkit+ in RideThaDragon, but only cause of the return of getServer().getVersion(). I use this to check if the CB version is new enough to enable some advance stuff, but my version parsing code fails with CraftBukkit+:
    int bv = Integer.parseInt(s.getVersion().split("-b")[1].substring(0, 4));
    As you see I'm not leaving the bukkit API in here, so that's not related to linking against CraftBukkit. All cb/notch code I'm calling are working as they should (tested it by removing this check). But you will have problems with the spout server if you leave the bukkit API, I think...
     
  13. Offline

    Faelsel

    I had to import manually it... Eclipse doesnt know that part of the JAR, so i had to write the import org.bukkit.craftbukkit and so on.....
    I tried to add this code on "onEnable()" putting the world as "Bukkit.getWorld(MY_WORLD_NAME);"

    after adding that code in the onEnable.
    PhysicsPlugin at Java:27 is exactly the code i added...(look on the top of this post)
     
  14. Offline

    ZachBora

    The world isn't loaded when your plugin is enabled. There's a plugin.yml thing to make your plugin load after world load.

    Put:
    load: POSTWORLD
    by default it's STARTUP

    Reference: http://wiki.bukkit.org/Plugin.yml
     
    Faelsel likes this.
  15. Offline

    Faelsel

    solved... or better:
    using POSTWORLD the problem persists, but i changed the position of the code... so i set the stop of physics only after "WorldGeneration()" so the "CraftWorld" is obviously already done all time.

    Thank you guys, its time to give you some "Likes" :D
     
Thread Status:
Not open for further replies.

Share This Page