[CLOSED] Disable item floating/hovering/spinning ? (Overriding NMS EntityItem)

Discussion in 'Plugin Development' started by Digi, Aug 22, 2012.

Thread Status:
Not open for further replies.
  1. I'm overriding some methods for net.minecraft.server.EntityItem to use in a custom item type... but I can't seem to be able to disable the floating/hovering animation when it's dropped.

    I literally removed all stuff from the movement method ( h_() ) and I tried setting/forcing some values... noclipping, inair, motion, last position Y, yaw (names translated from MCP)... but nothing disabled floating nor rotation animatinos :/

    Does anyone know a way to stop item entities from floating and/or rotating ?

    EDIT: Actually... are they client side ? xD
     
  2. Offline

    Jnorr44

    Please, tell me about it in romanian XD
     
  3. Offline

    Megolas

    I do believe they are clientside - but if you want to be sure for 100%, delete the spinning method (If it exists, i mean) from a custom CraftBukkit version of yours :)
     
  4. Offline

    Malikk

    I don't think it's client side, in a plugin of mine I added the ability to throw spawn eggs and then I had a scheduler checking for when the egg had stopped moving, based on it's location. I'm pretty sure that the hover movement was changing the item's Y value, so I ended up only making it accurate to the block.

    That's just my two cents.
     
  5. Offline

    Phinary

    Pretty sure it is client sided. If you lag out of a server, items continue to hover and spin, just like normal. If it was server sided, it would probably stop, just like how sounds (most of them) stop since they are server sided now. No way to really be sure unless you test it!
     
  6. Well I guess the animation itself is client sided... but I'm hoping for a control toggle or something... do all entities that look like items float and rotate ? :confused: Or is there a diferent entity that I can use ?
    The arrow, snowball and fireball don't float but they're not really configurable... any ideeas ? XD
     
  7. Offline

    Megolas

    Hmm... use another player and check whether you see the exact same animation part each second, if its client side, i guess it would be different (1 must join as the item is already spinning
     
  8. Offline

    Icyene

    I am GUESSING they are client side; using a mod like Optifine you can disable the floating by turning item animations to off.
     
  9. Yes I'm over that, I need alternatives to avoid the animation xD
    Is there a way to set item icons/blocks on other entities (which shouldn't animate on client) ?

    I only need the item's icon or 3d block to be visible at a location, I don't need it to do anything else :}
     
  10. Hmm, quick question...
    If I set entity's locX/Y/Z and motX/Y/Z along with positionChanged and velocityChanged to true every tick (in its h_() method which is called every tick)... would that send extra network packets or are they sent anyways and I'll just change what it sends ?
     
  11. This is where the packets are sent by the tracker. I'm pretty sure it keeps its own reference of previous locations it sent, dunno how you could affect that or if that even helps.

    The only thing coming to my mind that could possibly your problem would be constantly spamming out destroy & spawn packets, (maybe) keeping the item's animation at its beginning for the client. Would probably be killing bandwith when applied in large numbers, though ;)
    But yes, the spinning and hovering up and down is client-side, unfortunately.
     
  12. I see, I've dropped that ideea after some tests tough.

    I still have to re-spawn the item because it vanishes after 5 minutes even if I set age to 0... which is exacly what the despawn event does when cancelled... which I found an issue report that it doesn't work.
    I would make a patch for respawning the item if event is cancelled but I'm curious if there is another better way...

    That idea wasn't for the animation tough, I wanted it to prevent gravity and moving around caused by other blocks being on them... but I only need that for glass and I noticed the item gets out of the block 20 seconds+ after it's placed, so I'm respawning the item every 20 seconds if the holder is a glass block.. or after 5 minutes for every other supported block type.

    So yeah, I guess this the thread's objective is currently impossible :/
     
  13. Funnily enough, preventing despawn is way easier than you would imagine (since you're already working with NMS code anyway). I solved it by simple setting the EntityItem's "age" attribute to Integer.MIN_VALUE. See what I did there? Since that value is decreased by 1 each tick and it despawns when it reaches 6000, that will take more than 3 real-time years now, and it's automatically persistent ;)

    You don't even need an own class extending EntityItem just for that, you could just do:
    Code:java
    1. net.minecraft.server.Entity e = ((CraftItem) bukkitItem).getHandle();
    2. ((EntityItem) e).age = Integer.MIN_VALUE;
     
  14. Like I said, it's what the ItemDespawnEvent uses and even setting it to 0 each tick does absolutely nothing to prevent despawn.

    I've also completly disabled the age incrementing system by overwriting h_() entirely and blanking it... and now just to be sure, a small debug:
    Code:
    @Override
    	public void h_()
    	{
    		System.out.print("age = " + age);
    	}
    result of above debug (open)


    It's not incremented anymore, item still despawns.... or goes invisible, I'm unsure because I also disabled player pickup :}
     
  15. Well, setting the age worked for me, and it's also the only thing the despawning algorithm is using (in EntityItem.h_()). I've only really tested it with 1.2.5, the client might get rid of the item automatically after 6000 ticks by now. If that's the case, and the item actually stays there sever-side (which should definately be the case), relogging should show the item again, and your debug console statement should continue printing after it "disappeared".
     
  16. Hmm... even tough, respawning the item seems the better and easiest option, because if I were to resend the pickup packet to clients I'd have to find the nearby clients and all that stuff which the game itself handles.
     
  17. Offline

    ibWill

    What is the method for controlling whether or not the item falls? Digi Megolas
     
Thread Status:
Not open for further replies.

Share This Page