Solved Iron Golem attack animation

Discussion in 'Plugin Development' started by hawkfalcon, Sep 19, 2012.

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

    hawkfalcon

    Is there a way to make an iron golem swing its arms like it's hitting something?
    Like this for players:
    Code:
      EntityPlayer p = ((CraftPlayer)player).getHandle();
    p.netServerHandler.sendPacket(p, new Packet18ArmAnimation(p, 1));
    But for iron golems instead?
    Also, where do I go to see all the different packets?:3
     
  2. Offline

    travja

    What is the instance where you want to play the animation?
     
  3. Offline

    hawkfalcon

    :confused: why do you need to know? ;p
    I am making a IronGolem servant plugin. He is going to punch down trees.
     
  4. Offline

    travja

    Ok, so possibly create a zombie in the tree, send the update to the golem, he will automatically go punch it, you can even use .setTarget method to force him to that zombie, somehow keep the zombie in the tree, he'll go hit it, when he does, use EntityDamageEvent to get if it was the right zombie, if it was, chop down the tree, and delete the zombie entity.
     
  5. Offline

    hawkfalcon

    :(
    I was hoping I could trigger some packet, as that seems as though it would be a bit buggy.
     
  6. Offline

    Jnorr44

    hawkfalcon I can see what I can come up with. Maybe I could even write a little method you can use to make it easier.
     
    hawkfalcon likes this.
  7. Offline

    hawkfalcon

    Okay:D That would be really awesome. Thanks:3
     
  8. Offline

    Jnorr44

    I haven't yet been able to figure out how to make the iron golem hit stuff, but I have been able to get the block to destroy.

    Code:
    package com.github.Reference.JamesNorris;
     
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.entity.IronGolem;
     
    import net.minecraft.server.MathHelper;
     
    public class GolemHit {
        private IronGolem ig;
       
        public void hit() {
            World w = ig.getWorld();
            Location loc = ig.getLocation();
            int i = MathHelper.floor(loc.getX());
            int j = MathHelper.floor(loc.getY() - 0.20000000298023224D - (double) ig.getEyeHeight());
            int k = MathHelper.floor(loc.getZ());
            int l = w.getBlockAt(i, j, k).getTypeId();
     
            if (l > 0) {
                w.getBlockAt(i, j, k).breakNaturally();
            }
        }
    }
     
    hawkfalcon likes this.
  9. Offline

    hawkfalcon

    Cool, thanks, but I coulda done that ;p
    I just needed the Golem arm swing so it looks normal.
    But thanks anyway :p
    Edit: Oh, thats to make the block in from of it break :D coolio:3
    Making a whole IronGolem lib?:)
     
  10. Offline

    Jnorr44

    Yeah, I've been going through NMS, but I hate how its obfuscated. When the un-obfuscated code comes out in the mod update, I would be able to find it in 1/80000 of the time lol. I can keep trying though.
     
  11. Offline

    kyle1320

    hawkfalcon
    Code:
    net.minecraft.server.EntityIronGolem golem = (net.minecraft.server.EntityIronGolem)((CraftEntity)e).getHandle();
    golem.world.broadcastEntityEffect(golem, (byte) 4);
     
    hawkfalcon likes this.
  12. Offline

    hawkfalcon

    NMS..? :)

    Ooh, would that really work? :D Awesomeness!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  13. Offline

    kyle1320

    Yep, tested working here :D
    If you want the sound:
    Code:
    golem.world.makeSound(golem, "mob.irongolem.throw", 1.0F, 1.0F);
     
    hawkfalcon likes this.
  14. Offline

    Jnorr44

    Code:
    package com.github.Reference.JamesNorris;
     
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.entity.IronGolem;
     
    import net.minecraft.server.EntityIronGolem;
    import net.minecraft.server.MathHelper;
     
    public class GolemHit extends EntityIronGolem {
        public GolemHit(net.minecraft.server.World world) {
            super(world);
        }
     
        private IronGolem ig;
     
        public void hit() {
            World w = ig.getWorld();
            Location loc = ig.getLocation();
            int i = MathHelper.floor(loc.getX());
            int j = MathHelper.floor(loc.getY() - 0.20000000298023224D - (double) ig.getEyeHeight());
            int k = MathHelper.floor(loc.getZ());
            int l = w.getBlockAt(i, j, k).getTypeId();
     
            if (l > 0) {
                w.getBlockAt(i, j, k).breakNaturally();
                this.world.broadcastEntityEffect(this, (byte) 4);//I also know that 11 works!
                this.world.makeSound(this, "mob.irongolem.throw", 1.0F, 1.0F);
            }
        }
    }
    This should make the throw effect, not sure what 11 does though.

    EDIT: darn, kyle got to it first...
     
    hawkfalcon likes this.
  15. Offline

    hawkfalcon

    Awesome, you both got it ;)
    How exactly/ where are you getting this information?:)
     
  16. Offline

    Jnorr44

    glen3b and hawkfalcon like this.
Thread Status:
Not open for further replies.

Share This Page