Esempio n. 1
0
 public override void UsedByEntity(World world, bool leftClick, LivingEntity usedBy)
 {
     var player = usedBy as PlayerEntity;
     if (!leftClick)
     {
         if (!Item.Empty)
         {
             Orientation++;
             OnPropertyChanged("Metadata");
         }
         else
         {
             if (!player.SelectedItem.Empty)
             {
                 var slot = player.SelectedItem;
                 Item = new ItemStack(slot.Id, 1, slot.Metadata, slot.Nbt);
                 if (player.GameMode != GameMode.Creative)
                 {
                     slot.Count--;
                     player.Inventory[player.SelectedSlot] = slot;
                 }
             }
         }
     }
     else
     {
         world.OnDestroyEntity(this);
         if (player.GameMode != GameMode.Creative)
         {
             var spawnPosition = Position + new Vector3(0.5);
             switch (Direction)
             {
                 case ItemFrameDirection.North: spawnPosition += Vector3.North; break;
                 case ItemFrameDirection.South: spawnPosition += Vector3.South; break;
                 case ItemFrameDirection.East:  spawnPosition += Vector3.East;  break;
                 case ItemFrameDirection.West:  spawnPosition += Vector3.West;  break;
             }
             var frame = new ItemEntity(spawnPosition, new ItemStack(new ItemFrameItem()));
             var item = new ItemEntity(spawnPosition, Item);
             frame.ApplyRandomVelocity();
             item.ApplyRandomVelocity();
             world.OnSpawnEntity(frame);
             world.OnSpawnEntity(item);
         }
     }
     base.UsedByEntity(world, leftClick, usedBy);
 }
Esempio n. 2
0
        public override void UsedByEntity(World world, bool leftClick, LivingEntity usedBy)
        {
            if (leftClick)
            {
                world.OnDestroyEntity(this);
            }
            var  player = usedBy as PlayerEntity;
            bool drop   = true;

            if (player != null)
            {
                if (player.GameMode == GameMode.Creative)
                {
                    drop = false;
                }
            }
            if (drop)
            {
                var item = new ItemEntity(Center, new ItemStack(new PaintingItem()));
                item.ApplyRandomVelocity();
                world.OnSpawnEntity(item);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Note: This will not correctly kill players. If you wish to kill
 /// a player, set its health to zero and EntityManager will automatically
 /// kill the player through the correct means.
 /// </summary>
 public void KillEntity(LivingEntity entity)
 {
     entity.DeathAnimationComplete += (sender, args) =>
         {
             if (entity.Health <= 0)
                 DespawnEntity(entity);
         };
     entity.Kill();
     foreach (var client in GetKnownClients(entity))
         client.SendPacket(new EntityStatusPacket(entity.Id, EntityStatus.Dead));
 }
Esempio n. 4
0
 /// <summary>
 /// Note: This will not correctly kill players. If you wish to kill
 /// a player, set its health to zero and EntityManager will automatically
 /// kill the player through the correct means.
 /// </summary>
 public void KillEntity(LivingEntity entity)
 {
     entity.DeathAnimationComplete += (sender, args) =>
     {
         if (entity.Health <= 0)
             DespawnEntity(entity);
     };
     if (entity is PlayerEntity)
     {
         var player = entity as PlayerEntity;
         SpawnInventoryEntities(player);
         server.OnPlayerDeath(new PlayerDeathEventArgs(player.LastDamageType, player, player.LastAttackingEntity));
     }
     entity.Kill();
     foreach (var client in GetKnownClients(entity))
         client.SendPacket(new EntityStatusPacket(entity.Id, EntityStatusPacket.EntityStatus.Dead));
 }
Esempio n. 5
0
 public virtual void UsedByEntity(World world, bool leftClick, LivingEntity usedBy)
 {
 }
Esempio n. 6
0
 public virtual void UsedByEntity(World world, bool leftClick, LivingEntity usedBy)
 {
 }
Esempio n. 7
0
 public override void UsedByEntity(World world, bool leftClick, LivingEntity usedBy)
 {
     if (leftClick)
         world.OnDestroyEntity(this);
     var player = usedBy as PlayerEntity;
     bool drop = true;
     if (player != null)
     {
         if (player.GameMode == GameMode.Creative)
             drop = false;
     }
     if (drop)
     {
         var item = new ItemEntity(Center, new ItemStack(new PaintingItem()));
         item.ApplyRandomVelocity();
         world.OnSpawnEntity(item);
     }
 }