Solved Hopper Tick

Discussion in 'Plugin Development' started by mcoder, Apr 11, 2013.

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

    mcoder

    Hi,

    I am currently trying to find the cause for a hopper to try to drop/suck items. By cause I mean the part of the code, which actually triggers the hoppers every so often. It must be somewhere in the net.minecraft classes, but after many days of research, I still can't quite figure out where it is actually launched. I would really like to find it though, since the frequent hopper are causing a lot of lag (yes, I confirmed that it actually is teh cause by various tests and logs). Once I figured that part out, I'll look into implementing that in a plugin/modifying the classes directly.

    Thanks for any help, mcoder
     
  2. Offline

    chasechocolate

  3. Offline

    mcoder

    That's not what I'm looking for. I'm well aware of that event, but it doesn't help at all in my case. Even if I cancle it, it's still fireing the event 0.125 to 4 times / tick for each hopper, which is just way to much, considdering that lots of plugins already listen to that event and do their checks. What I'm looking for is the actual source, the part of the code that activates hopper each tick.
     
  4. Offline

    desht

    Knowing the event thrown is a big clue, because you can then search the CraftBukkit source for where that event is thrown.

    Easiest way to do that is to "git clone https://github.com/Bukkit/CraftBukkit.git", then "git grep InventoryMoveItemEvent" in the resulting CraftBukkit directory.

    That will point you to src/main/java/net/minecraft/server/TileEntityHopper.java, and the private u() and tryTakeInItemFromSlot() methods in that class, and a little more tracing will point you to the j() then h() methods in the same class; h() is inherited from TileEntity. And finally, a call to tileentity.h() can be seen in the World tickEntities() method, where all tile entities for that world are ticked.
     
    mcoder likes this.
  5. Offline

    mcoder

    Thanks a lot! Thats what I tried for hours, I started with the event aswell, but somehow never came to World. I probably got lost somewhere in all those obfuscated methods. Again, thanks a lot :)
     
Thread Status:
Not open for further replies.

Share This Page