Animation (Entities)

Started by MrScautHD on Sat, 12/05/2020 - 15:47

Topic category: User side tutorials

Last seen on 22:20, 26. Jan 2021
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Animation (Entities)
Mon, 12/07/2020 - 12:29 (edited)

6

This is my Tutorial for Custom Entities Animations:

Code made by RollTye!

1.Create a Entity

2.Add a Procedure OnEntityTick

3.Save the Entity

4.Go in your Entity Code

5.Add: NetworkLoader.registerMessages();

1

6.Add:

            if (!this.world.isRemote)
                NetworkLoader.INSTANCE.send(PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> this),
                        new CustomNameSpinPacket(this.getEntityId(), this.getPersistentData().getDouble("Animation"))); //Animation is the NBT you can use your Own NBT!                            //Change CustomName to a Name!

2

7.Add:

        public void setRotationAngles(Entity e, float f, float f1, float f2, float f3, float f4) {
            this.<Group name>.rotateAngleX = f2 / (180 / (float) Math.PI); //Group name is the Group in the model! change it to your group name!
            if (e instanceof LivingEntity) {
                this.<Group name>.rotateAngleX = (float) ((LivingEntity) e).getPersistentData().getDouble("Animation"); //Animation is the NBT you can use your Own NBT!   
            }
        }
    }

    // packages System
    private static class NetworkLoader {
        public static SimpleChannel INSTANCE;
        private static int id = 1;
        public static int nextID() {
            return id++;
        }

        public static void registerMessages() {
            INSTANCE = NetworkRegistry.newSimpleChannel(new ResourceLocation("Your-Mod-id", "Your-Mod-id_link"), () -> "1.0", s -> true, s -> true);
            INSTANCE.registerMessage(nextID(), CustomNameSpinPacket.class, CustomNameSpinPacket::encode, CustomNameSpinPacket::decode, CustomNameSpinPacket::handle); //CustomName is the Same name as by Number 6!
        }
    }

    // First Animation
    private static class CustomNameSpinPacket {
        private double animation;
        private int entityId;
        public CustomNameSpinPacket(int entityId, double animation) {
            this.animation = animation;
            this.entityId = entityId;
        }

        public static void encode(CustomNameSpinPacket msg, PacketBuffer buf) {
            buf.writeInt(msg.entityId);
            buf.writeDouble(msg.animation);
        }

        public static CustomNameSpinPacket decode(PacketBuffer buf) {
            return new CustomNameSpinPacket(buf.readInt(), buf.readDouble());
        }

        public static void handle(CustomNameSpinPacket msg, Supplier<NetworkEvent.Context> ctx) {
            ctx.get().enqueueWork(() -> {
                Entity entity = Minecraft.getInstance().world.getEntityByID(msg.entityId);
                if (entity instanceof LivingEntity) {
                    ((LivingEntity) entity).getPersistentData().putDouble("Animation", msg.animation);
                }
            });
            ctx.get().setPacketHandled(true);
        }
    }

4

8.Press Clt+w(for the Imports)

9.Save The Entity with Locked Code

10.You can now Rotate the Model Group with the nbt Animation

Need you Help? Discord: MrScautHD#0350

Edited by MrScautHD on Mon, 12/07/2020 - 12:29
Last seen on 22:20, 26. Jan 2021
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Thx :)
Sat, 12/05/2020 - 17:00

Thx :)

Last seen on 02:54, 3. Jan 2021
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
very noice 
Sat, 12/05/2020 - 17:41

very noice 

Last seen on 22:20, 26. Jan 2021
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Thxx :)
Sat, 12/05/2020 - 18:27

Thxx :)

Last seen on 23:20, 26. Jan 2021
Joined Aug 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Nice tutorial! :D (I won't…
Mon, 12/07/2020 - 14:47

Nice tutorial! :D (I won't make a plugin for this one. xD)

Last seen on 22:20, 26. Jan 2021
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
thx xD
Mon, 12/07/2020 - 19:55

thx xD

Last seen on 22:07, 26. Jan 2021
Joined Mar 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Saving Awesome Tutorial…
Fri, 12/18/2020 - 16:37

Saving Awesome Tutorial..... Initializing Chrome

Saving Awesome Tutorial..... Bookmarking

Saving Awesome Tutorial..... Screenshotting

Saving Awesome Tutorial..... Finalizing

Saving Awesome Tutorial..... Complete

Seriously dude this is a very helpful tutorial. Although it would be better if you added where you should insert each code snippet and the finished piece of code.