Exemplo n.º 1
0
 public void SetArmRotation(Vector3 rotation, bool isLeftArm)
 {
     if (ModelRenderer.GetBone(isLeftArm ? "leftarm" : "rightarm", out var head))
     {
         head.Rotation = rotation;
     }
 }
Exemplo n.º 2
0
        private void UpdateModelParts()
        {
            if (ModelRenderer == null)
            {
                return;
            }

            ModelRenderer.GetBone("body", out _body);
            ModelRenderer.GetBone("rightArm", out _rightArmModel);
            ModelRenderer.GetBone("leftArm", out _leftArmModel);

            ModelRenderer.GetBone("leftLeg", out _leftLegModel);
            ModelRenderer.GetBone("rightLeg", out _rightLegModel);

            ModelRenderer.GetBone("leftSleeve", out _leftSleeveModel);
            ModelRenderer.GetBone("rightSleeve", out _rightSleeveModel);

            ModelRenderer.GetBone("leftPants", out _leftPantsModel);
            ModelRenderer.GetBone("rightPants", out _rightPantsModel);

            ModelRenderer.GetBone("jacket", out _jacketModel);
            ModelRenderer.GetBone("head", out _head);

            if (ModelRenderer.GetBone("hat", out EntityModelRenderer.ModelBone hat))
            {
                foreach (var c in hat.Parts)
                {
                    c.ApplyHeadYaw = true;
                    c.ApplyYaw     = false;
                    c.ApplyPitch   = true;
                }
            }
        }
Exemplo n.º 3
0
 public void SetBodyRotation(Vector3 rotation)
 {
     if (ModelRenderer.GetBone("body", out var head))
     {
         head.Rotation = rotation;
     }
 }
Exemplo n.º 4
0
 public void SetLegRotation(Vector3 rotation, bool isLeftLeg)
 {
     if (ModelRenderer.GetBone(isLeftLeg ? "leftleg" : "rightleg", out var head))
     {
         head.Rotation = rotation;
     }
 }
Exemplo n.º 5
0
        protected override void UpdateModelParts()
        {
            //base.UpdateModelParts();
            if (ModelRenderer.GetBone("head", out var head))
            {
                var rot = head.Rotation;
                rot.Y         = _yRotation;
                head.Rotation = rot;

                HeadBone = head;
            }
        }
Exemplo n.º 6
0
        /// <inheritdoc />
        protected override void UpdateModelParts()
        {
            base.UpdateModelParts();

            if (ModelRenderer != null && ModelRenderer.GetBone("root", out var bone))
            {
                var rot = bone.Rotation;
                rot.Y         = _yRotation;
                bone.Rotation = rot;

                RootBone = bone;
            }
        }
Exemplo n.º 7
0
        /// <inheritdoc />
        protected override void UpdateModelParts()
        {
            //base.UpdateModelParts();
            if (ModelRenderer.GetBone("head", out var head))
            {
                HeadBone = head;
            }

            if (ModelRenderer.GetBone("body", out var body))
            {
                Body = body;

                var bodyRotation = Body.Rotation;
                bodyRotation.Y = _yRotation;
                Body.Rotation  = bodyRotation;
            }
        }
Exemplo n.º 8
0
        private void OnInventorySlotChanged(object sender, SlotChangedEventArgs e)
        {
            var inHand = Inventory.MainHand;

            Log.Info($"Inventory slot changed.");

            if (inHand == null && ItemRenderer != null)
            {
                ItemRenderer = null;
                return;
            }

            if (inHand != null)
            {
                if (!string.IsNullOrWhiteSpace(inHand.Name))
                {
                    /*var itemModel = Alex.Instance.Resources.ResourcePack.ItemModels.FirstOrDefault(x =>
                     *      x.Key.Contains(inHand.Name, StringComparison.InvariantCultureIgnoreCase));
                     *
                     * ItemRenderer = new ItemModelRenderer(itemModel.Value, Alex.Instance.Resources.ResourcePack);*/

                    var renderer = inHand.Renderer;
                    if (renderer == null)
                    {
                        Log.Warn($"No renderer for item: {inHand.Name}");
                        return;
                    }

                    var itemModel = renderer.Model;

                    ItemRenderer = renderer;

                    if (this is Player)
                    {
                        if (itemModel.Display.TryGetValue("thirdperson_righthand", out var value))
                        {
                            ItemRenderer.Rotation    = value.Rotation;
                            ItemRenderer.Translation = value.Translation;
                            ItemRenderer.Scale       = value.Scale;

                            if (ModelRenderer.GetBone("rightItem", out EntityModelRenderer.ModelBone bone))
                            {
                                Log.Info($"First Person item model rendering ready.");

                                bone.Attach(ItemRenderer);
                            }
                            else
                            {
                                Log.Warn($"Bone not found: rightItem");
                            }
                        }
                        else
                        {
                            Log.Warn($"Failed to get item model display element!");
                        }
                    }
                    else
                    {
                        if (itemModel.Display.TryGetValue("thirdperson_righthand", out var value))
                        {
                            ItemRenderer.Rotation    = value.Rotation;
                            ItemRenderer.Translation = value.Translation;
                            ItemRenderer.Scale       = value.Scale;

                            if (ModelRenderer.GetBone("rightItem", out EntityModelRenderer.ModelBone bone))
                            {
                                Log.Info($"Third Person item model rendering ready.");

                                bone.Attach(ItemRenderer);
                            }
                        }
                        else
                        {
                            Log.Warn($"Failed to get item model display element!");
                        }
                    }
                }
            }
        }