public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords) { var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face); Mob mob = null; EntityType type = (EntityType)Metadata; switch (type) { case EntityType.Chicken: mob = new Chicken(world); break; case EntityType.Cow: mob = new Cow(world); break; case EntityType.Pig: mob = new Pig(world); break; case EntityType.Sheep: mob = new Sheep(world); break; case EntityType.Wolf: mob = new Wolf(world); break; case EntityType.Npc: mob = new Villager(world); break; case EntityType.MushroomCow: mob = new MushroomCow(world); break; case EntityType.Squid: mob = new Squid(world); break; case EntityType.Rabbit: mob = new Rabbit(world); break; case EntityType.Bat: mob = new Bat(world); break; case EntityType.IronGolem: mob = new IronGolem(world); break; case EntityType.SnowGolem: mob = new SnowGolem(world); break; case EntityType.Ocelot: mob = new Ocelot(world); break; case EntityType.Zombie: mob = new Zombie(world); break; case EntityType.Creeper: mob = new Creeper(world); break; case EntityType.Skeleton: mob = new Skeleton(world); break; case EntityType.Spider: mob = new Spider(world); break; case EntityType.ZombiePigman: mob = new ZombiePigman(world); break; case EntityType.Slime: mob = new Slime(world); break; case EntityType.Enderman: mob = new Enderman(world); break; case EntityType.Silverfish: mob = new Silverfish(world); break; case EntityType.CaveSpider: mob = new CaveSpider(world); break; case EntityType.Ghast: mob = new Ghast(world); break; case EntityType.MagmaCube: mob = new MagmaCube(world); break; case EntityType.Blaze: mob = new Blaze(world); break; case EntityType.ZombieVillager: mob = new ZombieVillager(world); break; case EntityType.Witch: mob = new Witch(world); break; } if (mob == null) { return; } mob.KnownPosition = new PlayerLocation(coordinates.X, coordinates.Y, coordinates.Z); mob.SpawnEntity(); Log.WarnFormat("Player {0} spawned Mob #{1}.", player.Username, Metadata); }
public void Summon(Player player, EntityTypeEnum entityType, bool noAi = true, BlockPos spawnPos = null) { EntityType petType; try { petType = (EntityType)Enum.Parse(typeof(EntityType), entityType.Value, true); } catch (ArgumentException e) { return; } if (!Enum.IsDefined(typeof(EntityType), petType)) { player.SendMessage("No entity found"); return; } var coordinates = player.KnownPosition; if (spawnPos != null) { if (spawnPos.XRelative) { coordinates.X += spawnPos.X; } else { coordinates.X = spawnPos.X; } if (spawnPos.YRelative) { coordinates.Y += spawnPos.Y; } else { coordinates.Y = spawnPos.Y; } if (spawnPos.ZRelative) { coordinates.Z += spawnPos.Z; } else { coordinates.Z = spawnPos.Z; } } var world = player.Level; Mob mob = null; Entity entity = null; EntityType type = (EntityType)(int)petType; switch (type) { case EntityType.Chicken: mob = new Chicken(world); break; case EntityType.Cow: mob = new Cow(world); break; case EntityType.Pig: mob = new Pig(world); break; case EntityType.Sheep: mob = new Sheep(world); break; case EntityType.Wolf: mob = new Wolf(world) { Owner = player }; break; case EntityType.Villager: mob = new Villager(world); break; case EntityType.MushroomCow: mob = new MushroomCow(world); break; case EntityType.Squid: mob = new Squid(world); break; case EntityType.Rabbit: mob = new Rabbit(world); break; case EntityType.Bat: mob = new Bat(world); break; case EntityType.IronGolem: mob = new IronGolem(world); break; case EntityType.SnowGolem: mob = new SnowGolem(world); break; case EntityType.Ocelot: mob = new Ocelot(world); break; case EntityType.Zombie: mob = new Zombie(world); break; case EntityType.Creeper: mob = new Creeper(world); break; case EntityType.Skeleton: mob = new Skeleton(world); break; case EntityType.Spider: mob = new Spider(world); break; case EntityType.ZombiePigman: mob = new ZombiePigman(world); break; case EntityType.Slime: mob = new Slime(world); break; case EntityType.Enderman: mob = new Enderman(world); break; case EntityType.Silverfish: mob = new Silverfish(world); break; case EntityType.CaveSpider: mob = new CaveSpider(world); break; case EntityType.Ghast: mob = new Ghast(world); break; case EntityType.MagmaCube: mob = new MagmaCube(world); break; case EntityType.Blaze: mob = new Blaze(world); break; case EntityType.ZombieVillager: mob = new ZombieVillager(world); break; case EntityType.Witch: mob = new Witch(world); break; case EntityType.Stray: mob = new Stray(world); break; case EntityType.Husk: mob = new Husk(world); break; case EntityType.WitherSkeleton: mob = new WitherSkeleton(world); break; case EntityType.Guardian: mob = new Guardian(world); break; case EntityType.ElderGuardian: mob = new ElderGuardian(world); break; case EntityType.Horse: var random = new Random(); mob = new Horse(world, random.NextDouble() < 0.10, random); break; case EntityType.PolarBear: mob = new PolarBear(world); break; case EntityType.Shulker: mob = new Shulker(world); break; case EntityType.Dragon: mob = new Dragon(world); break; case EntityType.SkeletonHorse: mob = new SkeletonHorse(world); break; case EntityType.Wither: mob = new Wither(world); break; case EntityType.Evoker: mob = new Evoker(world); break; case EntityType.Vindicator: mob = new Vindicator(world); break; case EntityType.Vex: mob = new Vex(world); break; case EntityType.Npc: if (Config.GetProperty("EnableEdu", false)) { mob = new Npc(world); } else { mob = new PlayerMob("test", world); } break; case EntityType.Boat: entity = new Boat(world); break; } if (mob != null) { mob.NoAi = noAi; var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f; mob.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw); mob.SpawnEntity(); } else if (entity != null) { entity.NoAi = noAi; var direction = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f; entity.KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw, coordinates.Yaw); entity.SpawnEntity(); } }
public override void PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords) { Log.WarnFormat("Player {0} trying to spawn Mob #{1}.", player.Username, Metadata); var coordinates = GetNewCoordinatesFromFace(blockCoordinates, face); Mob mob = null; EntityType type = (EntityType)Metadata; switch (type) { case EntityType.Chicken: mob = new Chicken(world); break; case EntityType.Cow: mob = new Cow(world); break; case EntityType.Pig: mob = new Pig(world); break; case EntityType.Sheep: mob = new Sheep(world); break; case EntityType.Wolf: mob = new Wolf(world) { Owner = player }; break; case EntityType.Villager: mob = new Villager(world); break; case EntityType.MushroomCow: mob = new MushroomCow(world); break; case EntityType.Squid: mob = new Squid(world); break; case EntityType.Rabbit: mob = new Rabbit(world); break; case EntityType.Bat: mob = new Bat(world); break; case EntityType.IronGolem: mob = new IronGolem(world); break; case EntityType.SnowGolem: mob = new SnowGolem(world); break; case EntityType.Ocelot: mob = new Ocelot(world); break; case EntityType.Zombie: mob = new Zombie(world); break; case EntityType.Creeper: mob = new Creeper(world); break; case EntityType.Skeleton: mob = new Skeleton(world); break; case EntityType.Spider: mob = new Spider(world); break; case EntityType.ZombiePigman: mob = new ZombiePigman(world); break; case EntityType.Slime: mob = new Slime(world); break; case EntityType.Enderman: mob = new Enderman(world); break; case EntityType.Silverfish: mob = new Silverfish(world); break; case EntityType.CaveSpider: mob = new CaveSpider(world); break; case EntityType.Ghast: mob = new Ghast(world); break; case EntityType.MagmaCube: mob = new MagmaCube(world); break; case EntityType.Blaze: mob = new Blaze(world); break; case EntityType.ZombieVillager: mob = new ZombieVillager(world); break; case EntityType.Witch: mob = new Witch(world); break; case EntityType.Stray: mob = new Stray(world); break; case EntityType.Husk: mob = new Husk(world); break; case EntityType.WitherSkeleton: mob = new WitherSkeleton(world); break; case EntityType.Guardian: mob = new Guardian(world); break; case EntityType.ElderGuardian: mob = new ElderGuardian(world); break; case EntityType.Horse: var random = new Random(); mob = new Horse(world, random.NextDouble() < 0.10, random); break; case EntityType.PolarBear: mob = new PolarBear(world); break; case EntityType.Shulker: mob = new Shulker(world); break; case EntityType.Dragon: mob = new Dragon(world); break; case EntityType.SkeletonHorse: mob = new SkeletonHorse(world); break; case EntityType.Wither: mob = new Wither(world); break; case EntityType.Evoker: mob = new Evoker(world); break; case EntityType.Vindicator: mob = new Vindicator(world); break; case EntityType.Vex: mob = new Vex(world); break; case EntityType.Npc: mob = new PlayerMob("test", world); break; } if (mob == null) { return; } mob.KnownPosition = new PlayerLocation(coordinates.X, coordinates.Y, coordinates.Z); mob.NoAi = true; mob.SpawnEntity(); Log.WarnFormat("Player {0} spawned Mob #{1}.", player.Username, Metadata); if (player.GameMode == GameMode.Survival) { var itemInHand = player.Inventory.GetItemInHand(); itemInHand.Count--; player.Inventory.SetInventorySlot(player.Inventory.InHandSlot, itemInHand); } }
public static Entity Create(this EntityType entityType, Level world) { Entity entity = null; switch (entityType) { case EntityType.None: return(null); case EntityType.Chicken: entity = new Chicken(world); break; case EntityType.Cow: entity = new Cow(world); break; case EntityType.Pig: entity = new Pig(world); break; case EntityType.Sheep: entity = new Sheep(world); break; case EntityType.Wolf: entity = new Wolf(world); break; case EntityType.Villager: entity = new Villager(world); break; case EntityType.MushroomCow: entity = new MushroomCow(world); break; case EntityType.Squid: entity = new Squid(world); break; case EntityType.Rabbit: entity = new Rabbit(world); break; case EntityType.Bat: entity = new Bat(world); break; case EntityType.IronGolem: entity = new IronGolem(world); break; case EntityType.SnowGolem: entity = new SnowGolem(world); break; case EntityType.Ocelot: entity = new Ocelot(world); break; case EntityType.Zombie: entity = new Zombie(world); break; case EntityType.Creeper: entity = new Creeper(world); break; case EntityType.Skeleton: entity = new Skeleton(world); break; case EntityType.Spider: entity = new Spider(world); break; case EntityType.ZombiePigman: entity = new ZombiePigman(world); break; case EntityType.Slime: entity = new Slime(world); break; case EntityType.Enderman: entity = new Enderman(world); break; case EntityType.Silverfish: entity = new Silverfish(world); break; case EntityType.CaveSpider: entity = new CaveSpider(world); break; case EntityType.Ghast: entity = new Ghast(world); break; case EntityType.MagmaCube: entity = new MagmaCube(world); break; case EntityType.Blaze: entity = new Blaze(world); break; case EntityType.ZombieVillager: entity = new ZombieVillager(world); break; case EntityType.Witch: entity = new Witch(world); break; case EntityType.Stray: entity = new Stray(world); break; case EntityType.Husk: entity = new Husk(world); break; case EntityType.WitherSkeleton: entity = new WitherSkeleton(world); break; case EntityType.Guardian: entity = new Guardian(world); break; case EntityType.ElderGuardian: entity = new ElderGuardian(world); break; case EntityType.Horse: var random = new Random(); entity = new Horse(world, random.NextDouble() < 0.10, random); break; case EntityType.PolarBear: entity = new PolarBear(world); break; case EntityType.Shulker: entity = new Shulker(world); break; case EntityType.Dragon: entity = new Dragon(world); break; case EntityType.SkeletonHorse: entity = new SkeletonHorse(world); break; case EntityType.Wither: entity = new Wither(world); break; case EntityType.Evoker: entity = new Evoker(world); break; case EntityType.Vindicator: entity = new Vindicator(world); break; case EntityType.Vex: entity = new Vex(world); break; case EntityType.Npc: entity = new PlayerMob("test", world); break; default: return(null); } return(entity); }
public void CommandSpawnMob(MiNET.Player player, string entityName, string mobName = "", string mobScale = "") { if (!(player is SkyPlayer skyPlayer) || !skyPlayer.PlayerGroup.IsAtLeast(PlayerGroup.Admin)) { player.SendMessage("§c§l(!)§r §cYou do not have permission for this command."); return; } entityName = entityName.ToLower(); entityName = entityName.Substring(0, 1).ToUpper() + entityName.Substring(1); if (!Enum.TryParse(entityName, out EntityType entityType)) { player.SendMessage($"§c§l(!) §r§cUnknown EntityType '{entityName}'"); return; } Level level = player.Level; Mob mob = null; switch (entityType) { case EntityType.Chicken: mob = new Chicken(level); break; case EntityType.Cow: mob = new Cow(level); break; case EntityType.Pig: mob = new Pig(level); break; case EntityType.Sheep: mob = new Sheep(level); break; case EntityType.Wolf: mob = new Wolf(level) { Owner = player }; break; case EntityType.Villager: mob = new Villager(level); break; case EntityType.MushroomCow: mob = new MushroomCow(level); break; case EntityType.Squid: mob = new Squid(level); break; case EntityType.Rabbit: mob = new Rabbit(level); break; case EntityType.Bat: mob = new Bat(level); break; case EntityType.IronGolem: mob = new IronGolem(level); break; case EntityType.SnowGolem: mob = new SnowGolem(level); break; case EntityType.Ocelot: mob = new Ocelot(level); break; case EntityType.Zombie: mob = new Zombie(level); break; case EntityType.Creeper: mob = new Creeper(level); break; case EntityType.Skeleton: mob = new Skeleton(level); break; case EntityType.Spider: mob = new Spider(level); break; case EntityType.ZombiePigman: mob = new ZombiePigman(level); break; case EntityType.Slime: mob = new MiNET.Entities.Hostile.Slime(level); break; case EntityType.Enderman: mob = new Enderman(level); break; case EntityType.Silverfish: mob = new Silverfish(level); break; case EntityType.CaveSpider: mob = new CaveSpider(level); break; case EntityType.Ghast: mob = new Ghast(level); break; case EntityType.MagmaCube: mob = new MagmaCube(level); break; case EntityType.Blaze: mob = new Blaze(level); break; case EntityType.ZombieVillager: mob = new ZombieVillager(level); break; case EntityType.Witch: mob = new Witch(level); break; case EntityType.Stray: mob = new Stray(level); break; case EntityType.Husk: mob = new Husk(level); break; case EntityType.WitherSkeleton: mob = new WitherSkeleton(level); break; case EntityType.Guardian: mob = new Guardian(level); break; case EntityType.ElderGuardian: mob = new ElderGuardian(level); break; case EntityType.Horse: mob = new Horse(level); break; case EntityType.PolarBear: mob = new PolarBear(level); break; case EntityType.Shulker: mob = new Shulker(level); break; case EntityType.Dragon: mob = new Dragon(level); break; case EntityType.SkeletonHorse: mob = new SkeletonHorse(level); break; case EntityType.Wither: mob = new Wither(level); break; case EntityType.Evoker: mob = new Evoker(level); break; case EntityType.Vindicator: mob = new Vindicator(level); break; case EntityType.Vex: mob = new Vex(level); break; case EntityType.Npc: mob = new PlayerMob("test", level); break; } if (!String.IsNullOrEmpty(mobName)) { mob.NameTag = mobName.Replace("&", "§"); mob.HideNameTag = false; mob.IsAlwaysShowName = true; } if (!String.IsNullOrEmpty(mobScale)) { try { mob.Scale = Double.Parse(mobScale); } catch (Exception e) { Console.WriteLine(e); throw; } } mob.KnownPosition = (PlayerLocation)player.KnownPosition.Clone(); mob.SpawnEntity(); player.SendMessage($"§e§l(!) §r§eSpawned new {entityType}"); }