content: package com.github.alexthe666.iceandfire.message;
  
  import com.github.alexthe666.iceandfire.IceAndFire;
  import com.github.alexthe666.iceandfire.entity.EntityDeathWorm;
  import net.minecraft.network.FriendlyByteBuf;
  import net.minecraft.world.entity.Entity;
  import net.minecraft.world.entity.player.Player;
  import net.minecraftforge.fml.LogicalSide;
  import net.minecraftforge.network.NetworkEvent;
  
  import java.util.function.Supplier;
  
  
  public class MessageDeathWormHitbox {
  
      public int deathWormId;
      public float scale;
  
      public MessageDeathWormHitbox(int deathWormId, float scale) {
          this.deathWormId = deathWormId;
          this.scale = scale;
      }
  
      public MessageDeathWormHitbox() {
      }
  
      public static MessageDeathWormHitbox read(FriendlyByteBuf buf) {
          return new MessageDeathWormHitbox(buf.readInt(), buf.readFloat());
      }
  
      public static void write(MessageDeathWormHitbox message, FriendlyByteBuf buf) {
          buf.writeInt(message.deathWormId);
          buf.writeFloat(message.scale);
      }
  
      public static class Handler {
          public Handler() {
          }
  
          public static void handle(MessageDeathWormHitbox message, Supplier<NetworkEvent.Context> context) {
              context.get().setPacketHandled(true);
              Player player = context.get().getSender();
              if(context.get().getDirection().getReceptionSide() == LogicalSide.CLIENT){
                  player = IceAndFire.PROXY.getClientSidePlayer();
              }
              if (player != null) {
                  if (player.level != null) {
                      Entity entity = player.level.getEntity(message.deathWormId);
                      if (entity != null && entity instanceof EntityDeathWorm) {
                          EntityDeathWorm worm = (EntityDeathWorm) entity;
                          worm.initSegments(message.scale);
                      }
                  }
              }
          }
      }
  }