예제 #1
0
        public virtual void DamageItemInHand(ItemDamageReason reason, Entity target, Block block)
        {
            if (Player.GameMode != GameMode.Survival)
            {
                return;
            }

            var itemInHand = GetItemInHand();

            var unbreakingLevel = itemInHand.GetEnchantingLevel(EnchantingType.Unbreaking);

            if (unbreakingLevel > 0)
            {
                if (new Random().Next(1 + unbreakingLevel) != 0)
                {
                    return;
                }
            }


            if (itemInHand.DamageItem(Player, reason, target, block))
            {
                Slots[InHandSlot] = new ItemAir();

                McpeLevelSoundEvent sound = McpeLevelSoundEvent.CreateObject();
                sound.soundId    = 5;
                sound.blockId    = -1;
                sound.entityType = 1;
                sound.position   = Player.KnownPosition;
                Player.Level.RelayBroadcast(sound);
            }

            SendSetSlot(InHandSlot);
        }
예제 #2
0
        public virtual Item DamageArmorItem(Item item)
        {
            if (Player.GameMode != GameMode.Survival)
            {
                return(item);
            }

            var unbreakingLevel = item.GetEnchantingLevel(EnchantingType.Unbreaking);

            if (unbreakingLevel > 0)
            {
                if (new Random().Next(1 + unbreakingLevel) != 0)
                {
                    return(item);
                }
            }

            item.Metadata++;

            if (item.Metadata >= item.Durability)
            {
                item = new ItemAir();

                McpeLevelSoundEvent sound = McpeLevelSoundEvent.CreateObject();
                sound.soundId    = 5;
                sound.blockId    = -1;
                sound.entityType = 1;
                sound.position   = Player.KnownPosition;
                Player.Level.RelayBroadcast(sound);
            }

            return(item);
        }
예제 #3
0
        public override void SpawnEntity()
        {
            Velocity            = Force = KnownPosition.GetDirection().Normalize() * 0.06055374f;
            KnownPosition.Yaw   = (float)Velocity.GetYaw();
            KnownPosition.Pitch = (float)Velocity.GetPitch();

            McpeLevelSoundEvent sound = McpeLevelSoundEvent.CreateObject();

            sound.soundId    = 55;
            sound.blockId    = -1;
            sound.entityType = 1;
            sound.position   = KnownPosition;
            Level.RelayBroadcast(sound);

            base.SpawnEntity();
        }
예제 #4
0
        public override void DespawnEntity()
        {
            McpeEntityEvent entityEvent = McpeEntityEvent.CreateObject();

            entityEvent.runtimeEntityId = EntityId;
            entityEvent.eventId         = 25;
            entityEvent.data            = 0;
            Level.RelayBroadcast(entityEvent);

            base.DespawnEntity();

            McpeLevelSoundEvent sound = McpeLevelSoundEvent.CreateObject();

            sound.soundId    = 56;
            sound.blockId    = -1;
            sound.entityType = 1;
            sound.position   = KnownPosition;
            Level.RelayBroadcast(sound);
        }