public virtual void Place(IStructBlock baseBlock, BlockFace face) { if (!CanBePlacedOn(baseBlock, face)) { return; } var player = Owner.GetPlayer() as Player; byte bType = GetBlockToPlace(baseBlock, face); byte bMetaData = (byte)Durability; var coordsFromFace = UniversalCoords.FromFace(baseBlock.Coords, face); var bBlock = new StructBlock(coordsFromFace, bType, bMetaData, player.World); BlockHelper.Instance.CreateBlockInstance(bType).Place(player, bBlock, baseBlock, face); //Owner.GetPlayer().GetInventory().RemoveItem(Slot); }
public override void Use(IStructBlock baseBlock, BlockFace face) { var player = Owner.GetPlayer() as Player; var newBlockCoords = UniversalCoords.FromFace(baseBlock.Coords, face); if (Durability != 15) { return; } if (baseBlock.Type == (byte)BlockData.Blocks.Red_Mushroom || baseBlock.Type == (byte)BlockData.Blocks.Brown_Mushroom) { var baseMushroom = (BlockBaseMushroom)BlockHelper.Instance.CreateBlockInstance(baseBlock.Type); baseMushroom.Fertilize(player, (StructBlock)baseBlock); } base.Use(baseBlock, face); }
public void Use(IClient iClient, string commandName, string[] tokens) { Client client = iClient as Client; Vector3 facing = new Vector3(client.Owner.Yaw, client.Owner.Pitch); Vector3 start = new Vector3(client.Owner.Position.X, client.Owner.Position.Y + client.Owner.EyeHeight, client.Owner.Position.Z); Vector3 end = facing * 100 + start; if (end.Y < 0) { end = end * (Math.Abs(end.Y) / start.Y); end.Y = 0; } RayTraceHitBlock hit = client.Owner.World.RayTraceBlocks(new AbsWorldCoords(start), new AbsWorldCoords(end)); if (hit != null) { if (tokens.Length == 0) { } else { MobType mobType; if (Enum.TryParse <MobType>(tokens[0], true, out mobType)) { Mob theMob = MobFactory.Instance.CreateMob(client.Owner.World, client.Server, mobType, null) as Mob; theMob.Position = new AbsWorldCoords(UniversalCoords.FromFace(hit.TargetBlock, hit.FaceHit)); client.Server.AddEntity(theMob); } else if (tokens[0] == "update") { UniversalCoords coords = UniversalCoords.FromAbsWorld(client.Owner.Position); foreach (EntityBase entity in client.Server.GetNearbyEntitiesInternal(client.Owner.World, coords)) { entity.TeleportTo(entity.Position); } } else if (tokens[0] == "path") { PathFinder finder = new PathFinder(client.Owner.World); var path = finder.CreatePathToCoordinate(client.Owner, new AbsWorldCoords(UniversalCoords.FromFace(hit.TargetBlock, hit.FaceHit))); if (path != null) { foreach (var item in path) { client.Owner.World.SetBlockAndData(item.Coordinate, (byte) Chraft.Utilities.Blocks.BlockData.Blocks. Redstone_Torch_On, 0); } } else { client.SendMessage(String.Format("Unable to determine path to '{0}'", hit.TargetBlock.Offset(0, 1, 0))); } } else { client.SendMessage(String.Format("Unrecognised mob type: '{0}'", tokens[0])); } } } }