Important CraftBukkit changes/bugs/additions to be aware of

Discussion in 'Bukkit Discussion' started by bergerkiller, Apr 1, 2013.

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

    bergerkiller

    I have noticed that, by now, I have had to write support for countless of things, and have had to rewrite even CraftBukkit itself to avoid more problems. Anyway, for those using Bukkit or CraftBukkit, these are important changes/bugs you have to be aware of. Note: These bugs are in the CraftBukkit internals, and as they are unsupported, it is not useful to write issue tickets for them. Or, so have I been told over the years.

    1.) nms.ItemStack can not be constructed safely anymore
    If a plugin used an NMS ItemStack (for some reason), be aware that you can not safely construct it anymore. It has some sort of backwards system where it uses Item.byId to see whether data is supported by the item. If you try to make an NMS ItemStack with an ID that does not correspond with an Item constant (e.g. air), it will literally cause an error. If for whatever reason you have a different type of item ID, like a constant, this will no longer work. In my case, this resulted in problems because my 'emptyItem' construction (with air ID) started failing. I now had to use reflection to alter the field values to change it to air.

    2.) Double chests
    YAY, double chests! Bukkit added a Double chest BlockState. Although I like this idea, double chests were unknown to my 'anything to a Location' calculation, so if you didn't expect a DoubleChest to be returned as it did...yeah update your plugins.

    3.) New minecart classes
    There are now around 6 minecart NMS and Bukkit classes. In my case, having to extend NMS classes, I have had to rewrite everything. Anyway, instead I now store a controller object for Entities inside the NMS entity to which I delegate methods. If you extended NMS minecarts to add functionality like I did...yeah this is now broken. Sorry.

    4.) Activator rails
    There are now activator rails, so add them to your 'allowed rails' constants and make sure that your plugin knows what it is. Note that no Bukkit.Material class is available for it yet, but don't worry, it uses the same format as powered/detector rails. Just construct a new CraftPoweredRail for this type for now.

    5.) TNT minecarts
    It's a nice feature, but also incredibly buggy. Since minecarts cause an explosion that can damage other minecarts (IN THE SAME TICK), this feature is prone to the infamous 'stack trace overflow' exceptions. This problem is only worsened by the fact that the entity is set dead AFTER the explosion. So yeah, more than one TNT minecart in one place + detonation = server crash. This wasn't really thought through, now was it? I truly recommend disabling explosions with TNT minecarts as source, because it is unsafe in it's current state. Fixing it is also nearly impossible, because no matter what: it is still an entity-to-entity algorithm.

    6.) Minecart blocks can be changed
    You can now change the displayed block type and data of a minecart by changing a value in the meta data. No problems with this thus far, and I like it!

    7.) Redstone event is somewhat useless
    It's not entirely broken, but not all redstone changes are covered any more. For instance, a redstone torch turning off no longer results in a redstone change for blocks around it. If you need to keep track of redstone levels around a given non-redstone block, use block_physics instead, it is guaranteed to give some useful results. I do believe that redstone_change was working for redstone torches before, but perhaps it has been decided that it should not fire events for non-redstone conducting blocks, like signs in my case.

    8.) Scoreboard API
    It's a nice feature, but every line on the scoreboard is limited to 15/16 characters, rendering it useless for long messages. Perhaps tickers can be made for it, and perhaps one can use to show short names and a value, but that's about it. Oh, and there are objectives to display per player, although I haven't looked into it much. No idea whether Bukkit has an API for it, lenis already wrote something simple. Be aware that you are limited to 3 scoreboard areas, so I do wonder how this is going to be managed with 20 plugins using the same area to display stuff...perhaps someone has to write a small library to deal with this?

    9.) Entity portal teleportation
    There is now a small code portion added for all entities to support portal teleportation. But, unfortunately, vehicle/passengers can not be teleported, and for that reason I cut it out of all my Entity Controller logic. I have my own teleport methods that does support vehicles/passengers, so when the time is right, I'll just add 3 lines of code to support it. Do be aware that there is (probably) no Bukkit event for this yet, and if you didn't support it, Entities could suddenly disappear from the world without you knowing it. Update your plugins if you keep track of entities!

    10.) Entity Tracker changes
    They are no longer synchronized - so multi-threaded access = doom. Also, trying to track the same entity twice now results in an error again, nice. So if you try to set an Entity Tracker by handling an Entity spawn event...yeah it will now crash the server. Although I do believe this is now a 'silently catched' error and will no longer crash the server. But still, it's an annoyance.

    11.) Passenger tracking is bugged
    Since 1.5.1, the EntityTrackerEntry contains a fine addition of sending a passenger<>vehicle attachment packet every 60 ticks. Unfortunately, the Minecraft client does not support this. I have no idea why that addition is even there, perhaps it hasn't been tested properly. Anyway, I had to completely rewrite the entity tracker entry logic with my own Vector-based EntityNetworkController to fix this. Fun times.

    12.) Vehicle spawn message for new viewers is broken
    This is actually an ancient bug, but still present in 1.5.1. The problem is simple: Instead of constructing a VehicleSpawn packet that uses the synchronized x/y/z location, it uses the current 'live' position of the entity. Result? It will send relative move packets that result in the vehicle translating a certain offset away from where it really is. In the case of Minecarts: new players see minecarts next to the rails. Since I already rewrote all of the network controller logic, fixing it was done quite easily.

    13.) Minecart sound results in a huge amount of client lag
    When being a slight distance away from moving minecarts, the client suffers a huge amount of frame rate drop, combined with other forms of lag. Luckily, you can disable Minecart sound server-side by disabling the EntityVelocity packet for minecarts. This is what I did, combined with a system where it sends a 0/0/0 velocity packet when being 16 blocks away from the Minecart. It fixed pretty much all the lag people were having. I think the lag has to do with the sound system of Minecraft running on the CPU...

    14.) Passengers taking vehicle with them
    Yep, this is now in. To avoid your vehicle being destroyed, make sure to eject the player in the PLAYER_QUIT event. I use it in TrainCarts to allow or disallow this feature in a configurable fashion. (I don't want trains to fall apart just like that)

    15.) Field name changes
    You have no idea how many fields have changed names, especially in the Entity class. Seriously, if you don't double-triple validate your fields...you will run into funny surprises, because fields have changed names but the same names still exist with the same types. So no compiler errors! Careful.

    Anything else? Feel free to continue this post.
     
    XlegitXcrazymanX likes this.
  2. Offline

    TnT

    leaky.bukkit.org is the place to report bugs.
     
  3. Offline

    bergerkiller

    TnT
    I know, this is more to show what the current status is of new features and important changes. Also, most other issues are problems inside the NMS internals, and are not supported by the Bukkit developers, like I stated in the OP.

    They also need a reason to fix things, and the ItemStack construction bug will not be fixed because it doesn't apply for people using the Bukkit API. Entity Tracker entry bugs are NMS internals and should not be touched at all without reason, and the fixes should be Mojangs' task.

    I am also pretty sure that the redstone event has a proper leaky issue ticket. This post/thread is a reminder for the plugin developers so they know what the current status is. It is by no means a report for Bukkit or other server software developers, they are aware of it, I'm sure.
     
  4. Offline

    feildmaster

    You forgot the "April Fools!"
     
    chaseoes and bergerkiller like this.
Thread Status:
Not open for further replies.

Share This Page